Skip to contentSkip to conversation

net: ipqess: introduce Qualcomm IPQESS driver

PATCH Superseded Maxime Chevallier 4 participants 14 messages Sep 9, 2022 – Sep 17, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover net: ipqess: introduce Qualcomm IPQESS driver

Hello everyone,

This is the 4th iteration of a series that introduces a new driver, for the Qualcomm IPQESS Ethernet Controller, found on the IPQ4019.

Note that this series contains binding patches that should go through the DT tree.

The DSA out-of-band tagging is still using the skb->headroom part, but there doesn't seem to be any better way for now without adding fields to struct sk_buff.

Notables changes on V4 :
- Cache the uses_dsa info from CHANGEUPPER events
- Use better string handling helpers for ethtool stats
- rename ethtool callbacks
- Fix a binding typo

Notables changes on V3 :
- Took into account Russell's review on the ioctl handler and the mac capabilities that were missing
- Took Andrew's reviews into account by reworking the napi rx loop, some stray "inline" keywords, and useless warnings
- Took Vlad's reviews into account by reworking a few macros
- Took Christophe's review into account by removing extra GFP_ZERO
- Took Rob's review into account by simplifying the binding

Note that this V3 didn't focus on the tagging protocol, as I understand the issue is still open. I'm willing to keep on testing some ideas, and continue Florian's discussion.

Notables changes on V2 :
- Put the DSA tag in the skb itself instead of using skb->shinfo
- Fixed the initialisation sequence based on Andrew's comments
- Reworked the error paths in the init sequence
- Add support for the clock and reset lines on that controller
- Fixed and updated the binding

The driver itself is pretty straightforward, but has lived out-of-tree for a while. I've done my best to clean-up some outdated API calls, but some might remain.

This controller is somewhat special, since it's part of the IPQ4019 SoC which also includes an QCA8K switch, and uses the IPQESS controller for the CPU port. The switch is so tightly intergrated with the MAC that it is connected to the MAC using an internal link (hence the fact that we only support PHY_INTERFACE_MODE_INTERNAL), and this has some consequences on the DSA side.

The tagging for the switch isn't done inband as most switch do, but out-of-band, the DSA tag being included in the DMA descriptor.

This series includes a new out-of-band tagger that uses the skb headroom to convey the tag between the tagger and the MAC driver.

Thanks to the Sartura folks who worked on a base version of this driver, and provided test hardware.

Best regards,

Maxime Chevallier

Maxime Chevallier (5):
net: ipqess: introduce the Qualcomm IPQESS driver
net: dsa: add out-of-band tagging protocol
net: ipqess: Add out-of-band DSA tagging support
net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller
ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet
controller

 .../devicetree/bindings/net/qcom,ipqess.yaml  |   95 ++
 MAINTAINERS                                   |    6 +
 arch/arm/boot/dts/qcom-ipq4019.dtsi           |   46 +
 drivers/net/ethernet/qualcomm/Kconfig         |   12 +
 drivers/net/ethernet/qualcomm/Makefile        |    2 +
 drivers/net/ethernet/qualcomm/ipqess/Makefile |    8 +
 drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 1310 +++++++++++++++++
 drivers/net/ethernet/qualcomm/ipqess/ipqess.h |  522 +++++++
 .../ethernet/qualcomm/ipqess/ipqess_ethtool.c |  164 +++
 include/linux/dsa/oob.h                       |   17 +
 include/net/dsa.h                             |    2 +
 net/dsa/Kconfig                               |    7 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_oob.c                             |   84 ++
 14 files changed, 2276 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ipqess.yaml
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/Makefile
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.c
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.h
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c
 create mode 100644 include/linux/dsa/oob.h
 create mode 100644 net/dsa/tag_oob.c
Signature · 1 line
2.37.2
#1 lore raw

PATCH v4 1/5 net: ipqess: introduce the Qualcomm IPQESS driver

The Qualcomm IPQESS controller is a simple 1G Ethernet controller found on the IPQ4019 chip. This controller has some specificities, in that the IPQ4019 platform that includes that controller also has an internal switch, based on the QCA8K IP.

It is connected to that switch through an internal link, and doesn't expose directly any external interface, hence it only supports the PHY_INTERFACE_MODE_INTERNAL for now.

It has 16 RX and TX queues, with a very basic RSS fanout configured at init time.

