Commit 7ece6d21 authored by Arian van Putten's avatar Arian van Putten
Browse files

linuxPackages.ena: 2.12.1 -> 2.12.3

This now builds on 4.19 without the patch but needs a new patch for 6.10
parent 37b2df81
Loading
Loading
Loading
Loading
+0 −54
Original line number Diff line number Diff line
From 9be081925d979851298dc824f70e16f6344bdb1a Mon Sep 17 00:00:00 2001
From: Shay Agroskin <shayagr@amazon.com>
Date: Thu, 23 May 2024 10:03:11 +0300
Subject: [PATCH] [Temp fix] Allow 4.19.291 to compile eth_hw_addr_set()

This patch moves the backward compatibility check for eth_hw_addr_set()
into ECC.

Although the patch works, it might not be solution eventually release to
amzn-drivers.

Signed-off-by: Shay Agroskin <shayagr@amazon.com>
---
 kernel/linux/ena/config/test_defs.sh |  5 +++++
 kernel/linux/ena/kcompat.h           | 10 +---------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/kernel/linux/ena/config/test_defs.sh b/kernel/linux/ena/config/test_defs.sh
index 792e52ba620e..7b6be0e901fa 100755
--- a/kernel/linux/ena/config/test_defs.sh
+++ b/kernel/linux/ena/config/test_defs.sh
@@ -54,3 +54,8 @@ try_compile_async "#include <linux/ethtool.h>"           \
 		  "ENA_HAVE_ETHTOOL_RXFH_PARAM"          \
 		  ""                                     \
 		  "6.8.0 <= LINUX_VERSION_CODE"
+try_compile_async "#include <linux/etherdevice.h>"        \
+                  "eth_hw_addr_set(NULL, NULL);"          \
+                  "ENA_HAVE_ETH_HW_ADDR_SET"              \
+                  ""                                      \
+                  "5.15 <= LINUX_VERSION_CODE"
diff --git a/kernel/linux/ena/kcompat.h b/kernel/linux/ena/kcompat.h
index 32a9cc54dc2b..6d5a069804ec 100644
--- a/kernel/linux/ena/kcompat.h
+++ b/kernel/linux/ena/kcompat.h
@@ -888,15 +888,7 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 #define ENA_XDP_XMIT_FREES_FAILED_DESCS_INTERNALLY
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) && \
-	!(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 188) && \
-	 LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)) && \
-	!(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 251) && \
-	 LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0))) && \
-	!(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 6)) && \
-	!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 4)) && \
-	!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL == 3) && \
-	  ENA_KERNEL_VERSION_GTE(5, 3, 18, 150300, 59, 43))
+#ifndef ENA_HAVE_ETH_HW_ADDR_SET
 static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
 {
 	memcpy(dev->dev_addr, addr, ETH_ALEN);
-- 
2.34.1
+82 −0
Original line number Diff line number Diff line
From 4ff06a845979bd65e672ff4ab09f5310c681e13b Mon Sep 17 00:00:00 2001
From: Arthur Kiyanovski <akiyano@amazon.com>
Date: Tue, 30 Jul 2024 05:06:14 +0000
Subject: [PATCH] workaround patch for kernel 6.10

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
---
 kernel/linux/ena/config/test_defs.sh | 12 ++++++++++++
 kernel/linux/ena/ena_xdp.c           |  5 ++---
 kernel/linux/ena/kcompat.h           | 12 +++++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/kernel/linux/ena/config/test_defs.sh b/kernel/linux/ena/config/test_defs.sh
index f8951c3..0cf366b 100755
--- a/kernel/linux/ena/config/test_defs.sh
+++ b/kernel/linux/ena/config/test_defs.sh
@@ -60,3 +60,15 @@ try_compile_async "#include <linux/etherdevice.h>"       \
                   "ENA_HAVE_ETH_HW_ADDR_SET"             \
                   ""                                     \
                   "5.15.0 <= LINUX_VERSION_CODE"
+
+try_compile_async "#include <net/xdp_sock_drv.h>"        \
+                  "xsk_buff_dma_sync_for_cpu(NULL);"     \
+                  "ENA_XSK_BUFF_DMA_SYNC_SINGLE_ARG"     \
+                  ""                                     \
+                  "6.10.0 <= LINUX_VERSION_CODE"
+
+try_compile_async "#include <linux/skbuff.h>"            \
+                  "__napi_alloc_skb(NULL, 0, 0);"        \
+                  "ENA_NAPI_ALLOC_SKB_EXPLICIT_GFP_MASK" \
+                  ""                                     \
+                  "6.10.0 > LINUX_VERSION_CODE"
diff --git a/kernel/linux/ena/ena_xdp.c b/kernel/linux/ena/ena_xdp.c
index 204389f..ecbaa9f 100644
--- a/kernel/linux/ena/ena_xdp.c
+++ b/kernel/linux/ena/ena_xdp.c
@@ -746,9 +746,8 @@ static struct sk_buff *ena_xdp_rx_skb_zc(struct ena_ring *rx_ring, struct xdp_bu
 	data_addr = xdp->data;
 
 	/* allocate a skb to store the frags */
-	skb = __napi_alloc_skb(rx_ring->napi,
-			       headroom + data_len,
-			       GFP_ATOMIC | __GFP_NOWARN);
+	skb = napi_alloc_skb(rx_ring->napi,
+			     headroom + data_len);
 	if (unlikely(!skb)) {
 		ena_increase_stat(&rx_ring->rx_stats.skb_alloc_fail, 1,
 				  &rx_ring->syncp);
diff --git a/kernel/linux/ena/kcompat.h b/kernel/linux/ena/kcompat.h
index 6d5a069..7511087 100644
--- a/kernel/linux/ena/kcompat.h
+++ b/kernel/linux/ena/kcompat.h
@@ -998,10 +998,11 @@ static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)) && \
 	!(RHEL_RELEASE_CODE && \
 	(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)))
