diff options
author | raghavendra.koushik@neterion.com <raghavendra.koushik@neterion.com> | 2005-08-03 15:39:56 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-08-11 00:10:45 -0400 |
commit | 0b1f7ebe455ba4f1f46e7024150eeddbbf08addc (patch) | |
tree | 1d9f34fc02fdd7ae18034ced47061ac239b2af7c | |
parent | a371a07de9bce837ea4e84569a2b390a42e360ef (diff) |
[PATCH] S2io: Miscellaneous fixes
Hi,
The last patch in this series fixes the following issues found during
testing.
1. Ensure we don't pass zero sized buffers to the card(which can lockup)
2. Restore the PCI-X parameters(in case of Xframe I adapter) after a reset.
3. Make sure total size of all FIFOs does not exceed 8192.
Signed-off-by: Ravinandan Arakali <ravinandan.arakali@neterion.com>
Signed-off-by: Raghavendra Koushik <raghavendra.koushik@neterion.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | drivers/net/s2io.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index e7c428561e3f..abf910e40334 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -365,10 +365,9 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
365 | size += config->tx_cfg[i].fifo_len; | 365 | size += config->tx_cfg[i].fifo_len; |
366 | } | 366 | } |
367 | if (size > MAX_AVAILABLE_TXDS) { | 367 | if (size > MAX_AVAILABLE_TXDS) { |
368 | DBG_PRINT(ERR_DBG, "%s: Total number of Tx FIFOs ", | 368 | DBG_PRINT(ERR_DBG, "%s: Requested TxDs too high, ", |
369 | dev->name); | 369 | __FUNCTION__); |
370 | DBG_PRINT(ERR_DBG, "exceeds the maximum value "); | 370 | DBG_PRINT(ERR_DBG, "Requested: %d, max supported: 8192\n", size); |
371 | DBG_PRINT(ERR_DBG, "that can be used\n"); | ||
372 | return FAILURE; | 371 | return FAILURE; |
373 | } | 372 | } |
374 | 373 | ||
@@ -611,8 +610,9 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
611 | lst_per_page); | 610 | lst_per_page); |
612 | for (j = 0; j < page_num; j++) { | 611 | for (j = 0; j < page_num; j++) { |
613 | int mem_blks = (j * lst_per_page); | 612 | int mem_blks = (j * lst_per_page); |
614 | if (!mac_control->fifos[i].list_info[mem_blks]. | 613 | if ((!mac_control->fifos[i].list_info) || |
615 | list_virt_addr) | 614 | (!mac_control->fifos[i].list_info[mem_blks]. |
615 | list_virt_addr)) | ||
616 | break; | 616 | break; |
617 | pci_free_consistent(nic->pdev, PAGE_SIZE, | 617 | pci_free_consistent(nic->pdev, PAGE_SIZE, |
618 | mac_control->fifos[i]. | 618 | mac_control->fifos[i]. |
@@ -2594,6 +2594,8 @@ static void tx_intr_handler(fifo_info_t *fifo_data) | |||
2594 | for (j = 0; j < frg_cnt; j++, txdlp++) { | 2594 | for (j = 0; j < frg_cnt; j++, txdlp++) { |
2595 | skb_frag_t *frag = | 2595 | skb_frag_t *frag = |
2596 | &skb_shinfo(skb)->frags[j]; | 2596 | &skb_shinfo(skb)->frags[j]; |
2597 | if (!txdlp->Buffer_Pointer) | ||
2598 | break; | ||
2597 | pci_unmap_page(nic->pdev, | 2599 | pci_unmap_page(nic->pdev, |
2598 | (dma_addr_t) | 2600 | (dma_addr_t) |
2599 | txdlp-> | 2601 | txdlp-> |
@@ -2744,6 +2746,10 @@ void s2io_reset(nic_t * sp) | |||
2744 | u64 val64; | 2746 | u64 val64; |
2745 | u16 subid, pci_cmd; | 2747 | u16 subid, pci_cmd; |
2746 | 2748 | ||
2749 | /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */ | ||
2750 | if (sp->device_type == XFRAME_I_DEVICE) | ||
2751 | pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd)); | ||
2752 | |||
2747 | val64 = SW_RESET_ALL; | 2753 | val64 = SW_RESET_ALL; |
2748 | writeq(val64, &bar0->sw_reset); | 2754 | writeq(val64, &bar0->sw_reset); |
2749 | 2755 | ||
@@ -2762,8 +2768,10 @@ void s2io_reset(nic_t * sp) | |||
2762 | msleep(250); | 2768 | msleep(250); |
2763 | 2769 | ||
2764 | if (!(sp->device_type & XFRAME_II_DEVICE)) { | 2770 | if (!(sp->device_type & XFRAME_II_DEVICE)) { |
2765 | /* Restore the PCI state saved during initializarion. */ | 2771 | /* Restore the PCI state saved during initializarion. */ |
2766 | pci_restore_state(sp->pdev); | 2772 | pci_restore_state(sp->pdev); |
2773 | pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, | ||
2774 | pci_cmd); | ||
2767 | } else { | 2775 | } else { |
2768 | pci_set_master(sp->pdev); | 2776 | pci_set_master(sp->pdev); |
2769 | } | 2777 | } |
@@ -2974,7 +2982,7 @@ int s2io_open(struct net_device *dev) | |||
2974 | * Nic is initialized | 2982 | * Nic is initialized |
2975 | */ | 2983 | */ |
2976 | netif_carrier_off(dev); | 2984 | netif_carrier_off(dev); |
2977 | sp->last_link_state = LINK_DOWN; | 2985 | sp->last_link_state = 0; |
2978 | 2986 | ||
2979 | /* Initialize H/W and enable interrupts */ | 2987 | /* Initialize H/W and enable interrupts */ |
2980 | if (s2io_card_up(sp)) { | 2988 | if (s2io_card_up(sp)) { |
@@ -3102,6 +3110,15 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3102 | spin_unlock_irqrestore(&sp->tx_lock, flags); | 3110 | spin_unlock_irqrestore(&sp->tx_lock, flags); |
3103 | return 0; | 3111 | return 0; |
3104 | } | 3112 | } |
3113 | |||
3114 | /* A buffer with no data will be dropped */ | ||
3115 | if (!skb->len) { | ||
3116 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | ||
3117 | dev_kfree_skb(skb); | ||
3118 | spin_unlock_irqrestore(&sp->tx_lock, flags); | ||
3119 | return 0; | ||
3120 | } | ||
3121 | |||
3105 | #ifdef NETIF_F_TSO | 3122 | #ifdef NETIF_F_TSO |
3106 | mss = skb_shinfo(skb)->tso_size; | 3123 | mss = skb_shinfo(skb)->tso_size; |
3107 | if (mss) { | 3124 | if (mss) { |
@@ -3136,6 +3153,9 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3136 | /* For fragmented SKB. */ | 3153 | /* For fragmented SKB. */ |
3137 | for (i = 0; i < frg_cnt; i++) { | 3154 | for (i = 0; i < frg_cnt; i++) { |
3138 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 3155 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
3156 | /* A '0' length fragment will be ignored */ | ||
3157 | if (!frag->size) | ||
3158 | continue; | ||
3139 | txdp++; | 3159 | txdp++; |
3140 | txdp->Buffer_Pointer = (u64) pci_map_page | 3160 | txdp->Buffer_Pointer = (u64) pci_map_page |
3141 | (sp->pdev, frag->page, frag->page_offset, | 3161 | (sp->pdev, frag->page, frag->page_offset, |
@@ -5257,7 +5277,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
5257 | config = &sp->config; | 5277 | config = &sp->config; |
5258 | 5278 | ||
5259 | /* Tx side parameters. */ | 5279 | /* Tx side parameters. */ |
5260 | tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */ | 5280 | if (tx_fifo_len[0] == 0) |
5281 | tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */ | ||
5261 | config->tx_fifo_num = tx_fifo_num; | 5282 | config->tx_fifo_num = tx_fifo_num; |
5262 | for (i = 0; i < MAX_TX_FIFOS; i++) { | 5283 | for (i = 0; i < MAX_TX_FIFOS; i++) { |
5263 | config->tx_cfg[i].fifo_len = tx_fifo_len[i]; | 5284 | config->tx_cfg[i].fifo_len = tx_fifo_len[i]; |
@@ -5280,7 +5301,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
5280 | config->max_txds = MAX_SKB_FRAGS; | 5301 | config->max_txds = MAX_SKB_FRAGS; |
5281 | 5302 | ||
5282 | /* Rx side parameters. */ | 5303 | /* Rx side parameters. */ |
5283 | rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */ | 5304 | if (rx_ring_sz[0] == 0) |
5305 | rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */ | ||
5284 | config->rx_ring_num = rx_ring_num; | 5306 | config->rx_ring_num = rx_ring_num; |
5285 | for (i = 0; i < MAX_RX_RINGS; i++) { | 5307 | for (i = 0; i < MAX_RX_RINGS; i++) { |
5286 | config->rx_cfg[i].num_rxd = rx_ring_sz[i] * | 5308 | config->rx_cfg[i].num_rxd = rx_ring_sz[i] * |
@@ -5310,7 +5332,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
5310 | /* initialize the shared memory used by the NIC and the host */ | 5332 | /* initialize the shared memory used by the NIC and the host */ |
5311 | if (init_shared_mem(sp)) { | 5333 | if (init_shared_mem(sp)) { |
5312 | DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", | 5334 | DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", |
5313 | dev->name); | 5335 | __FUNCTION__); |
5314 | ret = -ENOMEM; | 5336 | ret = -ENOMEM; |
5315 | goto mem_alloc_failed; | 5337 | goto mem_alloc_failed; |
5316 | } | 5338 | } |
@@ -5488,7 +5510,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
5488 | sp->def_mac_addr[0].mac_addr[3], | 5510 | sp->def_mac_addr[0].mac_addr[3], |
5489 | sp->def_mac_addr[0].mac_addr[4], | 5511 | sp->def_mac_addr[0].mac_addr[4], |
5490 | sp->def_mac_addr[0].mac_addr[5]); | 5512 | sp->def_mac_addr[0].mac_addr[5]); |
5491 | int mode = s2io_print_pci_mode(sp); | 5513 | mode = s2io_print_pci_mode(sp); |
5492 | if (mode < 0) { | 5514 | if (mode < 0) { |
5493 | DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode "); | 5515 | DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode "); |
5494 | ret = -EBADSLT; | 5516 | ret = -EBADSLT; |