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().
Showing the changes to include/linux (1 of 6 files). Show all
Unified · Split
| @@ -1188,6 +1188,10 @@ struct dev_ifalias { · 1187 unmodified lines | |||
| 1188 | * not implement this, it is assumed that the hw is not able to have | 1188 | * not implement this, it is assumed that the hw is not able to have |
| 1189 | * multiple net devices on single physical port. | 1189 | * multiple net devices on single physical port. |
| 1190 | * | 1190 | * |
| 1191 | * int (*ndo_get_port_parent_id)(struct net_device *dev, | ||
| 1192 | * struct netdev_phys_item_id *ppid) | ||
| 1193 | * Called to get the parent ID of the physical port of this device. | ||
| 1194 | * | ||
| 1191 | * void (*ndo_udp_tunnel_add)(struct net_device *dev, | 1195 | * void (*ndo_udp_tunnel_add)(struct net_device *dev, |
| 1192 | * struct udp_tunnel_info *ti); | 1196 | * struct udp_tunnel_info *ti); |
| 1193 | * Called by UDP tunnel to notify a driver about the UDP port and socket | 1197 | * Called by UDP tunnel to notify a driver about the UDP port and socket |
| @@ -1412,6 +1416,8 @@ struct net_device_ops { · 218 unmodified lines | |||
| 1412 | bool new_carrier); | 1416 | bool new_carrier); |
| 1413 | int (*ndo_get_phys_port_id)(struct net_device *dev, | 1417 | int (*ndo_get_phys_port_id)(struct net_device *dev, |
| 1414 | struct netdev_phys_item_id *ppid); | 1418 | struct netdev_phys_item_id *ppid); |
| 1419 | int (*ndo_get_port_parent_id)(struct net_device *dev, | ||
| 1420 | struct netdev_phys_item_id *ppid); | ||
| 1415 | int (*ndo_get_phys_port_name)(struct net_device *dev, | 1421 | int (*ndo_get_phys_port_name)(struct net_device *dev, |
| 1416 | char *name, size_t len); | 1422 | char *name, size_t len); |
| 1417 | void (*ndo_udp_tunnel_add)(struct net_device *dev, | 1423 | void (*ndo_udp_tunnel_add)(struct net_device *dev, |
| @@ -3651,6 +3657,9 @@ int dev_get_phys_port_id(struct net_device *dev, · 2233 unmodified lines | |||
| 3651 | struct netdev_phys_item_id *ppid); | 3657 | struct netdev_phys_item_id *ppid); |
| 3652 | int dev_get_phys_port_name(struct net_device *dev, | 3658 | int dev_get_phys_port_name(struct net_device *dev, |
| 3653 | char *name, size_t len); | 3659 | char *name, size_t len); |
| 3660 | int dev_get_port_parent_id(struct net_device *dev, | ||
| 3661 | struct netdev_phys_item_id *ppid, bool recurse); | ||
| 3662 | bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b); | ||
| 3654 | int dev_change_proto_down(struct net_device *dev, bool proto_down); | 3663 | int dev_change_proto_down(struct net_device *dev, bool proto_down); |
| 3655 | struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again); | 3664 | struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again); |
| 3656 | struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, | 3665 | struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, |