---
V3->V4 :
- Renamed the ethtool ksettings callbacks
- Use ethtool_sprintf
- Cache uses_dsa on CHANGEUPPER events
V2->V3 :
- Cleaned up ioctls and phylink support
- Reworked the napi loop
- cleaned up some macros and warnings
V1->V2 :
- Reworked the init sequence, following Andrew's comments
- Added clock and reset support
- Reworked the error paths
- Added extra endianness wrappers to fix sparse warnings

 MAINTAINERS                                   |    6 +
 drivers/net/ethernet/qualcomm/Kconfig         |   11 +
 drivers/net/ethernet/qualcomm/Makefile        |    2 +
 drivers/net/ethernet/qualcomm/ipqess/Makefile |    8 +
 drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 1256 +++++++++++++++++
 drivers/net/ethernet/qualcomm/ipqess/ipqess.h |  518 +++++++
 .../ethernet/qualcomm/ipqess/ipqess_ethtool.c |  164 +++
 7 files changed, 1965 insertions(+)
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/Makefile
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.c
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.h
 create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c
MAINTAINERS +6 -0
index ba954d5a9a2f..53033fb43842 100644
@@ -16845,6 +16845,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/qualcomm/emac/
 
+QUALCOMM IPQESS ETHERNET DRIVER
+M:	Maxime Chevallier <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/net/ethernet/qualcomm/ipqess/
+
 QUALCOMM ETHQOS ETHERNET DRIVER
 M:	Vinod Koul <[email protected]>
 L:	[email protected]
drivers/net/ethernet/qualcomm/Kconfig +11 -0
index a4434eb38950..a723ddbea248 100644
@@ -60,6 +60,17 @@ config QCOM_EMAC
 	  low power, Receive-Side Scaling (RSS), and IEEE 1588-2008
 	  Precision Clock Synchronization Protocol.
 
+config QCOM_IPQ4019_ESS_EDMA
+	tristate "Qualcomm Atheros IPQ4019 ESS EDMA support"
+	depends on OF
+	select PHYLINK
+	help
+	  This driver supports the Qualcomm Atheros IPQ40xx built-in
+	  ESS EDMA ethernet controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ipqess.
+
 source "drivers/net/ethernet/qualcomm/rmnet/Kconfig"
 
 endif # NET_VENDOR_QUALCOMM
drivers/net/ethernet/qualcomm/Makefile +2 -0
index 9250976dd884..db463c9ea1f9 100644
@@ -11,4 +11,6 @@ qcauart-objs := qca_uart.o
 
 obj-y += emac/
 
+obj-$(CONFIG_QCOM_IPQ4019_ESS_EDMA) += ipqess/
+
 obj-$(CONFIG_RMNET) += rmnet/
drivers/net/ethernet/qualcomm/ipqess/Makefile new file +8 -0
new file mode 100644
index 000000000000..4f2db7283ebf
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the IPQ ESS driver
+#
+
+obj-$(CONFIG_QCOM_IPQ4019_ESS_EDMA) += ipq_ess.o
+
+ipq_ess-objs := ipqess.o ipqess_ethtool.o
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +1256 -0

1,256 lines not on this page · raw message

drivers/net/ethernet/qualcomm/ipqess/ipqess.h new file +518 -0

518 lines not on this page · raw message

drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
2.37.2
#2 lore raw

Re: [PATCH net-next v4 1/5] net: ipqess: introduce the Qualcomm IPQESS driver

Quoted 10 lines · Maxime Chevallier

The Qualcomm IPQESS controller is a simple 1G Ethernet controller found on the IPQ4019 chip. This controller has some specificities, in that the IPQ4019 platform that includes that controller also has an internal switch, based on the QCA8K IP.

It is connected to that switch through an internal link, and doesn't expose directly any external interface, hence it only supports the PHY_INTERFACE_MODE_INTERNAL for now.

It has 16 RX and TX queues, with a very basic RSS fanout configured at

Thank you for your patch. There is something to discuss/improve.

drivers/net/ethernet/qualcomm/ipqess/ipqess.c line 1107

Quoted 12 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +12 -0
+}
+
+static int ipqess_axi_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct net_device *netdev;
+	phy_interface_t phy_mode;
+	struct resource *res;
+	struct ipqess *ess;
+	int i, err = 0;
+
+	netdev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct ipqess),

sizeof(*)

Quoted 4 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +4 -0
+					 IPQESS_NETDEV_QUEUES,
+					 IPQESS_NETDEV_QUEUES);
+	if (!netdev)
+		return -ENOMEM;

drivers/net/ethernet/qualcomm/ipqess/ipqess.c line 1121

Quoted 10 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +10 -0
+
+	ess = netdev_priv(netdev);
+	ess->netdev = netdev;
+	ess->pdev = pdev;
+	spin_lock_init(&ess->stats_lock);
+	SET_NETDEV_DEV(netdev, &pdev->dev);
+	platform_set_drvdata(pdev, netdev);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ess->hw_addr = devm_ioremap_resource(&pdev->dev, res);

