slave.c (2a267e7c41aa88215de2b542de797d03d16ecdfd) slave.c (87671375108625bb7f8a09f0809a369d460ebe43)
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.

--- 106 unchanged lines hidden (view full) ---

115 return err;
116}
117
118static int dsa_slave_close(struct net_device *dev)
119{
120 struct net_device *master = dsa_slave_to_master(dev);
121 struct dsa_port *dp = dsa_slave_to_port(dev);
122
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.

--- 106 unchanged lines hidden (view full) ---

115 return err;
116}
117
118static int dsa_slave_close(struct net_device *dev)
119{
120 struct net_device *master = dsa_slave_to_master(dev);
121 struct dsa_port *dp = dsa_slave_to_port(dev);
122
123 cancel_work_sync(&dp->xmit_work);
124 skb_queue_purge(&dp->xmit_queue);
125
123 phylink_stop(dp->pl);
124
125 dsa_port_disable(dp);
126
127 dev_mc_unsync(master, dev);
128 dev_uc_unsync(master, dev);
129 if (dev->flags & IFF_ALLMULTI)
130 dev_set_allmulti(master, -1);

--- 243 unchanged lines hidden (view full) ---

374
375static int dsa_slave_get_port_parent_id(struct net_device *dev,
376 struct netdev_phys_item_id *ppid)
377{
378 struct dsa_port *dp = dsa_slave_to_port(dev);
379 struct dsa_switch *ds = dp->ds;
380 struct dsa_switch_tree *dst = ds->dst;
381
126 phylink_stop(dp->pl);
127
128 dsa_port_disable(dp);
129
130 dev_mc_unsync(master, dev);
131 dev_uc_unsync(master, dev);
132 if (dev->flags & IFF_ALLMULTI)
133 dev_set_allmulti(master, -1);

--- 243 unchanged lines hidden (view full) ---

377
378static int dsa_slave_get_port_parent_id(struct net_device *dev,
379 struct netdev_phys_item_id *ppid)
380{
381 struct dsa_port *dp = dsa_slave_to_port(dev);
382 struct dsa_switch *ds = dp->ds;
383 struct dsa_switch_tree *dst = ds->dst;
384
385 /* For non-legacy ports, devlink is used and it takes
386 * care of the name generation. This ndo implementation
387 * should be removed with legacy support.
388 */
389 if (dp->ds->devlink)
390 return -EOPNOTSUPP;
391
382 ppid->id_len = sizeof(dst->index);
383 memcpy(&ppid->id, &dst->index, ppid->id_len);
384
385 return 0;
386}
387
388static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
389 struct sk_buff *skb)

--- 28 unchanged lines hidden (view full) ---

418 return;
419
420 if (ds->ops->port_txtstamp(ds, p->dp->index, clone, type))
421 return;
422
423 kfree_skb(clone);
424}
425
392 ppid->id_len = sizeof(dst->index);
393 memcpy(&ppid->id, &dst->index, ppid->id_len);
394
395 return 0;
396}
397
398static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
399 struct sk_buff *skb)

--- 28 unchanged lines hidden (view full) ---

