aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r--drivers/net/netxen/netxen_nic_main.c147
1 files changed, 115 insertions, 32 deletions
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;