Use a helper for this.

drivers/net/ethernet/qualcomm/ipqess/ipqess.c line 1131

Quoted 10 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +10 -0
+	if (IS_ERR(ess->hw_addr))
+		return PTR_ERR(ess->hw_addr);
+
+	err = of_get_phy_mode(np, &phy_mode);
+	if (err) {
+		dev_err(&pdev->dev, "incorrect phy-mode\n");
+		return err;
+	}
+
+	ess->ess_clk = devm_clk_get(&pdev->dev, "ess");

There is no such clock "ess"...

drivers/net/ethernet/qualcomm/ipqess/ipqess.c line 1135

Quoted 4 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +4 -0
+	if (!IS_ERR(ess->ess_clk))
+		clk_prepare_enable(ess->ess_clk);
+
+	ess->ess_rst = devm_reset_control_get(&pdev->dev, "ess");

Same problem.

Quoted 11 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +11 -0
+	if (IS_ERR(ess->ess_rst))
+		goto err_clk;
+
+	ipqess_reset(ess);
+
+	ess->phylink_config.dev = &netdev->dev;
+	ess->phylink_config.type = PHYLINK_NETDEV;
+	ess->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 |
+					       MAC_100 | MAC_1000FD;
+
+	__set_bit(PHY_INTERFACE_MODE_INTERNAL,

drivers/net/ethernet/qualcomm/ipqess/ipqess.c line 1156

Quoted 10 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c new file +10 -0
+		  ess->phylink_config.supported_interfaces);
+
+	ess->phylink = phylink_create(&ess->phylink_config,
+				      of_fwnode_handle(np), phy_mode,
+				      &ipqess_phylink_mac_ops);
+	if (IS_ERR(ess->phylink)) {
+		err = PTR_ERR(ess->phylink);
+		goto err_clk;
+	}
+

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH net-next v4 1/5] net: ipqess: introduce the Qualcomm IPQESS driver

In reply to Maxime Chevallier
I love your patch! Yet something to improve:

Hi Maxime,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Maxime-Chevallier/net-ipqess-introduce-Qualcomm-IPQESS-driver/20220909-232946
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 169ccf0e40825d9e465863e4707d8e8546d3c3cb
config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20220912/[email protected]/config)
compiler: xtensa-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0f2d032fe80cfabb7db162b9c19ed6e23077baeb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Maxime-Chevallier/net-ipqess-introduce-Qualcomm-IPQESS-driver/20220909-232946 git checkout 0f2d032fe80cfabb7db162b9c19ed6e23077baeb
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=xtensa SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable

All errors (new ones prefixed by >>):

drivers/net/ethernet/qualcomm/ipqess/ipqess.c: In function 'ipqess_axi_probe':

