Skip to content

Commit f79beba

Browse files
committed
Merge branch 'am65-cpsw-nuss-switchdev-driver'
Vignesh Raghavendra says: ==================== net: ti: am65-cpsw-nuss: Add switchdev driver This series adds switchdev support for AM65 CPSW NUSS driver to support multi port CPSW present on J721e and AM64 SoCs. It adds devlink hook to switch b/w switch mode and multi mac mode. v2: Rebased on latest net-next Update patch 1/4 with rationale for using devlink ====================
2 parents b4e18b2 + e276cfb commit f79beba

File tree

10 files changed

+1267
-19
lines changed

10 files changed

+1267
-19
lines changed

Documentation/networking/device_drivers/ethernet/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Contents:
4949
stmicro/stmmac
5050
ti/cpsw
5151
ti/cpsw_switchdev
52+
ti/am65_nuss_cpsw_switchdev
5253
ti/tlan
5354
toshiba/spider_net
5455

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
===================================================================
4+
Texas Instruments K3 AM65 CPSW NUSS switchdev based ethernet driver
5+
===================================================================
6+
7+
:Version: 1.0
8+
9+
Port renaming
10+
=============
11+
12+
In order to rename via udev::
13+
14+
ip -d link show dev sw0p1 | grep switchid
15+
16+
SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
17+
ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
18+
19+
20+
Multi mac mode
21+
==============
22+
23+
- The driver is operating in multi-mac mode by default, thus
24+
working as N individual network interfaces.
25+
26+
Devlink configuration parameters
27+
================================
28+
29+
See Documentation/networking/devlink/am65-nuss-cpsw-switch.rst
30+
31+
Enabling "switch"
32+
=================
33+
34+
The Switch mode can be enabled by configuring devlink driver parameter
35+
"switch_mode" to 1/true::
36+
37+
devlink dev param set platform/c000000.ethernet \
38+
name switch_mode value true cmode runtime
39+
40+
This can be done regardless of the state of Port's netdev devices - UP/DOWN, but
41+
Port's netdev devices have to be in UP before joining to the bridge to avoid
42+
overwriting of bridge configuration as CPSW switch driver completely reloads its
43+
configuration when first port changes its state to UP.
44+
45+
When the both interfaces joined the bridge - CPSW switch driver will enable
46+
marking packets with offload_fwd_mark flag.
47+
48+
All configuration is implemented via switchdev API.
49+
50+
Bridge setup
51+
============
52+
53+
::
54+
55+
devlink dev param set platform/c000000.ethernet \
56+
name switch_mode value true cmode runtime
57+
58+
ip link add name br0 type bridge
59+
ip link set dev br0 type bridge ageing_time 1000
60+
ip link set dev sw0p1 up
61+
ip link set dev sw0p2 up
62+
ip link set dev sw0p1 master br0
63+
ip link set dev sw0p2 master br0
64+
65+
[*] bridge vlan add dev br0 vid 1 pvid untagged self
66+
67+
[*] if vlan_filtering=1. where default_pvid=1
68+
69+
Note. Steps [*] are mandatory.
70+
71+
72+
On/off STP
73+
==========
74+
75+
::
76+
77+
ip link set dev BRDEV type bridge stp_state 1/0
78+
79+
VLAN configuration
80+
==================
81+
82+
::
83+
84+
bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
85+
86+
Note. This step is mandatory for bridge/default_pvid.
87+
88+
Add extra VLANs
89+
===============
90+
91+
1. untagged::
92+
93+
bridge vlan add dev sw0p1 vid 100 pvid untagged master
94+
bridge vlan add dev sw0p2 vid 100 pvid untagged master
95+
bridge vlan add dev br0 vid 100 pvid untagged self <---- Add cpu port to VLAN100
96+
97+
2. tagged::
98+
99+
bridge vlan add dev sw0p1 vid 100 master
100+
bridge vlan add dev sw0p2 vid 100 master
101+
bridge vlan add dev br0 vid 100 pvid tagged self <---- Add cpu port to VLAN100
102+
103+
FDBs
104+
----
105+
106+
FDBs are automatically added on the appropriate switch port upon detection
107+
108+
Manually adding FDBs::
109+
110+
bridge fdb add aa:bb:cc:dd:ee:ff dev sw0p1 master vlan 100
111+
bridge fdb add aa:bb:cc:dd:ee:fe dev sw0p2 master <---- Add on all VLANs
112+
113+
MDBs
114+
----
115+
116+
MDBs are automatically added on the appropriate switch port upon detection
117+
118+
Manually adding MDBs::
119+
120+
bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100
121+
bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent <---- Add on all VLANs
122+
123+
Multicast flooding
124+
==================
125+
CPU port mcast_flooding is always on
126+
127+
Turning flooding on/off on swithch ports:
128+
bridge link set dev sw0p1 mcast_flood on/off
129+
130+
Access and Trunk port
131+
=====================
132+
133+
::
134+
135+
bridge vlan add dev sw0p1 vid 100 pvid untagged master
136+
bridge vlan add dev sw0p2 vid 100 master
137+
138+
139+
bridge vlan add dev br0 vid 100 self
140+
ip link add link br0 name br0.100 type vlan id 100
141+
142+
Note. Setting PVID on Bridge device itself works only for
143+
default VLAN (default_pvid).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
==============================
4+
am65-cpsw-nuss devlink support
5+
==============================
6+
7+
This document describes the devlink features implemented by the ``am65-cpsw-nuss``
8+
device driver.
9+
10+
Parameters
11+
==========
12+
13+
The ``am65-cpsw-nuss`` driver implements the following driver-specific
14+
parameters.
15+
16+
.. list-table:: Driver-specific parameters implemented
17+
:widths: 5 5 5 85
18+
19+
* - Name
20+
- Type
21+
- Mode
22+
- Description
23+
* - ``switch_mode``
24+
- Boolean
25+
- runtime
26+
- Enable switch mode

Documentation/networking/devlink/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ parameters, info versions, and other features it supports.
4545
sja1105
4646
qed
4747
ti-cpsw-switch
48+
am65-nuss-cpsw-switch

drivers/net/ethernet/ti/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ config TI_CPTS
9292
config TI_K3_AM65_CPSW_NUSS
9393
tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
9494
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
95+
select NET_DEVLINK
9596
select TI_DAVINCI_MDIO
9697
imply PHY_TI_GMII_SEL
9798
depends on TI_K3_AM65_CPTS || !TI_K3_AM65_CPTS
@@ -105,6 +106,15 @@ config TI_K3_AM65_CPSW_NUSS
105106
To compile this driver as a module, choose M here: the module
106107
will be called ti-am65-cpsw-nuss.
107108

109+
config TI_K3_AM65_CPSW_SWITCHDEV
110+
bool "TI K3 AM654x/J721E CPSW Switch mode support"
111+
depends on TI_K3_AM65_CPSW_NUSS
112+
depends on NET_SWITCHDEV
113+
help
114+
This enables switchdev support for TI K3 CPSWxG Ethernet
115+
Switch. Enable this driver to support hardware switch support for AM65
116+
CPSW NUSS driver.
117+
108118
config TI_K3_AM65_CPTS
109119
tristate "TI K3 AM65x CPTS"
110120
depends on ARCH_K3 && OF

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

0 commit comments

Comments
 (0)