Lines Matching +full:cpsw +full:- +full:switch
1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright (C) 2020 Texas Instruments Incorporated - https://www.ti.com/
14 #include "am65-cpsw-nuss.h"
15 #include "am65-cpsw-switchdev.h"
27 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_stp_state_set() local
31 switch (state) { in am65_cpsw_port_stp_state_set()
46 return -EOPNOTSUPP; in am65_cpsw_port_stp_state_set()
49 ret = cpsw_ale_control_set(cpsw->ale, port->port_id, in am65_cpsw_port_stp_state_set()
51 netdev_dbg(port->ndev, "ale state: %u\n", cpsw_state); in am65_cpsw_port_stp_state_set()
60 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_attr_br_flags_set() local
68 netdev_dbg(port->ndev, "BR_MCAST_FLOOD: %d port %u\n", in am65_cpsw_port_attr_br_flags_set()
69 unreg_mcast_add, port->port_id); in am65_cpsw_port_attr_br_flags_set()
71 cpsw_ale_set_unreg_mcast(cpsw->ale, BIT(port->port_id), in am65_cpsw_port_attr_br_flags_set()
82 return -EINVAL; in am65_cpsw_port_attr_br_flags_pre_set()
94 netdev_dbg(ndev, "attr: id %u port: %u\n", attr->id, port->port_id); in am65_cpsw_port_attr_set()
96 switch (attr->id) { in am65_cpsw_port_attr_set()
99 attr->u.brport_flags); in am65_cpsw_port_attr_set()
102 ret = am65_cpsw_port_stp_state_set(port, attr->u.stp_state); in am65_cpsw_port_attr_set()
103 netdev_dbg(ndev, "stp state: %u\n", attr->u.stp_state); in am65_cpsw_port_attr_set()
106 ret = am65_cpsw_port_attr_br_flags_set(port, attr->orig_dev, in am65_cpsw_port_attr_set()
107 attr->u.brport_flags); in am65_cpsw_port_attr_set()
110 ret = -EOPNOTSUPP; in am65_cpsw_port_attr_set()
119 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_get_pvid() local
120 struct am65_cpsw_host *host_p = am65_common_get_host(cpsw); in am65_cpsw_get_pvid()
123 if (port->port_id) in am65_cpsw_get_pvid()
124 pvid = readl(port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); in am65_cpsw_get_pvid()
126 pvid = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); in am65_cpsw_get_pvid()
135 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_set_pvid() local
136 struct am65_cpsw_host *host_p = am65_common_get_host(cpsw); in am65_cpsw_set_pvid()
143 if (port->port_id) in am65_cpsw_set_pvid()
144 writel(pvid, port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); in am65_cpsw_set_pvid()
146 writel(pvid, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); in am65_cpsw_set_pvid()
153 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_vlan_add() local
163 flags = orig_dev->flags; in am65_cpsw_port_vlan_add()
166 port_mask = BIT(port->port_id); in am65_cpsw_port_vlan_add()
167 flags = port->ndev->flags; in am65_cpsw_port_vlan_add()
176 ret = cpsw_ale_vlan_add_modify(cpsw->ale, vid, port_mask, untag_mask, in am65_cpsw_port_vlan_add()
179 netdev_err(port->ndev, "Unable to add vlan\n"); in am65_cpsw_port_vlan_add()
184 cpsw_ale_add_ucast(cpsw->ale, port->slave.mac_addr, in am65_cpsw_port_vlan_add()
191 netdev_dbg(port->ndev, "VID add: %s: vid:%u ports:%X\n", in am65_cpsw_port_vlan_add()
192 port->ndev->name, vid, port_mask); in am65_cpsw_port_vlan_add()
201 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_vlan_del() local
208 port_mask = BIT(port->port_id); in am65_cpsw_port_vlan_del()
210 ret = cpsw_ale_del_vlan(cpsw->ale, vid, port_mask); in am65_cpsw_port_vlan_del()
218 cpsw_ale_del_ucast(cpsw->ale, port->slave.mac_addr, in am65_cpsw_port_vlan_del()
227 cpsw_ale_del_mcast(cpsw->ale, port->ndev->broadcast, port_mask, in am65_cpsw_port_vlan_del()
229 netdev_dbg(port->ndev, "VID del: %s: vid:%u ports:%X\n", in am65_cpsw_port_vlan_del()
230 port->ndev->name, vid, port_mask); in am65_cpsw_port_vlan_del()
238 bool untag = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in am65_cpsw_port_vlans_add()
239 struct net_device *orig_dev = vlan->obj.orig_dev; in am65_cpsw_port_vlans_add()
240 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in am65_cpsw_port_vlans_add()
242 netdev_dbg(port->ndev, "VID add: %s: vid:%u flags:%X\n", in am65_cpsw_port_vlans_add()
243 port->ndev->name, vlan->vid, vlan->flags); in am65_cpsw_port_vlans_add()
245 return am65_cpsw_port_vlan_add(port, untag, pvid, vlan->vid, orig_dev); in am65_cpsw_port_vlans_add()
252 return am65_cpsw_port_vlan_del(port, vlan->vid, vlan->obj.orig_dev); in am65_cpsw_port_vlans_del()
259 struct net_device *orig_dev = mdb->obj.orig_dev; in am65_cpsw_port_mdb_add()
261 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_mdb_add() local
268 port_mask = BIT(port->port_id); in am65_cpsw_port_mdb_add()
270 err = cpsw_ale_add_mcast(cpsw->ale, mdb->addr, port_mask, in am65_cpsw_port_mdb_add()
271 ALE_VLAN, mdb->vid, 0); in am65_cpsw_port_mdb_add()
272 netdev_dbg(port->ndev, "MDB add: %s: vid %u:%pM ports: %X\n", in am65_cpsw_port_mdb_add()
273 port->ndev->name, mdb->vid, mdb->addr, port_mask); in am65_cpsw_port_mdb_add()
282 struct net_device *orig_dev = mdb->obj.orig_dev; in am65_cpsw_port_mdb_del()
284 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_port_mdb_del() local
290 del_mask = BIT(port->port_id); in am65_cpsw_port_mdb_del()
293 cpsw_ale_del_mcast(cpsw->ale, mdb->addr, del_mask, in am65_cpsw_port_mdb_del()
294 ALE_VLAN, mdb->vid); in am65_cpsw_port_mdb_del()
295 netdev_dbg(port->ndev, "MDB del: %s: vid %u:%pM ports: %X\n", in am65_cpsw_port_mdb_del()
296 port->ndev->name, mdb->vid, mdb->addr, del_mask); in am65_cpsw_port_mdb_del()
310 netdev_dbg(ndev, "obj_add: id %u port: %u\n", obj->id, port->port_id); in am65_cpsw_port_obj_add()
312 switch (obj->id) { in am65_cpsw_port_obj_add()
321 err = -EOPNOTSUPP; in am65_cpsw_port_obj_add()
336 netdev_dbg(ndev, "obj_del: id %u port: %u\n", obj->id, port->port_id); in am65_cpsw_port_obj_del()
338 switch (obj->id) { in am65_cpsw_port_obj_del()
347 err = -EOPNOTSUPP; in am65_cpsw_port_obj_del()
359 info.addr = rcv->addr; in am65_cpsw_fdb_offload_notify()
360 info.vid = rcv->vid; in am65_cpsw_fdb_offload_notify()
370 struct am65_cpsw_port *port = switchdev_work->port; in am65_cpsw_switchdev_event_work()
372 struct am65_cpsw_common *cpsw = port->common; in am65_cpsw_switchdev_event_work() local
373 int port_id = port->port_id; in am65_cpsw_switchdev_event_work()
376 switch (switchdev_work->event) { in am65_cpsw_switchdev_event_work()
378 fdb = &switchdev_work->fdb_info; in am65_cpsw_switchdev_event_work()
380 netdev_dbg(port->ndev, "cpsw_fdb_add: MACID = %pM vid = %u flags = %u %u -- port %d\n", in am65_cpsw_switchdev_event_work()
381 fdb->addr, fdb->vid, fdb->added_by_user, in am65_cpsw_switchdev_event_work()
382 fdb->offloaded, port_id); in am65_cpsw_switchdev_event_work()
384 if (!fdb->added_by_user || fdb->is_local) in am65_cpsw_switchdev_event_work()
386 if (memcmp(port->slave.mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in am65_cpsw_switchdev_event_work()
389 cpsw_ale_add_ucast(cpsw->ale, (u8 *)fdb->addr, port_id, in am65_cpsw_switchdev_event_work()
390 fdb->vid ? ALE_VLAN : 0, fdb->vid); in am65_cpsw_switchdev_event_work()
391 am65_cpsw_fdb_offload_notify(port->ndev, fdb); in am65_cpsw_switchdev_event_work()
394 fdb = &switchdev_work->fdb_info; in am65_cpsw_switchdev_event_work()
396 netdev_dbg(port->ndev, "cpsw_fdb_del: MACID = %pM vid = %u flags = %u %u -- port %d\n", in am65_cpsw_switchdev_event_work()
397 fdb->addr, fdb->vid, fdb->added_by_user, in am65_cpsw_switchdev_event_work()
398 fdb->offloaded, port_id); in am65_cpsw_switchdev_event_work()
400 if (!fdb->added_by_user || fdb->is_local) in am65_cpsw_switchdev_event_work()
402 if (memcmp(port->slave.mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0) in am65_cpsw_switchdev_event_work()
405 cpsw_ale_del_ucast(cpsw->ale, (u8 *)fdb->addr, port_id, in am65_cpsw_switchdev_event_work()
406 fdb->vid ? ALE_VLAN : 0, fdb->vid); in am65_cpsw_switchdev_event_work()
413 kfree(switchdev_work->fdb_info.addr); in am65_cpsw_switchdev_event_work()
415 dev_put(port->ndev); in am65_cpsw_switchdev_event_work()
442 INIT_WORK(&switchdev_work->work, am65_cpsw_switchdev_event_work); in am65_cpsw_switchdev_event()
443 switchdev_work->port = port; in am65_cpsw_switchdev_event()
444 switchdev_work->event = event; in am65_cpsw_switchdev_event()
446 switch (event) { in am65_cpsw_switchdev_event()
449 memcpy(&switchdev_work->fdb_info, ptr, in am65_cpsw_switchdev_event()
450 sizeof(switchdev_work->fdb_info)); in am65_cpsw_switchdev_event()
451 switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); in am65_cpsw_switchdev_event()
452 if (!switchdev_work->fdb_info.addr) in am65_cpsw_switchdev_event()
454 ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, in am65_cpsw_switchdev_event()
455 fdb_info->addr); in am65_cpsw_switchdev_event()
463 queue_work(system_long_wq, &switchdev_work->work); in am65_cpsw_switchdev_event()
482 switch (event) { in am65_cpsw_switchdev_blocking_event()
509 int am65_cpsw_switchdev_register_notifiers(struct am65_cpsw_common *cpsw) in am65_cpsw_switchdev_register_notifiers() argument
515 dev_err(cpsw->dev, "register switchdev notifier fail ret:%d\n", in am65_cpsw_switchdev_register_notifiers()
522 dev_err(cpsw->dev, "register switchdev blocking notifier ret:%d\n", in am65_cpsw_switchdev_register_notifiers()
530 void am65_cpsw_switchdev_unregister_notifiers(struct am65_cpsw_common *cpsw) in am65_cpsw_switchdev_unregister_notifiers() argument