Skip to contentSkip to conversation

net: mvpp2: Add TX Flow Control support

RFC PATCH Superseded [email protected] 3 participants 36 messages Jan 24, 2021 – Jan 25, 2021

Subsystems (5)

v2 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v2 cover net: mvpp2: Add TX Flow Control support

From: Stefan Chulski <[email protected]>

Armada hardware has a pause generation mechanism in GOP (MAC).
The GOP generate flow control frames based on an indication programmed in Ports Control 0 Register. There is a bit per port. However assertion of the PortX Pause bits in the ports control 0 register only sends a one time pause. To complement the function the GOP has a mechanism to periodically send pause control messages based on periodic counters. This mechanism ensures that the pause is effective as long as the Appropriate PortX Pause is asserted.

Problem is that Packet Processor that actually can drop packets due to lack of resources not connected to the GOP flow control generation mechanism. To solve this issue Armada has firmware running on CM3 CPU dedicated for Flow Control support.
Firmware monitors Packet Processor resources and asserts XON/XOFF by writing to Ports Control 0 Register.

MSS shared SRAM memory used to communicate between CM3 firmware and PP2 driver.
During init PP2 driver informs firmware about used BM pools, RXQs, congestion and depletion thresholds.

The pause frames are generated whenever congestion or depletion in resources is detected.
The back pressure is stopped when the resource reaches a sufficient level.
So the congestion/depletion and sufficient level implement a hysteresis that reduces the XON/XOFF toggle frequency.

Packet Processor v23 hardware introduces support for RX FIFO fill level monitor. Patch "add PPv23 version definition" to differ between v23 and v22 hardware. Patch "add TX FC firmware check" verifies that CM3 firmware supports Flow Control monitoring.

v1 --> v2
- Add memory requirements information
- Add EPROBE_DEFER if of_gen_pool_get return NULL
- Move Flow control configuration to mvpp2_mac_link_up callback
- Add firmware version info with Flow control support

Konstantin Porotchkin (1):
dts: marvell: add CM3 SRAM memory to cp115 ethernet device tree

Stefan Chulski (17):
doc: marvell: add cm3-mem device tree bindings description
net: mvpp2: add CM3 SRAM memory map
net: mvpp2: add PPv23 version definition
net: mvpp2: always compare hw-version vs MVPP21
net: mvpp2: increase BM pool size to 2048 buffers
net: mvpp2: increase RXQ size to 1024 descriptors
net: mvpp2: add FCA periodic timer configurations
net: mvpp2: add FCA RXQ non occupied descriptor threshold
net: mvpp2: add spinlock for FW FCA configuration path
net: mvpp2: enable global flow control
net: mvpp2: add RXQ flow control configurations
net: mvpp2: add ethtool flow control configuration support
net: mvpp2: add BM protection underrun feature support
net: mvpp2: add PPv23 RX FIFO flow control
net: mvpp2: set 802.3x GoP Flow Control mode
net: mvpp2: limit minimum ring size to 1024 descriptors
net: mvpp2: add TX FC firmware check

 Documentation/devicetree/bindings/net/marvell-pp2.txt |   1 +
 arch/arm64/boot/dts/marvell/armada-cp11x.dtsi         |  10 +
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h            | 130 ++++-
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c       | 558 +++++++++++++++++++-
 4 files changed, 657 insertions(+), 42 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH v2 1/18 doc: marvell: add cm3-mem device tree bindings description

From: Stefan Chulski <[email protected]>

---
 Documentation/devicetree/bindings/net/marvell-pp2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/marvell-pp2.txt +1 -0
index b783976..f9f8cc6 100644
@@ -37,6 +37,7 @@ Required properties (port):
   GOP (Group Of Ports) point of view. This ID is used to index the
   per-port registers in the second register area.
 - phy-mode: See ethernet.txt file in the same directory
+- cm3-mem: phandle to CM3 SRAM definitions
 
 Optional properties (port):
 
Signature · 1 line
1.9.1
#2 lore raw

RFC PATCH v2 2/18 dts: marvell: add CM3 SRAM memory to cp115 ethernet device tree

In reply to [email protected]

From: Konstantin Porotchkin <[email protected]>

CM3 SRAM address space would be used for Flow Control configuration.

---
 arch/arm64/boot/dts/marvell/armada-cp11x.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/marvell/armada-cp11x.dtsi +10 -0
index 9dcf16b..359cf42 100644
@@ -69,6 +69,8 @@
 			status = "disabled";
 			dma-coherent;
 
+			cm3-mem = <&CP11X_LABEL(cm3_sram)>;
+
 			CP11X_LABEL(eth0): eth0 {
 				interrupts = <39 IRQ_TYPE_LEVEL_HIGH>,
 					<43 IRQ_TYPE_LEVEL_HIGH>,
@@ -211,6 +213,14 @@
 			};
 		};
 
+		CP11X_LABEL(cm3_sram): cm3@220000 {
+			compatible = "mmio-sram";
+			reg = <0x220000 0x800>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0x220000 0x800>;
+		};
+
 		CP11X_LABEL(rtc): rtc@284000 {
 			compatible = "marvell,armada-8k-rtc";
 			reg = <0x284000 0x20>, <0x284080 0x24>;
Signature · 1 line
1.9.1
#3 lore raw

RFC PATCH v2 3/18 net: mvpp2: add CM3 SRAM memory map

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch adds CM3 memory map and CM3 read/write callbacks. No functionality changes.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  7 ++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 74 +++++++++++++++++++-
 2 files changed, 78 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +7 -0
index 6bd7e40..aec9179 100644
@@ -748,6 +748,9 @@
 #define MVPP2_TX_FIFO_THRESHOLD(kb)	\
 		((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
 
+/* MSS Flow control */
+#define MSS_SRAM_SIZE	0x800
+
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
 	SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
@@ -925,6 +928,7 @@ struct mvpp2 {
 	/* Shared registers' base addresses */
 	void __iomem *lms_base;
 	void __iomem *iface_base;
+	void __iomem *cm3_base;
 
 	/* On PPv2.2, each "software thread" can access the base
 	 * register through a separate address space, each 64 KB apart
@@ -996,6 +1000,9 @@ struct mvpp2 {
 
 	/* page_pool allocator */
 	struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ];
+
+	/* CM3 SRAM pool */
+	struct gen_pool *sram_pool;
 };
 
 struct mvpp2_pcpu_stats {
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +71 -3

118 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map

Quoted 17 lines · On Sun, Jan 24, 2021 at 01:43:52PM +0200, [email protected] wrote:
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +17 -0
+static int mvpp2_get_sram(struct platform_device *pdev,
+			  struct mvpp2 *priv)
+{
+	struct device_node *dn = pdev->dev.of_node;
+	static bool defer_once;
+	struct resource *res;
+
+	if (has_acpi_companion(&pdev->dev)) {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+		if (!res) {
+			dev_warn(&pdev->dev, "ACPI is too old, Flow control not supported\n");
+			return 0;
+		}
+		priv->cm3_base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(priv->cm3_base))
+			return PTR_ERR(priv->cm3_base);
+	} else {

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) · line 6888

Quoted 10 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +10 -0
+		priv->sram_pool = of_gen_pool_get(dn, "cm3-mem", 0);
+		if (!priv->sram_pool) {
+			if (!defer_once) {
+				defer_once = true;
+				/* Try defer once */
+				return -EPROBE_DEFER;
+			}
+			dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
+			return -ENOMEM;
+		}

Above, priv->sram_pool will only be non-NULL if the pool has been initialised.

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_probe(struct platform_device *pdev) · line 7150

Quoted 4 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +4 -0
+err_cm3:
+	if (!has_acpi_companion(&pdev->dev) && priv->cm3_base)
+		gen_pool_free(priv->sram_pool, (unsigned long)priv->cm3_base,
+			      MSS_SRAM_SIZE);

So wouldn't:

	if (priv->sram_pool && priv->cm3_base)

be more appropriate here?

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_remove(struct platform_device *pdev) · line 7196

Quoted 5 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +5 -0
+	if (!has_acpi_companion(&pdev->dev) && priv->cm3_base) {
+		gen_pool_free(priv->sram_pool, (unsigned long)priv->cm3_base,
+			      MSS_SRAM_SIZE);
+		gen_pool_destroy(priv->sram_pool);
+	}

Same here.

Why is it correct to call gen_pool_destroy() in the remove path but not the error path? I think you want to drop this - the pool is created and destroyed by the SRAM driver, users of it should not be destroying it.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#5 lore raw

Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map

In reply to [email protected]
Quoted 4 lines · On Sun, Jan 24, 2021 at 01:43:52PM +0200, [email protected] wrote:
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +4 -0
+		priv->sram_pool = of_gen_pool_get(dn, "cm3-mem", 0);
+		if (!priv->sram_pool) {
+			if (!defer_once) {
+				defer_once = true;

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) · line 6892

Quoted 10 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +10 -0
+				/* Try defer once */
+				return -EPROBE_DEFER;
+			}
+			dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
+			return -ENOMEM;
+		}
+		priv->cm3_base = (void __iomem *)gen_pool_alloc(priv->sram_pool,
+								MSS_SRAM_SIZE);
+		if (!priv->cm3_base)
+			return -ENOMEM;

This probably could do with a comment indicating that it is reliant on this allocation happening at offset zero into the SRAM. The only reason that is guaranteed _at the moment_ is because the SRAM mapping is 0x800 bytes in size, and you are requesting 0x800 bytes in this allocation, so allocating the full size.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#6 lore raw

Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map

Quoted 13 lines · Russell King - ARM Linux admin
Quoted 12 lines · On Sun, Jan 24, 2021 at 01:43:52PM +0200, [email protected] wrote:
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +12 -0
+		priv->sram_pool = of_gen_pool_get(dn, "cm3-mem", 0);
+		if (!priv->sram_pool) {
+			if (!defer_once) {
+				defer_once = true;
+				/* Try defer once */
+				return -EPROBE_DEFER;
+			}
+			dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
+			return -ENOMEM;
+		}
+		priv->cm3_base = (void __iomem *)gen_pool_alloc(priv->sram_pool,
+								MSS_SRAM_SIZE);
Quoted 8 lines

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) · line 6892

Quoted 2 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
+		if (!priv->cm3_base)
+			return -ENOMEM;

This probably could do with a comment indicating that it is reliant on this allocation happening at offset zero into the SRAM. The only reason that is guaranteed _at the moment_ is because the SRAM mapping is 0x800 bytes in size, and you are requesting 0x800 bytes in this allocation, so allocating the full size.

Hi Russell

I'm wondering if using a pool even makes sense. The ACPI case just ioremap() the memory region. Either this memory is dedicated, and then there is no need to use a pool, or the memory is shared, and at some point the ACPI code is going to run into problems when some other driver also wants access.

Andrew

maintainer
#7 lore raw

Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map

In reply to [email protected]
Quoted 17 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
index a07cf60..c969a2d 100644
@@ -25,6 +25,7 @@
 #include <linux/of_net.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
+#include <linux/genalloc.h>
 #include <linux/phy.h>
 #include <linux/phylink.h>
 #include <linux/phy/phy.h>
@@ -91,6 +92,18 @@ static inline u32 mvpp2_cpu_to_thread(struct mvpp2 *priv, int cpu)
 	return cpu % priv->nthreads;
 }
 