428 return;
429
430 if (ds->ops->port_txtstamp(ds, p->dp->index, clone, type))
431 return;
432
433 kfree_skb(clone);
434}
435
436netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev)
437{
438 /* SKB for netpoll still need to be mangled with the protocol-specific
439 * tag to be successfully transmitted
440 */
441 if (unlikely(netpoll_tx_running(dev)))
442 return dsa_slave_netpoll_send_skb(dev, skb);
443
444 /* Queue the SKB for transmission on the parent interface, but
445 * do not modify its EtherType
446 */
447 skb->dev = dsa_slave_to_master(dev);
448 dev_queue_xmit(skb);
449
450 return NETDEV_TX_OK;
451}
452EXPORT_SYMBOL_GPL(dsa_enqueue_skb);
453
426static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
427{
428 struct dsa_slave_priv *p = netdev_priv(dev);
429 struct pcpu_sw_netstats *s;
430 struct sk_buff *nskb;
431
432 s = this_cpu_ptr(p->stats64);
433 u64_stats_update_begin(&s->syncp);
434 s->tx_packets++;
435 s->tx_bytes += skb->len;
436 u64_stats_update_end(&s->syncp);
437
454static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
455{
456 struct dsa_slave_priv *p = netdev_priv(dev);
457 struct pcpu_sw_netstats *s;
458 struct sk_buff *nskb;
459
460 s = this_cpu_ptr(p->stats64);
461 u64_stats_update_begin(&s->syncp);
462 s->tx_packets++;
463 s->tx_bytes += skb->len;
464 u64_stats_update_end(&s->syncp);
465
466 DSA_SKB_CB(skb)->deferred_xmit = false;
467
438 /* Identify PTP protocol packets, clone them, and pass them to the
439 * switch driver
440 */
441 dsa_skb_tx_timestamp(p, skb);
442
443 /* Transmit function may have to reallocate the original SKB,
444 * in which case it must have freed it. Only free it here on error.
445 */
446 nskb = p->xmit(skb, dev);
447 if (!nskb) {
468 /* Identify PTP protocol packets, clone them, and pass them to the
469 * switch driver
470 */
471 dsa_skb_tx_timestamp(p, skb);
472
473 /* Transmit function may have to reallocate the original SKB,
474 * in which case it must have freed it. Only free it here on error.
475 */
476 nskb = p->xmit(skb, dev);
477 if (!nskb) {
448 kfree_skb(skb);
478 if (!DSA_SKB_CB(skb)->deferred_xmit)
479 kfree_skb(skb);
449 return NETDEV_TX_OK;
450 }
451
480 return NETDEV_TX_OK;
481 }
482
452 /* SKB for netpoll still need to be mangled with the protocol-specific
453 * tag to be successfully transmitted
454 */
455 if (unlikely(netpoll_tx_running(dev)))
456 return dsa_slave_netpoll_send_skb(dev, nskb);
483 return dsa_enqueue_skb(nskb, dev);
484}
457
485
458 /* Queue the SKB for transmission on the parent interface, but
459 * do not modify its EtherType
460 */
461 nskb->dev = dsa_slave_to_master(dev);
462 dev_queue_xmit(nskb);
486void *dsa_defer_xmit(struct sk_buff *skb, struct net_device *dev)
487{
488 struct dsa_port *dp = dsa_slave_to_port(dev);
463
489
464 return NETDEV_TX_OK;
490 DSA_SKB_CB(skb)->deferred_xmit = true;
491
492 skb_queue_tail(&dp->xmit_queue, skb);
493 schedule_work(&dp->xmit_work);
494 return NULL;
465}
495}
496EXPORT_SYMBOL_GPL(dsa_defer_xmit);
466
497
498static void dsa_port_xmit_work(struct work_struct *work)
499{
500 struct dsa_port *dp = container_of(work, struct dsa_port, xmit_work);
501 struct dsa_switch *ds = dp->ds;
502 struct sk_buff *skb;
503
504 if (unlikely(!ds->ops->port_deferred_xmit))
505 return;
506
507 while ((skb = skb_dequeue(&dp->xmit_queue)) != NULL)
508 ds->ops->port_deferred_xmit(ds, dp->index, skb);
509}
510
467/* ethtool operations *******************************************************/
468
469static void dsa_slave_get_drvinfo(struct net_device *dev,
470 struct ethtool_drvinfo *drvinfo)
471{
472 strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver));
473 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
474 strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));

--- 256 unchanged lines hidden (view full) ---

731}
732#endif
733
734static int dsa_slave_get_phys_port_name(struct net_device *dev,
735 char *name, size_t len)
736{
737 struct dsa_port *dp = dsa_slave_to_port(dev);
738
511/* ethtool operations *******************************************************/
512
513static void dsa_slave_get_drvinfo(struct net_device *dev,
514 struct ethtool_drvinfo *drvinfo)
515{
516 strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver));
517 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
518 strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));

--- 256 unchanged lines hidden (view full) ---

775}
776#endif
777
778static int dsa_slave_get_phys_port_name(struct net_device *dev,
779 char *name, size_t len)
780{
781 struct dsa_port *dp = dsa_slave_to_port(dev);
782
783 /* For non-legacy ports, devlink is used and it takes
784 * care of the name generation. This ndo implementation
785 * should be removed with legacy support.
786 */
787 if (dp->ds->devlink)
788 return -EOPNOTSUPP;
789
739 if (snprintf(name, len, "p%d", dp->index) >= len)
740 return -EINVAL;
741
742 return 0;
743}
744
745static struct dsa_mall_tc_entry *
746dsa_slave_mall_tc_entry_find(struct net_device *dev, unsigned long cookie)

--- 12 unchanged lines hidden (view full) ---