>> drivers/net/ethernet/qualcomm/ipqess/ipqess.c:1191:17: error: implicit declaration of function 'netif_tx_napi_add'; did you mean 'netif_napi_add'? [-Werror=implicit-function-declaration]
    1191 |                 netif_tx_napi_add(netdev, &ess->tx_ring[i].napi_tx,
         |                 ^~~~~~~~~~~~~~~~~
         |                 netif_napi_add

cc1: some warnings being treated as errors

vim +1191 drivers/net/ethernet/qualcomm/ipqess/ipqess.c

1097
1098 static int ipqess_axi_probe(struct platform_device *pdev)
1099 {
1100 struct device_node *np = pdev->dev.of_node;
1101 struct net_device *netdev;
1102 phy_interface_t phy_mode;
1103 struct resource *res;
1104 struct ipqess *ess;
1105 int i, err = 0;
1106
1107 netdev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct ipqess),
1108 IPQESS_NETDEV_QUEUES,
1109 IPQESS_NETDEV_QUEUES);
1110 if (!netdev)
1111 return -ENOMEM;
1112
1113 ess = netdev_priv(netdev);
1114 ess->netdev = netdev;
1115 ess->pdev = pdev;
1116 spin_lock_init(&ess->stats_lock);
1117 SET_NETDEV_DEV(netdev, &pdev->dev);
1118 platform_set_drvdata(pdev, netdev);
1119
1120 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1121 ess->hw_addr = devm_ioremap_resource(&pdev->dev, res);
1122 if (IS_ERR(ess->hw_addr))
1123 return PTR_ERR(ess->hw_addr);
1124
1125 err = of_get_phy_mode(np, &phy_mode);
1126 if (err) {
1127 dev_err(&pdev->dev, "incorrect phy-mode\n");
1128 return err;
1129 }
1130
1131 ess->ess_clk = devm_clk_get(&pdev->dev, "ess");
1132 if (!IS_ERR(ess->ess_clk))
1133 clk_prepare_enable(ess->ess_clk);
1134
1135 ess->ess_rst = devm_reset_control_get(&pdev->dev, "ess");
1136 if (IS_ERR(ess->ess_rst))
1137 goto err_clk;
1138
1139 ipqess_reset(ess);
1140
1141 ess->phylink_config.dev = &netdev->dev;
1142 ess->phylink_config.type = PHYLINK_NETDEV;
1143 ess->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 |
1144 MAC_100 | MAC_1000FD;
1145
1146 __set_bit(PHY_INTERFACE_MODE_INTERNAL,
1147 ess->phylink_config.supported_interfaces);
1148
1149 ess->phylink = phylink_create(&ess->phylink_config,
1150 of_fwnode_handle(np), phy_mode,
1151 &ipqess_phylink_mac_ops);
1152 if (IS_ERR(ess->phylink)) {
1153 err = PTR_ERR(ess->phylink);
1154 goto err_clk;
1155 }
1156
1157 for (i = 0; i < IPQESS_MAX_TX_QUEUE; i++) {
1158 ess->tx_irq[i] = platform_get_irq(pdev, i);
1159 scnprintf(ess->tx_irq_names[i], sizeof(ess->tx_irq_names[i]),
1160 "%s:txq%d", pdev->name, i);
1161 }
1162
1163 for (i = 0; i < IPQESS_MAX_RX_QUEUE; i++) {
1164 ess->rx_irq[i] = platform_get_irq(pdev, i + IPQESS_MAX_TX_QUEUE);
1165 scnprintf(ess->rx_irq_names[i], sizeof(ess->rx_irq_names[i]),
1166 "%s:rxq%d", pdev->name, i);
1167 }
1168
1169 netdev->netdev_ops = &ipqess_axi_netdev_ops;
1170 netdev->features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |

  1171				   NETIF_F_HW_VLAN_CTAG_RX |
  1172				   NETIF_F_HW_VLAN_CTAG_TX |
  1173				   NETIF_F_TSO | NETIF_F_GRO | NETIF_F_SG;
  1174		/* feature change is not supported yet */
  1175		netdev->hw_features = 0;
  1176		netdev->vlan_features = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_RXCSUM |
  1177					NETIF_F_TSO |
  1178					NETIF_F_GRO;
  1179		netdev->watchdog_timeo = 5 * HZ;
  1180		netdev->base_addr = (u32)ess->hw_addr;
  1181		netdev->max_mtu = 9000;
  1182		netdev->gso_max_segs = IPQESS_TX_RING_SIZE / 2;
  1183	
  1184		ipqess_set_ethtool_ops(netdev);
  1185	
  1186		err = ipqess_hw_init(ess);
  1187		if (err)
  1188			goto err_phylink;
  1189	
  1190		for (i = 0; i < IPQESS_NETDEV_QUEUES; i++) {
> 1191			netif_tx_napi_add(netdev, &ess->tx_ring[i].napi_tx,

1192 ipqess_tx_napi, 64);
1193 netif_napi_add(netdev, &ess->rx_ring[i].napi_rx, ipqess_rx_napi,
1194 64);
1195 }
1196
1197 err = register_netdev(netdev);
1198 if (err)
1199 goto err_hw_stop;
1200
1201 return 0;
1202
1203 err_hw_stop:
1204 ipqess_hw_stop(ess);
1205
1206 ipqess_tx_ring_free(ess);
1207 ipqess_rx_ring_free(ess);
1208 err_phylink:
1209 phylink_destroy(ess->phylink);
1210
1211 err_clk:
1212 clk_disable_unprepare(ess->ess_clk);
1213
1214 return err;
1215 }
1216

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#4 lore raw

PATCH v4 2/5 net: dsa: add out-of-band tagging protocol

In reply to Maxime Chevallier

This tagging protocol is designed for the situation where the link between the MAC and the Switch is designed such that the Destination Port, which is usually embedded in some part of the Ethernet Header, is sent out-of-band, and isn't present at all in the Ethernet frame.

This can happen when the MAC and Switch are tightly integrated on an SoC, as is the case with the Qualcomm IPQ4019 for example, where the DSA tag is inserted directly into the DMA descriptors. In that case, the MAC driver is responsible for sending the tag to the switch using the out-of-band medium. To do so, the MAC driver needs to have the information of the destination port for that skb.

