Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: store a dsa_port in dsa_slave_priv

Store a pointer to the dsa_port structure in the dsa_slave_priv
structure, instead of the switch/port index.

This will allow to store more information such as the bridge device,
needed in DSA drivers for multi-chip configuration.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vivien Didelot and committed by
David S. Miller
afdcf151 818be848

+96 -100
+2 -6
net/dsa/dsa_priv.h
··· 25 25 struct sk_buff * (*xmit)(struct sk_buff *skb, 26 26 struct net_device *dev); 27 27 28 - /* 29 - * Which switch this port is a part of, and the port index 30 - * for this port. 31 - */ 32 - struct dsa_switch *parent; 33 - u8 port; 28 + /* DSA port data, such as switch, port index, etc. */ 29 + struct dsa_port *dp; 34 30 35 31 /* 36 32 * The phylib phy_device pointer for the PHY connected
+82 -82
net/dsa/slave.c
··· 61 61 { 62 62 struct dsa_slave_priv *p = netdev_priv(dev); 63 63 64 - return p->parent->dst->master_netdev->ifindex; 64 + return p->dp->ds->dst->master_netdev->ifindex; 65 65 } 66 66 67 67 static inline bool dsa_port_is_bridged(struct dsa_slave_priv *p) ··· 96 96 static int dsa_slave_open(struct net_device *dev) 97 97 { 98 98 struct dsa_slave_priv *p = netdev_priv(dev); 99 - struct net_device *master = p->parent->dst->master_netdev; 100 - struct dsa_switch *ds = p->parent; 99 + struct net_device *master = p->dp->ds->dst->master_netdev; 100 + struct dsa_switch *ds = p->dp->ds; 101 101 u8 stp_state = dsa_port_is_bridged(p) ? 102 102 BR_STATE_BLOCKING : BR_STATE_FORWARDING; 103 103 int err; ··· 123 123 } 124 124 125 125 if (ds->ops->port_enable) { 126 - err = ds->ops->port_enable(ds, p->port, p->phy); 126 + err = ds->ops->port_enable(ds, p->dp->index, p->phy); 127 127 if (err) 128 128 goto clear_promisc; 129 129 } 130 130 131 - dsa_port_set_stp_state(ds, p->port, stp_state); 131 + dsa_port_set_stp_state(ds, p->dp->index, stp_state); 132 132 133 133 if (p->phy) 134 134 phy_start(p->phy); ··· 151 151 static int dsa_slave_close(struct net_device *dev) 152 152 { 153 153 struct dsa_slave_priv *p = netdev_priv(dev); 154 - struct net_device *master = p->parent->dst->master_netdev; 155 - struct dsa_switch *ds = p->parent; 154 + struct net_device *master = p->dp->ds->dst->master_netdev; 155 + struct dsa_switch *ds = p->dp->ds; 156 156 157 157 if (p->phy) 158 158 phy_stop(p->phy); ··· 168 168 dev_uc_del(master, dev->dev_addr); 169 169 170 170 if (ds->ops->port_disable) 171 - ds->ops->port_disable(ds, p->port, p->phy); 171 + ds->ops->port_disable(ds, p->dp->index, p->phy); 172 172 173 - dsa_port_set_stp_state(ds, p->port, BR_STATE_DISABLED); 173 + dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_DISABLED); 174 174 175 175 return 0; 176 176 } ··· 178 178 static void dsa_slave_change_rx_flags(struct net_device *dev, int change) 179 179 { 180 180 struct dsa_slave_priv *p = netdev_priv(dev); 181 - struct net_device *master = p->parent->dst->master_netdev; 181 + struct net_device *master = p->dp->ds->dst->master_netdev; 182 182 183 183 if (change & IFF_ALLMULTI) 184 184 dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1); ··· 189 189 static void dsa_slave_set_rx_mode(struct net_device *dev) 190 190 { 191 191 struct dsa_slave_priv *p = netdev_priv(dev); 192 - struct net_device *master = p->parent->dst->master_netdev; 192 + struct net_device *master = p->dp->ds->dst->master_netdev; 193 193 194 194 dev_mc_sync(master, dev); 195 195 dev_uc_sync(master, dev); ··· 198 198 static int dsa_slave_set_mac_address(struct net_device *dev, void *a) 199 199 { 200 200 struct dsa_slave_priv *p = netdev_priv(dev); 201 - struct net_device *master = p->parent->dst->master_netdev; 201 + struct net_device *master = p->dp->ds->dst->master_netdev; 202 202 struct sockaddr *addr = a; 203 203 int err; 204 204 ··· 228 228 struct switchdev_trans *trans) 229 229 { 230 230 struct dsa_slave_priv *p = netdev_priv(dev); 231 - struct dsa_switch *ds = p->parent; 231 + struct dsa_port *dp = p->dp; 232 + struct dsa_switch *ds = dp->ds; 232 233 233 234 if (switchdev_trans_ph_prepare(trans)) { 234 235 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add) 235 236 return -EOPNOTSUPP; 236 237 237 - return ds->ops->port_vlan_prepare(ds, p->port, vlan, trans); 238 + return ds->ops->port_vlan_prepare(ds, dp->index, vlan, trans); 238 239 } 239 240 240 - ds->ops->port_vlan_add(ds, p->port, vlan, trans); 241 + ds->ops->port_vlan_add(ds, dp->index, vlan, trans); 241 242 242 243 return 0; 243 244 } ··· 247 246 const struct switchdev_obj_port_vlan *vlan) 248 247 { 249 248 struct dsa_slave_priv *p = netdev_priv(dev); 250 - struct dsa_switch *ds = p->parent; 249 + struct dsa_switch *ds = p->dp->ds; 251 250 252 251 if (!ds->ops->port_vlan_del) 253 252 return -EOPNOTSUPP; 254 253 255 - return ds->ops->port_vlan_del(ds, p->port, vlan); 254 + return ds->ops->port_vlan_del(ds, p->dp->index, vlan); 256 255 } 257 256 258 257 static int dsa_slave_port_vlan_dump(struct net_device *dev, ··· 260 259 switchdev_obj_dump_cb_t *cb) 261 260 { 262 261 struct dsa_slave_priv *p = netdev_priv(dev); 263 - struct dsa_switch *ds = p->parent; 262 + struct dsa_switch *ds = p->dp->ds; 264 263 265 264 if (ds->ops->port_vlan_dump) 266 - return ds->ops->port_vlan_dump(ds, p->port, vlan, cb); 265 + return ds->ops->port_vlan_dump(ds, p->dp->index, vlan, cb); 267 266 268 267 return -EOPNOTSUPP; 269 268 } ··· 273 272 struct switchdev_trans *trans) 274 273 { 275 274 struct dsa_slave_priv *p = netdev_priv(dev); 276 - struct dsa_switch *ds = p->parent; 275 + struct dsa_switch *ds = p->dp->ds; 277 276 278 277 if (switchdev_trans_ph_prepare(trans)) { 279 278 if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add) 280 279 return -EOPNOTSUPP; 281 280 282 - return ds->ops->port_fdb_prepare(ds, p->port, fdb, trans); 281 + return ds->ops->port_fdb_prepare(ds, p->dp->index, fdb, trans); 283 282 } 284 283 285 - ds->ops->port_fdb_add(ds, p->port, fdb, trans); 284 + ds->ops->port_fdb_add(ds, p->dp->index, fdb, trans); 286 285 287 286 return 0; 288 287 } ··· 291 290 const struct switchdev_obj_port_fdb *fdb) 292 291 { 293 292 struct dsa_slave_priv *p = netdev_priv(dev); 294 - struct dsa_switch *ds = p->parent; 293 + struct dsa_switch *ds = p->dp->ds; 295 294 int ret = -EOPNOTSUPP; 296 295 297 296 if (ds->ops->port_fdb_del) 298 - ret = ds->ops->port_fdb_del(ds, p->port, fdb); 297 + ret = ds->ops->port_fdb_del(ds, p->dp->index, fdb); 299 298 300 299 return ret; 301 300 } ··· 305 304 switchdev_obj_dump_cb_t *cb) 306 305 { 307 306 struct dsa_slave_priv *p = netdev_priv(dev); 308 - struct dsa_switch *ds = p->parent; 307 + struct dsa_switch *ds = p->dp->ds; 309 308 310 309 if (ds->ops->port_fdb_dump) 311 - return ds->ops->port_fdb_dump(ds, p->port, fdb, cb); 310 + return ds->ops->port_fdb_dump(ds, p->dp->index, fdb, cb); 312 311 313 312 return -EOPNOTSUPP; 314 313 } ··· 318 317 struct switchdev_trans *trans) 319 318 { 320 319 struct dsa_slave_priv *p = netdev_priv(dev); 321 - struct dsa_switch *ds = p->parent; 320 + struct dsa_switch *ds = p->dp->ds; 322 321 323 322 if (switchdev_trans_ph_prepare(trans)) { 324 323 if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) 325 324 return -EOPNOTSUPP; 326 325 327 - return ds->ops->port_mdb_prepare(ds, p->port, mdb, trans); 326 + return ds->ops->port_mdb_prepare(ds, p->dp->index, mdb, trans); 328 327 } 329 328 330 - ds->ops->port_mdb_add(ds, p->port, mdb, trans); 329 + ds->ops->port_mdb_add(ds, p->dp->index, mdb, trans); 331 330 332 331 return 0; 333 332 } ··· 336 335 const struct switchdev_obj_port_mdb *mdb) 337 336 { 338 337 struct dsa_slave_priv *p = netdev_priv(dev); 339 - struct dsa_switch *ds = p->parent; 338 + struct dsa_switch *ds = p->dp->ds; 340 339 341 340 if (ds->ops->port_mdb_del) 342 - return ds->ops->port_mdb_del(ds, p->port, mdb); 341 + return ds->ops->port_mdb_del(ds, p->dp->index, mdb); 343 342 344 343 return -EOPNOTSUPP; 345 344 } ··· 349 348 switchdev_obj_dump_cb_t *cb) 350 349 { 351 350 struct dsa_slave_priv *p = netdev_priv(dev); 352 - struct dsa_switch *ds = p->parent; 351 + struct dsa_switch *ds = p->dp->ds; 353 352 354 353 if (ds->ops->port_mdb_dump) 355 - return ds->ops->port_mdb_dump(ds, p->port, mdb, cb); 354 + return ds->ops->port_mdb_dump(ds, p->dp->index, mdb, cb); 356 355 357 356 return -EOPNOTSUPP; 358 357 } ··· 372 371 struct switchdev_trans *trans) 373 372 { 374 373 struct dsa_slave_priv *p = netdev_priv(dev); 375 - struct dsa_switch *ds = p->parent; 374 + struct dsa_switch *ds = p->dp->ds; 376 375 377 376 if (switchdev_trans_ph_prepare(trans)) 378 377 return ds->ops->port_stp_state_set ? 0 : -EOPNOTSUPP; 379 378 380 - dsa_port_set_stp_state(ds, p->port, attr->u.stp_state); 379 + dsa_port_set_stp_state(ds, p->dp->index, attr->u.stp_state); 381 380 382 381 return 0; 383 382 } ··· 387 386 struct switchdev_trans *trans) 388 387 { 389 388 struct dsa_slave_priv *p = netdev_priv(dev); 390 - struct dsa_switch *ds = p->parent; 389 + struct dsa_switch *ds = p->dp->ds; 391 390 392 391 /* bridge skips -EOPNOTSUPP, so skip the prepare phase */ 393 392 if (switchdev_trans_ph_prepare(trans)) 394 393 return 0; 395 394 396 395 if (ds->ops->port_vlan_filtering) 397 - return ds->ops->port_vlan_filtering(ds, p->port, 396 + return ds->ops->port_vlan_filtering(ds, p->dp->index, 398 397 attr->u.vlan_filtering); 399 398 400 399 return 0; ··· 420 419 struct switchdev_trans *trans) 421 420 { 422 421 struct dsa_slave_priv *p = netdev_priv(dev); 423 - struct dsa_switch *ds = p->parent; 422 + struct dsa_switch *ds = p->dp->ds; 424 423 unsigned long ageing_jiffies = clock_t_to_jiffies(attr->u.ageing_time); 425 424 unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies); 426 425 ··· 429 428 return 0; 430 429 431 430 /* Keep the fastest ageing time in case of multiple bridges */ 432 - ds->ports[p->port].ageing_time = ageing_time; 431 + p->dp->ageing_time = ageing_time; 433 432 ageing_time = dsa_fastest_ageing_time(ds, ageing_time); 434 433 435 434 if (ds->ops->set_ageing_time) ··· 554 553 struct net_device *br) 555 554 { 556 555 struct dsa_slave_priv *p = netdev_priv(dev); 557 - struct dsa_switch *ds = p->parent; 556 + struct dsa_switch *ds = p->dp->ds; 558 557 int ret = -EOPNOTSUPP; 559 558 560 559 p->bridge_dev = br; 561 560 562 561 if (ds->ops->port_bridge_join) 563 - ret = ds->ops->port_bridge_join(ds, p->port, br); 562 + ret = ds->ops->port_bridge_join(ds, p->dp->index, br); 564 563 565 564 return ret == -EOPNOTSUPP ? 0 : ret; 566 565 } ··· 568 567 static void dsa_slave_bridge_port_leave(struct net_device *dev) 569 568 { 570 569 struct dsa_slave_priv *p = netdev_priv(dev); 571 - struct dsa_switch *ds = p->parent; 570 + struct dsa_switch *ds = p->dp->ds; 572 571 573 572 574 573 if (ds->ops->port_bridge_leave) 575 - ds->ops->port_bridge_leave(ds, p->port); 574 + ds->ops->port_bridge_leave(ds, p->dp->index); 576 575 577 576 p->bridge_dev = NULL; 578 577 579 578 /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer, 580 579 * so allow it to be in BR_STATE_FORWARDING to be kept functional 581 580 */ 582 - dsa_port_set_stp_state(ds, p->port, BR_STATE_FORWARDING); 581 + dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_FORWARDING); 583 582 } 584 583 585 584 static int dsa_slave_port_attr_get(struct net_device *dev, 586 585 struct switchdev_attr *attr) 587 586 { 588 587 struct dsa_slave_priv *p = netdev_priv(dev); 589 - struct dsa_switch *ds = p->parent; 588 + struct dsa_switch *ds = p->dp->ds; 590 589 591 590 switch (attr->id) { 592 591 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: ··· 634 633 /* Queue the SKB for transmission on the parent interface, but 635 634 * do not modify its EtherType 636 635 */ 637 - nskb->dev = p->parent->dst->master_netdev; 636 + nskb->dev = p->dp->ds->dst->master_netdev; 638 637 dev_queue_xmit(nskb); 639 638 640 639 return NETDEV_TX_OK; ··· 681 680 static int dsa_slave_get_regs_len(struct net_device *dev) 682 681 { 683 682 struct dsa_slave_priv *p = netdev_priv(dev); 684 - struct dsa_switch *ds = p->parent; 683 + struct dsa_switch *ds = p->dp->ds; 685 684 686 685 if (ds->ops->get_regs_len) 687 - return ds->ops->get_regs_len(ds, p->port); 686 + return ds->ops->get_regs_len(ds, p->dp->index); 688 687 689 688 return -EOPNOTSUPP; 690 689 } ··· 693 692 dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p) 694 693 { 695 694 struct dsa_slave_priv *p = netdev_priv(dev); 696 - struct dsa_switch *ds = p->parent; 695 + struct dsa_switch *ds = p->dp->ds; 697 696 698 697 if (ds->ops->get_regs) 699 - ds->ops->get_regs(ds, p->port, regs, _p); 698 + ds->ops->get_regs(ds, p->dp->index, regs, _p); 700 699 } 701 700 702 701 static int dsa_slave_nway_reset(struct net_device *dev) ··· 724 723 static int dsa_slave_get_eeprom_len(struct net_device *dev) 725 724 { 726 725 struct dsa_slave_priv *p = netdev_priv(dev); 727 - struct dsa_switch *ds = p->parent; 726 + struct dsa_switch *ds = p->dp->ds; 728 727 729 728 if (ds->cd && ds->cd->eeprom_len) 730 729 return ds->cd->eeprom_len; ··· 739 738 struct ethtool_eeprom *eeprom, u8 *data) 740 739 { 741 740 struct dsa_slave_priv *p = netdev_priv(dev); 742 - struct dsa_switch *ds = p->parent; 741 + struct dsa_switch *ds = p->dp->ds; 743 742 744 743 if (ds->ops->get_eeprom) 745 744 return ds->ops->get_eeprom(ds, eeprom, data); ··· 751 750 struct ethtool_eeprom *eeprom, u8 *data) 752 751 { 753 752 struct dsa_slave_priv *p = netdev_priv(dev); 754 - struct dsa_switch *ds = p->parent; 753 + struct dsa_switch *ds = p->dp->ds; 755 754 756 755 if (ds->ops->set_eeprom) 757 756 return ds->ops->set_eeprom(ds, eeprom, data); ··· 763 762 uint32_t stringset, uint8_t *data) 764 763 { 765 764 struct dsa_slave_priv *p = netdev_priv(dev); 766 - struct dsa_switch *ds = p->parent; 765 + struct dsa_switch *ds = p->dp->ds; 767 766 768 767 if (stringset == ETH_SS_STATS) { 769 768 int len = ETH_GSTRING_LEN; ··· 773 772 strncpy(data + 2 * len, "rx_packets", len); 774 773 strncpy(data + 3 * len, "rx_bytes", len); 775 774 if (ds->ops->get_strings) 776 - ds->ops->get_strings(ds, p->port, data + 4 * len); 775 + ds->ops->get_strings(ds, p->dp->index, data + 4 * len); 777 776 } 778 777 } 779 778 ··· 854 853 uint64_t *data) 855 854 { 856 855 struct dsa_slave_priv *p = netdev_priv(dev); 857 - struct dsa_switch *ds = p->parent; 856 + struct dsa_switch *ds = p->dp->ds; 858 857 859 858 data[0] = dev->stats.tx_packets; 860 859 data[1] = dev->stats.tx_bytes; 861 860 data[2] = dev->stats.rx_packets; 862 861 data[3] = dev->stats.rx_bytes; 863 862 if (ds->ops->get_ethtool_stats) 864 - ds->ops->get_ethtool_stats(ds, p->port, data + 4); 863 + ds->ops->get_ethtool_stats(ds, p->dp->index, data + 4); 865 864 } 866 865 867 866 static int dsa_slave_get_sset_count(struct net_device *dev, int sset) 868 867 { 869 868 struct dsa_slave_priv *p = netdev_priv(dev); 870 - struct dsa_switch *ds = p->parent; 869 + struct dsa_switch *ds = p->dp->ds; 871 870 872 871 if (sset == ETH_SS_STATS) { 873 872 int count; ··· 885 884 static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) 886 885 { 887 886 struct dsa_slave_priv *p = netdev_priv(dev); 888 - struct dsa_switch *ds = p->parent; 887 + struct dsa_switch *ds = p->dp->ds; 889 888 890 889 if (ds->ops->get_wol) 891 - ds->ops->get_wol(ds, p->port, w); 890 + ds->ops->get_wol(ds, p->dp->index, w); 892 891 } 893 892 894 893 static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) 895 894 { 896 895 struct dsa_slave_priv *p = netdev_priv(dev); 897 - struct dsa_switch *ds = p->parent; 896 + struct dsa_switch *ds = p->dp->ds; 898 897 int ret = -EOPNOTSUPP; 899 898 900 899 if (ds->ops->set_wol) 901 - ret = ds->ops->set_wol(ds, p->port, w); 900 + ret = ds->ops->set_wol(ds, p->dp->index, w); 902 901 903 902 return ret; 904 903 } ··· 906 905 static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e) 907 906 { 908 907 struct dsa_slave_priv *p = netdev_priv(dev); 909 - struct dsa_switch *ds = p->parent; 908 + struct dsa_switch *ds = p->dp->ds; 910 909 int ret; 911 910 912 911 if (!ds->ops->set_eee) 913 912 return -EOPNOTSUPP; 914 913 915 - ret = ds->ops->set_eee(ds, p->port, p->phy, e); 914 + ret = ds->ops->set_eee(ds, p->dp->index, p->phy, e); 916 915 if (ret) 917 916 return ret; 918 917 ··· 925 924 static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e) 926 925 { 927 926 struct dsa_slave_priv *p = netdev_priv(dev); 928 - struct dsa_switch *ds = p->parent; 927 + struct dsa_switch *ds = p->dp->ds; 929 928 int ret; 930 929 931 930 if (!ds->ops->get_eee) 932 931 return -EOPNOTSUPP; 933 932 934 - ret = ds->ops->get_eee(ds, p->port, e); 933 + ret = ds->ops->get_eee(ds, p->dp->index, e); 935 934 if (ret) 936 935 return ret; 937 936 ··· 946 945 struct netpoll_info *ni) 947 946 { 948 947 struct dsa_slave_priv *p = netdev_priv(dev); 949 - struct dsa_switch *ds = p->parent; 948 + struct dsa_switch *ds = p->dp->ds; 950 949 struct net_device *master = ds->dst->master_netdev; 951 950 struct netpoll *netpoll; 952 951 int err = 0; ··· 989 988 { 990 989 struct dsa_slave_priv *p = netdev_priv(dev); 991 990 992 - if (snprintf(name, len, "p%d", p->port) >= len) 991 + if (snprintf(name, len, "p%d", p->dp->index) >= len) 993 992 return -EINVAL; 994 993 995 994 return 0; ··· 1060 1059 static void dsa_slave_adjust_link(struct net_device *dev) 1061 1060 { 1062 1061 struct dsa_slave_priv *p = netdev_priv(dev); 1063 - struct dsa_switch *ds = p->parent; 1062 + struct dsa_switch *ds = p->dp->ds; 1064 1063 unsigned int status_changed = 0; 1065 1064 1066 1065 if (p->old_link != p->phy->link) { ··· 1079 1078 } 1080 1079 1081 1080 if (ds->ops->adjust_link && status_changed) 1082 - ds->ops->adjust_link(ds, p->port, p->phy); 1081 + ds->ops->adjust_link(ds, p->dp->index, p->phy); 1083 1082 1084 1083 if (status_changed) 1085 1084 phy_print_status(p->phy); ··· 1093 1092 1094 1093 if (dev) { 1095 1094 p = netdev_priv(dev); 1096 - ds = p->parent; 1095 + ds = p->dp->ds; 1097 1096 if (ds->ops->fixed_link_update) 1098 - ds->ops->fixed_link_update(ds, p->port, status); 1097 + ds->ops->fixed_link_update(ds, p->dp->index, status); 1099 1098 } 1100 1099 1101 1100 return 0; ··· 1106 1105 struct net_device *slave_dev, 1107 1106 int addr) 1108 1107 { 1109 - struct dsa_switch *ds = p->parent; 1108 + struct dsa_switch *ds = p->dp->ds; 1110 1109 1111 1110 p->phy = mdiobus_get_phy(ds->slave_mii_bus, addr); 1112 1111 if (!p->phy) { ··· 1124 1123 static int dsa_slave_phy_setup(struct dsa_slave_priv *p, 1125 1124 struct net_device *slave_dev) 1126 1125 { 1127 - struct dsa_switch *ds = p->parent; 1126 + struct dsa_switch *ds = p->dp->ds; 1128 1127 struct device_node *phy_dn, *port_dn; 1129 1128 bool phy_is_fixed = false; 1130 1129 u32 phy_flags = 0; 1131 1130 int mode, ret; 1132 1131 1133 - port_dn = ds->ports[p->port].dn; 1132 + port_dn = p->dp->dn; 1134 1133 mode = of_get_phy_mode(port_dn); 1135 1134 if (mode < 0) 1136 1135 mode = PHY_INTERFACE_MODE_NA; ··· 1151 1150 } 1152 1151 1153 1152 if (ds->ops->get_phy_flags) 1154 - phy_flags = ds->ops->get_phy_flags(ds, p->port); 1153 + phy_flags = ds->ops->get_phy_flags(ds, p->dp->index); 1155 1154 1156 1155 if (phy_dn) { 1157 1156 int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); ··· 1186 1185 * MDIO bus instead 1187 1186 */ 1188 1187 if (!p->phy) { 1189 - ret = dsa_slave_phy_connect(p, slave_dev, p->port); 1188 + ret = dsa_slave_phy_connect(p, slave_dev, p->dp->index); 1190 1189 if (ret) { 1191 - netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); 1190 + netdev_err(slave_dev, "failed to connect to port %d: %d\n", 1191 + p->dp->index, ret); 1192 1192 if (phy_is_fixed) 1193 1193 of_phy_deregister_fixed_link(port_dn); 1194 1194 return ret; ··· 1277 1275 slave_dev->vlan_features = master->vlan_features; 1278 1276 1279 1277 p = netdev_priv(slave_dev); 1280 - p->parent = ds; 1281 - p->port = port; 1278 + p->dp = &ds->ports[port]; 1282 1279 p->xmit = dst->tag_ops->xmit; 1283 1280 1284 1281 p->old_pause = -1; ··· 1310 1309 void dsa_slave_destroy(struct net_device *slave_dev) 1311 1310 { 1312 1311 struct dsa_slave_priv *p = netdev_priv(slave_dev); 1313 - struct dsa_switch *ds = p->parent; 1314 1312 struct device_node *port_dn; 1315 1313 1316 - port_dn = ds->ports[p->port].dn; 1314 + port_dn = p->dp->dn; 1317 1315 1318 1316 netif_carrier_off(slave_dev); 1319 1317 if (p->phy) {
+2 -2
net/dsa/tag_brcm.c
··· 80 80 ((skb->priority << BRCM_IG_TC_SHIFT) & BRCM_IG_TC_MASK); 81 81 brcm_tag[1] = 0; 82 82 brcm_tag[2] = 0; 83 - if (p->port == 8) 83 + if (p->dp->index == 8) 84 84 brcm_tag[2] = BRCM_IG_DSTMAP2_MASK; 85 - brcm_tag[3] = (1 << p->port) & BRCM_IG_DSTMAP1_MASK; 85 + brcm_tag[3] = (1 << p->dp->index) & BRCM_IG_DSTMAP1_MASK; 86 86 87 87 return skb; 88 88
+4 -4
net/dsa/tag_dsa.c
··· 33 33 * Construct tagged FROM_CPU DSA tag from 802.1q tag. 34 34 */ 35 35 dsa_header = skb->data + 2 * ETH_ALEN; 36 - dsa_header[0] = 0x60 | p->parent->index; 37 - dsa_header[1] = p->port << 3; 36 + dsa_header[0] = 0x60 | p->dp->ds->index; 37 + dsa_header[1] = p->dp->index << 3; 38 38 39 39 /* 40 40 * Move CFI field from byte 2 to byte 1. ··· 54 54 * Construct untagged FROM_CPU DSA tag. 55 55 */ 56 56 dsa_header = skb->data + 2 * ETH_ALEN; 57 - dsa_header[0] = 0x40 | p->parent->index; 58 - dsa_header[1] = p->port << 3; 57 + dsa_header[0] = 0x40 | p->dp->ds->index; 58 + dsa_header[1] = p->dp->index << 3; 59 59 dsa_header[2] = 0x00; 60 60 dsa_header[3] = 0x00; 61 61 }
+4 -4
net/dsa/tag_edsa.c
··· 42 42 edsa_header[1] = ETH_P_EDSA & 0xff; 43 43 edsa_header[2] = 0x00; 44 44 edsa_header[3] = 0x00; 45 - edsa_header[4] = 0x60 | p->parent->index; 46 - edsa_header[5] = p->port << 3; 45 + edsa_header[4] = 0x60 | p->dp->ds->index; 46 + edsa_header[5] = p->dp->index << 3; 47 47 48 48 /* 49 49 * Move CFI field from byte 6 to byte 5. ··· 67 67 edsa_header[1] = ETH_P_EDSA & 0xff; 68 68 edsa_header[2] = 0x00; 69 69 edsa_header[3] = 0x00; 70 - edsa_header[4] = 0x40 | p->parent->index; 71 - edsa_header[5] = p->port << 3; 70 + edsa_header[4] = 0x40 | p->dp->ds->index; 71 + edsa_header[5] = p->dp->index << 3; 72 72 edsa_header[6] = 0x00; 73 73 edsa_header[7] = 0x00; 74 74 }
+1 -1
net/dsa/tag_qca.c
··· 54 54 /* Set the version field, and set destination port information */ 55 55 hdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S | 56 56 QCA_HDR_XMIT_FROM_CPU | 57 - BIT(p->port); 57 + BIT(p->dp->index); 58 58 59 59 *phdr = htons(hdr); 60 60
+1 -1
net/dsa/tag_trailer.c
··· 50 50 51 51 trailer = skb_put(nskb, 4); 52 52 trailer[0] = 0x80; 53 - trailer[1] = 1 << p->port; 53 + trailer[1] = 1 << p->dp->index; 54 54 trailer[2] = 0x10; 55 55 trailer[3] = 0x00; 56 56