759 struct tc_cls_matchall_offload *cls,
760 bool ingress)
761{
762 struct dsa_port *dp = dsa_slave_to_port(dev);
763 struct dsa_slave_priv *p = netdev_priv(dev);
764 struct dsa_mall_tc_entry *mall_tc_entry;
765 __be16 protocol = cls->common.protocol;
766 struct dsa_switch *ds = dp->ds;
790 if (snprintf(name, len, "p%d", dp->index) >= len)
791 return -EINVAL;
792
793 return 0;
794}
795
796static struct dsa_mall_tc_entry *
797dsa_slave_mall_tc_entry_find(struct net_device *dev, unsigned long cookie)

--- 12 unchanged lines hidden (view full) ---

810 struct tc_cls_matchall_offload *cls,
811 bool ingress)
812{
813 struct dsa_port *dp = dsa_slave_to_port(dev);
814 struct dsa_slave_priv *p = netdev_priv(dev);
815 struct dsa_mall_tc_entry *mall_tc_entry;
816 __be16 protocol = cls->common.protocol;
817 struct dsa_switch *ds = dp->ds;
767 struct net_device *to_dev;
768 const struct tc_action *a;
818 struct flow_action_entry *act;
769 struct dsa_port *to_dp;
770 int err = -EOPNOTSUPP;
771
772 if (!ds->ops->port_mirror_add)
773 return err;
774
819 struct dsa_port *to_dp;
820 int err = -EOPNOTSUPP;
821
822 if (!ds->ops->port_mirror_add)
823 return err;
824
775 if (!tcf_exts_has_one_action(cls->exts))
825 if (!flow_offload_has_one_action(&cls->rule->action))
776 return err;
777
826 return err;
827
778 a = tcf_exts_first_action(cls->exts);
828 act = &cls->rule->action.entries[0];
779
829
780 if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
830 if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) {
781 struct dsa_mall_mirror_tc_entry *mirror;
782
831 struct dsa_mall_mirror_tc_entry *mirror;
832
783 to_dev = tcf_mirred_dev(a);
784 if (!to_dev)
833 if (!act->dev)
785 return -EINVAL;
786
834 return -EINVAL;
835
787 if (!dsa_slave_dev_check(to_dev))
836 if (!dsa_slave_dev_check(act->dev))
788 return -EOPNOTSUPP;
789
790 mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
791 if (!mall_tc_entry)
792 return -ENOMEM;
793
794 mall_tc_entry->cookie = cls->cookie;
795 mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
796 mirror = &mall_tc_entry->mirror;
797
837 return -EOPNOTSUPP;
838
839 mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
840 if (!mall_tc_entry)
841 return -ENOMEM;
842
843 mall_tc_entry->cookie = cls->cookie;
844 mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
845 mirror = &mall_tc_entry->mirror;
846
798 to_dp = dsa_slave_to_port(to_dev);
847 to_dp = dsa_slave_to_port(act->dev);
799
800 mirror->to_local_port = to_dp->index;
801 mirror->ingress = ingress;
802
803 err = ds->ops->port_mirror_add(ds, dp->index, mirror, ingress);
804 if (err) {
805 kfree(mall_tc_entry);
806 return err;

--- 175 unchanged lines hidden (view full) ---

982
983 return ds->ops->get_ts_info(ds, p->dp->index, ts);
984}
985
986static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
987 u16 vid)
988{
989 struct dsa_port *dp = dsa_slave_to_port(dev);
848
849 mirror->to_local_port = to_dp->index;
850 mirror->ingress = ingress;
851
852 err = ds->ops->port_mirror_add(ds, dp->index, mirror, ingress);
853 if (err) {
854 kfree(mall_tc_entry);
855 return err;

--- 175 unchanged lines hidden (view full) ---

1031
1032 return ds->ops->get_ts_info(ds, p->dp->index, ts);
1033}
1034
1035static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
1036 u16 vid)
1037{
1038 struct dsa_port *dp = dsa_slave_to_port(dev);
990 struct switchdev_obj_port_vlan vlan = {
991 .vid_begin = vid,
992 .vid_end = vid,
993 /* This API only allows programming tagged, non-PVID VIDs */
994 .flags = 0,
995 };
996 struct switchdev_trans trans;
997 struct bridge_vlan_info info;
998 int ret;
999
1000 /* Check for a possible bridge VLAN entry now since there is no
1001 * need to emulate the switchdev prepare + commit phase.
1002 */
1003 if (dp->bridge_dev) {
1004 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the
1005 * device, respectively the VID is not found, returning
1006 * 0 means success, which is a failure for us here.
1007 */
1008 ret = br_vlan_get_info(dp->bridge_dev, vid, &info);
1009 if (ret == 0)
1010 return -EBUSY;
1011 }
1012
1039 struct bridge_vlan_info info;
1040 int ret;
1041
1042 /* Check for a possible bridge VLAN entry now since there is no
1043 * need to emulate the switchdev prepare + commit phase.
1044 */
1045 if (dp->bridge_dev) {
1046 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the
1047 * device, respectively the VID is not found, returning
1048 * 0 means success, which is a failure for us here.
1049 */
1050 ret = br_vlan_get_info(dp->bridge_dev, vid, &info);
1051 if (ret == 0)
1052 return -EBUSY;
1053 }
1054
1013 trans.ph_prepare = true;
1014 ret = dsa_port_vlan_add(dp, &vlan, &trans);
1015 if (ret == -EOPNOTSUPP)
1016 return 0;
1017
1018 trans.ph_prepare = false;
1019 return dsa_port_vlan_add(dp, &vlan, &trans);
1055 /* This API only allows programming tagged, non-PVID VIDs */
1056 return dsa_port_vid_add(dp, vid, 0);
1020}
1021
1022static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
1023 u16 vid)
1024{
1025 struct dsa_port *dp = dsa_slave_to_port(dev);
1057}
1058
1059static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
1060 u16 vid)
1061{
1062 struct dsa_port *dp = dsa_slave_to_port(dev);
1026 struct switchdev_obj_port_vlan vlan = {
1027 .vid_begin = vid,
1028 .vid_end = vid,
1029 /* This API only allows programming tagged, non-PVID VIDs */
1030 .flags = 0,
1031 };
1032 struct bridge_vlan_info info;
1033 int ret;
1034
1035 /* Check for a possible bridge VLAN entry now since there is no
1036 * need to emulate the switchdev prepare + commit phase.
1037 */
1038 if (dp->bridge_dev) {
1039 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the
1040 * device, respectively the VID is not found, returning
1041 * 0 means success, which is a failure for us here.
1042 */
1043 ret = br_vlan_get_info(dp->bridge_dev, vid, &info);
1044 if (ret == 0)
1045 return -EBUSY;
1046 }
1047
1063 struct bridge_vlan_info info;
1064 int ret;
1065
1066 /* Check for a possible bridge VLAN entry now since there is no
1067 * need to emulate the switchdev prepare + commit phase.
1068 */
1069 if (dp->bridge_dev) {
1070 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the
1071 * device, respectively the VID is not found, returning
1072 * 0 means success, which is a failure for us here.
1073 */
1074 ret = br_vlan_get_info(dp->bridge_dev, vid, &info);
1075 if (ret == 0)
1076 return -EBUSY;
1077 }
1078
1048 ret = dsa_port_vlan_del(dp, &vlan);
1079 ret = dsa_port_vid_del(dp, vid);
1049 if (ret == -EOPNOTSUPP)
1050 ret = 0;
1051
1052 return ret;
1053}
1054
1055static const struct ethtool_ops dsa_slave_ethtool_ops = {
1056 .get_drvinfo = dsa_slave_get_drvinfo,

--- 34 unchanged lines hidden (view full) ---

1091 struct net_device *dev,
1092 const unsigned char *addr, u16 vid)
1093{
1094 struct dsa_port *dp = dsa_slave_to_port(dev);
1095
1096 return dsa_port_fdb_del(dp, addr, vid);
1097}
1098
1080 if (ret == -EOPNOTSUPP)
1081 ret = 0;
1082
1083 return ret;
1084}
1085
1086static const struct ethtool_ops dsa_slave_ethtool_ops = {
1087 .get_drvinfo = dsa_slave_get_drvinfo,

--- 34 unchanged lines hidden (view full) ---

1122 struct net_device *dev,
1123 const unsigned char *addr, u16 vid)
1124{
1125 struct dsa_port *dp = dsa_slave_to_port(dev);
1126
1127 return dsa_port_fdb_del(dp, addr, vid);
1128}
1129
1130static struct devlink_port *dsa_slave_get_devlink_port(struct net_device *dev)
1131{
1132 struct dsa_port *dp = dsa_slave_to_port(dev);
1133
1134 return dp->ds->devlink ? &dp->devlink_port : NULL;
1135}
1136
1099static const struct net_device_ops dsa_slave_netdev_ops = {
1100 .ndo_open = dsa_slave_open,
1101 .ndo_stop = dsa_slave_close,
1102 .ndo_start_xmit = dsa_slave_xmit,
1103 .ndo_change_rx_flags = dsa_slave_change_rx_flags,
1104 .ndo_set_rx_mode = dsa_slave_set_rx_mode,
1105 .ndo_set_mac_address = dsa_slave_set_mac_address,
1106 .ndo_fdb_add = dsa_legacy_fdb_add,

--- 7 unchanged lines hidden (view full) ---

1114 .ndo_poll_controller = dsa_slave_poll_controller,
1115#endif
1116 .ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
1117 .ndo_setup_tc = dsa_slave_setup_tc,
1118 .ndo_get_stats64 = dsa_slave_get_stats64,
1119 .ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
1120 .ndo_vlan_rx_add_vid = dsa_slave_vlan_rx_add_vid,
1121 .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
1137static const struct net_device_ops dsa_slave_netdev_ops = {
1138 .ndo_open = dsa_slave_open,
1139 .ndo_stop = dsa_slave_close,
1140 .ndo_start_xmit = dsa_slave_xmit,
1141 .ndo_change_rx_flags = dsa_slave_change_rx_flags,
1142 .ndo_set_rx_mode = dsa_slave_set_rx_mode,
1143 .ndo_set_mac_address = dsa_slave_set_mac_address,
1144 .ndo_fdb_add = dsa_legacy_fdb_add,

--- 7 unchanged lines hidden (view full) ---

1152 .ndo_poll_controller = dsa_slave_poll_controller,
1153#endif
1154 .ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
1155 .ndo_setup_tc = dsa_slave_setup_tc,
1156 .ndo_get_stats64 = dsa_slave_get_stats64,
1157 .ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
1158 .ndo_vlan_rx_add_vid = dsa_slave_vlan_rx_add_vid,
1159 .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
1160 .ndo_get_devlink_port = dsa_slave_get_devlink_port,
1122};
1123
1124static struct device_type dsa_type = {
1125 .name = "dsa",
1126};
1127
1128static void dsa_slave_phylink_validate(struct net_device *dev,
1129 unsigned long *supported,

--- 148 unchanged lines hidden (view full) ---

1278 */
1279 if (ds->ops->phylink_fixed_state)
1280 phylink_fixed_state_cb(dp->pl, dsa_slave_phylink_fixed_state);
1281
1282 if (ds->ops->get_phy_flags)
1283 phy_flags = ds->ops->get_phy_flags(ds, dp->index);
1284
1285 ret = phylink_of_phy_connect(dp->pl, port_dn, phy_flags);
1161};
1162
1163static struct device_type dsa_type = {
1164 .name = "dsa",
1165};
1166
1167static void dsa_slave_phylink_validate(struct net_device *dev,
1168 unsigned long *supported,

--- 148 unchanged lines hidden (view full) ---

1317 */
1318 if (ds->ops->phylink_fixed_state)
1319 phylink_fixed_state_cb(dp->pl, dsa_slave_phylink_fixed_state);
1320
1321 if (ds->ops->get_phy_flags)
1322 phy_flags = ds->ops->get_phy_flags(ds, dp->index);
1323
1324 ret = phylink_of_phy_connect(dp->pl, port_dn, phy_flags);
1286 if (ret == -ENODEV) {
1287 /* We could not connect to a designated PHY or SFP, so use the
1288 * switch internal MDIO bus instead
1325 if (ret == -ENODEV && ds->slave_mii_bus) {
1326 /* We could not connect to a designated PHY or SFP, so try to
1327 * use the switch internal MDIO bus instead
1289 */
1290 ret = dsa_slave_phy_connect(slave_dev, dp->index);
1291 if (ret) {
1292 netdev_err(slave_dev,
1293 "failed to connect to port %d: %d\n",
1294 dp->index, ret);
1295 phylink_destroy(dp->pl);
1296 return ret;
1297 }
1298 }
1299
1328 */
1329 ret = dsa_slave_phy_connect(slave_dev, dp->index);
1330 if (ret) {
1331 netdev_err(slave_dev,
1332 "failed to connect to port %d: %d\n",
1333 dp->index, ret);
1334 phylink_destroy(dp->pl);
1335 return ret;
1336 }
1337 }
1338
1300 return 0;
1339 return ret;
1301}
1302
1303static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
1304static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
1305 struct netdev_queue *txq,
1306 void *_unused)
1307{
1308 lockdep_set_class(&txq->_xmit_lock,
1309 &dsa_slave_netdev_xmit_lock_key);
1310}
1311
1312int dsa_slave_suspend(struct net_device *slave_dev)
1313{
1314 struct dsa_port *dp = dsa_slave_to_port(slave_dev);
1315
1316 if (!netif_running(slave_dev))
1317 return 0;
1318
1340}
1341
1342static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
1343static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
1344 struct netdev_queue *txq,
1345 void *_unused)
1346{
1347 lockdep_set_class(&txq->_xmit_lock,
1348 &dsa_slave_netdev_xmit_lock_key);
1349}
1350
1351int dsa_slave_suspend(struct net_device *slave_dev)
1352{
1353 struct dsa_port *dp = dsa_slave_to_port(slave_dev);
1354
1355 if (!netif_running(slave_dev))
1356 return 0;
1357
1358 cancel_work_sync(&dp->xmit_work);
1359 skb_queue_purge(&dp->xmit_queue);
1360
1319 netif_device_detach(slave_dev);
1320
1321 rtnl_lock();
1322 phylink_stop(dp->pl);
1323 rtnl_unlock();
1324
1325 return 0;
1326}