This out-of-band tagging protocol is using the very beggining of the skb headroom to store the tag. The drawback of this approch is that the headroom isn't initialized upon allocating it, therefore we have a chance that the garbage data that lies there at allocation time actually ressembles a valid oob tag. This is only problematic if we are sending/receiving traffic on the master port, which isn't a valid DSA use-case from the beggining. When dealing from traffic to/from a slave port, then the oob tag will be initialized properly by the tagger or the mac driver through the use of the dsa_oob_tag_push() call.

---
V3->V4
- No changes
V3->V2:
- No changes, as the discussion is ongoing
V1->V2:
- Reworked the tagging method, putting the tag at skb->head instead of putting it into skb->shinfo, as per Andrew, Florian and Vlad's reviews

 include/linux/dsa/oob.h | 17 +++++++++
 include/net/dsa.h       |  2 +
 net/dsa/Kconfig         |  7 ++++
 net/dsa/Makefile        |  1 +
 net/dsa/tag_oob.c       | 84 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 111 insertions(+)
 create mode 100644 include/linux/dsa/oob.h
 create mode 100644 net/dsa/tag_oob.c
include/linux/dsa/oob.h new file +17 -0
new file mode 100644
index 000000000000..dbb4a6fb1ce4
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * Copyright (C) 2022 Maxime Chevallier <[email protected]>
+ */
+
+#ifndef _NET_DSA_OOB_H
+#define _NET_DSA_OOB_H
+
+#include <linux/skbuff.h>
+
+struct dsa_oob_tag_info {
+	u16 proto;
+	u16 dp;
+};
+
+int dsa_oob_tag_push(struct sk_buff *skb, struct dsa_oob_tag_info *ti);
+int dsa_oob_tag_pop(struct sk_buff *skb, struct dsa_oob_tag_info *ti);
+#endif
include/net/dsa.h +2 -0
index f2ce12860546..8a63bb65b81b 100644
@@ -55,6 +55,7 @@ struct phylink_link_state;
 #define DSA_TAG_PROTO_RTL8_4T_VALUE		25
 #define DSA_TAG_PROTO_RZN1_A5PSW_VALUE		26
 #define DSA_TAG_PROTO_LAN937X_VALUE		27
+#define DSA_TAG_PROTO_OOB_VALUE			28
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -85,6 +86,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_RTL8_4T		= DSA_TAG_PROTO_RTL8_4T_VALUE,
 	DSA_TAG_PROTO_RZN1_A5PSW	= DSA_TAG_PROTO_RZN1_A5PSW_VALUE,
 	DSA_TAG_PROTO_LAN937X		= DSA_TAG_PROTO_LAN937X_VALUE,
+	DSA_TAG_PROTO_OOB		= DSA_TAG_PROTO_OOB_VALUE,
 };
 
 struct dsa_switch;
net/dsa/Kconfig +7 -0
index 3eef72ce99a4..3e095041dcca 100644
@@ -57,6 +57,13 @@ config NET_DSA_TAG_HELLCREEK
 	  Say Y or M if you want to enable support for tagging frames
 	  for the Hirschmann Hellcreek TSN switches.
 
+config NET_DSA_TAG_OOB
+	tristate "Tag driver for Out-of-band tagging drivers"
+	help
+	  Say Y or M if you want to enable support for tagging out-of-band. In
+	  that case, the MAC driver becomes responsible for sending the tag to
+	  the switch, outside the inband data.
+
 config NET_DSA_TAG_GSWIP
 	tristate "Tag driver for Lantiq / Intel GSWIP switches"
 	help
net/dsa/Makefile +1 -0
index af28c24ead18..729acd0a5511 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o
 obj-$(CONFIG_NET_DSA_TAG_DSA_COMMON) += tag_dsa.o
 obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o
 obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) += tag_hellcreek.o
+obj-$(CONFIG_NET_DSA_TAG_OOB) += tag_oob.o
 obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o
 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
net/dsa/tag_oob.c new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.37.2
#5 lore raw

Re: [PATCH net-next v4 2/5] net: dsa: add out-of-band tagging protocol

Hi Maxime,

