summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/cadence/macb_main.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2023-06-15 08:45:29 +0100
committerDavid S. Miller <davem@davemloft.net>2023-06-15 08:45:29 +0100
commit580b7fe5fcc430a38a0b073dbab2f94533a7ae89 (patch)
tree076f9088f2865cfbf795d58ff354d2d8b081099a /drivers/net/ethernet/cadence/macb_main.c
parent473f5e13b38b9533bd3ae0758418581eabf69b50 (diff)
parentcae4bc06b3e41bc6dfd7116a45c1006e50ffe153 (diff)
Merge branch 'macb-partial-store-and-forward'
Pranavi Somisetty says: ==================== Add support for partial store and forward Add support for partial store and forward mode in Cadence MACB. Link for v1: https://lore.kernel.org/all/20221213121245.13981-1-pranavi.somisetty@amd.com/ Changes v2: 1. Removed all the changes related to validating FCS when Rx checksum offload is disabled. 2. Instead of using a platform dependent number (0xFFF) for the reset value of rx watermark, derive it from designcfg_debug2 register. 3. Added a check to see if partial s/f is supported, by reading the designcfg_debug6 register. 4. Added devicetree bindings for "rx-watermark" property. Link for v2: https://lore.kernel.org/all/20230511071214.18611-1-pranavi.somisetty@amd.com/ Changes v3: 1. Fixed DT schema error: "scalar properties shouldn't have array keywords" 2. Modified description of rx-watermark in to include units of the watermark value 3. Modified the DT property name corresponding to rx_watermark in pbuf_rxcutthru to "cdns,rx-watermark". 4. Followed reverse christmas tree pattern in declaring variables. 5. Return -EINVAL when an invalid watermark value is set. 6. Removed netdev_info when partial store and forward is not enabled. 7. Validating the rx-watermark value in probe itself and only write to the register in init. 8. Writing a reset value to the pbuf_cuthru register before disabing partial store and forward is redundant. So removing it. 9. Removed the platform caps flag. 10. Instead of reading rx-watermark from DT in macb_configure_caps, reading it in probe. 11. Changed Signed-Off-By and author names on the macb driver patch. Link for v3: https://lore.kernel.org/all/20230530095138.1302-1-pranavi.somisetty@amd.com/ Changes v4: 1. Modified description for "rx-watermark" property in the DT bindings. 2. Changed the width of the rx-watermark property to uint32. 3. Removed redundant code and unused variables. 4. When the rx-watermark value is invalid, instead of returning EINVAL, do not enable partial store and forward. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cadence/macb_main.c')
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 50a4b04315e9..2e35e200fdcb 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2635,6 +2635,9 @@ static void macb_reset_hw(struct macb *bp)
macb_writel(bp, TSR, -1);
macb_writel(bp, RSR, -1);
+ /* Disable RX partial store and forward and reset watermark value */
+ gem_writel(bp, PBUFRXCUT, 0);
+
/* Disable all interrupts */
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
queue_writel(queue, IDR, -1);
@@ -2792,6 +2795,10 @@ static void macb_init_hw(struct macb *bp)
bp->rx_frm_len_mask = MACB_RX_JFRMLEN_MASK;
macb_configure_dma(bp);
+
+ /* Enable RX partial store and forward and set watermark */
+ if (bp->rx_watermark)
+ gem_writel(bp, PBUFRXCUT, (bp->rx_watermark | GEM_BIT(ENCUTTHRU)));
}
/* The hash address register is 64 bits long and takes up two
@@ -4946,6 +4953,7 @@ static int macb_probe(struct platform_device *pdev)
phy_interface_t interface;
struct net_device *dev;
struct resource *regs;
+ u32 wtrmrk_rst_val;
void __iomem *mem;
struct macb *bp;
int err, val;
@@ -5025,6 +5033,25 @@ static int macb_probe(struct platform_device *pdev)
bp->usrio = macb_config->usrio;
+ /* By default we set to partial store and forward mode for zynqmp.
+ * Disable if not set in devicetree.
+ */
+ if (GEM_BFEXT(PBUF_CUTTHRU, gem_readl(bp, DCFG6))) {
+ err = of_property_read_u32(bp->pdev->dev.of_node,
+ "cdns,rx-watermark",
+ &bp->rx_watermark);
+
+ if (!err) {
+ /* Disable partial store and forward in case of error or
+ * invalid watermark value
+ */
+ wtrmrk_rst_val = (1 << (GEM_BFEXT(RX_PBUF_ADDR, gem_readl(bp, DCFG2)))) - 1;
+ if (bp->rx_watermark > wtrmrk_rst_val || !bp->rx_watermark) {
+ dev_info(&bp->pdev->dev, "Invalid watermark value\n");
+ bp->rx_watermark = 0;
+ }
+ }
+ }
spin_lock_init(&bp->lock);
/* setup capabilities */