Lines Matching full:ds
17 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, in dsa_switch_fastest_ageing_time() argument
22 for (i = 0; i < ds->num_ports; ++i) { in dsa_switch_fastest_ageing_time()
23 struct dsa_port *dp = dsa_to_port(ds, i); in dsa_switch_fastest_ageing_time()
32 static int dsa_switch_ageing_time(struct dsa_switch *ds, in dsa_switch_ageing_time() argument
39 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) in dsa_switch_ageing_time()
41 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) in dsa_switch_ageing_time()
47 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
49 if (ds->ops->set_ageing_time) in dsa_switch_ageing_time()
50 return ds->ops->set_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
55 static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port, in dsa_switch_mtu_match() argument
58 if (ds->index == info->sw_index) in dsa_switch_mtu_match()
59 return (port == info->port) || dsa_is_dsa_port(ds, port); in dsa_switch_mtu_match()
64 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) in dsa_switch_mtu_match()
70 static int dsa_switch_mtu(struct dsa_switch *ds, in dsa_switch_mtu() argument
75 if (!ds->ops->port_change_mtu) in dsa_switch_mtu()
78 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_mtu()
79 if (dsa_switch_mtu_match(ds, port, info)) { in dsa_switch_mtu()
80 ret = ds->ops->port_change_mtu(ds, port, info->mtu); in dsa_switch_mtu()
89 static int dsa_switch_bridge_join(struct dsa_switch *ds, in dsa_switch_bridge_join() argument
92 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_bridge_join()
94 if (dst->index == info->tree_index && ds->index == info->sw_index && in dsa_switch_bridge_join()
95 ds->ops->port_bridge_join) in dsa_switch_bridge_join()
96 return ds->ops->port_bridge_join(ds, info->port, info->br); in dsa_switch_bridge_join()
98 if ((dst->index != info->tree_index || ds->index != info->sw_index) && in dsa_switch_bridge_join()
99 ds->ops->crosschip_bridge_join) in dsa_switch_bridge_join()
100 return ds->ops->crosschip_bridge_join(ds, info->tree_index, in dsa_switch_bridge_join()
107 static int dsa_switch_bridge_leave(struct dsa_switch *ds, in dsa_switch_bridge_leave() argument
111 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_bridge_leave()
114 if (dst->index == info->tree_index && ds->index == info->sw_index && in dsa_switch_bridge_leave()
115 ds->ops->port_bridge_leave) in dsa_switch_bridge_leave()
116 ds->ops->port_bridge_leave(ds, info->port, info->br); in dsa_switch_bridge_leave()
118 if ((dst->index != info->tree_index || ds->index != info->sw_index) && in dsa_switch_bridge_leave()
119 ds->ops->crosschip_bridge_leave) in dsa_switch_bridge_leave()
120 ds->ops->crosschip_bridge_leave(ds, info->tree_index, in dsa_switch_bridge_leave()
131 if (unset_vlan_filtering && ds->vlan_filtering_is_global) { in dsa_switch_bridge_leave()
132 for (i = 0; i < ds->num_ports; i++) { in dsa_switch_bridge_leave()
135 if (dsa_to_port(ds, i)->bridge_dev == info->br) { in dsa_switch_bridge_leave()
145 err = dsa_port_vlan_filtering(dsa_to_port(ds, info->port), in dsa_switch_bridge_leave()
151 err = dsa_port_vlan_filtering(dsa_to_port(ds, info->port), in dsa_switch_bridge_leave()
159 static int dsa_switch_fdb_add(struct dsa_switch *ds, in dsa_switch_fdb_add() argument
162 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_fdb_add()
164 if (!ds->ops->port_fdb_add) in dsa_switch_fdb_add()
167 return ds->ops->port_fdb_add(ds, port, info->addr, info->vid); in dsa_switch_fdb_add()
170 static int dsa_switch_fdb_del(struct dsa_switch *ds, in dsa_switch_fdb_del() argument
173 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_fdb_del()
175 if (!ds->ops->port_fdb_del) in dsa_switch_fdb_del()
178 return ds->ops->port_fdb_del(ds, port, info->addr, info->vid); in dsa_switch_fdb_del()
181 static bool dsa_switch_mdb_match(struct dsa_switch *ds, int port, in dsa_switch_mdb_match() argument
184 if (ds->index == info->sw_index && port == info->port) in dsa_switch_mdb_match()
187 if (dsa_is_dsa_port(ds, port)) in dsa_switch_mdb_match()
193 static int dsa_switch_mdb_prepare(struct dsa_switch *ds, in dsa_switch_mdb_prepare() argument
198 if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) in dsa_switch_mdb_prepare()
201 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_mdb_prepare()
202 if (dsa_switch_mdb_match(ds, port, info)) { in dsa_switch_mdb_prepare()
203 err = ds->ops->port_mdb_prepare(ds, port, info->mdb); in dsa_switch_mdb_prepare()
212 static int dsa_switch_mdb_add(struct dsa_switch *ds, in dsa_switch_mdb_add() argument
218 return dsa_switch_mdb_prepare(ds, info); in dsa_switch_mdb_add()
220 if (!ds->ops->port_mdb_add) in dsa_switch_mdb_add()
223 for (port = 0; port < ds->num_ports; port++) in dsa_switch_mdb_add()
224 if (dsa_switch_mdb_match(ds, port, info)) in dsa_switch_mdb_add()
225 ds->ops->port_mdb_add(ds, port, info->mdb); in dsa_switch_mdb_add()
230 static int dsa_switch_mdb_del(struct dsa_switch *ds, in dsa_switch_mdb_del() argument
233 if (!ds->ops->port_mdb_del) in dsa_switch_mdb_del()
236 if (ds->index == info->sw_index) in dsa_switch_mdb_del()
237 return ds->ops->port_mdb_del(ds, info->port, info->mdb); in dsa_switch_mdb_del()
242 static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port, in dsa_switch_vlan_match() argument
245 if (ds->index == info->sw_index && port == info->port) in dsa_switch_vlan_match()
248 if (dsa_is_dsa_port(ds, port)) in dsa_switch_vlan_match()
254 static int dsa_switch_vlan_prepare(struct dsa_switch *ds, in dsa_switch_vlan_prepare() argument
259 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add) in dsa_switch_vlan_prepare()
262 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_vlan_prepare()
263 if (dsa_switch_vlan_match(ds, port, info)) { in dsa_switch_vlan_prepare()
264 err = ds->ops->port_vlan_prepare(ds, port, info->vlan); in dsa_switch_vlan_prepare()
273 static int dsa_switch_vlan_add(struct dsa_switch *ds, in dsa_switch_vlan_add() argument
279 return dsa_switch_vlan_prepare(ds, info); in dsa_switch_vlan_add()
281 if (!ds->ops->port_vlan_add) in dsa_switch_vlan_add()
284 for (port = 0; port < ds->num_ports; port++) in dsa_switch_vlan_add()
285 if (dsa_switch_vlan_match(ds, port, info)) in dsa_switch_vlan_add()
286 ds->ops->port_vlan_add(ds, port, info->vlan); in dsa_switch_vlan_add()
291 static int dsa_switch_vlan_del(struct dsa_switch *ds, in dsa_switch_vlan_del() argument
294 if (!ds->ops->port_vlan_del) in dsa_switch_vlan_del()
297 if (ds->index == info->sw_index) in dsa_switch_vlan_del()
298 return ds->ops->port_vlan_del(ds, info->port, info->vlan); in dsa_switch_vlan_del()
309 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb); in dsa_switch_event() local
314 err = dsa_switch_ageing_time(ds, info); in dsa_switch_event()
317 err = dsa_switch_bridge_join(ds, info); in dsa_switch_event()
320 err = dsa_switch_bridge_leave(ds, info); in dsa_switch_event()
323 err = dsa_switch_fdb_add(ds, info); in dsa_switch_event()
326 err = dsa_switch_fdb_del(ds, info); in dsa_switch_event()
329 err = dsa_switch_mdb_add(ds, info); in dsa_switch_event()
332 err = dsa_switch_mdb_del(ds, info); in dsa_switch_event()
335 err = dsa_switch_vlan_add(ds, info); in dsa_switch_event()
338 err = dsa_switch_vlan_del(ds, info); in dsa_switch_event()
341 err = dsa_switch_mtu(ds, info); in dsa_switch_event()
353 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n", in dsa_switch_event()
359 int dsa_switch_register_notifier(struct dsa_switch *ds) in dsa_switch_register_notifier() argument
361 ds->nb.notifier_call = dsa_switch_event; in dsa_switch_register_notifier()
363 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb); in dsa_switch_register_notifier()
366 void dsa_switch_unregister_notifier(struct dsa_switch *ds) in dsa_switch_unregister_notifier() argument
370 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb); in dsa_switch_unregister_notifier()
372 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err); in dsa_switch_unregister_notifier()