1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Handling of a single switch port
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
9 #include <linux/if_bridge.h>
10 #include <linux/notifier.h>
11 #include <linux/of_mdio.h>
12 #include <linux/of_net.h>
17 * dsa_port_notify - Notify the switching fabric of changes to a port
18 * @dp: port on which change occurred
19 * @e: event, must be of type DSA_NOTIFIER_*
20 * @v: event-specific value.
22 * Notify all switches in the DSA tree that this port's switch belongs to,
23 * including this switch itself, of an event. Allows the other switches to
24 * reconfigure themselves for cross-chip operations. Can also be used to
25 * reconfigure ports without net_devices (CPU ports, DSA links) whenever
26 * a user port's state changes.
28 static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v)
30 return dsa_tree_notify(dp->ds->dst, e, v);
33 int dsa_port_set_state(struct dsa_port *dp, u8 state)
35 struct dsa_switch *ds = dp->ds;
38 if (!ds->ops->port_stp_state_set)
41 ds->ops->port_stp_state_set(ds, port, state);
43 if (ds->ops->port_fast_age) {
44 /* Fast age FDB entries or flush appropriate forwarding database
45 * for the given port, if we are moving it from Learning or
46 * Forwarding state, to Disabled or Blocking or Listening state.
49 if ((dp->stp_state == BR_STATE_LEARNING ||
50 dp->stp_state == BR_STATE_FORWARDING) &&
51 (state == BR_STATE_DISABLED ||
52 state == BR_STATE_BLOCKING ||
53 state == BR_STATE_LISTENING))
54 ds->ops->port_fast_age(ds, port);
57 dp->stp_state = state;
62 static void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
66 err = dsa_port_set_state(dp, state);
68 pr_err("DSA: failed to set STP state %u (%d)\n", state, err);
71 int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy)
73 struct dsa_switch *ds = dp->ds;
77 if (ds->ops->port_enable) {
78 err = ds->ops->port_enable(ds, port, phy);
84 dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
87 phylink_start(dp->pl);
92 int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy)
97 err = dsa_port_enable_rt(dp, phy);
103 void dsa_port_disable_rt(struct dsa_port *dp)
105 struct dsa_switch *ds = dp->ds;
106 int port = dp->index;
109 phylink_stop(dp->pl);
112 dsa_port_set_state_now(dp, BR_STATE_DISABLED);
114 if (ds->ops->port_disable)
115 ds->ops->port_disable(ds, port);
118 void dsa_port_disable(struct dsa_port *dp)
121 dsa_port_disable_rt(dp);
125 static void dsa_port_change_brport_flags(struct dsa_port *dp,
128 struct switchdev_brport_flags flags;
131 flags.mask = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;
133 flags.val = flags.mask;
135 flags.val = flags.mask & ~BR_LEARNING;
137 for_each_set_bit(flag, &flags.mask, 32) {
138 struct switchdev_brport_flags tmp;
140 tmp.val = flags.val & BIT(flag);
141 tmp.mask = BIT(flag);
143 dsa_port_bridge_flags(dp, tmp, NULL);
147 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)
149 struct dsa_notifier_bridge_info info = {
150 .tree_index = dp->ds->dst->index,
151 .sw_index = dp->ds->index,
157 /* Notify the port driver to set its configurable flags in a way that
158 * matches the initial settings of a bridge port.
160 dsa_port_change_brport_flags(dp, true);
162 /* Here the interface is already bridged. Reflect the current
163 * configuration so that drivers can program their chips accordingly.
167 err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_JOIN, &info);
169 /* The bridging is rolled back on error */
171 dsa_port_change_brport_flags(dp, false);
172 dp->bridge_dev = NULL;
178 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
180 struct dsa_notifier_bridge_info info = {
181 .tree_index = dp->ds->dst->index,
182 .sw_index = dp->ds->index,
188 /* Here the port is already unbridged. Reflect the current configuration
189 * so that drivers can program their chips accordingly.
191 dp->bridge_dev = NULL;
193 err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info);
195 pr_err("DSA: failed to notify DSA_NOTIFIER_BRIDGE_LEAVE\n");
197 /* Configure the port for standalone mode (no address learning,
199 * The bridge only emits SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS events
200 * when the user requests it through netlink or sysfs, but not
201 * automatically at port join or leave, so we need to handle resetting
202 * the brport flags ourselves. But we even prefer it that way, because
203 * otherwise, some setups might never get the notification they need,
204 * for example, when a port leaves a LAG that offloads the bridge,
205 * it becomes standalone, but as far as the bridge is concerned, no
208 dsa_port_change_brport_flags(dp, false);
210 /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
211 * so allow it to be in BR_STATE_FORWARDING to be kept functional
213 dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
216 int dsa_port_lag_change(struct dsa_port *dp,
217 struct netdev_lag_lower_state_info *linfo)
219 struct dsa_notifier_lag_info info = {
220 .sw_index = dp->ds->index,
228 /* On statically configured aggregates (e.g. loadbalance
229 * without LACP) ports will always be tx_enabled, even if the
230 * link is down. Thus we require both link_up and tx_enabled
231 * in order to include it in the tx set.
233 tx_enabled = linfo->link_up && linfo->tx_enabled;
235 if (tx_enabled == dp->lag_tx_enabled)
238 dp->lag_tx_enabled = tx_enabled;
240 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info);
243 int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag,
244 struct netdev_lag_upper_info *uinfo)
246 struct dsa_notifier_lag_info info = {
247 .sw_index = dp->ds->index,
254 dsa_lag_map(dp->ds->dst, lag);
257 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_JOIN, &info);
260 dsa_lag_unmap(dp->ds->dst, lag);
266 void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag)
268 struct dsa_notifier_lag_info info = {
269 .sw_index = dp->ds->index,
278 /* Port might have been part of a LAG that in turn was
279 * attached to a bridge.
282 dsa_port_bridge_leave(dp, dp->bridge_dev);
284 dp->lag_tx_enabled = false;
287 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info);
289 pr_err("DSA: failed to notify DSA_NOTIFIER_LAG_LEAVE: %d\n",
292 dsa_lag_unmap(dp->ds->dst, lag);
295 /* Must be called under rcu_read_lock() */
296 static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp,
298 struct netlink_ext_ack *extack)
300 struct dsa_switch *ds = dp->ds;
303 /* VLAN awareness was off, so the question is "can we turn it on".
304 * We may have had 8021q uppers, those need to go. Make sure we don't
305 * enter an inconsistent state: deny changing the VLAN awareness state
306 * as long as we have 8021q uppers.
308 if (vlan_filtering && dsa_is_user_port(ds, dp->index)) {
309 struct net_device *upper_dev, *slave = dp->slave;
310 struct net_device *br = dp->bridge_dev;
311 struct list_head *iter;
313 netdev_for_each_upper_dev_rcu(slave, upper_dev, iter) {
314 struct bridge_vlan_info br_info;
317 if (!is_vlan_dev(upper_dev))
320 vid = vlan_dev_vlan_id(upper_dev);
322 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the
323 * device, respectively the VID is not found, returning
324 * 0 means success, which is a failure for us here.
326 err = br_vlan_get_info(br, vid, &br_info);
328 NL_SET_ERR_MSG_MOD(extack,
329 "Must first remove VLAN uppers having VIDs also present in bridge");
335 if (!ds->vlan_filtering_is_global)
338 /* For cases where enabling/disabling VLAN awareness is global to the
339 * switch, we need to handle the case where multiple bridges span
340 * different ports of the same switch device and one of them has a
341 * different setting than what is being requested.
343 for (i = 0; i < ds->num_ports; i++) {
344 struct net_device *other_bridge;
346 other_bridge = dsa_to_port(ds, i)->bridge_dev;
349 /* If it's the same bridge, it also has same
350 * vlan_filtering setting => no need to check
352 if (other_bridge == dp->bridge_dev)
354 if (br_vlan_enabled(other_bridge) != vlan_filtering) {
355 NL_SET_ERR_MSG_MOD(extack,
356 "VLAN filtering is a global setting");
363 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
364 struct netlink_ext_ack *extack)
366 struct dsa_switch *ds = dp->ds;
370 if (!ds->ops->port_vlan_filtering)
373 /* We are called from dsa_slave_switchdev_blocking_event(),
374 * which is not under rcu_read_lock(), unlike
375 * dsa_slave_switchdev_event().
378 apply = dsa_port_can_apply_vlan_filtering(dp, vlan_filtering, extack);
383 if (dsa_port_is_vlan_filtering(dp) == vlan_filtering)
386 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering,
391 if (ds->vlan_filtering_is_global)
392 ds->vlan_filtering = vlan_filtering;
394 dp->vlan_filtering = vlan_filtering;
399 /* This enforces legacy behavior for switch drivers which assume they can't
400 * receive VLAN configuration when enslaved to a bridge with vlan_filtering=0
402 bool dsa_port_skip_vlan_configuration(struct dsa_port *dp)
404 struct dsa_switch *ds = dp->ds;
409 return (!ds->configure_vlan_while_not_filtering &&
410 !br_vlan_enabled(dp->bridge_dev));
413 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock)
415 unsigned long ageing_jiffies = clock_t_to_jiffies(ageing_clock);
416 unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
417 struct dsa_notifier_ageing_time_info info;
420 info.ageing_time = ageing_time;
422 err = dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
426 dp->ageing_time = ageing_time;
431 int dsa_port_pre_bridge_flags(const struct dsa_port *dp,
432 struct switchdev_brport_flags flags,
433 struct netlink_ext_ack *extack)
435 struct dsa_switch *ds = dp->ds;
437 if (!ds->ops->port_pre_bridge_flags)
440 return ds->ops->port_pre_bridge_flags(ds, dp->index, flags, extack);
443 int dsa_port_bridge_flags(const struct dsa_port *dp,
444 struct switchdev_brport_flags flags,
445 struct netlink_ext_ack *extack)
447 struct dsa_switch *ds = dp->ds;
449 if (!ds->ops->port_bridge_flags)
452 return ds->ops->port_bridge_flags(ds, dp->index, flags, extack);
455 int dsa_port_mrouter(struct dsa_port *dp, bool mrouter,
456 struct netlink_ext_ack *extack)
458 struct dsa_switch *ds = dp->ds;
460 if (!ds->ops->port_set_mrouter)
463 return ds->ops->port_set_mrouter(ds, dp->index, mrouter, extack);
466 int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu,
467 bool propagate_upstream)
469 struct dsa_notifier_mtu_info info = {
470 .sw_index = dp->ds->index,
471 .propagate_upstream = propagate_upstream,
476 return dsa_port_notify(dp, DSA_NOTIFIER_MTU, &info);
479 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
482 struct dsa_notifier_fdb_info info = {
483 .sw_index = dp->ds->index,
489 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info);
492 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
495 struct dsa_notifier_fdb_info info = {
496 .sw_index = dp->ds->index,
503 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
506 int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data)
508 struct dsa_switch *ds = dp->ds;
509 int port = dp->index;
511 if (!ds->ops->port_fdb_dump)
514 return ds->ops->port_fdb_dump(ds, port, cb, data);
517 int dsa_port_mdb_add(const struct dsa_port *dp,
518 const struct switchdev_obj_port_mdb *mdb)
520 struct dsa_notifier_mdb_info info = {
521 .sw_index = dp->ds->index,
526 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_ADD, &info);
529 int dsa_port_mdb_del(const struct dsa_port *dp,
530 const struct switchdev_obj_port_mdb *mdb)
532 struct dsa_notifier_mdb_info info = {
533 .sw_index = dp->ds->index,
538 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
541 int dsa_port_vlan_add(struct dsa_port *dp,
542 const struct switchdev_obj_port_vlan *vlan,
543 struct netlink_ext_ack *extack)
545 struct dsa_notifier_vlan_info info = {
546 .sw_index = dp->ds->index,
552 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);
555 int dsa_port_vlan_del(struct dsa_port *dp,
556 const struct switchdev_obj_port_vlan *vlan)
558 struct dsa_notifier_vlan_info info = {
559 .sw_index = dp->ds->index,
564 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
567 int dsa_port_mrp_add(const struct dsa_port *dp,
568 const struct switchdev_obj_mrp *mrp)
570 struct dsa_notifier_mrp_info info = {
571 .sw_index = dp->ds->index,
576 return dsa_port_notify(dp, DSA_NOTIFIER_MRP_ADD, &info);
579 int dsa_port_mrp_del(const struct dsa_port *dp,
580 const struct switchdev_obj_mrp *mrp)
582 struct dsa_notifier_mrp_info info = {
583 .sw_index = dp->ds->index,
588 return dsa_port_notify(dp, DSA_NOTIFIER_MRP_DEL, &info);
591 int dsa_port_mrp_add_ring_role(const struct dsa_port *dp,
592 const struct switchdev_obj_ring_role_mrp *mrp)
594 struct dsa_notifier_mrp_ring_role_info info = {
595 .sw_index = dp->ds->index,
600 return dsa_port_notify(dp, DSA_NOTIFIER_MRP_ADD_RING_ROLE, &info);
603 int dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
604 const struct switchdev_obj_ring_role_mrp *mrp)
606 struct dsa_notifier_mrp_ring_role_info info = {
607 .sw_index = dp->ds->index,
612 return dsa_port_notify(dp, DSA_NOTIFIER_MRP_DEL_RING_ROLE, &info);
615 void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
616 const struct dsa_device_ops *tag_ops)
618 cpu_dp->filter = tag_ops->filter;
619 cpu_dp->rcv = tag_ops->rcv;
620 cpu_dp->tag_ops = tag_ops;
623 static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
625 struct device_node *phy_dn;
626 struct phy_device *phydev;
628 phy_dn = of_parse_phandle(dp->dn, "phy-handle", 0);
632 phydev = of_phy_find_device(phy_dn);
635 return ERR_PTR(-EPROBE_DEFER);
642 static void dsa_port_phylink_validate(struct phylink_config *config,
643 unsigned long *supported,
644 struct phylink_link_state *state)
646 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
647 struct dsa_switch *ds = dp->ds;
649 if (!ds->ops->phylink_validate)
652 ds->ops->phylink_validate(ds, dp->index, supported, state);
655 static void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
656 struct phylink_link_state *state)
658 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
659 struct dsa_switch *ds = dp->ds;
662 /* Only called for inband modes */
663 if (!ds->ops->phylink_mac_link_state) {
668 err = ds->ops->phylink_mac_link_state(ds, dp->index, state);
670 dev_err(ds->dev, "p%d: phylink_mac_link_state() failed: %d\n",
676 static void dsa_port_phylink_mac_config(struct phylink_config *config,
678 const struct phylink_link_state *state)
680 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
681 struct dsa_switch *ds = dp->ds;
683 if (!ds->ops->phylink_mac_config)
686 ds->ops->phylink_mac_config(ds, dp->index, mode, state);
689 static void dsa_port_phylink_mac_an_restart(struct phylink_config *config)
691 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
692 struct dsa_switch *ds = dp->ds;
694 if (!ds->ops->phylink_mac_an_restart)
697 ds->ops->phylink_mac_an_restart(ds, dp->index);
700 static void dsa_port_phylink_mac_link_down(struct phylink_config *config,
702 phy_interface_t interface)
704 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
705 struct phy_device *phydev = NULL;
706 struct dsa_switch *ds = dp->ds;
708 if (dsa_is_user_port(ds, dp->index))
709 phydev = dp->slave->phydev;
711 if (!ds->ops->phylink_mac_link_down) {
712 if (ds->ops->adjust_link && phydev)
713 ds->ops->adjust_link(ds, dp->index, phydev);
717 ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
720 static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
721 struct phy_device *phydev,
723 phy_interface_t interface,
724 int speed, int duplex,
725 bool tx_pause, bool rx_pause)
727 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
728 struct dsa_switch *ds = dp->ds;
730 if (!ds->ops->phylink_mac_link_up) {
731 if (ds->ops->adjust_link && phydev)
732 ds->ops->adjust_link(ds, dp->index, phydev);
736 ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
737 speed, duplex, tx_pause, rx_pause);
740 const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
741 .validate = dsa_port_phylink_validate,
742 .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
743 .mac_config = dsa_port_phylink_mac_config,
744 .mac_an_restart = dsa_port_phylink_mac_an_restart,
745 .mac_link_down = dsa_port_phylink_mac_link_down,
746 .mac_link_up = dsa_port_phylink_mac_link_up,
749 static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable)
751 struct dsa_switch *ds = dp->ds;
752 struct phy_device *phydev;
753 int port = dp->index;
756 phydev = dsa_port_get_phy_device(dp);
761 return PTR_ERR(phydev);
764 err = genphy_resume(phydev);
768 err = genphy_read_status(phydev);
772 err = genphy_suspend(phydev);
777 if (ds->ops->adjust_link)
778 ds->ops->adjust_link(ds, port, phydev);
780 dev_dbg(ds->dev, "enabled port's phy: %s", phydev_name(phydev));
783 put_device(&phydev->mdio.dev);
787 static int dsa_port_fixed_link_register_of(struct dsa_port *dp)
789 struct device_node *dn = dp->dn;
790 struct dsa_switch *ds = dp->ds;
791 struct phy_device *phydev;
792 int port = dp->index;
793 phy_interface_t mode;
796 err = of_phy_register_fixed_link(dn);
799 "failed to register the fixed PHY of port %d\n",
804 phydev = of_phy_find_device(dn);
806 err = of_get_phy_mode(dn, &mode);
808 mode = PHY_INTERFACE_MODE_NA;
809 phydev->interface = mode;
811 genphy_read_status(phydev);
813 if (ds->ops->adjust_link)
814 ds->ops->adjust_link(ds, port, phydev);
816 put_device(&phydev->mdio.dev);
821 static int dsa_port_phylink_register(struct dsa_port *dp)
823 struct dsa_switch *ds = dp->ds;
824 struct device_node *port_dn = dp->dn;
825 phy_interface_t mode;
828 err = of_get_phy_mode(port_dn, &mode);
830 mode = PHY_INTERFACE_MODE_NA;
832 dp->pl_config.dev = ds->dev;
833 dp->pl_config.type = PHYLINK_DEV;
834 dp->pl_config.pcs_poll = ds->pcs_poll;
836 dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn),
837 mode, &dsa_port_phylink_mac_ops);
838 if (IS_ERR(dp->pl)) {
839 pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl));
840 return PTR_ERR(dp->pl);
843 err = phylink_of_phy_connect(dp->pl, port_dn, 0);
844 if (err && err != -ENODEV) {
845 pr_err("could not attach to PHY: %d\n", err);
846 goto err_phy_connect;
852 phylink_destroy(dp->pl);
856 int dsa_port_link_register_of(struct dsa_port *dp)
858 struct dsa_switch *ds = dp->ds;
859 struct device_node *phy_np;
860 int port = dp->index;
862 if (!ds->ops->adjust_link) {
863 phy_np = of_parse_phandle(dp->dn, "phy-handle", 0);
864 if (of_phy_is_fixed_link(dp->dn) || phy_np) {
865 if (ds->ops->phylink_mac_link_down)
866 ds->ops->phylink_mac_link_down(ds, port,
867 MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
868 return dsa_port_phylink_register(dp);
874 "Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n");
876 if (of_phy_is_fixed_link(dp->dn))
877 return dsa_port_fixed_link_register_of(dp);
879 return dsa_port_setup_phy_of(dp, true);
882 void dsa_port_link_unregister_of(struct dsa_port *dp)
884 struct dsa_switch *ds = dp->ds;
886 if (!ds->ops->adjust_link && dp->pl) {
888 phylink_disconnect_phy(dp->pl);
890 phylink_destroy(dp->pl);
895 if (of_phy_is_fixed_link(dp->dn))
896 of_phy_deregister_fixed_link(dp->dn);
898 dsa_port_setup_phy_of(dp, false);
901 int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data)
903 struct phy_device *phydev;
904 int ret = -EOPNOTSUPP;
906 if (of_phy_is_fixed_link(dp->dn))
909 phydev = dsa_port_get_phy_device(dp);
910 if (IS_ERR_OR_NULL(phydev))
913 ret = phy_ethtool_get_strings(phydev, data);
914 put_device(&phydev->mdio.dev);
918 EXPORT_SYMBOL_GPL(dsa_port_get_phy_strings);
920 int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data)
922 struct phy_device *phydev;
923 int ret = -EOPNOTSUPP;
925 if (of_phy_is_fixed_link(dp->dn))
928 phydev = dsa_port_get_phy_device(dp);
929 if (IS_ERR_OR_NULL(phydev))
932 ret = phy_ethtool_get_stats(phydev, NULL, data);
933 put_device(&phydev->mdio.dev);
937 EXPORT_SYMBOL_GPL(dsa_port_get_ethtool_phy_stats);
939 int dsa_port_get_phy_sset_count(struct dsa_port *dp)
941 struct phy_device *phydev;
942 int ret = -EOPNOTSUPP;
944 if (of_phy_is_fixed_link(dp->dn))
947 phydev = dsa_port_get_phy_device(dp);
948 if (IS_ERR_OR_NULL(phydev))
951 ret = phy_ethtool_get_sset_count(phydev);
952 put_device(&phydev->mdio.dev);
956 EXPORT_SYMBOL_GPL(dsa_port_get_phy_sset_count);
958 int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr)
960 struct dsa_notifier_hsr_info info = {
961 .sw_index = dp->ds->index,
969 err = dsa_port_notify(dp, DSA_NOTIFIER_HSR_JOIN, &info);
976 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr)
978 struct dsa_notifier_hsr_info info = {
979 .sw_index = dp->ds->index,
987 err = dsa_port_notify(dp, DSA_NOTIFIER_HSR_LEAVE, &info);
989 pr_err("DSA: failed to notify DSA_NOTIFIER_HSR_LEAVE\n");