Quoted 33 lines · Maxime Chevallier
net/dsa/tag_oob.c new file +33 -0
+int dsa_oob_tag_push(struct sk_buff *skb, struct dsa_oob_tag_info *ti)
+{
+	struct dsa_oob_tag_info *tag_info;
+
+	tag_info = (struct dsa_oob_tag_info *)skb->head;
+
+	tag_info->proto = ti->proto;
+	tag_info->dp = ti->dp;
+
+	return 0;
+}
+EXPORT_SYMBOL(dsa_oob_tag_push);
+
+int dsa_oob_tag_pop(struct sk_buff *skb, struct dsa_oob_tag_info *ti)
+{
+	struct dsa_oob_tag_info *tag_info;
+
+	tag_info = (struct dsa_oob_tag_info *)skb->head;
+
+	if (tag_info->proto != DSA_TAG_PROTO_OOB)
+		return -EINVAL;
+
+	ti->proto = tag_info->proto;
+	ti->dp = tag_info->dp;
+
+	return 0;
+}
+EXPORT_SYMBOL(dsa_oob_tag_pop);
+
+static struct sk_buff *oob_tag_xmit(struct sk_buff *skb,
+				    struct net_device *dev)
+{
+	struct dsa_port *dp = dsa_slave_to_port(dev);

net/dsa/tag_oob.c line 54

Quoted 10 lines
net/dsa/tag_oob.c new file +10 -0
+	struct dsa_oob_tag_info tag_info;
+
+	tag_info.dp = dp->index;
+	tag_info.proto = DSA_TAG_PROTO_OOB;
+
+	if (dsa_oob_tag_push(skb, &tag_info))
+		return NULL;
+
+	return skb;
+}

I don't have too many comments on this patch set, except for a very fundamental one. It is impossible to pass a DSA out of band header between the switch tagging protocol driver and the host Ethernet controller via the beginning of skb->head, and just putting some magic bytes there and hoping that no random junk in the buffer will have the same value (and that skb_push() calls will not eat into your tag_info structure which isn't accounted for in any way by skb->data).

Please create an skb extension for this, it is the only unambiguous way to deal with the given hardware, which will not give lots of headaches in the future.

#6 lore raw

Re: [PATCH net-next v4 2/5] net: dsa: add out-of-band tagging protocol

Hello Vladimir,

Thanks for the comment :)

Quoted 55 lines · On Sat, 17 Sep 2022 00:15:22 +0000 Vladimir Oltean <[email protected]>…

Hi Maxime,

Quoted 33 lines · Maxime Chevallier

+int dsa_oob_tag_push(struct sk_buff *skb, struct dsa_oob_tag_info *ti) +{

net/dsa/tag_oob.c new file +12 -0
+	struct dsa_oob_tag_info *tag_info;
+
+	tag_info = (struct dsa_oob_tag_info *)skb->head;
+
+	tag_info->proto = ti->proto;
+	tag_info->dp = ti->dp;
+
+	return 0;
+}
+EXPORT_SYMBOL(dsa_oob_tag_push);
+
+int dsa_oob_tag_pop(struct sk_buff *skb, struct dsa_oob_tag_info

*ti) +{

net/dsa/tag_oob.c new file +18 -0
+	struct dsa_oob_tag_info *tag_info;
+
+	tag_info = (struct dsa_oob_tag_info *)skb->head;
+
+	if (tag_info->proto != DSA_TAG_PROTO_OOB)
+		return -EINVAL;
+
+	ti->proto = tag_info->proto;
+	ti->dp = tag_info->dp;
+
+	return 0;
+}
+EXPORT_SYMBOL(dsa_oob_tag_pop);
+
+static struct sk_buff *oob_tag_xmit(struct sk_buff *skb,
+				    struct net_device *dev)
+{
+	struct dsa_port *dp = dsa_slave_to_port(dev);

net/dsa/tag_oob.c line 54

Quoted 10 lines
net/dsa/tag_oob.c new file +10 -0
+	struct dsa_oob_tag_info tag_info;
+
+	tag_info.dp = dp->index;
+	tag_info.proto = DSA_TAG_PROTO_OOB;
+
+	if (dsa_oob_tag_push(skb, &tag_info))
+		return NULL;
+
+	return skb;
+}  

I don't have too many comments on this patch set, except for a very fundamental one. It is impossible to pass a DSA out of band header between the switch tagging protocol driver and the host Ethernet controller via the beginning of skb->head, and just putting some magic bytes there and hoping that no random junk in the buffer will have the same value (and that skb_push() calls will not eat into your tag_info structure which isn't accounted for in any way by skb->data).

Quoted 3 lines

Please create an skb extension for this, it is the only unambiguous way to deal with the given hardware, which will not give lots of headaches in the future.

I have no problem with the skb extension approach, my goal from the start was to find the correct way to approach this tagging process. I'll spin a new version with the skb extension approach then, unless someone else sees a problem with using skb extensions ?

Thanks,

Maxime

#7 lore raw

PATCH v4 3/5 net: ipqess: Add out-of-band DSA tagging support

In reply to Maxime Chevallier

On the IPQ4019, there's an 5 ports switch connected to the CPU through the IPQESS Ethernet controller. The way the DSA tag is sent-out to that switch is through the DMA descriptor, due to how tightly it is integrated with the switch.