--- 46 unchanged lines hidden (view full) ---

1373 ds->num_tx_queues, 1);
1374 if (slave_dev == NULL)
1375 return -ENOMEM;
1376
1377 slave_dev->features = master->vlan_features | NETIF_F_HW_TC |
1378 NETIF_F_HW_VLAN_CTAG_FILTER;
1379 slave_dev->hw_features |= NETIF_F_HW_TC;
1380 slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
1361 netif_device_detach(slave_dev);
1362
1363 rtnl_lock();
1364 phylink_stop(dp->pl);
1365 rtnl_unlock();
1366
1367 return 0;
1368}

--- 46 unchanged lines hidden (view full) ---

1415 ds->num_tx_queues, 1);
1416 if (slave_dev == NULL)
1417 return -ENOMEM;
1418
1419 slave_dev->features = master->vlan_features | NETIF_F_HW_TC |
1420 NETIF_F_HW_VLAN_CTAG_FILTER;
1421 slave_dev->hw_features |= NETIF_F_HW_TC;
1422 slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
1381 eth_hw_addr_inherit(slave_dev, master);
1423 if (!IS_ERR_OR_NULL(port->mac))
1424 ether_addr_copy(slave_dev->dev_addr, port->mac);
1425 else
1426 eth_hw_addr_inherit(slave_dev, master);
1382 slave_dev->priv_flags |= IFF_NO_QUEUE;
1383 slave_dev->netdev_ops = &dsa_slave_netdev_ops;
1384 slave_dev->min_mtu = 0;
1385 slave_dev->max_mtu = ETH_MAX_MTU;
1386 SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
1387
1388 netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
1389 NULL);

