Lines Matching +full:cpsw +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0
15 #include "cpsw.h"
29 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_stp_state_set() local
33 switch (state) { in cpsw_port_stp_state_set()
48 return -EOPNOTSUPP; in cpsw_port_stp_state_set()
51 ret = cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_stp_state_set()
53 dev_dbg(priv->dev, "ale state: %u\n", cpsw_state); in cpsw_port_stp_state_set()
62 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_attr_br_flags_set() local
70 dev_dbg(priv->dev, "BR_MCAST_FLOOD: %d port %u\n", in cpsw_port_attr_br_flags_set()
71 unreg_mcast_add, priv->emac_port); in cpsw_port_attr_br_flags_set()
73 cpsw_ale_set_unreg_mcast(cpsw->ale, BIT(priv->emac_port), in cpsw_port_attr_br_flags_set()
84 return -EINVAL; in cpsw_port_attr_br_flags_pre_set()
96 dev_dbg(priv->dev, "attr: id %u port: %u\n", attr->id, priv->emac_port); in cpsw_port_attr_set()
98 switch (attr->id) { in cpsw_port_attr_set()
101 attr->u.brport_flags); in cpsw_port_attr_set()
104 ret = cpsw_port_stp_state_set(priv, attr->u.stp_state); in cpsw_port_attr_set()
105 dev_dbg(priv->dev, "stp state: %u\n", attr->u.stp_state); in cpsw_port_attr_set()
108 ret = cpsw_port_attr_br_flags_set(priv, attr->orig_dev, in cpsw_port_attr_set()
109 attr->u.brport_flags); in cpsw_port_attr_set()
112 ret = -EOPNOTSUPP; in cpsw_port_attr_set()
121 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_pvid() local
125 if (priv->emac_port) { in cpsw_get_pvid()
128 if (cpsw->version == CPSW_VERSION_1) in cpsw_get_pvid()
130 pvid = slave_read(cpsw->slaves + (priv->emac_port - 1), reg); in cpsw_get_pvid()
132 port_vlan_reg = &cpsw->host_port_regs->port_vlan; in cpsw_get_pvid()
143 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_pvid() local
151 if (priv->emac_port) { in cpsw_set_pvid()
154 if (cpsw->version == CPSW_VERSION_1) in cpsw_set_pvid()
157 slave_write(cpsw->slaves + (priv->emac_port - 1), pvid, reg); in cpsw_set_pvid()
160 port_vlan_reg = &cpsw->host_port_regs->port_vlan; in cpsw_set_pvid()
169 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_vlan_add() local
179 flags = orig_dev->flags; in cpsw_port_vlan_add()
182 port_mask = BIT(priv->emac_port); in cpsw_port_vlan_add()
183 flags = priv->ndev->flags; in cpsw_port_vlan_add()
192 ret = cpsw_ale_vlan_add_modify(cpsw->ale, vid, port_mask, untag_mask, in cpsw_port_vlan_add()
195 dev_err(priv->dev, "Unable to add vlan\n"); in cpsw_port_vlan_add()
200 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_vlan_add()
207 dev_dbg(priv->dev, "VID add: %s: vid:%u ports:%X\n", in cpsw_port_vlan_add()
208 priv->ndev->name, vid, port_mask); in cpsw_port_vlan_add()
216 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_vlan_del() local
223 port_mask = BIT(priv->emac_port); in cpsw_port_vlan_del()
225 ret = cpsw_ale_vlan_del_modify(cpsw->ale, vid, port_mask); in cpsw_port_vlan_del()
233 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_vlan_del()
242 cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_vlan_del()
244 dev_dbg(priv->dev, "VID del: %s: vid:%u ports:%X\n", in cpsw_port_vlan_del()
245 priv->ndev->name, vid, port_mask); in cpsw_port_vlan_del()
253 bool untag = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in cpsw_port_vlans_add()
254 struct net_device *orig_dev = vlan->obj.orig_dev; in cpsw_port_vlans_add()
255 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in cpsw_port_vlans_add()
257 dev_dbg(priv->dev, "VID add: %s: vid:%u flags:%X\n", in cpsw_port_vlans_add()
258 priv->ndev->name, vlan->vid, vlan->flags); in cpsw_port_vlans_add()
260 return cpsw_port_vlan_add(priv, untag, pvid, vlan->vid, orig_dev); in cpsw_port_vlans_add()
267 struct net_device *orig_dev = mdb->obj.orig_dev; in cpsw_port_mdb_add()
269 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_mdb_add() local
276 port_mask = BIT(priv->emac_port); in cpsw_port_mdb_add()
278 err = cpsw_ale_add_mcast(cpsw->ale, mdb->addr, port_mask, in cpsw_port_mdb_add()
279 ALE_VLAN, mdb->vid, 0); in cpsw_port_mdb_add()
280 dev_dbg(priv->dev, "MDB add: %s: vid %u:%pM ports: %X\n", in cpsw_port_mdb_add()
281 priv->ndev->name, mdb->vid, mdb->addr, port_mask); in cpsw_port_mdb_add()
290 struct net_device *orig_dev = mdb->obj.orig_dev; in cpsw_port_mdb_del()
292 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_mdb_del() local
299 del_mask = BIT(priv->emac_port); in cpsw_port_mdb_del()
301 err = cpsw_ale_del_mcast(cpsw->ale, mdb->addr, del_mask, in cpsw_port_mdb_del()
302 ALE_VLAN, mdb->vid); in cpsw_port_mdb_del()
303 dev_dbg(priv->dev, "MDB del: %s: vid %u:%pM ports: %X\n", in cpsw_port_mdb_del()
304 priv->ndev->name, mdb->vid, mdb->addr, del_mask); in cpsw_port_mdb_del()
318 dev_dbg(priv->dev, "obj_add: id %u port: %u\n", in cpsw_port_obj_add()
319 obj->id, priv->emac_port); in cpsw_port_obj_add()
321 switch (obj->id) { in cpsw_port_obj_add()
330 err = -EOPNOTSUPP; in cpsw_port_obj_add()
345 dev_dbg(priv->dev, "obj_del: id %u port: %u\n", in cpsw_port_obj_del()
346 obj->id, priv->emac_port); in cpsw_port_obj_del()
348 switch (obj->id) { in cpsw_port_obj_del()
350 err = cpsw_port_vlan_del(priv, vlan->vid, vlan->obj.orig_dev); in cpsw_port_obj_del()
357 err = -EOPNOTSUPP; in cpsw_port_obj_del()
369 info.addr = rcv->addr; in cpsw_fdb_offload_notify()
370 info.vid = rcv->vid; in cpsw_fdb_offload_notify()
380 struct cpsw_priv *priv = switchdev_work->priv; in cpsw_switchdev_event_work()
382 struct cpsw_common *cpsw = priv->cpsw; in cpsw_switchdev_event_work() local
383 int port = priv->emac_port; in cpsw_switchdev_event_work()
386 switch (switchdev_work->event) { in cpsw_switchdev_event_work()
388 fdb = &switchdev_work->fdb_info; in cpsw_switchdev_event_work()
390 dev_dbg(cpsw->dev, "cpsw_fdb_add: MACID = %pM vid = %u flags = %u %u -- port %d\n", in cpsw_switchdev_event_work()
391 fdb->addr, fdb->vid, fdb->added_by_user, in cpsw_switchdev_event_work()
392 fdb->offloaded, port); in cpsw_switchdev_event_work()
394 if (!fdb->added_by_user || fdb->is_local) in cpsw_switchdev_event_work()
396 if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in cpsw_switchdev_event_work()
399 cpsw_ale_add_ucast(cpsw->ale, (u8 *)fdb->addr, port, in cpsw_switchdev_event_work()
400 fdb->vid ? ALE_VLAN : 0, fdb->vid); in cpsw_switchdev_event_work()
401 cpsw_fdb_offload_notify(priv->ndev, fdb); in cpsw_switchdev_event_work()
404 fdb = &switchdev_work->fdb_info; in cpsw_switchdev_event_work()
406 dev_dbg(cpsw->dev, "cpsw_fdb_del: MACID = %pM vid = %u flags = %u %u -- port %d\n", in cpsw_switchdev_event_work()
407 fdb->addr, fdb->vid, fdb->added_by_user, in cpsw_switchdev_event_work()
408 fdb->offloaded, port); in cpsw_switchdev_event_work()
410 if (!fdb->added_by_user || fdb->is_local) in cpsw_switchdev_event_work()
412 if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in cpsw_switchdev_event_work()
415 cpsw_ale_del_ucast(cpsw->ale, (u8 *)fdb->addr, port, in cpsw_switchdev_event_work()
416 fdb->vid ? ALE_VLAN : 0, fdb->vid); in cpsw_switchdev_event_work()
423 kfree(switchdev_work->fdb_info.addr); in cpsw_switchdev_event_work()
425 dev_put(priv->ndev); in cpsw_switchdev_event_work()
452 INIT_WORK(&switchdev_work->work, cpsw_switchdev_event_work); in cpsw_switchdev_event()
453 switchdev_work->priv = priv; in cpsw_switchdev_event()
454 switchdev_work->event = event; in cpsw_switchdev_event()
456 switch (event) { in cpsw_switchdev_event()
459 memcpy(&switchdev_work->fdb_info, ptr, in cpsw_switchdev_event()
460 sizeof(switchdev_work->fdb_info)); in cpsw_switchdev_event()
461 switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); in cpsw_switchdev_event()
462 if (!switchdev_work->fdb_info.addr) in cpsw_switchdev_event()
464 ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, in cpsw_switchdev_event()
465 fdb_info->addr); in cpsw_switchdev_event()
473 queue_work(system_long_wq, &switchdev_work->work); in cpsw_switchdev_event()
492 switch (event) { in cpsw_switchdev_blocking_event()
519 int cpsw_switchdev_register_notifiers(struct cpsw_common *cpsw) in cpsw_switchdev_register_notifiers() argument
525 dev_err(cpsw->dev, "register switchdev notifier fail ret:%d\n", in cpsw_switchdev_register_notifiers()
532 dev_err(cpsw->dev, "register switchdev blocking notifier ret:%d\n", in cpsw_switchdev_register_notifiers()
540 void cpsw_switchdev_unregister_notifiers(struct cpsw_common *cpsw) in cpsw_switchdev_unregister_notifiers() argument