net: Introduce ndo_get_port_parent_id()
In preparation for getting rid of switchdev_ops, create a dedicated NDO operation for getting the port's parent identifier. There are essentially two classes of drivers that need to implement getting the port's parent ID which are VF/PF drivers with a built-in switch, and pure switchdev drivers such as mlxsw, ocelot, dsa etc. We introduce a helper function: dev_get_port_parent_id() which supports recursion into the lower devices to obtain the first port's parent ID. Convert the bridge, core and ipv4 multicast routing code to check for such ndo_get_port_parent_id() and call the helper function when valid before falling back to switchdev_port_attr_get(). This will allow us to convert all relevant drivers in one go instead of having to implement both switchdev_port_attr_get() and ndo_get_port_parent_id() operations, then get rid of switchdev_port_attr_get(). Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
47b98039fb
commit
d6abc59694
@@ -1188,6 +1188,10 @@ struct dev_ifalias {
|
||||
* not implement this, it is assumed that the hw is not able to have
|
||||
* multiple net devices on single physical port.
|
||||
*
|
||||
* int (*ndo_get_port_parent_id)(struct net_device *dev,
|
||||
* struct netdev_phys_item_id *ppid)
|
||||
* Called to get the parent ID of the physical port of this device.
|
||||
*
|
||||
* void (*ndo_udp_tunnel_add)(struct net_device *dev,
|
||||
* struct udp_tunnel_info *ti);
|
||||
* Called by UDP tunnel to notify a driver about the UDP port and socket
|
||||
@@ -1412,6 +1416,8 @@ struct net_device_ops {
|
||||
bool new_carrier);
|
||||
int (*ndo_get_phys_port_id)(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid);
|
||||
int (*ndo_get_port_parent_id)(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid);
|
||||
int (*ndo_get_phys_port_name)(struct net_device *dev,
|
||||
char *name, size_t len);
|
||||
void (*ndo_udp_tunnel_add)(struct net_device *dev,
|
||||
@@ -3651,6 +3657,9 @@ int dev_get_phys_port_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid);
|
||||
int dev_get_phys_port_name(struct net_device *dev,
|
||||
char *name, size_t len);
|
||||
int dev_get_port_parent_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid, bool recurse);
|
||||
bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
|
||||
int dev_change_proto_down(struct net_device *dev, bool proto_down);
|
||||
struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again);
|
||||
struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
|
Reference in New Issue
Block a user