slave.c (6158eaa7a717b469b1b0c0ae6d79910737686279) | slave.c (d945097bb19501bd95790d8220d4eeb418b6ebb2) |
---|---|
1/* 2 * net/dsa/slave.c - Slave device handling 3 * Copyright (c) 2008-2009 Marvell Semiconductor 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 58 unchanged lines hidden (view full) --- 67 struct dsa_slave_priv *p = netdev_priv(dev); 68 69 return dsa_master_netdev(p)->ifindex; 70} 71 72static int dsa_slave_open(struct net_device *dev) 73{ 74 struct dsa_slave_priv *p = netdev_priv(dev); | 1/* 2 * net/dsa/slave.c - Slave device handling 3 * Copyright (c) 2008-2009 Marvell Semiconductor 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 58 unchanged lines hidden (view full) --- 67 struct dsa_slave_priv *p = netdev_priv(dev); 68 69 return dsa_master_netdev(p)->ifindex; 70} 71 72static int dsa_slave_open(struct net_device *dev) 73{ 74 struct dsa_slave_priv *p = netdev_priv(dev); |
75 struct dsa_port *dp = p->dp; | |
76 struct net_device *master = dsa_master_netdev(p); | 75 struct net_device *master = dsa_master_netdev(p); |
76 struct dsa_port *dp = dsa_slave_to_port(dev); |
|
77 int err; 78 79 if (!(master->flags & IFF_UP)) 80 return -ENETDOWN; 81 82 if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) { 83 err = dev_uc_add(master, dev->dev_addr); 84 if (err < 0) --- 32 unchanged lines hidden (view full) --- 117out: 118 return err; 119} 120 121static int dsa_slave_close(struct net_device *dev) 122{ 123 struct dsa_slave_priv *p = netdev_priv(dev); 124 struct net_device *master = dsa_master_netdev(p); | 77 int err; 78 79 if (!(master->flags & IFF_UP)) 80 return -ENETDOWN; 81 82 if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) { 83 err = dev_uc_add(master, dev->dev_addr); 84 if (err < 0) --- 32 unchanged lines hidden (view full) --- 117out: 118 return err; 119} 120 121static int dsa_slave_close(struct net_device *dev) 122{ 123 struct dsa_slave_priv *p = netdev_priv(dev); 124 struct net_device *master = dsa_master_netdev(p); |
125 struct dsa_port *dp = p->dp; | 125 struct dsa_port *dp = dsa_slave_to_port(dev); |
126 127 if (dev->phydev) 128 phy_stop(dev->phydev); 129 130 dsa_port_disable(dp, dev->phydev); 131 132 dev_mc_unsync(master, dev); 133 dev_uc_unsync(master, dev); --- 107 unchanged lines hidden (view full) --- 241 return -EMSGSIZE; 242} 243 244static int 245dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, 246 struct net_device *dev, struct net_device *filter_dev, 247 int *idx) 248{ | 126 127 if (dev->phydev) 128 phy_stop(dev->phydev); 129 130 dsa_port_disable(dp, dev->phydev); 131 132 dev_mc_unsync(master, dev); 133 dev_uc_unsync(master, dev); --- 107 unchanged lines hidden (view full) --- 241 return -EMSGSIZE; 242} 243 244static int 245dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, 246 struct net_device *dev, struct net_device *filter_dev, 247 int *idx) 248{ |
249 struct dsa_port *dp = dsa_slave_to_port(dev); |
|
249 struct dsa_slave_dump_ctx dump = { 250 .dev = dev, 251 .skb = skb, 252 .cb = cb, 253 .idx = *idx, 254 }; | 250 struct dsa_slave_dump_ctx dump = { 251 .dev = dev, 252 .skb = skb, 253 .cb = cb, 254 .idx = *idx, 255 }; |
255 struct dsa_slave_priv *p = netdev_priv(dev); 256 struct dsa_port *dp = p->dp; | |
257 int err; 258 259 err = dsa_port_fdb_dump(dp, dsa_slave_port_fdb_do_dump, &dump); 260 *idx = dump.idx; 261 262 return err; 263} 264 --- 4 unchanged lines hidden (view full) --- 269 270 return phy_mii_ioctl(dev->phydev, ifr, cmd); 271} 272 273static int dsa_slave_port_attr_set(struct net_device *dev, 274 const struct switchdev_attr *attr, 275 struct switchdev_trans *trans) 276{ | 256 int err; 257 258 err = dsa_port_fdb_dump(dp, dsa_slave_port_fdb_do_dump, &dump); 259 *idx = dump.idx; 260 261 return err; 262} 263 --- 4 unchanged lines hidden (view full) --- 268 269 return phy_mii_ioctl(dev->phydev, ifr, cmd); 270} 271 272static int dsa_slave_port_attr_set(struct net_device *dev, 273 const struct switchdev_attr *attr, 274 struct switchdev_trans *trans) 275{ |
277 struct dsa_slave_priv *p = netdev_priv(dev); 278 struct dsa_port *dp = p->dp; | 276 struct dsa_port *dp = dsa_slave_to_port(dev); |
279 int ret; 280 281 switch (attr->id) { 282 case SWITCHDEV_ATTR_ID_PORT_STP_STATE: 283 ret = dsa_port_set_state(dp, attr->u.stp_state, trans); 284 break; 285 case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: 286 ret = dsa_port_vlan_filtering(dp, attr->u.vlan_filtering, --- 9 unchanged lines hidden (view full) --- 296 297 return ret; 298} 299 300static int dsa_slave_port_obj_add(struct net_device *dev, 301 const struct switchdev_obj *obj, 302 struct switchdev_trans *trans) 303{ | 277 int ret; 278 279 switch (attr->id) { 280 case SWITCHDEV_ATTR_ID_PORT_STP_STATE: 281 ret = dsa_port_set_state(dp, attr->u.stp_state, trans); 282 break; 283 case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: 284 ret = dsa_port_vlan_filtering(dp, attr->u.vlan_filtering, --- 9 unchanged lines hidden (view full) --- 294 295 return ret; 296} 297 298static int dsa_slave_port_obj_add(struct net_device *dev, 299 const struct switchdev_obj *obj, 300 struct switchdev_trans *trans) 301{ |
304 struct dsa_slave_priv *p = netdev_priv(dev); 305 struct dsa_port *dp = p->dp; | 302 struct dsa_port *dp = dsa_slave_to_port(dev); |
306 int err; 307 308 /* For the prepare phase, ensure the full set of changes is feasable in 309 * one go in order to signal a failure properly. If an operation is not 310 * supported, return -EOPNOTSUPP. 311 */ 312 313 switch (obj->id) { --- 10 unchanged lines hidden (view full) --- 324 } 325 326 return err; 327} 328 329static int dsa_slave_port_obj_del(struct net_device *dev, 330 const struct switchdev_obj *obj) 331{ | 303 int err; 304 305 /* For the prepare phase, ensure the full set of changes is feasable in 306 * one go in order to signal a failure properly. If an operation is not 307 * supported, return -EOPNOTSUPP. 308 */ 309 310 switch (obj->id) { --- 10 unchanged lines hidden (view full) --- 321 } 322 323 return err; 324} 325 326static int dsa_slave_port_obj_del(struct net_device *dev, 327 const struct switchdev_obj *obj) 328{ |
332 struct dsa_slave_priv *p = netdev_priv(dev); 333 struct dsa_port *dp = p->dp; | 329 struct dsa_port *dp = dsa_slave_to_port(dev); |
334 int err; 335 336 switch (obj->id) { 337 case SWITCHDEV_OBJ_ID_PORT_MDB: 338 err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); 339 break; 340 case SWITCHDEV_OBJ_ID_PORT_VLAN: 341 err = dsa_port_vlan_del(dp, SWITCHDEV_OBJ_PORT_VLAN(obj)); --- 4 unchanged lines hidden (view full) --- 346 } 347 348 return err; 349} 350 351static int dsa_slave_port_attr_get(struct net_device *dev, 352 struct switchdev_attr *attr) 353{ | 330 int err; 331 332 switch (obj->id) { 333 case SWITCHDEV_OBJ_ID_PORT_MDB: 334 err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); 335 break; 336 case SWITCHDEV_OBJ_ID_PORT_VLAN: 337 err = dsa_port_vlan_del(dp, SWITCHDEV_OBJ_PORT_VLAN(obj)); --- 4 unchanged lines hidden (view full) --- 342 } 343 344 return err; 345} 346 347static int dsa_slave_port_attr_get(struct net_device *dev, 348 struct switchdev_attr *attr) 349{ |
354 struct dsa_slave_priv *p = netdev_priv(dev); 355 struct dsa_switch *ds = p->dp->ds; | 350 struct dsa_port *dp = dsa_slave_to_port(dev); 351 struct dsa_switch *ds = dp->ds; |
356 357 switch (attr->id) { 358 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: 359 attr->u.ppid.id_len = sizeof(ds->index); 360 memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len); 361 break; 362 case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT: 363 attr->u.brport_flags_support = 0; --- 62 unchanged lines hidden (view full) --- 426{ 427 strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver)); 428 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 429 strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info)); 430} 431 432static int dsa_slave_get_regs_len(struct net_device *dev) 433{ | 352 353 switch (attr->id) { 354 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: 355 attr->u.ppid.id_len = sizeof(ds->index); 356 memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len); 357 break; 358 case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT: 359 attr->u.brport_flags_support = 0; --- 62 unchanged lines hidden (view full) --- 422{ 423 strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver)); 424 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 425 strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info)); 426} 427 428static int dsa_slave_get_regs_len(struct net_device *dev) 429{ |
434 struct dsa_slave_priv *p = netdev_priv(dev); 435 struct dsa_switch *ds = p->dp->ds; | 430 struct dsa_port *dp = dsa_slave_to_port(dev); 431 struct dsa_switch *ds = dp->ds; |
436 437 if (ds->ops->get_regs_len) | 432 433 if (ds->ops->get_regs_len) |
438 return ds->ops->get_regs_len(ds, p->dp->index); | 434 return ds->ops->get_regs_len(ds, dp->index); |
439 440 return -EOPNOTSUPP; 441} 442 443static void 444dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p) 445{ | 435 436 return -EOPNOTSUPP; 437} 438 439static void 440dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p) 441{ |
446 struct dsa_slave_priv *p = netdev_priv(dev); 447 struct dsa_switch *ds = p->dp->ds; | 442 struct dsa_port *dp = dsa_slave_to_port(dev); 443 struct dsa_switch *ds = dp->ds; |
448 449 if (ds->ops->get_regs) | 444 445 if (ds->ops->get_regs) |
450 ds->ops->get_regs(ds, p->dp->index, regs, _p); | 446 ds->ops->get_regs(ds, dp->index, regs, _p); |
451} 452 453static u32 dsa_slave_get_link(struct net_device *dev) 454{ 455 if (!dev->phydev) 456 return -ENODEV; 457 458 genphy_update_link(dev->phydev); 459 460 return dev->phydev->link; 461} 462 463static int dsa_slave_get_eeprom_len(struct net_device *dev) 464{ | 447} 448 449static u32 dsa_slave_get_link(struct net_device *dev) 450{ 451 if (!dev->phydev) 452 return -ENODEV; 453 454 genphy_update_link(dev->phydev); 455 456 return dev->phydev->link; 457} 458 459static int dsa_slave_get_eeprom_len(struct net_device *dev) 460{ |
465 struct dsa_slave_priv *p = netdev_priv(dev); 466 struct dsa_switch *ds = p->dp->ds; | 461 struct dsa_port *dp = dsa_slave_to_port(dev); 462 struct dsa_switch *ds = dp->ds; |
467 468 if (ds->cd && ds->cd->eeprom_len) 469 return ds->cd->eeprom_len; 470 471 if (ds->ops->get_eeprom_len) 472 return ds->ops->get_eeprom_len(ds); 473 474 return 0; 475} 476 477static int dsa_slave_get_eeprom(struct net_device *dev, 478 struct ethtool_eeprom *eeprom, u8 *data) 479{ | 463 464 if (ds->cd && ds->cd->eeprom_len) 465 return ds->cd->eeprom_len; 466 467 if (ds->ops->get_eeprom_len) 468 return ds->ops->get_eeprom_len(ds); 469 470 return 0; 471} 472 473static int dsa_slave_get_eeprom(struct net_device *dev, 474 struct ethtool_eeprom *eeprom, u8 *data) 475{ |
480 struct dsa_slave_priv *p = netdev_priv(dev); 481 struct dsa_switch *ds = p->dp->ds; | 476 struct dsa_port *dp = dsa_slave_to_port(dev); 477 struct dsa_switch *ds = dp->ds; |
482 483 if (ds->ops->get_eeprom) 484 return ds->ops->get_eeprom(ds, eeprom, data); 485 486 return -EOPNOTSUPP; 487} 488 489static int dsa_slave_set_eeprom(struct net_device *dev, 490 struct ethtool_eeprom *eeprom, u8 *data) 491{ | 478 479 if (ds->ops->get_eeprom) 480 return ds->ops->get_eeprom(ds, eeprom, data); 481 482 return -EOPNOTSUPP; 483} 484 485static int dsa_slave_set_eeprom(struct net_device *dev, 486 struct ethtool_eeprom *eeprom, u8 *data) 487{ |
492 struct dsa_slave_priv *p = netdev_priv(dev); 493 struct dsa_switch *ds = p->dp->ds; | 488 struct dsa_port *dp = dsa_slave_to_port(dev); 489 struct dsa_switch *ds = dp->ds; |
494 495 if (ds->ops->set_eeprom) 496 return ds->ops->set_eeprom(ds, eeprom, data); 497 498 return -EOPNOTSUPP; 499} 500 501static void dsa_slave_get_strings(struct net_device *dev, 502 uint32_t stringset, uint8_t *data) 503{ | 490 491 if (ds->ops->set_eeprom) 492 return ds->ops->set_eeprom(ds, eeprom, data); 493 494 return -EOPNOTSUPP; 495} 496 497static void dsa_slave_get_strings(struct net_device *dev, 498 uint32_t stringset, uint8_t *data) 499{ |
504 struct dsa_slave_priv *p = netdev_priv(dev); 505 struct dsa_switch *ds = p->dp->ds; | 500 struct dsa_port *dp = dsa_slave_to_port(dev); 501 struct dsa_switch *ds = dp->ds; |
506 507 if (stringset == ETH_SS_STATS) { 508 int len = ETH_GSTRING_LEN; 509 510 strncpy(data, "tx_packets", len); 511 strncpy(data + len, "tx_bytes", len); 512 strncpy(data + 2 * len, "rx_packets", len); 513 strncpy(data + 3 * len, "rx_bytes", len); 514 if (ds->ops->get_strings) | 502 503 if (stringset == ETH_SS_STATS) { 504 int len = ETH_GSTRING_LEN; 505 506 strncpy(data, "tx_packets", len); 507 strncpy(data + len, "tx_bytes", len); 508 strncpy(data + 2 * len, "rx_packets", len); 509 strncpy(data + 3 * len, "rx_bytes", len); 510 if (ds->ops->get_strings) |
515 ds->ops->get_strings(ds, p->dp->index, data + 4 * len); | 511 ds->ops->get_strings(ds, dp->index, data + 4 * len); |
516 } 517} 518 519static void dsa_slave_get_ethtool_stats(struct net_device *dev, 520 struct ethtool_stats *stats, 521 uint64_t *data) 522{ | 512 } 513} 514 515static void dsa_slave_get_ethtool_stats(struct net_device *dev, 516 struct ethtool_stats *stats, 517 uint64_t *data) 518{ |
519 struct dsa_port *dp = dsa_slave_to_port(dev); |
|
523 struct dsa_slave_priv *p = netdev_priv(dev); | 520 struct dsa_slave_priv *p = netdev_priv(dev); |
524 struct dsa_switch *ds = p->dp->ds; | 521 struct dsa_switch *ds = dp->ds; |
525 struct pcpu_sw_netstats *s; 526 unsigned int start; 527 int i; 528 529 for_each_possible_cpu(i) { 530 u64 tx_packets, tx_bytes, rx_packets, rx_bytes; 531 532 s = per_cpu_ptr(p->stats64, i); --- 5 unchanged lines hidden (view full) --- 538 rx_bytes = s->rx_bytes; 539 } while (u64_stats_fetch_retry_irq(&s->syncp, start)); 540 data[0] += tx_packets; 541 data[1] += tx_bytes; 542 data[2] += rx_packets; 543 data[3] += rx_bytes; 544 } 545 if (ds->ops->get_ethtool_stats) | 522 struct pcpu_sw_netstats *s; 523 unsigned int start; 524 int i; 525 526 for_each_possible_cpu(i) { 527 u64 tx_packets, tx_bytes, rx_packets, rx_bytes; 528 529 s = per_cpu_ptr(p->stats64, i); --- 5 unchanged lines hidden (view full) --- 535 rx_bytes = s->rx_bytes; 536 } while (u64_stats_fetch_retry_irq(&s->syncp, start)); 537 data[0] += tx_packets; 538 data[1] += tx_bytes; 539 data[2] += rx_packets; 540 data[3] += rx_bytes; 541 } 542 if (ds->ops->get_ethtool_stats) |
546 ds->ops->get_ethtool_stats(ds, p->dp->index, data + 4); | 543 ds->ops->get_ethtool_stats(ds, dp->index, data + 4); |
547} 548 549static int dsa_slave_get_sset_count(struct net_device *dev, int sset) 550{ | 544} 545 546static int dsa_slave_get_sset_count(struct net_device *dev, int sset) 547{ |
551 struct dsa_slave_priv *p = netdev_priv(dev); 552 struct dsa_switch *ds = p->dp->ds; | 548 struct dsa_port *dp = dsa_slave_to_port(dev); 549 struct dsa_switch *ds = dp->ds; |
553 554 if (sset == ETH_SS_STATS) { 555 int count; 556 557 count = 4; 558 if (ds->ops->get_sset_count) 559 count += ds->ops->get_sset_count(ds); 560 561 return count; 562 } 563 564 return -EOPNOTSUPP; 565} 566 567static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) 568{ | 550 551 if (sset == ETH_SS_STATS) { 552 int count; 553 554 count = 4; 555 if (ds->ops->get_sset_count) 556 count += ds->ops->get_sset_count(ds); 557 558 return count; 559 } 560 561 return -EOPNOTSUPP; 562} 563 564static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) 565{ |
569 struct dsa_slave_priv *p = netdev_priv(dev); 570 struct dsa_switch *ds = p->dp->ds; | 566 struct dsa_port *dp = dsa_slave_to_port(dev); 567 struct dsa_switch *ds = dp->ds; |
571 572 if (ds->ops->get_wol) | 568 569 if (ds->ops->get_wol) |
573 ds->ops->get_wol(ds, p->dp->index, w); | 570 ds->ops->get_wol(ds, dp->index, w); |
574} 575 576static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) 577{ | 571} 572 573static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) 574{ |
578 struct dsa_slave_priv *p = netdev_priv(dev); 579 struct dsa_switch *ds = p->dp->ds; | 575 struct dsa_port *dp = dsa_slave_to_port(dev); 576 struct dsa_switch *ds = dp->ds; |
580 int ret = -EOPNOTSUPP; 581 582 if (ds->ops->set_wol) | 577 int ret = -EOPNOTSUPP; 578 579 if (ds->ops->set_wol) |
583 ret = ds->ops->set_wol(ds, p->dp->index, w); | 580 ret = ds->ops->set_wol(ds, dp->index, w); |
584 585 return ret; 586} 587 588static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e) 589{ | 581 582 return ret; 583} 584 585static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e) 586{ |
590 struct dsa_slave_priv *p = netdev_priv(dev); 591 struct dsa_switch *ds = p->dp->ds; | 587 struct dsa_port *dp = dsa_slave_to_port(dev); 588 struct dsa_switch *ds = dp->ds; |
592 int ret; 593 594 /* Port's PHY and MAC both need to be EEE capable */ 595 if (!dev->phydev) 596 return -ENODEV; 597 598 if (!ds->ops->set_mac_eee) 599 return -EOPNOTSUPP; 600 | 589 int ret; 590 591 /* Port's PHY and MAC both need to be EEE capable */ 592 if (!dev->phydev) 593 return -ENODEV; 594 595 if (!ds->ops->set_mac_eee) 596 return -EOPNOTSUPP; 597 |
601 ret = ds->ops->set_mac_eee(ds, p->dp->index, e); | 598 ret = ds->ops->set_mac_eee(ds, dp->index, e); |
602 if (ret) 603 return ret; 604 605 if (e->eee_enabled) { 606 ret = phy_init_eee(dev->phydev, 0); 607 if (ret) 608 return ret; 609 } 610 611 return phy_ethtool_set_eee(dev->phydev, e); 612} 613 614static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e) 615{ | 599 if (ret) 600 return ret; 601 602 if (e->eee_enabled) { 603 ret = phy_init_eee(dev->phydev, 0); 604 if (ret) 605 return ret; 606 } 607 608 return phy_ethtool_set_eee(dev->phydev, e); 609} 610 611static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e) 612{ |
616 struct dsa_slave_priv *p = netdev_priv(dev); 617 struct dsa_switch *ds = p->dp->ds; | 613 struct dsa_port *dp = dsa_slave_to_port(dev); 614 struct dsa_switch *ds = dp->ds; |
618 int ret; 619 620 /* Port's PHY and MAC both need to be EEE capable */ 621 if (!dev->phydev) 622 return -ENODEV; 623 624 if (!ds->ops->get_mac_eee) 625 return -EOPNOTSUPP; 626 | 615 int ret; 616 617 /* Port's PHY and MAC both need to be EEE capable */ 618 if (!dev->phydev) 619 return -ENODEV; 620 621 if (!ds->ops->get_mac_eee) 622 return -EOPNOTSUPP; 623 |
627 ret = ds->ops->get_mac_eee(ds, p->dp->index, e); | 624 ret = ds->ops->get_mac_eee(ds, dp->index, e); |
628 if (ret) 629 return ret; 630 631 return phy_ethtool_get_eee(dev->phydev, e); 632} 633 634#ifdef CONFIG_NET_POLL_CONTROLLER 635static int dsa_slave_netpoll_setup(struct net_device *dev, --- 35 unchanged lines hidden (view full) --- 671static void dsa_slave_poll_controller(struct net_device *dev) 672{ 673} 674#endif 675 676static int dsa_slave_get_phys_port_name(struct net_device *dev, 677 char *name, size_t len) 678{ | 625 if (ret) 626 return ret; 627 628 return phy_ethtool_get_eee(dev->phydev, e); 629} 630 631#ifdef CONFIG_NET_POLL_CONTROLLER 632static int dsa_slave_netpoll_setup(struct net_device *dev, --- 35 unchanged lines hidden (view full) --- 668static void dsa_slave_poll_controller(struct net_device *dev) 669{ 670} 671#endif 672 673static int dsa_slave_get_phys_port_name(struct net_device *dev, 674 char *name, size_t len) 675{ |
679 struct dsa_slave_priv *p = netdev_priv(dev); | 676 struct dsa_port *dp = dsa_slave_to_port(dev); |
680 | 677 |
681 if (snprintf(name, len, "p%d", p->dp->index) >= len) | 678 if (snprintf(name, len, "p%d", dp->index) >= len) |
682 return -EINVAL; 683 684 return 0; 685} 686 687static struct dsa_mall_tc_entry * 688dsa_slave_mall_tc_entry_find(struct net_device *dev, unsigned long cookie) 689{ --- 6 unchanged lines hidden (view full) --- 696 697 return NULL; 698} 699 700static int dsa_slave_add_cls_matchall(struct net_device *dev, 701 struct tc_cls_matchall_offload *cls, 702 bool ingress) 703{ | 679 return -EINVAL; 680 681 return 0; 682} 683 684static struct dsa_mall_tc_entry * 685dsa_slave_mall_tc_entry_find(struct net_device *dev, unsigned long cookie) 686{ --- 6 unchanged lines hidden (view full) --- 693 694 return NULL; 695} 696 697static int dsa_slave_add_cls_matchall(struct net_device *dev, 698 struct tc_cls_matchall_offload *cls, 699 bool ingress) 700{ |
701 struct dsa_port *dp = dsa_slave_to_port(dev); |
|
704 struct dsa_slave_priv *p = netdev_priv(dev); 705 struct dsa_mall_tc_entry *mall_tc_entry; 706 __be16 protocol = cls->common.protocol; | 702 struct dsa_slave_priv *p = netdev_priv(dev); 703 struct dsa_mall_tc_entry *mall_tc_entry; 704 __be16 protocol = cls->common.protocol; |
707 struct dsa_switch *ds = p->dp->ds; | |
708 struct net *net = dev_net(dev); | 705 struct net *net = dev_net(dev); |
709 struct dsa_slave_priv *to_p; | 706 struct dsa_switch *ds = dp->ds; |
710 struct net_device *to_dev; 711 const struct tc_action *a; | 707 struct net_device *to_dev; 708 const struct tc_action *a; |
709 struct dsa_port *to_dp; |
|
712 int err = -EOPNOTSUPP; 713 LIST_HEAD(actions); 714 int ifindex; 715 716 if (!ds->ops->port_mirror_add) 717 return err; 718 719 if (!tcf_exts_has_one_action(cls->exts)) --- 16 unchanged lines hidden (view full) --- 736 mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL); 737 if (!mall_tc_entry) 738 return -ENOMEM; 739 740 mall_tc_entry->cookie = cls->cookie; 741 mall_tc_entry->type = DSA_PORT_MALL_MIRROR; 742 mirror = &mall_tc_entry->mirror; 743 | 710 int err = -EOPNOTSUPP; 711 LIST_HEAD(actions); 712 int ifindex; 713 714 if (!ds->ops->port_mirror_add) 715 return err; 716 717 if (!tcf_exts_has_one_action(cls->exts)) --- 16 unchanged lines hidden (view full) --- 734 mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL); 735 if (!mall_tc_entry) 736 return -ENOMEM; 737 738 mall_tc_entry->cookie = cls->cookie; 739 mall_tc_entry->type = DSA_PORT_MALL_MIRROR; 740 mirror = &mall_tc_entry->mirror; 741 |
744 to_p = netdev_priv(to_dev); | 742 to_dp = dsa_slave_to_port(to_dev); |
745 | 743 |
746 mirror->to_local_port = to_p->dp->index; | 744 mirror->to_local_port = to_dp->index; |
747 mirror->ingress = ingress; 748 | 745 mirror->ingress = ingress; 746 |
749 err = ds->ops->port_mirror_add(ds, p->dp->index, mirror, 750 ingress); | 747 err = ds->ops->port_mirror_add(ds, dp->index, mirror, ingress); |
751 if (err) { 752 kfree(mall_tc_entry); 753 return err; 754 } 755 756 list_add_tail(&mall_tc_entry->list, &p->mall_tc_list); 757 } 758 759 return 0; 760} 761 762static void dsa_slave_del_cls_matchall(struct net_device *dev, 763 struct tc_cls_matchall_offload *cls) 764{ | 748 if (err) { 749 kfree(mall_tc_entry); 750 return err; 751 } 752 753 list_add_tail(&mall_tc_entry->list, &p->mall_tc_list); 754 } 755 756 return 0; 757} 758 759static void dsa_slave_del_cls_matchall(struct net_device *dev, 760 struct tc_cls_matchall_offload *cls) 761{ |
765 struct dsa_slave_priv *p = netdev_priv(dev); | 762 struct dsa_port *dp = dsa_slave_to_port(dev); |
766 struct dsa_mall_tc_entry *mall_tc_entry; | 763 struct dsa_mall_tc_entry *mall_tc_entry; |
767 struct dsa_switch *ds = p->dp->ds; | 764 struct dsa_switch *ds = dp->ds; |
768 769 if (!ds->ops->port_mirror_del) 770 return; 771 772 mall_tc_entry = dsa_slave_mall_tc_entry_find(dev, cls->cookie); 773 if (!mall_tc_entry) 774 return; 775 776 list_del(&mall_tc_entry->list); 777 778 switch (mall_tc_entry->type) { 779 case DSA_PORT_MALL_MIRROR: | 765 766 if (!ds->ops->port_mirror_del) 767 return; 768 769 mall_tc_entry = dsa_slave_mall_tc_entry_find(dev, cls->cookie); 770 if (!mall_tc_entry) 771 return; 772 773 list_del(&mall_tc_entry->list); 774 775 switch (mall_tc_entry->type) { 776 case DSA_PORT_MALL_MIRROR: |
780 ds->ops->port_mirror_del(ds, p->dp->index, 781 &mall_tc_entry->mirror); | 777 ds->ops->port_mirror_del(ds, dp->index, &mall_tc_entry->mirror); |
782 break; 783 default: 784 WARN_ON(1); 785 } 786 787 kfree(mall_tc_entry); 788} 789 --- 60 unchanged lines hidden (view full) --- 850 stats->rx_packets += rx_packets; 851 stats->rx_bytes += rx_bytes; 852 } 853} 854 855static int dsa_slave_get_rxnfc(struct net_device *dev, 856 struct ethtool_rxnfc *nfc, u32 *rule_locs) 857{ | 778 break; 779 default: 780 WARN_ON(1); 781 } 782 783 kfree(mall_tc_entry); 784} 785 --- 60 unchanged lines hidden (view full) --- 846 stats->rx_packets += rx_packets; 847 stats->rx_bytes += rx_bytes; 848 } 849} 850 851static int dsa_slave_get_rxnfc(struct net_device *dev, 852 struct ethtool_rxnfc *nfc, u32 *rule_locs) 853{ |
858 struct dsa_slave_priv *p = netdev_priv(dev); 859 struct dsa_switch *ds = p->dp->ds; | 854 struct dsa_port *dp = dsa_slave_to_port(dev); 855 struct dsa_switch *ds = dp->ds; |
860 861 if (!ds->ops->get_rxnfc) 862 return -EOPNOTSUPP; 863 | 856 857 if (!ds->ops->get_rxnfc) 858 return -EOPNOTSUPP; 859 |
864 return ds->ops->get_rxnfc(ds, p->dp->index, nfc, rule_locs); | 860 return ds->ops->get_rxnfc(ds, dp->index, nfc, rule_locs); |
865} 866 867static int dsa_slave_set_rxnfc(struct net_device *dev, 868 struct ethtool_rxnfc *nfc) 869{ | 861} 862 863static int dsa_slave_set_rxnfc(struct net_device *dev, 864 struct ethtool_rxnfc *nfc) 865{ |
870 struct dsa_slave_priv *p = netdev_priv(dev); 871 struct dsa_switch *ds = p->dp->ds; | 866 struct dsa_port *dp = dsa_slave_to_port(dev); 867 struct dsa_switch *ds = dp->ds; |
872 873 if (!ds->ops->set_rxnfc) 874 return -EOPNOTSUPP; 875 | 868 869 if (!ds->ops->set_rxnfc) 870 return -EOPNOTSUPP; 871 |
876 return ds->ops->set_rxnfc(ds, p->dp->index, nfc); | 872 return ds->ops->set_rxnfc(ds, dp->index, nfc); |
877} 878 879static const struct ethtool_ops dsa_slave_ethtool_ops = { 880 .get_drvinfo = dsa_slave_get_drvinfo, 881 .get_regs_len = dsa_slave_get_regs_len, 882 .get_regs = dsa_slave_get_regs, 883 .nway_reset = phy_ethtool_nway_reset, 884 .get_link = dsa_slave_get_link, --- 43 unchanged lines hidden (view full) --- 928}; 929 930static struct device_type dsa_type = { 931 .name = "dsa", 932}; 933 934static void dsa_slave_adjust_link(struct net_device *dev) 935{ | 873} 874 875static const struct ethtool_ops dsa_slave_ethtool_ops = { 876 .get_drvinfo = dsa_slave_get_drvinfo, 877 .get_regs_len = dsa_slave_get_regs_len, 878 .get_regs = dsa_slave_get_regs, 879 .nway_reset = phy_ethtool_nway_reset, 880 .get_link = dsa_slave_get_link, --- 43 unchanged lines hidden (view full) --- 924}; 925 926static struct device_type dsa_type = { 927 .name = "dsa", 928}; 929 930static void dsa_slave_adjust_link(struct net_device *dev) 931{ |
932 struct dsa_port *dp = dsa_slave_to_port(dev); |
|
936 struct dsa_slave_priv *p = netdev_priv(dev); | 933 struct dsa_slave_priv *p = netdev_priv(dev); |
937 struct dsa_switch *ds = p->dp->ds; | 934 struct dsa_switch *ds = dp->ds; |
938 unsigned int status_changed = 0; 939 940 if (p->old_link != dev->phydev->link) { 941 status_changed = 1; 942 p->old_link = dev->phydev->link; 943 } 944 945 if (p->old_duplex != dev->phydev->duplex) { 946 status_changed = 1; 947 p->old_duplex = dev->phydev->duplex; 948 } 949 950 if (p->old_pause != dev->phydev->pause) { 951 status_changed = 1; 952 p->old_pause = dev->phydev->pause; 953 } 954 955 if (ds->ops->adjust_link && status_changed) | 935 unsigned int status_changed = 0; 936 937 if (p->old_link != dev->phydev->link) { 938 status_changed = 1; 939 p->old_link = dev->phydev->link; 940 } 941 942 if (p->old_duplex != dev->phydev->duplex) { 943 status_changed = 1; 944 p->old_duplex = dev->phydev->duplex; 945 } 946 947 if (p->old_pause != dev->phydev->pause) { 948 status_changed = 1; 949 p->old_pause = dev->phydev->pause; 950 } 951 952 if (ds->ops->adjust_link && status_changed) |
956 ds->ops->adjust_link(ds, p->dp->index, dev->phydev); | 953 ds->ops->adjust_link(ds, dp->index, dev->phydev); |
957 958 if (status_changed) 959 phy_print_status(dev->phydev); 960} 961 962static int dsa_slave_fixed_link_update(struct net_device *dev, 963 struct fixed_phy_status *status) 964{ | 954 955 if (status_changed) 956 phy_print_status(dev->phydev); 957} 958 959static int dsa_slave_fixed_link_update(struct net_device *dev, 960 struct fixed_phy_status *status) 961{ |
965 struct dsa_slave_priv *p; | |
966 struct dsa_switch *ds; | 962 struct dsa_switch *ds; |
963 struct dsa_port *dp; |
|
967 968 if (dev) { | 964 965 if (dev) { |
969 p = netdev_priv(dev); 970 ds = p->dp->ds; | 966 dp = dsa_slave_to_port(dev); 967 ds = dp->ds; |
971 if (ds->ops->fixed_link_update) | 968 if (ds->ops->fixed_link_update) |
972 ds->ops->fixed_link_update(ds, p->dp->index, status); | 969 ds->ops->fixed_link_update(ds, dp->index, status); |
973 } 974 975 return 0; 976} 977 978/* slave device setup *******************************************************/ 979static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr) 980{ | 970 } 971 972 return 0; 973} 974 975/* slave device setup *******************************************************/ 976static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr) 977{ |
978 struct dsa_port *dp = dsa_slave_to_port(slave_dev); |
|
981 struct dsa_slave_priv *p = netdev_priv(slave_dev); | 979 struct dsa_slave_priv *p = netdev_priv(slave_dev); |
982 struct dsa_switch *ds = p->dp->ds; | 980 struct dsa_switch *ds = dp->ds; |
983 984 slave_dev->phydev = mdiobus_get_phy(ds->slave_mii_bus, addr); 985 if (!slave_dev->phydev) { 986 netdev_err(slave_dev, "no phy at %d\n", addr); 987 return -ENODEV; 988 } 989 990 /* Use already configured phy mode */ 991 if (p->phy_interface == PHY_INTERFACE_MODE_NA) 992 p->phy_interface = slave_dev->phydev->interface; 993 994 return phy_connect_direct(slave_dev, slave_dev->phydev, 995 dsa_slave_adjust_link, p->phy_interface); 996} 997 998static int dsa_slave_phy_setup(struct net_device *slave_dev) 999{ | 981 982 slave_dev->phydev = mdiobus_get_phy(ds->slave_mii_bus, addr); 983 if (!slave_dev->phydev) { 984 netdev_err(slave_dev, "no phy at %d\n", addr); 985 return -ENODEV; 986 } 987 988 /* Use already configured phy mode */ 989 if (p->phy_interface == PHY_INTERFACE_MODE_NA) 990 p->phy_interface = slave_dev->phydev->interface; 991 992 return phy_connect_direct(slave_dev, slave_dev->phydev, 993 dsa_slave_adjust_link, p->phy_interface); 994} 995 996static int dsa_slave_phy_setup(struct net_device *slave_dev) 997{ |
998 struct dsa_port *dp = dsa_slave_to_port(slave_dev); |
|
1000 struct dsa_slave_priv *p = netdev_priv(slave_dev); | 999 struct dsa_slave_priv *p = netdev_priv(slave_dev); |
1001 struct dsa_switch *ds = p->dp->ds; 1002 struct device_node *phy_dn, *port_dn; | 1000 struct device_node *port_dn = dp->dn; 1001 struct dsa_switch *ds = dp->ds; 1002 struct device_node *phy_dn; |
1003 bool phy_is_fixed = false; 1004 u32 phy_flags = 0; 1005 int mode, ret; 1006 | 1003 bool phy_is_fixed = false; 1004 u32 phy_flags = 0; 1005 int mode, ret; 1006 |
1007 port_dn = p->dp->dn; | |
1008 mode = of_get_phy_mode(port_dn); 1009 if (mode < 0) 1010 mode = PHY_INTERFACE_MODE_NA; 1011 p->phy_interface = mode; 1012 1013 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); 1014 if (!phy_dn && of_phy_is_fixed_link(port_dn)) { 1015 /* In the case of a fixed PHY, the DT node associated --- 4 unchanged lines hidden (view full) --- 1020 netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret); 1021 return ret; 1022 } 1023 phy_is_fixed = true; 1024 phy_dn = of_node_get(port_dn); 1025 } 1026 1027 if (ds->ops->get_phy_flags) | 1007 mode = of_get_phy_mode(port_dn); 1008 if (mode < 0) 1009 mode = PHY_INTERFACE_MODE_NA; 1010 p->phy_interface = mode; 1011 1012 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); 1013 if (!phy_dn && of_phy_is_fixed_link(port_dn)) { 1014 /* In the case of a fixed PHY, the DT node associated --- 4 unchanged lines hidden (view full) --- 1019 netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret); 1020 return ret; 1021 } 1022 phy_is_fixed = true; 1023 phy_dn = of_node_get(port_dn); 1024 } 1025 1026 if (ds->ops->get_phy_flags) |
1028 phy_flags = ds->ops->get_phy_flags(ds, p->dp->index); | 1027 phy_flags = ds->ops->get_phy_flags(ds, dp->index); |
1029 1030 if (phy_dn) { 1031 int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); 1032 1033 /* If this PHY address is part of phys_mii_mask, which means 1034 * that we need to divert reads and writes to/from it, then we 1035 * want to bind this device using the slave MII bus created by 1036 * DSA to make that happen. --- 19 unchanged lines hidden (view full) --- 1056 if (slave_dev->phydev && phy_is_fixed) 1057 fixed_phy_set_link_update(slave_dev->phydev, 1058 dsa_slave_fixed_link_update); 1059 1060 /* We could not connect to a designated PHY, so use the switch internal 1061 * MDIO bus instead 1062 */ 1063 if (!slave_dev->phydev) { | 1028 1029 if (phy_dn) { 1030 int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); 1031 1032 /* If this PHY address is part of phys_mii_mask, which means 1033 * that we need to divert reads and writes to/from it, then we 1034 * want to bind this device using the slave MII bus created by 1035 * DSA to make that happen. --- 19 unchanged lines hidden (view full) --- 1055 if (slave_dev->phydev && phy_is_fixed) 1056 fixed_phy_set_link_update(slave_dev->phydev, 1057 dsa_slave_fixed_link_update); 1058 1059 /* We could not connect to a designated PHY, so use the switch internal 1060 * MDIO bus instead 1061 */ 1062 if (!slave_dev->phydev) { |
1064 ret = dsa_slave_phy_connect(slave_dev, p->dp->index); | 1063 ret = dsa_slave_phy_connect(slave_dev, dp->index); |
1065 if (ret) { 1066 netdev_err(slave_dev, "failed to connect to port %d: %d\n", | 1064 if (ret) { 1065 netdev_err(slave_dev, "failed to connect to port %d: %d\n", |
1067 p->dp->index, ret); | 1066 dp->index, ret); |
1068 if (phy_is_fixed) 1069 of_phy_deregister_fixed_link(port_dn); 1070 return ret; 1071 } 1072 } 1073 1074 phy_attached_info(slave_dev->phydev); 1075 --- 37 unchanged lines hidden (view full) --- 1113 1114 return 0; 1115} 1116 1117static void dsa_slave_notify(struct net_device *dev, unsigned long val) 1118{ 1119 struct dsa_slave_priv *p = netdev_priv(dev); 1120 struct net_device *master = dsa_master_netdev(p); | 1067 if (phy_is_fixed) 1068 of_phy_deregister_fixed_link(port_dn); 1069 return ret; 1070 } 1071 } 1072 1073 phy_attached_info(slave_dev->phydev); 1074 --- 37 unchanged lines hidden (view full) --- 1112 1113 return 0; 1114} 1115 1116static void dsa_slave_notify(struct net_device *dev, unsigned long val) 1117{ 1118 struct dsa_slave_priv *p = netdev_priv(dev); 1119 struct net_device *master = dsa_master_netdev(p); |
1121 struct dsa_port *dp = p->dp; | 1120 struct dsa_port *dp = dsa_slave_to_port(dev); |
1122 struct dsa_notifier_register_info rinfo = { 1123 .switch_number = dp->ds->index, 1124 .port_number = dp->index, 1125 .master = master, 1126 .info.dev = dev, 1127 }; 1128 1129 call_dsa_notifiers(val, dev, &rinfo.info); --- 67 unchanged lines hidden (view full) --- 1197 ret, slave_dev->name); 1198 goto out_phy; 1199 } 1200 1201 return 0; 1202 1203out_phy: 1204 phy_disconnect(slave_dev->phydev); | 1121 struct dsa_notifier_register_info rinfo = { 1122 .switch_number = dp->ds->index, 1123 .port_number = dp->index, 1124 .master = master, 1125 .info.dev = dev, 1126 }; 1127 1128 call_dsa_notifiers(val, dev, &rinfo.info); --- 67 unchanged lines hidden (view full) --- 1196 ret, slave_dev->name); 1197 goto out_phy; 1198 } 1199 1200 return 0; 1201 1202out_phy: 1203 phy_disconnect(slave_dev->phydev); |
1205 if (of_phy_is_fixed_link(p->dp->dn)) 1206 of_phy_deregister_fixed_link(p->dp->dn); | 1204 if (of_phy_is_fixed_link(port->dn)) 1205 of_phy_deregister_fixed_link(port->dn); |
1207out_free: 1208 free_percpu(p->stats64); 1209 free_netdev(slave_dev); 1210 port->netdev = NULL; 1211 return ret; 1212} 1213 1214void dsa_slave_destroy(struct net_device *slave_dev) 1215{ | 1206out_free: 1207 free_percpu(p->stats64); 1208 free_netdev(slave_dev); 1209 port->netdev = NULL; 1210 return ret; 1211} 1212 1213void dsa_slave_destroy(struct net_device *slave_dev) 1214{ |
1215 struct dsa_port *dp = dsa_slave_to_port(slave_dev); |
|
1216 struct dsa_slave_priv *p = netdev_priv(slave_dev); | 1216 struct dsa_slave_priv *p = netdev_priv(slave_dev); |
1217 struct device_node *port_dn; | 1217 struct device_node *port_dn = dp->dn; |
1218 | 1218 |
1219 port_dn = p->dp->dn; 1220 | |
1221 netif_carrier_off(slave_dev); 1222 if (slave_dev->phydev) { 1223 phy_disconnect(slave_dev->phydev); 1224 1225 if (of_phy_is_fixed_link(port_dn)) 1226 of_phy_deregister_fixed_link(port_dn); 1227 } 1228 dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER); --- 5 unchanged lines hidden (view full) --- 1234static bool dsa_slave_dev_check(struct net_device *dev) 1235{ 1236 return dev->netdev_ops == &dsa_slave_netdev_ops; 1237} 1238 1239static int dsa_slave_changeupper(struct net_device *dev, 1240 struct netdev_notifier_changeupper_info *info) 1241{ | 1219 netif_carrier_off(slave_dev); 1220 if (slave_dev->phydev) { 1221 phy_disconnect(slave_dev->phydev); 1222 1223 if (of_phy_is_fixed_link(port_dn)) 1224 of_phy_deregister_fixed_link(port_dn); 1225 } 1226 dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER); --- 5 unchanged lines hidden (view full) --- 1232static bool dsa_slave_dev_check(struct net_device *dev) 1233{ 1234 return dev->netdev_ops == &dsa_slave_netdev_ops; 1235} 1236 1237static int dsa_slave_changeupper(struct net_device *dev, 1238 struct netdev_notifier_changeupper_info *info) 1239{ |
1242 struct dsa_slave_priv *p = netdev_priv(dev); 1243 struct dsa_port *dp = p->dp; | 1240 struct dsa_port *dp = dsa_slave_to_port(dev); |
1244 int err = NOTIFY_DONE; 1245 1246 if (netif_is_bridge_master(info->upper_dev)) { 1247 if (info->linking) { 1248 err = dsa_port_bridge_join(dp, info->upper_dev); 1249 err = notifier_from_errno(err); 1250 } else { 1251 dsa_port_bridge_leave(dp, info->upper_dev); --- 26 unchanged lines hidden (view full) --- 1278}; 1279 1280static void dsa_slave_switchdev_event_work(struct work_struct *work) 1281{ 1282 struct dsa_switchdev_event_work *switchdev_work = 1283 container_of(work, struct dsa_switchdev_event_work, work); 1284 struct net_device *dev = switchdev_work->dev; 1285 struct switchdev_notifier_fdb_info *fdb_info; | 1241 int err = NOTIFY_DONE; 1242 1243 if (netif_is_bridge_master(info->upper_dev)) { 1244 if (info->linking) { 1245 err = dsa_port_bridge_join(dp, info->upper_dev); 1246 err = notifier_from_errno(err); 1247 } else { 1248 dsa_port_bridge_leave(dp, info->upper_dev); --- 26 unchanged lines hidden (view full) --- 1275}; 1276 1277static void dsa_slave_switchdev_event_work(struct work_struct *work) 1278{ 1279 struct dsa_switchdev_event_work *switchdev_work = 1280 container_of(work, struct dsa_switchdev_event_work, work); 1281 struct net_device *dev = switchdev_work->dev; 1282 struct switchdev_notifier_fdb_info *fdb_info; |
1286 struct dsa_slave_priv *p = netdev_priv(dev); | 1283 struct dsa_port *dp = dsa_slave_to_port(dev); |
1287 int err; 1288 1289 rtnl_lock(); 1290 switch (switchdev_work->event) { 1291 case SWITCHDEV_FDB_ADD_TO_DEVICE: 1292 fdb_info = &switchdev_work->fdb_info; | 1284 int err; 1285 1286 rtnl_lock(); 1287 switch (switchdev_work->event) { 1288 case SWITCHDEV_FDB_ADD_TO_DEVICE: 1289 fdb_info = &switchdev_work->fdb_info; |
1293 err = dsa_port_fdb_add(p->dp, fdb_info->addr, fdb_info->vid); | 1290 err = dsa_port_fdb_add(dp, fdb_info->addr, fdb_info->vid); |
1294 if (err) { 1295 netdev_dbg(dev, "fdb add failed err=%d\n", err); 1296 break; 1297 } 1298 call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, 1299 &fdb_info->info); 1300 break; 1301 1302 case SWITCHDEV_FDB_DEL_TO_DEVICE: 1303 fdb_info = &switchdev_work->fdb_info; | 1291 if (err) { 1292 netdev_dbg(dev, "fdb add failed err=%d\n", err); 1293 break; 1294 } 1295 call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, 1296 &fdb_info->info); 1297 break; 1298 1299 case SWITCHDEV_FDB_DEL_TO_DEVICE: 1300 fdb_info = &switchdev_work->fdb_info; |
1304 err = dsa_port_fdb_del(p->dp, fdb_info->addr, fdb_info->vid); | 1301 err = dsa_port_fdb_del(dp, fdb_info->addr, fdb_info->vid); |
1305 if (err) { 1306 netdev_dbg(dev, "fdb del failed err=%d\n", err); 1307 dev_close(dev); 1308 } 1309 break; 1310 } 1311 rtnl_unlock(); 1312 --- 100 unchanged lines hidden --- | 1302 if (err) { 1303 netdev_dbg(dev, "fdb del failed err=%d\n", err); 1304 dev_close(dev); 1305 } 1306 break; 1307 } 1308 rtnl_unlock(); 1309 --- 100 unchanged lines hidden --- |