aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/s2io.c223
-rw-r--r--drivers/net/s2io.h9
2 files changed, 146 insertions, 86 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 846873159662..1dcda887cef7 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -26,15 +26,22 @@
26 * 26 *
27 * The module loadable parameters that are supported by the driver and a brief 27 * The module loadable parameters that are supported by the driver and a brief
28 * explaination of all the variables. 28 * explaination of all the variables.
29 *
29 * rx_ring_num : This can be used to program the number of receive rings used 30 * rx_ring_num : This can be used to program the number of receive rings used
30 * in the driver. 31 * in the driver.
31 * rx_ring_sz: This defines the number of descriptors each ring can have. This 32 * rx_ring_sz: This defines the number of receive blocks each ring can have.
32 * is also an array of size 8. 33 * This is also an array of size 8.
33 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid 34 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid
34 * values are 1, 2 and 3. 35 * values are 1, 2 and 3.
35 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. 36 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
36 * tx_fifo_len: This too is an array of 8. Each element defines the number of 37 * tx_fifo_len: This too is an array of 8. Each element defines the number of
37 * Tx descriptors that can be associated with each corresponding FIFO. 38 * Tx descriptors that can be associated with each corresponding FIFO.
39 * intr_type: This defines the type of interrupt. The values can be 0(INTA),
40 * 1(MSI), 2(MSI_X). Default value is '0(INTA)'
41 * lro: Specifies whether to enable Large Receive Offload (LRO) or not.
42 * Possible values '1' for enable '0' for disable. Default is '0'
43 * lro_max_pkts: This parameter defines maximum number of packets can be
44 * aggregated as a single large packet
38 ************************************************************************/ 45 ************************************************************************/
39 46
40#include <linux/config.h> 47#include <linux/config.h>
@@ -299,10 +306,10 @@ static const u64 fix_mac[] = {
299/* Module Loadable parameters. */ 306/* Module Loadable parameters. */
300static unsigned int tx_fifo_num = 1; 307static unsigned int tx_fifo_num = 1;
301static unsigned int tx_fifo_len[MAX_TX_FIFOS] = 308static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
302 {[0 ...(MAX_TX_FIFOS - 1)] = 0 }; 309 {DEFAULT_FIFO_0_LEN, [1 ...(MAX_TX_FIFOS - 1)] = DEFAULT_FIFO_1_7_LEN};
303static unsigned int rx_ring_num = 1; 310static unsigned int rx_ring_num = 1;
304static unsigned int rx_ring_sz[MAX_RX_RINGS] = 311static unsigned int rx_ring_sz[MAX_RX_RINGS] =
305 {[0 ...(MAX_RX_RINGS - 1)] = 0 }; 312 {[0 ...(MAX_RX_RINGS - 1)] = SMALL_BLK_CNT};
306static unsigned int rts_frm_len[MAX_RX_RINGS] = 313static unsigned int rts_frm_len[MAX_RX_RINGS] =
307 {[0 ...(MAX_RX_RINGS - 1)] = 0 }; 314 {[0 ...(MAX_RX_RINGS - 1)] = 0 };
308static unsigned int rx_ring_mode = 1; 315static unsigned int rx_ring_mode = 1;
@@ -4626,6 +4633,45 @@ static int write_eeprom(nic_t * sp, int off, u64 data, int cnt)
4626 return ret; 4633 return ret;
4627} 4634}
4628 4635
4636static void s2io_vpd_read(nic_t *nic)
4637{
4638 u8 vpd_data[256],data;
4639 int i=0, cnt, fail = 0;
4640 int vpd_addr = 0x80;
4641
4642 if (nic->device_type == XFRAME_II_DEVICE) {
4643 strcpy(nic->product_name, "Xframe II 10GbE network adapter");
4644 vpd_addr = 0x80;
4645 }
4646 else {
4647 strcpy(nic->product_name, "Xframe I 10GbE network adapter");
4648 vpd_addr = 0x50;
4649 }
4650
4651 for (i = 0; i < 256; i +=4 ) {
4652 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i);
4653 pci_read_config_byte(nic->pdev, (vpd_addr + 2), &data);
4654 pci_write_config_byte(nic->pdev, (vpd_addr + 3), 0);
4655 for (cnt = 0; cnt <5; cnt++) {
4656 msleep(2);
4657 pci_read_config_byte(nic->pdev, (vpd_addr + 3), &data);
4658 if (data == 0x80)
4659 break;
4660 }
4661 if (cnt >= 5) {
4662 DBG_PRINT(ERR_DBG, "Read of VPD data failed\n");
4663 fail = 1;
4664 break;
4665 }
4666 pci_read_config_dword(nic->pdev, (vpd_addr + 4),
4667 (u32 *)&vpd_data[i]);
4668 }
4669 if ((!fail) && (vpd_data[1] < VPD_PRODUCT_NAME_LEN)) {
4670 memset(nic->product_name, 0, vpd_data[1]);
4671 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]);
4672 }
4673}
4674
4629/** 4675/**
4630 * s2io_ethtool_geeprom - reads the value stored in the Eeprom. 4676 * s2io_ethtool_geeprom - reads the value stored in the Eeprom.
4631 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. 4677 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure.
@@ -5962,6 +6008,55 @@ module_param(intr_type, int, 0);
5962module_param(lro, int, 0); 6008module_param(lro, int, 0);
5963module_param(lro_max_pkts, int, 0); 6009module_param(lro_max_pkts, int, 0);
5964 6010
6011static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type)
6012{
6013 if ( tx_fifo_num > 8) {
6014 DBG_PRINT(ERR_DBG, "s2io: Requested number of Tx fifos not "
6015 "supported\n");
6016 DBG_PRINT(ERR_DBG, "s2io: Default to 8 Tx fifos\n");
6017 tx_fifo_num = 8;
6018 }
6019 if ( rx_ring_num > 8) {
6020 DBG_PRINT(ERR_DBG, "s2io: Requested number of Rx rings not "
6021 "supported\n");
6022 DBG_PRINT(ERR_DBG, "s2io: Default to 8 Rx rings\n");
6023 rx_ring_num = 8;
6024 }
6025#ifdef CONFIG_S2IO_NAPI
6026 if (*dev_intr_type != INTA) {
6027 DBG_PRINT(ERR_DBG, "s2io: NAPI cannot be enabled when "
6028 "MSI/MSI-X is enabled. Defaulting to INTA\n");
6029 *dev_intr_type = INTA;
6030 }
6031#endif
6032#ifndef CONFIG_PCI_MSI
6033 if (*dev_intr_type != INTA) {
6034 DBG_PRINT(ERR_DBG, "s2io: This kernel does not support"
6035 "MSI/MSI-X. Defaulting to INTA\n");
6036 *dev_intr_type = INTA;
6037 }
6038#else
6039 if (*dev_intr_type > MSI_X) {
6040 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. "
6041 "Defaulting to INTA\n");
6042 *dev_intr_type = INTA;
6043 }
6044#endif
6045 if ((*dev_intr_type == MSI_X) &&
6046 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
6047 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
6048 DBG_PRINT(ERR_DBG, "s2io: Xframe I does not support MSI_X. "
6049 "Defaulting to INTA\n");
6050 *dev_intr_type = INTA;
6051 }
6052 if (rx_ring_mode > 3) {
6053 DBG_PRINT(ERR_DBG, "s2io: Requested ring mode not supported\n");
6054 DBG_PRINT(ERR_DBG, "s2io: Defaulting to 3-buffer mode\n");
6055 rx_ring_mode = 3;
6056 }
6057 return SUCCESS;
6058}
6059
5965/** 6060/**
5966 * s2io_init_nic - Initialization of the adapter . 6061 * s2io_init_nic - Initialization of the adapter .
5967 * @pdev : structure containing the PCI related information of the device. 6062 * @pdev : structure containing the PCI related information of the device.
@@ -5992,15 +6087,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5992 int mode; 6087 int mode;
5993 u8 dev_intr_type = intr_type; 6088 u8 dev_intr_type = intr_type;
5994 6089
5995#ifdef CONFIG_S2IO_NAPI 6090 if ((ret = s2io_verify_parm(pdev, &dev_intr_type)))
5996 if (dev_intr_type != INTA) { 6091 return ret;
5997 DBG_PRINT(ERR_DBG, "NAPI cannot be enabled when MSI/MSI-X \
5998is enabled. Defaulting to INTA\n");
5999 dev_intr_type = INTA;
6000 }
6001 else
6002 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
6003#endif
6004 6092
6005 if ((ret = pci_enable_device(pdev))) { 6093 if ((ret = pci_enable_device(pdev))) {
6006 DBG_PRINT(ERR_DBG, 6094 DBG_PRINT(ERR_DBG,
@@ -6025,14 +6113,6 @@ is enabled. Defaulting to INTA\n");
6025 pci_disable_device(pdev); 6113 pci_disable_device(pdev);
6026 return -ENOMEM; 6114 return -ENOMEM;
6027 } 6115 }
6028
6029 if ((dev_intr_type == MSI_X) &&
6030 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
6031 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
6032 DBG_PRINT(ERR_DBG, "Xframe I does not support MSI_X. \
6033Defaulting to INTA\n");
6034 dev_intr_type = INTA;
6035 }
6036 if (dev_intr_type != MSI_X) { 6116 if (dev_intr_type != MSI_X) {
6037 if (pci_request_regions(pdev, s2io_driver_name)) { 6117 if (pci_request_regions(pdev, s2io_driver_name)) {
6038 DBG_PRINT(ERR_DBG, "Request Regions failed\n"), 6118 DBG_PRINT(ERR_DBG, "Request Regions failed\n"),
@@ -6108,8 +6188,6 @@ Defaulting to INTA\n");
6108 config = &sp->config; 6188 config = &sp->config;
6109 6189
6110 /* Tx side parameters. */ 6190 /* Tx side parameters. */
6111 if (tx_fifo_len[0] == 0)
6112 tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */
6113 config->tx_fifo_num = tx_fifo_num; 6191 config->tx_fifo_num = tx_fifo_num;
6114 for (i = 0; i < MAX_TX_FIFOS; i++) { 6192 for (i = 0; i < MAX_TX_FIFOS; i++) {
6115 config->tx_cfg[i].fifo_len = tx_fifo_len[i]; 6193 config->tx_cfg[i].fifo_len = tx_fifo_len[i];
@@ -6133,8 +6211,6 @@ Defaulting to INTA\n");
6133 config->max_txds = MAX_SKB_FRAGS + 2; 6211 config->max_txds = MAX_SKB_FRAGS + 2;
6134 6212
6135 /* Rx side parameters. */ 6213 /* Rx side parameters. */
6136 if (rx_ring_sz[0] == 0)
6137 rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */
6138 config->rx_ring_num = rx_ring_num; 6214 config->rx_ring_num = rx_ring_num;
6139 for (i = 0; i < MAX_RX_RINGS; i++) { 6215 for (i = 0; i < MAX_RX_RINGS; i++) {
6140 config->rx_cfg[i].num_rxd = rx_ring_sz[i] * 6216 config->rx_cfg[i].num_rxd = rx_ring_sz[i] *
@@ -6330,82 +6406,63 @@ Defaulting to INTA\n");
6330 ret = -ENODEV; 6406 ret = -ENODEV;
6331 goto register_failed; 6407 goto register_failed;
6332 } 6408 }
6333 6409 s2io_vpd_read(sp);
6334 if (sp->device_type & XFRAME_II_DEVICE) { 6410 DBG_PRINT(ERR_DBG, "%s: Neterion %s",dev->name, sp->product_name);
6335 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ", 6411 DBG_PRINT(ERR_DBG, "(rev %d), Driver version %s\n",
6336 dev->name);
6337 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
6338 get_xena_rev_id(sp->pdev), 6412 get_xena_rev_id(sp->pdev),
6339 s2io_driver_version); 6413 s2io_driver_version);
6340 switch(sp->intr_type) { 6414 DBG_PRINT(ERR_DBG, "Copyright(c) 2002-2005 Neterion Inc.\n");
6341 case INTA: 6415 DBG_PRINT(ERR_DBG, "%s: MAC ADDR: "
6342 DBG_PRINT(ERR_DBG, ", Intr type INTA"); 6416 "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
6343 break;
6344 case MSI:
6345 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6346 break;
6347 case MSI_X:
6348 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6349 break;
6350 }
6351
6352 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
6353 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
6354 sp->def_mac_addr[0].mac_addr[0], 6417 sp->def_mac_addr[0].mac_addr[0],
6355 sp->def_mac_addr[0].mac_addr[1], 6418 sp->def_mac_addr[0].mac_addr[1],
6356 sp->def_mac_addr[0].mac_addr[2], 6419 sp->def_mac_addr[0].mac_addr[2],
6357 sp->def_mac_addr[0].mac_addr[3], 6420 sp->def_mac_addr[0].mac_addr[3],
6358 sp->def_mac_addr[0].mac_addr[4], 6421 sp->def_mac_addr[0].mac_addr[4],
6359 sp->def_mac_addr[0].mac_addr[5]); 6422 sp->def_mac_addr[0].mac_addr[5]);
6423 if (sp->device_type & XFRAME_II_DEVICE) {
6360 mode = s2io_print_pci_mode(sp); 6424 mode = s2io_print_pci_mode(sp);
6361 if (mode < 0) { 6425 if (mode < 0) {
6362 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode "); 6426 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode\n");
6363 ret = -EBADSLT; 6427 ret = -EBADSLT;
6428 unregister_netdev(dev);
6364 goto set_swap_failed; 6429 goto set_swap_failed;
6365 } 6430 }
6366 } else {
6367 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
6368 dev->name);
6369 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
6370 get_xena_rev_id(sp->pdev),
6371 s2io_driver_version);
6372 switch(sp->intr_type) {
6373 case INTA:
6374 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6375 break;
6376 case MSI:
6377 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6378 break;
6379 case MSI_X:
6380 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6381 break;
6382 }
6383 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
6384 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
6385 sp->def_mac_addr[0].mac_addr[0],
6386 sp->def_mac_addr[0].mac_addr[1],
6387 sp->def_mac_addr[0].mac_addr[2],
6388 sp->def_mac_addr[0].mac_addr[3],
6389 sp->def_mac_addr[0].mac_addr[4],
6390 sp->def_mac_addr[0].mac_addr[5]);
6391 } 6431 }
6392 if (sp->rxd_mode == RXD_MODE_3B) 6432 switch(sp->rxd_mode) {
6393 DBG_PRINT(ERR_DBG, "%s: 2-Buffer mode support has been " 6433 case RXD_MODE_1:
6394 "enabled\n",dev->name); 6434 DBG_PRINT(ERR_DBG, "%s: 1-Buffer receive mode enabled\n",
6395 if (sp->rxd_mode == RXD_MODE_3A) 6435 dev->name);
6396 DBG_PRINT(ERR_DBG, "%s: 3-Buffer mode support has been " 6436 break;
6397 "enabled\n",dev->name); 6437 case RXD_MODE_3B:
6398 6438 DBG_PRINT(ERR_DBG, "%s: 2-Buffer receive mode enabled\n",
6439 dev->name);
6440 break;
6441 case RXD_MODE_3A:
6442 DBG_PRINT(ERR_DBG, "%s: 3-Buffer receive mode enabled\n",
6443 dev->name);
6444 break;
6445 }
6446#ifdef CONFIG_S2IO_NAPI
6447 DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name);
6448#endif
6449 switch(sp->intr_type) {
6450 case INTA:
6451 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name);
6452 break;
6453 case MSI:
6454 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI\n", dev->name);
6455 break;
6456 case MSI_X:
6457 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI-X\n", dev->name);
6458 break;
6459 }
6399 if (sp->lro) 6460 if (sp->lro)
6400 DBG_PRINT(ERR_DBG, "%s: Large receive offload enabled\n", 6461 DBG_PRINT(ERR_DBG, "%s: Large receive offload enabled\n",
6401 dev->name); 6462 dev->name);
6402 6463
6403 /* Initialize device name */ 6464 /* Initialize device name */
6404 strcpy(sp->name, dev->name); 6465 sprintf(sp->name, "%s Neterion %s", dev->name, sp->product_name);
6405 if (sp->device_type & XFRAME_II_DEVICE)
6406 strcat(sp->name, ": Neterion Xframe II 10GbE adapter");
6407 else
6408 strcat(sp->name, ": Neterion Xframe I 10GbE adapter");
6409 6466
6410 /* Initialize bimodal Interrupts */ 6467 /* Initialize bimodal Interrupts */
6411 sp->config.bimodal = bimodal; 6468 sp->config.bimodal = bimodal;
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 0a0b5b29d81e..a83a1d85f72e 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -659,9 +659,10 @@ typedef struct {
659} usr_addr_t; 659} usr_addr_t;
660 660
661/* Default Tunable parameters of the NIC. */ 661/* Default Tunable parameters of the NIC. */
662#define DEFAULT_FIFO_LEN 4096 662#define DEFAULT_FIFO_0_LEN 4096
663#define SMALL_BLK_CNT 30 663#define DEFAULT_FIFO_1_7_LEN 512
664#define LARGE_BLK_CNT 100 664#define SMALL_BLK_CNT 30
665#define LARGE_BLK_CNT 100
665 666
666/* 667/*
667 * Structure to keep track of the MSI-X vectors and the corresponding 668 * Structure to keep track of the MSI-X vectors and the corresponding
@@ -824,6 +825,8 @@ struct s2io_nic {
824 spinlock_t rx_lock; 825 spinlock_t rx_lock;
825 atomic_t isr_cnt; 826 atomic_t isr_cnt;
826 u64 *ufo_in_band_v; 827 u64 *ufo_in_band_v;
828#define VPD_PRODUCT_NAME_LEN 50
829 u8 product_name[VPD_PRODUCT_NAME_LEN];
827}; 830};
828 831
829#define RESET_ERROR 1; 832#define RESET_ERROR 1;