net: ipqess: introduce Qualcomm IPQESS driver
Subsystems (5)
v3 cover net: ipqess: introduce Qualcomm IPQESS driver
Hello everyone,
This is the 3rd iteration of a series that introduces a new driver, for the Qualcomm IPQESS Ethernet Controller, found on the IPQ4019.
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 | 1284 +++++++++++++++++ drivers/net/ethernet/qualcomm/ipqess/ipqess.h | 518 +++++++ .../ethernet/qualcomm/ipqess/ipqess_ethtool.c | 168 +++ 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, 2250 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
PATCH v3 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.
---V2->V3 :
- Cleaned up ioctls and phylink support
- Reworked the napi loop
- cleaned up some macros and warningsV1->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 | 1257 +++++++++++++++++ drivers/net/ethernet/qualcomm/ipqess/ipqess.h | 518 +++++++ .../ethernet/qualcomm/ipqess/ipqess_ethtool.c | 168 +++ 7 files changed, 1970 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
@@ -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
@@ -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
@@ -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
@@ -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 +1257 -0
1,257 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 +168 -0
168 lines not on this page · raw message
Signature · 1 line
2.37.2
kernel test robot
build botRe: [PATCH net-next v3 1/5] net: ipqess: introduce the Qualcomm IPQESS driver
I love your patch! Perhaps something to improve:
Hi Maxime,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Chevallier/net-ipqess-introduce-Qualcomm-IPQESS-driver/20220826-234846 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 44387d1736c40a74085be354e2b5f37ca0689608 config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20220827/[email protected]/config) compiler: s390-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/7a04850338791b6a0d192df5be0e4317e6961fc4
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/20220826-234846 git checkout 7a04850338791b6a0d192df5be0e4317e6961fc4
# 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=s390 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from include/linux/skbuff.h:31,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from include/linux/if_vlan.h:10,
from drivers/net/ethernet/qualcomm/ipqess/ipqess.c:12:
drivers/net/ethernet/qualcomm/ipqess/ipqess.c: In function 'ipqess_rx_buf_prepare':
>> drivers/net/ethernet/qualcomm/ipqess/ipqess.c:180:30: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'dma_addr_t' {aka 'long long unsigned int'} [-Wformat=]
180 | "IPQESS DMA mapping failed for linear address %x",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
include/linux/dev_printk.h:174:17: note: in expansion of macro 'dev_err'
174 | dev_level(dev, fmt, ##__VA_ARGS__); \
| ^~~~~~~~~
include/linux/dev_printk.h:192:9: note: in expansion of macro 'dev_level_once'
192 | dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~
drivers/net/ethernet/qualcomm/ipqess/ipqess.c:179:17: note: in expansion of macro 'dev_err_once'
179 | dev_err_once(rx_ring->ppdev,
| ^~~~~~~~~~~~
drivers/net/ethernet/qualcomm/ipqess/ipqess.c:180:77: note: format string is defined here
180 | "IPQESS DMA mapping failed for linear address %x",
| ~^
| |
| unsigned int
| %llx
drivers/net/ethernet/qualcomm/ipqess/ipqess.c: In function 'ipqess_axi_probe':
>> drivers/net/ethernet/qualcomm/ipqess/ipqess.c:1181:29: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1181 | netdev->base_addr = (u32)ess->hw_addr;
| ^vim +180 drivers/net/ethernet/qualcomm/ipqess/ipqess.c
170
171 static int ipqess_rx_buf_prepare(struct ipqess_buf *buf,
172 struct ipqess_rx_ring *rx_ring)
173 {
174 memset(buf->skb->data, 0, sizeof(struct ipqess_rx_desc));
175
176 buf->dma = dma_map_single(rx_ring->ppdev, buf->skb->data,
177 IPQESS_RX_HEAD_BUFF_SIZE, DMA_FROM_DEVICE);
178 if (dma_mapping_error(rx_ring->ppdev, buf->dma)) {
179 dev_err_once(rx_ring->ppdev,
> 180 "IPQESS DMA mapping failed for linear address %x",
181 buf->dma);
182 dev_kfree_skb_any(buf->skb);
183 buf->skb = NULL;
184 return -EFAULT;
185 }
186
187 buf->length = IPQESS_RX_HEAD_BUFF_SIZE;
188 rx_ring->hw_desc[rx_ring->head] = (struct ipqess_rx_desc *)buf->dma;
189 rx_ring->head = (rx_ring->head + 1) % IPQESS_RX_RING_SIZE;
190
191 ipqess_m32(rx_ring->ess, IPQESS_RFD_PROD_IDX_BITS,
192 (rx_ring->head + IPQESS_RX_RING_SIZE - 1) % IPQESS_RX_RING_SIZE,
193 IPQESS_REG_RFD_IDX_Q(rx_ring->idx));
194
195 return 0;
196 }
197
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botRe: [PATCH net-next v3 1/5] net: ipqess: introduce the Qualcomm IPQESS driver
In reply to Maxime ChevallierI love your patch! Perhaps something to improve:
Hi Maxime,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Chevallier/net-ipqess-introduce-Qualcomm-IPQESS-driver/20220826-234846 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 44387d1736c40a74085be354e2b5f37ca0689608 config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220827/[email protected]/config) compiler: arceb-elf-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/7a04850338791b6a0d192df5be0e4317e6961fc4
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/20220826-234846
git checkout 7a04850338791b6a0d192df5be0e4317e6961fc4
# 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=arc SHELL=/bin/bash drivers/net/ethernet/qualcomm/ipqess/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from include/linux/skbuff.h:31,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from include/linux/if_vlan.h:10,
from drivers/net/ethernet/qualcomm/ipqess/ipqess.c:12:
drivers/net/ethernet/qualcomm/ipqess/ipqess.c: In function 'ipqess_rx_buf_prepare':
drivers/net/ethernet/qualcomm/ipqess/ipqess.c:180:30: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'dma_addr_t' {aka 'long long unsigned int'} [-Wformat=]
180 | "IPQESS DMA mapping failed for linear address %x",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
include/linux/dev_printk.h:174:17: note: in expansion of macro 'dev_err'
174 | dev_level(dev, fmt, ##__VA_ARGS__); \
| ^~~~~~~~~
include/linux/dev_printk.h:192:9: note: in expansion of macro 'dev_level_once'
192 | dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~
drivers/net/ethernet/qualcomm/ipqess/ipqess.c:179:17: note: in expansion of macro 'dev_err_once'
179 | dev_err_once(rx_ring->ppdev,
| ^~~~~~~~~~~~
drivers/net/ethernet/qualcomm/ipqess/ipqess.c:180:77: note: format string is defined here
180 | "IPQESS DMA mapping failed for linear address %x",
| ~^
| |
| unsigned int
| %llx
>> drivers/net/ethernet/qualcomm/ipqess/ipqess.c:188:43: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
188 | rx_ring->hw_desc[rx_ring->head] = (struct ipqess_rx_desc *)buf->dma;
| ^vim +188 drivers/net/ethernet/qualcomm/ipqess/ipqess.c
170
171 static int ipqess_rx_buf_prepare(struct ipqess_buf *buf,
172 struct ipqess_rx_ring *rx_ring)
173 {
174 memset(buf->skb->data, 0, sizeof(struct ipqess_rx_desc));
175
176 buf->dma = dma_map_single(rx_ring->ppdev, buf->skb->data,
177 IPQESS_RX_HEAD_BUFF_SIZE, DMA_FROM_DEVICE);
178 if (dma_mapping_error(rx_ring->ppdev, buf->dma)) {
179 dev_err_once(rx_ring->ppdev,
180 "IPQESS DMA mapping failed for linear address %x",
181 buf->dma);
182 dev_kfree_skb_any(buf->skb);
183 buf->skb = NULL;
184 return -EFAULT;
185 }
186
187 buf->length = IPQESS_RX_HEAD_BUFF_SIZE;
> 188 rx_ring->hw_desc[rx_ring->head] = (struct ipqess_rx_desc *)buf->dma;
189 rx_ring->head = (rx_ring->head + 1) % IPQESS_RX_RING_SIZE;
190
191 ipqess_m32(rx_ring->ess, IPQESS_RFD_PROD_IDX_BITS,
192 (rx_ring->head + IPQESS_RX_RING_SIZE - 1) % IPQESS_RX_RING_SIZE,
193 IPQESS_REG_RFD_IDX_Q(rx_ring->idx));
194
195 return 0;
196 }
197
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Andrew Lunn
maintainerRe: [PATCH net-next v3 1/5] net: ipqess: introduce the Qualcomm IPQESS driver
In reply to Maxime Chevallierdrivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c line 97
Quoted 12 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +12
-0+static void ipqess_get_strings (struct net_device *netdev,u32 stringset, +u8 *data) +{ +u8 *p = data; +u32 i; + +switch (stringset) { +case ETH_SS_STATS : +for (i =0 ; i <ARRAY_SIZE (ipqess_stats); i++) { +memcpy (p, ipqess_stats[i].string, +min ((size_t )ETH_GSTRING_LEN , +strlen (ipqess_stats[i].string) +1 ));
That looks pretty similar to strlcpy().
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c line 130
Quoted 2 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +2
-0+static int ipqess_get_settings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd)
It would be traditional to have the k in the name.
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c line 139
Quoted 9 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +9
-0+{ +struct ipqess *ess =netdev_priv (netdev); + +return phylink_ethtool_ksettings_get (ess->phylink, cmd); +} + +static int ipqess_set_settings (struct net_device *netdev, +const struct ethtool_link_ksettings *cmd) +{
Here too.
Andrew
Re: [PATCH net-next v3 1/5] net: ipqess: introduce the Qualcomm IPQESS driver
Hello Andrew, and thanks for the review
Quoted 8 lines · On Sat, 27 Aug 2022 21:28:21 +0200 Andrew Lunn <[email protected]> wrote:
Quoted 8 lines
+static void ipqess_get_strings(struct
net_device*netdev, u32 stringset,drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +6
-0+ u8 *data) +{ +u8 *p = data; +u32 i; + +switch (stringset) {
Quoted 8 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c
Quoted 6 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +6
-0+case ETH_SS_STATS : +for (i =0 ; i <ARRAY_SIZE (ipqess_stats); i++) { +memcpy (p, ipqess_stats[i].string, +min ((size_t )ETH_GSTRING_LEN , +strlen (ipqess_stats[i].string) + 1));That looks pretty similar to
strlcpy().
Indeed... and after digging I even found ethtool_sprintf() which seems to fit even better :)
Quoted 6 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c line 130
Quoted 3 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +2
-0+static int ipqess_get_settings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd)It would be traditional to have the k in the name.
Quoted 11 lines
Quoted 9 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c new file +8
-0+{ +struct ipqess *ess =netdev_priv (netdev); + +return phylink_ethtool_ksettings_get (ess->phylink, cmd); +} + +static int ipqess_set_settings (struct net_device *netdev, + const struct ethtool_link_ksettings*cmd) +{
Here too.
Agreed, I'll address that. Thanks !
Maxime
Quoted 1 line
Andrew
PATCH v3 2/5 net: dsa: add out-of-band tagging protocol
In reply to Maxime ChevallierThis 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->V2:
- No changes, as the discussion is ongoingV1->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
@@ -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
@@ -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 28enum 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
@@ -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
@@ -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
Andrew Lunn
maintainerRe: [PATCH net-next v3 2/5] net: dsa: add out-of-band tagging protocol
Quoted 5 lines
net/dsa/Kconfig +0
-0
net/dsa/Kconfig config NET_DSA_TAG_HELLCREEK · line 66
Quoted 10 lines
net/dsa/Kconfig +7
-0@@ -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. +
This file is sorted by the tristate text. So this new entry should come after NET_DSA_TAG_OCELOT_8021Q
net/dsa/Kconfig obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o · line 15
Quoted 8 lines
net/dsa/Kconfig +1
-0@@ -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
And this should also be after NET_DSA_TAG_OCELOT_8021Q.
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next v3 2/5] net: dsa: add out-of-band tagging protocol
In reply to Maxime ChevallierQuoted 5 lines
net/dsa/tag_oob.c new file +4
-0+struct dsa_oob_tag_info { +u16 proto; +u16 dp; +};
net/dsa/tag_oob.c line 19
Quoted 10 lines
net/dsa/tag_oob.c new file +10
-0+#define DSA_OOB_TAG_LEN 4 + +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;
Do you need to be worried about alignment here? Is skb->head guaranteed to be at least 16 bit aligned? I think you would be safer to use get_unaligned_le16(val, tag);
Andrew
PATCH v3 3/5 net: ipqess: Add out-of-band DSA tagging support
In reply to Maxime ChevallierOn 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.
---V2->V3:
- No changesV1->V2:
- Use the new tagger, and the dsa_oob_tag_* helpers
drivers/net/ethernet/qualcomm/Kconfig | 3 ++- drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
drivers/net/ethernet/qualcomm/Kconfig +2 -1
@@ -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 +27 -0
@@ -9,6 +9,7 @@#include <linux/bitfield.h> #include <linux/clk.h> +#include <linux/dsa/oob.h> #include <linux/if_vlan.h> #include <linux/interrupt.h> #include <linux/module.h>
@@ -22,6 +23,7 @@#include <linux/skbuff.h> #include <linux/vmalloc.h> #include <net/checksum.h> +#include <net/dsa.h> #include <net/ip6_checksum.h> #include "ipqess.h"
@@ -330,6 +332,7 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget) tail &=IPQESS_RFD_CONS_IDX_MASK ;while (done < budget) { +struct dsa_oob_tag_info tag_info;struct ipqess_rx_desc *rd;struct sk_buff *skb;
@@ -409,6 +412,12 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021AD ), rd->rrd4); +if (netdev_uses_dsa (rx_ring->ess->netdev)) { + tag_info.dp =FIELD_GET (IPQESS_RRD_PORT_ID_MASK , rd->rrd1); + tag_info.proto =DSA_TAG_PROTO_OOB ; +dsa_oob_tag_push (skb, &tag_info); + } +napi_gro_receive (&rx_ring->napi_rx, skb); rx_ring->ess->stats.rx_packets++;
@@ -713,6 +722,22 @@ static void ipqess_rollback_tx(struct ipqess *eth, tx_ring->head = start_index; } +static void ipqess_process_dsa_tag_sh (struct ipqess *ess,struct sk_buff *skb, +u32 *word3) +{ +struct dsa_oob_tag_info tag_info; + +if (!netdev_uses_dsa (ess->netdev)) +return ; + +if (dsa_oob_tag_pop (skb, &tag_info)) +return ; + + *word3 |= tag_info.dp <<IPQESS_TPD_PORT_BITMAP_SHIFT ; + *word3 |=BIT (IPQESS_TPD_FROM_CPU_SHIFT ); + *word3 |=0x3e <<IPQESS_TPD_PORT_BITMAP_SHIFT ; +} +static int ipqess_tx_map_and_fill (struct ipqess_tx_ring *tx_ring,struct sk_buff *skb) {
@@ -723,6 +748,8 @@ static int ipqess_tx_map_and_fill(struct ipqess_tx_ring *tx_ring,u16 len;int i; +ipqess_process_dsa_tag_sh (tx_ring->ess, skb, &word3); +if (skb_is_gso (skb)) {if (skb_shinfo (skb)->gso_type &SKB_GSO_TCPV4 ) { lso_word1 |=IPQESS_TPD_IPV4_EN ;
Signature · 1 line
2.37.2
Andrew Lunn
maintainerRe: [PATCH net-next v3 3/5] net: ipqess: Add out-of-band DSA tagging support
Quoted 22 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c +11
-0@@ -409,6 +412,12 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021AD ), rd->rrd4); +if (netdev_uses_dsa (rx_ring->ess->netdev)) { + tag_info.dp =FIELD_GET (IPQESS_RRD_PORT_ID_MASK , rd->rrd1); + tag_info.proto =DSA_TAG_PROTO_OOB ; +dsa_oob_tag_push (skb, &tag_info); + } +napi_gro_receive (&rx_ring->napi_rx, skb); rx_ring->ess->stats.rx_packets++;@@ -713,6 +722,22 @@ static void ipqess_rollback_tx(struct ipqess *eth, tx_ring->head = start_index; } +static void ipqess_process_dsa_tag_sh (struct ipqess *ess,struct sk_buff *skb, +u32 *word3) +{ +struct dsa_oob_tag_info tag_info; +
drivers/net/ethernet/qualcomm/ipqess/ipqess.c static void ipqess_rollback_tx(struct ipqess *eth, · line 739
Quoted 10 lines
drivers/net/ethernet/qualcomm/ipqess/ipqess.c +10
-0+if (!netdev_uses_dsa (ess->netdev)) +return ; + +if (dsa_oob_tag_pop (skb, &tag_info)) +return ; + + *word3 |= tag_info.dp <<IPQESS_TPD_PORT_BITMAP_SHIFT ; + *word3 |=BIT (IPQESS_TPD_FROM_CPU_SHIFT ); + *word3 |=0x3e <<IPQESS_TPD_PORT_BITMAP_SHIFT ; +}
Using netdev_uses_dsa() here will work, but you are on the fast path. You are following a lot of pointers, which could be bad on the cache. You might want to consider caching this as a bool in struct ipqess. Maybe update the cache on NETDEV_CHANGEUPPER?
Andrew
PATCH v3 4/5 net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller
In reply to Maxime ChevallierAdd 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.
---V2->V3:
- Cleanup on reset and clock namesV1->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
@@ -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,ipq4019e-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
Rob Herring
maintainerRe: [PATCH net-next v3 4/5] net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller
Quoted 13 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.
Signed-off-by Maxime Chevallier <[email protected]>---
V2->V3:
- Cleanup on reset and clock namesV1->V2:
- Fixed the example
- Added reset and clocks
- Removed generic ethernet attributes
Quoted 4 lines
.../devicetree/bindings/net/qcom,ipqess.yaml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,ipqess.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:Documentation/devicetree/bindings/net/qcom,ipqess.example.dtb:0:0: /example-0/ethernet@c080000: failed to match any schema with compatible: ['qcom,ipq4019-ess-edma']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v3 5/5 ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet controller
In reply to Maxime ChevallierThe 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.
---V2->V3:
- No ChangesV1->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
@@ -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