Lines Matching full:dp
19 * @dp: port on which change occurred
29 static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v) in dsa_port_notify() argument
31 return dsa_tree_notify(dp->ds->dst, e, v); in dsa_port_notify()
34 static void dsa_port_notify_bridge_fdb_flush(const struct dsa_port *dp, u16 vid) in dsa_port_notify_bridge_fdb_flush() argument
36 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_notify_bridge_fdb_flush()
51 static void dsa_port_fast_age(const struct dsa_port *dp) in dsa_port_fast_age() argument
53 struct dsa_switch *ds = dp->ds; in dsa_port_fast_age()
58 ds->ops->port_fast_age(ds, dp->index); in dsa_port_fast_age()
61 dsa_port_notify_bridge_fdb_flush(dp, 0); in dsa_port_fast_age()
64 static int dsa_port_vlan_fast_age(const struct dsa_port *dp, u16 vid) in dsa_port_vlan_fast_age() argument
66 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_fast_age()
72 err = ds->ops->port_vlan_fast_age(ds, dp->index, vid); in dsa_port_vlan_fast_age()
75 dsa_port_notify_bridge_fdb_flush(dp, vid); in dsa_port_vlan_fast_age()
80 static int dsa_port_msti_fast_age(const struct dsa_port *dp, u16 msti) in dsa_port_msti_fast_age() argument
85 err = br_mst_get_info(dsa_port_bridge_dev_get(dp), msti, vids); in dsa_port_msti_fast_age()
90 err = dsa_port_vlan_fast_age(dp, vid); in dsa_port_msti_fast_age()
98 static bool dsa_port_can_configure_learning(struct dsa_port *dp) in dsa_port_can_configure_learning() argument
103 struct dsa_switch *ds = dp->ds; in dsa_port_can_configure_learning()
109 err = ds->ops->port_pre_bridge_flags(ds, dp->index, flags, NULL); in dsa_port_can_configure_learning()
113 bool dsa_port_supports_hwtstamp(struct dsa_port *dp, struct ifreq *ifr) in dsa_port_supports_hwtstamp() argument
115 struct dsa_switch *ds = dp->ds; in dsa_port_supports_hwtstamp()
125 err = ds->ops->port_hwtstamp_get(ds, dp->index, ifr); in dsa_port_supports_hwtstamp()
129 int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) in dsa_port_set_state() argument
131 struct dsa_switch *ds = dp->ds; in dsa_port_set_state()
132 int port = dp->index; in dsa_port_set_state()
139 if (!dsa_port_can_configure_learning(dp) || in dsa_port_set_state()
140 (do_fast_age && dp->learning)) { in dsa_port_set_state()
149 if ((dp->stp_state == BR_STATE_LEARNING || in dsa_port_set_state()
150 dp->stp_state == BR_STATE_FORWARDING) && in dsa_port_set_state()
154 dsa_port_fast_age(dp); in dsa_port_set_state()
157 dp->stp_state = state; in dsa_port_set_state()
162 static void dsa_port_set_state_now(struct dsa_port *dp, u8 state, in dsa_port_set_state_now() argument
165 struct dsa_switch *ds = dp->ds; in dsa_port_set_state_now()
168 err = dsa_port_set_state(dp, state, do_fast_age); in dsa_port_set_state_now()
171 dp->index, state, ERR_PTR(err)); in dsa_port_set_state_now()
175 int dsa_port_set_mst_state(struct dsa_port *dp, in dsa_port_set_mst_state() argument
179 struct dsa_switch *ds = dp->ds; in dsa_port_set_mst_state()
186 err = br_mst_get_state(dsa_port_to_bridge_port(dp), state->msti, in dsa_port_set_mst_state()
191 err = ds->ops->port_mst_state_set(ds, dp->index, state); in dsa_port_set_mst_state()
195 if (!(dp->learning && in dsa_port_set_mst_state()
203 err = dsa_port_msti_fast_age(dp, state->msti); in dsa_port_set_mst_state()
211 int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy) in dsa_port_enable_rt() argument
213 struct dsa_switch *ds = dp->ds; in dsa_port_enable_rt()
214 int port = dp->index; in dsa_port_enable_rt()
223 if (!dp->bridge) in dsa_port_enable_rt()
224 dsa_port_set_state_now(dp, BR_STATE_FORWARDING, false); in dsa_port_enable_rt()
226 if (dp->pl) in dsa_port_enable_rt()
227 phylink_start(dp->pl); in dsa_port_enable_rt()
232 int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy) in dsa_port_enable() argument
237 err = dsa_port_enable_rt(dp, phy); in dsa_port_enable()
243 void dsa_port_disable_rt(struct dsa_port *dp) in dsa_port_disable_rt() argument
245 struct dsa_switch *ds = dp->ds; in dsa_port_disable_rt()
246 int port = dp->index; in dsa_port_disable_rt()
248 if (dp->pl) in dsa_port_disable_rt()
249 phylink_stop(dp->pl); in dsa_port_disable_rt()
251 if (!dp->bridge) in dsa_port_disable_rt()
252 dsa_port_set_state_now(dp, BR_STATE_DISABLED, false); in dsa_port_disable_rt()
258 void dsa_port_disable(struct dsa_port *dp) in dsa_port_disable() argument
261 dsa_port_disable_rt(dp); in dsa_port_disable()
265 static void dsa_port_reset_vlan_filtering(struct dsa_port *dp, in dsa_port_reset_vlan_filtering() argument
270 struct dsa_switch *ds = dp->ds; in dsa_port_reset_vlan_filtering()
307 err = dsa_port_vlan_filtering(dp, vlan_filtering, &extack); in dsa_port_reset_vlan_filtering()
309 dev_err(ds->dev, "port %d: %s\n", dp->index, in dsa_port_reset_vlan_filtering()
315 dp->index, vlan_filtering, ERR_PTR(err)); in dsa_port_reset_vlan_filtering()
319 static int dsa_port_inherit_brport_flags(struct dsa_port *dp, in dsa_port_inherit_brport_flags() argument
324 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_inherit_brport_flags()
335 err = dsa_port_bridge_flags(dp, flags, extack); in dsa_port_inherit_brport_flags()
343 static void dsa_port_clear_brport_flags(struct dsa_port *dp) in dsa_port_clear_brport_flags() argument
356 err = dsa_port_bridge_flags(dp, flags, NULL); in dsa_port_clear_brport_flags()
358 dev_err(dp->ds->dev, in dsa_port_clear_brport_flags()
364 static int dsa_port_switchdev_sync_attrs(struct dsa_port *dp, in dsa_port_switchdev_sync_attrs() argument
367 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_switchdev_sync_attrs()
368 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_switchdev_sync_attrs()
371 err = dsa_port_inherit_brport_flags(dp, extack); in dsa_port_switchdev_sync_attrs()
375 err = dsa_port_set_state(dp, br_port_get_stp_state(brport_dev), false); in dsa_port_switchdev_sync_attrs()
379 err = dsa_port_vlan_filtering(dp, br_vlan_enabled(br), extack); in dsa_port_switchdev_sync_attrs()
383 err = dsa_port_ageing_time(dp, br_get_ageing_time(br)); in dsa_port_switchdev_sync_attrs()
390 static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp, in dsa_port_switchdev_unsync_attrs() argument
404 dsa_port_clear_brport_flags(dp); in dsa_port_switchdev_unsync_attrs()
409 dsa_port_set_state_now(dp, BR_STATE_FORWARDING, true); in dsa_port_switchdev_unsync_attrs()
411 dsa_port_reset_vlan_filtering(dp, bridge); in dsa_port_switchdev_unsync_attrs()
418 static int dsa_port_bridge_create(struct dsa_port *dp, in dsa_port_bridge_create() argument
422 struct dsa_switch *ds = dp->ds; in dsa_port_bridge_create()
428 dp->bridge = bridge; in dsa_port_bridge_create()
448 dp->bridge = bridge; in dsa_port_bridge_create()
453 static void dsa_port_bridge_destroy(struct dsa_port *dp, in dsa_port_bridge_destroy() argument
456 struct dsa_bridge *bridge = dp->bridge; in dsa_port_bridge_destroy()
458 dp->bridge = NULL; in dsa_port_bridge_destroy()
469 static bool dsa_port_supports_mst(struct dsa_port *dp) in dsa_port_supports_mst() argument
471 struct dsa_switch *ds = dp->ds; in dsa_port_supports_mst()
476 dsa_port_can_configure_learning(dp); in dsa_port_supports_mst()
479 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, in dsa_port_bridge_join() argument
483 .dp = dp, in dsa_port_bridge_join()
486 struct net_device *dev = dp->slave; in dsa_port_bridge_join()
490 if (br_mst_enabled(br) && !dsa_port_supports_mst(dp)) in dsa_port_bridge_join()
496 err = dsa_port_bridge_create(dp, br, extack); in dsa_port_bridge_join()
500 brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_bridge_join()
502 info.bridge = *dp->bridge; in dsa_port_bridge_join()
508 dp->bridge->tx_fwd_offload = info.tx_fwd_offload; in dsa_port_bridge_join()
510 err = switchdev_bridge_port_offload(brport_dev, dev, dp, in dsa_port_bridge_join()
513 dp->bridge->tx_fwd_offload, extack); in dsa_port_bridge_join()
517 err = dsa_port_switchdev_sync_attrs(dp, extack); in dsa_port_bridge_join()
524 switchdev_bridge_port_unoffload(brport_dev, dp, in dsa_port_bridge_join()
531 dsa_port_bridge_destroy(dp, br); in dsa_port_bridge_join()
535 void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br) in dsa_port_pre_bridge_leave() argument
537 struct net_device *brport_dev = dsa_port_to_bridge_port(dp); in dsa_port_pre_bridge_leave()
543 switchdev_bridge_port_unoffload(brport_dev, dp, in dsa_port_pre_bridge_leave()
550 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) in dsa_port_bridge_leave() argument
553 .dp = dp, in dsa_port_bridge_leave()
560 if (!dp->bridge) in dsa_port_bridge_leave()
563 info.bridge = *dp->bridge; in dsa_port_bridge_leave()
568 dsa_port_bridge_destroy(dp, br); in dsa_port_bridge_leave()
572 dev_err(dp->ds->dev, in dsa_port_bridge_leave()
574 dp->index, ERR_PTR(err)); in dsa_port_bridge_leave()
576 dsa_port_switchdev_unsync_attrs(dp, info.bridge); in dsa_port_bridge_leave()
579 int dsa_port_lag_change(struct dsa_port *dp, in dsa_port_lag_change() argument
583 .dp = dp, in dsa_port_lag_change()
587 if (!dp->lag) in dsa_port_lag_change()
597 if (tx_enabled == dp->lag_tx_enabled) in dsa_port_lag_change()
600 dp->lag_tx_enabled = tx_enabled; in dsa_port_lag_change()
602 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info); in dsa_port_lag_change()
605 static int dsa_port_lag_create(struct dsa_port *dp, in dsa_port_lag_create() argument
608 struct dsa_switch *ds = dp->ds; in dsa_port_lag_create()
614 dp->lag = lag; in dsa_port_lag_create()
627 dp->lag = lag; in dsa_port_lag_create()
632 static void dsa_port_lag_destroy(struct dsa_port *dp) in dsa_port_lag_destroy() argument
634 struct dsa_lag *lag = dp->lag; in dsa_port_lag_destroy()
636 dp->lag = NULL; in dsa_port_lag_destroy()
637 dp->lag_tx_enabled = false; in dsa_port_lag_destroy()
643 dsa_lag_unmap(dp->ds->dst, lag); in dsa_port_lag_destroy()
647 int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag_dev, in dsa_port_lag_join() argument
652 .dp = dp, in dsa_port_lag_join()
659 err = dsa_port_lag_create(dp, lag_dev); in dsa_port_lag_join()
663 info.lag = *dp->lag; in dsa_port_lag_join()
664 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_JOIN, &info); in dsa_port_lag_join()
672 err = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_lag_join()
679 dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info); in dsa_port_lag_join()
681 dsa_port_lag_destroy(dp); in dsa_port_lag_join()
686 void dsa_port_pre_lag_leave(struct dsa_port *dp, struct net_device *lag_dev) in dsa_port_pre_lag_leave() argument
688 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_pre_lag_leave()
691 dsa_port_pre_bridge_leave(dp, br); in dsa_port_pre_lag_leave()
694 void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev) in dsa_port_lag_leave() argument
696 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_lag_leave()
698 .dp = dp, in dsa_port_lag_leave()
702 if (!dp->lag) in dsa_port_lag_leave()
709 dsa_port_bridge_leave(dp, br); in dsa_port_lag_leave()
711 info.lag = *dp->lag; in dsa_port_lag_leave()
713 dsa_port_lag_destroy(dp); in dsa_port_lag_leave()
715 err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info); in dsa_port_lag_leave()
717 dev_err(dp->ds->dev, in dsa_port_lag_leave()
719 dp->index, ERR_PTR(err)); in dsa_port_lag_leave()
723 static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp, in dsa_port_can_apply_vlan_filtering() argument
727 struct dsa_switch *ds = dp->ds; in dsa_port_can_apply_vlan_filtering()
736 if (vlan_filtering && dsa_port_is_user(dp)) { in dsa_port_can_apply_vlan_filtering()
737 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_can_apply_vlan_filtering()
738 struct net_device *upper_dev, *slave = dp->slave; in dsa_port_can_apply_vlan_filtering()
777 if (!other_br || other_br == dsa_port_bridge_dev_get(dp)) in dsa_port_can_apply_vlan_filtering()
789 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, in dsa_port_vlan_filtering() argument
792 bool old_vlan_filtering = dsa_port_is_vlan_filtering(dp); in dsa_port_vlan_filtering()
793 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_filtering()
805 apply = dsa_port_can_apply_vlan_filtering(dp, vlan_filtering, extack); in dsa_port_vlan_filtering()
810 if (dsa_port_is_vlan_filtering(dp) == vlan_filtering) in dsa_port_vlan_filtering()
813 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering, in dsa_port_vlan_filtering()
838 dp->vlan_filtering = vlan_filtering; in dsa_port_vlan_filtering()
840 err = dsa_slave_manage_vlan_filtering(dp->slave, in dsa_port_vlan_filtering()
849 ds->ops->port_vlan_filtering(ds, dp->index, old_vlan_filtering, NULL); in dsa_port_vlan_filtering()
854 dp->vlan_filtering = old_vlan_filtering; in dsa_port_vlan_filtering()
862 bool dsa_port_skip_vlan_configuration(struct dsa_port *dp) in dsa_port_skip_vlan_configuration() argument
864 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_port_skip_vlan_configuration()
865 struct dsa_switch *ds = dp->ds; in dsa_port_skip_vlan_configuration()
873 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock) in dsa_port_ageing_time() argument
882 err = dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info); in dsa_port_ageing_time()
886 dp->ageing_time = ageing_time; in dsa_port_ageing_time()
891 int dsa_port_mst_enable(struct dsa_port *dp, bool on, in dsa_port_mst_enable() argument
894 if (on && !dsa_port_supports_mst(dp)) { in dsa_port_mst_enable()
902 int dsa_port_pre_bridge_flags(const struct dsa_port *dp, in dsa_port_pre_bridge_flags() argument
906 struct dsa_switch *ds = dp->ds; in dsa_port_pre_bridge_flags()
911 return ds->ops->port_pre_bridge_flags(ds, dp->index, flags, extack); in dsa_port_pre_bridge_flags()
914 int dsa_port_bridge_flags(struct dsa_port *dp, in dsa_port_bridge_flags() argument
918 struct dsa_switch *ds = dp->ds; in dsa_port_bridge_flags()
924 err = ds->ops->port_bridge_flags(ds, dp->index, flags, extack); in dsa_port_bridge_flags()
931 if (learning == dp->learning) in dsa_port_bridge_flags()
934 if ((dp->learning && !learning) && in dsa_port_bridge_flags()
935 (dp->stp_state == BR_STATE_LEARNING || in dsa_port_bridge_flags()
936 dp->stp_state == BR_STATE_FORWARDING)) in dsa_port_bridge_flags()
937 dsa_port_fast_age(dp); in dsa_port_bridge_flags()
939 dp->learning = learning; in dsa_port_bridge_flags()
945 void dsa_port_set_host_flood(struct dsa_port *dp, bool uc, bool mc) in dsa_port_set_host_flood() argument
947 struct dsa_switch *ds = dp->ds; in dsa_port_set_host_flood()
950 ds->ops->port_set_host_flood(ds, dp->index, uc, mc); in dsa_port_set_host_flood()
953 int dsa_port_vlan_msti(struct dsa_port *dp, in dsa_port_vlan_msti() argument
956 struct dsa_switch *ds = dp->ds; in dsa_port_vlan_msti()
961 return ds->ops->vlan_msti_set(ds, *dp->bridge, msti); in dsa_port_vlan_msti()
964 int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu) in dsa_port_mtu_change() argument
967 .dp = dp, in dsa_port_mtu_change()
971 return dsa_port_notify(dp, DSA_NOTIFIER_MTU, &info); in dsa_port_mtu_change()
974 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, in dsa_port_fdb_add() argument
978 .dp = dp, in dsa_port_fdb_add()
983 .bridge = *dp->bridge, in dsa_port_fdb_add()
991 if (!dp->ds->fdb_isolation) in dsa_port_fdb_add()
994 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info); in dsa_port_fdb_add()
997 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, in dsa_port_fdb_del() argument
1001 .dp = dp, in dsa_port_fdb_del()
1006 .bridge = *dp->bridge, in dsa_port_fdb_del()
1010 if (!dp->ds->fdb_isolation) in dsa_port_fdb_del()
1013 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info); in dsa_port_fdb_del()
1016 static int dsa_port_host_fdb_add(struct dsa_port *dp, in dsa_port_host_fdb_add() argument
1021 .dp = dp, in dsa_port_host_fdb_add()
1027 if (!dp->ds->fdb_isolation) in dsa_port_host_fdb_add()
1030 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_ADD, &info); in dsa_port_host_fdb_add()
1033 int dsa_port_standalone_host_fdb_add(struct dsa_port *dp, in dsa_port_standalone_host_fdb_add() argument
1038 .dp = dp, in dsa_port_standalone_host_fdb_add()
1041 return dsa_port_host_fdb_add(dp, addr, vid, db); in dsa_port_standalone_host_fdb_add()
1044 int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, in dsa_port_bridge_host_fdb_add() argument
1047 struct net_device *master = dsa_port_to_master(dp); in dsa_port_bridge_host_fdb_add()
1050 .bridge = *dp->bridge, in dsa_port_bridge_host_fdb_add()
1064 return dsa_port_host_fdb_add(dp, addr, vid, db); in dsa_port_bridge_host_fdb_add()
1067 static int dsa_port_host_fdb_del(struct dsa_port *dp, in dsa_port_host_fdb_del() argument
1072 .dp = dp, in dsa_port_host_fdb_del()
1078 if (!dp->ds->fdb_isolation) in dsa_port_host_fdb_del()
1081 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info); in dsa_port_host_fdb_del()
1084 int dsa_port_standalone_host_fdb_del(struct dsa_port *dp, in dsa_port_standalone_host_fdb_del() argument
1089 .dp = dp, in dsa_port_standalone_host_fdb_del()
1092 return dsa_port_host_fdb_del(dp, addr, vid, db); in dsa_port_standalone_host_fdb_del()
1095 int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, in dsa_port_bridge_host_fdb_del() argument
1098 struct net_device *master = dsa_port_to_master(dp); in dsa_port_bridge_host_fdb_del()
1101 .bridge = *dp->bridge, in dsa_port_bridge_host_fdb_del()
1111 return dsa_port_host_fdb_del(dp, addr, vid, db); in dsa_port_bridge_host_fdb_del()
1114 int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, in dsa_port_lag_fdb_add() argument
1118 .lag = dp->lag, in dsa_port_lag_fdb_add()
1123 .bridge = *dp->bridge, in dsa_port_lag_fdb_add()
1127 if (!dp->ds->fdb_isolation) in dsa_port_lag_fdb_add()
1130 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_ADD, &info); in dsa_port_lag_fdb_add()
1133 int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr, in dsa_port_lag_fdb_del() argument
1137 .lag = dp->lag, in dsa_port_lag_fdb_del()
1142 .bridge = *dp->bridge, in dsa_port_lag_fdb_del()
1146 if (!dp->ds->fdb_isolation) in dsa_port_lag_fdb_del()
1149 return dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_DEL, &info); in dsa_port_lag_fdb_del()
1152 int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data) in dsa_port_fdb_dump() argument
1154 struct dsa_switch *ds = dp->ds; in dsa_port_fdb_dump()
1155 int port = dp->index; in dsa_port_fdb_dump()
1163 int dsa_port_mdb_add(const struct dsa_port *dp, in dsa_port_mdb_add() argument
1167 .dp = dp, in dsa_port_mdb_add()
1171 .bridge = *dp->bridge, in dsa_port_mdb_add()
1175 if (!dp->ds->fdb_isolation) in dsa_port_mdb_add()
1178 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_ADD, &info); in dsa_port_mdb_add()
1181 int dsa_port_mdb_del(const struct dsa_port *dp, in dsa_port_mdb_del() argument
1185 .dp = dp, in dsa_port_mdb_del()
1189 .bridge = *dp->bridge, in dsa_port_mdb_del()
1193 if (!dp->ds->fdb_isolation) in dsa_port_mdb_del()
1196 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info); in dsa_port_mdb_del()
1199 static int dsa_port_host_mdb_add(const struct dsa_port *dp, in dsa_port_host_mdb_add() argument
1204 .dp = dp, in dsa_port_host_mdb_add()
1209 if (!dp->ds->fdb_isolation) in dsa_port_host_mdb_add()
1212 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_ADD, &info); in dsa_port_host_mdb_add()
1215 int dsa_port_standalone_host_mdb_add(const struct dsa_port *dp, in dsa_port_standalone_host_mdb_add() argument
1220 .dp = dp, in dsa_port_standalone_host_mdb_add()
1223 return dsa_port_host_mdb_add(dp, mdb, db); in dsa_port_standalone_host_mdb_add()
1226 int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp, in dsa_port_bridge_host_mdb_add() argument
1229 struct net_device *master = dsa_port_to_master(dp); in dsa_port_bridge_host_mdb_add()
1232 .bridge = *dp->bridge, in dsa_port_bridge_host_mdb_add()
1240 return dsa_port_host_mdb_add(dp, mdb, db); in dsa_port_bridge_host_mdb_add()
1243 static int dsa_port_host_mdb_del(const struct dsa_port *dp, in dsa_port_host_mdb_del() argument
1248 .dp = dp, in dsa_port_host_mdb_del()
1253 if (!dp->ds->fdb_isolation) in dsa_port_host_mdb_del()
1256 return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info); in dsa_port_host_mdb_del()
1259 int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp, in dsa_port_standalone_host_mdb_del() argument
1264 .dp = dp, in dsa_port_standalone_host_mdb_del()
1267 return dsa_port_host_mdb_del(dp, mdb, db); in dsa_port_standalone_host_mdb_del()
1270 int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp, in dsa_port_bridge_host_mdb_del() argument
1273 struct net_device *master = dsa_port_to_master(dp); in dsa_port_bridge_host_mdb_del()
1276 .bridge = *dp->bridge, in dsa_port_bridge_host_mdb_del()
1284 return dsa_port_host_mdb_del(dp, mdb, db); in dsa_port_bridge_host_mdb_del()
1287 int dsa_port_vlan_add(struct dsa_port *dp, in dsa_port_vlan_add() argument
1292 .dp = dp, in dsa_port_vlan_add()
1297 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info); in dsa_port_vlan_add()
1300 int dsa_port_vlan_del(struct dsa_port *dp, in dsa_port_vlan_del() argument
1304 .dp = dp, in dsa_port_vlan_del()
1308 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info); in dsa_port_vlan_del()
1311 int dsa_port_host_vlan_add(struct dsa_port *dp, in dsa_port_host_vlan_add() argument
1315 struct net_device *master = dsa_port_to_master(dp); in dsa_port_host_vlan_add()
1317 .dp = dp, in dsa_port_host_vlan_add()
1323 err = dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_ADD, &info); in dsa_port_host_vlan_add()
1332 int dsa_port_host_vlan_del(struct dsa_port *dp, in dsa_port_host_vlan_del() argument
1335 struct net_device *master = dsa_port_to_master(dp); in dsa_port_host_vlan_del()
1337 .dp = dp, in dsa_port_host_vlan_del()
1342 err = dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_DEL, &info); in dsa_port_host_vlan_del()
1351 int dsa_port_mrp_add(const struct dsa_port *dp, in dsa_port_mrp_add() argument
1354 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_add()
1359 return ds->ops->port_mrp_add(ds, dp->index, mrp); in dsa_port_mrp_add()
1362 int dsa_port_mrp_del(const struct dsa_port *dp, in dsa_port_mrp_del() argument
1365 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_del()
1370 return ds->ops->port_mrp_del(ds, dp->index, mrp); in dsa_port_mrp_del()
1373 int dsa_port_mrp_add_ring_role(const struct dsa_port *dp, in dsa_port_mrp_add_ring_role() argument
1376 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_add_ring_role()
1381 return ds->ops->port_mrp_add_ring_role(ds, dp->index, mrp); in dsa_port_mrp_add_ring_role()
1384 int dsa_port_mrp_del_ring_role(const struct dsa_port *dp, in dsa_port_mrp_del_ring_role() argument
1387 struct dsa_switch *ds = dp->ds; in dsa_port_mrp_del_ring_role()
1392 return ds->ops->port_mrp_del_ring_role(ds, dp->index, mrp); in dsa_port_mrp_del_ring_role()
1395 static int dsa_port_assign_master(struct dsa_port *dp, in dsa_port_assign_master() argument
1400 struct dsa_switch *ds = dp->ds; in dsa_port_assign_master()
1401 int port = dp->index, err; in dsa_port_assign_master()
1411 dp->cpu_dp = master->dsa_ptr; in dsa_port_assign_master()
1412 dp->cpu_port_in_lag = netif_is_lag_master(master); in dsa_port_assign_master()
1417 /* Change the dp->cpu_dp affinity for a user port. Note that both cross-chip
1425 int dsa_port_change_master(struct dsa_port *dp, struct net_device *master, in dsa_port_change_master() argument
1428 struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp); in dsa_port_change_master()
1429 struct net_device *old_master = dsa_port_to_master(dp); in dsa_port_change_master()
1430 struct net_device *dev = dp->slave; in dsa_port_change_master()
1431 struct dsa_switch *ds = dp->ds; in dsa_port_change_master()
1440 dsa_port_pre_bridge_leave(dp, bridge_dev); in dsa_port_change_master()
1441 dsa_port_bridge_leave(dp, bridge_dev); in dsa_port_change_master()
1449 vlan_filtering = dsa_port_is_vlan_filtering(dp); in dsa_port_change_master()
1464 err = dsa_port_assign_master(dp, master, extack, true); in dsa_port_change_master()
1480 err = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_change_master()
1497 dsa_port_assign_master(dp, old_master, NULL, false); in dsa_port_change_master()
1508 dp->index, ERR_PTR(tmp)); in dsa_port_change_master()
1514 tmp = dsa_port_bridge_join(dp, bridge_dev, extack); in dsa_port_change_master()
1518 dp->index, bridge_dev->name, ERR_PTR(tmp)); in dsa_port_change_master()
1532 static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp) in dsa_port_get_phy_device() argument
1537 phy_dn = of_parse_phandle(dp->dn, "phy-handle", 0); in dsa_port_get_phy_device()
1555 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_validate() local
1556 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_validate()
1564 ds->ops->phylink_validate(ds, dp->index, supported, state); in dsa_port_phylink_validate()
1570 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_pcs_get_state() local
1571 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_pcs_get_state()
1580 err = ds->ops->phylink_mac_link_state(ds, dp->index, state); in dsa_port_phylink_mac_pcs_get_state()
1583 dp->index, err); in dsa_port_phylink_mac_pcs_get_state()
1592 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_select_pcs() local
1594 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_select_pcs()
1597 pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface); in dsa_port_phylink_mac_select_pcs()
1606 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_config() local
1607 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_config()
1612 ds->ops->phylink_mac_config(ds, dp->index, mode, state); in dsa_port_phylink_mac_config()
1617 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_an_restart() local
1618 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_an_restart()
1623 ds->ops->phylink_mac_an_restart(ds, dp->index); in dsa_port_phylink_mac_an_restart()
1630 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_link_down() local
1632 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_link_down()
1634 if (dsa_port_is_user(dp)) in dsa_port_phylink_mac_link_down()
1635 phydev = dp->slave->phydev; in dsa_port_phylink_mac_link_down()
1639 ds->ops->adjust_link(ds, dp->index, phydev); in dsa_port_phylink_mac_link_down()
1643 ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface); in dsa_port_phylink_mac_link_down()
1653 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); in dsa_port_phylink_mac_link_up() local
1654 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_mac_link_up()
1658 ds->ops->adjust_link(ds, dp->index, phydev); in dsa_port_phylink_mac_link_up()
1662 ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev, in dsa_port_phylink_mac_link_up()
1676 int dsa_port_phylink_create(struct dsa_port *dp) in dsa_port_phylink_create() argument
1678 struct dsa_switch *ds = dp->ds; in dsa_port_phylink_create()
1683 err = of_get_phy_mode(dp->dn, &mode); in dsa_port_phylink_create()
1692 dp->pl_config.legacy_pre_march2020 = true; in dsa_port_phylink_create()
1695 ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); in dsa_port_phylink_create()
1697 pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), in dsa_port_phylink_create()
1704 dp->pl = pl; in dsa_port_phylink_create()
1709 void dsa_port_phylink_destroy(struct dsa_port *dp) in dsa_port_phylink_destroy() argument
1711 phylink_destroy(dp->pl); in dsa_port_phylink_destroy()
1712 dp->pl = NULL; in dsa_port_phylink_destroy()
1715 static int dsa_shared_port_setup_phy_of(struct dsa_port *dp, bool enable) in dsa_shared_port_setup_phy_of() argument
1717 struct dsa_switch *ds = dp->ds; in dsa_shared_port_setup_phy_of()
1719 int port = dp->index; in dsa_shared_port_setup_phy_of()
1722 phydev = dsa_port_get_phy_device(dp); in dsa_shared_port_setup_phy_of()
1753 static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp) in dsa_shared_port_fixed_link_register_of() argument
1755 struct device_node *dn = dp->dn; in dsa_shared_port_fixed_link_register_of()
1756 struct dsa_switch *ds = dp->ds; in dsa_shared_port_fixed_link_register_of()
1758 int port = dp->index; in dsa_shared_port_fixed_link_register_of()
1787 static int dsa_shared_port_phylink_register(struct dsa_port *dp) in dsa_shared_port_phylink_register() argument
1789 struct dsa_switch *ds = dp->ds; in dsa_shared_port_phylink_register()
1790 struct device_node *port_dn = dp->dn; in dsa_shared_port_phylink_register()
1793 dp->pl_config.dev = ds->dev; in dsa_shared_port_phylink_register()
1794 dp->pl_config.type = PHYLINK_DEV; in dsa_shared_port_phylink_register()
1796 err = dsa_port_phylink_create(dp); in dsa_shared_port_phylink_register()
1800 err = phylink_of_phy_connect(dp->pl, port_dn, 0); in dsa_shared_port_phylink_register()
1809 dsa_port_phylink_destroy(dp); in dsa_shared_port_phylink_register()
1927 static void dsa_shared_port_validate_of(struct dsa_port *dp, in dsa_shared_port_validate_of() argument
1931 struct device_node *dn = dp->dn, *phy_np; in dsa_shared_port_validate_of()
1932 struct dsa_switch *ds = dp->ds; in dsa_shared_port_validate_of()
1942 dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_validate_of()
1961 dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_validate_of()
1964 int dsa_shared_port_link_register_of(struct dsa_port *dp) in dsa_shared_port_link_register_of() argument
1966 struct dsa_switch *ds = dp->ds; in dsa_shared_port_link_register_of()
1969 int port = dp->index; in dsa_shared_port_link_register_of()
1971 dsa_shared_port_validate_of(dp, &missing_phy_mode, in dsa_shared_port_link_register_of()
1983 dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); in dsa_shared_port_link_register_of()
1989 return dsa_shared_port_phylink_register(dp); in dsa_shared_port_link_register_of()
1997 if (of_phy_is_fixed_link(dp->dn)) in dsa_shared_port_link_register_of()
1998 return dsa_shared_port_fixed_link_register_of(dp); in dsa_shared_port_link_register_of()
2000 return dsa_shared_port_setup_phy_of(dp, true); in dsa_shared_port_link_register_of()
2003 void dsa_shared_port_link_unregister_of(struct dsa_port *dp) in dsa_shared_port_link_unregister_of() argument
2005 struct dsa_switch *ds = dp->ds; in dsa_shared_port_link_unregister_of()
2007 if (!ds->ops->adjust_link && dp->pl) { in dsa_shared_port_link_unregister_of()
2009 phylink_disconnect_phy(dp->pl); in dsa_shared_port_link_unregister_of()
2011 dsa_port_phylink_destroy(dp); in dsa_shared_port_link_unregister_of()
2015 if (of_phy_is_fixed_link(dp->dn)) in dsa_shared_port_link_unregister_of()
2016 of_phy_deregister_fixed_link(dp->dn); in dsa_shared_port_link_unregister_of()
2018 dsa_shared_port_setup_phy_of(dp, false); in dsa_shared_port_link_unregister_of()
2021 int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr) in dsa_port_hsr_join() argument
2023 struct dsa_switch *ds = dp->ds; in dsa_port_hsr_join()
2029 dp->hsr_dev = hsr; in dsa_port_hsr_join()
2031 err = ds->ops->port_hsr_join(ds, dp->index, hsr); in dsa_port_hsr_join()
2033 dp->hsr_dev = NULL; in dsa_port_hsr_join()
2038 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr) in dsa_port_hsr_leave() argument
2040 struct dsa_switch *ds = dp->ds; in dsa_port_hsr_leave()
2043 dp->hsr_dev = NULL; in dsa_port_hsr_leave()
2046 err = ds->ops->port_hsr_leave(ds, dp->index, hsr); in dsa_port_hsr_leave()
2048 dev_err(dp->ds->dev, in dsa_port_hsr_leave()
2050 dp->index, hsr->name, ERR_PTR(err)); in dsa_port_hsr_leave()
2054 int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast) in dsa_port_tag_8021q_vlan_add() argument
2057 .dp = dp, in dsa_port_tag_8021q_vlan_add()
2064 return dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_ADD, &info); in dsa_port_tag_8021q_vlan_add()
2067 void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast) in dsa_port_tag_8021q_vlan_del() argument
2070 .dp = dp, in dsa_port_tag_8021q_vlan_del()
2078 err = dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info); in dsa_port_tag_8021q_vlan_del()
2080 dev_err(dp->ds->dev, in dsa_port_tag_8021q_vlan_del()
2082 dp->index, vid, ERR_PTR(err)); in dsa_port_tag_8021q_vlan_del()