Commit 0b1f7ebe authored by raghavendra.koushik@neterion.com's avatar raghavendra.koushik@neterion.com Committed by Jeff Garzik

[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: default avatarRavinandan Arakali <ravinandan.arakali@neterion.com>
Signed-off-by: default avatarRaghavendra Koushik <raghavendra.koushik@neterion.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent a371a07d
...@@ -365,10 +365,9 @@ static int init_shared_mem(struct s2io_nic *nic) ...@@ -365,10 +365,9 @@ static int init_shared_mem(struct s2io_nic *nic)
size += config->tx_cfg[i].fifo_len; size += config->tx_cfg[i].fifo_len;
} }
if (size > MAX_AVAILABLE_TXDS) { if (size > MAX_AVAILABLE_TXDS) {
DBG_PRINT(ERR_DBG, "%s: Total number of Tx FIFOs ", DBG_PRINT(ERR_DBG, "%s: Requested TxDs too high, ",
dev->name); __FUNCTION__);
DBG_PRINT(ERR_DBG, "exceeds the maximum value "); DBG_PRINT(ERR_DBG, "Requested: %d, max supported: 8192\n", size);
DBG_PRINT(ERR_DBG, "that can be used\n");
return FAILURE; return FAILURE;
} }
...@@ -611,8 +610,9 @@ static void free_shared_mem(struct s2io_nic *nic) ...@@ -611,8 +610,9 @@ static void free_shared_mem(struct s2io_nic *nic)
lst_per_page); lst_per_page);
for (j = 0; j < page_num; j++) { for (j = 0; j < page_num; j++) {
int mem_blks = (j * lst_per_page); int mem_blks = (j * lst_per_page);
if (!mac_control->fifos[i].list_info[mem_blks]. if ((!mac_control->fifos[i].list_info) ||
list_virt_addr) (!mac_control->fifos[i].list_info[mem_blks].
list_virt_addr))
break; break;
pci_free_consistent(nic->pdev, PAGE_SIZE, pci_free_consistent(nic->pdev, PAGE_SIZE,
mac_control->fifos[i]. mac_control->fifos[i].
...@@ -2594,6 +2594,8 @@ static void tx_intr_handler(fifo_info_t *fifo_data) ...@@ -2594,6 +2594,8 @@ static void tx_intr_handler(fifo_info_t *fifo_data)
for (j = 0; j < frg_cnt; j++, txdlp++) { for (j = 0; j < frg_cnt; j++, txdlp++) {
skb_frag_t *frag = skb_frag_t *frag =
&skb_shinfo(skb)->frags[j]; &skb_shinfo(skb)->frags[j];
if (!txdlp->Buffer_Pointer)
break;
pci_unmap_page(nic->pdev, pci_unmap_page(nic->pdev,
(dma_addr_t) (dma_addr_t)
txdlp-> txdlp->
...@@ -2744,6 +2746,10 @@ void s2io_reset(nic_t * sp) ...@@ -2744,6 +2746,10 @@ void s2io_reset(nic_t * sp)
u64 val64; u64 val64;
u16 subid, pci_cmd; u16 subid, pci_cmd;
/* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
if (sp->device_type == XFRAME_I_DEVICE)
pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
val64 = SW_RESET_ALL; val64 = SW_RESET_ALL;
writeq(val64, &bar0->sw_reset); writeq(val64, &bar0->sw_reset);
...@@ -2764,6 +2770,8 @@ void s2io_reset(nic_t * sp) ...@@ -2764,6 +2770,8 @@ void s2io_reset(nic_t * sp)
if (!(sp->device_type & XFRAME_II_DEVICE)) { if (!(sp->device_type & XFRAME_II_DEVICE)) {
/* Restore the PCI state saved during initializarion. */ /* Restore the PCI state saved during initializarion. */
pci_restore_state(sp->pdev); pci_restore_state(sp->pdev);
pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
pci_cmd);
} else { } else {
pci_set_master(sp->pdev); pci_set_master(sp->pdev);
} }
...@@ -2974,7 +2982,7 @@ int s2io_open(struct net_device *dev) ...@@ -2974,7 +2982,7 @@ int s2io_open(struct net_device *dev)
* Nic is initialized * Nic is initialized
*/ */
netif_carrier_off(dev); netif_carrier_off(dev);
sp->last_link_state = LINK_DOWN; sp->last_link_state = 0;
/* Initialize H/W and enable interrupts */ /* Initialize H/W and enable interrupts */
if (s2io_card_up(sp)) { if (s2io_card_up(sp)) {
...@@ -3102,6 +3110,15 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -3102,6 +3110,15 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
spin_unlock_irqrestore(&sp->tx_lock, flags); spin_unlock_irqrestore(&sp->tx_lock, flags);
return 0; return 0;
} }
/* A buffer with no data will be dropped */
if (!skb->len) {
DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
dev_kfree_skb(skb);
spin_unlock_irqrestore(&sp->tx_lock, flags);
return 0;
}
#ifdef NETIF_F_TSO #ifdef NETIF_F_TSO
mss = skb_shinfo(skb)->tso_size; mss = skb_shinfo(skb)->tso_size;
if (mss) { if (mss) {
...@@ -3136,6 +3153,9 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -3136,6 +3153,9 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
/* For fragmented SKB. */ /* For fragmented SKB. */
for (i = 0; i < frg_cnt; i++) { for (i = 0; i < frg_cnt; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
/* A '0' length fragment will be ignored */
if (!frag->size)
continue;
txdp++; txdp++;
txdp->Buffer_Pointer = (u64) pci_map_page txdp->Buffer_Pointer = (u64) pci_map_page
(sp->pdev, frag->page, frag->page_offset, (sp->pdev, frag->page, frag->page_offset,
...@@ -5257,6 +5277,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -5257,6 +5277,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
config = &sp->config; config = &sp->config;
/* Tx side parameters. */ /* Tx side parameters. */
if (tx_fifo_len[0] == 0)
tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */ tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */
config->tx_fifo_num = tx_fifo_num; config->tx_fifo_num = tx_fifo_num;
for (i = 0; i < MAX_TX_FIFOS; i++) { for (i = 0; i < MAX_TX_FIFOS; i++) {
...@@ -5280,6 +5301,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -5280,6 +5301,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
config->max_txds = MAX_SKB_FRAGS; config->max_txds = MAX_SKB_FRAGS;
/* Rx side parameters. */ /* Rx side parameters. */
if (rx_ring_sz[0] == 0)
rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */ rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */
config->rx_ring_num = rx_ring_num; config->rx_ring_num = rx_ring_num;
for (i = 0; i < MAX_RX_RINGS; i++) { for (i = 0; i < MAX_RX_RINGS; i++) {
...@@ -5310,7 +5332,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -5310,7 +5332,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
/* initialize the shared memory used by the NIC and the host */ /* initialize the shared memory used by the NIC and the host */
if (init_shared_mem(sp)) { if (init_shared_mem(sp)) {
DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n",
dev->name); __FUNCTION__);
ret = -ENOMEM; ret = -ENOMEM;
goto mem_alloc_failed; goto mem_alloc_failed;
} }
...@@ -5488,7 +5510,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -5488,7 +5510,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
sp->def_mac_addr[0].mac_addr[3], sp->def_mac_addr[0].mac_addr[3],
sp->def_mac_addr[0].mac_addr[4], sp->def_mac_addr[0].mac_addr[4],
sp->def_mac_addr[0].mac_addr[5]); sp->def_mac_addr[0].mac_addr[5]);
int mode = s2io_print_pci_mode(sp); mode = s2io_print_pci_mode(sp);
if (mode < 0) { if (mode < 0) {
DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode "); DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode ");
ret = -EBADSLT; ret = -EBADSLT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment