forked from Minki/linux
net: mscc: ocelot: move ocelot_port_private :: chip_port to ocelot_port :: index
Currently the ocelot switch lib is unaware of the index of a struct ocelot_port, since that is kept in the encapsulating structures of outer drivers (struct dsa_port :: index, struct ocelot_port_private :: chip_port). With the upcoming increase in complexity associated with assigning DSA tag_8021q CPU ports to certain user ports, it becomes necessary for the switch lib to be able to retrieve the index of a certain ocelot_port. Therefore, introduce a new u8 to ocelot_port (same size as the chip_port used by the ocelot switchdev driver) and rework the existing code to populate and use it. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
6d0be60047
commit
7e708760fc
@ -1249,6 +1249,7 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
|
||||
ocelot_port->phy_mode = port_phy_modes[port];
|
||||
ocelot_port->ocelot = ocelot;
|
||||
ocelot_port->target = target;
|
||||
ocelot_port->index = port;
|
||||
ocelot->ports[port] = ocelot_port;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,6 @@ struct ocelot_port_private {
|
||||
struct net_device *dev;
|
||||
struct phylink *phylink;
|
||||
struct phylink_config phylink_config;
|
||||
u8 chip_port;
|
||||
struct ocelot_port_tc tc;
|
||||
};
|
||||
|
||||
|
@ -191,7 +191,7 @@ static struct devlink_port *ocelot_get_devlink_port(struct net_device *dev)
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return &ocelot->devlink_ports[port];
|
||||
}
|
||||
@ -201,7 +201,7 @@ int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv,
|
||||
bool ingress)
|
||||
{
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
if (!ingress)
|
||||
return -EOPNOTSUPP;
|
||||
@ -226,7 +226,7 @@ static int ocelot_setup_tc_cls_matchall_police(struct ocelot_port_private *priv,
|
||||
struct flow_action_entry *action = &f->rule->action.entries[0];
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
struct ocelot_policer pol = { 0 };
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int err;
|
||||
|
||||
if (!ingress) {
|
||||
@ -288,8 +288,8 @@ static int ocelot_setup_tc_cls_matchall_mirred(struct ocelot_port_private *priv,
|
||||
|
||||
other_priv = netdev_priv(a->dev);
|
||||
|
||||
err = ocelot_port_mirror_add(ocelot, priv->chip_port,
|
||||
other_priv->chip_port, ingress, extack);
|
||||
err = ocelot_port_mirror_add(ocelot, priv->port.index,
|
||||
other_priv->port.index, ingress, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -306,7 +306,7 @@ static int ocelot_del_tc_cls_matchall_police(struct ocelot_port_private *priv,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int err;
|
||||
|
||||
err = ocelot_port_policer_del(ocelot, port);
|
||||
@ -327,7 +327,7 @@ static int ocelot_del_tc_cls_matchall_mirred(struct ocelot_port_private *priv,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_port_mirror_del(ocelot, port, ingress);
|
||||
|
||||
@ -497,7 +497,7 @@ static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int ret;
|
||||
|
||||
ret = ocelot_vlan_add(ocelot, port, vid, pvid, untagged);
|
||||
@ -515,7 +515,7 @@ static int ocelot_vlan_vid_del(struct net_device *dev, u16 vid)
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int ret;
|
||||
|
||||
/* 8021q removes VID 0 on module unload for all interfaces
|
||||
@ -558,7 +558,7 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
u32 rew_op = 0;
|
||||
|
||||
if (!static_branch_unlikely(&ocelot_fdma_enabled) &&
|
||||
@ -724,7 +724,7 @@ static void ocelot_get_stats64(struct net_device *dev,
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
/* Configure the port to read the stats from */
|
||||
ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port),
|
||||
@ -767,7 +767,7 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge);
|
||||
}
|
||||
@ -780,7 +780,7 @@ static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge);
|
||||
}
|
||||
@ -798,7 +798,7 @@ static int ocelot_port_fdb_dump(struct sk_buff *skb,
|
||||
.cb = cb,
|
||||
.idx = *idx,
|
||||
};
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int ret;
|
||||
|
||||
ret = ocelot_fdb_dump(ocelot, port, ocelot_port_fdb_do_dump, &dump);
|
||||
@ -840,7 +840,7 @@ static int ocelot_set_features(struct net_device *dev,
|
||||
netdev_features_t changed = dev->features ^ features;
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
if ((dev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) &&
|
||||
priv->tc.offload_cnt) {
|
||||
@ -859,7 +859,7 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
/* If the attached PHY device isn't capable of timestamping operations,
|
||||
* use our own (when possible).
|
||||
@ -882,7 +882,7 @@ static int ocelot_change_mtu(struct net_device *dev, int new_mtu)
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
|
||||
ocelot_port_set_maxlen(ocelot, priv->chip_port, new_mtu);
|
||||
ocelot_port_set_maxlen(ocelot, priv->port.index, new_mtu);
|
||||
WRITE_ONCE(dev->mtu, new_mtu);
|
||||
|
||||
return 0;
|
||||
@ -935,7 +935,7 @@ int ocelot_netdev_to_port(struct net_device *dev)
|
||||
|
||||
priv = netdev_priv(dev);
|
||||
|
||||
return priv->chip_port;
|
||||
return priv->port.index;
|
||||
}
|
||||
|
||||
static void ocelot_port_get_strings(struct net_device *netdev, u32 sset,
|
||||
@ -943,7 +943,7 @@ static void ocelot_port_get_strings(struct net_device *netdev, u32 sset,
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(netdev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_get_strings(ocelot, port, sset, data);
|
||||
}
|
||||
@ -954,7 +954,7 @@ static void ocelot_port_get_ethtool_stats(struct net_device *dev,
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_get_ethtool_stats(ocelot, port, data);
|
||||
}
|
||||
@ -963,7 +963,7 @@ static int ocelot_port_get_sset_count(struct net_device *dev, int sset)
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_get_sset_count(ocelot, port, sset);
|
||||
}
|
||||
@ -973,7 +973,7 @@ static int ocelot_port_get_ts_info(struct net_device *dev,
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
if (!ocelot->ptp)
|
||||
return ethtool_op_get_ts_info(dev, info);
|
||||
@ -1025,7 +1025,7 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx,
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int err = 0;
|
||||
|
||||
if (ctx && ctx != priv)
|
||||
@ -1066,7 +1066,7 @@ static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack);
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ static int ocelot_port_obj_add_mdb(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_port_mdb_add(ocelot, port, mdb, ocelot_port->bridge);
|
||||
}
|
||||
@ -1103,7 +1103,7 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_port_mdb_del(ocelot, port, mdb, ocelot_port->bridge);
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ static int ocelot_port_obj_mrp_add(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_mrp_add(ocelot, port, mrp);
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ static int ocelot_port_obj_mrp_del(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_mrp_del(ocelot, port, mrp);
|
||||
}
|
||||
@ -1137,7 +1137,7 @@ ocelot_port_obj_mrp_add_ring_role(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_mrp_add_ring_role(ocelot, port, mrp);
|
||||
}
|
||||
@ -1149,7 +1149,7 @@ ocelot_port_obj_mrp_del_ring_role(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
return ocelot_mrp_del_ring_role(ocelot, port, mrp);
|
||||
}
|
||||
@ -1314,7 +1314,7 @@ static int ocelot_netdevice_bridge_join(struct net_device *dev,
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int bridge_num, err;
|
||||
|
||||
bridge_num = ocelot_bridge_num_get(ocelot, bridge);
|
||||
@ -1366,7 +1366,7 @@ static int ocelot_netdevice_bridge_leave(struct net_device *dev,
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int bridge_num = ocelot_port->bridge_num;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int err;
|
||||
|
||||
err = ocelot_switchdev_unsync(ocelot, port);
|
||||
@ -1388,7 +1388,7 @@ static int ocelot_netdevice_lag_join(struct net_device *dev,
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
struct net_device *bridge_dev;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
int err;
|
||||
|
||||
err = ocelot_port_lag_join(ocelot, port, bond, info);
|
||||
@ -1431,7 +1431,7 @@ static int ocelot_netdevice_lag_leave(struct net_device *dev,
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
struct net_device *bridge_dev;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_port_lag_leave(ocelot, port, bond);
|
||||
|
||||
@ -1545,7 +1545,7 @@ ocelot_netdevice_changelowerstate(struct net_device *dev,
|
||||
bool is_active = info->link_up && info->tx_enabled;
|
||||
struct ocelot_port *ocelot_port = &priv->port;
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
if (!ocelot_port->bond)
|
||||
return NOTIFY_DONE;
|
||||
@ -1693,7 +1693,7 @@ static void vsc7514_phylink_mac_link_down(struct phylink_config *config,
|
||||
struct net_device *ndev = to_net_dev(config->dev);
|
||||
struct ocelot_port_private *priv = netdev_priv(ndev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface,
|
||||
OCELOT_MAC_QUIRKS);
|
||||
@ -1709,7 +1709,7 @@ static void vsc7514_phylink_mac_link_up(struct phylink_config *config,
|
||||
struct net_device *ndev = to_net_dev(config->dev);
|
||||
struct ocelot_port_private *priv = netdev_priv(ndev);
|
||||
struct ocelot *ocelot = priv->port.ocelot;
|
||||
int port = priv->chip_port;
|
||||
int port = priv->port.index;
|
||||
|
||||
ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode,
|
||||
interface, speed, duplex,
|
||||
@ -1823,9 +1823,9 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
|
||||
SET_NETDEV_DEV(dev, ocelot->dev);
|
||||
priv = netdev_priv(dev);
|
||||
priv->dev = dev;
|
||||
priv->chip_port = port;
|
||||
ocelot_port = &priv->port;
|
||||
ocelot_port->ocelot = ocelot;
|
||||
ocelot_port->index = port;
|
||||
ocelot_port->target = target;
|
||||
ocelot->ports[port] = ocelot_port;
|
||||
|
||||
|
@ -675,6 +675,8 @@ struct ocelot_port {
|
||||
u8 ptp_cmd;
|
||||
u8 ts_id;
|
||||
|
||||
u8 index;
|
||||
|
||||
u8 stp_state;
|
||||
bool vlan_aware;
|
||||
bool is_dsa_8021q_cpu;
|
||||
|
Loading…
Reference in New Issue
Block a user