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

1 // SPDX-License-Identifier: GPL-2.0
15 #include "cpsw.h"
30 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_stp_state_set() local
37 switch (state) { in cpsw_port_stp_state_set()
52 return -EOPNOTSUPP; in cpsw_port_stp_state_set()
55 ret = cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_stp_state_set()
57 dev_dbg(priv->dev, "ale state: %u\n", cpsw_state); in cpsw_port_stp_state_set()
67 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_attr_br_flags_set() local
75 dev_dbg(priv->dev, "BR_MCAST_FLOOD: %d port %u\n", in cpsw_port_attr_br_flags_set()
76 unreg_mcast_add, priv->emac_port); in cpsw_port_attr_br_flags_set()
78 cpsw_ale_set_unreg_mcast(cpsw->ale, BIT(priv->emac_port), in cpsw_port_attr_br_flags_set()
89 return -EINVAL; in cpsw_port_attr_br_flags_pre_set()
101 dev_dbg(priv->dev, "attr: id %u port: %u\n", attr->id, priv->emac_port); in cpsw_port_attr_set()
103 switch (attr->id) { in cpsw_port_attr_set()
106 attr->u.brport_flags); in cpsw_port_attr_set()
109 ret = cpsw_port_stp_state_set(priv, trans, attr->u.stp_state); in cpsw_port_attr_set()
110 dev_dbg(priv->dev, "stp state: %u\n", attr->u.stp_state); in cpsw_port_attr_set()
113 ret = cpsw_port_attr_br_flags_set(priv, trans, attr->orig_dev, in cpsw_port_attr_set()
114 attr->u.brport_flags); in cpsw_port_attr_set()
117 ret = -EOPNOTSUPP; in cpsw_port_attr_set()
126 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_pvid() local
130 if (priv->emac_port) { in cpsw_get_pvid()
133 if (cpsw->version == CPSW_VERSION_1) in cpsw_get_pvid()
135 pvid = slave_read(cpsw->slaves + (priv->emac_port - 1), reg); in cpsw_get_pvid()
137 port_vlan_reg = &cpsw->host_port_regs->port_vlan; in cpsw_get_pvid()
148 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_pvid() local
156 if (priv->emac_port) { in cpsw_set_pvid()
159 if (cpsw->version == CPSW_VERSION_1) in cpsw_set_pvid()
162 slave_write(cpsw->slaves + (priv->emac_port - 1), pvid, reg); in cpsw_set_pvid()
165 port_vlan_reg = &cpsw->host_port_regs->port_vlan; in cpsw_set_pvid()
174 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_vlan_add() local
184 flags = orig_dev->flags; in cpsw_port_vlan_add()
187 port_mask = BIT(priv->emac_port); in cpsw_port_vlan_add()
188 flags = priv->ndev->flags; in cpsw_port_vlan_add()
197 ret = cpsw_ale_vlan_add_modify(cpsw->ale, vid, port_mask, untag_mask, in cpsw_port_vlan_add()
200 dev_err(priv->dev, "Unable to add vlan\n"); in cpsw_port_vlan_add()
205 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_vlan_add()
212 dev_dbg(priv->dev, "VID add: %s: vid:%u ports:%X\n", in cpsw_port_vlan_add()
213 priv->ndev->name, vid, port_mask); in cpsw_port_vlan_add()
221 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_vlan_del() local
228 port_mask = BIT(priv->emac_port); in cpsw_port_vlan_del()
230 ret = cpsw_ale_del_vlan(cpsw->ale, vid, port_mask); in cpsw_port_vlan_del()
238 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_vlan_del()
247 cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_vlan_del()
249 dev_dbg(priv->dev, "VID del: %s: vid:%u ports:%X\n", in cpsw_port_vlan_del()
250 priv->ndev->name, vid, port_mask); in cpsw_port_vlan_del()
259 bool untag = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in cpsw_port_vlans_add()
260 struct net_device *orig_dev = vlan->obj.orig_dev; in cpsw_port_vlans_add()
262 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in cpsw_port_vlans_add()
265 dev_dbg(priv->dev, "VID add: %s: vid:%u flags:%X\n", in cpsw_port_vlans_add()
266 priv->ndev->name, vlan->vid_begin, vlan->flags); in cpsw_port_vlans_add()
268 if (cpu_port && !(vlan->flags & BRIDGE_VLAN_INFO_BRENTRY)) in cpsw_port_vlans_add()
274 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { in cpsw_port_vlans_add()
289 struct net_device *orig_dev = vlan->obj.orig_dev; in cpsw_port_vlans_del()
292 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { in cpsw_port_vlans_del()
308 struct net_device *orig_dev = mdb->obj.orig_dev; in cpsw_port_mdb_add()
310 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_mdb_add() local
320 port_mask = BIT(priv->emac_port); in cpsw_port_mdb_add()
322 err = cpsw_ale_add_mcast(cpsw->ale, mdb->addr, port_mask, in cpsw_port_mdb_add()
323 ALE_VLAN, mdb->vid, 0); in cpsw_port_mdb_add()
324 dev_dbg(priv->dev, "MDB add: %s: vid %u:%pM ports: %X\n", in cpsw_port_mdb_add()
325 priv->ndev->name, mdb->vid, mdb->addr, port_mask); in cpsw_port_mdb_add()
334 struct net_device *orig_dev = mdb->obj.orig_dev; in cpsw_port_mdb_del()
336 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_mdb_del() local
343 del_mask = BIT(priv->emac_port); in cpsw_port_mdb_del()
345 err = cpsw_ale_del_mcast(cpsw->ale, mdb->addr, del_mask, in cpsw_port_mdb_del()
346 ALE_VLAN, mdb->vid); in cpsw_port_mdb_del()
347 dev_dbg(priv->dev, "MDB del: %s: vid %u:%pM ports: %X\n", in cpsw_port_mdb_del()
348 priv->ndev->name, mdb->vid, mdb->addr, del_mask); in cpsw_port_mdb_del()
363 dev_dbg(priv->dev, "obj_add: id %u port: %u\n", in cpsw_port_obj_add()
364 obj->id, priv->emac_port); in cpsw_port_obj_add()
366 switch (obj->id) { in cpsw_port_obj_add()
375 err = -EOPNOTSUPP; in cpsw_port_obj_add()
390 dev_dbg(priv->dev, "obj_del: id %u port: %u\n", in cpsw_port_obj_del()
391 obj->id, priv->emac_port); in cpsw_port_obj_del()
393 switch (obj->id) { in cpsw_port_obj_del()
402 err = -EOPNOTSUPP; in cpsw_port_obj_del()
414 info.addr = rcv->addr; in cpsw_fdb_offload_notify()
415 info.vid = rcv->vid; in cpsw_fdb_offload_notify()
425 struct cpsw_priv *priv = switchdev_work->priv; in cpsw_switchdev_event_work()
427 struct cpsw_common *cpsw = priv->cpsw; in cpsw_switchdev_event_work() local
428 int port = priv->emac_port; in cpsw_switchdev_event_work()
431 switch (switchdev_work->event) { in cpsw_switchdev_event_work()
433 fdb = &switchdev_work->fdb_info; in cpsw_switchdev_event_work()
435 dev_dbg(cpsw->dev, "cpsw_fdb_add: MACID = %pM vid = %u flags = %u %u -- port %d\n", in cpsw_switchdev_event_work()
436 fdb->addr, fdb->vid, fdb->added_by_user, in cpsw_switchdev_event_work()
437 fdb->offloaded, port); in cpsw_switchdev_event_work()
439 if (!fdb->added_by_user) in cpsw_switchdev_event_work()
441 if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in cpsw_switchdev_event_work()
444 cpsw_ale_add_ucast(cpsw->ale, (u8 *)fdb->addr, port, in cpsw_switchdev_event_work()
445 fdb->vid ? ALE_VLAN : 0, fdb->vid); in cpsw_switchdev_event_work()
446 cpsw_fdb_offload_notify(priv->ndev, fdb); in cpsw_switchdev_event_work()
449 fdb = &switchdev_work->fdb_info; in cpsw_switchdev_event_work()
451 dev_dbg(cpsw->dev, "cpsw_fdb_del: MACID = %pM vid = %u flags = %u %u -- port %d\n", in cpsw_switchdev_event_work()
452 fdb->addr, fdb->vid, fdb->added_by_user, in cpsw_switchdev_event_work()
453 fdb->offloaded, port); in cpsw_switchdev_event_work()
455 if (!fdb->added_by_user) in cpsw_switchdev_event_work()
457 if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in cpsw_switchdev_event_work()
460 cpsw_ale_del_ucast(cpsw->ale, (u8 *)fdb->addr, port, in cpsw_switchdev_event_work()
461 fdb->vid ? ALE_VLAN : 0, fdb->vid); in cpsw_switchdev_event_work()
468 kfree(switchdev_work->fdb_info.addr); in cpsw_switchdev_event_work()
470 dev_put(priv->ndev); in cpsw_switchdev_event_work()
497 INIT_WORK(&switchdev_work->work, cpsw_switchdev_event_work); in cpsw_switchdev_event()
498 switchdev_work->priv = priv; in cpsw_switchdev_event()
499 switchdev_work->event = event; in cpsw_switchdev_event()
501 switch (event) { in cpsw_switchdev_event()
504 memcpy(&switchdev_work->fdb_info, ptr, in cpsw_switchdev_event()
505 sizeof(switchdev_work->fdb_info)); in cpsw_switchdev_event()
506 switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); in cpsw_switchdev_event()
507 if (!switchdev_work->fdb_info.addr) in cpsw_switchdev_event()
509 ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, in cpsw_switchdev_event()
510 fdb_info->addr); in cpsw_switchdev_event()
518 queue_work(system_long_wq, &switchdev_work->work); in cpsw_switchdev_event()
537 switch (event) { in cpsw_switchdev_blocking_event()
564 int cpsw_switchdev_register_notifiers(struct cpsw_common *cpsw) in cpsw_switchdev_register_notifiers() argument
570 dev_err(cpsw->dev, "register switchdev notifier fail ret:%d\n", in cpsw_switchdev_register_notifiers()
577 dev_err(cpsw->dev, "register switchdev blocking notifier ret:%d\n", in cpsw_switchdev_register_notifiers()
585 void cpsw_switchdev_unregister_notifiers(struct cpsw_common *cpsw) in cpsw_switchdev_unregister_notifiers() argument