Lines Matching +full:dp +full:- +full:bridge

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
22 * dsa_port_notify - Notify the switching fabric of changes to a port
23 * @dp: port on which change occurred
25 * @v: event-specific value.
29 * reconfigure themselves for cross-chip operations. Can also be used to
33 static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v) in dsa_port_notify() argument
35 return dsa_tree_notify(dp->ds->dst, e, v); in dsa_port_notify()
38 static void dsa_port_notify_bridge_fdb_flush(const struct dsa_port *dp, u16 vid) in dsa_port_notify_bridge_fdb_flush() argument
40 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_notify_bridge_fdb_flush()
45 /* When the port becomes standalone it has already left the bridge. in dsa_port_notify_bridge_fdb_flush()
46 * Don't notify the bridge in that case. in dsa_port_notify_bridge_fdb_flush()
55 static void dsa_port_fast_age(const struct dsa_port *dp) in dsa_port_fast_age() argument
57 struct dsa_switch *ds = dp->ds; in dsa_port_fast_age()
59 if (!ds->ops->port_fast_age) in dsa_port_fast_age()
62 ds->ops->port_fast_age(ds, dp->index); in dsa_port_fast_age()
65 dsa_port_notify_bridge_fdb_flush(dp, 0); in dsa_port_fast_age()
68 static int dsa_port_vlan_fast_age(const struct dsa_port *dp, u16 vid) in dsa_port_vlan_fast_age() argument
70 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_fast_age()
73 if (!ds->ops->port_vlan_fast_age) in dsa_port_vlan_fast_age()
74 return -EOPNOTSUPP; in dsa_port_vlan_fast_age()
76 err = ds->ops->port_vlan_fast_age(ds, dp->index, vid); in dsa_port_vlan_fast_age()
79 dsa_port_notify_bridge_fdb_flush(dp, vid); in dsa_port_vlan_fast_age()
84 static int dsa_port_msti_fast_age(const struct dsa_port *dp, u16 msti) in dsa_port_msti_fast_age() argument
89 err = br_mst_get_info(dsa_port_bridge_dev_get(dp), msti, vids); in dsa_port_msti_fast_age()
94 err = dsa_port_vlan_fast_age(dp, vid); in dsa_port_msti_fast_age()
102 static bool dsa_port_can_configure_learning(struct dsa_port *dp) in dsa_port_can_configure_learning() argument
107 struct dsa_switch *ds = dp->ds; in dsa_port_can_configure_learning()
110 if (!ds->ops->port_bridge_flags || !ds->ops->port_pre_bridge_flags) in dsa_port_can_configure_learning()
113 err = ds->ops->port_pre_bridge_flags(ds, dp->index, flags, NULL); in dsa_port_can_configure_learning()
117 bool dsa_port_supports_hwtstamp(struct dsa_port *dp) in dsa_port_supports_hwtstamp() argument
119 struct dsa_switch *ds = dp->ds; in dsa_port_supports_hwtstamp()
123 if (!ds->ops->port_hwtstamp_get || !ds->ops->port_hwtstamp_set) in dsa_port_supports_hwtstamp()
128 * fail in copy_to_user() with -EFAULT, which hopefully is enough to in dsa_port_supports_hwtstamp()
131 err = ds->ops->port_hwtstamp_get(ds, dp->index, &ifr); in dsa_port_supports_hwtstamp()
132 return err != -EOPNOTSUPP; in dsa_port_supports_hwtstamp()
135 int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) in dsa_port_set_state() argument
137 struct dsa_switch *ds = dp->ds; in dsa_port_set_state()
138 int port = dp->index; in dsa_port_set_state()
140 if (!ds->ops->port_stp_state_set) in dsa_port_set_state()
141 return -EOPNOTSUPP; in dsa_port_set_state()
143 ds->ops->port_stp_state_set(ds, port, state); in dsa_port_set_state()
145 if (!dsa_port_can_configure_learning(dp) || in dsa_port_set_state()
146 (do_fast_age && dp->learning)) { in dsa_port_set_state()
155 if ((dp->stp_state == BR_STATE_LEARNING || in dsa_port_set_state()
156 dp->stp_state == BR_STATE_FORWARDING) && in dsa_port_set_state()
160 dsa_port_fast_age(dp); in dsa_port_set_state()
163 dp->stp_state = state; in dsa_port_set_state()
168 static void dsa_port_set_state_now(struct dsa_port *dp, u8 state, in dsa_port_set_state_now() argument
171 struct dsa_switch *ds = dp->ds; in dsa_port_set_state_now()
174 err = dsa_port_set_state(dp, state, do_fast_age); in dsa_port_set_state_now()
175 if (err && err != -EOPNOTSUPP) { in dsa_port_set_state_now()
176 dev_err(ds->dev, "port %d failed to set STP state %u: %pe\n", in dsa_port_set_state_now()
177 dp->index, state, ERR_PTR(err)); in dsa_port_set_state_now()
181 int dsa_port_set_mst_state(struct dsa_port *dp, in dsa_port_set_mst_state() argument
185 struct dsa_switch *ds = dp->ds; in dsa_port_set_mst_state()
189 if (!ds->ops->port_mst_state_set) in dsa_port_set_mst_state()
190 return -EOPNOTSUPP; in dsa_port_set_mst_state()
192 err = br_mst_get_state(dsa_port_to_bridge_port(dp), state->msti, in dsa_port_set_mst_state()
197 err = ds->ops->port_mst_state_set(ds, dp->index, state); in dsa_port_set_mst_state()
201 if (!(dp->learning && in dsa_port_set_mst_state()
204 (state->state == BR_STATE_DISABLED || in dsa_port_set_mst_state()
205 state->state == BR_STATE_BLOCKING || in dsa_port_set_mst_state()
206 state->state == BR_STATE_LISTENING))) in dsa_port_set_mst_state()
209 err = dsa_port_msti_fast_age(dp, state->msti); in dsa_port_set_mst_state()
217 int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy) in dsa_port_enable_rt() argument
219 struct dsa_switch *ds = dp->ds; in dsa_port_enable_rt()
220 int port = dp->index; in dsa_port_enable_rt()
223 if (ds->ops->port_enable) { in dsa_port_enable_rt()
224 err = ds->ops->port_enable(ds, port, phy); in dsa_port_enable_rt()
229 if (!dp->bridge) in dsa_port_enable_rt()
230 dsa_port_set_state_now(dp, BR_STATE_FORWARDING, false); in dsa_port_enable_rt()
232 if (dp->pl) in dsa_port_enable_rt()
233 phylink_start(dp->pl); in dsa_port_enable_rt()
238 int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy) in dsa_port_enable() argument
243 err = dsa_port_enable_rt(dp, phy); in dsa_port_enable()
249 void dsa_port_disable_rt(struct dsa_port *dp) in dsa_port_disable_rt() argument
251 struct dsa_switch *ds = dp->ds; in dsa_port_disable_rt()
252 int port = dp->index; in dsa_port_disable_rt()
254 if (dp->pl) in dsa_port_disable_rt()
255 phylink_stop(dp->pl); in dsa_port_disable_rt()
257 if (!dp->bridge) in dsa_port_disable_rt()
258 dsa_port_set_state_now(dp, BR_STATE_DISABLED, false); in dsa_port_disable_rt()
260 if (ds->ops->port_disable) in dsa_port_disable_rt()
261 ds->ops->port_disable(ds, port); in dsa_port_disable_rt()
264 void dsa_port_disable(struct dsa_port *dp) in dsa_port_disable() argument
267 dsa_port_disable_rt(dp); in dsa_port_disable()
271 static void dsa_port_reset_vlan_filtering(struct dsa_port *dp, in dsa_port_reset_vlan_filtering() argument
272 struct dsa_bridge bridge) in dsa_port_reset_vlan_filtering() argument
276 struct dsa_switch *ds = dp->ds; in dsa_port_reset_vlan_filtering()
281 if (ds->needs_standalone_vlan_filtering && in dsa_port_reset_vlan_filtering()
282 !br_vlan_enabled(bridge.dev)) { in dsa_port_reset_vlan_filtering()
285 } else if (!ds->needs_standalone_vlan_filtering && in dsa_port_reset_vlan_filtering()
286 br_vlan_enabled(bridge.dev)) { in dsa_port_reset_vlan_filtering()
291 /* If the bridge was vlan_filtering, the bridge core doesn't trigger an in dsa_port_reset_vlan_filtering()
297 * VLAN-aware bridge. in dsa_port_reset_vlan_filtering()
299 if (change_vlan_filtering && ds->vlan_filtering_is_global) { in dsa_port_reset_vlan_filtering()
313 err = dsa_port_vlan_filtering(dp, vlan_filtering, &extack); in dsa_port_reset_vlan_filtering()
315 dev_err(ds->dev, "port %d: %s\n", dp->index, in dsa_port_reset_vlan_filtering()
318 if (err && err != -EOPNOTSUPP) { in dsa_port_reset_vlan_filtering()
319 dev_err(ds->dev, in dsa_port_reset_vlan_filtering()
321 dp->index, vlan_filtering, ERR_PTR(err)); in dsa_port_reset_vlan_filtering()
325 static int dsa_port_inherit_brport_flags(struct dsa_port *dp, in dsa_port_inherit_brport_flags() argument
330 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_inherit_brport_flags()
341 err = dsa_port_bridge_flags(dp, flags, extack); in dsa_port_inherit_brport_flags()
342 if (err && err != -EOPNOTSUPP) in dsa_port_inherit_brport_flags()
349 static void dsa_port_clear_brport_flags(struct dsa_port *dp) in dsa_port_clear_brport_flags() argument
362 err = dsa_port_bridge_flags(dp, flags, NULL); in dsa_port_clear_brport_flags()
363 if (err && err != -EOPNOTSUPP) in dsa_port_clear_brport_flags()
364 dev_err(dp->ds->dev, in dsa_port_clear_brport_flags()
365 "failed to clear bridge port flag %lu: %pe\n", in dsa_port_clear_brport_flags()
370 static int dsa_port_switchdev_sync_attrs(struct dsa_port *dp, in dsa_port_switchdev_sync_attrs() argument
373 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_switchdev_sync_attrs()
374 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_switchdev_sync_attrs()
377 err = dsa_port_inherit_brport_flags(dp, extack); in dsa_port_switchdev_sync_attrs()
381 err = dsa_port_set_state(dp, br_port_get_stp_state(brport_dev), false); in dsa_port_switchdev_sync_attrs()
382 if (err && err != -EOPNOTSUPP) in dsa_port_switchdev_sync_attrs()
385 err = dsa_port_vlan_filtering(dp, br_vlan_enabled(br), extack); in dsa_port_switchdev_sync_attrs()
386 if (err && err != -EOPNOTSUPP) in dsa_port_switchdev_sync_attrs()
389 err = dsa_port_ageing_time(dp, br_get_ageing_time(br)); in dsa_port_switchdev_sync_attrs()
390 if (err && err != -EOPNOTSUPP) in dsa_port_switchdev_sync_attrs()
396 static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp, in dsa_port_switchdev_unsync_attrs() argument
397 struct dsa_bridge bridge) in dsa_port_switchdev_unsync_attrs() argument
401 * The bridge only emits SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS events in dsa_port_switchdev_unsync_attrs()
406 * for example, when a port leaves a LAG that offloads the bridge, in dsa_port_switchdev_unsync_attrs()
407 * it becomes standalone, but as far as the bridge is concerned, no in dsa_port_switchdev_unsync_attrs()
410 dsa_port_clear_brport_flags(dp); in dsa_port_switchdev_unsync_attrs()
412 /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer, in dsa_port_switchdev_unsync_attrs()
415 dsa_port_set_state_now(dp, BR_STATE_FORWARDING, true); in dsa_port_switchdev_unsync_attrs()
417 dsa_port_reset_vlan_filtering(dp, bridge); in dsa_port_switchdev_unsync_attrs()
424 static int dsa_port_bridge_create(struct dsa_port *dp, in dsa_port_bridge_create() argument
428 struct dsa_switch *ds = dp->ds; in dsa_port_bridge_create()
429 struct dsa_bridge *bridge; in dsa_port_bridge_create() local
431 bridge = dsa_tree_bridge_find(ds->dst, br); in dsa_port_bridge_create()
432 if (bridge) { in dsa_port_bridge_create()
433 refcount_inc(&bridge->refcount); in dsa_port_bridge_create()
434 dp->bridge = bridge; in dsa_port_bridge_create()
438 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); in dsa_port_bridge_create()
439 if (!bridge) in dsa_port_bridge_create()
440 return -ENOMEM; in dsa_port_bridge_create()
442 refcount_set(&bridge->refcount, 1); in dsa_port_bridge_create()
444 bridge->dev = br; in dsa_port_bridge_create()
446 bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges); in dsa_port_bridge_create()
447 if (ds->max_num_bridges && !bridge->num) { in dsa_port_bridge_create()
450 kfree(bridge); in dsa_port_bridge_create()
451 return -EOPNOTSUPP; in dsa_port_bridge_create()
454 dp->bridge = bridge; in dsa_port_bridge_create()
459 static void dsa_port_bridge_destroy(struct dsa_port *dp, in dsa_port_bridge_destroy() argument
462 struct dsa_bridge *bridge = dp->bridge; in dsa_port_bridge_destroy() local
464 dp->bridge = NULL; in dsa_port_bridge_destroy()
466 if (!refcount_dec_and_test(&bridge->refcount)) in dsa_port_bridge_destroy()
469 if (bridge->num) in dsa_port_bridge_destroy()
470 dsa_bridge_num_put(br, bridge->num); in dsa_port_bridge_destroy()
472 kfree(bridge); in dsa_port_bridge_destroy()
475 static bool dsa_port_supports_mst(struct dsa_port *dp) in dsa_port_supports_mst() argument
477 struct dsa_switch *ds = dp->ds; in dsa_port_supports_mst()
479 return ds->ops->vlan_msti_set && in dsa_port_supports_mst()
480 ds->ops->port_mst_state_set && in dsa_port_supports_mst()
481 ds->ops->port_vlan_fast_age && in dsa_port_supports_mst()
482 dsa_port_can_configure_learning(dp); in dsa_port_supports_mst()
485 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, in dsa_port_bridge_join() argument
489 .dp = dp, in dsa_port_bridge_join()
492 struct net_device *dev = dp->user; in dsa_port_bridge_join()
496 if (br_mst_enabled(br) && !dsa_port_supports_mst(dp)) in dsa_port_bridge_join()
497 return -EOPNOTSUPP; in dsa_port_bridge_join()
502 err = dsa_port_bridge_create(dp, br, extack); in dsa_port_bridge_join()
506 brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_bridge_join()
508 info.bridge = *dp->bridge; in dsa_port_bridge_join()
513 /* Drivers which support bridge TX forwarding should set this */ in dsa_port_bridge_join()
514 dp->bridge->tx_fwd_offload = info.tx_fwd_offload; in dsa_port_bridge_join()
516 err = switchdev_bridge_port_offload(brport_dev, dev, dp, in dsa_port_bridge_join()
519 dp->bridge->tx_fwd_offload, extack); in dsa_port_bridge_join()
523 err = dsa_port_switchdev_sync_attrs(dp, extack); in dsa_port_bridge_join()
530 switchdev_bridge_port_unoffload(brport_dev, dp, in dsa_port_bridge_join()
537 dsa_port_bridge_destroy(dp, br); in dsa_port_bridge_join()
541 void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br) in dsa_port_pre_bridge_leave() argument
543 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_pre_bridge_leave()
549 switchdev_bridge_port_unoffload(brport_dev, dp, in dsa_port_pre_bridge_leave()
556 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) in dsa_port_bridge_leave() argument
559 .dp = dp, in dsa_port_bridge_leave()
566 if (!dp->bridge) in dsa_port_bridge_leave()
569 info.bridge = *dp->bridge; in dsa_port_bridge_leave()
574 dsa_port_bridge_destroy(dp, br); in dsa_port_bridge_leave()
578 dev_err(dp->ds->dev, in dsa_port_bridge_leave()
580 dp->index, ERR_PTR(err)); in dsa_port_bridge_leave()
582 dsa_port_switchdev_unsync_attrs(dp, info.bridge); in dsa_port_bridge_leave()
585 int dsa_port_lag_change(struct dsa_port *dp, in dsa_port_lag_change() argument
589 .dp = dp, in dsa_port_lag_change()
593 if (!dp->lag) in dsa_port_lag_change()
601 tx_enabled = linfo->link_up && linfo->tx_enabled; in dsa_port_lag_change()
603 if (tx_enabled == dp->lag_tx_enabled) in dsa_port_lag_change()
606 dp->lag_tx_enabled = tx_enabled; in dsa_port_lag_change()
608 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info); in dsa_port_lag_change()
611 static int dsa_port_lag_create(struct dsa_port *dp, in dsa_port_lag_create() argument
614 struct dsa_switch *ds = dp->ds; in dsa_port_lag_create()
617 lag = dsa_tree_lag_find(ds->dst, lag_dev); in dsa_port_lag_create()
619 refcount_inc(&lag->refcount); in dsa_port_lag_create()
620 dp->lag = lag; in dsa_port_lag_create()
626 return -ENOMEM; in dsa_port_lag_create()
628 refcount_set(&lag->refcount, 1); in dsa_port_lag_create()
629 mutex_init(&lag->fdb_lock); in dsa_port_lag_create()
630 INIT_LIST_HEAD(&lag->fdbs); in dsa_port_lag_create()
631 lag->dev = lag_dev; in dsa_port_lag_create()
632 dsa_lag_map(ds->dst, lag); in dsa_port_lag_create()
633 dp->lag = lag; in dsa_port_lag_create()
638 static void dsa_port_lag_destroy(struct dsa_port *dp) in dsa_port_lag_destroy() argument
640 struct dsa_lag *lag = dp->lag; in dsa_port_lag_destroy()
642 dp->lag = NULL; in dsa_port_lag_destroy()
643 dp->lag_tx_enabled = false; in dsa_port_lag_destroy()
645 if (!refcount_dec_and_test(&lag->refcount)) in dsa_port_lag_destroy()
648 WARN_ON(!list_empty(&lag->fdbs)); in dsa_port_lag_destroy()
649 dsa_lag_unmap(dp->ds->dst, lag); in dsa_port_lag_destroy()
653 int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag_dev, in dsa_port_lag_join() argument
658 .dp = dp, in dsa_port_lag_join()
665 err = dsa_port_lag_create(dp, lag_dev); in dsa_port_lag_join()
669 info.lag = *dp->lag; in dsa_port_lag_join()
670 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_JOIN, &info); in dsa_port_lag_join()
678 err = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_lag_join()
685 dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info); in dsa_port_lag_join()
687 dsa_port_lag_destroy(dp); in dsa_port_lag_join()
692 void dsa_port_pre_lag_leave(struct dsa_port *dp, struct net_device *lag_dev) in dsa_port_pre_lag_leave() argument
694 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_pre_lag_leave()
697 dsa_port_pre_bridge_leave(dp, br); in dsa_port_pre_lag_leave()
700 void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev) in dsa_port_lag_leave() argument
702 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_lag_leave()
704 .dp = dp, in dsa_port_lag_leave()
708 if (!dp->lag) in dsa_port_lag_leave()
712 * attached to a bridge. in dsa_port_lag_leave()
715 dsa_port_bridge_leave(dp, br); in dsa_port_lag_leave()
717 info.lag = *dp->lag; in dsa_port_lag_leave()
719 dsa_port_lag_destroy(dp); in dsa_port_lag_leave()
721 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info); in dsa_port_lag_leave()
723 dev_err(dp->ds->dev, in dsa_port_lag_leave()
725 dp->index, ERR_PTR(err)); in dsa_port_lag_leave()
729 static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp, in dsa_port_can_apply_vlan_filtering() argument
733 struct dsa_switch *ds = dp->ds; in dsa_port_can_apply_vlan_filtering()
742 if (vlan_filtering && dsa_port_is_user(dp)) { in dsa_port_can_apply_vlan_filtering()
743 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_can_apply_vlan_filtering()
744 struct net_device *upper_dev, *user = dp->user; in dsa_port_can_apply_vlan_filtering()
756 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the in dsa_port_can_apply_vlan_filtering()
763 "Must first remove VLAN uppers having VIDs also present in bridge"); in dsa_port_can_apply_vlan_filtering()
769 if (!ds->vlan_filtering_is_global) in dsa_port_can_apply_vlan_filtering()
780 /* If it's the same bridge, it also has same in dsa_port_can_apply_vlan_filtering()
783 if (!other_br || other_br == dsa_port_bridge_dev_get(dp)) in dsa_port_can_apply_vlan_filtering()
795 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, in dsa_port_vlan_filtering() argument
798 bool old_vlan_filtering = dsa_port_is_vlan_filtering(dp); in dsa_port_vlan_filtering()
799 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_filtering()
803 if (!ds->ops->port_vlan_filtering) in dsa_port_vlan_filtering()
804 return -EOPNOTSUPP; in dsa_port_vlan_filtering()
811 apply = dsa_port_can_apply_vlan_filtering(dp, vlan_filtering, extack); in dsa_port_vlan_filtering()
814 return -EINVAL; in dsa_port_vlan_filtering()
816 if (dsa_port_is_vlan_filtering(dp) == vlan_filtering) in dsa_port_vlan_filtering()
819 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering, in dsa_port_vlan_filtering()
824 if (ds->vlan_filtering_is_global) { in dsa_port_vlan_filtering()
827 ds->vlan_filtering = vlan_filtering; in dsa_port_vlan_filtering()
830 struct net_device *user = other_dp->user; in dsa_port_vlan_filtering()
844 dp->vlan_filtering = vlan_filtering; in dsa_port_vlan_filtering()
846 err = dsa_user_manage_vlan_filtering(dp->user, in dsa_port_vlan_filtering()
855 ds->ops->port_vlan_filtering(ds, dp->index, old_vlan_filtering, NULL); in dsa_port_vlan_filtering()
857 if (ds->vlan_filtering_is_global) in dsa_port_vlan_filtering()
858 ds->vlan_filtering = old_vlan_filtering; in dsa_port_vlan_filtering()
860 dp->vlan_filtering = old_vlan_filtering; in dsa_port_vlan_filtering()
866 * receive VLAN configuration when joining a bridge with vlan_filtering=0
868 bool dsa_port_skip_vlan_configuration(struct dsa_port *dp) in dsa_port_skip_vlan_configuration() argument
870 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_skip_vlan_configuration()
871 struct dsa_switch *ds = dp->ds; in dsa_port_skip_vlan_configuration()
876 return !ds->configure_vlan_while_not_filtering && !br_vlan_enabled(br); in dsa_port_skip_vlan_configuration()
879 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock) in dsa_port_ageing_time() argument
888 err = dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info); in dsa_port_ageing_time()
892 dp->ageing_time = ageing_time; in dsa_port_ageing_time()
897 int dsa_port_mst_enable(struct dsa_port *dp, bool on, in dsa_port_mst_enable() argument
900 if (on && !dsa_port_supports_mst(dp)) { in dsa_port_mst_enable()
902 return -EINVAL; in dsa_port_mst_enable()
908 int dsa_port_pre_bridge_flags(const struct dsa_port *dp, in dsa_port_pre_bridge_flags() argument
912 struct dsa_switch *ds = dp->ds; in dsa_port_pre_bridge_flags()
914 if (!ds->ops->port_pre_bridge_flags) in dsa_port_pre_bridge_flags()
915 return -EINVAL; in dsa_port_pre_bridge_flags()
917 return ds->ops->port_pre_bridge_flags(ds, dp->index, flags, extack); in dsa_port_pre_bridge_flags()
920 int dsa_port_bridge_flags(struct dsa_port *dp, in dsa_port_bridge_flags() argument
924 struct dsa_switch *ds = dp->ds; in dsa_port_bridge_flags()
927 if (!ds->ops->port_bridge_flags) in dsa_port_bridge_flags()
928 return -EOPNOTSUPP; in dsa_port_bridge_flags()
930 err = ds->ops->port_bridge_flags(ds, dp->index, flags, extack); in dsa_port_bridge_flags()
937 if (learning == dp->learning) in dsa_port_bridge_flags()
940 if ((dp->learning && !learning) && in dsa_port_bridge_flags()
941 (dp->stp_state == BR_STATE_LEARNING || in dsa_port_bridge_flags()
942 dp->stp_state == BR_STATE_FORWARDING)) in dsa_port_bridge_flags()
943 dsa_port_fast_age(dp); in dsa_port_bridge_flags()
945 dp->learning = learning; in dsa_port_bridge_flags()
951 void dsa_port_set_host_flood(struct dsa_port *dp, bool uc, bool mc) in dsa_port_set_host_flood() argument
953 struct dsa_switch *ds = dp->ds; in dsa_port_set_host_flood()
955 if (ds->ops->port_set_host_flood) in dsa_port_set_host_flood()
956 ds->ops->port_set_host_flood(ds, dp->index, uc, mc); in dsa_port_set_host_flood()
959 int dsa_port_vlan_msti(struct dsa_port *dp, in dsa_port_vlan_msti() argument
962 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_msti()
964 if (!ds->ops->vlan_msti_set) in dsa_port_vlan_msti()
965 return -EOPNOTSUPP; in dsa_port_vlan_msti()
967 return ds->ops->vlan_msti_set(ds, *dp->bridge, msti); in dsa_port_vlan_msti()
970 int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu) in dsa_port_mtu_change() argument
973 .dp = dp, in dsa_port_mtu_change()
977 return dsa_port_notify(dp, DSA_NOTIFIER_MTU, &info); in dsa_port_mtu_change()
980 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, in dsa_port_fdb_add() argument
984 .dp = dp, in dsa_port_fdb_add()
989 .bridge = *dp->bridge, in dsa_port_fdb_add()
993 /* Refcounting takes bridge.num as a key, and should be global for all in dsa_port_fdb_add()
994 * bridges in the absence of FDB isolation, and per bridge otherwise. in dsa_port_fdb_add()
995 * Force the bridge.num to zero here in the absence of FDB isolation. in dsa_port_fdb_add()
997 if (!dp->ds->fdb_isolation) in dsa_port_fdb_add()
998 info.db.bridge.num = 0; in dsa_port_fdb_add()
1000 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info); in dsa_port_fdb_add()
1003 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, in dsa_port_fdb_del() argument
1007 .dp = dp, in dsa_port_fdb_del()
1012 .bridge = *dp->bridge, in dsa_port_fdb_del()
1016 if (!dp->ds->fdb_isolation) in dsa_port_fdb_del()
1017 info.db.bridge.num = 0; in dsa_port_fdb_del()
1019 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info); in dsa_port_fdb_del()
1022 static int dsa_port_host_fdb_add(struct dsa_port *dp, in dsa_port_host_fdb_add() argument
1027 .dp = dp, in dsa_port_host_fdb_add()
1033 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_ADD, &info); in dsa_port_host_fdb_add()
1036 int dsa_port_standalone_host_fdb_add(struct dsa_port *dp, in dsa_port_standalone_host_fdb_add() argument
1041 .dp = dp, in dsa_port_standalone_host_fdb_add()
1044 return dsa_port_host_fdb_add(dp, addr, vid, db); in dsa_port_standalone_host_fdb_add()
1047 int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, in dsa_port_bridge_host_fdb_add() argument
1050 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_bridge_host_fdb_add()
1053 .bridge = *dp->bridge, in dsa_port_bridge_host_fdb_add()
1057 if (!dp->ds->fdb_isolation) in dsa_port_bridge_host_fdb_add()
1058 db.bridge.num = 0; in dsa_port_bridge_host_fdb_add()
1064 if (conduit->priv_flags & IFF_UNICAST_FLT) { in dsa_port_bridge_host_fdb_add()
1070 return dsa_port_host_fdb_add(dp, addr, vid, db); in dsa_port_bridge_host_fdb_add()
1073 static int dsa_port_host_fdb_del(struct dsa_port *dp, in dsa_port_host_fdb_del() argument
1078 .dp = dp, in dsa_port_host_fdb_del()
1084 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info); in dsa_port_host_fdb_del()
1087 int dsa_port_standalone_host_fdb_del(struct dsa_port *dp, in dsa_port_standalone_host_fdb_del() argument
1092 .dp = dp, in dsa_port_standalone_host_fdb_del()
1095 return dsa_port_host_fdb_del(dp, addr, vid, db); in dsa_port_standalone_host_fdb_del()
1098 int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, in dsa_port_bridge_host_fdb_del() argument
1101 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_bridge_host_fdb_del()
1104 .bridge = *dp->bridge, in dsa_port_bridge_host_fdb_del()
1108 if (!dp->ds->fdb_isolation) in dsa_port_bridge_host_fdb_del()
1109 db.bridge.num = 0; in dsa_port_bridge_host_fdb_del()
1111 if (conduit->priv_flags & IFF_UNICAST_FLT) { in dsa_port_bridge_host_fdb_del()
1117 return dsa_port_host_fdb_del(dp, addr, vid, db); in dsa_port_bridge_host_fdb_del()
1120 int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, in dsa_port_lag_fdb_add() argument
1124 .lag = dp->lag, in dsa_port_lag_fdb_add()
1129 .bridge = *dp->bridge, in dsa_port_lag_fdb_add()
1133 if (!dp->ds->fdb_isolation) in dsa_port_lag_fdb_add()
1134 info.db.bridge.num = 0; in dsa_port_lag_fdb_add()
1136 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_ADD, &info); in dsa_port_lag_fdb_add()
1139 int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr, in dsa_port_lag_fdb_del() argument
1143 .lag = dp->lag, in dsa_port_lag_fdb_del()
1148 .bridge = *dp->bridge, in dsa_port_lag_fdb_del()
1152 if (!dp->ds->fdb_isolation) in dsa_port_lag_fdb_del()
1153 info.db.bridge.num = 0; in dsa_port_lag_fdb_del()
1155 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_DEL, &info); in dsa_port_lag_fdb_del()
1158 int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data) in dsa_port_fdb_dump() argument
1160 struct dsa_switch *ds = dp->ds; in dsa_port_fdb_dump()
1161 int port = dp->index; in dsa_port_fdb_dump()
1163 if (!ds->ops->port_fdb_dump) in dsa_port_fdb_dump()
1164 return -EOPNOTSUPP; in dsa_port_fdb_dump()
1166 return ds->ops->port_fdb_dump(ds, port, cb, data); in dsa_port_fdb_dump()
1169 int dsa_port_mdb_add(const struct dsa_port *dp, in dsa_port_mdb_add() argument
1173 .dp = dp, in dsa_port_mdb_add()
1177 .bridge = *dp->bridge, in dsa_port_mdb_add()
1181 if (!dp->ds->fdb_isolation) in dsa_port_mdb_add()
1182 info.db.bridge.num = 0; in dsa_port_mdb_add()
1184 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_ADD, &info); in dsa_port_mdb_add()
1187 int dsa_port_mdb_del(const struct dsa_port *dp, in dsa_port_mdb_del() argument
1191 .dp = dp, in dsa_port_mdb_del()
1195 .bridge = *dp->bridge, in dsa_port_mdb_del()
1199 if (!dp->ds->fdb_isolation) in dsa_port_mdb_del()
1200 info.db.bridge.num = 0; in dsa_port_mdb_del()
1202 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info); in dsa_port_mdb_del()
1205 static int dsa_port_host_mdb_add(const struct dsa_port *dp, in dsa_port_host_mdb_add() argument
1210 .dp = dp, in dsa_port_host_mdb_add()
1215 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_ADD, &info); in dsa_port_host_mdb_add()
1218 int dsa_port_standalone_host_mdb_add(const struct dsa_port *dp, in dsa_port_standalone_host_mdb_add() argument
1223 .dp = dp, in dsa_port_standalone_host_mdb_add()
1226 return dsa_port_host_mdb_add(dp, mdb, db); in dsa_port_standalone_host_mdb_add()
1229 int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp, in dsa_port_bridge_host_mdb_add() argument
1232 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_bridge_host_mdb_add()
1235 .bridge = *dp->bridge, in dsa_port_bridge_host_mdb_add()
1239 if (!dp->ds->fdb_isolation) in dsa_port_bridge_host_mdb_add()
1240 db.bridge.num = 0; in dsa_port_bridge_host_mdb_add()
1242 err = dev_mc_add(conduit, mdb->addr); in dsa_port_bridge_host_mdb_add()
1246 return dsa_port_host_mdb_add(dp, mdb, db); in dsa_port_bridge_host_mdb_add()
1249 static int dsa_port_host_mdb_del(const struct dsa_port *dp, in dsa_port_host_mdb_del() argument
1254 .dp = dp, in dsa_port_host_mdb_del()
1259 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info); in dsa_port_host_mdb_del()
1262 int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp, in dsa_port_standalone_host_mdb_del() argument
1267 .dp = dp, in dsa_port_standalone_host_mdb_del()
1270 return dsa_port_host_mdb_del(dp, mdb, db); in dsa_port_standalone_host_mdb_del()
1273 int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp, in dsa_port_bridge_host_mdb_del() argument
1276 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_bridge_host_mdb_del()
1279 .bridge = *dp->bridge, in dsa_port_bridge_host_mdb_del()
1283 if (!dp->ds->fdb_isolation) in dsa_port_bridge_host_mdb_del()
1284 db.bridge.num = 0; in dsa_port_bridge_host_mdb_del()
1286 err = dev_mc_del(conduit, mdb->addr); in dsa_port_bridge_host_mdb_del()
1290 return dsa_port_host_mdb_del(dp, mdb, db); in dsa_port_bridge_host_mdb_del()
1293 int dsa_port_vlan_add(struct dsa_port *dp, in dsa_port_vlan_add() argument
1298 .dp = dp, in dsa_port_vlan_add()
1303 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info); in dsa_port_vlan_add()
1306 int dsa_port_vlan_del(struct dsa_port *dp, in dsa_port_vlan_del() argument
1310 .dp = dp, in dsa_port_vlan_del()
1314 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info); in dsa_port_vlan_del()
1317 int dsa_port_host_vlan_add(struct dsa_port *dp, in dsa_port_host_vlan_add() argument
1321 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_host_vlan_add()
1323 .dp = dp, in dsa_port_host_vlan_add()
1329 err = dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_ADD, &info); in dsa_port_host_vlan_add()
1330 if (err && err != -EOPNOTSUPP) in dsa_port_host_vlan_add()
1333 vlan_vid_add(conduit, htons(ETH_P_8021Q), vlan->vid); in dsa_port_host_vlan_add()
1338 int dsa_port_host_vlan_del(struct dsa_port *dp, in dsa_port_host_vlan_del() argument
1341 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_port_host_vlan_del()
1343 .dp = dp, in dsa_port_host_vlan_del()
1348 err = dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_DEL, &info); in dsa_port_host_vlan_del()
1349 if (err && err != -EOPNOTSUPP) in dsa_port_host_vlan_del()
1352 vlan_vid_del(conduit, htons(ETH_P_8021Q), vlan->vid); in dsa_port_host_vlan_del()
1357 int dsa_port_mrp_add(const struct dsa_port *dp, in dsa_port_mrp_add() argument
1360 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_add()
1362 if (!ds->ops->port_mrp_add) in dsa_port_mrp_add()
1363 return -EOPNOTSUPP; in dsa_port_mrp_add()
1365 return ds->ops->port_mrp_add(ds, dp->index, mrp); in dsa_port_mrp_add()
1368 int dsa_port_mrp_del(const struct dsa_port *dp, in dsa_port_mrp_del() argument
1371 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_del()
1373 if (!ds->ops->port_mrp_del) in dsa_port_mrp_del()
1374 return -EOPNOTSUPP; in dsa_port_mrp_del()
1376 return ds->ops->port_mrp_del(ds, dp->index, mrp); in dsa_port_mrp_del()
1379 int dsa_port_mrp_add_ring_role(const struct dsa_port *dp, in dsa_port_mrp_add_ring_role() argument
1382 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_add_ring_role()
1384 if (!ds->ops->port_mrp_add_ring_role) in dsa_port_mrp_add_ring_role()
1385 return -EOPNOTSUPP; in dsa_port_mrp_add_ring_role()
1387 return ds->ops->port_mrp_add_ring_role(ds, dp->index, mrp); in dsa_port_mrp_add_ring_role()
1390 int dsa_port_mrp_del_ring_role(const struct dsa_port *dp, in dsa_port_mrp_del_ring_role() argument
1393 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_del_ring_role()
1395 if (!ds->ops->port_mrp_del_ring_role) in dsa_port_mrp_del_ring_role()
1396 return -EOPNOTSUPP; in dsa_port_mrp_del_ring_role()
1398 return ds->ops->port_mrp_del_ring_role(ds, dp->index, mrp); in dsa_port_mrp_del_ring_role()
1401 static int dsa_port_assign_conduit(struct dsa_port *dp, in dsa_port_assign_conduit() argument
1406 struct dsa_switch *ds = dp->ds; in dsa_port_assign_conduit()
1407 int port = dp->index, err; in dsa_port_assign_conduit()
1409 err = ds->ops->port_change_conduit(ds, port, conduit, extack); in dsa_port_assign_conduit()
1411 dev_err(ds->dev, "port %d failed to assign conduit %s: %pe\n", in dsa_port_assign_conduit()
1412 port, conduit->name, ERR_PTR(err)); in dsa_port_assign_conduit()
1417 dp->cpu_dp = conduit->dsa_ptr; in dsa_port_assign_conduit()
1418 dp->cpu_port_in_lag = netif_is_lag_master(conduit); in dsa_port_assign_conduit()
1423 /* Change the dp->cpu_dp affinity for a user port. Note that both cross-chip
1424 * notifiers and drivers have implicit assumptions about user-to-CPU-port
1431 int dsa_port_change_conduit(struct dsa_port *dp, struct net_device *conduit, in dsa_port_change_conduit() argument
1434 struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp); in dsa_port_change_conduit()
1435 struct net_device *old_conduit = dsa_port_to_conduit(dp); in dsa_port_change_conduit()
1436 struct net_device *dev = dp->user; in dsa_port_change_conduit()
1437 struct dsa_switch *ds = dp->ds; in dsa_port_change_conduit()
1442 * migrated, so dynamically unoffload and later reoffload the bridge in dsa_port_change_conduit()
1446 dsa_port_pre_bridge_leave(dp, bridge_dev); in dsa_port_change_conduit()
1447 dsa_port_bridge_leave(dp, bridge_dev); in dsa_port_change_conduit()
1451 * under a bridge, either due to ds->vlan_filtering_is_global or in dsa_port_change_conduit()
1452 * ds->needs_standalone_vlan_filtering. In turn this means VLANs in dsa_port_change_conduit()
1455 vlan_filtering = dsa_port_is_vlan_filtering(dp); in dsa_port_change_conduit()
1470 /* If live-changing, we also need to uninstall the user device address in dsa_port_change_conduit()
1473 if (dev->flags & IFF_UP) in dsa_port_change_conduit()
1476 err = dsa_port_assign_conduit(dp, conduit, extack, true); in dsa_port_change_conduit()
1483 if (is_zero_ether_addr(dp->mac)) in dsa_port_change_conduit()
1486 /* If live-changing, we need to install the user device address to the in dsa_port_change_conduit()
1489 if (dev->flags & IFF_UP) { in dsa_port_change_conduit()
1490 err = dsa_user_host_uc_install(dev, dev->dev_addr); in dsa_port_change_conduit()
1510 err = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_change_conduit()
1511 if (err && err == -EOPNOTSUPP) { in dsa_port_change_conduit()
1513 "Failed to reoffload bridge"); in dsa_port_change_conduit()
1527 if (dev->flags & IFF_UP) in dsa_port_change_conduit()
1531 if (is_zero_ether_addr(dp->mac)) in dsa_port_change_conduit()
1534 dsa_port_assign_conduit(dp, old_conduit, NULL, false); in dsa_port_change_conduit()
1538 if (dev->flags & IFF_UP) { in dsa_port_change_conduit()
1539 tmp = dsa_user_host_uc_install(dev, dev->dev_addr); in dsa_port_change_conduit()
1541 dev_err(ds->dev, in dsa_port_change_conduit()
1543 dp->index, ERR_PTR(tmp)); in dsa_port_change_conduit()
1552 dev_err(ds->dev, in dsa_port_change_conduit()
1554 dp->index, ERR_PTR(tmp)); in dsa_port_change_conduit()
1560 tmp = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_change_conduit()
1562 dev_err(ds->dev, in dsa_port_change_conduit()
1563 "port %d failed to rejoin bridge %s: %pe\n", in dsa_port_change_conduit()
1564 dp->index, bridge_dev->name, ERR_PTR(tmp)); in dsa_port_change_conduit()
1574 cpu_dp->rcv = tag_ops->rcv; in dsa_port_set_tag_protocol()
1575 cpu_dp->tag_ops = tag_ops; in dsa_port_set_tag_protocol()
1582 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_port_phylink_mac_select_pcs() local
1583 struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP); in dsa_port_phylink_mac_select_pcs()
1584 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_select_pcs()
1586 if (ds->ops->phylink_mac_select_pcs) in dsa_port_phylink_mac_select_pcs()
1587 pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface); in dsa_port_phylink_mac_select_pcs()
1596 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_port_phylink_mac_config() local
1597 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_config()
1599 if (!ds->ops->phylink_mac_config) in dsa_port_phylink_mac_config()
1602 ds->ops->phylink_mac_config(ds, dp->index, mode, state); in dsa_port_phylink_mac_config()
1609 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_port_phylink_mac_link_down() local
1610 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_link_down()
1612 if (!ds->ops->phylink_mac_link_down) in dsa_port_phylink_mac_link_down()
1615 ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface); in dsa_port_phylink_mac_link_down()
1625 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_port_phylink_mac_link_up() local
1626 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_link_up()
1628 if (!ds->ops->phylink_mac_link_up) in dsa_port_phylink_mac_link_up()
1631 ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev, in dsa_port_phylink_mac_link_up()
1642 int dsa_port_phylink_create(struct dsa_port *dp) in dsa_port_phylink_create() argument
1645 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_create()
1650 err = of_get_phy_mode(dp->dn, &mode); in dsa_port_phylink_create()
1654 if (ds->ops->phylink_get_caps) { in dsa_port_phylink_create()
1655 ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); in dsa_port_phylink_create()
1659 __set_bit(mode, dp->pl_config.supported_interfaces); in dsa_port_phylink_create()
1662 dp->pl_config.supported_interfaces); in dsa_port_phylink_create()
1664 dp->pl_config.supported_interfaces); in dsa_port_phylink_create()
1669 if (ds->phylink_mac_ops) in dsa_port_phylink_create()
1670 mac_ops = ds->phylink_mac_ops; in dsa_port_phylink_create()
1672 pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode, in dsa_port_phylink_create()
1679 dp->pl = pl; in dsa_port_phylink_create()
1684 void dsa_port_phylink_destroy(struct dsa_port *dp) in dsa_port_phylink_destroy() argument
1686 phylink_destroy(dp->pl); in dsa_port_phylink_destroy()
1687 dp->pl = NULL; in dsa_port_phylink_destroy()
1690 static int dsa_shared_port_phylink_register(struct dsa_port *dp) in dsa_shared_port_phylink_register() argument
1692 struct dsa_switch *ds = dp->ds; in dsa_shared_port_phylink_register()
1693 struct device_node *port_dn = dp->dn; in dsa_shared_port_phylink_register()
1696 dp->pl_config.dev = ds->dev; in dsa_shared_port_phylink_register()
1697 dp->pl_config.type = PHYLINK_DEV; in dsa_shared_port_phylink_register()
1699 err = dsa_port_phylink_create(dp); in dsa_shared_port_phylink_register()
1703 err = phylink_of_phy_connect(dp->pl, port_dn, 0); in dsa_shared_port_phylink_register()
1704 if (err && err != -ENODEV) { in dsa_shared_port_phylink_register()
1712 dsa_port_phylink_destroy(dp); in dsa_shared_port_phylink_register()
1718 * link management perspective (phy-handle, fixed-link, etc). Additionally, the
1719 * phy-mode may be absent. The interpretation of these port OF nodes depends on
1722 * User ports with no phy-handle or fixed-link are expected to connect to an
1723 * internal PHY located on the ds->user_mii_bus at an MDIO address equal to
1726 * Shared (CPU and DSA) ports with no phy-handle or fixed-link are expected to
1727 * operate at the maximum speed that their phy-mode is capable of. If the
1728 * phy-mode is absent, they are expected to operate using the phy-mode
1731 * if the phy-mode is a SERDES link, whether in-band autoneg is expected to be
1741 * a fixed-link, a phy-handle, or a managed = "in-band-status" property.
1768 "brcm,bcm53010-srab",
1769 "brcm,bcm53011-srab",
1770 "brcm,bcm53012-srab",
1771 "brcm,bcm53018-srab",
1772 "brcm,bcm53019-srab",
1773 "brcm,bcm5301x-srab",
1774 "brcm,bcm11360-srab",
1775 "brcm,bcm58522-srab",
1776 "brcm,bcm58525-srab",
1777 "brcm,bcm58535-srab",
1778 "brcm,bcm58622-srab",
1779 "brcm,bcm58623-srab",
1780 "brcm,bcm58625-srab",
1781 "brcm,bcm88312-srab",
1782 "brcm,cygnus-srab",
1783 "brcm,nsp-srab",
1784 "brcm,omega-srab",
1785 "brcm,bcm3384-switch",
1786 "brcm,bcm6328-switch",
1787 "brcm,bcm6368-switch",
1788 "brcm,bcm63xx-switch",
1791 "brcm,bcm7445-switch-v4.0",
1792 "brcm,bcm7278-switch-v4.0",
1793 "brcm,bcm7278-switch-v4.8",
1796 "lantiq,xrx200-gswip",
1797 "lantiq,xrx300-gswip",
1798 "lantiq,xrx330-gswip",
1822 "smsc,lan9303-mdio",
1825 "smsc,lan9303-i2c",
1830 static void dsa_shared_port_validate_of(struct dsa_port *dp, in dsa_shared_port_validate_of() argument
1834 struct device_node *dn = dp->dn, *phy_np; in dsa_shared_port_validate_of()
1835 struct dsa_switch *ds = dp->ds; in dsa_shared_port_validate_of()
1843 dev_err(ds->dev, in dsa_shared_port_validate_of()
1844 "OF node %pOF of %s port %d lacks the required \"phy-mode\" property\n", in dsa_shared_port_validate_of()
1845 dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_validate_of()
1849 * managed = "in-band-status" in dsa_shared_port_validate_of()
1854 phy_np = of_parse_phandle(dn, "phy-handle", 0); in dsa_shared_port_validate_of()
1862 dev_err(ds->dev, in dsa_shared_port_validate_of()
1863 …"OF node %pOF of %s port %d lacks the required \"phy-handle\", \"fixed-link\" or \"managed\" prope… in dsa_shared_port_validate_of()
1864 dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_validate_of()
1867 static void dsa_shared_port_link_down(struct dsa_port *dp) in dsa_shared_port_link_down() argument
1869 struct dsa_switch *ds = dp->ds; in dsa_shared_port_link_down()
1871 if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down) in dsa_shared_port_link_down()
1872 ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED, in dsa_shared_port_link_down()
1874 else if (ds->ops->phylink_mac_link_down) in dsa_shared_port_link_down()
1875 ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED, in dsa_shared_port_link_down()
1879 int dsa_shared_port_link_register_of(struct dsa_port *dp) in dsa_shared_port_link_register_of() argument
1881 struct dsa_switch *ds = dp->ds; in dsa_shared_port_link_register_of()
1885 dsa_shared_port_validate_of(dp, &missing_phy_mode, in dsa_shared_port_link_register_of()
1889 !of_device_compatible_match(ds->dev->of_node, in dsa_shared_port_link_register_of()
1891 return -EINVAL; in dsa_shared_port_link_register_of()
1894 dev_warn(ds->dev, in dsa_shared_port_link_register_of()
1896 dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_link_register_of()
1898 dsa_shared_port_link_down(dp); in dsa_shared_port_link_register_of()
1900 return dsa_shared_port_phylink_register(dp); in dsa_shared_port_link_register_of()
1906 void dsa_shared_port_link_unregister_of(struct dsa_port *dp) in dsa_shared_port_link_unregister_of() argument
1908 if (dp->pl) { in dsa_shared_port_link_unregister_of()
1910 phylink_disconnect_phy(dp->pl); in dsa_shared_port_link_unregister_of()
1912 dsa_port_phylink_destroy(dp); in dsa_shared_port_link_unregister_of()
1917 int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr, in dsa_port_hsr_join() argument
1920 struct dsa_switch *ds = dp->ds; in dsa_port_hsr_join()
1923 if (!ds->ops->port_hsr_join) in dsa_port_hsr_join()
1924 return -EOPNOTSUPP; in dsa_port_hsr_join()
1926 dp->hsr_dev = hsr; in dsa_port_hsr_join()
1928 err = ds->ops->port_hsr_join(ds, dp->index, hsr, extack); in dsa_port_hsr_join()
1930 dp->hsr_dev = NULL; in dsa_port_hsr_join()
1935 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr) in dsa_port_hsr_leave() argument
1937 struct dsa_switch *ds = dp->ds; in dsa_port_hsr_leave()
1940 dp->hsr_dev = NULL; in dsa_port_hsr_leave()
1942 if (ds->ops->port_hsr_leave) { in dsa_port_hsr_leave()
1943 err = ds->ops->port_hsr_leave(ds, dp->index, hsr); in dsa_port_hsr_leave()
1945 dev_err(dp->ds->dev, in dsa_port_hsr_leave()
1947 dp->index, hsr->name, ERR_PTR(err)); in dsa_port_hsr_leave()
1951 int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast) in dsa_port_tag_8021q_vlan_add() argument
1954 .dp = dp, in dsa_port_tag_8021q_vlan_add()
1961 return dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_ADD, &info); in dsa_port_tag_8021q_vlan_add()
1964 void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast) in dsa_port_tag_8021q_vlan_del() argument
1967 .dp = dp, in dsa_port_tag_8021q_vlan_del()
1975 err = dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info); in dsa_port_tag_8021q_vlan_del()
1977 dev_err(dp->ds->dev, in dsa_port_tag_8021q_vlan_del()
1979 dp->index, vid, ERR_PTR(err)); in dsa_port_tag_8021q_vlan_del()