compat-wireless: add alx driver and backport
authorLuis R. Rodriguez <mcgrof@frijolero.org>
Wed, 1 Feb 2012 03:05:56 +0000 (19:05 -0800)
committerLuis R. Rodriguez <mcgrof@frijolero.org>
Fri, 10 Feb 2012 21:41:00 +0000 (13:41 -0800)
This adds backport support for the alx driver.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
Makefile
config.mk
crap/0001-backport-alx.patch [new file with mode: 0644]
scripts/admin-update.sh
scripts/alx-enable [new file with mode: 0755]
scripts/driver-select
scripts/unload.sh

index c70ecdeb6ca3e4741995288ab35aae4974e5cd52..5ab1ff910de96e95f310a89babca197019a25e26 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,7 @@ MODPROBE := /sbin/modprobe
 ifneq ($(wildcard $(MODPROBE)),)
 MADWIFI=$(shell $(MODPROBE) -l ath_pci)
 OLD_IWL=$(shell $(MODPROBE) -l iwl4965)
+OLD_ALX=$(shell $(MODPROBE) -l atl1c)
 endif
 
 DESTDIR?=
@@ -185,6 +186,7 @@ install-scripts: $(MODPROBE)
        @install scripts/athenable      $(DESTDIR)/usr/sbin/
        @install scripts/b43enable      $(DESTDIR)/usr/sbin/
        @install scripts/iwl-enable     $(DESTDIR)/usr/sbin/
+       @install scripts/alx-enable     $(DESTDIR)/usr/sbin/
        @install scripts/athload        $(DESTDIR)/usr/sbin/
        @install scripts/b43load        $(DESTDIR)/usr/sbin/
        @install scripts/iwl-load       $(DESTDIR)/usr/sbin/
@@ -206,6 +208,15 @@ install-scripts: $(MODPROBE)
                echo Running iwl-enable iwlagn...;\
                /usr/sbin/iwl-enable iwlagn ;\
        fi
+       @if [ ! -z "$(OLD_ALX)" ] && [ -z "$(DESTDIR)" ]; then \
+               echo ;\
+               echo -n "Note: atl1c detected, we're going to disable it. "  ;\
+               echo "If you would like to enable it later you can run:"  ;\
+               echo "    sudo alx-load atl1c"  ;\
+               echo ;\
+               echo Running alx-enable alx...;\
+               /usr/sbin/alx-enable alx;\
+       fi
        @# If on distributions like Mandriva which like to
        @# compress their modules this will find out and do
        @# it for you. Reason is some old version of modutils
@@ -299,6 +310,7 @@ install-scripts: $(MODPROBE)
        @$(MODPROBE) -l atl2
        @$(MODPROBE) -l atl1e
        @$(MODPROBE) -l atl1c
+       @$(MODPROBE) -l alx
        @echo
        @echo "Currently detected bluetooth subsystem modules:"
        @echo
@@ -430,6 +442,7 @@ uninstall: $(MODPROBE)
        @$(MODPROBE) -l atl2
        @$(MODPROBE) -l atl1e
        @$(MODPROBE) -l atl1c
+       @$(MODPROBE) -l alx
        @echo
        @echo "Your old bluetooth subsystem modules were left intact:"
        @echo
index a9d189eb1957004e3ceef61475e78f3221728aaa..f8a4ca5a92faa829160ad19f82561df676a60c0c 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -413,8 +413,10 @@ CONFIG_ATL2=m
 CONFIG_ATL1E=m
 ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_ATL1C=n
+CONFIG_ALX=m
 else #CONFIG_COMPAT_KERNEL_2_6_27
-CONFIG_ATL1C=m
+CONFIG_ATL1C=n
+CONFIG_ALX=m
 endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 ifdef CONFIG_WIRELESS_EXT
