Now that we have a dedicated NDO for getting a port's parent ID, get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the NDO exclusively. This is a preliminary change to getting rid of switchdev_ops eventually.
Unified · Split
| @@ -43,7 +43,6 @@ static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans) · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | enum switchdev_attr_id { |
| 45 | 45 | SWITCHDEV_ATTR_ID_UNDEFINED, |
| 46 | − SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 47 | 46 | SWITCHDEV_ATTR_ID_PORT_STP_STATE, |
| 48 | 47 | SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS, |
| 49 | 48 | SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT, |
| @@ -61,7 +60,6 @@ struct switchdev_attr { · 11 unmodified lines | ||
| 61 | 60 | void *complete_priv; |
| 62 | 61 | void (*complete)(struct net_device *dev, int err, void *priv); |
| 63 | 62 | union { |
| 64 | − struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */ | |
| 65 | 63 | u8 stp_state; /* PORT_STP_STATE */ |
| 66 | 64 | unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */ |
| 67 | 65 | unsigned long brport_flags_support; /* PORT_BRIDGE_FLAGS_SUPPORT */ |
| @@ -208,9 +206,6 @@ void switchdev_port_fwd_mark_set(struct net_device *dev, · 140 unmodified lines | ||
| 208 | 206 | struct net_device *group_dev, |
| 209 | 207 | bool joining); |
| 210 | 208 | |
| 211 | −bool switchdev_port_same_parent_id(struct net_device *a, | |
| 212 | − struct net_device *b); | |
| 213 | − | |
| 214 | 209 | int switchdev_handle_port_obj_add(struct net_device *dev, |
| 215 | 210 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 216 | 211 | bool (*check_cb)(const struct net_device *dev), |
| @@ -295,12 +290,6 @@ call_switchdev_blocking_notifiers(unsigned long val, · 78 unmodified lines | ||
| 295 | 290 | return NOTIFY_DONE; |
| 296 | 291 | } |
| 297 | 292 | |
| 298 | −static inline bool switchdev_port_same_parent_id(struct net_device *a, | |
| 299 | − struct net_device *b) | |
| 300 | −{ | |
| 301 | − return false; | |
| 302 | −} | |
| 303 | − | |
| 304 | 293 | static inline int |
| 305 | 294 | switchdev_handle_port_obj_add(struct net_device *dev, |
| 306 | 295 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| @@ -14,8 +14,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | /* dev is yet to be added to the port list. */ |
| 16 | 16 | list_for_each_entry(p, &br->port_list, list) { |
| 17 | − if (netdev_port_same_parent_id(dev, p->dev) || | |
| 18 | − switchdev_port_same_parent_id(dev, p->dev)) | |
| 17 | + if (netdev_port_same_parent_id(dev, p->dev)) | |
| 19 | 18 | return p->offload_fwd_mark; |
| 20 | 19 | } |
| 21 | 20 | |
| @@ -24,19 +23,12 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) · 2 unmodified lines | ||
| 24 | 23 | |
| 25 | 24 | int nbp_switchdev_mark_set(struct net_bridge_port *p) |
| 26 | 25 | { |
| 27 | − const struct net_device_ops *ops = p->dev->netdev_ops; | |
| 28 | − struct switchdev_attr attr = { | |
| 29 | − .orig_dev = p->dev, | |
| 30 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 31 | − }; | |
| 26 | + struct netdev_phys_item_id ppid = { }; | |
| 32 | 27 | int err; |
| 33 | 28 | |
| 34 | 29 | ASSERT_RTNL(); |
| 35 | 30 | |
| 36 | − if (ops->ndo_get_port_parent_id) | |
| 37 | − err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true); | |
| 38 | − else | |
| 39 | − err = switchdev_port_attr_get(p->dev, &attr); | |
| 31 | + err = dev_get_port_parent_id(p->dev, &ppid, true); | |
| 40 | 32 | if (err) { |
| 41 | 33 | if (err == -EOPNOTSUPP) |
| 42 | 34 | return 0; |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/capability.h> |
| 13 | 13 | #include <linux/kernel.h> |
| 14 | 14 | #include <linux/netdevice.h> |
| 15 | −#include <net/switchdev.h> | |
| 16 | 15 | #include <linux/if_arp.h> |
| 17 | 16 | #include <linux/slab.h> |
| 18 | 17 | #include <linux/sched/signal.h> |
| @@ -495,27 +494,17 @@ static ssize_t phys_switch_id_show(struct device *dev, · 476 unmodified lines | ||
| 495 | 494 | struct device_attribute *attr, char *buf) |
| 496 | 495 | { |
| 497 | 496 | struct net_device *netdev = to_net_dev(dev); |
| 498 | − const struct net_device_ops *ops = netdev->netdev_ops; | |
| 499 | 497 | ssize_t ret = -EINVAL; |
| 500 | 498 | |
| 501 | 499 | if (!rtnl_trylock()) |
| 502 | 500 | return restart_syscall(); |
| 503 | 501 | |
| 504 | 502 | if (dev_isalive(netdev)) { |
| 505 | − struct switchdev_attr attr = { | |
| 506 | − .orig_dev = netdev, | |
| 507 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 508 | − .flags = SWITCHDEV_F_NO_RECURSE, | |
| 509 | − }; | |
| 510 | − | |
| 511 | − if (ops->ndo_get_port_parent_id) | |
| 512 | − ret = dev_get_port_parent_id(netdev, &attr.u.ppid, | |
| 513 | − false); | |
| 514 | − else | |
| 515 | − ret = switchdev_port_attr_get(netdev, &attr); | |
| 503 | + struct netdev_phys_item_id ppid = { }; | |
| 504 | + | |
| 505 | + ret = dev_get_port_parent_id(netdev, &ppid, false); | |
| 516 | 506 | if (!ret) |
| 517 | − ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len, | |
| 518 | − attr.u.ppid.id); | |
| 507 | + ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id); | |
| 519 | 508 | } |
| 520 | 509 | rtnl_unlock(); |
| 521 | 510 | |
| @@ -46,7 +46,6 @@ · 45 unmodified lines | ||
| 46 | 46 | |
| 47 | 47 | #include <linux/inet.h> |
| 48 | 48 | #include <linux/netdevice.h> |
| 49 | −#include <net/switchdev.h> | |
| 50 | 49 | #include <net/ip.h> |
| 51 | 50 | #include <net/protocol.h> |
| 52 | 51 | #include <net/arp.h> |
| @@ -1146,26 +1145,17 @@ static int rtnl_phys_port_name_fill(struct sk_buff *skb, struct net_device *dev) · 1093 unmodified lines | ||
| 1146 | 1145 | |
| 1147 | 1146 | static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) |
| 1148 | 1147 | { |
| 1149 | − const struct net_device_ops *ops = dev->netdev_ops; | |
| 1148 | + struct netdev_phys_item_id ppid = { }; | |
| 1150 | 1149 | int err; |
| 1151 | − struct switchdev_attr attr = { | |
| 1152 | − .orig_dev = dev, | |
| 1153 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 1154 | − .flags = SWITCHDEV_F_NO_RECURSE, | |
| 1155 | − }; | |
| 1156 | 1150 | |
| 1157 | − if (ops->ndo_get_port_parent_id) | |
| 1158 | − err = dev_get_port_parent_id(dev, &attr.u.ppid, false); | |
| 1159 | − else | |
| 1160 | − err = switchdev_port_attr_get(dev, &attr); | |
| 1151 | + err = dev_get_port_parent_id(dev, &ppid, false); | |
| 1161 | 1152 | if (err) { |
| 1162 | 1153 | if (err == -EOPNOTSUPP) |
| 1163 | 1154 | return 0; |
| 1164 | 1155 | return err; |
| 1165 | 1156 | } |
| 1166 | 1157 | |
| 1167 | − if (nla_put(skb, IFLA_PHYS_SWITCH_ID, attr.u.ppid.id_len, | |
| 1168 | − attr.u.ppid.id)) | |
| 1158 | + if (nla_put(skb, IFLA_PHYS_SWITCH_ID, ppid.id_len, ppid.id)) | |
| 1169 | 1159 | return -EMSGSIZE; |
| 1170 | 1160 | |
| 1171 | 1161 | return 0; |
| @@ -67,7 +67,6 @@ · 66 unmodified lines | ||
| 67 | 67 | #include <net/fib_rules.h> |
| 68 | 68 | #include <linux/netconf.h> |
| 69 | 69 | #include <net/nexthop.h> |
| 70 | −#include <net/switchdev.h> | |
| 71 | 70 | |
| 72 | 71 | #include <linux/nospec.h> |
| 73 | 72 | |
| @@ -837,11 +836,8 @@ static void ipmr_update_thresholds(struct mr_table *mrt, struct mr_mfc *cache, · 763 unmodified lines | ||
| 837 | 836 | static int vif_add(struct net *net, struct mr_table *mrt, |
| 838 | 837 | struct vifctl *vifc, int mrtsock) |
| 839 | 838 | { |
| 840 | − const struct net_device_ops *ops; | |
| 839 | + struct netdev_phys_item_id ppid = { }; | |
| 841 | 840 | int vifi = vifc->vifc_vifi; |
| 842 | − struct switchdev_attr attr = { | |
| 843 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 844 | − }; | |
| 845 | 841 | struct vif_device *v = &mrt->vif_table[vifi]; |
| 846 | 842 | struct net_device *dev; |
| 847 | 843 | struct in_device *in_dev; |
| @@ -920,15 +916,10 @@ static int vif_add(struct net *net, struct mr_table *mrt, · 72 unmodified lines | ||
| 920 | 916 | vifc->vifc_flags | (!mrtsock ? VIFF_STATIC : 0), |
| 921 | 917 | (VIFF_TUNNEL | VIFF_REGISTER)); |
| 922 | 918 | |
| 923 | − attr.orig_dev = dev; | |
| 924 | − ops = dev->netdev_ops; | |
| 925 | − if (ops->ndo_get_port_parent_id && | |
| 926 | − !dev_get_port_parent_id(dev, &attr.u.ppid, true)) { | |
| 927 | − memcpy(v->dev_parent_id.id, attr.u.ppid.id, attr.u.ppid.id_len); | |
| 928 | − v->dev_parent_id.id_len = attr.u.ppid.id_len; | |
| 929 | − } else if (!switchdev_port_attr_get(dev, &attr)) { | |
| 930 | − memcpy(v->dev_parent_id.id, attr.u.ppid.id, attr.u.ppid.id_len); | |
| 931 | − v->dev_parent_id.id_len = attr.u.ppid.id_len; | |
| 919 | + err = dev_get_port_parent_id(dev, &ppid, true); | |
| 920 | + if (err == 0) { | |
| 921 | + memcpy(v->dev_parent_id.id, ppid.id, ppid.id_len); | |
| 922 | + v->dev_parent_id.id_len = ppid.id_len; | |
| 932 | 923 | } else { |
| 933 | 924 | v->dev_parent_id.id_len = 0; |
| 934 | 925 | } |
| @@ -592,26 +592,6 @@ int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, · 591 unmodified lines | ||
| 592 | 592 | } |
| 593 | 593 | EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers); |
| 594 | 594 | |
| 595 | −bool switchdev_port_same_parent_id(struct net_device *a, | |
| 596 | − struct net_device *b) | |
| 597 | −{ | |
| 598 | − struct switchdev_attr a_attr = { | |
| 599 | − .orig_dev = a, | |
| 600 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 601 | − }; | |
| 602 | − struct switchdev_attr b_attr = { | |
| 603 | − .orig_dev = b, | |
| 604 | − .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | |
| 605 | − }; | |
| 606 | − | |
| 607 | − if (switchdev_port_attr_get(a, &a_attr) || | |
| 608 | − switchdev_port_attr_get(b, &b_attr)) | |
| 609 | − return false; | |
| 610 | − | |
| 611 | − return netdev_phys_item_id_same(&a_attr.u.ppid, &b_attr.u.ppid); | |
| 612 | −} | |
| 613 | −EXPORT_SYMBOL_GPL(switchdev_port_same_parent_id); | |
| 614 | − | |
| 615 | 595 | static int __switchdev_handle_port_obj_add(struct net_device *dev, |
| 616 | 596 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 617 | 597 | bool (*check_cb)(const struct net_device *dev), |