Hello everyone,
This is the 8th iteration on the IPQESS driver, that includes a new
DSA tagger to let the MAC convey the tag to the switch through an
out-of-band medium, here using DMA descriptors.
Notables changes on v8 :
- Added fixed-link in the dtsi SoC file
- Removed the ethernet0 alias from the dtsi
- Added a missing blank line in tagger driver
Notables changes on V7 :
- Fixed sparse warnings
- Fixed a typo in the bindings
- Added missing maintainers in CC
Notables changes on V6 :
- Cleanup unused helpers and fields in the tagger
- Cleanup ordering in various files
- Added more documentation on the tagger
- Fixed the CHANGEUPPER caching
- Cleanups in the IPQESS driver
Notables changes on V5 :
- Fix caching of CHANGEUPPER events
- Use a skb extension-based tagger
- Rename the binding file
- Some cleanups in the ipqess driver itself
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
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 skb extensions
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
Maxime Chevallier (5):
net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller
net: ipqess: introduce the Qualcomm IPQESS driver
net: dsa: add out-of-band tagging protocol
net: ipqess: Add out-of-band DSA tagging support
ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet
controller
.../bindings/net/qcom,ipq4019-ess-edma.yaml | 94 ++
Documentation/networking/dsa/dsa.rst | 13 +-
MAINTAINERS | 8 +
arch/arm/boot/dts/qcom-ipq4019.dtsi | 48 +
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 | 1308 +++++++++++++++++
drivers/net/ethernet/qualcomm/ipqess/ipqess.h | 522 +++++++
.../ethernet/qualcomm/ipqess/ipqess_ethtool.c | 164 +++
include/linux/dsa/oob.h | 16 +
include/linux/skbuff.h | 3 +
include/net/dsa.h | 2 +
net/core/skbuff.c | 10 +
net/dsa/Kconfig | 9 +
net/dsa/Makefile | 1 +
net/dsa/tag_oob.c | 49 +
17 files changed, 2268 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/qcom,ipq4019-ess-edma.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
--
2.37.3
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.
We use the out-of-band tagging protocol by getting the source
port from the descriptor, push it into the skb extensions, 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.
Signed-off-by: Maxime Chevallier <[email protected]>
---
V7->V8:
- No changes
V6->V7:
- Added proper endianness conversion for descriptor accesses
V5->V6:
- Fixed the CHANGEUPPER event handling
- removed pop/push helpers
V4->V5:
- Rework the CHANGEUPPER event handling
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 | 1 +
drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 64 ++++++++++++++++++-
drivers/net/ethernet/qualcomm/ipqess/ipqess.h | 4 ++
3 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index 28861bca5a5b..7eda94131cb1 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -64,6 +64,7 @@ config QCOM_IPQ4019_ESS_EDMA
tristate "Qualcomm Atheros IPQ4019 ESS EDMA support"
depends on (OF && ARCH_QCOM) || COMPILE_TEST
select PHYLINK
+ select NET_DSA_TAG_OOB
help
This driver supports the Qualcomm Atheros IPQ40xx built-in
ESS EDMA ethernet controller.
diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
index df3f2ce77065..a2385d6407b3 100644
--- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
+++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
@@ -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"
@@ -327,6 +329,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;
@@ -406,6 +409,12 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021AD),
le16_to_cpu(rd->rrd4));
+ if (likely(rx_ring->ess->dsa_ports)) {
+ tag_info = skb_ext_add(skb, SKB_EXT_DSA_OOB);
+ tag_info->port = FIELD_GET(IPQESS_RRD_PORT_ID_MASK,
+ le16_to_cpu(rd->rrd1));
+ }
+
napi_gro_receive(&rx_ring->napi_rx, skb);
rx_ring->ess->stats.rx_packets++;
@@ -706,6 +715,23 @@ 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 (unlikely(!ess->dsa_ports))
+ return;
+
+ tag_info = skb_ext_find(skb, SKB_EXT_DSA_OOB);
+ if (!tag_info)
+ return;
+
+ *word3 |= tag_info->port << 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)
{
@@ -716,6 +742,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;
@@ -917,6 +945,33 @@ static const struct net_device_ops ipqess_axi_netdev_ops = {
.ndo_tx_timeout = ipqess_tx_timeout,
};
+static int ipqess_netdevice_event(struct notifier_block *nb,
+ unsigned long event, void *ptr)
+{
+ struct ipqess *ess = container_of(nb, struct ipqess, netdev_notifier);
+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+ struct netdev_notifier_changeupper_info *info;
+
+ if (dev != ess->netdev)
+ return NOTIFY_DONE;
+
+ switch (event) {
+ case NETDEV_CHANGEUPPER:
+ info = ptr;
+
+ if (!dsa_slave_dev_check(info->upper_dev))
+ return NOTIFY_DONE;
+
+ if (info->linking)
+ ess->dsa_ports++;
+ else
+ ess->dsa_ports--;
+
+ return NOTIFY_DONE;
+ }
+ return NOTIFY_OK;
+}
+
static void ipqess_hw_stop(struct ipqess *ess)
{
int i;
@@ -1184,12 +1239,19 @@ static int ipqess_axi_probe(struct platform_device *pdev)
netif_napi_add(netdev, &ess->rx_ring[i].napi_rx, ipqess_rx_napi);
}
- err = register_netdev(netdev);
+ ess->netdev_notifier.notifier_call = ipqess_netdevice_event;
+ err = register_netdevice_notifier(&ess->netdev_notifier);
if (err)
goto err_hw_stop;
+ err = register_netdev(netdev);
+ if (err)
+ goto err_notifier_unregister;
+
return 0;
+err_notifier_unregister:
+ unregister_netdevice_notifier(&ess->netdev_notifier);
err_hw_stop:
ipqess_hw_stop(ess);
diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
index dae17f3a23e4..5999a3b26235 100644
--- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
+++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
@@ -171,6 +171,10 @@ struct ipqess {
struct platform_device *pdev;
struct phylink *phylink;
struct phylink_config phylink_config;
+
+ struct notifier_block netdev_notifier;
+ int dsa_ports;
+
struct ipqess_tx_ring tx_ring[IPQESS_NETDEV_QUEUES];
struct ipqess_statistics ipqess_stats;
--
2.37.3