Skip to contentSkip to conversation

tsnep: multi queue support and some other improvements

PATCH Superseded Gerhard Engleder 2 participants 16 messages Sep 23, 2022 – Sep 28, 2022

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover tsnep: multi queue support and some other improvements

Add support for additional TX/RX queues along with RX flow classification support.

Binding is extended to allow additional interrupts for additional TX/RX queues. Also dma-coherent is allowed as minor improvement.

RX path optimisation is done by using page pool as preparations for future XDP support.

v3:
- now with changes in cover letter

v2:
- use netdev_name() (Jakub Kicinski)
- use ENOENT if RX flow rule is not found (Jakub Kicinski)
- eliminate return code of tsnep_add_rule() (Jakub Kicinski)
- remove commit with lazy refill due to depletion problem (Jakub Kicinski)

Gerhard Engleder (6):
dt-bindings: net: tsnep: Allow dma-coherent
dt-bindings: net: tsnep: Allow additional interrupts
tsnep: Move interrupt from device to queue
tsnep: Support multiple TX/RX queue pairs
tsnep: Add EtherType RX flow classification support
tsnep: Use page pool for RX

 .../bindings/net/engleder,tsnep.yaml          |  39 +-
 drivers/net/ethernet/engleder/Kconfig         |   1 +
 drivers/net/ethernet/engleder/Makefile        |   2 +-
 drivers/net/ethernet/engleder/tsnep.h         |  47 ++-
 drivers/net/ethernet/engleder/tsnep_ethtool.c |  38 ++
 drivers/net/ethernet/engleder/tsnep_hw.h      |  13 +-
 drivers/net/ethernet/engleder/tsnep_main.c    | 356 +++++++++++++-----
 drivers/net/ethernet/engleder/tsnep_rxnfc.c   | 281 ++++++++++++++
 8 files changed, 662 insertions(+), 115 deletions(-)
 create mode 100644 drivers/net/ethernet/engleder/tsnep_rxnfc.c
Signature · 1 line
2.30.2
#1 lore raw

PATCH v3 1/6 dt-bindings: net: tsnep: Allow dma-coherent

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+' From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

---
 Documentation/devicetree/bindings/net/engleder,tsnep.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +2 -0
index d0e1476e15b5..37e08ee744a8 100644
@@ -22,6 +22,8 @@ properties:
   interrupts:
     maxItems: 1
 
+  dma-coherent: true
+
   local-mac-address: true
 
   mac-address: true
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+' From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

Quoted 2 lines

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

I will skip that line.

The binding is for an FPGA based Ethernet MAC. I'm working with an evaluation platform currently. The DTS for the evaluation platform is mainline, but my derived DTS was not accepted mainline. So there is no DTS. This is similar for other FPGA based devices.

Quoted 4 lines
Quoted 2 lines

Best regards,
Krzysztof

Thanks!

Gerhard

#4 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 11 lines · Gerhard Engleder
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

Quoted 6 lines

I will skip that line.

The binding is for an FPGA based Ethernet MAC. I'm working with an evaluation platform currently. The DTS for the evaluation platform is mainline, but my derived DTS was not accepted mainline. So there is no DTS. This is similar for other FPGA based devices.

If this is not coming from mainline, then there is no warning... we are not interested in warnings in out-of-tree code, because we are not fixing them.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 14 lines · Krzysztof Kozlowski
Quoted 13 lines · Gerhard Engleder
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

I will skip that line.

Quoted 8 lines
Quoted 4 lines

The binding is for an FPGA based Ethernet MAC. I'm working with an evaluation platform currently. The DTS for the evaluation platform is mainline, but my derived DTS was not accepted mainline. So there is no DTS. This is similar for other FPGA based devices.

If this is not coming from mainline, then there is no warning... we are not interested in warnings in out-of-tree code, because we are not fixing them.

Ok. So I would rewrite the description that it just allows dma-coherent and remove the fix/warning stuff. Is that ok?

Thanks!

Gerhard

#6 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 20 lines · Gerhard Engleder
Quoted 19 lines · Krzysztof Kozlowski
Quoted 17 lines · Gerhard Engleder
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

I will skip that line.

