Skip to content

Commit 86e8b07

Browse files
r-vigneshdavem330
authored andcommitted
net: ti: am65-cpsw-nuss: Add switchdev support
J721e, J7200 and AM64 have multi port switches which can work in multi mac mode and in switch mode. Add support for configuring this HW in switch mode using devlink and switchdev notifiers. Support is similar to existing CPSW switchdev implementation of TI's 32 bit platform like AM33/AM43/AM57. To enable switch mode: devlink dev param set platform/8000000.ethernet name switch_mode value true cmode runtime All configuration is implemented via switchdev API and notifiers. Supported: - SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS - SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS - SWITCHDEV_ATTR_ID_PORT_STP_STATE - SWITCHDEV_OBJ_ID_PORT_VLAN - SWITCHDEV_OBJ_ID_PORT_MDB - SWITCHDEV_OBJ_ID_HOST_MDB Hence AM65 CPSW switchdev driver supports: - FDB offloading - MDB offloading - VLAN filtering and offloading - STP Signed-off-by: Vignesh Raghavendra <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2934db9 commit 86e8b07

File tree

4 files changed

+587
-1
lines changed

4 files changed

+587
-1
lines changed

drivers/net/ethernet/ti/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.
2626

2727
obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
2828
ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-cppi-desc-pool.o am65-cpsw-qos.o
29+
ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
2930
obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cpsw_ale.h"
3232
#include "cpsw_sl.h"
3333
#include "am65-cpsw-nuss.h"
34+
#include "am65-cpsw-switchdev.h"
3435
#include "k3-cppi-desc-pool.h"
3536
#include "am65-cpts.h"
3637

@@ -228,6 +229,9 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
228229
u32 port_mask, unreg_mcast = 0;
229230
int ret;
230231

232+
if (!common->is_emac_mode)
233+
return 0;
234+
231235
if (!netif_running(ndev) || !vid)
232236
return 0;
233237

@@ -255,6 +259,9 @@ static int am65_cpsw_nuss_ndo_slave_kill_vid(struct net_device *ndev,
255259
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
256260
int ret;
257261

262+
if (!common->is_emac_mode)
263+
return 0;
264+
258265
if (!netif_running(ndev) || !vid)
259266
return 0;
260267

@@ -277,6 +284,11 @@ static void am65_cpsw_slave_set_promisc(struct am65_cpsw_port *port,
277284
{
278285
struct am65_cpsw_common *common = port->common;
279286

287+
if (promisc && !common->is_emac_mode) {
288+
dev_dbg(common->dev, "promisc mode requested in switch mode");
289+
return;
290+
}
291+
280292
if (promisc) {
281293
/* Enable promiscuous mode */
282294
cpsw_ale_control_set(common->ale, port->port_id,
@@ -800,12 +812,13 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_common *common,
800812

801813
new_skb = netdev_alloc_skb_ip_align(ndev, AM65_CPSW_MAX_PACKET_SIZE);
802814
if (new_skb) {
815+
ndev_priv = netdev_priv(ndev);
816+
am65_cpsw_nuss_set_offload_fwd_mark(skb, ndev_priv->offload_fwd_mark);
803817
skb_put(skb, pkt_len);
804818
skb->protocol = eth_type_trans(skb, ndev);
805819
am65_cpsw_nuss_rx_csum(skb, csum_info);
806820
napi_gro_receive(&common->napi_rx, skb);
807821

808-
ndev_priv = netdev_priv(ndev);
809822
stats = this_cpu_ptr(ndev_priv->stats);
810823

811824
u64_stats_update_begin(&stats->syncp);
@@ -2144,6 +2157,10 @@ static int am65_cpsw_register_notifiers(struct am65_cpsw_common *cpsw)
21442157
return ret;
21452158
}
21462159

2160+
ret = am65_cpsw_switchdev_register_notifiers(cpsw);
2161+
if (ret)
2162+
unregister_netdevice_notifier(&cpsw->am65_cpsw_netdevice_nb);
2163+
21472164
return ret;
21482165
}
21492166

@@ -2153,6 +2170,7 @@ static void am65_cpsw_unregister_notifiers(struct am65_cpsw_common *cpsw)
21532170
!IS_REACHABLE(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV))
21542171
return;
21552172

2173+
am65_cpsw_switchdev_unregister_notifiers(cpsw);
21562174
unregister_netdevice_notifier(&cpsw->am65_cpsw_netdevice_nb);
21572175
}
21582176

0 commit comments

Comments
 (0)