+#define ENA_KCOMAPT_NAPI_ALLOC_SKB
 static inline struct sk_buff *napi_alloc_skb(struct napi_struct *napi,
 					     unsigned int length)
 {
-	return netdev_alloc_skb_ip_align(napi->dev, length);
+	return __netdev_alloc_skb_ip_align(napi->dev, length, GFP_ATOMIC | __GFP_NOWARN);
 }
 #endif
 
@@ -1150,4 +1151,13 @@ static inline int irq_update_affinity_hint(unsigned int irq, const struct cpumas
 #define ethtool_puts ethtool_sprintf
 #endif /* ENA_HAVE_ETHTOOL_PUTS */
 
+#ifdef ENA_XSK_BUFF_DMA_SYNC_SINGLE_ARG
+#include <net/xdp_sock_drv.h>
+#define xsk_buff_dma_sync_for_cpu(xdp, xsk_pool) xsk_buff_dma_sync_for_cpu(xdp)
+#endif /* ENA_XSK_BUFF_DMA_SYNC_SINGLE_ARG */
+
+#if defined(ENA_NAPI_ALLOC_SKB_EXPLICIT_GFP_MASK) && !defined(ENA_KCOMAPT_NAPI_ALLOC_SKB)
+#define napi_alloc_skb(napi, len) __napi_alloc_skb(napi, len, GFP_ATOMIC | __GFP_NOWARN)
+#endif /* ENA_NAPI_ALLOC_SKB_EXPLICIT_GFP_MASK && !ENA_KCOMAPT_NAPI_ALLOC_SKB*/
+
 #endif /* _KCOMPAT_H_ */
-- 
2.40.1
+4 −5
Original line number Diff line number Diff line
@@ -6,14 +6,14 @@
}:

stdenv.mkDerivation rec {
  version = "2.12.1";
  version = "2.12.3";
  name = "ena-${version}-${kernel.version}";

  src = fetchFromGitHub {
    owner = "amzn";
    repo = "amzn-drivers";
    rev = "ena_linux_${version}";
    hash = "sha256-K7FcUdx5pPMtBGSqFgxhHWlg9FT6J3MhUqwGtqHzex4=";
    hash = "sha256-F8vDPPwO0PnGXhqt0EeT4m/+d8w/rjMHWRV3RYC/wVQ=";
  };

  hardeningDisable = [ "pic" ];
@@ -24,9 +24,8 @@ stdenv.mkDerivation rec {
  env.KERNEL_BUILD_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";

  patches = [
    # The eth_hw_addr_set function was backported to kernel 4.19.291 but support for it wasn't added to ENA. It will be added in a future release.
    # See https://github.com/amzn/amzn-drivers/issues/302#issuecomment-2126587626
    ./0001-Temp-fix-Allow-4.19.291-to-compile-eth_hw_addr_set.patch
    # https://github.com/amzn/amzn-drivers/issues/313
    ./0001-workaround-patch-for-kernel-6.10.patch
  ];

  configurePhase = ''