.cls_flower_stats       = felix_cls_flower_stats,
        .port_setup_tc          = felix_port_setup_tc,
 };
+
+struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port)
+{
+       struct felix *felix = ocelot_to_felix(ocelot);
+       struct dsa_switch *ds = felix->ds;
+
+       if (!dsa_is_user_port(ds, port))
+               return NULL;
+
+       return dsa_to_port(ds, port)->slave;
+}
+
+int felix_netdev_to_port(struct net_device *dev)
+{
+       struct dsa_port *dp;
+
+       dp = dsa_port_from_netdev(dev);
+       if (IS_ERR(dp))
+               return -EINVAL;
+
+       return dp->index;
+}
 
        resource_size_t                 imdio_base;
 };
 
+struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
+int felix_netdev_to_port(struct net_device *dev);
+
 #endif
 
 static const struct ocelot_ops vsc9959_ops = {
        .reset                  = vsc9959_reset,
        .wm_enc                 = vsc9959_wm_enc,
+       .port_to_netdev         = felix_port_to_netdev,
+       .netdev_to_port         = felix_netdev_to_port,
 };
 
 static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
 
 static const struct ocelot_ops vsc9953_ops = {
        .reset                  = vsc9953_reset,
        .wm_enc                 = vsc9953_wm_enc,
+       .port_to_netdev         = felix_port_to_netdev,
+       .netdev_to_port         = felix_netdev_to_port,
 };
 
 static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
 
                         struct net_device *bond);
 void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
                           struct net_device *bond);
+struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
+int ocelot_netdev_to_port(struct net_device *dev);
 
 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
 
        .ndo_do_ioctl                   = ocelot_ioctl,
 };
 
+struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port)
+{
+       struct ocelot_port *ocelot_port = ocelot->ports[port];
+       struct ocelot_port_private *priv;
+
+       if (!ocelot_port)
+               return NULL;
+
+       priv = container_of(ocelot_port, struct ocelot_port_private, port);
+
+       return priv->dev;
+}
+
+static bool ocelot_port_dev_check(const struct net_device *dev)
+{
+       return dev->netdev_ops == &ocelot_port_netdev_ops;
+}
+
+int ocelot_netdev_to_port(struct net_device *dev)
+{
+       struct ocelot_port_private *priv;
+
+       if (!dev || !ocelot_port_dev_check(dev))
+               return -EINVAL;
+
+       priv = netdev_priv(dev);
+
+       return priv->chip_port;
+}
+
 static void ocelot_port_get_strings(struct net_device *netdev, u32 sset,
                                    u8 *data)
 {
 
 static const struct ocelot_ops ocelot_ops = {
        .reset                  = ocelot_reset,
        .wm_enc                 = ocelot_wm_enc,
+       .port_to_netdev         = ocelot_port_to_netdev,
+       .netdev_to_port         = ocelot_netdev_to_port,
 };
 
 static const struct vcap_field vsc7514_vcap_es0_keys[] = {
 
 struct ocelot;
 
 struct ocelot_ops {
+       struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
+       int (*netdev_to_port)(struct net_device *dev);
        int (*reset)(struct ocelot *ocelot);
        u16 (*wm_enc)(u16 value);
 };