diff options
Diffstat (limited to 'drivers/net/s2io.c')
-rw-r--r-- | drivers/net/s2io.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 51a91154125d..685030bb1d5e 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -2501,6 +2501,9 @@ static void stop_nic(struct s2io_nic *nic) | |||
2501 | /** | 2501 | /** |
2502 | * fill_rx_buffers - Allocates the Rx side skbs | 2502 | * fill_rx_buffers - Allocates the Rx side skbs |
2503 | * @ring_info: per ring structure | 2503 | * @ring_info: per ring structure |
2504 | * @from_card_up: If this is true, we will map the buffer to get | ||
2505 | * the dma address for buf0 and buf1 to give it to the card. | ||
2506 | * Else we will sync the already mapped buffer to give it to the card. | ||
2504 | * Description: | 2507 | * Description: |
2505 | * The function allocates Rx side skbs and puts the physical | 2508 | * The function allocates Rx side skbs and puts the physical |
2506 | * address of these buffers into the RxD buffer pointers, so that the NIC | 2509 | * address of these buffers into the RxD buffer pointers, so that the NIC |
@@ -2518,7 +2521,7 @@ static void stop_nic(struct s2io_nic *nic) | |||
2518 | * SUCCESS on success or an appropriate -ve value on failure. | 2521 | * SUCCESS on success or an appropriate -ve value on failure. |
2519 | */ | 2522 | */ |
2520 | 2523 | ||
2521 | static int fill_rx_buffers(struct ring_info *ring) | 2524 | static int fill_rx_buffers(struct ring_info *ring, int from_card_up) |
2522 | { | 2525 | { |
2523 | struct sk_buff *skb; | 2526 | struct sk_buff *skb; |
2524 | struct RxD_t *rxdp; | 2527 | struct RxD_t *rxdp; |
@@ -2637,17 +2640,16 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2637 | skb->data = (void *) (unsigned long)tmp; | 2640 | skb->data = (void *) (unsigned long)tmp; |
2638 | skb_reset_tail_pointer(skb); | 2641 | skb_reset_tail_pointer(skb); |
2639 | 2642 | ||
2640 | /* AK: check is wrong. 0 can be valid dma address */ | 2643 | if (from_card_up) { |
2641 | if (!(rxdp3->Buffer0_ptr)) | ||
2642 | rxdp3->Buffer0_ptr = | 2644 | rxdp3->Buffer0_ptr = |
2643 | pci_map_single(ring->pdev, ba->ba_0, | 2645 | pci_map_single(ring->pdev, ba->ba_0, |
2644 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 2646 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
2645 | else | 2647 | if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) |
2648 | goto pci_map_failed; | ||
2649 | } else | ||
2646 | pci_dma_sync_single_for_device(ring->pdev, | 2650 | pci_dma_sync_single_for_device(ring->pdev, |
2647 | (dma_addr_t) rxdp3->Buffer0_ptr, | 2651 | (dma_addr_t) rxdp3->Buffer0_ptr, |
2648 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 2652 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
2649 | if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) | ||
2650 | goto pci_map_failed; | ||
2651 | 2653 | ||
2652 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); | 2654 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); |
2653 | if (ring->rxd_mode == RXD_MODE_3B) { | 2655 | if (ring->rxd_mode == RXD_MODE_3B) { |
@@ -2664,21 +2666,22 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2664 | if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) | 2666 | if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) |
2665 | goto pci_map_failed; | 2667 | goto pci_map_failed; |
2666 | 2668 | ||
2667 | /* AK: check is wrong */ | 2669 | if (from_card_up) { |
2668 | if (!rxdp3->Buffer1_ptr) | ||
2669 | rxdp3->Buffer1_ptr = | 2670 | rxdp3->Buffer1_ptr = |
2670 | pci_map_single(ring->pdev, | 2671 | pci_map_single(ring->pdev, |
2671 | ba->ba_1, BUF1_LEN, | 2672 | ba->ba_1, BUF1_LEN, |
2672 | PCI_DMA_FROMDEVICE); | 2673 | PCI_DMA_FROMDEVICE); |
2673 | 2674 | ||
2674 | if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) { | 2675 | if (pci_dma_mapping_error |
2675 | pci_unmap_single | 2676 | (rxdp3->Buffer1_ptr)) { |
2676 | (ring->pdev, | 2677 | pci_unmap_single |
2677 | (dma_addr_t)(unsigned long) | 2678 | (ring->pdev, |
2678 | skb->data, | 2679 | (dma_addr_t)(unsigned long) |
2679 | ring->mtu + 4, | 2680 | skb->data, |
2680 | PCI_DMA_FROMDEVICE); | 2681 | ring->mtu + 4, |
2681 | goto pci_map_failed; | 2682 | PCI_DMA_FROMDEVICE); |
2683 | goto pci_map_failed; | ||
2684 | } | ||
2682 | } | 2685 | } |
2683 | rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); | 2686 | rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); |
2684 | rxdp->Control_2 |= SET_BUFFER2_SIZE_3 | 2687 | rxdp->Control_2 |= SET_BUFFER2_SIZE_3 |
@@ -2813,7 +2816,7 @@ static void free_rx_buffers(struct s2io_nic *sp) | |||
2813 | 2816 | ||
2814 | static int s2io_chk_rx_buffers(struct ring_info *ring) | 2817 | static int s2io_chk_rx_buffers(struct ring_info *ring) |
2815 | { | 2818 | { |
2816 | if (fill_rx_buffers(ring) == -ENOMEM) { | 2819 | if (fill_rx_buffers(ring, 0) == -ENOMEM) { |
2817 | DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name); | 2820 | DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name); |
2818 | DBG_PRINT(INFO_DBG, " in Rx Intr!!\n"); | 2821 | DBG_PRINT(INFO_DBG, " in Rx Intr!!\n"); |
2819 | } | 2822 | } |
@@ -2944,7 +2947,7 @@ static void s2io_netpoll(struct net_device *dev) | |||
2944 | rx_intr_handler(&mac_control->rings[i], 0); | 2947 | rx_intr_handler(&mac_control->rings[i], 0); |
2945 | 2948 | ||
2946 | for (i = 0; i < config->rx_ring_num; i++) { | 2949 | for (i = 0; i < config->rx_ring_num; i++) { |
2947 | if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { | 2950 | if (fill_rx_buffers(&mac_control->rings[i], 0) == -ENOMEM) { |
2948 | DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); | 2951 | DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); |
2949 | DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n"); | 2952 | DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n"); |
2950 | break; | 2953 | break; |
@@ -7183,7 +7186,7 @@ static int s2io_card_up(struct s2io_nic * sp) | |||
7183 | 7186 | ||
7184 | for (i = 0; i < config->rx_ring_num; i++) { | 7187 | for (i = 0; i < config->rx_ring_num; i++) { |
7185 | mac_control->rings[i].mtu = dev->mtu; | 7188 | mac_control->rings[i].mtu = dev->mtu; |
7186 | ret = fill_rx_buffers(&mac_control->rings[i]); | 7189 | ret = fill_rx_buffers(&mac_control->rings[i], 1); |
7187 | if (ret) { | 7190 | if (ret) { |
7188 | DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n", | 7191 | DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n", |
7189 | dev->name); | 7192 | dev->name); |