--- 5 unchanged lines hidden (view full) ---

1395 p = netdev_priv(slave_dev);
1396 p->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1397 if (!p->stats64) {
1398 free_netdev(slave_dev);
1399 return -ENOMEM;
1400 }
1401 p->dp = port;
1402 INIT_LIST_HEAD(&p->mall_tc_list);
1427 slave_dev->priv_flags |= IFF_NO_QUEUE;
1428 slave_dev->netdev_ops = &dsa_slave_netdev_ops;
1429 slave_dev->min_mtu = 0;
1430 slave_dev->max_mtu = ETH_MAX_MTU;
1431 SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
1432
1433 netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
1434 NULL);

--- 5 unchanged lines hidden (view full) ---

1440 p = netdev_priv(slave_dev);
1441 p->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1442 if (!p->stats64) {
1443 free_netdev(slave_dev);
1444 return -ENOMEM;
1445 }
1446 p->dp = port;
1447 INIT_LIST_HEAD(&p->mall_tc_list);
1448 INIT_WORK(&port->xmit_work, dsa_port_xmit_work);
1449 skb_queue_head_init(&port->xmit_queue);
1403 p->xmit = cpu_dp->tag_ops->xmit;
1404 port->slave = slave_dev;
1405
1406 netif_carrier_off(slave_dev);
1407
1408 ret = dsa_slave_phy_setup(slave_dev);
1409 if (ret) {
1410 netdev_err(master, "error %d setting up slave phy\n", ret);

--- 334 unchanged lines hidden ---
1450 p->xmit = cpu_dp->tag_ops->xmit;
1451 port->slave = slave_dev;
1452
1453 netif_carrier_off(slave_dev);
1454
1455 ret = dsa_slave_phy_setup(slave_dev);
1456 if (ret) {
1457 netdev_err(master, "error %d setting up slave phy\n", ret);

--- 334 unchanged lines hidden ---