diff options
author | Ananda Raju <Ananda.Raju@neterion.com> | 2006-04-21 19:05:41 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-05-02 15:16:36 -0400 |
commit | 9dc737a77353920a67337aa627f7d9dae8dade05 (patch) | |
tree | b87c69eb07c905791c68b7b976b72b31712ac621 /drivers/net/s2io.c | |
parent | 863c11a91e4507c3ff44783a75a5433c8cf7700e (diff) |
[PATCH] s2io: input parms, output messages update
hi,
This patch contains the modification and bug fixes with respect to
input parameters and outupt dmesages. following is brief description
of the changes.
1. Set default values for rx_ring_sz[0..7] and tx_fifo_len[0..7]
2. verify few basic load parameters
3. read product description from VPD
4. clean up of dmesg when driver is loaded
Signed-off-by: Ananda Raju <ananda.raju@neterion.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/s2io.c')
-rw-r--r-- | drivers/net/s2io.c | 223 |
1 files changed, 140 insertions, 83 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. */ |
300 | static unsigned int tx_fifo_num = 1; | 307 | static unsigned int tx_fifo_num = 1; |
301 | static unsigned int tx_fifo_len[MAX_TX_FIFOS] = | 308 | static 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}; |
303 | static unsigned int rx_ring_num = 1; | 310 | static unsigned int rx_ring_num = 1; |
304 | static unsigned int rx_ring_sz[MAX_RX_RINGS] = | 311 | static unsigned int rx_ring_sz[MAX_RX_RINGS] = |
305 | {[0 ...(MAX_RX_RINGS - 1)] = 0 }; | 312 | {[0 ...(MAX_RX_RINGS - 1)] = SMALL_BLK_CNT}; |
306 | static unsigned int rts_frm_len[MAX_RX_RINGS] = | 313 | static unsigned int rts_frm_len[MAX_RX_RINGS] = |
307 | {[0 ...(MAX_RX_RINGS - 1)] = 0 }; | 314 | {[0 ...(MAX_RX_RINGS - 1)] = 0 }; |
308 | static unsigned int rx_ring_mode = 1; | 315 | static 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 | ||
4636 | static 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); | |||
5962 | module_param(lro, int, 0); | 6008 | module_param(lro, int, 0); |
5963 | module_param(lro_max_pkts, int, 0); | 6009 | module_param(lro_max_pkts, int, 0); |
5964 | 6010 | ||
6011 | static 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 \ | ||
5998 | is 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. \ | ||
6033 | Defaulting 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; |