This commit uses the out-of-band tagging protocol by getting the source port from the descriptor, push it into the skb, and have the tagger pull it to infer the destination netdev. The reverse process is done on the TX side, where the driver pulls the tag from the skb and builds the descriptor accordingly.

---
V3->V4:
- No changes
V2->V3:
- No changes
V1->V2:
- Use the new tagger, and the dsa_oob_tag_* helpers

 drivers/net/ethernet/qualcomm/Kconfig         |  3 +-
 drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 56 ++++++++++++++++++-
 drivers/net/ethernet/qualcomm/ipqess/ipqess.h |  4 ++
 3 files changed, 61 insertions(+), 2 deletions(-)
drivers/net/ethernet/qualcomm/Kconfig +2 -1
index a723ddbea248..eeb2c608d6b9 100644
@@ -62,8 +62,9 @@ config QCOM_EMAC
 
 config QCOM_IPQ4019_ESS_EDMA
 	tristate "Qualcomm Atheros IPQ4019 ESS EDMA support"
-	depends on OF
+	depends on OF && NET_DSA
 	select PHYLINK
+	select NET_DSA_TAG_OOB
 	help
 	  This driver supports the Qualcomm Atheros IPQ40xx built-in
 	  ESS EDMA ethernet controller.
drivers/net/ethernet/qualcomm/ipqess/ipqess.c +55 -1

109 lines not on this page · raw message