The binding is for an FPGA based Ethernet MAC. I'm working with an evaluation platform currently. The DTS for the evaluation platform is mainline, but my derived DTS was not accepted mainline. So there is no DTS. This is similar for other FPGA based devices.

Quoted 6 lines
Quoted 3 lines

If this is not coming from mainline, then there is no warning... we are not interested in warnings in out-of-tree code, because we are not fixing them.

Ok. So I would rewrite the description that it just allows dma-coherent and remove the fix/warning stuff. Is that ok?

That would be okay, but please add answer to why you are making this change.

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 21 lines · Krzysztof Kozlowski
Quoted 20 lines · Gerhard Engleder
Quoted 19 lines · Krzysztof Kozlowski
Quoted 17 lines · Gerhard Engleder
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Gerhard Engleder

Fix the following dtbs_check error if dma-coherent is used:

...: 'dma-coherent' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: .../Documentation/devicetree/bindings/net/engleder,tsnep.yaml

Skip last line - it's obvious. What instead you miss here - the DTS/target which has this warning. I assume that some existing DTS uses this property?

I will skip that line.

The binding is for an FPGA based Ethernet MAC. I'm working with an evaluation platform currently. The DTS for the evaluation platform is mainline, but my derived DTS was not accepted mainline. So there is no DTS. This is similar for other FPGA based devices.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

If this is not coming from mainline, then there is no warning... we are not interested in warnings in out-of-tree code, because we are not fixing them.

Ok. So I would rewrite the description that it just allows dma-coherent and remove the fix/warning stuff. Is that ok?

That would be okay, but please add answer to why you are making this change.

I already prepared it:

Within SoCs like ZynqMP, FPGA logic can be connected to different kinds of AXI master ports. Also cache coherent AXI master ports are available. The property "dma-coherent" is used to signal that DMA is cache coherent.
Add "dma-coherent" property to allow the configuration of cache coherent DMA.

Thanks!

Gerhard

#8 lore raw

Re: [PATCH net-next v3 1/6] dt-bindings: net: tsnep: Allow dma-coherent

Quoted 11 lines · Gerhard Engleder
Quoted 1 line

That would be okay, but please add answer to why you are making this change.

I already prepared it:

Within SoCs like ZynqMP, FPGA logic can be connected to different kinds of AXI master ports. Also cache coherent AXI master ports are available. The property "dma-coherent" is used to signal that DMA is cache coherent.
Add "dma-coherent" property to allow the configuration of cache coherent DMA.

Sounds good, thanks.

Best regards,
Krzysztof

#9 lore raw

PATCH v3 2/6 dt-bindings: net: tsnep: Allow additional interrupts

In reply to Gerhard Engleder

Additional TX/RX queue pairs require dedicated interrupts. Extend binding with additional interrupts.

---
 .../bindings/net/engleder,tsnep.yaml          | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +36 -1
index 37e08ee744a8..ce1f1bd413c2 100644
@@ -20,7 +20,23 @@ properties:
     maxItems: 1
 
   interrupts:
-    maxItems: 1
+    minItems: 1
+    maxItems: 8
+
+  interrupt-names:
+    minItems: 1
+    maxItems: 8
+    items:
+      pattern: '^mac|txrx-[1-7]$'
+    description:
+      If more than one interrupt is available, then interrupts are
+      identified by their names.
+      "mac" is the main interrupt for basic MAC features and the first
+      TX/RX queue pair. If only a single interrupt is available, then
+      it is assumed that this interrupt is the "mac" interrupt.
+      "txrx-[1-7]" are the interrupts for additional TX/RX queue pairs.
+      These interrupt names shall start with index 1 and increment the
+      index by 1 with every further TX/RX queue pair.
 
   dma-coherent: true
 
@@ -78,4 +94,23 @@ examples:
                 };
             };
         };
+        tnsep1: ethernet@a0010000 {
+            compatible = "engleder,tsnep";
+            reg = <0x0 0xa0010000 0x0 0x10000>;
+            interrupts = <0 93 1>, <0 94 1>, <0 95 1>, <0 96 1>;
+            interrupt-names = "mac", "txrx-1", "txrx-2", "txrx-3";
+            interrupt-parent = <&gic>;
+            local-mac-address = [00 00 00 00 00 00];
+            phy-mode = "rgmii";
+            phy-handle = <&phy1>;
+            mdio {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                suppress-preamble;
+                phy1: ethernet-phy@1 {
+                    reg = <1>;
+                    rxc-skew-ps = <1080>;
+                };
+            };
+        };
     };
