hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/neterion/s2io.c
....@@ -75,6 +75,7 @@
7575 #include <linux/tcp.h>
7676 #include <linux/uaccess.h>
7777 #include <linux/io.h>
78
+#include <linux/io-64-nonatomic-lo-hi.h>
7879 #include <linux/slab.h>
7980 #include <linux/prefetch.h>
8081 #include <net/tcp.h>
....@@ -491,7 +492,7 @@
491492 };
492493
493494 /* A simplifier macro used both by init and free shared_mem Fns(). */
494
-#define TXD_MEM_PAGE_CNT(len, per_each) ((len+per_each - 1) / per_each)
495
+#define TXD_MEM_PAGE_CNT(len, per_each) DIV_ROUND_UP(len, per_each)
495496
496497 /* netqueue manipulation helper functions */
497498 static inline void s2io_stop_all_tx_queue(struct s2io_nic *sp)
....@@ -639,11 +640,11 @@
639640 int k = 0;
640641 dma_addr_t tmp_p;
641642 void *tmp_v;
642
- tmp_v = pci_alloc_consistent(nic->pdev,
643
- PAGE_SIZE, &tmp_p);
643
+ tmp_v = dma_alloc_coherent(&nic->pdev->dev, PAGE_SIZE,
644
+ &tmp_p, GFP_KERNEL);
644645 if (!tmp_v) {
645646 DBG_PRINT(INFO_DBG,
646
- "pci_alloc_consistent failed for TxDL\n");
647
+ "dma_alloc_coherent failed for TxDL\n");
647648 return -ENOMEM;
648649 }
649650 /* If we got a zero DMA address(can happen on
....@@ -657,11 +658,12 @@
657658 "%s: Zero DMA address for TxDL. "
658659 "Virtual address %p\n",
659660 dev->name, tmp_v);
660
- tmp_v = pci_alloc_consistent(nic->pdev,
661
- PAGE_SIZE, &tmp_p);
661
+ tmp_v = dma_alloc_coherent(&nic->pdev->dev,
662
+ PAGE_SIZE, &tmp_p,
663
+ GFP_KERNEL);
662664 if (!tmp_v) {
663665 DBG_PRINT(INFO_DBG,
664
- "pci_alloc_consistent failed for TxDL\n");
666
+ "dma_alloc_coherent failed for TxDL\n");
665667 return -ENOMEM;
666668 }
667669 mem_allocated += PAGE_SIZE;
....@@ -733,8 +735,8 @@
733735
734736 rx_blocks = &ring->rx_blocks[j];
735737 size = SIZE_OF_BLOCK; /* size is always page size */
736
- tmp_v_addr = pci_alloc_consistent(nic->pdev, size,
737
- &tmp_p_addr);
738
+ tmp_v_addr = dma_alloc_coherent(&nic->pdev->dev, size,
739
+ &tmp_p_addr, GFP_KERNEL);
738740 if (tmp_v_addr == NULL) {
739741 /*
740742 * In case of failure, free_shared_mem()
....@@ -746,7 +748,6 @@
746748 return -ENOMEM;
747749 }
748750 mem_allocated += size;
749
- memset(tmp_v_addr, 0, size);
750751
751752 size = sizeof(struct rxd_info) *
752753 rxd_count[nic->rxd_mode];
....@@ -835,8 +836,8 @@
835836 /* Allocation and initialization of Statistics block */
836837 size = sizeof(struct stat_block);
837838 mac_control->stats_mem =
838
- pci_alloc_consistent(nic->pdev, size,
839
- &mac_control->stats_mem_phy);
839
+ dma_alloc_coherent(&nic->pdev->dev, size,
840
+ &mac_control->stats_mem_phy, GFP_KERNEL);
840841
841842 if (!mac_control->stats_mem) {
842843 /*
....@@ -906,18 +907,18 @@
906907 fli = &fifo->list_info[mem_blks];
907908 if (!fli->list_virt_addr)
908909 break;
909
- pci_free_consistent(nic->pdev, PAGE_SIZE,
910
- fli->list_virt_addr,
911
- fli->list_phy_addr);
910
+ dma_free_coherent(&nic->pdev->dev, PAGE_SIZE,
911
+ fli->list_virt_addr,
912
+ fli->list_phy_addr);
912913 swstats->mem_freed += PAGE_SIZE;
913914 }
914915 /* If we got a zero DMA address during allocation,
915916 * free the page now
916917 */
917918 if (mac_control->zerodma_virt_addr) {
918
- pci_free_consistent(nic->pdev, PAGE_SIZE,
919
- mac_control->zerodma_virt_addr,
920
- (dma_addr_t)0);
919
+ dma_free_coherent(&nic->pdev->dev, PAGE_SIZE,
920
+ mac_control->zerodma_virt_addr,
921
+ (dma_addr_t)0);
921922 DBG_PRINT(INIT_DBG,
922923 "%s: Freeing TxDL with zero DMA address. "
923924 "Virtual address %p\n",
....@@ -939,8 +940,8 @@
939940 tmp_p_addr = ring->rx_blocks[j].block_dma_addr;
940941 if (tmp_v_addr == NULL)
941942 break;
942
- pci_free_consistent(nic->pdev, size,
943
- tmp_v_addr, tmp_p_addr);
943
+ dma_free_coherent(&nic->pdev->dev, size, tmp_v_addr,
944
+ tmp_p_addr);
944945 swstats->mem_freed += size;
945946 kfree(ring->rx_blocks[j].rxds);
946947 swstats->mem_freed += sizeof(struct rxd_info) *
....@@ -993,14 +994,13 @@
993994
994995 if (mac_control->stats_mem) {
995996 swstats->mem_freed += mac_control->stats_mem_sz;
996
- pci_free_consistent(nic->pdev,
997
- mac_control->stats_mem_sz,
998
- mac_control->stats_mem,
999
- mac_control->stats_mem_phy);
997
+ dma_free_coherent(&nic->pdev->dev, mac_control->stats_mem_sz,
998
+ mac_control->stats_mem,
999
+ mac_control->stats_mem_phy);
10001000 }
10011001 }
10021002
1003
-/**
1003
+/*
10041004 * s2io_verify_pci_mode -
10051005 */
10061006
....@@ -1035,7 +1035,7 @@
10351035 }
10361036
10371037 static int bus_speed[8] = {33, 133, 133, 200, 266, 133, 200, 266};
1038
-/**
1038
+/*
10391039 * s2io_print_pci_mode -
10401040 */
10411041 static int s2io_print_pci_mode(struct s2io_nic *nic)
....@@ -2064,6 +2064,9 @@
20642064
20652065 /**
20662066 * verify_pcc_quiescent- Checks for PCC quiescent state
2067
+ * @sp : private member of the device structure, which is a pointer to the
2068
+ * s2io_nic structure.
2069
+ * @flag: boolean controlling function path
20672070 * Return: 1 If PCC is quiescence
20682071 * 0 If PCC is not quiescence
20692072 */
....@@ -2099,6 +2102,8 @@
20992102 }
21002103 /**
21012104 * verify_xena_quiescence - Checks whether the H/W is ready
2105
+ * @sp : private member of the device structure, which is a pointer to the
2106
+ * s2io_nic structure.
21022107 * Description: Returns whether the H/W is ready to go or not. Depending
21032108 * on whether adapter enable bit was written or not the comparison
21042109 * differs and the calling function passes the input argument flag to
....@@ -2305,6 +2310,9 @@
23052310 }
23062311 /**
23072312 * s2io_txdl_getskb - Get the skb from txdl, unmap and return skb
2313
+ * @fifo_data: fifo data pointer
2314
+ * @txdlp: descriptor
2315
+ * @get_off: unused
23082316 */
23092317 static struct sk_buff *s2io_txdl_getskb(struct fifo_info *fifo_data,
23102318 struct TxD *txdlp, int get_off)
....@@ -2316,8 +2324,9 @@
23162324
23172325 txds = txdlp;
23182326 if (txds->Host_Control == (u64)(long)fifo_data->ufo_in_band_v) {
2319
- pci_unmap_single(nic->pdev, (dma_addr_t)txds->Buffer_Pointer,
2320
- sizeof(u64), PCI_DMA_TODEVICE);
2327
+ dma_unmap_single(&nic->pdev->dev,
2328
+ (dma_addr_t)txds->Buffer_Pointer,
2329
+ sizeof(u64), DMA_TO_DEVICE);
23212330 txds++;
23222331 }
23232332
....@@ -2326,8 +2335,8 @@
23262335 memset(txdlp, 0, (sizeof(struct TxD) * fifo_data->max_txds));
23272336 return NULL;
23282337 }
2329
- pci_unmap_single(nic->pdev, (dma_addr_t)txds->Buffer_Pointer,
2330
- skb_headlen(skb), PCI_DMA_TODEVICE);
2338
+ dma_unmap_single(&nic->pdev->dev, (dma_addr_t)txds->Buffer_Pointer,
2339
+ skb_headlen(skb), DMA_TO_DEVICE);
23312340 frg_cnt = skb_shinfo(skb)->nr_frags;
23322341 if (frg_cnt) {
23332342 txds++;
....@@ -2335,9 +2344,9 @@
23352344 const skb_frag_t *frag = &skb_shinfo(skb)->frags[j];
23362345 if (!txds->Buffer_Pointer)
23372346 break;
2338
- pci_unmap_page(nic->pdev,
2347
+ dma_unmap_page(&nic->pdev->dev,
23392348 (dma_addr_t)txds->Buffer_Pointer,
2340
- skb_frag_size(frag), PCI_DMA_TODEVICE);
2349
+ skb_frag_size(frag), DMA_TO_DEVICE);
23412350 }
23422351 }
23432352 memset(txdlp, 0, (sizeof(struct TxD) * fifo_data->max_txds));
....@@ -2375,7 +2384,7 @@
23752384 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
23762385 if (skb) {
23772386 swstats->mem_freed += skb->truesize;
2378
- dev_kfree_skb(skb);
2387
+ dev_kfree_skb_irq(skb);
23792388 cnt++;
23802389 }
23812390 }
....@@ -2390,7 +2399,7 @@
23902399
23912400 /**
23922401 * stop_nic - To stop the nic
2393
- * @nic ; device private variable.
2402
+ * @nic : device private variable.
23942403 * Description:
23952404 * This function does exactly the opposite of what the start_nic()
23962405 * function does. This function is called to stop the device.
....@@ -2418,7 +2427,8 @@
24182427
24192428 /**
24202429 * fill_rx_buffers - Allocates the Rx side skbs
2421
- * @ring_info: per ring structure
2430
+ * @nic : device private variable.
2431
+ * @ring: per ring structure
24222432 * @from_card_up: If this is true, we will map the buffer to get
24232433 * the dma address for buf0 and buf1 to give it to the card.
24242434 * Else we will sync the already mapped buffer to give it to the card.
....@@ -2521,11 +2531,10 @@
25212531 memset(rxdp, 0, sizeof(struct RxD1));
25222532 skb_reserve(skb, NET_IP_ALIGN);
25232533 rxdp1->Buffer0_ptr =
2524
- pci_map_single(ring->pdev, skb->data,
2534
+ dma_map_single(&ring->pdev->dev, skb->data,
25252535 size - NET_IP_ALIGN,
2526
- PCI_DMA_FROMDEVICE);
2527
- if (pci_dma_mapping_error(nic->pdev,
2528
- rxdp1->Buffer0_ptr))
2536
+ DMA_FROM_DEVICE);
2537
+ if (dma_mapping_error(&nic->pdev->dev, rxdp1->Buffer0_ptr))
25292538 goto pci_map_failed;
25302539
25312540 rxdp->Control_2 =
....@@ -2557,17 +2566,16 @@
25572566
25582567 if (from_card_up) {
25592568 rxdp3->Buffer0_ptr =
2560
- pci_map_single(ring->pdev, ba->ba_0,
2561
- BUF0_LEN,
2562
- PCI_DMA_FROMDEVICE);
2563
- if (pci_dma_mapping_error(nic->pdev,
2564
- rxdp3->Buffer0_ptr))
2569
+ dma_map_single(&ring->pdev->dev,
2570
+ ba->ba_0, BUF0_LEN,
2571
+ DMA_FROM_DEVICE);
2572
+ if (dma_mapping_error(&nic->pdev->dev, rxdp3->Buffer0_ptr))
25652573 goto pci_map_failed;
25662574 } else
2567
- pci_dma_sync_single_for_device(ring->pdev,
2568
- (dma_addr_t)rxdp3->Buffer0_ptr,
2569
- BUF0_LEN,
2570
- PCI_DMA_FROMDEVICE);
2575
+ dma_sync_single_for_device(&ring->pdev->dev,
2576
+ (dma_addr_t)rxdp3->Buffer0_ptr,
2577
+ BUF0_LEN,
2578
+ DMA_FROM_DEVICE);
25712579
25722580 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
25732581 if (ring->rxd_mode == RXD_MODE_3B) {
....@@ -2577,29 +2585,28 @@
25772585 * Buffer2 will have L3/L4 header plus
25782586 * L4 payload
25792587 */
2580
- rxdp3->Buffer2_ptr = pci_map_single(ring->pdev,
2588
+ rxdp3->Buffer2_ptr = dma_map_single(&ring->pdev->dev,
25812589 skb->data,
25822590 ring->mtu + 4,
2583
- PCI_DMA_FROMDEVICE);
2591
+ DMA_FROM_DEVICE);
25842592
2585
- if (pci_dma_mapping_error(nic->pdev,
2586
- rxdp3->Buffer2_ptr))
2593
+ if (dma_mapping_error(&nic->pdev->dev, rxdp3->Buffer2_ptr))
25872594 goto pci_map_failed;
25882595
25892596 if (from_card_up) {
25902597 rxdp3->Buffer1_ptr =
2591
- pci_map_single(ring->pdev,
2598
+ dma_map_single(&ring->pdev->dev,
25922599 ba->ba_1,
25932600 BUF1_LEN,
2594
- PCI_DMA_FROMDEVICE);
2601
+ DMA_FROM_DEVICE);
25952602
2596
- if (pci_dma_mapping_error(nic->pdev,
2597
- rxdp3->Buffer1_ptr)) {
2598
- pci_unmap_single(ring->pdev,
2603
+ if (dma_mapping_error(&nic->pdev->dev,
2604
+ rxdp3->Buffer1_ptr)) {
2605
+ dma_unmap_single(&ring->pdev->dev,
25992606 (dma_addr_t)(unsigned long)
26002607 skb->data,
26012608 ring->mtu + 4,
2602
- PCI_DMA_FROMDEVICE);
2609
+ DMA_FROM_DEVICE);
26032610 goto pci_map_failed;
26042611 }
26052612 }
....@@ -2668,27 +2675,24 @@
26682675 continue;
26692676 if (sp->rxd_mode == RXD_MODE_1) {
26702677 rxdp1 = (struct RxD1 *)rxdp;
2671
- pci_unmap_single(sp->pdev,
2678
+ dma_unmap_single(&sp->pdev->dev,
26722679 (dma_addr_t)rxdp1->Buffer0_ptr,
26732680 dev->mtu +
26742681 HEADER_ETHERNET_II_802_3_SIZE +
26752682 HEADER_802_2_SIZE + HEADER_SNAP_SIZE,
2676
- PCI_DMA_FROMDEVICE);
2683
+ DMA_FROM_DEVICE);
26772684 memset(rxdp, 0, sizeof(struct RxD1));
26782685 } else if (sp->rxd_mode == RXD_MODE_3B) {
26792686 rxdp3 = (struct RxD3 *)rxdp;
2680
- pci_unmap_single(sp->pdev,
2687
+ dma_unmap_single(&sp->pdev->dev,
26812688 (dma_addr_t)rxdp3->Buffer0_ptr,
2682
- BUF0_LEN,
2683
- PCI_DMA_FROMDEVICE);
2684
- pci_unmap_single(sp->pdev,
2689
+ BUF0_LEN, DMA_FROM_DEVICE);
2690
+ dma_unmap_single(&sp->pdev->dev,
26852691 (dma_addr_t)rxdp3->Buffer1_ptr,
2686
- BUF1_LEN,
2687
- PCI_DMA_FROMDEVICE);
2688
- pci_unmap_single(sp->pdev,
2692
+ BUF1_LEN, DMA_FROM_DEVICE);
2693
+ dma_unmap_single(&sp->pdev->dev,
26892694 (dma_addr_t)rxdp3->Buffer2_ptr,
2690
- dev->mtu + 4,
2691
- PCI_DMA_FROMDEVICE);
2695
+ dev->mtu + 4, DMA_FROM_DEVICE);
26922696 memset(rxdp, 0, sizeof(struct RxD3));
26932697 }
26942698 swstats->mem_freed += skb->truesize;
....@@ -2869,7 +2873,7 @@
28692873
28702874 /**
28712875 * rx_intr_handler - Rx interrupt handler
2872
- * @ring_info: per ring structure.
2876
+ * @ring_data: per ring structure.
28732877 * @budget: budget for napi processing.
28742878 * Description:
28752879 * If the interrupt is because of a received frame or if the
....@@ -2919,23 +2923,21 @@
29192923 }
29202924 if (ring_data->rxd_mode == RXD_MODE_1) {
29212925 rxdp1 = (struct RxD1 *)rxdp;
2922
- pci_unmap_single(ring_data->pdev, (dma_addr_t)
2923
- rxdp1->Buffer0_ptr,
2926
+ dma_unmap_single(&ring_data->pdev->dev,
2927
+ (dma_addr_t)rxdp1->Buffer0_ptr,
29242928 ring_data->mtu +
29252929 HEADER_ETHERNET_II_802_3_SIZE +
29262930 HEADER_802_2_SIZE +
29272931 HEADER_SNAP_SIZE,
2928
- PCI_DMA_FROMDEVICE);
2932
+ DMA_FROM_DEVICE);
29292933 } else if (ring_data->rxd_mode == RXD_MODE_3B) {
29302934 rxdp3 = (struct RxD3 *)rxdp;
2931
- pci_dma_sync_single_for_cpu(ring_data->pdev,
2932
- (dma_addr_t)rxdp3->Buffer0_ptr,
2933
- BUF0_LEN,
2934
- PCI_DMA_FROMDEVICE);
2935
- pci_unmap_single(ring_data->pdev,
2935
+ dma_sync_single_for_cpu(&ring_data->pdev->dev,
2936
+ (dma_addr_t)rxdp3->Buffer0_ptr,
2937
+ BUF0_LEN, DMA_FROM_DEVICE);
2938
+ dma_unmap_single(&ring_data->pdev->dev,
29362939 (dma_addr_t)rxdp3->Buffer2_ptr,
2937
- ring_data->mtu + 4,
2938
- PCI_DMA_FROMDEVICE);
2940
+ ring_data->mtu + 4, DMA_FROM_DEVICE);
29392941 }
29402942 prefetch(skb->data);
29412943 rx_osm_handler(ring_data, rxdp);
....@@ -2979,7 +2981,7 @@
29792981
29802982 /**
29812983 * tx_intr_handler - Transmit interrupt handler
2982
- * @nic : device private variable
2984
+ * @fifo_data : fifo data pointer
29832985 * Description:
29842986 * If an interrupt was raised to indicate DMA complete of the
29852987 * Tx packet, this function is called. It identifies the last TxD
....@@ -3054,7 +3056,7 @@
30543056
30553057 /* Updating the statistics block */
30563058 swstats->mem_freed += skb->truesize;
3057
- dev_kfree_skb_irq(skb);
3059
+ dev_consume_skb_irq(skb);
30583060
30593061 get_info.offset++;
30603062 if (get_info.offset == get_info.fifo_len + 1)
....@@ -3160,6 +3162,8 @@
31603162 /**
31613163 * s2io_chk_xpak_counter - Function to check the status of the xpak counters
31623164 * @counter : counter value to be updated
3165
+ * @regs_stat : registers status
3166
+ * @index : index
31633167 * @flag : flag to indicate the status
31643168 * @type : counter type
31653169 * Description:
....@@ -3316,8 +3320,9 @@
33163320
33173321 /**
33183322 * wait_for_cmd_complete - waits for a command to complete.
3319
- * @sp : private member of the device structure, which is a pointer to the
3320
- * s2io_nic structure.
3323
+ * @addr: address
3324
+ * @busy_bit: bit to check for busy
3325
+ * @bit_state: state to check
33213326 * Description: Function that waits for a command to Write into RMAC
33223327 * ADDR DATA registers to be completed and returns either success or
33233328 * error depending on whether the command was complete or not.
....@@ -3679,11 +3684,9 @@
36793684 writeq(nic->msix_info[i].data, &bar0->xmsi_data);
36803685 val64 = (s2BIT(7) | s2BIT(15) | vBIT(msix_index, 26, 6));
36813686 writeq(val64, &bar0->xmsi_access);
3682
- if (wait_for_msix_trans(nic, msix_index)) {
3687
+ if (wait_for_msix_trans(nic, msix_index))
36833688 DBG_PRINT(ERR_DBG, "%s: index: %d failed\n",
36843689 __func__, msix_index);
3685
- continue;
3686
- }
36873690 }
36883691 }
36893692
....@@ -4119,9 +4122,9 @@
41194122 }
41204123
41214124 frg_len = skb_headlen(skb);
4122
- txdp->Buffer_Pointer = pci_map_single(sp->pdev, skb->data,
4123
- frg_len, PCI_DMA_TODEVICE);
4124
- if (pci_dma_mapping_error(sp->pdev, txdp->Buffer_Pointer))
4125
+ txdp->Buffer_Pointer = dma_map_single(&sp->pdev->dev, skb->data,
4126
+ frg_len, DMA_TO_DEVICE);
4127
+ if (dma_mapping_error(&sp->pdev->dev, txdp->Buffer_Pointer))
41254128 goto pci_map_failed;
41264129
41274130 txdp->Host_Control = (unsigned long)skb;
....@@ -4153,8 +4156,6 @@
41534156 val64 |= TX_FIFO_SPECIAL_FUNC;
41544157
41554158 writeq(val64, &tx_fifo->List_Control);
4156
-
4157
- mmiowb();
41584159
41594160 put_off++;
41604161 if (put_off == fifo->tx_curr_put_info.fifo_len + 1)
....@@ -4346,7 +4347,7 @@
43464347
43474348 /**
43484349 * s2io_handle_errors - Xframe error indication handler
4349
- * @nic: device private variable
4350
+ * @dev_id: opaque handle to dev
43504351 * Description: Handle alarms such as loss of link, single or
43514352 * double ECC errors, critical and serious errors.
43524353 * Return Value:
....@@ -4750,7 +4751,7 @@
47504751 return IRQ_HANDLED;
47514752 }
47524753
4753
-/**
4754
+/*
47544755 * s2io_updt_stats -
47554756 */
47564757 static void s2io_updt_stats(struct s2io_nic *sp)
....@@ -5159,7 +5160,7 @@
51595160 /* read mac entries from CAM */
51605161 static u64 do_s2io_read_unicast_mc(struct s2io_nic *sp, int offset)
51615162 {
5162
- u64 tmp64 = 0xffffffffffff0000ULL, val64;
5163
+ u64 tmp64, val64;
51635164 struct XENA_dev_config __iomem *bar0 = sp->bar0;
51645165
51655166 /* read mac addr */
....@@ -5179,7 +5180,7 @@
51795180 return tmp64 >> 16;
51805181 }
51815182
5182
-/**
5183
+/*
51835184 * s2io_set_mac_addr - driver entry point
51845185 */
51855186
....@@ -5254,8 +5255,7 @@
52545255
52555256 /**
52565257 * s2io_ethtool_set_link_ksettings - Sets different link parameters.
5257
- * @sp : private member of the device structure, which is a pointer to the
5258
- * s2io_nic structure.
5258
+ * @dev : pointer to netdev
52595259 * @cmd: pointer to the structure with parameters given by ethtool to set
52605260 * link information.
52615261 * Description:
....@@ -5284,8 +5284,7 @@
52845284
52855285 /**
52865286 * s2io_ethtol_get_link_ksettings - Return link specific information.
5287
- * @sp : private member of the device structure, pointer to the
5288
- * s2io_nic structure.
5287
+ * @dev: pointer to netdev
52895288 * @cmd : pointer to the structure with parameters given by ethtool
52905289 * to return link information.
52915290 * Description:
....@@ -5324,8 +5323,7 @@
53245323
53255324 /**
53265325 * s2io_ethtool_gdrvinfo - Returns driver specific information.
5327
- * @sp : private member of the device structure, which is a pointer to the
5328
- * s2io_nic structure.
5326
+ * @dev: pointer to netdev
53295327 * @info : pointer to the structure with parameters given by ethtool to
53305328 * return driver information.
53315329 * Description:
....@@ -5346,11 +5344,10 @@
53465344
53475345 /**
53485346 * s2io_ethtool_gregs - dumps the entire space of Xfame into the buffer.
5349
- * @sp: private member of the device structure, which is a pointer to the
5350
- * s2io_nic structure.
5347
+ * @dev: pointer to netdev
53515348 * @regs : pointer to the structure with parameters given by ethtool for
5352
- * dumping the registers.
5353
- * @reg_space: The input argument into which all the registers are dumped.
5349
+ * dumping the registers.
5350
+ * @space: The input argument into which all the registers are dumped.
53545351 * Description:
53555352 * Dumps the entire register space of xFrame NIC into the user given
53565353 * buffer area.
....@@ -5482,8 +5479,7 @@
54825479
54835480 /**
54845481 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
5485
- * @sp : private member of the device structure, which is a pointer to the
5486
- * s2io_nic structure.
5482
+ * @dev: pointer to netdev
54875483 * @ep : pointer to the structure with pause parameters given by ethtool.
54885484 * Description:
54895485 * Returns the Pause frame generation and reception capability of the NIC.
....@@ -5507,8 +5503,7 @@
55075503
55085504 /**
55095505 * s2io_ethtool_setpause_data - set/reset pause frame generation.
5510
- * @sp : private member of the device structure, which is a pointer to the
5511
- * s2io_nic structure.
5506
+ * @dev: pointer to netdev
55125507 * @ep : pointer to the structure with pause parameters given by ethtool.
55135508 * Description:
55145509 * It can be used to set or reset Pause frame generation or reception
....@@ -5537,6 +5532,7 @@
55375532 return 0;
55385533 }
55395534
5535
+#define S2IO_DEV_ID 5
55405536 /**
55415537 * read_eeprom - reads 4 bytes of data from user given offset.
55425538 * @sp : private member of the device structure, which is a pointer to the
....@@ -5552,8 +5548,6 @@
55525548 * Return value:
55535549 * -1 on failure and 0 on success.
55545550 */
5555
-
5556
-#define S2IO_DEV_ID 5
55575551 static int read_eeprom(struct s2io_nic *sp, int off, u64 *data)
55585552 {
55595553 int ret = -1;
....@@ -5745,8 +5739,7 @@
57455739
57465740 /**
57475741 * s2io_ethtool_geeprom - reads the value stored in the Eeprom.
5748
- * @sp : private member of the device structure, which is a pointer to the
5749
- * s2io_nic structure.
5742
+ * @dev: pointer to netdev
57505743 * @eeprom : pointer to the user level structure provided by ethtool,
57515744 * containing all relevant information.
57525745 * @data_buf : user defined value to be written into Eeprom.
....@@ -5782,11 +5775,10 @@
57825775
57835776 /**
57845777 * s2io_ethtool_seeprom - tries to write the user provided value in Eeprom
5785
- * @sp : private member of the device structure, which is a pointer to the
5786
- * s2io_nic structure.
5778
+ * @dev: pointer to netdev
57875779 * @eeprom : pointer to the user level structure provided by ethtool,
57885780 * containing all relevant information.
5789
- * @data_buf ; user defined value to be written into Eeprom.
5781
+ * @data_buf : user defined value to be written into Eeprom.
57905782 * Description:
57915783 * Tries to write the user provided value in the Eeprom, at the offset
57925784 * given by the user.
....@@ -6038,7 +6030,7 @@
60386030
60396031 /**
60406032 * s2io_link_test - verifies the link state of the nic
6041
- * @sp ; private member of the device structure, which is a pointer to the
6033
+ * @sp: private member of the device structure, which is a pointer to the
60426034 * s2io_nic structure.
60436035 * @data: variable that returns the result of each of the test conducted by
60446036 * the driver.
....@@ -6161,8 +6153,7 @@
61616153
61626154 /**
61636155 * s2io_ethtool_test - conducts 6 tsets to determine the health of card.
6164
- * @sp : private member of the device structure, which is a pointer to the
6165
- * s2io_nic structure.
6156
+ * @dev: pointer to netdev
61666157 * @ethtest : pointer to a ethtool command specific structure that will be
61676158 * returned to the user.
61686159 * @data : variable that returns the result of each of the test
....@@ -6608,7 +6599,7 @@
66086599 /**
66096600 * s2io_ioctl - Entry point for the Ioctl
66106601 * @dev : Device pointer.
6611
- * @ifr : An IOCTL specefic structure, that can contain a pointer to
6602
+ * @rq : An IOCTL specefic structure, that can contain a pointer to
66126603 * a proprietary structure used to pass information to the driver.
66136604 * @cmd : This is used to distinguish between the different commands that
66146605 * can be passed to the IOCTL functions.
....@@ -6661,7 +6652,7 @@
66616652
66626653 /**
66636654 * s2io_set_link - Set the LInk status
6664
- * @data: long pointer to device private structue
6655
+ * @work: work struct containing a pointer to device private structue
66656656 * Description: Sets the link status for the adapter
66666657 */
66676658
....@@ -6776,10 +6767,10 @@
67766767 * Host Control is NULL
67776768 */
67786769 rxdp1->Buffer0_ptr = *temp0 =
6779
- pci_map_single(sp->pdev, (*skb)->data,
6770
+ dma_map_single(&sp->pdev->dev, (*skb)->data,
67806771 size - NET_IP_ALIGN,
6781
- PCI_DMA_FROMDEVICE);
6782
- if (pci_dma_mapping_error(sp->pdev, rxdp1->Buffer0_ptr))
6772
+ DMA_FROM_DEVICE);
6773
+ if (dma_mapping_error(&sp->pdev->dev, rxdp1->Buffer0_ptr))
67836774 goto memalloc_failed;
67846775 rxdp->Host_Control = (unsigned long) (*skb);
67856776 }
....@@ -6802,37 +6793,34 @@
68026793 }
68036794 stats->mem_allocated += (*skb)->truesize;
68046795 rxdp3->Buffer2_ptr = *temp2 =
6805
- pci_map_single(sp->pdev, (*skb)->data,
6806
- dev->mtu + 4,
6807
- PCI_DMA_FROMDEVICE);
6808
- if (pci_dma_mapping_error(sp->pdev, rxdp3->Buffer2_ptr))
6796
+ dma_map_single(&sp->pdev->dev, (*skb)->data,
6797
+ dev->mtu + 4, DMA_FROM_DEVICE);
6798
+ if (dma_mapping_error(&sp->pdev->dev, rxdp3->Buffer2_ptr))
68096799 goto memalloc_failed;
68106800 rxdp3->Buffer0_ptr = *temp0 =
6811
- pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6812
- PCI_DMA_FROMDEVICE);
6813
- if (pci_dma_mapping_error(sp->pdev,
6814
- rxdp3->Buffer0_ptr)) {
6815
- pci_unmap_single(sp->pdev,
6801
+ dma_map_single(&sp->pdev->dev, ba->ba_0,
6802
+ BUF0_LEN, DMA_FROM_DEVICE);
6803
+ if (dma_mapping_error(&sp->pdev->dev, rxdp3->Buffer0_ptr)) {
6804
+ dma_unmap_single(&sp->pdev->dev,
68166805 (dma_addr_t)rxdp3->Buffer2_ptr,
68176806 dev->mtu + 4,
6818
- PCI_DMA_FROMDEVICE);
6807
+ DMA_FROM_DEVICE);
68196808 goto memalloc_failed;
68206809 }
68216810 rxdp->Host_Control = (unsigned long) (*skb);
68226811
68236812 /* Buffer-1 will be dummy buffer not used */
68246813 rxdp3->Buffer1_ptr = *temp1 =
6825
- pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN,
6826
- PCI_DMA_FROMDEVICE);
6827
- if (pci_dma_mapping_error(sp->pdev,
6828
- rxdp3->Buffer1_ptr)) {
6829
- pci_unmap_single(sp->pdev,
6814
+ dma_map_single(&sp->pdev->dev, ba->ba_1,
6815
+ BUF1_LEN, DMA_FROM_DEVICE);
6816
+ if (dma_mapping_error(&sp->pdev->dev, rxdp3->Buffer1_ptr)) {
6817
+ dma_unmap_single(&sp->pdev->dev,
68306818 (dma_addr_t)rxdp3->Buffer0_ptr,
6831
- BUF0_LEN, PCI_DMA_FROMDEVICE);
6832
- pci_unmap_single(sp->pdev,
6819
+ BUF0_LEN, DMA_FROM_DEVICE);
6820
+ dma_unmap_single(&sp->pdev->dev,
68336821 (dma_addr_t)rxdp3->Buffer2_ptr,
68346822 dev->mtu + 4,
6835
- PCI_DMA_FROMDEVICE);
6823
+ DMA_FROM_DEVICE);
68366824 goto memalloc_failed;
68376825 }
68386826 }
....@@ -7126,9 +7114,8 @@
71267114 if (ret) {
71277115 DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n",
71287116 dev->name);
7129
- s2io_reset(sp);
7130
- free_rx_buffers(sp);
7131
- return -ENOMEM;
7117
+ ret = -ENOMEM;
7118
+ goto err_fill_buff;
71327119 }
71337120 DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i,
71347121 ring->rx_bufs_left);
....@@ -7166,18 +7153,16 @@
71667153 /* Enable Rx Traffic and interrupts on the NIC */
71677154 if (start_nic(sp)) {
71687155 DBG_PRINT(ERR_DBG, "%s: Starting NIC failed\n", dev->name);
7169
- s2io_reset(sp);
7170
- free_rx_buffers(sp);
7171
- return -ENODEV;
7156
+ ret = -ENODEV;
7157
+ goto err_out;
71727158 }
71737159
71747160 /* Add interrupt service routine */
71757161 if (s2io_add_isr(sp) != 0) {
71767162 if (sp->config.intr_type == MSI_X)
71777163 s2io_rem_isr(sp);
7178
- s2io_reset(sp);
7179
- free_rx_buffers(sp);
7180
- return -ENODEV;
7164
+ ret = -ENODEV;
7165
+ goto err_out;
71817166 }
71827167
71837168 timer_setup(&sp->alarm_timer, s2io_alarm_handle, 0);
....@@ -7197,11 +7182,25 @@
71977182 }
71987183
71997184 return 0;
7185
+
7186
+err_out:
7187
+ if (config->napi) {
7188
+ if (config->intr_type == MSI_X) {
7189
+ for (i = 0; i < sp->config.rx_ring_num; i++)
7190
+ napi_disable(&sp->mac_control.rings[i].napi);
7191
+ } else {
7192
+ napi_disable(&sp->napi);
7193
+ }
7194
+ }
7195
+err_fill_buff:
7196
+ s2io_reset(sp);
7197
+ free_rx_buffers(sp);
7198
+ return ret;
72007199 }
72017200
72027201 /**
72037202 * s2io_restart_nic - Resets the NIC.
7204
- * @data : long pointer to the device private structure
7203
+ * @work : work struct containing a pointer to the device private structure
72057204 * Description:
72067205 * This function is scheduled to be run by the s2io_tx_watchdog
72077206 * function after 0.5 secs to reset the NIC. The idea is to reduce
....@@ -7232,6 +7231,7 @@
72327231 /**
72337232 * s2io_tx_watchdog - Watchdog for transmit side.
72347233 * @dev : Pointer to net device structure
7234
+ * @txqueue: index of the hanging queue
72357235 * Description:
72367236 * This function is triggered if the Tx Queue is stopped
72377237 * for a pre-defined amount of time when the Interface is still up.
....@@ -7242,7 +7242,7 @@
72427242 * void
72437243 */
72447244
7245
-static void s2io_tx_watchdog(struct net_device *dev)
7245
+static void s2io_tx_watchdog(struct net_device *dev, unsigned int txqueue)
72467246 {
72477247 struct s2io_nic *sp = netdev_priv(dev);
72487248 struct swStat *swstats = &sp->mac_control.stats_info->sw_stat;
....@@ -7256,11 +7256,8 @@
72567256
72577257 /**
72587258 * rx_osm_handler - To perform some OS related operations on SKB.
7259
- * @sp: private member of the device structure,pointer to s2io_nic structure.
7260
- * @skb : the socket buffer pointer.
7261
- * @len : length of the packet
7262
- * @cksum : FCS checksum of the frame.
7263
- * @ring_no : the ring from which this RxD was extracted.
7259
+ * @ring_data : the ring from which this RxD was extracted.
7260
+ * @rxdp: descriptor
72647261 * Description:
72657262 * This function is called by the Rx interrupt serivce routine to perform
72667263 * some OS related operations on the SKB before passing it to the upper
....@@ -7280,7 +7277,7 @@
72807277 int ring_no = ring_data->ring_no;
72817278 u16 l3_csum, l4_csum;
72827279 unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
7283
- struct lro *uninitialized_var(lro);
7280
+ struct lro *lro;
72847281 u8 err_mask;
72857282 struct swStat *swstats = &sp->mac_control.stats_info->sw_stat;
72867283
....@@ -7590,9 +7587,10 @@
75907587 }
75917588
75927589 /**
7593
- * rts_ds_steer - Receive traffic steering based on IPv4 or IPv6 TOS
7594
- * or Traffic class respectively.
7590
+ * rts_ds_steer - Receive traffic steering based on IPv4 or IPv6 TOS or Traffic class respectively.
75957591 * @nic: device private variable
7592
+ * @ds_codepoint: data
7593
+ * @ring: ring index
75967594 * Description: The function configures the receive steering to
75977595 * desired receive ring.
75987596 * Return Value: SUCCESS on success and
....@@ -7679,17 +7677,16 @@
76797677 return ret;
76807678 }
76817679
7682
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
7680
+ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
76837681 DBG_PRINT(INIT_DBG, "%s: Using 64bit DMA\n", __func__);
76847682 dma_flag = true;
7685
- if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
7683
+ if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
76867684 DBG_PRINT(ERR_DBG,
7687
- "Unable to obtain 64bit DMA "
7688
- "for consistent allocations\n");
7685
+ "Unable to obtain 64bit DMA for coherent allocations\n");
76897686 pci_disable_device(pdev);
76907687 return -ENOMEM;
76917688 }
7692
- } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
7689
+ } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
76937690 DBG_PRINT(INIT_DBG, "%s: Using 32bit DMA\n", __func__);
76947691 } else {
76957692 pci_disable_device(pdev);