Commit f633fcf7 authored by Enric Morales's avatar Enric Morales Committed by Arian van Putten
Browse files

linuxPackages.ena: reformat, use upstream patch, remove problematic flag

parent b34ee7d4
Loading
Loading
Loading
Loading
+54 −0
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 32a9cc5..8d39362 100644
index 32a9cc54dc2b..6d5a069804ec 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,
@@ -888,15 +888,7 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 #define ENA_XDP_XMIT_FREES_FAILED_DESCS_INTERNALLY
 #endif
 
@@ -15,41 +45,10 @@ index 32a9cc5..8d39362 100644
-	!(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)
+#ifndef ENA_HAVE_ETH_HW_ADDR_SET
 static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
 {
 	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
 	memcpy(dev->dev_addr, addr, ETH_ALEN);
-- 
2.34.1
 #endif /* _KCOMPAT_H_ */
+14 −8
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, kernel }:
{
  lib,
  stdenv,
  fetchFromGitHub,
  kernel,
}:

stdenv.mkDerivation rec {
  version = "2.12.0";
@@ -16,20 +21,18 @@ 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 = [
    # Use kernel version checks instead of API feature detection
    # See https://github.com/NixOS/nixpkgs/pull/310680
    ./override-features-api-detection.patch
    # 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
  ];

  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
  '';

@@ -47,7 +50,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; [
      eelco
      sielicki
    ];
    platforms = platforms.linux;
  };
}