Signature · 1 line
2.30.2
#10 lore raw

Re: [PATCH net-next v3 2/6] dt-bindings: net: tsnep: Allow additional interrupts

Quoted 15 lines · Gerhard Engleder

Additional TX/RX queue pairs require dedicated interrupts. Extend binding with additional interrupts.

---
 .../bindings/net/engleder,tsnep.yaml          | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +0 -0
index 37e08ee744a8..ce1f1bd413c2 100644
@@ -20,7 +20,23 @@ properties:
     maxItems: 1
 

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 30

Quoted 10 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +8 -1
   interrupts:
-    maxItems: 1
+    minItems: 1
+    maxItems: 8
+
+  interrupt-names:
+    minItems: 1
+    maxItems: 8
+    items:
+      pattern: '^mac|txrx-[1-7]$'

No. The order of items must be fixed. Now you allow any combination, which is exactly what we do not want.

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 33

Quoted 3 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +3 -0
+    description:
+      If more than one interrupt is available, then interrupts are
+      identified by their names.

Not really. Interrupts are fixed, unless explicitly mentioned otherwise.

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 39

Quoted 6 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +6 -0
+      "mac" is the main interrupt for basic MAC features and the first
+      TX/RX queue pair. If only a single interrupt is available, then
+      it is assumed that this interrupt is the "mac" interrupt.
+      "txrx-[1-7]" are the interrupts for additional TX/RX queue pairs.
+      These interrupt names shall start with index 1 and increment the
+      index by 1 with every further TX/RX queue pair.

Skip last three sentences - they will become redundant after implementing proper items.

Documentation/devicetree/bindings/net/engleder,tsnep.yaml examples: · line 96

Quoted 7 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +0 -0
   dma-coherent: true
 
@@ -78,4 +94,23 @@ examples:
                 };
             };
         };

Missing line break.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH net-next v3 2/6] dt-bindings: net: tsnep: Allow additional interrupts

Quoted 16 lines · Krzysztof Kozlowski
Quoted 15 lines · Gerhard Engleder

Additional TX/RX queue pairs require dedicated interrupts. Extend binding with additional interrupts.

---
  .../bindings/net/engleder,tsnep.yaml          | 37 ++++++++++++++++++-
  1 file changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +0 -0
index 37e08ee744a8..ce1f1bd413c2 100644
@@ -20,7 +20,23 @@ properties:
      maxItems: 1
 
Quoted 13 lines

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 30

Quoted 10 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +8 -1
    interrupts:
-    maxItems: 1
+    minItems: 1
+    maxItems: 8
+
+  interrupt-names:
+    minItems: 1
+    maxItems: 8
+    items:
+      pattern: '^mac|txrx-[1-7]$'

No. The order of items must be fixed. Now you allow any combination, which is exactly what we do not want.

Ok. I will do it like in https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml#L58

Quoted 13 lines

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 33

Quoted 3 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +3 -0
+    description:
+      If more than one interrupt is available, then interrupts are
+      identified by their names.

Not really. Interrupts are fixed, unless explicitly mentioned otherwise.

Documentation/devicetree/bindings/net/engleder,tsnep.yaml properties: · line 39

Quoted 6 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +6 -0
+      "mac" is the main interrupt for basic MAC features and the first
+      TX/RX queue pair. If only a single interrupt is available, then
+      it is assumed that this interrupt is the "mac" interrupt.
+      "txrx-[1-7]" are the interrupts for additional TX/RX queue pairs.
+      These interrupt names shall start with index 1 and increment the
+      index by 1 with every further TX/RX queue pair.
Quoted 2 lines

Skip last three sentences - they will become redundant after implementing proper items.

I will rework description for fixed order.

Quoted 9 lines

Documentation/devicetree/bindings/net/engleder,tsnep.yaml examples: · line 96

