hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/jme.c
....@@ -1,25 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * JMicron JMC2x0 series PCIe Ethernet Linux Device Driver
34 *
45 * Copyright 2008 JMicron Technology Corporation
5
- * http://www.jmicron.com/
6
+ * https://www.jmicron.com/
67 * Copyright (c) 2009 - 2010 Guo-Fu Tseng <cooldavid@cooldavid.org>
78 *
89 * Author: Guo-Fu Tseng <cooldavid@cooldavid.org>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
- *
2310 */
2411
2512 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -27,7 +14,6 @@
2714 #include <linux/module.h>
2815 #include <linux/kernel.h>
2916 #include <linux/pci.h>
30
-#include <linux/pci-aspm.h>
3117 #include <linux/netdevice.h>
3218 #include <linux/etherdevice.h>
3319 #include <linux/ethtool.h>
....@@ -594,11 +580,6 @@
594580 GFP_ATOMIC);
595581 if (unlikely(!(txring->bufinf)))
596582 goto err_free_txring;
597
-
598
- /*
599
- * Initialize Transmit Descriptors
600
- */
601
- memset(txring->alloc, 0, TX_RING_ALLOC_SIZE(jme->tx_ring_size));
602583
603584 return 0;
604585
....@@ -1206,9 +1187,9 @@
12061187 }
12071188
12081189 static void
1209
-jme_pcc_tasklet(unsigned long arg)
1190
+jme_pcc_tasklet(struct tasklet_struct *t)
12101191 {
1211
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1192
+ struct jme_adapter *jme = from_tasklet(jme, t, pcc_task);
12121193 struct net_device *netdev = jme->dev;
12131194
12141195 if (unlikely(test_bit(JME_FLAG_SHUTDOWN, &jme->flags))) {
....@@ -1284,10 +1265,9 @@
12841265 jwrite32f(jme, JME_APMC, apmc);
12851266 }
12861267
1287
-static void
1288
-jme_link_change_tasklet(unsigned long arg)
1268
+static void jme_link_change_tasklet(struct tasklet_struct *t)
12891269 {
1290
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1270
+ struct jme_adapter *jme = from_tasklet(jme, t, linkch_task);
12911271 struct net_device *netdev = jme->dev;
12921272 int rc;
12931273
....@@ -1364,9 +1344,9 @@
13641344 }
13651345
13661346 static void
1367
-jme_rx_clean_tasklet(unsigned long arg)
1347
+jme_rx_clean_tasklet(struct tasklet_struct *t)
13681348 {
1369
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1349
+ struct jme_adapter *jme = from_tasklet(jme, t, rxclean_task);
13701350 struct dynpcc_info *dpi = &(jme->dpi);
13711351
13721352 jme_process_receive(jme, jme->rx_ring_size);
....@@ -1399,9 +1379,9 @@
13991379 }
14001380
14011381 static void
1402
-jme_rx_empty_tasklet(unsigned long arg)
1382
+jme_rx_empty_tasklet(struct tasklet_struct *t)
14031383 {
1404
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1384
+ struct jme_adapter *jme = from_tasklet(jme, t, rxempty_task);
14051385
14061386 if (unlikely(atomic_read(&jme->link_changing) != 1))
14071387 return;
....@@ -1411,7 +1391,7 @@
14111391
14121392 netif_info(jme, rx_status, jme->dev, "RX Queue Full!\n");
14131393
1414
- jme_rx_clean_tasklet(arg);
1394
+ jme_rx_clean_tasklet(&jme->rxclean_task);
14151395
14161396 while (atomic_read(&jme->rx_empty) > 0) {
14171397 atomic_dec(&jme->rx_empty);
....@@ -1435,10 +1415,9 @@
14351415
14361416 }
14371417
1438
-static void
1439
-jme_tx_clean_tasklet(unsigned long arg)
1418
+static void jme_tx_clean_tasklet(struct tasklet_struct *t)
14401419 {
1441
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1420
+ struct jme_adapter *jme = from_tasklet(jme, t, txclean_task);
14421421 struct jme_ring *txring = &(jme->txring[0]);
14431422 struct txdesc *txdesc = txring->desc;
14441423 struct jme_buffer_info *txbi = txring->bufinf, *ctxbi, *ttxbi;
....@@ -1853,14 +1832,10 @@
18531832 jme_clear_pm_disable_wol(jme);
18541833 JME_NAPI_ENABLE(jme);
18551834
1856
- tasklet_init(&jme->linkch_task, jme_link_change_tasklet,
1857
- (unsigned long) jme);
1858
- tasklet_init(&jme->txclean_task, jme_tx_clean_tasklet,
1859
- (unsigned long) jme);
1860
- tasklet_init(&jme->rxclean_task, jme_rx_clean_tasklet,
1861
- (unsigned long) jme);
1862
- tasklet_init(&jme->rxempty_task, jme_rx_empty_tasklet,
1863
- (unsigned long) jme);
1835
+ tasklet_setup(&jme->linkch_task, jme_link_change_tasklet);
1836
+ tasklet_setup(&jme->txclean_task, jme_tx_clean_tasklet);
1837
+ tasklet_setup(&jme->rxclean_task, jme_rx_clean_tasklet);
1838
+ tasklet_setup(&jme->rxempty_task, jme_rx_empty_tasklet);
18641839
18651840 rc = jme_request_irq(jme);
18661841 if (rc)
....@@ -2034,10 +2009,9 @@
20342009 ctxbi->len,
20352010 PCI_DMA_TODEVICE);
20362011
2037
- ctxbi->mapping = 0;
2038
- ctxbi->len = 0;
2012
+ ctxbi->mapping = 0;
2013
+ ctxbi->len = 0;
20392014 }
2040
-
20412015 }
20422016
20432017 static int
....@@ -2049,23 +2023,22 @@
20492023 bool hidma = jme->dev->features & NETIF_F_HIGHDMA;
20502024 int i, nr_frags = skb_shinfo(skb)->nr_frags;
20512025 int mask = jme->tx_ring_mask;
2052
- const struct skb_frag_struct *frag;
20532026 u32 len;
20542027 int ret = 0;
20552028
20562029 for (i = 0 ; i < nr_frags ; ++i) {
2057
- frag = &skb_shinfo(skb)->frags[i];
2030
+ const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
2031
+
20582032 ctxdesc = txdesc + ((idx + i + 2) & (mask));
20592033 ctxbi = txbi + ((idx + i + 2) & (mask));
20602034
20612035 ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi,
2062
- skb_frag_page(frag),
2063
- frag->page_offset, skb_frag_size(frag), hidma);
2036
+ skb_frag_page(frag), skb_frag_off(frag),
2037
+ skb_frag_size(frag), hidma);
20642038 if (ret) {
20652039 jme_drop_tx_map(jme, idx, i);
20662040 goto out;
20672041 }
2068
-
20692042 }
20702043
20712044 len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len;
....@@ -2098,12 +2071,7 @@
20982071 IPPROTO_TCP,
20992072 0);
21002073 } else {
2101
- struct ipv6hdr *ip6h = ipv6_hdr(skb);
2102
-
2103
- tcp_hdr(skb)->check = ~csum_ipv6_magic(&ip6h->saddr,
2104
- &ip6h->daddr, 0,
2105
- IPPROTO_TCP,
2106
- 0);
2074
+ tcp_v6_gso_csum_prep(skb);
21072075 }
21082076
21092077 return 0;
....@@ -2358,7 +2326,7 @@
23582326 }
23592327
23602328 static void
2361
-jme_tx_timeout(struct net_device *netdev)
2329
+jme_tx_timeout(struct net_device *netdev, unsigned int txqueue)
23622330 {
23632331 struct jme_adapter *jme = netdev_priv(netdev);
23642332
....@@ -2865,6 +2833,9 @@
28652833 }
28662834
28672835 static const struct ethtool_ops jme_ethtool_ops = {
2836
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
2837
+ ETHTOOL_COALESCE_MAX_FRAMES |
2838
+ ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
28682839 .get_drvinfo = jme_get_drvinfo,
28692840 .get_regs_len = jme_get_regs_len,
28702841 .get_regs = jme_get_regs,
....@@ -3063,9 +3034,7 @@
30633034 atomic_set(&jme->tx_cleaning, 1);
30643035 atomic_set(&jme->rx_empty, 1);
30653036
3066
- tasklet_init(&jme->pcc_task,
3067
- jme_pcc_tasklet,
3068
- (unsigned long) jme);
3037
+ tasklet_setup(&jme->pcc_task, jme_pcc_tasklet);
30693038 jme->dpi.cur = PCC_P1;
30703039
30713040 jme->reg_ghc = 0;
....@@ -3212,8 +3181,7 @@
32123181 static int
32133182 jme_suspend(struct device *dev)
32143183 {
3215
- struct pci_dev *pdev = to_pci_dev(dev);
3216
- struct net_device *netdev = pci_get_drvdata(pdev);
3184
+ struct net_device *netdev = dev_get_drvdata(dev);
32173185 struct jme_adapter *jme = netdev_priv(netdev);
32183186
32193187 if (!netif_running(netdev))
....@@ -3255,8 +3223,7 @@
32553223 static int
32563224 jme_resume(struct device *dev)
32573225 {
3258
- struct pci_dev *pdev = to_pci_dev(dev);
3259
- struct net_device *netdev = pci_get_drvdata(pdev);
3226
+ struct net_device *netdev = dev_get_drvdata(dev);
32603227 struct jme_adapter *jme = netdev_priv(netdev);
32613228
32623229 if (!netif_running(netdev))