diff --git a/crap/0001-backport-alx.patch b/crap/0001-backport-alx.patch
new file mode 100644 (file)
index 0000000..786cc39
--- /dev/null
@@ -0,0 +1,122 @@
+This should go into patches/01-netdev.patch
+
+--- a/drivers/net/ethernet/atheros/alx/alx_main.c
++++ b/drivers/net/ethernet/atheros/alx/alx_main.c
+@@ -318,7 +318,11 @@ static void alx_set_multicase_list(struc
+       /* comoute mc addresses' hash value ,and put it into hash table */
+       netdev_for_each_mc_addr(ha, netdev)
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+               hw->cbs.set_mc_addr(hw, ha->addr);
++#else
++              hw->cbs.set_mc_addr(hw, ha->dmi_addr);
++#endif
+ }
+@@ -2482,7 +2486,7 @@ static void alx_free_all_rtx_descriptor(
+       ring_header->size = ring_header->used = 0;
+ }
+-
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ static netdev_features_t alx_fix_features(struct net_device *netdev,
+                                         netdev_features_t features)
+ {
+@@ -2514,6 +2518,8 @@ static int alx_set_features(struct net_d
+               alx_vlan_mode(netdev, features);
+       return 0;
+ }
++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */
++
+ /*
+  * alx_change_mtu - Change the Maximum Transfer Unit
+  */
+@@ -2537,7 +2543,17 @@ static int alx_change_mtu(struct net_dev
+               adpt->hw.mtu = new_mtu;
+               adpt->rxbuf_size = new_mtu > ALX_DEF_RX_BUF_SIZE ?
+                                  ALIGN(max_frame, 8) : ALX_DEF_RX_BUF_SIZE;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
++              if (new_mtu > (7*1024)) {
++                      netdev->features &= ~NETIF_F_TSO;
++                      netdev->features &= ~NETIF_F_TSO6;
++              } else {
++                      netdev->features |= NETIF_F_TSO;
++                      netdev->features |= NETIF_F_TSO6;
++              }
++#else
+               netdev_update_features(netdev);
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
+               alx_reinit_locked(adpt);
+       }
+@@ -3443,8 +3459,10 @@ static const struct net_device_ops alx_n
+       .ndo_change_mtu         = alx_change_mtu,
+       .ndo_do_ioctl           = alx_ioctl,
+       .ndo_tx_timeout         = alx_tx_timeout,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       .ndo_fix_features       = alx_fix_features,
+       .ndo_set_features       = alx_set_features,
++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = alx_poll_controller,
+ #endif
+@@ -3531,7 +3549,7 @@ static int __devinit alx_init(struct pci
+       netdev->base_addr = (unsigned long)adpt->hw.hw_addr;
+       /* set cb member of netdev structure*/
+-      netdev->netdev_ops = &alx_netdev_ops;
++      netdev_attach_ops(netdev, &alx_netdev_ops);
+       alx_set_ethtool_ops(netdev);
+       netdev->watchdog_timeo = ALX_WATCHDOG_TIME;
+       strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
+@@ -3579,6 +3597,7 @@ static int __devinit alx_init(struct pci
+       adpt->max_rxques = min_t(int, ALX_MAX_RX_QUEUES, num_online_cpus());
+       adpt->max_txques = min_t(int, ALX_MAX_TX_QUEUES, num_online_cpus());
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       netdev->hw_features = NETIF_F_SG         |
+                             NETIF_F_HW_CSUM    |
+                             NETIF_F_HW_VLAN_RX;
+@@ -3590,6 +3609,19 @@ static int __devinit alx_init(struct pci
+       }
+       netdev->features = netdev->hw_features |
+                          NETIF_F_HW_VLAN_TX;
++#else
++      netdev->features = NETIF_F_SG    |
++                         NETIF_F_HW_CSUM       |
++                         NETIF_F_HW_VLAN_RX;
++      if (adpt->hw.mac_type != alx_mac_l1c &&
++          adpt->hw.mac_type != alx_mac_l2c) {
++              netdev->features = netdev->features |
++                                 NETIF_F_TSO |
++                                 NETIF_F_TSO6;
++      }
++      netdev->features = netdev->features |
++                         NETIF_F_HW_VLAN_TX;
++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */
+       /* get mac addr and perm mac addr, set to register */
+       if (hw->cbs.get_mac_addr)
+@@ -3859,6 +3891,8 @@ static struct pci_error_handlers alx_err
+ #ifdef CONFIG_PM_SLEEP
+ static SIMPLE_DEV_PM_OPS(alx_pm_ops, alx_suspend, alx_resume);
+ #define ALX_PM_OPS      (&alx_pm_ops)
++compat_pci_suspend(alx_suspend)
++compat_pci_resume(alx_resume)
+ #else
+ #define ALX_PM_OPS      NULL
+ #endif
+@@ -3871,7 +3905,12 @@ static struct pci_driver alx_driver = {
+       .remove      = __devexit_p(alx_remove),
+       .shutdown    = alx_shutdown,
+       .err_handler = &alx_err_handler,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+       .driver.pm   = ALX_PM_OPS,
++#elif defined(CONFIG_PM_SLEEP)
++      .suspend        = alx_suspend_compat,
++      .resume         = alx_resume_compat,
++#endif
+ };
index 7cd5a16ddec730c1dba22e87fdb1c8eb88823131..9c1c5a459255265da07f24fc70b0a0a9628bd837 100755 (executable)
@@ -261,6 +261,7 @@ DRIVERS="$DRIVERS drivers/net/ethernet/atheros"
 DRIVERS="$DRIVERS drivers/net/ethernet/atheros/atl1c"
 DRIVERS="$DRIVERS drivers/net/ethernet/atheros/atl1e"
 DRIVERS="$DRIVERS drivers/net/ethernet/atheros/atlx"
+DRIVERS="$DRIVERS drivers/net/ethernet/atheros/alx"
 
 # Bluetooth drivers
 DRIVERS_BT="drivers/bluetooth"
diff --git a/scripts/alx-enable b/scripts/alx-enable
new file mode 100755 (executable)
index 0000000..e04a762
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# Copyright 2012       Luis R. Rodriguez <mcgrof@frijolero.org>
+#
+# Makes sure either alx (new) or atl1c (old)
+# is enabled to be used. This allows us to choose any driver without
+# blacklisting each other.
+
+. /usr/lib/compat-wireless/modlib.sh
+
+if [[ $UID -ne 0 ]]; then
+       echo "Run with root privileges"
+       exit
+fi
+
+ALX_NEW="alx"
+ALX_OLD="atl1c"
+
+# Appended to module file at the end when we want to ignore one
+USAGE="Usage: $0 [ $ALX_NEW | $ALX_OLD ]"
+
+function enable_alx {
+       module_disable $ALX_OLD
+       for i in $ALX_NEW; do
+               module_enable $i
+       done
+}
+
+# Default behavior: disables the old atl1c driver and enables alx
+if [ $# -eq 0 ]; then
+       enable_alx
+       exit
+elif [ $# -ne 1 ]; then
+       echo "$USAGE"
+       exit
+fi
+
+MODULE=$1
+if [ "$MODULE" == "atl1c" ]; then
+       module_disable $ALX_NEW
+       module_enable $ALX_OLD
+elif [ "$MODULE" == "alx" ]; then
+       enable_alx
+else
+       echo "$USAGE"
+       exit
+fi
index 95dbddc5adc543dbef5ad68c1190880f78ce0a7b..3855bc50d764000f6838417a60b6bb8bf24f0004 100755 (executable)
@@ -37,7 +37,7 @@ SUPPORTED_80211_DRIVERS="ath5k ath9k ath9k_htc carl9170 ath6kl b43 zd1211rw rt2x
 
 # b43 needs some more work for driver-select, the SSB stuff, plus
 # what if you update b44 but not b43? It will bust.
-SUPPORTED_ETH_DRIVERS="atl1 atl2 atl1e atl1c"
+SUPPORTED_ETH_DRIVERS="atl1 atl2 atl1e atl1c alx"
 
 function usage {
        echo -e "${GREEN}Usage${NORMAL}: ${BOLD}$0${NORMAL} [ ${PURPLE}<driver-name>${NORMAL} | ${CYAN}<driver-group-name>${NORMAL} | ${GREEN}restore${NORMAL} ]"
@@ -65,7 +65,7 @@ function usage {
        echo -e "\t${CYAN}ti${NORMAL} < ${PURPLE} wl1251 wl12xx (SPI and SDIO)${NORMAL}>"
        
        echo -e "\nSupported group drivers: Bluetooth & Ethernet:"
-       echo -e "\t${CYAN}atlxx${NORMAL} < ${PURPLE} atl1 atl2 atl1e atl1c ${NORMAL}>"
+       echo -e "\t${CYAN}atlxx${NORMAL} < ${PURPLE} atl1 atl2 atl1e alx${NORMAL}>"
        echo -e "\t${CYAN}bt${NORMAL} < ${PURPLE} Linux bluetooth drivers ${NORMAL}>"
 
        echo -e "Restoring compat-wireless:"
@@ -456,8 +456,12 @@ case $1 in
                enable_only_ethernet
                echo -e "obj-\$(CONFIG_ATL1C) += atl1c/" > $DRIVERS_NET_ATHEROS
                ;;
+       alx)
+               enable_only_ethernet
+               echo -e "obj-\$(CONFIG_ALX) += alx/" > $DRIVERS_NET_ATHEROS
+               ;;
        atlxx)
-               select_drivers          CONFIG_ATL1 CONFIG_ATL2 CONFIG_ATL1E CONFIG_ATL1C
+               select_drivers          CONFIG_ATL1 CONFIG_ATL2 CONFIG_ATL1E CONFIG_ALX
                enable_only_ethernet
                disable_b44
                disable_update-initramfs
index abc5e72e89afa4cd3e03b9df0be484da6d951256..c659a70508c03dc539d7a5f6573f7049cf796d69 100755 (executable)
@@ -36,7 +36,7 @@ MODULES="$MODULES compat"
 # Bluetooth modules
 MODULES="$MODULES ath3k bcm203x bluecard_cs bnep bpa10x bt3c_cs btmrvl btmrvl_sdio btsdio"
 MODULES="$MODULES btusb btuart_cs cmtp dtl1_cs hidp hci_vhci hci_uart rfcomm sco bluetooth l2cap"
-MODULES="$MODULES atl1 atl2 atl1e atl1c"
+MODULES="$MODULES atl1 atl2 atl1e atl1c alx"
 echo Stoping bluetooth service..
 /etc/init.d/bluetooth stop
 /etc/init.d/bluetooth status