diff options
Diffstat (limited to 'pkgs/os-specific/linux/ena')
-rw-r--r-- | pkgs/os-specific/linux/ena/0001-workaround-patch-for-kernel-6.10.patch | 82 | ||||
-rw-r--r-- | pkgs/os-specific/linux/ena/default.nix | 25 |
2 files changed, 100 insertions, 7 deletions
diff --git a/pkgs/os-specific/linux/ena/0001-workaround-patch-for-kernel-6.10.patch b/pkgs/os-specific/linux/ena/0001-workaround-patch-for-kernel-6.10.patch new file mode 100644 index 0000000000000..ae684d9be2340 --- /dev/null +++ b/pkgs/os-specific/linux/ena/0001-workaround-patch-for-kernel-6.10.patch @@ -0,0 +1,82 @@ +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 + diff --git a/pkgs/os-specific/linux/ena/default.nix b/pkgs/os-specific/linux/ena/default.nix index b6ed869a71f52..90167977cf5cd 100644 --- a/pkgs/os-specific/linux/ena/default.nix +++ b/pkgs/os-specific/linux/ena/default.nix @@ -1,14 +1,19 @@ -{ lib, stdenv, fetchFromGitHub, kernel }: +{ + lib, + stdenv, + fetchFromGitHub, + kernel, +}: stdenv.mkDerivation rec { - version = "2.8.9"; + version = "2.12.3"; name = "ena-${version}-${kernel.version}"; src = fetchFromGitHub { owner = "amzn"; repo = "amzn-drivers"; rev = "ena_linux_${version}"; - hash = "sha256-9Csrq9wM7Q99qPj7+NlnQgP6KcciNHMbAAb+Wg7eYAU="; + hash = "sha256-F8vDPPwO0PnGXhqt0EeT4m/+d8w/rjMHWRV3RYC/wVQ="; }; hardeningDisable = [ "pic" ]; @@ -16,14 +21,17 @@ stdenv.mkDerivation rec { nativeBuildInputs = kernel.moduleBuildDependencies; makeFlags = kernel.makeFlags; - # linux 3.12 - env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration"; + env.KERNEL_BUILD_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; + + patches = [ + # https://github.com/amzn/amzn-drivers/issues/313 + ./0001-workaround-patch-for-kernel-6.10.patch + ]; configurePhase = '' runHook preConfigure cd kernel/linux/ena export ENA_PHC_INCLUDE=1 - substituteInPlace Makefile --replace '/lib/modules/$(BUILD_KERNEL)' ${kernel.dev}/lib/modules/${kernel.modDirVersion} runHook postConfigure ''; @@ -41,7 +49,10 @@ stdenv.mkDerivation rec { description = "Amazon Elastic Network Adapter (ENA) driver for Linux"; homepage = "https://github.com/amzn/amzn-drivers"; license = licenses.gpl2Only; - maintainers = with maintainers; [ eelco sielicki ]; + maintainers = with maintainers; [ + sielicki + arianvp + ]; platforms = platforms.linux; }; } |