From: Hauke Mehrtens Date: Wed, 20 Apr 2011 21:35:11 +0000 (+0200) Subject: compat-wireless: fix build of atheros Ethernet drivers. X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0744b9a08ef7f82352818625934f7c36d6b2962d;p=openwrt%2Fstaging%2Fblogic.git compat-wireless: fix build of atheros Ethernet drivers. The Ethernet drivers where converted to a new hw_features netdev attribute. For kernel < 2.6.39 this does not work. Signed-off-by: Hauke Mehrtens --- diff --git a/patches/40-netdev-hw-features.patch b/patches/40-netdev-hw-features.patch new file mode 100644 index 000000000000..06c5c1a99140 --- /dev/null +++ b/patches/40-netdev-hw-features.patch @@ -0,0 +1,246 @@ +This reverts the following commit in linux mainline for kernel < 2.6.39: + +commit 782d640afd15af7a1faf01cfe566ca4ac511319d +Author: Michał Mirosław +Date: Thu Apr 7 07:32:18 2011 +0000 + + net: atl*: convert to hw_features + + Things left as they were: + - atl1: is RX checksum really enabled? + - atl2: copy-paste from atl1, with-errors-on-modify I presume + - atl1c: there's a bug: MTU can't be changed if device is not up + + Signed-off-by: Michał Mirosław + Signed-off-by: David S. Miller + +--- a/drivers/net/atl1c/atl1c_ethtool.c ++++ b/drivers/net/atl1c/atl1c_ethtool.c +@@ -113,6 +113,13 @@ static int atl1c_set_settings(struct net + return 0; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++static u32 atl1c_get_tx_csum(struct net_device *netdev) ++{ ++ return (netdev->features & NETIF_F_HW_CSUM) != 0; ++} ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ ++ + static u32 atl1c_get_msglevel(struct net_device *netdev) + { + struct atl1c_adapter *adapter = netdev_priv(netdev); +@@ -302,6 +309,11 @@ static const struct ethtool_ops atl1c_et + .get_link = ethtool_op_get_link, + .get_eeprom_len = atl1c_get_eeprom_len, + .get_eeprom = atl1c_get_eeprom, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++ .get_tx_csum = atl1c_get_tx_csum, ++ .get_sg = ethtool_op_get_sg, ++ .set_sg = ethtool_op_set_sg, ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + }; + + void atl1c_set_ethtool_ops(struct net_device *netdev) +--- a/drivers/net/atl1c/atl1c_main.c ++++ b/drivers/net/atl1c/atl1c_main.c +@@ -489,6 +489,7 @@ static void atl1c_set_rxbufsize(struct a + roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE; + } + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + static u32 atl1c_fix_features(struct net_device *netdev, u32 features) + { + if (netdev->mtu > MAX_TSO_FRAME_SIZE) +@@ -496,6 +497,7 @@ static u32 atl1c_fix_features(struct net + + return features; + } ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + + /* + * atl1c_change_mtu - Change the Maximum Transfer Unit +@@ -523,8 +525,19 @@ static int atl1c_change_mtu(struct net_d + netdev->mtu = new_mtu; + adapter->hw.max_frame_size = new_mtu; + atl1c_set_rxbufsize(adapter, netdev); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++ if (new_mtu > MAX_TSO_FRAME_SIZE) { ++ adapter->netdev->features &= ~NETIF_F_TSO; ++ adapter->netdev->features &= ~NETIF_F_TSO6; ++ } else { ++ adapter->netdev->features |= NETIF_F_TSO; ++ adapter->netdev->features |= NETIF_F_TSO6; ++ } ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + atl1c_down(adapter); ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev_update_features(netdev); ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + atl1c_up(adapter); + clear_bit(__AT_RESETTING, &adapter->flags); + if (adapter->hw.ctrl_flags & ATL1C_FPGA_VERSION) { +@@ -2590,7 +2603,9 @@ static const struct net_device_ops atl1c + .ndo_set_mac_address = atl1c_set_mac_addr, + .ndo_set_multicast_list = atl1c_set_multi, + .ndo_change_mtu = atl1c_change_mtu, ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + .ndo_fix_features = atl1c_fix_features, ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + .ndo_do_ioctl = atl1c_ioctl, + .ndo_tx_timeout = atl1c_tx_timeout, + .ndo_get_stats = atl1c_get_stats, +@@ -2611,6 +2626,7 @@ static int atl1c_init_netdev(struct net_ + atl1c_set_ethtool_ops(netdev); + + /* TODO: add when ready */ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev->hw_features = NETIF_F_SG | + NETIF_F_HW_CSUM | + NETIF_F_HW_VLAN_TX | +@@ -2618,6 +2634,14 @@ static int atl1c_init_netdev(struct net_ + NETIF_F_TSO6; + netdev->features = netdev->hw_features | + NETIF_F_HW_VLAN_RX; ++#else ++ netdev->features = NETIF_F_SG | ++ NETIF_F_HW_CSUM | ++ NETIF_F_HW_VLAN_TX | ++ NETIF_F_HW_VLAN_RX | ++ NETIF_F_TSO | ++ NETIF_F_TSO6; ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + return 0; + } + +--- a/drivers/net/atl1e/atl1e_ethtool.c ++++ b/drivers/net/atl1e/atl1e_ethtool.c +@@ -382,6 +382,11 @@ static const struct ethtool_ops atl1e_et + .get_eeprom_len = atl1e_get_eeprom_len, + .get_eeprom = atl1e_get_eeprom, + .set_eeprom = atl1e_set_eeprom, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++ .set_tx_csum = ethtool_op_set_tx_hw_csum, ++ .set_sg = ethtool_op_set_sg, ++ .set_tso = ethtool_op_set_tso, ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + }; + + void atl1e_set_ethtool_ops(struct net_device *netdev) +--- a/drivers/net/atl1e/atl1e_main.c ++++ b/drivers/net/atl1e/atl1e_main.c +@@ -1929,7 +1929,11 @@ void atl1e_down(struct atl1e_adapter *ad + * reschedule our watchdog timer */ + set_bit(__AT_DOWN, &adapter->flags); + ++#if defined(NETIF_F_LLTX) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netif_stop_queue(netdev); ++#else ++ netif_tx_disable(netdev); ++#endif + + /* reset MAC to disable all RX/TX */ + atl1e_reset_hw(&adapter->hw); +@@ -2221,10 +2225,17 @@ static int atl1e_init_netdev(struct net_ + netdev->watchdog_timeo = AT_TX_WATCHDOG; + atl1e_set_ethtool_ops(netdev); + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | + NETIF_F_HW_VLAN_TX; + netdev->features = netdev->hw_features | + NETIF_F_HW_VLAN_RX | NETIF_F_LLTX; ++#else ++ netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM | ++ NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; ++ netdev->features |= NETIF_F_LLTX; ++ netdev->features |= NETIF_F_TSO; ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + + return 0; + } +--- a/drivers/net/atlx/atl1.c ++++ b/drivers/net/atlx/atl1.c +@@ -2986,10 +2986,12 @@ static int __devinit atl1_probe(struct p + netdev->features |= NETIF_F_SG; + netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_TSO; + + /* is this valid? see atl1_setup_mac_ctrl() */ + netdev->features |= NETIF_F_RXCSUM; ++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + + /* + * patch for some L1 of old version, +@@ -3605,6 +3607,14 @@ static int atl1_set_pauseparam(struct ne + return 0; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++/* FIXME: is this right? -- CHS */ ++static u32 atl1_get_rx_csum(struct net_device *netdev) ++{ ++ return 1; ++} ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ ++ + static void atl1_get_strings(struct net_device *netdev, u32 stringset, + u8 *data) + { +@@ -3677,4 +3687,10 @@ static const struct ethtool_ops atl1_eth + .nway_reset = atl1_nway_reset, + .get_ethtool_stats = atl1_get_ethtool_stats, + .get_sset_count = atl1_get_sset_count, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++ .get_rx_csum = atl1_get_rx_csum, ++ .set_tx_csum = ethtool_op_set_tx_hw_csum, ++ .set_sg = ethtool_op_set_sg, ++ .set_tso = ethtool_op_set_tso, ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + }; +--- a/drivers/net/atlx/atl2.c ++++ b/drivers/net/atlx/atl2.c +@@ -1415,8 +1415,12 @@ static int __devinit atl2_probe(struct p + + err = -EIO; + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev->hw_features = NETIF_F_SG; ++#endif ++#if defined(NETIF_F_HW_VLAN_TX) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) + netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); ++#endif + + /* Init PHY as early as possible due to power saving issue */ + atl2_phy_init(&adapter->hw); +@@ -1843,6 +1847,13 @@ static int atl2_set_settings(struct net_ + return 0; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++static u32 atl2_get_tx_csum(struct net_device *netdev) ++{ ++ return (netdev->features & NETIF_F_HW_CSUM) != 0; ++} ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ ++ + static u32 atl2_get_msglevel(struct net_device *netdev) + { + return 0; +@@ -2110,6 +2121,14 @@ static const struct ethtool_ops atl2_eth + .get_eeprom_len = atl2_get_eeprom_len, + .get_eeprom = atl2_get_eeprom, + .set_eeprom = atl2_set_eeprom, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) ++ .get_tx_csum = atl2_get_tx_csum, ++ .get_sg = ethtool_op_get_sg, ++ .set_sg = ethtool_op_set_sg, ++#ifdef NETIF_F_TSO ++ .get_tso = ethtool_op_get_tso, ++#endif ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + }; + + static void atl2_set_ethtool_ops(struct net_device *netdev)