Skip to content

Commit 44efc78

Browse files
LorenzoBianconidavem330
authored andcommitted
net: mvneta: fix XDP support if sw bm is used as fallback
In order to fix XDP support if sw buffer management is used as fallback for hw bm devices, define MVNETA_SKB_HEADROOM as maximum between XDP_PACKET_HEADROOM and NET_SKB_PAD and let the hw aligns the IP header to 4-byte boundary. Fix rx_offset_correction initialization if mvneta_bm_port_init fails in mvneta_resume routine Fixes: 0db51da ("net: mvneta: add basic XDP support") Tested-by: Sven Auhagen <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 793da4b commit 44efc78

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@
324324
ETH_HLEN + ETH_FCS_LEN, \
325325
cache_line_size())
326326

327-
#define MVNETA_SKB_HEADROOM (max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + \
328-
NET_IP_ALIGN)
327+
#define MVNETA_SKB_HEADROOM max(XDP_PACKET_HEADROOM, NET_SKB_PAD)
329328
#define MVNETA_SKB_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info) + \
330329
MVNETA_SKB_HEADROOM))
331330
#define MVNETA_SKB_SIZE(len) (SKB_DATA_ALIGN(len) + MVNETA_SKB_PAD)
@@ -1167,6 +1166,7 @@ static void mvneta_bm_update_mtu(struct mvneta_port *pp, int mtu)
11671166
mvneta_bm_pool_destroy(pp->bm_priv, pp->pool_short, 1 << pp->id);
11681167

11691168
pp->bm_priv = NULL;
1169+
pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
11701170
mvreg_write(pp, MVNETA_ACC_MODE, MVNETA_ACC_MODE_EXT1);
11711171
netdev_info(pp->dev, "fail to update MTU, fall back to software BM\n");
11721172
}
@@ -4948,7 +4948,6 @@ static int mvneta_probe(struct platform_device *pdev)
49484948
SET_NETDEV_DEV(dev, &pdev->dev);
49494949

49504950
pp->id = global_port_id++;
4951-
pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
49524951

49534952
/* Obtain access to BM resources if enabled and already initialized */
49544953
bm_node = of_parse_phandle(dn, "buffer-manager", 0);
@@ -4973,6 +4972,10 @@ static int mvneta_probe(struct platform_device *pdev)
49734972
}
49744973
of_node_put(bm_node);
49754974

4975+
/* sw buffer management */
4976+
if (!pp->bm_priv)
4977+
pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
4978+
49764979
err = mvneta_init(&pdev->dev, pp);
49774980
if (err < 0)
49784981
goto err_netdev;
@@ -5130,6 +5133,7 @@ static int mvneta_resume(struct device *device)
51305133
err = mvneta_bm_port_init(pdev, pp);
51315134
if (err < 0) {
51325135
dev_info(&pdev->dev, "use SW buffer management\n");
5136+
pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
51335137
pp->bm_priv = NULL;
51345138
}
51355139
}

0 commit comments

Comments
 (0)