Lines Matching full:dp

23  * @dp: port on which change occurred
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()
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()
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()
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()
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()
131 err = ds->ops->port_hwtstamp_get(ds, dp->index, &ifr); 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()
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()
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()
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()
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()
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()
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
276 struct dsa_switch *ds = dp->ds; 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()
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()
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()
364 dev_err(dp->ds->dev, 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()
385 err = dsa_port_vlan_filtering(dp, br_vlan_enabled(br), extack); in dsa_port_switchdev_sync_attrs()
389 err = dsa_port_ageing_time(dp, br_get_ageing_time(br)); 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
410 dsa_port_clear_brport_flags(dp); 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()
434 dp->bridge = bridge; 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()
464 dp->bridge = NULL; 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()
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()
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()
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()
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()
620 dp->lag = 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()
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()
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()
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()
811 apply = dsa_port_can_apply_vlan_filtering(dp, vlan_filtering, extack); 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()
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()
860 dp->vlan_filtering = old_vlan_filtering; in dsa_port_vlan_filtering()
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()
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()
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()
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()
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()
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()
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()
997 if (!dp->ds->fdb_isolation) 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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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
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()
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()
1455 vlan_filtering = dsa_port_is_vlan_filtering(dp); 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()
1510 err = dsa_port_bridge_join(dp, bridge_dev, extack); 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()
1543 dp->index, ERR_PTR(tmp)); 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()
1564 dp->index, bridge_dev->name, ERR_PTR(tmp)); in dsa_port_change_conduit()
1582 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_port_phylink_mac_select_pcs() local
1584 struct dsa_switch *ds = dp->ds; 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()
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()
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()
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()
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()
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()
1712 dsa_port_phylink_destroy(dp); in dsa_shared_port_phylink_register()
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()
1845 dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); 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()
1872 ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED, 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()
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()
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()
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()