023-net-mvneta-fix-XDP-support-if-sw-bm-is-used-as-fallb.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 44efc78d0e464ce70b45b165c005f8bedc17952e Mon Sep 17 00:00:00 2001
  2. From: Lorenzo Bianconi <[email protected]>
  3. Date: Wed, 29 Jan 2020 12:50:53 +0100
  4. Subject: [PATCH] net: mvneta: fix XDP support if sw bm is used as fallback
  5. In order to fix XDP support if sw buffer management is used as fallback
  6. for hw bm devices, define MVNETA_SKB_HEADROOM as maximum between
  7. XDP_PACKET_HEADROOM and NET_SKB_PAD and let the hw aligns the IP header
  8. to 4-byte boundary.
  9. Fix rx_offset_correction initialization if mvneta_bm_port_init fails in
  10. mvneta_resume routine
  11. Fixes: 0db51da7a8e9 ("net: mvneta: add basic XDP support")
  12. Tested-by: Sven Auhagen <[email protected]>
  13. Signed-off-by: Lorenzo Bianconi <[email protected]>
  14. Signed-off-by: David S. Miller <[email protected]>
  15. ---
  16. drivers/net/ethernet/marvell/mvneta.c | 10 +++++++---
  17. 1 file changed, 7 insertions(+), 3 deletions(-)
  18. --- a/drivers/net/ethernet/marvell/mvneta.c
  19. +++ b/drivers/net/ethernet/marvell/mvneta.c
  20. @@ -326,8 +326,7 @@
  21. ETH_HLEN + ETH_FCS_LEN, \
  22. cache_line_size())
  23. -#define MVNETA_SKB_HEADROOM (max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + \
  24. - NET_IP_ALIGN)
  25. +#define MVNETA_SKB_HEADROOM max(XDP_PACKET_HEADROOM, NET_SKB_PAD)
  26. #define MVNETA_SKB_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info) + \
  27. MVNETA_SKB_HEADROOM))
  28. #define MVNETA_SKB_SIZE(len) (SKB_DATA_ALIGN(len) + MVNETA_SKB_PAD)
  29. @@ -1174,6 +1173,7 @@ bm_mtu_err:
  30. mvneta_bm_pool_destroy(pp->bm_priv, pp->pool_short, 1 << pp->id);
  31. pp->bm_priv = NULL;
  32. + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
  33. mvreg_write(pp, MVNETA_ACC_MODE, MVNETA_ACC_MODE_EXT1);
  34. netdev_info(pp->dev, "fail to update MTU, fall back to software BM\n");
  35. }
  36. @@ -4976,7 +4976,6 @@ static int mvneta_probe(struct platform_
  37. SET_NETDEV_DEV(dev, &pdev->dev);
  38. pp->id = global_port_id++;
  39. - pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
  40. /* Obtain access to BM resources if enabled and already initialized */
  41. bm_node = of_parse_phandle(dn, "buffer-manager", 0);
  42. @@ -5001,6 +5000,10 @@ static int mvneta_probe(struct platform_
  43. }
  44. of_node_put(bm_node);
  45. + /* sw buffer management */
  46. + if (!pp->bm_priv)
  47. + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
  48. +
  49. err = mvneta_init(&pdev->dev, pp);
  50. if (err < 0)
  51. goto err_netdev;
  52. @@ -5154,6 +5157,7 @@ static int mvneta_resume(struct device *
  53. err = mvneta_bm_port_init(pdev, pp);
  54. if (err < 0) {
  55. dev_info(&pdev->dev, "use SW buffer management\n");
  56. + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
  57. pp->bm_priv = NULL;
  58. }
  59. }