+static inline

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static inline u32 mvpp2_cpu_to_thread(struct mvpp2 *priv, int cpu) · line 105

Quoted 10 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +10 -0
+void mvpp2_cm3_write(struct mvpp2 *priv, u32 offset, u32 data)
+{
+	writel(data, priv->cm3_base + offset);
+}
+
+static inline
+u32 mvpp2_cm3_read(struct mvpp2 *priv, u32 offset)
+{
+	return readl(priv->cm3_base + offset);
+}

No inline functions in .c file please. Let the compiler decide.

Andrew

#8 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map

Quoted 22 lines

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static inline u32 mvpp2_cpu_to_thread(struct

Quoted 8 lines

#include <linux/of_net.h>
#include <linux/of_address.h>
#include <linux/of_device.h>

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
+#include <linux/genalloc.h>
 #include <linux/phy.h>
 #include <linux/phylink.h>
 #include <linux/phy/phy.h>
@@ -91,6 +92,18 @@ static inline u32 mvpp2_cpu_to_thread(struct

mvpp2 *priv, int cpu)

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static inline u32 mvpp2_cpu_to_thread(struct mvpp2 *priv, int cpu)

Quoted 10 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +7 -0
 	return cpu % priv->nthreads;
 }
 
+static inline
+void mvpp2_cm3_write(struct mvpp2 *priv, u32 offset, u32 data) {
+	writel(data, priv->cm3_base + offset); }
+
+static inline
+u32 mvpp2_cm3_read(struct mvpp2 *priv, u32 offset) {
+	return readl(priv->cm3_base + offset); }

No inline functions in .c file please. Let the compiler decide.

Quoted 1 line

Andrew

Ok, I would fix.

Thanks,
Stefan.

#9 lore raw

RFC PATCH v2 4/18 net: mvpp2: add PPv23 version definition

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch add PPv23 version definition.
PPv23 is new packet processor in CP115.
Everything that supported by PPv22, also supported by PPv23. No functional changes in this stage.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 24 ++++++++++++--------
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++-----
 2 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +14 -10
index aec9179..89b3ede 100644
@@ -60,6 +60,9 @@
 /* Top Registers */
 #define MVPP2_MH_REG(port)			(0x5040 + 4 * (port))
 #define MVPP2_DSA_EXTENDED			BIT(5)
+#define MVPP2_VER_ID_REG			0x50b0
+#define MVPP2_VER_PP22				0x10
+#define MVPP2_VER_PP23				0x11
 
 /* Parser Registers */
 #define MVPP2_PRS_INIT_LOOKUP_REG		0x1000
@@ -469,7 +472,7 @@
 #define     MVPP22_GMAC_INT_SUM_MASK_LINK_STAT	BIT(1)
 #define	    MVPP22_GMAC_INT_SUM_MASK_PTP	BIT(2)
 
-/* Per-port XGMAC registers. PPv2.2 only, only for GOP port 0,
+/* Per-port XGMAC registers. PPv2.2 and PPv2.3, only for GOP port 0,
  * relative to port->base.
  */
 #define MVPP22_XLG_CTRL0_REG			0x100
@@ -506,7 +509,7 @@
 #define     MVPP22_XLG_CTRL4_MACMODSELECT_GMAC	BIT(12)
 #define     MVPP22_XLG_CTRL4_EN_IDLE_CHECK	BIT(14)
 
-/* SMI registers. PPv2.2 only, relative to priv->iface_base. */
+/* SMI registers. PPv2.2 and PPv2.3, relative to priv->iface_base. */
 #define MVPP22_SMI_MISC_CFG_REG			0x1204
 #define     MVPP22_SMI_POLLING_EN		BIT(10)
 
@@ -582,7 +585,7 @@
 #define MVPP2_QUEUE_NEXT_DESC(q, index) \
 	(((index) < (q)->last_desc) ? ((index) + 1) : 0)
 
-/* XPCS registers. PPv2.2 only */
+/* XPCS registers.PPv2.2 and PPv2.3 */
 #define MVPP22_MPCS_BASE(port)			(0x7000 + (port) * 0x1000)
 #define MVPP22_MPCS_CTRL			0x14
 #define     MVPP22_MPCS_CTRL_FWD_ERR_CONN	BIT(10)
@@ -593,7 +596,7 @@
 #define     MVPP22_MPCS_CLK_RESET_DIV_RATIO(n)	((n) << 4)
 #define     MVPP22_MPCS_CLK_RESET_DIV_SET	BIT(11)
 
-/* XPCS registers. PPv2.2 only */
+/* XPCS registers. PPv2.2 and PPv2.3 */
 #define MVPP22_XPCS_BASE(port)			(0x7400 + (port) * 0x1000)
 #define MVPP22_XPCS_CFG0			0x0
 #define     MVPP22_XPCS_CFG0_RESET_DIS		BIT(0)
