From 1271a9d48c61b397fc06ccc607c82d76d0a7250d Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Fri, 10 May 2024 23:09:10 +0200 Subject: [PATCH 1/2] linuxPackages.ena: 2.8.9 -> 2.12.0 --- pkgs/os-specific/linux/ena/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/ena/default.nix b/pkgs/os-specific/linux/ena/default.nix index b6ed869a71f5..28fe4efea941 100644 --- a/pkgs/os-specific/linux/ena/default.nix +++ b/pkgs/os-specific/linux/ena/default.nix @@ -1,14 +1,14 @@ { lib, stdenv, fetchFromGitHub, kernel }: stdenv.mkDerivation rec { - version = "2.8.9"; + version = "2.12.0"; name = "ena-${version}-${kernel.version}"; src = fetchFromGitHub { owner = "amzn"; repo = "amzn-drivers"; rev = "ena_linux_${version}"; - hash = "sha256-9Csrq9wM7Q99qPj7+NlnQgP6KcciNHMbAAb+Wg7eYAU="; + hash = "sha256-Z/eeIUY7Yl2l/IqK3Z2nxPhn+JLvP976IZ9ZXPBqoSo="; }; hardeningDisable = [ "pic" ]; From 98bd35c20c6092951605a2d33aea4ff6a8a26f5c Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Tue, 14 May 2024 16:13:55 +0200 Subject: [PATCH 2/2] linuxPackages.ena: patch kcompat.h for explicit compatibility with < 6.8 --- pkgs/os-specific/linux/ena/default.nix | 6 ++ .../ena/override-features-api-detection.patch | 55 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 pkgs/os-specific/linux/ena/override-features-api-detection.patch diff --git a/pkgs/os-specific/linux/ena/default.nix b/pkgs/os-specific/linux/ena/default.nix index 28fe4efea941..9ce71745cdcf 100644 --- a/pkgs/os-specific/linux/ena/default.nix +++ b/pkgs/os-specific/linux/ena/default.nix @@ -19,6 +19,12 @@ stdenv.mkDerivation rec { # linux 3.12 env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration"; + patches = [ + # Use kernel version checks instead of API feature detection + # See https://github.com/NixOS/nixpkgs/pull/310680 + ./override-features-api-detection.patch + ]; + configurePhase = '' runHook preConfigure cd kernel/linux/ena diff --git a/pkgs/os-specific/linux/ena/override-features-api-detection.patch b/pkgs/os-specific/linux/ena/override-features-api-detection.patch new file mode 100644 index 000000000000..099530b12171 --- /dev/null +++ b/pkgs/os-specific/linux/ena/override-features-api-detection.patch @@ -0,0 +1,55 @@ +diff --git a/kernel/linux/ena/kcompat.h b/kernel/linux/ena/kcompat.h +index 32a9cc5..8d39362 100644 +--- a/kernel/linux/ena/kcompat.h ++++ b/kernel/linux/ena/kcompat.h +@@ -888,21 +888,6 @@ 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)) +-static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) +-{ +- memcpy(dev->dev_addr, addr, ETH_ALEN); +-} +-#endif +- + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || \ + (defined(RHEL_RELEASE_CODE) && \ + RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 6) && \ +@@ -1112,7 +1097,7 @@ static inline void ena_dma_unmap_page_attrs(struct device *dev, + #define pci_dev_id(pdev) ((((u16)(pdev->bus->number)) << 8) | (pdev->devfn)) + #endif /* ENA_HAVE_PCI_DEV_ID */ + +-#ifndef ENA_HAVE_XDP_DO_FLUSH ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) + #define xdp_do_flush xdp_do_flush_map + #endif /* ENA_HAVE_XDP_DO_FLUSH */ + +@@ -1147,15 +1132,15 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) + } + #endif /* ENA_HAVE_CPUMASK_LOCAL_SPREAD */ + +-#ifndef ENA_HAVE_UPDATE_AFFINITY_HINT ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) + static inline int irq_update_affinity_hint(unsigned int irq, const struct cpumask *m) + { + return 0; + } +-#endif /* ENA_HAVE_UPDATE_AFFINITY_HINT */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5.17.0) */ + +-#ifndef ENA_HAVE_ETHTOOL_PUTS ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) + #define ethtool_puts ethtool_sprintf +-#endif /* ENA_HAVE_ETHTOOL_PUTS */ ++#endif + + #endif /* _KCOMPAT_H_ */