drivers/net/ethernet/qualcomm/ipqess/ipqess.h +4 -0
index 9a4ab6ce282a..f21515df3ded 100644
@@ -171,6 +171,10 @@ struct ipqess {
 	struct platform_device *pdev;
 	struct phylink *phylink;
 	struct phylink_config phylink_config;
+
+	struct notifier_block netdev_notifier;
+	bool uses_dsa;
+
 	struct ipqess_tx_ring tx_ring[IPQESS_NETDEV_QUEUES];
 
 	struct ipqess_statistics ipqess_stats;
Signature · 1 line
2.37.2
#8 lore raw

PATCH v4 4/5 net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller

In reply to Maxime Chevallier

Add the DT binding for the IPQESS Ethernet Controller. This is a simple controller, only requiring the phy-mode, interrupts, clocks, and possibly a MAC address setting.

---
V3->V4:
- Fix a binding typo in the compatible string
V2->V3:
- Cleanup on reset and clock names
V1->V2:
- Fixed the example
- Added reset and clocks
- Removed generic ethernet attributes

 .../devicetree/bindings/net/qcom,ipqess.yaml  | 95 +++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ipqess.yaml
Documentation/devicetree/bindings/net/qcom,ipqess.yaml new file +95 -0
new file mode 100644
index 000000000000..3d2f790647cd
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/qcom,ipqess.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm IPQ ESS EDMA Ethernet Controller
+
+maintainers:
+  - Maxime Chevallier <[email protected]>
+
+allOf:
+  - $ref: "ethernet-controller.yaml#"
+
+properties:
+  compatible:
+    const: qcom,ipq4019-ess-edma
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    minItems: 2
+    maxItems: 32
+    description: One interrupt per tx and rx queue, with up to 16 queues.
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - resets
+  - phy-mode
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    gmac: ethernet@c080000 {
+        compatible = "qcom,ipq4019-ess-edma";
+        reg = <0xc080000 0x8000>;
+        resets = <&gcc ESS_RESET>;
+        clocks = <&gcc GCC_ESS_CLK>;
+        interrupts = <GIC_SPI  65 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  66 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  67 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  68 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  69 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  70 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  71 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  72 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  73 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  74 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  75 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  76 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  77 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  78 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  79 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI  80 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 240 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 241 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 242 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 243 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 244 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 245 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 246 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 247 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 248 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 249 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 250 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 251 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 252 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 253 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 254 IRQ_TYPE_EDGE_RISING>,
+                     <GIC_SPI 255 IRQ_TYPE_EDGE_RISING>;
+
+        phy-mode = "internal";
+        fixed-link {
+            speed = <1000>;
+            full-duplex;
+            pause;
+            asym-pause;
+        };
+    };
+
+...
Signature · 1 line
2.37.2
#9 lore raw

Re: [PATCH net-next v4 4/5] net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller

Quoted 25 lines · Maxime Chevallier

Add the DT binding for the IPQESS Ethernet Controller. This is a simple controller, only requiring the phy-mode, interrupts, clocks, and possibly a MAC address setting.

---
V3->V4:
- Fix a binding typo in the compatible string
V2->V3:
- Cleanup on reset and clock names
V1->V2:
- Fixed the example
- Added reset and clocks
- Removed generic ethernet attributes

 .../devicetree/bindings/net/qcom,ipqess.yaml  | 95 +++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ipqess.yaml
Documentation/devicetree/bindings/net/qcom,ipqess.yaml new file +0 -0
new file mode 100644
index 000000000000..3d2f790647cd

Documentation/devicetree/bindings/net/qcom,ipqess.yaml line 4

Quoted 4 lines
Documentation/devicetree/bindings/net/qcom,ipqess.yaml new file +4 -0
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/qcom,ipqess.yaml#

Filename based on the compatible, so qcom,ipq4019-ess-edma.yaml

Apologies for not bringing it up earlier...

Documentation/devicetree/bindings/net/qcom,ipqess.yaml line 13

Quoted 9 lines
Documentation/devicetree/bindings/net/qcom,ipqess.yaml new file +9 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm IPQ ESS EDMA Ethernet Controller
+
+maintainers:
+  - Maxime Chevallier <[email protected]>
+
+allOf:
+  - $ref: "ethernet-controller.yaml#"

Drop quotes.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#10 lore raw

PATCH v4 5/5 ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet controller

In reply to Maxime Chevallier

The Qualcomm IPQ4019 includes an internal 5 ports switch, which is connected to the CPU through the internal IPQESS Ethernet controller.

This commit adds support for this internal interface, which is internally connected to a modified version of the QCA8K Ethernet switch.

This Ethernet controller only support a specific internal interface mode for connection to the switch.

---
V3->V4:
- No Changes
V2->V3:
- No Changes
V1->V2:
- Added clock and resets

 arch/arm/boot/dts/qcom-ipq4019.dtsi | 46 +++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/arm/boot/dts/qcom-ipq4019.dtsi +46 -0
index bb307b8f678c..8cf1c5e6724f 100644
@@ -38,6 +38,7 @@ aliases {
 		spi1 = &blsp1_spi2;
 		i2c0 = &blsp1_i2c3;
 		i2c1 = &blsp1_i2c4;
+		ethernet0 = &gmac;
 	};
 
 	cpus {
@@ -590,6 +591,51 @@ wifi1: wifi@a800000 {
 			status = "disabled";
 		};
 
+		gmac: ethernet@c080000 {
+			compatible = "qcom,ipq4019-ess-edma";
+			reg = <0xc080000 0x8000>;
+			resets = <&gcc ESS_RESET>;
+			reset-names = "ess";
+			clocks = <&gcc GCC_ESS_CLK>;
+			clock-names = "ess";
+			interrupts = <GIC_SPI  65 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  66 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  67 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  68 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  69 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  70 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  71 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  72 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  73 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  74 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  75 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  76 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  77 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  78 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  79 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI  80 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 240 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 241 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 242 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 243 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 244 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 245 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 246 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 247 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 248 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 249 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 250 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 251 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 252 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 253 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 254 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 255 IRQ_TYPE_EDGE_RISING>;
+
+			status = "disabled";
+
+			phy-mode = "internal";
+		};
+
 		mdio: mdio@90000 {
 			#address-cells = <1>;
 			#size-cells = <0>;
Signature · 1 line
2.37.2
Reviewed-by on v4 5/5
#11 lore raw

Re: [PATCH net-next v4 5/5] ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet controller

Quoted 5 lines · Maxime Chevallier

The Qualcomm IPQ4019 includes an internal 5 ports switch, which is connected to the CPU through the internal IPQESS Ethernet controller.

This commit adds support for this internal interface, which is internally connected to a modified version of the QCA8K Ethernet switch.

Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Quoted 5 lines

This Ethernet controller only support a specific internal interface mode for connection to the switch.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#12 lore raw
In reply to Maxime Chevallier
Quoted 3 lines · Maxime Chevallier

The DSA out-of-band tagging is still using the skb->headroom part, but there doesn't seem to be any better way for now without adding fields to struct sk_buff.

Are we on the same page about what is meant by "skb extensions"? See what is provided by CONFIG_SKB_EXTENSIONS, I did not mean it as in "extend struct sk_buff with new fields".

#13 lore raw
Quoted 8 lines · On Sat, 17 Sep 2022 00:20:31 +0000 Vladimir Oltean <[email protected]>…
Quoted 3 lines · Maxime Chevallier

The DSA out-of-band tagging is still using the skb->headroom part, but there doesn't seem to be any better way for now without adding fields to struct sk_buff.

Are we on the same page about what is meant by "skb extensions"? See what is provided by CONFIG_SKB_EXTENSIONS, I did not mean it as in "extend struct sk_buff with new fields".

Yep, that was one of the other approaches I had in mind, and I've submitted a series adding fields to sk_buff in the past which was rejected (for good reasons). But indeed that comment on the cover-letter was misleading...

Thanks,

Maxime