hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/net/ethernet/tehuti/tehuti.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Tehuti Networks(R) Network Driver
34 * ethtool interface implementation
45 * Copyright (C) 2007 Tehuti Networks Ltd. All rights reserved
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 /*
....@@ -142,7 +138,10 @@
142138 * @priv: NIC private structure
143139 * @f: fifo to initialize
144140 * @fsz_type: fifo size type: 0-4KB, 1-8KB, 2-16KB, 3-32KB
145
- * @reg_XXX: offsets of registers relative to base address
141
+ * @reg_CFG0: offsets of registers relative to base address
142
+ * @reg_CFG1: offsets of registers relative to base address
143
+ * @reg_RPTR: offsets of registers relative to base address
144
+ * @reg_WPTR: offsets of registers relative to base address
146145 *
147146 * 1K extra space is allocated at the end of the fifo to simplify
148147 * processing of descriptors that wraps around fifo's end
....@@ -157,11 +156,11 @@
157156 u16 memsz = FIFO_SIZE * (1 << fsz_type);
158157
159158 memset(f, 0, sizeof(struct fifo));
160
- /* pci_alloc_consistent gives us 4k-aligned memory */
161
- f->va = pci_alloc_consistent(priv->pdev,
162
- memsz + FIFO_EXTRA_SPACE, &f->da);
159
+ /* dma_alloc_coherent gives us 4k-aligned memory */
160
+ f->va = dma_alloc_coherent(&priv->pdev->dev, memsz + FIFO_EXTRA_SPACE,
161
+ &f->da, GFP_ATOMIC);
163162 if (!f->va) {
164
- pr_err("pci_alloc_consistent failed\n");
163
+ pr_err("dma_alloc_coherent failed\n");
165164 RET(-ENOMEM);
166165 }
167166 f->reg_CFG0 = reg_CFG0;
....@@ -187,8 +186,8 @@
187186 {
188187 ENTER;
189188 if (f->va) {
190
- pci_free_consistent(priv->pdev,
191
- f->memsz + FIFO_EXTRA_SPACE, f->va, f->da);
189
+ dma_free_coherent(&priv->pdev->dev,
190
+ f->memsz + FIFO_EXTRA_SPACE, f->va, f->da);
192191 f->va = NULL;
193192 }
194193 RET();
....@@ -562,7 +561,7 @@
562561
563562 /**
564563 * bdx_close - Disables a network interface
565
- * @netdev: network interface device structure
564
+ * @ndev: network interface device structure
566565 *
567566 * Returns 0, this is not allowed to fail
568567 *
....@@ -589,7 +588,7 @@
589588
590589 /**
591590 * bdx_open - Called when a network interface is made active
592
- * @netdev: network interface device structure
591
+ * @ndev: network interface device structure
593592 *
594593 * Returns 0 on success, negative value on failure
595594 *
....@@ -702,7 +701,7 @@
702701 * __bdx_vlan_rx_vid - private helper for adding/killing VLAN vid
703702 * @ndev: network device
704703 * @vid: VLAN vid
705
- * @op: add or kill operation
704
+ * @enable: enable or disable vlan
706705 *
707706 * Passes VLAN filter table to hardware
708707 */
....@@ -733,6 +732,7 @@
733732 /**
734733 * bdx_vlan_rx_add_vid - kernel hook for adding VLAN vid to hw filtering table
735734 * @ndev: network device
735
+ * @proto: unused
736736 * @vid: VLAN vid to add
737737 */
738738 static int bdx_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid)
....@@ -744,6 +744,7 @@
744744 /**
745745 * bdx_vlan_rx_kill_vid - kernel hook for killing VLAN vid in hw filtering table
746746 * @ndev: network device
747
+ * @proto: unused
747748 * @vid: VLAN vid to kill
748749 */
749750 static int bdx_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
....@@ -754,7 +755,7 @@
754755
755756 /**
756757 * bdx_change_mtu - Change the Maximum Transfer Unit
757
- * @netdev: network interface device structure
758
+ * @ndev: network interface device structure
758759 * @new_mtu: new value for maximum frame size
759760 *
760761 * Returns 0 on success, negative on failure
....@@ -1037,9 +1038,8 @@
10371038 for (i = 0; i < db->nelem; i++) {
10381039 dm = bdx_rxdb_addr_elem(db, i);
10391040 if (dm->dma) {
1040
- pci_unmap_single(priv->pdev,
1041
- dm->dma, f->m.pktsz,
1042
- PCI_DMA_FROMDEVICE);
1041
+ dma_unmap_single(&priv->pdev->dev, dm->dma,
1042
+ f->m.pktsz, DMA_FROM_DEVICE);
10431043 dev_kfree_skb(dm->skb);
10441044 }
10451045 }
....@@ -1101,9 +1101,8 @@
11011101
11021102 idx = bdx_rxdb_alloc_elem(db);
11031103 dm = bdx_rxdb_addr_elem(db, idx);
1104
- dm->dma = pci_map_single(priv->pdev,
1105
- skb->data, f->m.pktsz,
1106
- PCI_DMA_FROMDEVICE);
1104
+ dm->dma = dma_map_single(&priv->pdev->dev, skb->data,
1105
+ f->m.pktsz, DMA_FROM_DEVICE);
11071106 dm->skb = skb;
11081107 rxfd = (struct rxf_desc *)(f->m.va + f->m.wptr);
11091108 rxfd->info = CPU_CHIP_SWAP32(0x10003); /* INFO=1 BC=3 */
....@@ -1263,16 +1262,15 @@
12631262 (skb2 = netdev_alloc_skb(priv->ndev, len + NET_IP_ALIGN))) {
12641263 skb_reserve(skb2, NET_IP_ALIGN);
12651264 /*skb_put(skb2, len); */
1266
- pci_dma_sync_single_for_cpu(priv->pdev,
1267
- dm->dma, rxf_fifo->m.pktsz,
1268
- PCI_DMA_FROMDEVICE);
1265
+ dma_sync_single_for_cpu(&priv->pdev->dev, dm->dma,
1266
+ rxf_fifo->m.pktsz,
1267
+ DMA_FROM_DEVICE);
12691268 memcpy(skb2->data, skb->data, len);
12701269 bdx_recycle_skb(priv, rxdd);
12711270 skb = skb2;
12721271 } else {
1273
- pci_unmap_single(priv->pdev,
1274
- dm->dma, rxf_fifo->m.pktsz,
1275
- PCI_DMA_FROMDEVICE);
1272
+ dma_unmap_single(&priv->pdev->dev, dm->dma,
1273
+ rxf_fifo->m.pktsz, DMA_FROM_DEVICE);
12761274 bdx_rxdb_free_elem(db, rxdd->va_lo);
12771275 }
12781276
....@@ -1365,18 +1363,6 @@
13651363 * This technique avoids eccessive reading of RPTR and WPTR registers.
13661364 * As our benchmarks shows, it adds 1.5 Gbit/sec to NIS's throuput.
13671365 */
1368
-
1369
-/*************************************************************************
1370
- * Tx DB *
1371
- *************************************************************************/
1372
-static inline int bdx_tx_db_size(struct txdb *db)
1373
-{
1374
- int taken = db->wptr - db->rptr;
1375
- if (taken < 0)
1376
- taken = db->size + 1 + taken; /* (size + 1) equals memsz */
1377
-
1378
- return db->size - taken;
1379
-}
13801366
13811367 /**
13821368 * __bdx_tx_db_ptr_next - helper function, increment read/write pointer + wrap
....@@ -1494,8 +1480,8 @@
14941480 int i;
14951481
14961482 db->wptr->len = skb_headlen(skb);
1497
- db->wptr->addr.dma = pci_map_single(priv->pdev, skb->data,
1498
- db->wptr->len, PCI_DMA_TODEVICE);
1483
+ db->wptr->addr.dma = dma_map_single(&priv->pdev->dev, skb->data,
1484
+ db->wptr->len, DMA_TO_DEVICE);
14991485 pbl->len = CPU_CHIP_SWAP32(db->wptr->len);
15001486 pbl->pa_lo = CPU_CHIP_SWAP32(L32_64(db->wptr->addr.dma));
15011487 pbl->pa_hi = CPU_CHIP_SWAP32(H32_64(db->wptr->addr.dma));
....@@ -1505,7 +1491,7 @@
15051491 bdx_tx_db_inc_wptr(db);
15061492
15071493 for (i = 0; i < nr_frags; i++) {
1508
- const struct skb_frag_struct *frag;
1494
+ const skb_frag_t *frag;
15091495
15101496 frag = &skb_shinfo(skb)->frags[i];
15111497 db->wptr->len = skb_frag_size(frag);
....@@ -1732,14 +1718,14 @@
17321718 BDX_ASSERT(db->rptr->len == 0);
17331719 do {
17341720 BDX_ASSERT(db->rptr->addr.dma == 0);
1735
- pci_unmap_page(priv->pdev, db->rptr->addr.dma,
1736
- db->rptr->len, PCI_DMA_TODEVICE);
1721
+ dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma,
1722
+ db->rptr->len, DMA_TO_DEVICE);
17371723 bdx_tx_db_inc_rptr(db);
17381724 } while (db->rptr->len > 0);
17391725 tx_level -= db->rptr->len; /* '-' koz len is negative */
17401726
17411727 /* now should come skb pointer - free it */
1742
- dev_kfree_skb_irq(db->rptr->addr.skb);
1728
+ dev_consume_skb_irq(db->rptr->addr.skb);
17431729 bdx_tx_db_inc_rptr(db);
17441730 }
17451731
....@@ -1772,6 +1758,8 @@
17721758
17731759 /**
17741760 * bdx_tx_free_skbs - frees all skbs from TXD fifo.
1761
+ * @priv: NIC private structure
1762
+ *
17751763 * It gets called when OS stops this dev, eg upon "ifconfig down" or rmmod
17761764 */
17771765 static void bdx_tx_free_skbs(struct bdx_priv *priv)
....@@ -1781,8 +1769,8 @@
17811769 ENTER;
17821770 while (db->rptr != db->wptr) {
17831771 if (likely(db->rptr->len))
1784
- pci_unmap_page(priv->pdev, db->rptr->addr.dma,
1785
- db->rptr->len, PCI_DMA_TODEVICE);
1772
+ dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma,
1773
+ db->rptr->len, DMA_TO_DEVICE);
17861774 else
17871775 dev_kfree_skb(db->rptr->addr.skb);
17881776 bdx_tx_db_inc_rptr(db);
....@@ -1918,12 +1906,12 @@
19181906 if (err) /* it triggers interrupt, dunno why. */
19191907 goto err_pci; /* it's not a problem though */
19201908
1921
- if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) &&
1922
- !(err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))) {
1909
+ if (!(err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) &&
1910
+ !(err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)))) {
19231911 pci_using_dac = 1;
19241912 } else {
1925
- if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) ||
1926
- (err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)))) {
1913
+ if ((err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) ||
1914
+ (err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)))) {
19271915 pr_err("No usable DMA configuration, aborting\n");
19281916 goto err_dma;
19291917 }
....@@ -2378,6 +2366,8 @@
23782366 static void bdx_set_ethtool_ops(struct net_device *netdev)
23792367 {
23802368 static const struct ethtool_ops bdx_ethtool_ops = {
2369
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
2370
+ ETHTOOL_COALESCE_MAX_FRAMES,
23812371 .get_drvinfo = bdx_get_drvinfo,
23822372 .get_link = ethtool_op_get_link,
23832373 .get_coalesce = bdx_get_coalesce,