Quoted 7 lines
Documentation/devicetree/bindings/net/engleder,tsnep.yaml +0 -0
    dma-coherent: true
 
@@ -78,4 +94,23 @@ examples:
                  };
              };
          };

Missing line break.

I will add it.

Quoted 2 lines

Best regards,
Krzysztof

Thanks!

Gerhard

#12 lore raw

PATCH v3 3/6 tsnep: Move interrupt from device to queue

In reply to Gerhard Engleder

For multiple queues multiple interrupts shall be used. Therefore, rework global interrupt to per queue interrupt.

Every interrupt name shall contain interface name and queue information. To get a valid interface name, the interrupt request needs to by done during open like in other drivers. Additionally, this allows the removal of some initialisation checks in the interrupt handler.

---
 drivers/net/ethernet/engleder/tsnep.h      |   4 +-
 drivers/net/ethernet/engleder/tsnep_main.c | 128 +++++++++++++++------
 2 files changed, 99 insertions(+), 33 deletions(-)
drivers/net/ethernet/engleder/tsnep.h +3 -1
index 147fe03ca979..149c9acbae9c 100644
@@ -55,6 +55,7 @@ struct tsnep_tx_entry {
 struct tsnep_tx {
 	struct tsnep_adapter *adapter;
 	void __iomem *addr;
+	int queue_index;
 
 	void *page[TSNEP_RING_PAGE_COUNT];
 	dma_addr_t page_dma[TSNEP_RING_PAGE_COUNT];
@@ -105,12 +106,14 @@ struct tsnep_rx {
 
 struct tsnep_queue {
 	struct tsnep_adapter *adapter;
+	char name[IFNAMSIZ + 9];
 
 	struct tsnep_tx *tx;
 	struct tsnep_rx *rx;
 
 	struct napi_struct napi;
 
+	int irq;
 	u32 irq_mask;
 };
 
@@ -126,7 +129,6 @@ struct tsnep_adapter {
 	struct platform_device *pdev;
 	struct device *dmadev;
 	void __iomem *addr;
-	int irq;
 
 	bool gate_control;
 	/* gate control lock */
drivers/net/ethernet/engleder/tsnep_main.c +96 -32

245 lines not on this page · raw message

Signature · 1 line
2.30.2
#13 lore raw

PATCH v3 4/6 tsnep: Support multiple TX/RX queue pairs

In reply to Gerhard Engleder

Support additional TX/RX queue pairs if dedicated interrupt is available. Interrupts are detected by name in device tree.

---
 drivers/net/ethernet/engleder/tsnep.h      |  2 -
 drivers/net/ethernet/engleder/tsnep_hw.h   |  1 +
 drivers/net/ethernet/engleder/tsnep_main.c | 61 ++++++++++++++++++----
 3 files changed, 53 insertions(+), 11 deletions(-)
drivers/net/ethernet/engleder/tsnep.h +0 -2
index 149c9acbae9c..62a279bcb011 100644
@@ -21,8 +21,6 @@
 #define TSNEP_RING_ENTRIES_PER_PAGE (PAGE_SIZE / TSNEP_DESC_SIZE)
 #define TSNEP_RING_PAGE_COUNT (TSNEP_RING_SIZE / TSNEP_RING_ENTRIES_PER_PAGE)
 
-#define TSNEP_QUEUES 1
-
 struct tsnep_gcl {
 	void __iomem *addr;
 
drivers/net/ethernet/engleder/tsnep_hw.h +1 -0
index e03aaafab559..e6cc6fbaf0d7 100644
@@ -34,6 +34,7 @@
 #define ECM_INT_LINK 0x00000020
 #define ECM_INT_TX_0 0x00000100
 #define ECM_INT_RX_0 0x00000200
+#define ECM_INT_TXRX_SHIFT 2
 #define ECM_INT_ALL 0x7FFFFFFF
 #define ECM_INT_DISABLE 0x80000000
 
drivers/net/ethernet/engleder/tsnep_main.c +52 -9

83 lines not on this page · raw message

Signature · 1 line
2.30.2
#14 lore raw

PATCH v3 5/6 tsnep: Add EtherType RX flow classification support

In reply to Gerhard Engleder

Received Ethernet frames are assigned to first RX queue per default. Based on EtherType Ethernet frames can be assigned to other RX queues. This enables processing of real-time Ethernet protocols on dedicated RX queues.

Add RX flow classification interface for EtherType based RX queue assignment.

---
 drivers/net/ethernet/engleder/Makefile        |   2 +-
 drivers/net/ethernet/engleder/tsnep.h         |  36 +++
 drivers/net/ethernet/engleder/tsnep_ethtool.c |  38 +++
 drivers/net/ethernet/engleder/tsnep_hw.h      |  12 +-
 drivers/net/ethernet/engleder/tsnep_main.c    |  11 +
 drivers/net/ethernet/engleder/tsnep_rxnfc.c   | 281 ++++++++++++++++++
 6 files changed, 375 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/engleder/tsnep_rxnfc.c
drivers/net/ethernet/engleder/Makefile +1 -1
index cce2191cb889..b6e3b16623de 100644
@@ -6,5 +6,5 @@
 obj-$(CONFIG_TSNEP) += tsnep.o
 
 tsnep-objs := tsnep_main.o tsnep_ethtool.o tsnep_ptp.o tsnep_tc.o \
-	      $(tsnep-y)
+	      tsnep_rxnfc.o $(tsnep-y)
 tsnep-$(CONFIG_TSNEP_SELFTESTS) += tsnep_selftests.o
drivers/net/ethernet/engleder/tsnep.h +36 -0
index 62a279bcb011..2ca34ae9b55a 100644
@@ -37,6 +37,24 @@ struct tsnep_gcl {
 	bool change;
 };
 
+enum tsnep_rxnfc_filter_type {
+	TSNEP_RXNFC_ETHER_TYPE,
+};
+
+struct tsnep_rxnfc_filter {
+	enum tsnep_rxnfc_filter_type type;
+	union {
+		u16 ether_type;
+	};
+};
+
+struct tsnep_rxnfc_rule {
+	struct list_head list;
+	struct tsnep_rxnfc_filter filter;
+	int queue_index;
+	int location;
+};
+
 struct tsnep_tx_entry {
 	struct tsnep_tx_desc *desc;
 	struct tsnep_tx_desc_wb *desc_wb;
@@ -141,6 +159,12 @@ struct tsnep_adapter {
 	/* ptp clock lock */
 	spinlock_t ptp_lock;
 
+	/* RX flow classification rules lock */
+	struct mutex rxnfc_lock;
+	struct list_head rxnfc_rules;
+	int rxnfc_count;
+	int rxnfc_max;
+
 	int num_tx_queues;
 	struct tsnep_tx tx[TSNEP_MAX_QUEUES];
 	int num_rx_queues;
@@ -161,6 +185,18 @@ void tsnep_tc_cleanup(struct tsnep_adapter *adapter);
 int tsnep_tc_setup(struct net_device *netdev, enum tc_setup_type type,
 		   void *type_data);
 
+int tsnep_rxnfc_init(struct tsnep_adapter *adapter);
+void tsnep_rxnfc_cleanup(struct tsnep_adapter *adapter);
+int tsnep_rxnfc_get_rule(struct tsnep_adapter *adapter,
+			 struct ethtool_rxnfc *cmd);
+int tsnep_rxnfc_get_all(struct tsnep_adapter *adapter,
+			struct ethtool_rxnfc *cmd,
+			u32 *rule_locs);
+int tsnep_rxnfc_add_rule(struct tsnep_adapter *adapter,
+			 struct ethtool_rxnfc *cmd);
+int tsnep_rxnfc_del_rule(struct tsnep_adapter *adapter,
+			 struct ethtool_rxnfc *cmd);
+
 #if IS_ENABLED(CONFIG_TSNEP_SELFTESTS)
 int tsnep_ethtool_get_test_count(void);
 void tsnep_ethtool_get_test_strings(u8 *data);
drivers/net/ethernet/engleder/tsnep_ethtool.c +38 -0
index e6760dc68ddd..b9c4c45db052 100644
@@ -250,6 +250,42 @@ static int tsnep_ethtool_get_sset_count(struct net_device *netdev, int sset)
 	}
 }
 
+static int tsnep_ethtool_get_rxnfc(struct net_device *dev,
+				   struct ethtool_rxnfc *cmd, u32 *rule_locs)
+{
+	struct tsnep_adapter *adapter = netdev_priv(dev);
+
+	switch (cmd->cmd) {
+	case ETHTOOL_GRXRINGS:
+		cmd->data = adapter->num_rx_queues;
+		return 0;
+	case ETHTOOL_GRXCLSRLCNT:
+		cmd->rule_cnt = adapter->rxnfc_count;
+		return 0;
+	case ETHTOOL_GRXCLSRULE:
+		return tsnep_rxnfc_get_rule(adapter, cmd);
+	case ETHTOOL_GRXCLSRLALL:
+		return tsnep_rxnfc_get_all(adapter, cmd, rule_locs);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int tsnep_ethtool_set_rxnfc(struct net_device *dev,
+				   struct ethtool_rxnfc *cmd)
+{
+	struct tsnep_adapter *adapter = netdev_priv(dev);
+
+	switch (cmd->cmd) {
+	case ETHTOOL_SRXCLSRLINS:
+		return tsnep_rxnfc_add_rule(adapter, cmd);
+	case ETHTOOL_SRXCLSRLDEL:
+		return tsnep_rxnfc_del_rule(adapter, cmd);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int tsnep_ethtool_get_ts_info(struct net_device *dev,
 				     struct ethtool_ts_info *info)
 {
@@ -287,6 +323,8 @@ const struct ethtool_ops tsnep_ethtool_ops = {
 	.get_strings = tsnep_ethtool_get_strings,
 	.get_ethtool_stats = tsnep_ethtool_get_ethtool_stats,
 	.get_sset_count = tsnep_ethtool_get_sset_count,
+	.get_rxnfc = tsnep_ethtool_get_rxnfc,
+	.set_rxnfc = tsnep_ethtool_set_rxnfc,
 	.get_ts_info = tsnep_ethtool_get_ts_info,
 	.get_link_ksettings = phy_ethtool_get_link_ksettings,
 	.set_link_ksettings = phy_ethtool_set_link_ksettings,
drivers/net/ethernet/engleder/tsnep_hw.h +8 -4
index e6cc6fbaf0d7..315dada75323 100644
@@ -122,10 +122,6 @@
 #define TSNEP_RX_STATISTIC_BUFFER_TOO_SMALL 0x0191
 #define TSNEP_RX_STATISTIC_FIFO_OVERFLOW 0x0192
 #define TSNEP_RX_STATISTIC_INVALID_FRAME 0x0193
-#define TSNEP_RX_ASSIGN 0x01A0
-#define TSNEP_RX_ASSIGN_ETHER_TYPE_ACTIVE 0x00000001
-#define TSNEP_RX_ASSIGN_ETHER_TYPE_MASK 0xFFFF0000
-#define TSNEP_RX_ASSIGN_ETHER_TYPE_SHIFT 16
 #define TSNEP_MAC_ADDRESS_LOW 0x0800
 #define TSNEP_MAC_ADDRESS_HIGH 0x0804
 #define TSNEP_RX_FILTER 0x0806
@@ -152,6 +148,14 @@
 #define TSNEP_GCL_A 0x2000
 #define TSNEP_GCL_B 0x2800
 #define TSNEP_GCL_SIZE SZ_2K
+#define TSNEP_RX_ASSIGN 0x0840
+#define TSNEP_RX_ASSIGN_ACTIVE 0x00000001
+#define TSNEP_RX_ASSIGN_QUEUE_MASK 0x00000006
+#define TSNEP_RX_ASSIGN_QUEUE_SHIFT 1
+#define TSNEP_RX_ASSIGN_OFFSET 1
+#define TSNEP_RX_ASSIGN_ETHER_TYPE 0x0880
+#define TSNEP_RX_ASSIGN_ETHER_TYPE_OFFSET 2
+#define TSNEP_RX_ASSIGN_ETHER_TYPE_COUNT 2
 
 /* tsnep gate control list operation */
 struct tsnep_gcl_operation {
drivers/net/ethernet/engleder/tsnep_main.c +11 -0
index bf088b91efb7..a6b81f32d76b 100644
@@ -1341,6 +1341,8 @@ static int tsnep_probe(struct platform_device *pdev)
 	netdev->max_mtu = TSNEP_MAX_FRAME_SIZE;
 
 	mutex_init(&adapter->gate_control_lock);
+	mutex_init(&adapter->rxnfc_lock);
+	INIT_LIST_HEAD(&adapter->rxnfc_rules);
 
 	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	adapter->addr = devm_ioremap_resource(&pdev->dev, io);
@@ -1354,6 +1356,7 @@ static int tsnep_probe(struct platform_device *pdev)
 	version = (type & ECM_VERSION_MASK) >> ECM_VERSION_SHIFT;
 	queue_count = (type & ECM_QUEUE_COUNT_MASK) >> ECM_QUEUE_COUNT_SHIFT;
 	adapter->gate_control = type & ECM_GATE_CONTROL;
+	adapter->rxnfc_max = TSNEP_RX_ASSIGN_ETHER_TYPE_COUNT;
 
 	tsnep_disable_irq(adapter, ECM_INT_ALL);
 
@@ -1388,6 +1391,10 @@ static int tsnep_probe(struct platform_device *pdev)
 	if (retval)
 		goto tc_init_failed;
 
+	retval = tsnep_rxnfc_init(adapter);
+	if (retval)
+		goto rxnfc_init_failed;
+
 	netdev->netdev_ops = &tsnep_netdev_ops;
 	netdev->ethtool_ops = &tsnep_ethtool_ops;
 	netdev->features = NETIF_F_SG;
@@ -1408,6 +1415,8 @@ static int tsnep_probe(struct platform_device *pdev)
 	return 0;
 
 register_failed:
+	tsnep_rxnfc_cleanup(adapter);
+rxnfc_init_failed:
 	tsnep_tc_cleanup(adapter);
 tc_init_failed:
 	tsnep_ptp_cleanup(adapter);
@@ -1425,6 +1434,8 @@ static int tsnep_remove(struct platform_device *pdev)
 
 	unregister_netdev(adapter->netdev);
 
+	tsnep_rxnfc_cleanup(adapter);
+
 	tsnep_tc_cleanup(adapter);
 
 	tsnep_ptp_cleanup(adapter);
drivers/net/ethernet/engleder/tsnep_rxnfc.c new file +281 -0

281 lines not on this page · raw message

Signature · 1 line
2.30.2
#15 lore raw

PATCH v3 6/6 tsnep: Use page pool for RX

In reply to Gerhard Engleder

Use page pool for RX buffer handling. Makes RX path more efficient and is required prework for future XDP support.

---
 drivers/net/ethernet/engleder/Kconfig      |   1 +
 drivers/net/ethernet/engleder/tsnep.h      |   5 +-
 drivers/net/ethernet/engleder/tsnep_main.c | 162 ++++++++++++---------
 3 files changed, 100 insertions(+), 68 deletions(-)
drivers/net/ethernet/engleder/Kconfig +1 -0
index f4e2b1102d8f..3df6bf476ae7 100644
@@ -21,6 +21,7 @@ config TSNEP
 	depends on HAS_IOMEM && HAS_DMA
 	depends on PTP_1588_CLOCK_OPTIONAL
 	select PHYLIB
+	select PAGE_POOL
 	help
 	  Support for the Engleder TSN endpoint Ethernet MAC IP Core.
 
drivers/net/ethernet/engleder/tsnep.h +3 -2
index 2ca34ae9b55a..09a723b827c7 100644
@@ -96,9 +96,9 @@ struct tsnep_rx_entry {
 
 	u32 properties;
 
-	struct sk_buff *skb;
+	struct page *page;
 	size_t len;
-	DEFINE_DMA_UNMAP_ADDR(dma);
+	dma_addr_t dma;
 };
 
 struct tsnep_rx {
@@ -113,6 +113,7 @@ struct tsnep_rx {
 	int read;
 	u32 owner_counter;
 	int increment_owner_counter;
+	struct page_pool *page_pool;
 
 	u32 packets;
 	u32 bytes;
drivers/net/ethernet/engleder/tsnep_main.c +96 -66

238 lines not on this page · raw message

Signature · 1 line
2.30.2