hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
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_work(struct work_struct *work)
12891269 {
1290
- struct jme_adapter *jme = (struct jme_adapter *)arg;
1270
+ struct jme_adapter *jme = container_of(work, struct jme_adapter, 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;
....@@ -1531,7 +1510,7 @@
15311510 * all other events are ignored
15321511 */
15331512 jwrite32(jme, JME_IEVE, intrstat);
1534
- tasklet_schedule(&jme->linkch_task);
1513
+ schedule_work(&jme->linkch_task);
15351514 goto out_reenable;
15361515 }
15371516
....@@ -1853,14 +1832,9 @@
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->txclean_task, jme_tx_clean_tasklet);
1836
+ tasklet_setup(&jme->rxclean_task, jme_rx_clean_tasklet);
1837
+ tasklet_setup(&jme->rxempty_task, jme_rx_empty_tasklet);
18641838
18651839 rc = jme_request_irq(jme);
18661840 if (rc)
....@@ -1945,7 +1919,7 @@
19451919
19461920 JME_NAPI_DISABLE(jme);
19471921
1948
- tasklet_kill(&jme->linkch_task);
1922
+ cancel_work_sync(&jme->linkch_task);
19491923 tasklet_kill(&jme->txclean_task);
19501924 tasklet_kill(&jme->rxclean_task);
19511925 tasklet_kill(&jme->rxempty_task);
....@@ -2034,10 +2008,9 @@
20342008 ctxbi->len,
20352009 PCI_DMA_TODEVICE);
20362010
2037
- ctxbi->mapping = 0;
2038
- ctxbi->len = 0;
2011
+ ctxbi->mapping = 0;
2012
+ ctxbi->len = 0;
20392013 }
2040
-
20412014 }
20422015
20432016 static int
....@@ -2049,23 +2022,22 @@
20492022 bool hidma = jme->dev->features & NETIF_F_HIGHDMA;
20502023 int i, nr_frags = skb_shinfo(skb)->nr_frags;
20512024 int mask = jme->tx_ring_mask;
2052
- const struct skb_frag_struct *frag;
20532025 u32 len;
20542026 int ret = 0;
20552027
20562028 for (i = 0 ; i < nr_frags ; ++i) {
2057
- frag = &skb_shinfo(skb)->frags[i];
2029
+ const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
2030
+
20582031 ctxdesc = txdesc + ((idx + i + 2) & (mask));
20592032 ctxbi = txbi + ((idx + i + 2) & (mask));
20602033
20612034 ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi,
2062
- skb_frag_page(frag),
2063
- frag->page_offset, skb_frag_size(frag), hidma);
2035
+ skb_frag_page(frag), skb_frag_off(frag),
2036
+ skb_frag_size(frag), hidma);
20642037 if (ret) {
20652038 jme_drop_tx_map(jme, idx, i);
20662039 goto out;
20672040 }
2068
-
20692041 }
20702042
20712043 len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len;
....@@ -2098,12 +2070,7 @@
20982070 IPPROTO_TCP,
20992071 0);
21002072 } 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);
2073
+ tcp_v6_gso_csum_prep(skb);
21072074 }
21082075
21092076 return 0;
....@@ -2358,7 +2325,7 @@
23582325 }
23592326
23602327 static void
2361
-jme_tx_timeout(struct net_device *netdev)
2328
+jme_tx_timeout(struct net_device *netdev, unsigned int txqueue)
23622329 {
23632330 struct jme_adapter *jme = netdev_priv(netdev);
23642331
....@@ -2865,6 +2832,9 @@
28652832 }
28662833
28672834 static const struct ethtool_ops jme_ethtool_ops = {
2835
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
2836
+ ETHTOOL_COALESCE_MAX_FRAMES |
2837
+ ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
28682838 .get_drvinfo = jme_get_drvinfo,
28692839 .get_regs_len = jme_get_regs_len,
28702840 .get_regs = jme_get_regs,
....@@ -3063,9 +3033,8 @@
30633033 atomic_set(&jme->tx_cleaning, 1);
30643034 atomic_set(&jme->rx_empty, 1);
30653035
3066
- tasklet_init(&jme->pcc_task,
3067
- jme_pcc_tasklet,
3068
- (unsigned long) jme);
3036
+ tasklet_setup(&jme->pcc_task, jme_pcc_tasklet);
3037
+ INIT_WORK(&jme->linkch_task, jme_link_change_work);
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))