Unverified Commit 68e7e734 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

linuxPackages_latest.broadcom_sta: add patches (#337948)

parents 04f613bd 2cae96e4
Loading
Loading
Loading
Loading
+53 −32
Original line number Diff line number Diff line
{ lib, stdenv, fetchurl, kernel }:
{
  lib,
  stdenv,
  fetchurl,
  fetchFromGitHub,
  kernel,
}:

let
  version = "6.30.223.271";
  hashes = {
    i686-linux   = "1kaqa2dw3nb8k23ffvx46g8jj3wdhz8xa6jp1v3wb35cjfr712sg";
    x86_64-linux = "1gj485qqr190idilacpxwgqyw21il03zph2rddizgj7fbd6pfyaz";
    i686-linux = "sha256-T4twspOsjMXHDlca1dGHjQ8p0TOkb+eGmGjZwZtQWM0=";
    x86_64-linux = "sha256-X3l3TVvuyPdja1nA+wegMQju8eP9MkVjiyCFjHFBRL4=";
  };

  arch = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "_64";
  tarballVersion = lib.replaceStrings [ "." ] [ "_" ] version;
  tarball = "hybrid-v35${arch}-nodebug-pcoem-${tarballVersion}.tar.gz";

  rpmFusionPatches = fetchFromGitHub {
    owner = "rpmfusion";
    repo = "wl-kmod";
    rev = "a04330284bfc38fd91eade6f8b28fa63cfcdc95e";
    hash = "sha256-c72Pr/v+nxZPLEeNKbWnSpbH3gqYZaTgzMO9PlYQkf0=";
  };
  patchset = [
    "wl-kmod-001_wext_workaround.patch"
    "wl-kmod-002_kernel_3.18_null_pointer.patch"
    "wl-kmod-003_gcc_4.9_remove_TIME_DATE_macros.patch"
    "wl-kmod-004_kernel_4.3_rdtscl_to_rdtsc.patch"
    "wl-kmod-005_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch"
    "wl-kmod-006_gcc_6_fix_indentation_warnings.patch"
    "wl-kmod-007_kernel_4.8_add_cfg80211_scan_info_struct.patch"
    "wl-kmod-008_fix_kernel_warnings.patch"
    "wl-kmod-009_kernel_4.11_remove_last_rx_in_net_device_struct.patch"
    "wl-kmod-010_kernel_4.12_add_cfg80211_roam_info_struct.patch"
    "wl-kmod-011_kernel_4.14_new_kernel_read_function_prototype.patch"
    "wl-kmod-012_kernel_4.15_new_timer.patch"
    "wl-kmod-013_gcc8_fix_bounds_check_warnings.patch"
    "wl-kmod-014_kernel_read_pos_increment_fix.patch"
    "wl-kmod-015_kernel_5.1_get_ds_removed.patch"
    "wl-kmod-016_fix_unsupported_mesh_point.patch"
    "wl-kmod-017_fix_gcc_fallthrough_warning.patch"
    "wl-kmod-018_kernel_5.6_adaptations.patch"
    "wl-kmod-019_kernel_5.9_segment_eq_removed.patch"
    "wl-kmod-020_kernel_5.10_get_set_fs_removed.patch"
    "wl-kmod-021_kernel_5.17_adaptation.patch"
    "wl-kmod-022_kernel_5.18_adaptation.patch"
    "wl-kmod-023_kernel_6.0_adaptation.patch"
    "wl-kmod-024_kernel_6.1_adaptation.patch"
    "wl-kmod-025_kernel_6.5_adaptation.patch"
    "wl-kmod-026_kernel_6.10_fix_empty_body_in_if_warning.patch"
    "wl-kmod-027_wpa_supplicant-2.11_add_max_scan_ie_len.patch"
  ];
in
stdenv.mkDerivation {
  name = "broadcom-sta-${version}-${kernel.version}";

  src = fetchurl {
    url = "https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/${tarball}";
    sha256 = hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
    hash =
      hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
  };

  hardeningDisable = [ "pic" ];

  nativeBuildInputs = kernel.moduleBuildDependencies;

  patches = [
    ./license.patch
    ./linux-4.7.patch
    # source: https://git.archlinux.org/svntogit/community.git/tree/trunk/004-linux48.patch?h=packages/broadcom-wl-dkms
    ./linux-4.8.patch
    # source: https://aur.archlinux.org/cgit/aur.git/tree/linux411.patch?h=broadcom-wl
    ./linux-4.11.patch
    # source: https://aur.archlinux.org/cgit/aur.git/tree/linux412.patch?h=broadcom-wl
    ./linux-4.12.patch
    ./linux-4.15.patch
    ./linux-5.1.patch
    # source: https://salsa.debian.org/Herrie82-guest/broadcom-sta/-/commit/247307926e5540ad574a17c062c8da76990d056f
    ./linux-5.6.patch
    # source: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
    ./linux-5.9.patch
    # source: https://github.com/archlinux/svntogit-community/blob/33b4bd2b9e30679b03f5d7aa2741911d914dcf94/trunk/012-linux517.patch
    ./linux-5.17.patch
    # source: https://github.com/archlinux/svntogit-community/blob/2e1fd240f9ce06f500feeaa3e4a9675e65e6b967/trunk/013-linux518.patch
    ./linux-5.18.patch
    # source: https://gist.github.com/joanbm/207210d74637870c01ef5a3c262a597d
    ./linux-6.0.patch
    # source: https://gist.github.com/joanbm/94323ea99eff1e1d1c51241b5b651549
    ./linux-6.1.patch
    ./pedantic-fix.patch
    ./null-pointer-fix.patch
    ./gcc.patch
  ];
  patches = map (patch: "${rpmFusionPatches}/${patch}") patchset;

  makeFlags = [ "KBASE=${kernel.dev}/lib/modules/${kernel.modDirVersion}" ];

  unpackPhase = ''
    runHook preUnpack
    sourceRoot=broadcom-sta
    mkdir "$sourceRoot"
    tar xvf "$src" -C "$sourceRoot"
    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall
    binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/net/wireless/"
    docDir="$out/share/doc/broadcom-sta/"
    mkdir -p "$binDir" "$docDir"
    cp wl.ko "$binDir"
    cp lib/LICENSE.txt "$docDir"
    runHook postInstall
  '';

  meta = {
+0 −28
Original line number Diff line number Diff line
From 3e28c2a24c3b3b011506bcaa4fee7e8da347c5ff Mon Sep 17 00:00:00 2001
From: Charles Strahan <charles.c.strahan@gmail.com>
Date: Tue, 5 May 2015 15:09:51 -0400
Subject: [PATCH 01/16] linuxPackages.broadcom_sta: since GCC respects
 SOURCE_DATE_EPOCH, set in the stdenv, set -Wno-date-time

---
 Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Makefile b/Makefile
index a323a0d..15e85c8 100644
--- a/Makefile
+++ b/Makefile
@@ -140,10 +140,7 @@ wl-objs            += src/wl/sys/wl_cfg80211_hybrid.o
 EXTRA_CFLAGS       += -I$(src)/src/include -I$(src)/src/common/include
 EXTRA_CFLAGS       += -I$(src)/src/wl/sys -I$(src)/src/wl/phy -I$(src)/src/wl/ppr/include
 EXTRA_CFLAGS       += -I$(src)/src/shared/bcmwifi/include
-#EXTRA_CFLAGS       += -DBCMDBG_ASSERT -DBCMDBG_ERR
-ifeq "$(GE_49)" "1"
 EXTRA_CFLAGS       += -Wno-date-time
-endif
 
 EXTRA_LDFLAGS      := $(src)/lib/wlc_hybrid.o_shipped
 
-- 
2.45.1
+0 −26
Original line number Diff line number Diff line
From 5a964e14474e4482a4d24c015371856560dacabc Mon Sep 17 00:00:00 2001
From: Shea Levy <shea@shealevy.com>
Date: Sat, 4 Jan 2014 20:57:21 -0500
Subject: [PATCH 02/16] linuxPackages.broadcom_sta: apply MIXED/Proprietary
 license

---
 src/wl/sys/wl_linux.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 0d05100..14922c0 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -148,6 +148,8 @@ static struct wl_if *wl_alloc_if(wl_info_t *wl, int iftype, uint unit, struct wl
 static void wl_free_if(wl_info_t *wl, wl_if_t *wlif);
 static void wl_get_driver_info(struct net_device *dev, struct ethtool_drvinfo *info);
 
+MODULE_LICENSE("MIXED/Proprietary");
+
 #if defined(WL_CONFIG_RFKILL)
 #include <linux/rfkill.h>
 static int wl_init_rfkill(wl_info_t *wl);
-- 
2.45.1
+0 −65
Original line number Diff line number Diff line
From 5a0301c2d9c65dbb3c5b8990e635d37f071d26c4 Mon Sep 17 00:00:00 2001
From: georgewhewell <georgerw@gmail.com>
Date: Fri, 2 Jun 2017 14:19:04 +0100
Subject: [PATCH 06/16] linuxPackages.broadcom_sta: fix build for kernel 4.11+

---
 src/wl/sys/wl_cfg80211_hybrid.c |  3 +++
 src/wl/sys/wl_linux.c           | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 84f0068..9fd8ed1 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -30,6 +30,9 @@
 #include <linux/kthread.h>
 #include <linux/netdevice.h>
 #include <linux/ieee80211.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+#include <linux/sched/signal.h>
+#endif
 #include <net/cfg80211.h>
 #include <linux/nl80211.h>
 #include <net/rtnetlink.h>
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 65d7a22..18841d9 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -117,6 +117,9 @@ int wl_found = 0;
 
 typedef struct priv_link {
 	wl_if_t *wlif;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+	unsigned long last_rx;
+#endif
 } priv_link_t;
 
 #define WL_DEV_IF(dev)          ((wl_if_t*)((priv_link_t*)DEV_PRIV(dev))->wlif)
@@ -2451,6 +2454,9 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
 {
 	struct sk_buff *oskb = (struct sk_buff *)p;
 	struct sk_buff *skb;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+	priv_link_t *priv_link;
+#endif
 	uchar *pdata;
 	uint len;
 
@@ -2917,7 +2923,13 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
 	if (skb == NULL) return;
 
 	skb->dev = wl->monitor_dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+	priv_link = MALLOC(wl->osh, sizeof(priv_link_t));
+	priv_link = netdev_priv(skb->dev);
+	priv_link->last_rx = jiffies;
+#else
 	skb->dev->last_rx = jiffies;
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
 	skb_reset_mac_header(skb);
 #else
-- 
2.45.1
+0 −92
Original line number Diff line number Diff line
From 2e9c7bd146fbc3b4a62940140eafb47df16b6cb4 Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Tue, 18 Jul 2017 21:32:13 +0200
Subject: [PATCH 07/16] linuxPackages.broadcom_sta: fix build for kernel 4.12+

The patch is from Arch Linux at:

https://aur.archlinux.org/cgit/aur.git/tree/linux412.patch?h=broadcom-wl

Tested this by building against the following attributes:

  * linuxPackages.broadcom_sta
  * linuxPackages_latest.broadcom_sta
  * pkgsI686Linux.linuxPackages.broadcom_sta
  * pkgsI686Linux.linuxPackages_latest.broadcom_sta

I have not tested whether this works at runtime, because I do not possess the hardware.
---
 src/wl/sys/wl_cfg80211_hybrid.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 9fd8ed1..1893a53 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
 #endif
 
 static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+           enum nl80211_iftype type, struct vif_params *params);
+#else
            enum nl80211_iftype type, u32 *flags, struct vif_params *params);
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
 static s32
 wl_cfg80211_scan(struct wiphy *wiphy,
@@ -466,7 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
 
 static s32
 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+                         enum nl80211_iftype type,
+#else
                          enum nl80211_iftype type, u32 *flags,
+#endif
    struct vif_params *params)
 {
 	struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
@@ -2361,6 +2369,20 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
                     const wl_event_msg_t *e, void *data)
 {
 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+	struct cfg80211_bss *bss;
+	struct wlc_ssid *ssid;
+	ssid = &wl->profile->ssid;
+	bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
+	ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
+	struct cfg80211_roam_info roam_info = {
+		.bss = bss,
+		.req_ie = conn_info->req_ie,
+		.req_ie_len = conn_info->req_ie_len,
+		.resp_ie = conn_info->resp_ie,
+		.resp_ie_len = conn_info->resp_ie_len,
+	};
+#endif
 	s32 err = 0;
 
 	wl_get_assoc_ies(wl);
@@ -2368,12 +2390,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
 	memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
 	wl_update_bss_info(wl);
 	cfg80211_roamed(ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+			&roam_info,
+#else
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
 			&wl->conf->channel,	 
 #endif
 			(u8 *)&wl->bssid,
 			conn_info->req_ie, conn_info->req_ie_len,
-			conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
+			conn_info->resp_ie, conn_info->resp_ie_len,
+#endif
+			GFP_KERNEL);
 	WL_DBG(("Report roaming result\n"));
 
 	set_bit(WL_STATUS_CONNECTED, &wl->status);
-- 
2.45.1
Loading