@@ -930,15 +933,16 @@ struct mvpp2 {
 	void __iomem *iface_base;
 	void __iomem *cm3_base;
 
-	/* On PPv2.2, each "software thread" can access the base
+	/* On PPv2.2 and PPv2.3, each "software thread" can access the base
 	 * register through a separate address space, each 64 KB apart
 	 * from each other. Typically, such address spaces will be
 	 * used per CPU.
 	 */
 	void __iomem *swth_base[MVPP2_MAX_THREADS];
 
-	/* On PPv2.2, some port control registers are located into the system
-	 * controller space. These registers are accessible through a regmap.
+	/* On PPv2.2 and PPv2.3, some port control registers are located into
+	 * the system controller space. These registers are accessible
+	 * through a regmap.
 	 */
 	struct regmap *sysctrl_base;
 
@@ -980,7 +984,7 @@ struct mvpp2 {
 	u32 tclk;
 
 	/* HW version */
-	enum { MVPP21, MVPP22 } hw_version;
+	enum { MVPP21, MVPP22, MVPP23 } hw_version;
 
 	/* Maximum number of RXQs per port */
 	unsigned int max_port_rxqs;
@@ -1227,7 +1231,7 @@ struct mvpp21_rx_desc {
 	__le32 reserved8;
 };
 
-/* HW TX descriptor for PPv2.2 */
+/* HW TX descriptor for PPv2.2 and PPv2.3 */
 struct mvpp22_tx_desc {
 	__le32 command;
 	u8  packet_offset;
@@ -1239,7 +1243,7 @@ struct mvpp22_tx_desc {
 	__le64 buf_cookie_misc;
 };
 
-/* HW RX descriptor for PPv2.2 */
+/* HW RX descriptor for PPv2.2 and PPv2.3 */
 struct mvpp22_rx_desc {
 	__le32 status;
 	__le16 reserved1;
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +11 -6
index c969a2d..fc102f2 100644
@@ -397,7 +397,7 @@ static int mvpp2_bm_pool_create(struct device *dev, struct mvpp2 *priv,
 	if (!IS_ALIGNED(size, 16))
 		return -EINVAL;
 
-	/* PPv2.1 needs 8 bytes per buffer pointer, PPv2.2 needs 16
+	/* PPv2.1 needs 8 bytes per buffer pointer, PPv2.2 and PPv2.3 needs 16
 	 * bytes per buffer pointer
 	 */
 	if (priv->hw_version == MVPP21)
@@ -1185,7 +1185,7 @@ static void mvpp2_interrupts_unmask(void *arg)
 	u32 val;
 	int i;
 
-	if (port->priv->hw_version != MVPP22)
+	if (port->priv->hw_version == MVPP21)
 		return;
 
 	if (mask)
@@ -5469,7 +5469,7 @@ static void mvpp2_rx_irqs_setup(struct mvpp2_port *port)
 		return;
 	}
 
-	/* Handle the more complicated PPv2.2 case */
+	/* Handle the more complicated PPv2.2 and PPv2.3 case */
 	for (i = 0; i < port->nqvecs; i++) {
 		struct mvpp2_queue_vector *qv = port->qvecs + i;
 
@@ -5646,7 +5646,7 @@ static bool mvpp22_port_has_legacy_tx_irqs(struct device_node *port_node,
 
 /* Checks if the port dt description has the required Tx interrupts:
  * - PPv2.1: there are no such interrupts.
- * - PPv2.2:
+ * - PPv2.2 and PPv2.3:
  *   - The old DTs have: "rx-shared", "tx-cpuX" with X in [0...3]
  *   - The new ones have: "hifX" with X in [0..8]
  *
@@ -6634,7 +6634,7 @@ static void mvpp22_rx_fifo_set_hw(struct mvpp2 *priv, int port, int data_size)
 	mvpp2_write(priv, MVPP2_RX_ATTR_FIFO_SIZE_REG(port), attr_size);
 }
 
-/* Initialize TX FIFO's: the total FIFO size is 48kB on PPv2.2.
+/* Initialize TX FIFO's: the total FIFO size is 48kB on PPv2.2 and PPv2.3.
  * 4kB fixed space must be assigned for the loopback port.
  * Redistribute remaining avialable 44kB space among all active ports.
  * Guarantee minimum 32kB for 10G port and 8kB for port 1, capable of 2.5G
@@ -6691,7 +6691,7 @@ static void mvpp22_tx_fifo_set_hw(struct mvpp2 *priv, int port, int size)
 	mvpp2_write(priv, MVPP22_TX_FIFO_THRESH_REG(port), threshold);
 }
 
-/* Initialize TX FIFO's: the total FIFO size is 19kB on PPv2.2.
+/* Initialize TX FIFO's: the total FIFO size is 19kB on PPv2.2 and PPv2.3.
  * 3kB fixed space must be assigned for the loopback port.
  * Redistribute remaining avialable 16kB space among all active ports.
  * The 10G interface should use 10kB (which is maximum possible size
@@ -7080,6 +7080,11 @@ static int mvpp2_probe(struct platform_device *pdev)
 			priv->port_map |= BIT(i);
 	}
 
+	if (priv->hw_version != MVPP21) {
+		if (mvpp2_read(priv, MVPP2_VER_ID_REG) == MVPP2_VER_PP23)
+			priv->hw_version = MVPP23;
+	}
+
 	/* Initialize network controller */
 	err = mvpp2_init(pdev, priv);
 	if (err < 0) {
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition

Quoted 18 lines · On Sun, Jan 24, 2021 at 01:43:53PM +0200, [email protected] wrote:

From: Stefan Chulski <[email protected]>

This patch add PPv23 version definition.
PPv23 is new packet processor in CP115.
Everything that supported by PPv22, also supported by PPv23. No functional changes in this stage.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 24 ++++++++++++--------
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++-----
 2 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +0 -0
index aec9179..89b3ede 100644

drivers/net/ethernet/marvell/mvpp2/mvpp2.h line 65

Quoted 6 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +3 -0
@@ -60,6 +60,9 @@
 /* Top Registers */
 #define MVPP2_MH_REG(port)			(0x5040 + 4 * (port))
 #define MVPP2_DSA_EXTENDED			BIT(5)
+#define MVPP2_VER_ID_REG			0x50b0
+#define MVPP2_VER_PP22				0x10
+#define MVPP2_VER_PP23				0x11

Looking at the Armada 8040 docs, it seems this register exists on PPv2.1 as well, and holds the value zero there.

I wonder whether we should instead read it's value directly into hw_version, and test against these values, rather than inventing our own verison enum.

I've also been wondering whether your != MVPP21 comparisons should instead be >= MVPP22.

Any thoughts?

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#11 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition

Quoted 23 lines
Quoted 3 lines
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 24 ++++++++++++------

--

Quoted 9 lines
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++-----
 2 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +0 -0
index aec9179..89b3ede 100644

drivers/net/ethernet/marvell/mvpp2/mvpp2.h line 65

Quoted 6 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +3 -0
@@ -60,6 +60,9 @@
 /* Top Registers */
 #define MVPP2_MH_REG(port)			(0x5040 + 4 * (port))
 #define MVPP2_DSA_EXTENDED			BIT(5)
+#define MVPP2_VER_ID_REG			0x50b0
+#define MVPP2_VER_PP22				0x10
+#define MVPP2_VER_PP23				0x11

Looking at the Armada 8040 docs, it seems this register exists on PPv2.1 as well, and holds the value zero there.

Quoted 7 lines

I wonder whether we should instead read it's value directly into hw_version, and test against these values, rather than inventing our own verison enum.

I've also been wondering whether your != MVPP21 comparisons should instead be >= MVPP22.

Any thoughts?

We cannot access PPv2 register space before enabling clocks(done in mvpp2_probe) , PP21 and PP22/23 have different sets of clocks. So diff between PP21 and PP22/23 should be stored in device tree(in of_device_id), with MVPP22 and MVPP21 stored as .data Maybe we can do it differently, but I prefer to make this change not in the Flow Control patch series.
I'm OK with both >= MVPP22 and != MVPP21 options.

Regards,
Stefan.

maintainer
#12 lore raw

Re: [EXT] Re: [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition

Quoted 29 lines · Stefan Chulski
Quoted 29 lines
Quoted 3 lines
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 24 ++++++++++++------

--

Quoted 9 lines
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++-----
 2 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +0 -0
index aec9179..89b3ede 100644

drivers/net/ethernet/marvell/mvpp2/mvpp2.h line 65

Quoted 6 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +3 -0
@@ -60,6 +60,9 @@
 /* Top Registers */
 #define MVPP2_MH_REG(port)			(0x5040 + 4 * (port))
 #define MVPP2_DSA_EXTENDED			BIT(5)
+#define MVPP2_VER_ID_REG			0x50b0
+#define MVPP2_VER_PP22				0x10
+#define MVPP2_VER_PP23				0x11

Looking at the Armada 8040 docs, it seems this register exists on PPv2.1 as well, and holds the value zero there.

I wonder whether we should instead read it's value directly into hw_version, and test against these values, rather than inventing our own verison enum.

I've also been wondering whether your != MVPP21 comparisons should instead be >= MVPP22.

Quoted 6 lines
Quoted 1 line

Any thoughts?

We cannot access PPv2 register space before enabling clocks(done in mvpp2_probe) , PP21 and PP22/23 have different sets of clocks.

So diff between PP21 and PP22/23 should be stored in device tree(in of_device_id), with MVPP22 and MVPP21 stored as .data

Hi Stefan

As far as i can see, you are not adding a new compatible. So 'marvell,armada-7k-pp2' means PPv2.2 and PPv2.3? It would be good to update the comment at the beginning of marvell-pp2.txt to indicate this.

Andrew

#13 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition

Quoted 6 lines
Quoted 1 line

We cannot access PPv2 register space before enabling clocks(done in

mvpp2_probe) , PP21 and PP22/23 have different sets of clocks.

Quoted 2 lines

So diff between PP21 and PP22/23 should be stored in device tree(in of_device_id), with MVPP22 and MVPP21 stored as .data

Quoted 7 lines

Hi Stefan

As far as i can see, you are not adding a new compatible. So 'marvell,armada- 7k-pp2' means PPv2.2 and PPv2.3? It would be good to update the comment at the beginning of marvell-pp2.txt to indicate this.

Andrew

Ok, I would add comment.

Thanks,
Stefan.

#14 lore raw

RFC PATCH v2 5/18 net: mvpp2: always compare hw-version vs MVPP21

In reply to [email protected]

From: Stefan Chulski <[email protected]>

Currently we have PP2v1 and PP2v2 hw-versions, with some different handlers depending upon condition hw_version = MVPP21/MVPP22. In a future there will be also PP2v3. Let's use now the generic "if equal/notEqual MVPP21" for all cases instead of "if MVPP22".

This patch does not change any functionality.
It is not intended to introduce PP2v3.
It just modifies MVPP21/MVPP22 check-condition bringing it to generic and unified form correct for new-code introducing and PP2v3 net-next generation.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 36 ++++++++++----------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +18 -18
index fc102f2..7143909 100644
@@ -332,7 +332,7 @@ static int mvpp2_get_nrxqs(struct mvpp2 *priv)
 {
 	unsigned int nrxqs;
 
-	if (priv->hw_version == MVPP22 && queue_mode == MVPP2_QDIST_SINGLE_MODE)
+	if (priv->hw_version != MVPP21 && queue_mode == MVPP2_QDIST_SINGLE_MODE)
 		return 1;
 
 	/* According to the PPv2.2 datasheet and our experiments on
@@ -459,7 +459,7 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv,
 				      MVPP2_BM_PHY_ALLOC_REG(bm_pool->id));
 	*phys_addr = mvpp2_thread_read(priv, thread, MVPP2_BM_VIRT_ALLOC_REG);
 
-	if (priv->hw_version == MVPP22) {
+	if (priv->hw_version != MVPP21) {
 		u32 val;
 		u32 dma_addr_highbits, phys_addr_highbits;
 
@@ -755,7 +755,7 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
 	if (test_bit(thread, &port->priv->lock_map))
 		spin_lock_irqsave(&port->bm_lock[thread], flags);
 
-	if (port->priv->hw_version == MVPP22) {
+	if (port->priv->hw_version != MVPP21) {
 		u32 val = 0;
 
 		if (sizeof(dma_addr_t) == 8)
@@ -1212,7 +1212,7 @@ static bool mvpp2_port_supports_xlg(struct mvpp2_port *port)
 
 static bool mvpp2_port_supports_rgmii(struct mvpp2_port *port)
 {
-	return !(port->priv->hw_version == MVPP22 && port->gop_id == 0);
+	return !(port->priv->hw_version != MVPP21 && port->gop_id == 0);
 }
 
 /* Port configuration routines */
@@ -1830,7 +1830,7 @@ static void mvpp2_mac_reset_assert(struct mvpp2_port *port)
 	      MVPP2_GMAC_PORT_RESET_MASK;
 	writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
 
-	if (port->priv->hw_version == MVPP22 && port->gop_id == 0) {
+	if (port->priv->hw_version != MVPP21 && port->gop_id == 0) {
 		val = readl(port->base + MVPP22_XLG_CTRL0_REG) &
 		      ~MVPP22_XLG_CTRL0_MAC_RESET_DIS;
 		writel(val, port->base + MVPP22_XLG_CTRL0_REG);
@@ -1843,7 +1843,7 @@ static void mvpp22_pcs_reset_assert(struct mvpp2_port *port)
 	void __iomem *mpcs, *xpcs;
 	u32 val;
 
-	if (port->priv->hw_version != MVPP22 || port->gop_id != 0)
+	if (port->priv->hw_version == MVPP21 || port->gop_id != 0)
 		return;
 
 	mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id);
@@ -1864,7 +1864,7 @@ static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port)
 	void __iomem *mpcs, *xpcs;
 	u32 val;
 
-	if (port->priv->hw_version != MVPP22 || port->gop_id != 0)
+	if (port->priv->hw_version == MVPP21 || port->gop_id != 0)
 		return;
 
 	mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id);
@@ -4201,7 +4201,7 @@ static void mvpp2_start_dev(struct mvpp2_port *port)
 	/* Enable interrupts on all threads */
 	mvpp2_interrupts_enable(port);
 
-	if (port->priv->hw_version == MVPP22)
+	if (port->priv->hw_version != MVPP21)
 		mvpp22_mode_reconfigure(port);
 
 	if (port->phylink) {
@@ -4417,7 +4417,7 @@ static int mvpp2_open(struct net_device *dev)
 		valid = true;
 	}
 
-	if (priv->hw_version == MVPP22 && port->port_irq) {
+	if (priv->hw_version != MVPP21 && port->port_irq) {
 		err = request_irq(port->port_irq, mvpp2_port_isr, 0,
 				  dev->name, port);
 		if (err) {
@@ -6065,7 +6065,7 @@ static int mvpp2__mac_prepare(struct phylink_config *config, unsigned int mode,
 			     MVPP2_GMAC_PORT_RESET_MASK,
 			     MVPP2_GMAC_PORT_RESET_MASK);
 
-		if (port->priv->hw_version == MVPP22) {
+		if (port->priv->hw_version != MVPP21) {
 			mvpp22_gop_mask_irq(port);
 
 			phy_power_off(port->comphy);
@@ -6119,7 +6119,7 @@ static int mvpp2_mac_finish(struct phylink_config *config, unsigned int mode,
 {
 	struct mvpp2_port *port = mvpp2_phylink_to_port(config);
 
-	if (port->priv->hw_version == MVPP22 &&
+	if (port->priv->hw_version != MVPP21 &&
 	    port->phy_interface != interface) {
 		port->phy_interface = interface;
 
@@ -6799,7 +6799,7 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv)
 	if (dram_target_info)
 		mvpp2_conf_mbus_windows(dram_target_info, priv);
 
-	if (priv->hw_version == MVPP22)
+	if (priv->hw_version != MVPP21)
 		mvpp2_axi_init(priv);
 
 	/* Disable HW PHY polling */
@@ -6959,7 +6959,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 			dev_warn(&pdev->dev, "Fail to alloc CM3 SRAM\n");
 	}
 
-	if (priv->hw_version == MVPP22 && dev_of_node(&pdev->dev)) {
+	if (priv->hw_version != MVPP21 && dev_of_node(&pdev->dev)) {
 		priv->sysctrl_base =
 			syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
 							"marvell,system-controller");
@@ -6972,7 +6972,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 			priv->sysctrl_base = NULL;
 	}
 
-	if (priv->hw_version == MVPP22 &&
+	if (priv->hw_version != MVPP21 &&
 	    mvpp2_get_nrxqs(priv) * 2 <= MVPP2_BM_MAX_POOLS)
 		priv->percpu_pools = 1;
 
@@ -7019,7 +7019,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 		if (err < 0)
 			goto err_pp_clk;
 
-		if (priv->hw_version == MVPP22) {
+		if (priv->hw_version != MVPP21) {
 			priv->mg_clk = devm_clk_get(&pdev->dev, "mg_clk");
 			if (IS_ERR(priv->mg_clk)) {
 				err = PTR_ERR(priv->mg_clk);
@@ -7060,7 +7060,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (priv->hw_version == MVPP22) {
+	if (priv->hw_version != MVPP21) {
 		err = dma_set_mask(&pdev->dev, MVPP2_DESC_DMA_MASK);
 		if (err)
 			goto err_axi_clk;
@@ -7140,10 +7140,10 @@ static int mvpp2_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->axi_clk);
 
 err_mg_core_clk:
-	if (priv->hw_version == MVPP22)
+	if (priv->hw_version != MVPP21)
 		clk_disable_unprepare(priv->mg_core_clk);
 err_mg_clk:
-	if (priv->hw_version == MVPP22)
+	if (priv->hw_version != MVPP21)
 		clk_disable_unprepare(priv->mg_clk);
 err_gop_clk:
 	clk_disable_unprepare(priv->gop_clk);
Signature · 1 line
1.9.1
#15 lore raw

RFC PATCH v2 6/18 net: mvpp2: increase BM pool size to 2048 buffers

In reply to [email protected]

From: Stefan Chulski <[email protected]>

BM pool size increased to support Firmware Flow Control. Minimum depletion thresholds to support FC is 1024 buffers. BM pool size increased to 2048 to have some 1024 buffers space between depletion thresholds and BM pool size.

Jumbo frames require a 9888B buffer, so memory requirements for data buffers increased from 7MB to 24MB.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +2 -2
index 89b3ede..8dc669d 100644
@@ -851,8 +851,8 @@ enum mvpp22_ptp_packet_format {
 #define MVPP22_PTP_TIMESTAMPQUEUESELECT	BIT(18)
 
 /* BM constants */
-#define MVPP2_BM_JUMBO_BUF_NUM		512
-#define MVPP2_BM_LONG_BUF_NUM		1024
+#define MVPP2_BM_JUMBO_BUF_NUM		2048
+#define MVPP2_BM_LONG_BUF_NUM		2048
 #define MVPP2_BM_SHORT_BUF_NUM		2048
 #define MVPP2_BM_POOL_SIZE_MAX		(16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4)
 #define MVPP2_BM_POOL_PTR_ALIGN		128
Signature · 1 line
1.9.1
#16 lore raw

RFC PATCH v2 7/18 net: mvpp2: increase RXQ size to 1024 descriptors

In reply to [email protected]

From: Stefan Chulski <[email protected]>

RXQ size increased to support Firmware Flow Control. Minimum depletion thresholds to support FC is 1024 buffers. Default set to 1024 descriptors and maximum size to 2048.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +2 -2
index 8dc669d..cac9885 100644
@@ -715,8 +715,8 @@
 #define MVPP2_PORT_MAX_RXQ		32
 
 /* Max number of Rx descriptors */
-#define MVPP2_MAX_RXD_MAX		1024
-#define MVPP2_MAX_RXD_DFLT		128
+#define MVPP2_MAX_RXD_MAX		2048
+#define MVPP2_MAX_RXD_DFLT		1024
 
 /* Max number of Tx descriptors */
 #define MVPP2_MAX_TXD_MAX		2048
Signature · 1 line
1.9.1
#17 lore raw

RFC PATCH v2 8/18 net: mvpp2: add FCA periodic timer configurations

In reply to [email protected]

From: Stefan Chulski <[email protected]>

Flow Control periodic timer would be used if port in XOFF to transmit periodic XOFF frames.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 13 +++++-
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 45 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +12 -1
index cac9885..0861c0b 100644
@@ -596,6 +596,15 @@
 #define     MVPP22_MPCS_CLK_RESET_DIV_RATIO(n)	((n) << 4)
 #define     MVPP22_MPCS_CLK_RESET_DIV_SET	BIT(11)
 
+/* FCA registers. PPv2.2 and PPv2.3 */
+#define MVPP22_FCA_BASE(port)			(0x7600 + (port) * 0x1000)
+#define MVPP22_FCA_REG_SIZE			16
+#define MVPP22_FCA_REG_MASK			0xFFFF
+#define MVPP22_FCA_CONTROL_REG			0x0
+#define MVPP22_FCA_ENABLE_PERIODIC		BIT(11)
+#define MVPP22_PERIODIC_COUNTER_LSB_REG		(0x110)
+#define MVPP22_PERIODIC_COUNTER_MSB_REG		(0x114)
+
 /* XPCS registers. PPv2.2 and PPv2.3 */
 #define MVPP22_XPCS_BASE(port)			(0x7400 + (port) * 0x1000)
 #define MVPP22_XPCS_CFG0			0x0
@@ -752,7 +761,9 @@
 		((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
 
 /* MSS Flow control */
-#define MSS_SRAM_SIZE	0x800
+#define MSS_SRAM_SIZE		0x800
+#define FC_QUANTA		0xFFFF
+#define FC_CLK_DIVIDER		0x140
 
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +45 -0

57 lines not on this page · raw message

Signature · 1 line
1.9.1
#18 lore raw

Re: [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations

Quoted 2 lines · On Sun, Jan 24, 2021 at 01:43:57PM +0200, [email protected] wrote:

+/* Set Flow Control timer x140 faster than pause quanta to ensure that link
+ * partner won't send taffic if port in XOFF mode.

Can you explain more why 140 times faster is desirable here? Why 140 times and not, say, 10 times faster? Where does this figure come from, and what is the reasoning? Is there a switch that requires it?

Also, spelling "traffic".

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#19 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations

Quoted 10 lines

----------------------------------------------------------------------

Review

Quoted 3 lines · On Sun, Jan 24, 2021 at 01:43:57PM +0200, [email protected] wrote:
(quoted diff) +3 -0
+/* Set Flow Control timer x140 faster than pause quanta to ensure
+that link
+ * partner won't send taffic if port in XOFF mode.

Can you explain more why 140 times faster is desirable here? Why 140 times and not, say, 10 times faster? Where does this figure come from, and what is the reasoning? Is there a switch that requires it?

I tested with 140.
Actually regarding to spec each quanta should be equal to 512 bit times. In 10G bit time is 0.1ns.
So It actually should be:
FC_CLK_DIVIDER = 10000 / 512 = ~20. I took some buffer and made it 140. So maybe I can do it 100?

Regards,
Stefan.

maintainer
#20 lore raw

Re: [EXT] Re: [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations

Quoted 11 lines · Stefan Chulski
Quoted 10 lines

----------------------------------------------------------------------

Review

Quoted 3 lines · On Sun, Jan 24, 2021 at 01:43:57PM +0200, [email protected] wrote:
(quoted diff) +3 -0
+/* Set Flow Control timer x140 faster than pause quanta to ensure
+that link
+ * partner won't send taffic if port in XOFF mode.

Can you explain more why 140 times faster is desirable here? Why 140 times and not, say, 10 times faster? Where does this figure come from, and what is the reasoning? Is there a switch that requires it?

Quoted 3 lines

I tested with 140.
Actually regarding to spec each quanta should be equal to 512 bit times. In 10G bit time is 0.1ns.

And if the link has been negotiated to 10Mbps? Or is the clock already scaled to the link speed?

Andrew

#21 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

--------------------------------------------------------------------
-- On Sun, Jan 24, 2021 at 01:43:57PM +0200, [email protected]

Review

Quoted 3 lines · wrote:
(quoted diff) +3 -0
+/* Set Flow Control timer x140 faster than pause quanta to ensure
+that link
+ * partner won't send taffic if port in XOFF mode.

Can you explain more why 140 times faster is desirable here? Why 140 times and not, say, 10 times faster? Where does this figure come from, and what is the reasoning? Is there a switch that requires it?

Quoted 8 lines
Quoted 3 lines

I tested with 140.
Actually regarding to spec each quanta should be equal to 512 bit times. In 10G bit time is 0.1ns.

And if the link has been negotiated to 10Mbps? Or is the clock already scaled to the link speed?

Andrew

Currently its static, probably I can add function that reconfigure timer during runtime(based on link speed). Should it be part of this series or add it afterwards?

Regards,
Stefan.

#22 lore raw

RFC PATCH v2 9/18 net: mvpp2: add FCA RXQ non occupied descriptor threshold

In reply to [email protected]

From: Stefan Chulski <[email protected]>

RXQ non occupied descriptor threshold would be used by Flow Control Firmware feature to move to the XOFF mode. RXQ non occupied threshold would change interrupt cause that polled by CM3 Firmware.
Actual non occupied interrupt masked and won't trigger interrupt.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  3 ++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 29 ++++++++++++++++++++
 2 files changed, 32 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +3 -0
index 0861c0b..3df8f60 100644
@@ -295,6 +295,8 @@
 #define     MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK	0x3fc00000
 #define     MVPP2_PON_CAUSE_MISC_SUM_MASK		BIT(31)
 #define MVPP2_ISR_MISC_CAUSE_REG		0x55b0
+#define MVPP2_ISR_RX_ERR_CAUSE_REG(port)	(0x5520 + 4 * (port))
+#define	    MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK	0x00ff
 
 /* Buffer Manager registers */
 #define MVPP2_BM_POOL_BASE_REG(pool)		(0x6000 + ((pool) * 4))
@@ -764,6 +766,7 @@
 #define MSS_SRAM_SIZE		0x800
 #define FC_QUANTA		0xFFFF
 #define FC_CLK_DIVIDER		0x140
+#define MSS_THRESHOLD_STOP    768
 
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +29 -0
index 9d69752..0f5069f 100644
@@ -1154,6 +1154,9 @@ static void mvpp2_interrupts_mask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);
 }
 
 /* Unmask the current thread's Rx/Tx interrupts.
@@ -1177,6 +1180,10 @@ static void mvpp2_interrupts_unmask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), val);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id),
+			   MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK);
 }
 
 static void
@@ -1201,6 +1208,9 @@ static void mvpp2_interrupts_unmask(void *arg)
 
 		mvpp2_thread_write(port->priv, v->sw_thread_id,
 				   MVPP2_ISR_RX_TX_MASK_REG(port->id), val);
+		mvpp2_thread_write(port->priv, v->sw_thread_id,
+				   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id),
+				   MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK);
 	}
 }
 
@@ -2406,6 +2416,22 @@ static void mvpp2_txp_max_tx_size_set(struct mvpp2_port *port)
 	}
 }
 
+/* Routine set the number of non-occupied descriptors threshold that change
+ * interrupt error cause polled by FW Flow Control
+ */
+static void mvpp2_set_rxq_free_tresh(struct mvpp2_port *port,
+				     struct mvpp2_rx_queue *rxq)
+{
+	u32 val;
+
+	mvpp2_write(port->priv, MVPP2_RXQ_NUM_REG, rxq->id);
+
+	val = mvpp2_read(port->priv, MVPP2_RXQ_THRESH_REG);
+	val &= ~MVPP2_RXQ_NON_OCCUPIED_MASK;
+	val |= MSS_THRESHOLD_STOP << MVPP2_RXQ_NON_OCCUPIED_OFFSET;
+	mvpp2_write(port->priv, MVPP2_RXQ_THRESH_REG, val);
+}
+
 /* Set the number of packets that will be received before Rx interrupt
  * will be generated by HW.
  */
@@ -2661,6 +2687,9 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
 	mvpp2_rx_pkts_coal_set(port, rxq);
 	mvpp2_rx_time_coal_set(port, rxq);
 
+	/* Set the number of non occupied descriptors threshold */
+	mvpp2_set_rxq_free_tresh(port, rxq);
+
 	/* Add number of descriptors ready for receiving packets */
 	mvpp2_rxq_status_update(port, rxq->id, 0, rxq->size);
 
Signature · 1 line
1.9.1
#23 lore raw

Re: [PATCH v2 RFC net-next 09/18] net: mvpp2: add FCA RXQ non occupied descriptor threshold

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_interrupts_mask(void *arg) · line 1159

Quoted 11 lines · On Sun, Jan 24, 2021 at 01:43:58PM +0200, [email protected] wrote:
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +3 -0
index 9d69752..0f5069f 100644
@@ -1154,6 +1154,9 @@ static void mvpp2_interrupts_mask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);

I wonder if this should be refactored:

	u32 thread = mvpp2_cpu_to_thread(port->priv, smp_processor_id());

	mvpp2_thread_write(port->priv, thread,
			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
	mvpp2_thread_write(port->priv, thread,
			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);

to avoid having to recompute mvpp2_cpu_to_thread() for each write?

However, looking deeper...

static void mvpp2_interrupts_mask(void *arg)

{
	struct mvpp2_port *port = arg;
	u32 thread;
	int cpu;

	cpu = smp_processor_id();
	if (cpu > port->priv->nthreads)
		return

	thread = mvpp2_cpu_to_thread(port->priv, cpu);
	...

and I wonder about that condition - "cpu > port->priv->nthreads". If cpu == port->priv->nthreads, then mvpp2_cpu_to_thread() will return zero, just like the cpu=0 case. This leads me to suspect that this comparison off by one.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#24 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 09/18] net: mvpp2: add FCA RXQ non occupied descriptor threshold

Quoted 38 lines

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_interrupts_mask(void *arg) · line 1155

Quoted 5 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +0 -0
@@ -1154,6 +1154,9 @@ static void mvpp2_interrupts_mask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv,

smp_processor_id()),

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_interrupts_mask(void *arg)

Quoted 3 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv,

smp_processor_id()),

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_interrupts_mask(void *arg) · line 1159

Quoted 1 line
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);

I wonder if this should be refactored:

	u32 thread = mvpp2_cpu_to_thread(port->priv,

smp_processor_id());

	mvpp2_thread_write(port->priv, thread,
			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
	mvpp2_thread_write(port->priv, thread,
			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);

to avoid having to recompute mvpp2_cpu_to_thread() for each write?

However, looking deeper...

static void mvpp2_interrupts_mask(void *arg) {
	struct mvpp2_port *port = arg;
	u32 thread;
	int cpu;

	cpu = smp_processor_id();
	if (cpu > port->priv->nthreads)
		return

	thread = mvpp2_cpu_to_thread(port->priv, cpu);
	...
Quoted 3 lines

and I wonder about that condition - "cpu > port->priv->nthreads". If cpu == port->priv->nthreads, then mvpp2_cpu_to_thread() will return zero, just like the cpu=0 case. This leads me to suspect that this comparison off by one.

I can push patch that make it if (cpu => port->priv->nthreads). Or even remove this if.
Anyway on current Armada platforms we have only 4 CPU's and maximum 9 PPv2 threads(nthreads is min between num_present_cpus and maximum HW PPv2 threads), so this would be always false.

Regards,
Stefan.

#25 lore raw

RFC PATCH v2 10/18 net: mvpp2: add spinlock for FW FCA configuration path

In reply to [email protected]

From: Stefan Chulski <[email protected]>

Spinlock added to MSS shared memory configuration space.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 5 +++++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 +++
 2 files changed, 8 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +5 -0
index 3df8f60..4d58af6 100644
@@ -1021,6 +1021,11 @@ struct mvpp2 {
 
 	/* CM3 SRAM pool */
 	struct gen_pool *sram_pool;
+
+	bool custom_dma_mask;
+
+	/* Spinlocks for CM3 shared memory configuration */
+	spinlock_t mss_spinlock;
 };
 
 struct mvpp2_pcpu_stats {
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +3 -0
index 0f5069f..32c79c50 100644
@@ -7159,6 +7159,9 @@ static int mvpp2_probe(struct platform_device *pdev)
 			priv->hw_version = MVPP23;
 	}
 
+	/* Init mss lock */
+	spin_lock_init(&priv->mss_spinlock);
+
 	/* Initialize network controller */
 	err = mvpp2_init(pdev, priv);
 	if (err < 0) {
Signature · 1 line
1.9.1
#26 lore raw

RFC PATCH v2 11/18 net: mvpp2: enable global flow control

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch enables global flow control in FW and in the phylink validate mask.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  3 +++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +3 -0
index 4d58af6..4c8e422 100644
@@ -1022,6 +1022,9 @@ struct mvpp2 {
 	/* CM3 SRAM pool */
 	struct gen_pool *sram_pool;
 
+	/* Global TX Flow Control config */
+	bool global_tx_fc;
+
 	bool custom_dma_mask;
 
 	/* Spinlocks for CM3 shared memory configuration */
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +19 -1
index 32c79c50..d79c687 100644
@@ -5962,6 +5962,11 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
 	phylink_set(mask, Autoneg);
 	phylink_set_port_modes(mask);
 
+	if (port->priv->global_tx_fc) {
+		phylink_set(mask, Pause);
+		phylink_set(mask, Asym_Pause);
+	}
+
 	switch (state->interface) {
 	case PHY_INTERFACE_MODE_10GBASER:
 	case PHY_INTERFACE_MODE_XAUI:
@@ -6977,7 +6982,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *base;
 	int i, shared;
-	int err;
+	int err, val;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -7031,6 +7036,10 @@ static int mvpp2_probe(struct platform_device *pdev)
 			return err;
 		else if (err)
 			dev_warn(&pdev->dev, "Fail to alloc CM3 SRAM\n");
+
+		/* Enable global Flow Control only if handler to SRAM not NULL */
+		if (priv->cm3_base)
+			priv->global_tx_fc = true;
 	}
 
 	if (priv->hw_version != MVPP21 && dev_of_node(&pdev->dev)) {
@@ -7201,6 +7210,15 @@ static int mvpp2_probe(struct platform_device *pdev)
 		goto err_port_probe;
 	}
 
+	/* Enable global flow control. In this stage global
+	 * flow control enabled, but still disabled per port.
+	 */
+	if (priv->global_tx_fc && priv->hw_version != MVPP21) {
+		val = mvpp2_cm3_read(priv, MSS_FC_COM_REG);
+		val |= FLOW_CONTROL_ENABLE_BIT;
+		mvpp2_cm3_write(priv, MSS_FC_COM_REG, val);
+	}
+
 	mvpp2_dbgfs_init(priv, pdev->name);
 
 	platform_set_drvdata(pdev, priv);
Signature · 1 line
1.9.1
#27 lore raw

RFC PATCH v2 12/18 net: mvpp2: add RXQ flow control configurations

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch add RXQ flow control configurations. Patch do not enable flow control itself, flow control disabled by default.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  40 ++++++-
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 111 ++++++++++++++++++++
 2 files changed, 147 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +36 -4
index 4c8e422..ba57465 100644
@@ -763,10 +763,39 @@
 		((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
 
 /* MSS Flow control */
-#define MSS_SRAM_SIZE		0x800
-#define FC_QUANTA		0xFFFF
-#define FC_CLK_DIVIDER		0x140
-#define MSS_THRESHOLD_STOP    768
+#define MSS_SRAM_SIZE			0x800
+#define MSS_FC_COM_REG			0
+#define FLOW_CONTROL_ENABLE_BIT		BIT(0)
+#define FLOW_CONTROL_UPDATE_COMMAND_BIT	BIT(31)
+#define FC_QUANTA			0xFFFF
+#define FC_CLK_DIVIDER			0x140
+
+#define MSS_RXQ_TRESH_BASE		0x200
+#define MSS_RXQ_TRESH_OFFS		4
+#define MSS_RXQ_TRESH_REG(q, fq)	(MSS_RXQ_TRESH_BASE + (((q) + (fq)) \
+					* MSS_RXQ_TRESH_OFFS))
+
+#define MSS_RXQ_TRESH_START_MASK	0xFFFF
+#define MSS_RXQ_TRESH_STOP_MASK		(0xFFFF << MSS_RXQ_TRESH_STOP_OFFS)
+#define MSS_RXQ_TRESH_STOP_OFFS		16
+
+#define MSS_RXQ_ASS_BASE	0x80
+#define MSS_RXQ_ASS_OFFS	4
+#define MSS_RXQ_ASS_PER_REG	4
+#define MSS_RXQ_ASS_PER_OFFS	8
+#define MSS_RXQ_ASS_PORTID_OFFS	0
+#define MSS_RXQ_ASS_PORTID_MASK	0x3
+#define MSS_RXQ_ASS_HOSTID_OFFS	2
+#define MSS_RXQ_ASS_HOSTID_MASK	0x3F
+
+#define MSS_RXQ_ASS_Q_BASE(q, fq) ((((q) + (fq)) % MSS_RXQ_ASS_PER_REG)	 \
+				  * MSS_RXQ_ASS_PER_OFFS)
+#define MSS_RXQ_ASS_PQ_BASE(q, fq) ((((q) + (fq)) / MSS_RXQ_ASS_PER_REG) \
+				   * MSS_RXQ_ASS_OFFS)
+#define MSS_RXQ_ASS_REG(q, fq) (MSS_RXQ_ASS_BASE + MSS_RXQ_ASS_PQ_BASE(q, fq))
+
+#define MSS_THRESHOLD_STOP	768
+#define MSS_THRESHOLD_START	1024
 
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
@@ -1191,6 +1220,9 @@ struct mvpp2_port {
 	bool rx_hwtstamp;
 	enum hwtstamp_tx_types tx_hwtstamp_type;
 	struct mvpp2_hwtstamp_queue tx_hwtstamp_queue[2];
+
+	/* Firmware TX flow control */
+	bool tx_fc;
 };
 
 /* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +111 -0

129 lines not on this page · raw message

Signature · 1 line
1.9.1
#28 lore raw

RFC PATCH v2 13/18 net: mvpp2: add ethtool flow control configuration support

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch add ethtool flow control configuration support.

Tx flow control retrieved correctly by ethtool get function. FW per port ethtool configuration capability added.

Patch also takes care about mtu change procedure, if PPv2 switch BM pools during mtu change.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  13 +++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 106 ++++++++++++++++++++
 2 files changed, 119 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +13 -0
index ba57465..feac64c 100644
@@ -775,6 +775,19 @@
 #define MSS_RXQ_TRESH_REG(q, fq)	(MSS_RXQ_TRESH_BASE + (((q) + (fq)) \
 					* MSS_RXQ_TRESH_OFFS))
 
+#define MSS_BUF_POOL_BASE		0x40
+#define MSS_BUF_POOL_OFFS		4
+#define MSS_BUF_POOL_REG(id)		(MSS_BUF_POOL_BASE		\
+					+ (id) * MSS_BUF_POOL_OFFS)
+
+#define MSS_BUF_POOL_STOP_MASK		0xFFF
+#define MSS_BUF_POOL_START_MASK		(0xFFF << MSS_BUF_POOL_START_OFFS)
+#define MSS_BUF_POOL_START_OFFS		12
+#define MSS_BUF_POOL_PORTS_MASK		(0xF << MSS_BUF_POOL_PORTS_OFFS)
+#define MSS_BUF_POOL_PORTS_OFFS		24
+#define MSS_BUF_POOL_PORT_OFFS(id)	(0x1 <<				\
+					((id) + MSS_BUF_POOL_PORTS_OFFS))
+
 #define MSS_RXQ_TRESH_START_MASK	0xFFFF
 #define MSS_RXQ_TRESH_STOP_MASK		(0xFFFF << MSS_RXQ_TRESH_STOP_OFFS)
 #define MSS_RXQ_TRESH_STOP_OFFS		16
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +106 -0

136 lines not on this page · raw message

Signature · 1 line
1.9.1
#29 lore raw

Re: [PATCH v2 RFC net-next 13/18] net: mvpp2: add ethtool flow control configuration support

Quoted 17 lines · On Sun, Jan 24, 2021 at 01:44:02PM +0200, [email protected] wrote:
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +13 -0
@@ -6407,6 +6490,29 @@ static void mvpp2_mac_link_up(struct phylink_config *config,
 			     val);
 	}
 
+	if (tx_pause && port->priv->global_tx_fc) {
+		port->tx_fc = true;
+		mvpp2_rxq_enable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[i], true);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long, true);
+			mvpp2_bm_pool_update_fc(port, port->pool_short, true);
+		}
+
+	} else if (port->priv->global_tx_fc) {
+		port->tx_fc = false;

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_mac_link_up(struct phylink_config *config, · line 6515

Quoted 10 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +10 -0
+		mvpp2_rxq_disable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port->priv->bm_pools[i], false);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long, false);
+			mvpp2_bm_pool_update_fc(port, port->pool_short, false);
+		}
+	}
+

It seems this can be written more succinctly:

	if (port->priv->global_tx_fc) {
		port->tx_fc = tx_pause;
		if (tx_pause)
			mvpp2_rxq_enable_fc(port);
		else
			mvpp2_rxq_disable_fc(port);
		if (port->priv->percpu_pools) {
			for (i = 0; i < port->nrxqs; i++)
				mvpp2_bm_pool_update_fc(port,
						&port->priv->bm_pools[i],
						tx_pause);
		} else {
			mvpp2_bm_pool_update_fc(port, port->pool_long,
						tx_pause);
			mvpp2_bm_pool_update_fc(port, port->pool_short,
						tx_pause);
		}
	}
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#30 lore raw

RE: [EXT] Re: [PATCH v2 RFC net-next 13/18] net: mvpp2: add ethtool flow control configuration support

Quoted 50 lines

----------------------------------------------------------------------

Review static void mvpp2_mac_link_up(struct

Quoted 1 line · On Sun, Jan 24, 2021 at 01:44:02PM +0200, [email protected] wrote:
(quoted diff) +0 -0
@@ -6407,6 +6490,29 @@ static void mvpp2_mac_link_up(struct

phylink_config *config,

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_mac_link_up(struct phylink_config *config,

Quoted 12 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +8 -0
 			     val);
 	}
 
+	if (tx_pause && port->priv->global_tx_fc) {
+		port->tx_fc = true;
+		mvpp2_rxq_enable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port-
 priv->bm_pools[i], true);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long,

true);

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu) · line 1267

Quoted 1 line
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
+			mvpp2_bm_pool_update_fc(port, port->pool_short,

true);

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_mac_link_up(struct phylink_config *config,

Quoted 11 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +10 -0
+		}
+
+	} else if (port->priv->global_tx_fc) {
+		port->tx_fc = false;
+		mvpp2_rxq_disable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port-
 priv->bm_pools[i], false);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long,

false);

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu) · line 1267

Quoted 1 line
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
+			mvpp2_bm_pool_update_fc(port, port->pool_short,

false);

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c static void mvpp2_rxq_disable_fc(struct mvpp2_port *port) · line 894

Quoted 3 lines
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +3 -0
+		}
+	}
+

It seems this can be written more succinctly:

	if (port->priv->global_tx_fc) {
		port->tx_fc = tx_pause;
		if (tx_pause)
			mvpp2_rxq_enable_fc(port);
		else
			mvpp2_rxq_disable_fc(port);
		if (port->priv->percpu_pools) {
			for (i = 0; i < port->nrxqs; i++)
				mvpp2_bm_pool_update_fc(port,
						&port->priv->bm_pools[i],
Quoted 9 lines
						tx_pause);
		} else {
			mvpp2_bm_pool_update_fc(port, port->pool_long,
						tx_pause);
			mvpp2_bm_pool_update_fc(port, port->pool_short,
						tx_pause);
		}
	}

Ok, I would update.

Thanks,
Stefan.

#31 lore raw

RFC PATCH v2 14/18 net: mvpp2: add BM protection underrun feature support

In reply to [email protected]

From: Stefan Chulski <[email protected]>

Feature double size of BPPI by decreasing number of pools from 16 to 8. Increasing of BPPI size protect BM drop from BPPI underrun. Underrun could occurred due to stress on DDR and as result slow buffer transition from BPPE to BPPI.
New BPPI threshold recommended by spec is:
BPPI low threshold - 640 buffers
BPPI high threshold - 832 buffers
Supported only in PPv23.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  8 +++++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 35 +++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +8 -0
index feac64c..1db8245 100644
@@ -324,6 +324,10 @@
 #define     MVPP2_BM_HIGH_THRESH_MASK		0x7f0000
 #define     MVPP2_BM_HIGH_THRESH_VALUE(val)	((val) << \
 						MVPP2_BM_HIGH_THRESH_OFFS)
+#define     MVPP2_BM_BPPI_HIGH_THRESH		0x1E
+#define     MVPP2_BM_BPPI_LOW_THRESH		0x1C
+#define     MVPP23_BM_BPPI_HIGH_THRESH		0x34
+#define     MVPP23_BM_BPPI_LOW_THRESH		0x28
 #define MVPP2_BM_INTR_CAUSE_REG(pool)		(0x6240 + ((pool) * 4))
 #define     MVPP2_BM_RELEASED_DELAY_MASK	BIT(0)
 #define     MVPP2_BM_ALLOC_FAILED_MASK		BIT(1)
@@ -352,6 +356,10 @@
 #define MVPP2_OVERRUN_ETH_DROP			0x7000
 #define MVPP2_CLS_ETH_DROP			0x7020
 
+#define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG	0x6310
+#define     MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK	0xff
+#define     MVPP23_BM_8POOL_MODE		BIT(8)
+
 /* Hit counters registers */
 #define MVPP2_CTRS_IDX				0x7040
 #define     MVPP22_CTRS_TX_CTR(port, txq)	((txq) | ((port) << 3) | BIT(7))
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +34 -1
index 20157b5..da387dd2 100644
@@ -70,6 +70,11 @@ enum mvpp2_bm_pool_log_num {
 module_param(queue_mode, int, 0444);
 MODULE_PARM_DESC(queue_mode, "Set queue_mode (single=0, multi=1)");
 
+static int bm_underrun_protect = 1;
+
+module_param(bm_underrun_protect, int, 0444);
+MODULE_PARM_DESC(bm_underrun_protect, "Set BM underrun protect feature (0-1), def=1");
+
 /* Utility/helper methods */
 
 void mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data)
@@ -426,6 +431,21 @@ static int mvpp2_bm_pool_create(struct device *dev, struct mvpp2 *priv,
 
 	val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id));
 	val |= MVPP2_BM_START_MASK;
+
+	val &= ~MVPP2_BM_LOW_THRESH_MASK;
+	val &= ~MVPP2_BM_HIGH_THRESH_MASK;
+
+	/* Set 8 Pools BPPI threshold if BM underrun protection feature
+	 * were enabled
+	 */
+	if (priv->hw_version == MVPP23 && bm_underrun_protect) {
+		val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP23_BM_BPPI_LOW_THRESH);
+		val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP23_BM_BPPI_HIGH_THRESH);
+	} else {
+		val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP2_BM_BPPI_LOW_THRESH);
+		val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP2_BM_BPPI_HIGH_THRESH);
+	}
+
 	mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val);
 
 	bm_pool->size = size;
@@ -594,6 +614,16 @@ static int mvpp2_bm_pools_init(struct device *dev, struct mvpp2 *priv)
 	return err;
 }
 
+/* Routine enable PPv23 8 pool mode */
+static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv)
+{
+	int val;
+
+	val = mvpp2_read(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG);
+	val |= MVPP23_BM_8POOL_MODE;
+	mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val);
+}
+
 static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
 {
 	enum dma_data_direction dma_dir = DMA_FROM_DEVICE;
@@ -647,6 +677,9 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
 	if (!priv->bm_pools)
 		return -ENOMEM;
 
+	if (priv->hw_version == MVPP23 && bm_underrun_protect)
+		mvpp23_bm_set_8pool_mode(priv);
+
 	err = mvpp2_bm_pools_init(dev, priv);
 	if (err < 0)
 		return err;
@@ -6490,7 +6523,7 @@ static void mvpp2_mac_link_up(struct phylink_config *config,
 			     val);
 	}
 
-	if (tx_pause && port->priv->global_tx_fc) {
+	if (tx_pause && port->priv->global_tx_fc && bm_underrun_protect) {
 		port->tx_fc = true;
 		mvpp2_rxq_enable_fc(port);
 		if (port->priv->percpu_pools) {
Signature · 1 line
1.9.1
#32 lore raw

RFC PATCH v2 15/18 net: mvpp2: add PPv23 RX FIFO flow control

In reply to [email protected]

From: Stefan Chulski <[email protected]>

New FIFO flow control feature were added in PPv23. PPv2 FIFO polled by HW and trigger pause frame if FIFO fill level is below threshold.
FIFO HW flow control enabled with CM3 RXQ&BM flow control with ethtool.
Current FIFO thresholds is:
9KB for port with maximum speed 10Gb/s port 4KB for port with maximum speed 5Gb/s port 2KB for port with maximum speed 1Gb/s port

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      | 15 ++++++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 55 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +15 -0
index 1db8245..417cc43 100644
@@ -770,6 +770,18 @@
 #define MVPP2_TX_FIFO_THRESHOLD(kb)	\
 		((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
 
+/* RX FIFO threshold in 1KB granularity */
+#define MVPP23_PORT0_FIFO_TRSH	(9 * 1024)
+#define MVPP23_PORT1_FIFO_TRSH	(4 * 1024)
+#define MVPP23_PORT2_FIFO_TRSH	(2 * 1024)
+
+/* RX Flow Control Registers */
+#define MVPP2_RX_FC_REG(port)		(0x150 + 4 * (port))
+#define     MVPP2_RX_FC_EN		BIT(24)
+#define     MVPP2_RX_FC_TRSH_OFFS	16
+#define     MVPP2_RX_FC_TRSH_MASK	(0xFF << MVPP2_RX_FC_TRSH_OFFS)
+#define     MVPP2_RX_FC_TRSH_UNIT	256
+
 /* MSS Flow control */
 #define MSS_SRAM_SIZE			0x800
 #define MSS_FC_COM_REG			0
@@ -1504,6 +1516,8 @@ struct mvpp2_bm_pool {
 
 void mvpp2_dbgfs_cleanup(struct mvpp2 *priv);
 
+void mvpp23_rx_fifo_fc_en(struct mvpp2 *priv, int port, bool en);
+
 #ifdef CONFIG_MVPP2_PTP
 int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv);
 void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
@@ -1536,4 +1550,5 @@ static inline bool mvpp22_rx_hwtstamping(struct mvpp2_port *port)
 {
 	return IS_ENABLED(CONFIG_MVPP2_PTP) && port->rx_hwtstamp;
 }
+
 #endif
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +55 -0

79 lines not on this page · raw message

Signature · 1 line
1.9.1
#33 lore raw

RFC PATCH v2 16/18 net: mvpp2: set 802.3x GoP Flow Control mode

In reply to [email protected]

From: Stefan Chulski <[email protected]>

This patch fix GMAC TX flow control autoneg.
Flow control autoneg wrongly were disabled with enabled TX flow control.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -1
index ee4f1ff..03a4b36 100644
@@ -6283,7 +6283,7 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
 	old_ctrl4 = ctrl4 = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
 
 	ctrl0 &= ~MVPP2_GMAC_PORT_TYPE_MASK;
-	ctrl2 &= ~(MVPP2_GMAC_INBAND_AN_MASK | MVPP2_GMAC_PCS_ENABLE_MASK);
+	ctrl2 &= ~(MVPP2_GMAC_INBAND_AN_MASK | MVPP2_GMAC_PCS_ENABLE_MASK | MVPP2_GMAC_FLOW_CTRL_MASK);
 
 	/* Configure port type */
 	if (phy_interface_mode_is_8023z(state->interface)) {
Signature · 1 line
1.9.1
#34 lore raw

RFC PATCH v2 17/18 net: mvpp2: limit minimum ring size to 1024 descriptors

In reply to [email protected]

From: Stefan Chulski <[email protected]>

To support Flow Control ring size should be at least 1024 descriptors.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
index 03a4b36..f8fc682 100644
@@ -4544,6 +4544,8 @@ static int mvpp2_check_ringparam_valid(struct net_device *dev,
 
 	if (ring->rx_pending > MVPP2_MAX_RXD_MAX)
 		new_rx_pending = MVPP2_MAX_RXD_MAX;
+	else if (ring->rx_pending < MSS_THRESHOLD_START)
+		new_rx_pending = MSS_THRESHOLD_START;
 	else if (!IS_ALIGNED(ring->rx_pending, 16))
 		new_rx_pending = ALIGN(ring->rx_pending, 16);
 
Signature · 1 line
1.9.1
#35 lore raw

RFC PATCH v2 18/18 net: mvpp2: add TX FC firmware check

In reply to [email protected]

From: Stefan Chulski <[email protected]>

Patch check that TX FC firmware is running in CM3. If not, global TX FC would be disabled.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  1 +
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 41 ++++++++++++++++----
 2 files changed, 35 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +1 -0
index 417cc43..40aad0c 100644
@@ -829,6 +829,7 @@
 
 #define MSS_THRESHOLD_STOP	768
 #define MSS_THRESHOLD_START	1024
+#define MSS_FC_MAX_TIMEOUT	5000
 
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +34 -7

60 lines not on this page · raw message

Signature · 1 line
1.9.1