aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic.h40
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c30
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c149
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h2
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c64
-rw-r--r--drivers/net/netxen/netxen_nic_init.c24
-rw-r--r--drivers/net/netxen/netxen_nic_main.c147
7 files changed, 207 insertions, 249 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 6dca3574e355..77220687b92a 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -53,8 +53,8 @@
53 53
54#define _NETXEN_NIC_LINUX_MAJOR 4 54#define _NETXEN_NIC_LINUX_MAJOR 4
55#define _NETXEN_NIC_LINUX_MINOR 0 55#define _NETXEN_NIC_LINUX_MINOR 0
56#define _NETXEN_NIC_LINUX_SUBVERSION 74 56#define _NETXEN_NIC_LINUX_SUBVERSION 75
57#define NETXEN_NIC_LINUX_VERSIONID "4.0.74" 57#define NETXEN_NIC_LINUX_VERSIONID "4.0.75"
58 58
59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
60#define _major(v) (((v) >> 24) & 0xff) 60#define _major(v) (((v) >> 24) & 0xff)
@@ -174,8 +174,11 @@
174 174
175#define MAX_NUM_CARDS 4 175#define MAX_NUM_CARDS 4
176 176
177#define MAX_BUFFERS_PER_CMD 32 177#define NETXEN_MAX_FRAGS_PER_TX 14
178#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + 4) 178#define MAX_TSO_HEADER_DESC 2
179#define MGMT_CMD_DESC_RESV 4
180#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \
181 + MGMT_CMD_DESC_RESV)
179#define NX_MAX_TX_TIMEOUTS 2 182#define NX_MAX_TX_TIMEOUTS 2
180 183
181/* 184/*
@@ -555,7 +558,7 @@ struct netxen_recv_crb {
555 */ 558 */
556struct netxen_cmd_buffer { 559struct netxen_cmd_buffer {
557 struct sk_buff *skb; 560 struct sk_buff *skb;
558 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1]; 561 struct netxen_skb_frag frag_array[MAX_SKB_FRAGS + 1];
559 u32 frag_count; 562 u32 frag_count;
560}; 563};
561 564
@@ -736,7 +739,8 @@ struct netxen_recv_context {
736#define NX_CDRP_CMD_READ_PEXQ_PARAMETERS 0x0000001c 739#define NX_CDRP_CMD_READ_PEXQ_PARAMETERS 0x0000001c
737#define NX_CDRP_CMD_GET_LIC_CAPABILITIES 0x0000001d 740#define NX_CDRP_CMD_GET_LIC_CAPABILITIES 0x0000001d
738#define NX_CDRP_CMD_READ_MAX_LRO_PER_BOARD 0x0000001e 741#define NX_CDRP_CMD_READ_MAX_LRO_PER_BOARD 0x0000001e
739#define NX_CDRP_CMD_MAX 0x0000001f 742#define NX_CDRP_CMD_CONFIG_GBE_PORT 0x0000001f
743#define NX_CDRP_CMD_MAX 0x00000020
740 744
741#define NX_RCODE_SUCCESS 0 745#define NX_RCODE_SUCCESS 0
742#define NX_RCODE_NO_HOST_MEM 1 746#define NX_RCODE_NO_HOST_MEM 1
@@ -1051,6 +1055,7 @@ typedef struct {
1051#define NX_FW_CAPABILITY_BDG (1 << 8) 1055#define NX_FW_CAPABILITY_BDG (1 << 8)
1052#define NX_FW_CAPABILITY_FVLANTX (1 << 9) 1056#define NX_FW_CAPABILITY_FVLANTX (1 << 9)
1053#define NX_FW_CAPABILITY_HW_LRO (1 << 10) 1057#define NX_FW_CAPABILITY_HW_LRO (1 << 10)
1058#define NX_FW_CAPABILITY_GBE_LINK_CFG (1 << 11)
1054 1059
1055/* module types */ 1060/* module types */
1056#define LINKEVENT_MODULE_NOT_PRESENT 1 1061#define LINKEVENT_MODULE_NOT_PRESENT 1
@@ -1129,6 +1134,7 @@ typedef struct {
1129#define NETXEN_NIC_MSI_ENABLED 0x02 1134#define NETXEN_NIC_MSI_ENABLED 0x02
1130#define NETXEN_NIC_MSIX_ENABLED 0x04 1135#define NETXEN_NIC_MSIX_ENABLED 0x04
1131#define NETXEN_NIC_LRO_ENABLED 0x08 1136#define NETXEN_NIC_LRO_ENABLED 0x08
1137#define NETXEN_NIC_LRO_DISABLED 0x00
1132#define NETXEN_NIC_BRIDGE_ENABLED 0X10 1138#define NETXEN_NIC_BRIDGE_ENABLED 0X10
1133#define NETXEN_NIC_DIAG_ENABLED 0x20 1139#define NETXEN_NIC_DIAG_ENABLED 0x20
1134#define NETXEN_IS_MSI_FAMILY(adapter) \ 1140#define NETXEN_IS_MSI_FAMILY(adapter) \
@@ -1171,7 +1177,7 @@ struct netxen_adapter {
1171 u8 max_sds_rings; 1177 u8 max_sds_rings;
1172 u8 driver_mismatch; 1178 u8 driver_mismatch;
1173 u8 msix_supported; 1179 u8 msix_supported;
1174 u8 rx_csum; 1180 u8 __pad;
1175 u8 pci_using_dac; 1181 u8 pci_using_dac;
1176 u8 portnum; 1182 u8 portnum;
1177 u8 physical_port; 1183 u8 physical_port;
@@ -1253,19 +1259,9 @@ struct netxen_adapter {
1253 const struct firmware *fw; 1259 const struct firmware *fw;
1254}; 1260};
1255 1261
1256int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
1257int netxen_niu_disable_xg_port(struct netxen_adapter *adapter);
1258
1259int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val); 1262int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val);
1260int nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val); 1263int nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val);
1261 1264
1262/* Functions available from netxen_nic_hw.c */
1263int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
1264int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
1265
1266int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr);
1267int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr);
1268
1269#define NXRD32(adapter, off) \ 1265#define NXRD32(adapter, off) \
1270 (adapter->crb_read(adapter, off)) 1266 (adapter->crb_read(adapter, off))
1271#define NXWR32(adapter, off, val) \ 1267#define NXWR32(adapter, off, val) \
@@ -1345,11 +1341,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
1345 struct nx_host_rds_ring *rds_ring); 1341 struct nx_host_rds_ring *rds_ring);
1346int netxen_process_cmd_ring(struct netxen_adapter *adapter); 1342int netxen_process_cmd_ring(struct netxen_adapter *adapter);
1347int netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max); 1343int netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max);
1348void netxen_p2_nic_set_multi(struct net_device *netdev); 1344
1349void netxen_p3_nic_set_multi(struct net_device *netdev);
1350void netxen_p3_free_mac_list(struct netxen_adapter *adapter); 1345void netxen_p3_free_mac_list(struct netxen_adapter *adapter);
1351int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode);
1352int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32);
1353int netxen_config_intr_coalesce(struct netxen_adapter *adapter); 1346int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
1354int netxen_config_rss(struct netxen_adapter *adapter, int enable); 1347int netxen_config_rss(struct netxen_adapter *adapter, int enable);
1355int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd); 1348int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd);
@@ -1358,15 +1351,14 @@ void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup);
1358void netxen_pci_camqm_read_2M(struct netxen_adapter *, u64, u64 *); 1351void netxen_pci_camqm_read_2M(struct netxen_adapter *, u64, u64 *);
1359void netxen_pci_camqm_write_2M(struct netxen_adapter *, u64, u64); 1352void netxen_pci_camqm_write_2M(struct netxen_adapter *, u64, u64);
1360 1353
1354int nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
1355 u32 speed, u32 duplex, u32 autoneg);
1361int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu); 1356int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu);
1362int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); 1357int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
1363int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable); 1358int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable);
1364int netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable); 1359int netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable);
1365int netxen_send_lro_cleanup(struct netxen_adapter *adapter); 1360int netxen_send_lro_cleanup(struct netxen_adapter *adapter);
1366 1361
1367int netxen_nic_set_mac(struct net_device *netdev, void *p);
1368struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
1369
1370void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 1362void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
1371 struct nx_host_tx_ring *tx_ring); 1363 struct nx_host_tx_ring *tx_ring);
1372 1364
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 12612127a087..f16966afa64e 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -112,6 +112,21 @@ nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu)
112 return 0; 112 return 0;
113} 113}
114 114
115int
116nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
117 u32 speed, u32 duplex, u32 autoneg)
118{
119
120 return netxen_issue_cmd(adapter,
121 adapter->ahw.pci_func,
122 NXHAL_VERSION,
123 speed,
124 duplex,
125 autoneg,
126 NX_CDRP_CMD_CONFIG_GBE_PORT);
127
128}
129
115static int 130static int
116nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) 131nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
117{ 132{
@@ -255,19 +270,6 @@ out_free_rq:
255} 270}
256 271
257static void 272static void
258nx_fw_cmd_reset_ctx(struct netxen_adapter *adapter)
259{
260
261 netxen_issue_cmd(adapter, adapter->ahw.pci_func, NXHAL_VERSION,
262 adapter->ahw.pci_func, NX_DESTROY_CTX_RESET, 0,
263 NX_CDRP_CMD_DESTROY_RX_CTX);
264
265 netxen_issue_cmd(adapter, adapter->ahw.pci_func, NXHAL_VERSION,
266 adapter->ahw.pci_func, NX_DESTROY_CTX_RESET, 0,
267 NX_CDRP_CMD_DESTROY_TX_CTX);
268}
269
270static void
271nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter) 273nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter)
272{ 274{
273 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; 275 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
@@ -698,8 +700,6 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
698 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 700 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
699 if (test_and_set_bit(__NX_FW_ATTACHED, &adapter->state)) 701 if (test_and_set_bit(__NX_FW_ATTACHED, &adapter->state))
700 goto done; 702 goto done;
701 if (reset_devices)
702 nx_fw_cmd_reset_ctx(adapter);
703 err = nx_fw_cmd_create_rx_ctx(adapter); 703 err = nx_fw_cmd_create_rx_ctx(adapter);
704 if (err) 704 if (err)
705 goto err_out_free; 705 goto err_out_free;
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index b30de24f4a52..b34fb74d07e3 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -117,7 +117,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
117 117
118 ecmd->port = PORT_TP; 118 ecmd->port = PORT_TP;
119 119
120 ecmd->speed = adapter->link_speed; 120 ethtool_cmd_speed_set(ecmd, adapter->link_speed);
121 ecmd->duplex = adapter->link_duplex; 121 ecmd->duplex = adapter->link_duplex;
122 ecmd->autoneg = adapter->link_autoneg; 122 ecmd->autoneg = adapter->link_autoneg;
123 123
@@ -134,7 +134,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
134 } 134 }
135 135
136 if (netif_running(dev) && adapter->has_link_events) { 136 if (netif_running(dev) && adapter->has_link_events) {
137 ecmd->speed = adapter->link_speed; 137 ethtool_cmd_speed_set(ecmd, adapter->link_speed);
138 ecmd->autoneg = adapter->link_autoneg; 138 ecmd->autoneg = adapter->link_autoneg;
139 ecmd->duplex = adapter->link_duplex; 139 ecmd->duplex = adapter->link_duplex;
140 goto skip; 140 goto skip;
@@ -146,10 +146,10 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
146 u16 pcifn = adapter->ahw.pci_func; 146 u16 pcifn = adapter->ahw.pci_func;
147 147
148 val = NXRD32(adapter, P3_LINK_SPEED_REG(pcifn)); 148 val = NXRD32(adapter, P3_LINK_SPEED_REG(pcifn));
149 ecmd->speed = P3_LINK_SPEED_MHZ * 149 ethtool_cmd_speed_set(ecmd, P3_LINK_SPEED_MHZ *
150 P3_LINK_SPEED_VAL(pcifn, val); 150 P3_LINK_SPEED_VAL(pcifn, val));
151 } else 151 } else
152 ecmd->speed = SPEED_10000; 152 ethtool_cmd_speed_set(ecmd, SPEED_10000);
153 153
154 ecmd->duplex = DUPLEX_FULL; 154 ecmd->duplex = DUPLEX_FULL;
155 ecmd->autoneg = AUTONEG_DISABLE; 155 ecmd->autoneg = AUTONEG_DISABLE;
@@ -214,7 +214,6 @@ skip:
214 check_sfp_module = netif_running(dev) && 214 check_sfp_module = netif_running(dev) &&
215 adapter->has_link_events; 215 adapter->has_link_events;
216 } else { 216 } else {
217 ecmd->autoneg = AUTONEG_ENABLE;
218 ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg); 217 ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg);
219 ecmd->advertising |= 218 ecmd->advertising |=
220 (ADVERTISED_TP | ADVERTISED_Autoneg); 219 (ADVERTISED_TP | ADVERTISED_Autoneg);
@@ -252,53 +251,25 @@ static int
252netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 251netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
253{ 252{
254 struct netxen_adapter *adapter = netdev_priv(dev); 253 struct netxen_adapter *adapter = netdev_priv(dev);
255 __u32 status; 254 u32 speed = ethtool_cmd_speed(ecmd);
255 int ret;
256 256
257 /* read which mode */ 257 if (adapter->ahw.port_type != NETXEN_NIC_GBE)
258 if (adapter->ahw.port_type == NETXEN_NIC_GBE) { 258 return -EOPNOTSUPP;
259 /* autonegotiation */
260 if (adapter->phy_write &&
261 adapter->phy_write(adapter,
262 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
263 ecmd->autoneg) != 0)
264 return -EIO;
265 else
266 adapter->link_autoneg = ecmd->autoneg;
267 259
268 if (adapter->phy_read && 260 if (!(adapter->capabilities & NX_FW_CAPABILITY_GBE_LINK_CFG))
269 adapter->phy_read(adapter, 261 return -EOPNOTSUPP;
270 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
271 &status) != 0)
272 return -EIO;
273 262
274 /* speed */ 263 ret = nx_fw_cmd_set_gbe_port(adapter, speed, ecmd->duplex,
275 switch (ecmd->speed) { 264 ecmd->autoneg);
276 case SPEED_10: 265 if (ret == NX_RCODE_NOT_SUPPORTED)
277 netxen_set_phy_speed(status, 0);
278 break;
279 case SPEED_100:
280 netxen_set_phy_speed(status, 1);
281 break;
282 case SPEED_1000:
283 netxen_set_phy_speed(status, 2);
284 break;
285 }
286 /* set duplex mode */
287 if (ecmd->duplex == DUPLEX_HALF)
288 netxen_clear_phy_duplex(status);
289 if (ecmd->duplex == DUPLEX_FULL)
290 netxen_set_phy_duplex(status);
291 if (adapter->phy_write &&
292 adapter->phy_write(adapter,
293 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
294 *((int *)&status)) != 0)
295 return -EIO;
296 else {
297 adapter->link_speed = ecmd->speed;
298 adapter->link_duplex = ecmd->duplex;
299 }
300 } else
301 return -EOPNOTSUPP; 266 return -EOPNOTSUPP;
267 else if (ret)
268 return -EIO;
269
270 adapter->link_speed = speed;
271 adapter->link_duplex = ecmd->duplex;
272 adapter->link_autoneg = ecmd->autoneg;
302 273
303 if (!netif_running(dev)) 274 if (!netif_running(dev))
304 return 0; 275 return 0;
@@ -706,48 +677,6 @@ netxen_nic_get_ethtool_stats(struct net_device *dev,
706 } 677 }
707} 678}
708 679
709static u32 netxen_nic_get_tx_csum(struct net_device *dev)
710{
711 return dev->features & NETIF_F_IP_CSUM;
712}
713
714static u32 netxen_nic_get_rx_csum(struct net_device *dev)
715{
716 struct netxen_adapter *adapter = netdev_priv(dev);
717 return adapter->rx_csum;
718}
719
720static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
721{
722 struct netxen_adapter *adapter = netdev_priv(dev);
723 adapter->rx_csum = !!data;
724 return 0;
725}
726
727static u32 netxen_nic_get_tso(struct net_device *dev)
728{
729 struct netxen_adapter *adapter = netdev_priv(dev);
730
731 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
732 return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0;
733
734 return (dev->features & NETIF_F_TSO) != 0;
735}
736
737static int netxen_nic_set_tso(struct net_device *dev, u32 data)
738{
739 if (data) {
740 struct netxen_adapter *adapter = netdev_priv(dev);
741
742 dev->features |= NETIF_F_TSO;
743 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
744 dev->features |= NETIF_F_TSO6;
745 } else
746 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
747
748 return 0;
749}
750
751static void 680static void
752netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 681netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
753{ 682{
@@ -882,35 +811,6 @@ static int netxen_get_intr_coalesce(struct net_device *netdev,
882 return 0; 811 return 0;
883} 812}
884 813
885static int netxen_nic_set_flags(struct net_device *netdev, u32 data)
886{
887 struct netxen_adapter *adapter = netdev_priv(netdev);
888 int hw_lro;
889
890 if (data & ~ETH_FLAG_LRO)
891 return -EINVAL;
892
893 if (!(adapter->capabilities & NX_FW_CAPABILITY_HW_LRO))
894 return -EINVAL;
895
896 if (data & ETH_FLAG_LRO) {
897 hw_lro = NETXEN_NIC_LRO_ENABLED;
898 netdev->features |= NETIF_F_LRO;
899 } else {
900 hw_lro = 0;
901 netdev->features &= ~NETIF_F_LRO;
902 }
903
904 if (netxen_config_hw_lro(adapter, hw_lro))
905 return -EIO;
906
907 if ((hw_lro == 0) && netxen_send_lro_cleanup(adapter))
908 return -EIO;
909
910
911 return 0;
912}
913
914const struct ethtool_ops netxen_nic_ethtool_ops = { 814const struct ethtool_ops netxen_nic_ethtool_ops = {
915 .get_settings = netxen_nic_get_settings, 815 .get_settings = netxen_nic_get_settings,
916 .set_settings = netxen_nic_set_settings, 816 .set_settings = netxen_nic_set_settings,
@@ -924,21 +824,12 @@ const struct ethtool_ops netxen_nic_ethtool_ops = {
924 .set_ringparam = netxen_nic_set_ringparam, 824 .set_ringparam = netxen_nic_set_ringparam,
925 .get_pauseparam = netxen_nic_get_pauseparam, 825 .get_pauseparam = netxen_nic_get_pauseparam,
926 .set_pauseparam = netxen_nic_set_pauseparam, 826 .set_pauseparam = netxen_nic_set_pauseparam,
927 .get_tx_csum = netxen_nic_get_tx_csum,
928 .set_tx_csum = ethtool_op_set_tx_csum,
929 .set_sg = ethtool_op_set_sg,
930 .get_tso = netxen_nic_get_tso,
931 .set_tso = netxen_nic_set_tso,
932 .get_wol = netxen_nic_get_wol, 827 .get_wol = netxen_nic_get_wol,
933 .set_wol = netxen_nic_set_wol, 828 .set_wol = netxen_nic_set_wol,
934 .self_test = netxen_nic_diag_test, 829 .self_test = netxen_nic_diag_test,
935 .get_strings = netxen_nic_get_strings, 830 .get_strings = netxen_nic_get_strings,
936 .get_ethtool_stats = netxen_nic_get_ethtool_stats, 831 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
937 .get_sset_count = netxen_get_sset_count, 832 .get_sset_count = netxen_get_sset_count,
938 .get_rx_csum = netxen_nic_get_rx_csum,
939 .set_rx_csum = netxen_nic_set_rx_csum,
940 .get_coalesce = netxen_get_intr_coalesce, 833 .get_coalesce = netxen_get_intr_coalesce,
941 .set_coalesce = netxen_set_intr_coalesce, 834 .set_coalesce = netxen_set_intr_coalesce,
942 .get_flags = ethtool_op_get_flags,
943 .set_flags = netxen_nic_set_flags,
944}; 835};
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index d8bd73d7e296..dc1967c1f312 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -780,7 +780,7 @@ enum {
780 780
781/* 781/*
782 * capabilities register, can be used to selectively enable/disable features 782 * capabilities register, can be used to selectively enable/disable features
783 * for backward compability 783 * for backward compatibility
784 */ 784 */
785#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8) 785#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8)
786#define CRB_NIC_MSI_MODE_HOST NETXEN_NIC_REG(0x270) 786#define CRB_NIC_MSI_MODE_HOST NETXEN_NIC_REG(0x270)
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 29d7b93d0493..5cef718fe35f 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -319,6 +319,8 @@ static unsigned crb_hub_agt[64] =
319 319
320#define NETXEN_PCIE_SEM_TIMEOUT 10000 320#define NETXEN_PCIE_SEM_TIMEOUT 10000
321 321
322static int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
323
322int 324int
323netxen_pcie_sem_lock(struct netxen_adapter *adapter, int sem, u32 id_reg) 325netxen_pcie_sem_lock(struct netxen_adapter *adapter, int sem, u32 id_reg)
324{ 326{
@@ -345,7 +347,7 @@ netxen_pcie_sem_unlock(struct netxen_adapter *adapter, int sem)
345 NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM_UNLOCK(sem))); 347 NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM_UNLOCK(sem)));
346} 348}
347 349
348int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port) 350static int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
349{ 351{
350 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 352 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
351 NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447); 353 NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447);
@@ -356,7 +358,7 @@ int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
356} 358}
357 359
358/* Disable an XG interface */ 360/* Disable an XG interface */
359int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) 361static int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
360{ 362{
361 __u32 mac_cfg; 363 __u32 mac_cfg;
362 u32 port = adapter->physical_port; 364 u32 port = adapter->physical_port;
@@ -383,7 +385,7 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
383#define MAC_LO(addr) \ 385#define MAC_LO(addr) \
384 ((addr[5] << 16) | (addr[4] << 8) | (addr[3])) 386 ((addr[5] << 16) | (addr[4] << 8) | (addr[3]))
385 387
386int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) 388static int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
387{ 389{
388 u32 mac_cfg; 390 u32 mac_cfg;
389 u32 cnt = 0; 391 u32 cnt = 0;
@@ -434,7 +436,7 @@ int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
434 return 0; 436 return 0;
435} 437}
436 438
437int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr) 439static int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr)
438{ 440{
439 u32 mac_hi, mac_lo; 441 u32 mac_hi, mac_lo;
440 u32 reg_hi, reg_lo; 442 u32 reg_hi, reg_lo;
@@ -531,7 +533,7 @@ netxen_nic_set_mcast_addr(struct netxen_adapter *adapter,
531 return 0; 533 return 0;
532} 534}
533 535
534void netxen_p2_nic_set_multi(struct net_device *netdev) 536static void netxen_p2_nic_set_multi(struct net_device *netdev)
535{ 537{
536 struct netxen_adapter *adapter = netdev_priv(netdev); 538 struct netxen_adapter *adapter = netdev_priv(netdev);
537 struct netdev_hw_addr *ha; 539 struct netdev_hw_addr *ha;
@@ -598,8 +600,14 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
598 600
599 if (nr_desc >= netxen_tx_avail(tx_ring)) { 601 if (nr_desc >= netxen_tx_avail(tx_ring)) {
600 netif_tx_stop_queue(tx_ring->txq); 602 netif_tx_stop_queue(tx_ring->txq);
601 __netif_tx_unlock_bh(tx_ring->txq); 603 smp_mb();
602 return -EBUSY; 604 if (netxen_tx_avail(tx_ring) > nr_desc) {
605 if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH)
606 netif_tx_wake_queue(tx_ring->txq);
607 } else {
608 __netif_tx_unlock_bh(tx_ring->txq);
609 return -EBUSY;
610 }
603 } 611 }
604 612
605 do { 613 do {
@@ -647,7 +655,7 @@ nx_p3_sre_macaddr_change(struct netxen_adapter *adapter, u8 *addr, unsigned op)
647} 655}
648 656
649static int nx_p3_nic_add_mac(struct netxen_adapter *adapter, 657static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
650 u8 *addr, struct list_head *del_list) 658 const u8 *addr, struct list_head *del_list)
651{ 659{
652 struct list_head *head; 660 struct list_head *head;
653 nx_mac_list_t *cur; 661 nx_mac_list_t *cur;
@@ -674,11 +682,13 @@ static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
674 cur->mac_addr, NETXEN_MAC_ADD); 682 cur->mac_addr, NETXEN_MAC_ADD);
675} 683}
676 684
677void netxen_p3_nic_set_multi(struct net_device *netdev) 685static void netxen_p3_nic_set_multi(struct net_device *netdev)
678{ 686{
679 struct netxen_adapter *adapter = netdev_priv(netdev); 687 struct netxen_adapter *adapter = netdev_priv(netdev);
680 struct netdev_hw_addr *ha; 688 struct netdev_hw_addr *ha;
681 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 689 static const u8 bcast_addr[ETH_ALEN] = {
690 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
691 };
682 u32 mode = VPORT_MISS_MODE_DROP; 692 u32 mode = VPORT_MISS_MODE_DROP;
683 LIST_HEAD(del_list); 693 LIST_HEAD(del_list);
684 struct list_head *head; 694 struct list_head *head;
@@ -721,7 +731,7 @@ send_fw_cmd:
721 } 731 }
722} 732}
723 733
724int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) 734static int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
725{ 735{
726 nx_nic_req_t req; 736 nx_nic_req_t req;
727 u64 word; 737 u64 word;
@@ -754,7 +764,7 @@ void netxen_p3_free_mac_list(struct netxen_adapter *adapter)
754 } 764 }
755} 765}
756 766
757int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr) 767static int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr)
758{ 768{
759 /* assuming caller has already copied new addr to netdev */ 769 /* assuming caller has already copied new addr to netdev */
760 netxen_p3_nic_set_multi(adapter->netdev); 770 netxen_p3_nic_set_multi(adapter->netdev);
@@ -799,9 +809,6 @@ int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable)
799 u64 word; 809 u64 word;
800 int rv = 0; 810 int rv = 0;
801 811
802 if ((adapter->flags & NETXEN_NIC_LRO_ENABLED) == enable)
803 return 0;
804
805 memset(&req, 0, sizeof(nx_nic_req_t)); 812 memset(&req, 0, sizeof(nx_nic_req_t));
806 813
807 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); 814 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
@@ -817,8 +824,6 @@ int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable)
817 "configure hw lro request\n"); 824 "configure hw lro request\n");
818 } 825 }
819 826
820 adapter->flags ^= NETXEN_NIC_LRO_ENABLED;
821
822 return rv; 827 return rv;
823} 828}
824 829
@@ -861,9 +866,11 @@ int netxen_config_rss(struct netxen_adapter *adapter, int enable)
861 u64 word; 866 u64 word;
862 int i, rv; 867 int i, rv;
863 868
864 u64 key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, 869 static const u64 key[] = {
865 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, 870 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL,
866 0x255b0ec26d5a56daULL }; 871 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL,
872 0x255b0ec26d5a56daULL
873 };
867 874
868 875
869 memset(&req, 0, sizeof(nx_nic_req_t)); 876 memset(&req, 0, sizeof(nx_nic_req_t));
@@ -887,7 +894,7 @@ int netxen_config_rss(struct netxen_adapter *adapter, int enable)
887 ((u64)(enable & 0x1) << 8) | 894 ((u64)(enable & 0x1) << 8) |
888 ((0x7ULL) << 48); 895 ((0x7ULL) << 48);
889 req.words[0] = cpu_to_le64(word); 896 req.words[0] = cpu_to_le64(word);
890 for (i = 0; i < 5; i++) 897 for (i = 0; i < ARRAY_SIZE(key); i++)
891 req.words[i+1] = cpu_to_le64(key[i]); 898 req.words[i+1] = cpu_to_le64(key[i]);
892 899
893 900
@@ -1816,14 +1823,14 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
1816 if (netxen_rom_fast_read(adapter, offset, &board_type)) 1823 if (netxen_rom_fast_read(adapter, offset, &board_type))
1817 return -EIO; 1824 return -EIO;
1818 1825
1819 adapter->ahw.board_type = board_type;
1820
1821 if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { 1826 if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
1822 u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I); 1827 u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I);
1823 if ((gpio & 0x8000) == 0) 1828 if ((gpio & 0x8000) == 0)
1824 board_type = NETXEN_BRDTYPE_P3_10G_TP; 1829 board_type = NETXEN_BRDTYPE_P3_10G_TP;
1825 } 1830 }
1826 1831
1832 adapter->ahw.board_type = board_type;
1833
1827 switch (board_type) { 1834 switch (board_type) {
1828 case NETXEN_BRDTYPE_P2_SB35_4G: 1835 case NETXEN_BRDTYPE_P2_SB35_4G:
1829 adapter->ahw.port_type = NETXEN_NIC_GBE; 1836 adapter->ahw.port_type = NETXEN_NIC_GBE;
@@ -1867,16 +1874,7 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
1867} 1874}
1868 1875
1869/* NIU access sections */ 1876/* NIU access sections */
1870 1877static int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
1871int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu)
1872{
1873 new_mtu += MTU_FUDGE_FACTOR;
1874 NXWR32(adapter, NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->physical_port),
1875 new_mtu);
1876 return 0;
1877}
1878
1879int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
1880{ 1878{
1881 new_mtu += MTU_FUDGE_FACTOR; 1879 new_mtu += MTU_FUDGE_FACTOR;
1882 if (adapter->physical_port == 0) 1880 if (adapter->physical_port == 0)
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index b075a35b85d4..7f999671c7b2 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -214,13 +214,12 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
214 tx_ring->num_desc = adapter->num_txd; 214 tx_ring->num_desc = adapter->num_txd;
215 tx_ring->txq = netdev_get_tx_queue(netdev, 0); 215 tx_ring->txq = netdev_get_tx_queue(netdev, 0);
216 216
217 cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring)); 217 cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
218 if (cmd_buf_arr == NULL) { 218 if (cmd_buf_arr == NULL) {
219 dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n", 219 dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
220 netdev->name); 220 netdev->name);
221 goto err_out; 221 goto err_out;
222 } 222 }
223 memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
224 tx_ring->cmd_buf_arr = cmd_buf_arr; 223 tx_ring->cmd_buf_arr = cmd_buf_arr;
225 224
226 recv_ctx = &adapter->recv_ctx; 225 recv_ctx = &adapter->recv_ctx;
@@ -279,8 +278,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
279 break; 278 break;
280 279
281 } 280 }
282 rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) 281 rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
283 vmalloc(RCV_BUFF_RINGSIZE(rds_ring));
284 if (rds_ring->rx_buf_arr == NULL) { 282 if (rds_ring->rx_buf_arr == NULL) {
285 printk(KERN_ERR "%s: Failed to allocate " 283 printk(KERN_ERR "%s: Failed to allocate "
286 "rx buffer ring %d\n", 284 "rx buffer ring %d\n",
@@ -288,7 +286,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
288 /* free whatever was already allocated */ 286 /* free whatever was already allocated */
289 goto err_out; 287 goto err_out;
290 } 288 }
291 memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring));
292 INIT_LIST_HEAD(&rds_ring->free_list); 289 INIT_LIST_HEAD(&rds_ring->free_list);
293 /* 290 /*
294 * Now go through all of them, set reference handles 291 * Now go through all of them, set reference handles
@@ -346,7 +343,7 @@ static u32 netxen_decode_crb_addr(u32 addr)
346 if (pci_base == NETXEN_ADDR_ERROR) 343 if (pci_base == NETXEN_ADDR_ERROR)
347 return pci_base; 344 return pci_base;
348 else 345 else
349 return (pci_base + offset); 346 return pci_base + offset;
350} 347}
351 348
352#define NETXEN_MAX_ROM_WAIT_USEC 100 349#define NETXEN_MAX_ROM_WAIT_USEC 100
@@ -1486,7 +1483,8 @@ static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter,
1486 if (!skb) 1483 if (!skb)
1487 goto no_skb; 1484 goto no_skb;
1488 1485
1489 if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) { 1486 if (likely((adapter->netdev->features & NETIF_F_RXCSUM)
1487 && cksum == STATUS_CKSUM_OK)) {
1490 adapter->stats.csummed++; 1488 adapter->stats.csummed++;
1491 skb->ip_summed = CHECKSUM_UNNECESSARY; 1489 skb->ip_summed = CHECKSUM_UNNECESSARY;
1492 } else 1490 } else
@@ -1763,14 +1761,10 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1763 1761
1764 smp_mb(); 1762 smp_mb();
1765 1763
1766 if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) { 1764 if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev))
1767 __netif_tx_lock(tx_ring->txq, smp_processor_id()); 1765 if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH)
1768 if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) {
1769 netif_wake_queue(netdev); 1766 netif_wake_queue(netdev);
1770 adapter->tx_timeo_cnt = 0; 1767 adapter->tx_timeo_cnt = 0;
1771 }
1772 __netif_tx_unlock(tx_ring->txq);
1773 }
1774 } 1768 }
1775 /* 1769 /*
1776 * If everything is freed up to consumer then check if the ring is full 1770 * If everything is freed up to consumer then check if the ring is full
@@ -1789,7 +1783,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1789 done = (sw_consumer == hw_consumer); 1783 done = (sw_consumer == hw_consumer);
1790 spin_unlock(&adapter->tx_clean_lock); 1784 spin_unlock(&adapter->tx_clean_lock);
1791 1785
1792 return (done); 1786 return done;
1793} 1787}
1794 1788
1795void 1789void
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 73d314592230..c0788a31ff0f 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -38,12 +38,9 @@
38#include <linux/sysfs.h> 38#include <linux/sysfs.h>
39#include <linux/aer.h> 39#include <linux/aer.h>
40 40
41MODULE_DESCRIPTION("QLogic/NetXen (1/10) GbE Converged Ethernet Driver"); 41MODULE_DESCRIPTION("QLogic/NetXen (1/10) GbE Intelligent Ethernet Driver");
42MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
43MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); 43MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
44MODULE_FIRMWARE(NX_P2_MN_ROMIMAGE_NAME);
45MODULE_FIRMWARE(NX_P3_CT_ROMIMAGE_NAME);
46MODULE_FIRMWARE(NX_P3_MN_ROMIMAGE_NAME);
47MODULE_FIRMWARE(NX_UNIFIED_ROMIMAGE_NAME); 44MODULE_FIRMWARE(NX_UNIFIED_ROMIMAGE_NAME);
48 45
49char netxen_nic_driver_name[] = "netxen_nic"; 46char netxen_nic_driver_name[] = "netxen_nic";
@@ -95,6 +92,8 @@ static irqreturn_t netxen_msi_intr(int irq, void *data);
95static irqreturn_t netxen_msix_intr(int irq, void *data); 92static irqreturn_t netxen_msix_intr(int irq, void *data);
96 93
97static void netxen_config_indev_addr(struct net_device *dev, unsigned long); 94static void netxen_config_indev_addr(struct net_device *dev, unsigned long);
95static struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
96static int netxen_nic_set_mac(struct net_device *netdev, void *p);
98 97
99/* PCI Device ID Table */ 98/* PCI Device ID Table */
100#define ENTRY(device) \ 99#define ENTRY(device) \
@@ -125,11 +124,6 @@ netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
125 struct nx_host_tx_ring *tx_ring) 124 struct nx_host_tx_ring *tx_ring)
126{ 125{
127 NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); 126 NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer);
128
129 if (netxen_tx_avail(tx_ring) <= TX_STOP_THRESH) {
130 netif_stop_queue(adapter->netdev);
131 smp_mb();
132 }
133} 127}
134 128
135static uint32_t crb_cmd_consumer[4] = { 129static uint32_t crb_cmd_consumer[4] = {
@@ -177,7 +171,7 @@ netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count)
177 171
178 recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); 172 recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL);
179 173
180 return (recv_ctx->sds_rings == NULL); 174 return recv_ctx->sds_rings == NULL;
181} 175}
182 176
183static void 177static void
@@ -460,7 +454,7 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
460 return 0; 454 return 0;
461} 455}
462 456
463int netxen_nic_set_mac(struct net_device *netdev, void *p) 457static int netxen_nic_set_mac(struct net_device *netdev, void *p)
464{ 458{
465 struct netxen_adapter *adapter = netdev_priv(netdev); 459 struct netxen_adapter *adapter = netdev_priv(netdev);
466 struct sockaddr *addr = p; 460 struct sockaddr *addr = p;
@@ -491,6 +485,37 @@ static void netxen_set_multicast_list(struct net_device *dev)
491 adapter->set_multi(dev); 485 adapter->set_multi(dev);
492} 486}
493 487
488static u32 netxen_fix_features(struct net_device *dev, u32 features)
489{
490 if (!(features & NETIF_F_RXCSUM)) {
491 netdev_info(dev, "disabling LRO as RXCSUM is off\n");
492
493 features &= ~NETIF_F_LRO;
494 }
495
496 return features;
497}
498
499static int netxen_set_features(struct net_device *dev, u32 features)
500{
501 struct netxen_adapter *adapter = netdev_priv(dev);
502 int hw_lro;
503
504 if (!((dev->features ^ features) & NETIF_F_LRO))
505 return 0;
506
507 hw_lro = (features & NETIF_F_LRO) ? NETXEN_NIC_LRO_ENABLED
508 : NETXEN_NIC_LRO_DISABLED;
509
510 if (netxen_config_hw_lro(adapter, hw_lro))
511 return -EIO;
512
513 if (!(features & NETIF_F_LRO) && netxen_send_lro_cleanup(adapter))
514 return -EIO;
515
516 return 0;
517}
518
494static const struct net_device_ops netxen_netdev_ops = { 519static const struct net_device_ops netxen_netdev_ops = {
495 .ndo_open = netxen_nic_open, 520 .ndo_open = netxen_nic_open,
496 .ndo_stop = netxen_nic_close, 521 .ndo_stop = netxen_nic_close,
@@ -501,6 +526,8 @@ static const struct net_device_ops netxen_netdev_ops = {
501 .ndo_set_mac_address = netxen_nic_set_mac, 526 .ndo_set_mac_address = netxen_nic_set_mac,
502 .ndo_change_mtu = netxen_nic_change_mtu, 527 .ndo_change_mtu = netxen_nic_change_mtu,
503 .ndo_tx_timeout = netxen_tx_timeout, 528 .ndo_tx_timeout = netxen_tx_timeout,
529 .ndo_fix_features = netxen_fix_features,
530 .ndo_set_features = netxen_set_features,
504#ifdef CONFIG_NET_POLL_CONTROLLER 531#ifdef CONFIG_NET_POLL_CONTROLLER
505 .ndo_poll_controller = netxen_nic_poll_controller, 532 .ndo_poll_controller = netxen_nic_poll_controller,
506#endif 533#endif
@@ -768,8 +795,6 @@ netxen_check_options(struct netxen_adapter *adapter)
768 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) 795 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222))
769 adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); 796 adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1);
770 797
771 adapter->flags &= ~NETXEN_NIC_LRO_ENABLED;
772
773 if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 798 if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
774 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; 799 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G;
775 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; 800 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G;
@@ -913,7 +938,7 @@ netxen_nic_request_irq(struct netxen_adapter *adapter)
913 struct nx_host_sds_ring *sds_ring; 938 struct nx_host_sds_ring *sds_ring;
914 int err, ring; 939 int err, ring;
915 940
916 unsigned long flags = IRQF_SAMPLE_RANDOM; 941 unsigned long flags = 0;
917 struct net_device *netdev = adapter->netdev; 942 struct net_device *netdev = adapter->netdev;
918 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; 943 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
919 944
@@ -996,7 +1021,7 @@ __netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
996 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 1021 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
997 netxen_config_intr_coalesce(adapter); 1022 netxen_config_intr_coalesce(adapter);
998 1023
999 if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) 1024 if (netdev->features & NETIF_F_LRO)
1000 netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_ENABLED); 1025 netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_ENABLED);
1001 1026
1002 netxen_napi_enable(adapter); 1027 netxen_napi_enable(adapter);
@@ -1040,6 +1065,9 @@ __netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1040 netif_carrier_off(netdev); 1065 netif_carrier_off(netdev);
1041 netif_tx_disable(netdev); 1066 netif_tx_disable(netdev);
1042 1067
1068 if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)
1069 netxen_linkevent_request(adapter, 0);
1070
1043 if (adapter->stop_port) 1071 if (adapter->stop_port)
1044 adapter->stop_port(adapter); 1072 adapter->stop_port(adapter);
1045 1073
@@ -1201,7 +1229,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
1201 int err = 0; 1229 int err = 0;
1202 struct pci_dev *pdev = adapter->pdev; 1230 struct pci_dev *pdev = adapter->pdev;
1203 1231
1204 adapter->rx_csum = 1;
1205 adapter->mc_enabled = 0; 1232 adapter->mc_enabled = 0;
1206 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 1233 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1207 adapter->max_mc_count = 38; 1234 adapter->max_mc_count = 38;
@@ -1209,20 +1236,19 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
1209 adapter->max_mc_count = 16; 1236 adapter->max_mc_count = 16;
1210 1237
1211 netdev->netdev_ops = &netxen_netdev_ops; 1238 netdev->netdev_ops = &netxen_netdev_ops;
1212 netdev->watchdog_timeo = 2*HZ; 1239 netdev->watchdog_timeo = 5*HZ;
1213 1240
1214 netxen_nic_change_mtu(netdev, netdev->mtu); 1241 netxen_nic_change_mtu(netdev, netdev->mtu);
1215 1242
1216 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); 1243 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
1217 1244
1218 netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO); 1245 netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
1219 netdev->features |= (NETIF_F_GRO); 1246 NETIF_F_RXCSUM;
1220 netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
1221 1247
1222 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 1248 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
1223 netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); 1249 netdev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
1224 netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); 1250
1225 } 1251 netdev->vlan_features |= netdev->hw_features;
1226 1252
1227 if (adapter->pci_using_dac) { 1253 if (adapter->pci_using_dac) {
1228 netdev->features |= NETIF_F_HIGHDMA; 1254 netdev->features |= NETIF_F_HIGHDMA;
@@ -1230,10 +1256,12 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
1230 } 1256 }
1231 1257
1232 if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX) 1258 if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX)
1233 netdev->features |= (NETIF_F_HW_VLAN_TX); 1259 netdev->hw_features |= NETIF_F_HW_VLAN_TX;
1234 1260
1235 if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) 1261 if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO)
1236 netdev->features |= NETIF_F_LRO; 1262 netdev->hw_features |= NETIF_F_LRO;
1263
1264 netdev->features |= netdev->hw_features;
1237 1265
1238 netdev->irq = adapter->msix_entries[0].vector; 1266 netdev->irq = adapter->msix_entries[0].vector;
1239 1267
@@ -1243,7 +1271,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
1243 dev_warn(&pdev->dev, "failed to read mac addr\n"); 1271 dev_warn(&pdev->dev, "failed to read mac addr\n");
1244 1272
1245 netif_carrier_off(netdev); 1273 netif_carrier_off(netdev);
1246 netif_stop_queue(netdev);
1247 1274
1248 err = register_netdev(netdev); 1275 err = register_netdev(netdev);
1249 if (err) { 1276 if (err) {
@@ -1254,6 +1281,28 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
1254 return 0; 1281 return 0;
1255} 1282}
1256 1283
1284#ifdef CONFIG_PCIEAER
1285static void netxen_mask_aer_correctable(struct netxen_adapter *adapter)
1286{
1287 struct pci_dev *pdev = adapter->pdev;
1288 struct pci_dev *root = pdev->bus->self;
1289 u32 aer_pos;
1290
1291 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM &&
1292 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP)
1293 return;
1294
1295 if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT)
1296 return;
1297
1298 aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR);
1299 if (!aer_pos)
1300 return;
1301
1302 pci_write_config_dword(root, aer_pos + PCI_ERR_COR_MASK, 0xffff);
1303}
1304#endif
1305
1257static int __devinit 1306static int __devinit
1258netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 1307netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1259{ 1308{
@@ -1262,6 +1311,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1262 int i = 0, err; 1311 int i = 0, err;
1263 int pci_func_id = PCI_FUNC(pdev->devfn); 1312 int pci_func_id = PCI_FUNC(pdev->devfn);
1264 uint8_t revision_id; 1313 uint8_t revision_id;
1314 u32 val;
1265 1315
1266 if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) { 1316 if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) {
1267 pr_warning("%s: chip revisions between 0x%x-0x%x " 1317 pr_warning("%s: chip revisions between 0x%x-0x%x "
@@ -1322,6 +1372,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1322 goto err_out_iounmap; 1372 goto err_out_iounmap;
1323 } 1373 }
1324 1374
1375#ifdef CONFIG_PCIEAER
1376 netxen_mask_aer_correctable(adapter);
1377#endif
1378
1325 /* Mezz cards have PCI function 0,2,3 enabled */ 1379 /* Mezz cards have PCI function 0,2,3 enabled */
1326 switch (adapter->ahw.board_type) { 1380 switch (adapter->ahw.board_type) {
1327 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: 1381 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
@@ -1333,6 +1387,14 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1333 break; 1387 break;
1334 } 1388 }
1335 1389
1390 if (adapter->portnum == 0) {
1391 val = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
1392 if (val != 0xffffffff && val != 0) {
1393 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, 0);
1394 adapter->need_fw_reset = 1;
1395 }
1396 }
1397
1336 err = netxen_start_firmware(adapter); 1398 err = netxen_start_firmware(adapter);
1337 if (err) 1399 if (err)
1338 goto err_out_decr_ref; 1400 goto err_out_decr_ref;
@@ -1815,6 +1877,8 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1815 struct cmd_desc_type0 *hwdesc, *first_desc; 1877 struct cmd_desc_type0 *hwdesc, *first_desc;
1816 struct pci_dev *pdev; 1878 struct pci_dev *pdev;
1817 int i, k; 1879 int i, k;
1880 int delta = 0;
1881 struct skb_frag_struct *frag;
1818 1882
1819 u32 producer; 1883 u32 producer;
1820 int frag_count, no_of_desc; 1884 int frag_count, no_of_desc;
@@ -1822,12 +1886,31 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1822 1886
1823 frag_count = skb_shinfo(skb)->nr_frags + 1; 1887 frag_count = skb_shinfo(skb)->nr_frags + 1;
1824 1888
1889 /* 14 frags supported for normal packet and
1890 * 32 frags supported for TSO packet
1891 */
1892 if (!skb_is_gso(skb) && frag_count > NETXEN_MAX_FRAGS_PER_TX) {
1893
1894 for (i = 0; i < (frag_count - NETXEN_MAX_FRAGS_PER_TX); i++) {
1895 frag = &skb_shinfo(skb)->frags[i];
1896 delta += frag->size;
1897 }
1898
1899 if (!__pskb_pull_tail(skb, delta))
1900 goto drop_packet;
1901
1902 frag_count = 1 + skb_shinfo(skb)->nr_frags;
1903 }
1825 /* 4 fragments per cmd des */ 1904 /* 4 fragments per cmd des */
1826 no_of_desc = (frag_count + 3) >> 2; 1905 no_of_desc = (frag_count + 3) >> 2;
1827 1906
1828 if (unlikely(no_of_desc + 2 > netxen_tx_avail(tx_ring))) { 1907 if (unlikely(netxen_tx_avail(tx_ring) <= TX_STOP_THRESH)) {
1829 netif_stop_queue(netdev); 1908 netif_stop_queue(netdev);
1830 return NETDEV_TX_BUSY; 1909 smp_mb();
1910 if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH)
1911 netif_start_queue(netdev);
1912 else
1913 return NETDEV_TX_BUSY;
1831 } 1914 }
1832 1915
1833 producer = tx_ring->producer; 1916 producer = tx_ring->producer;
@@ -1882,11 +1965,11 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1882 1965
1883 netxen_tso_check(netdev, tx_ring, first_desc, skb); 1966 netxen_tso_check(netdev, tx_ring, first_desc, skb);
1884 1967
1885 netxen_nic_update_cmd_producer(adapter, tx_ring);
1886
1887 adapter->stats.txbytes += skb->len; 1968 adapter->stats.txbytes += skb->len;
1888 adapter->stats.xmitcalled++; 1969 adapter->stats.xmitcalled++;
1889 1970
1971 netxen_nic_update_cmd_producer(adapter, tx_ring);
1972
1890 return NETDEV_TX_OK; 1973 return NETDEV_TX_OK;
1891 1974
1892drop_packet: 1975drop_packet:
@@ -2027,7 +2110,7 @@ request_reset:
2027 clear_bit(__NX_RESETTING, &adapter->state); 2110 clear_bit(__NX_RESETTING, &adapter->state);
2028} 2111}
2029 2112
2030struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) 2113static struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
2031{ 2114{
2032 struct netxen_adapter *adapter = netdev_priv(netdev); 2115 struct netxen_adapter *adapter = netdev_priv(netdev);
2033 struct net_device_stats *stats = &netdev->stats; 2116 struct net_device_stats *stats = &netdev->stats;