| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * JMicron JMC2x0 series PCIe Ethernet Linux Device Driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2008 JMicron Technology Corporation |
|---|
| 5 | | - * http://www.jmicron.com/ |
|---|
| 6 | + * https://www.jmicron.com/ |
|---|
| 6 | 7 | * Copyright (c) 2009 - 2010 Guo-Fu Tseng <cooldavid@cooldavid.org> |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * 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 | | - * |
|---|
| 23 | 10 | */ |
|---|
| 24 | 11 | |
|---|
| 25 | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 27 | 14 | #include <linux/module.h> |
|---|
| 28 | 15 | #include <linux/kernel.h> |
|---|
| 29 | 16 | #include <linux/pci.h> |
|---|
| 30 | | -#include <linux/pci-aspm.h> |
|---|
| 31 | 17 | #include <linux/netdevice.h> |
|---|
| 32 | 18 | #include <linux/etherdevice.h> |
|---|
| 33 | 19 | #include <linux/ethtool.h> |
|---|
| .. | .. |
|---|
| 594 | 580 | GFP_ATOMIC); |
|---|
| 595 | 581 | if (unlikely(!(txring->bufinf))) |
|---|
| 596 | 582 | goto err_free_txring; |
|---|
| 597 | | - |
|---|
| 598 | | - /* |
|---|
| 599 | | - * Initialize Transmit Descriptors |
|---|
| 600 | | - */ |
|---|
| 601 | | - memset(txring->alloc, 0, TX_RING_ALLOC_SIZE(jme->tx_ring_size)); |
|---|
| 602 | 583 | |
|---|
| 603 | 584 | return 0; |
|---|
| 604 | 585 | |
|---|
| .. | .. |
|---|
| 1206 | 1187 | } |
|---|
| 1207 | 1188 | |
|---|
| 1208 | 1189 | static void |
|---|
| 1209 | | -jme_pcc_tasklet(unsigned long arg) |
|---|
| 1190 | +jme_pcc_tasklet(struct tasklet_struct *t) |
|---|
| 1210 | 1191 | { |
|---|
| 1211 | | - struct jme_adapter *jme = (struct jme_adapter *)arg; |
|---|
| 1192 | + struct jme_adapter *jme = from_tasklet(jme, t, pcc_task); |
|---|
| 1212 | 1193 | struct net_device *netdev = jme->dev; |
|---|
| 1213 | 1194 | |
|---|
| 1214 | 1195 | if (unlikely(test_bit(JME_FLAG_SHUTDOWN, &jme->flags))) { |
|---|
| .. | .. |
|---|
| 1284 | 1265 | jwrite32f(jme, JME_APMC, apmc); |
|---|
| 1285 | 1266 | } |
|---|
| 1286 | 1267 | |
|---|
| 1287 | | -static void |
|---|
| 1288 | | -jme_link_change_tasklet(unsigned long arg) |
|---|
| 1268 | +static void jme_link_change_tasklet(struct tasklet_struct *t) |
|---|
| 1289 | 1269 | { |
|---|
| 1290 | | - struct jme_adapter *jme = (struct jme_adapter *)arg; |
|---|
| 1270 | + struct jme_adapter *jme = from_tasklet(jme, t, linkch_task); |
|---|
| 1291 | 1271 | struct net_device *netdev = jme->dev; |
|---|
| 1292 | 1272 | int rc; |
|---|
| 1293 | 1273 | |
|---|
| .. | .. |
|---|
| 1364 | 1344 | } |
|---|
| 1365 | 1345 | |
|---|
| 1366 | 1346 | static void |
|---|
| 1367 | | -jme_rx_clean_tasklet(unsigned long arg) |
|---|
| 1347 | +jme_rx_clean_tasklet(struct tasklet_struct *t) |
|---|
| 1368 | 1348 | { |
|---|
| 1369 | | - struct jme_adapter *jme = (struct jme_adapter *)arg; |
|---|
| 1349 | + struct jme_adapter *jme = from_tasklet(jme, t, rxclean_task); |
|---|
| 1370 | 1350 | struct dynpcc_info *dpi = &(jme->dpi); |
|---|
| 1371 | 1351 | |
|---|
| 1372 | 1352 | jme_process_receive(jme, jme->rx_ring_size); |
|---|
| .. | .. |
|---|
| 1399 | 1379 | } |
|---|
| 1400 | 1380 | |
|---|
| 1401 | 1381 | static void |
|---|
| 1402 | | -jme_rx_empty_tasklet(unsigned long arg) |
|---|
| 1382 | +jme_rx_empty_tasklet(struct tasklet_struct *t) |
|---|
| 1403 | 1383 | { |
|---|
| 1404 | | - struct jme_adapter *jme = (struct jme_adapter *)arg; |
|---|
| 1384 | + struct jme_adapter *jme = from_tasklet(jme, t, rxempty_task); |
|---|
| 1405 | 1385 | |
|---|
| 1406 | 1386 | if (unlikely(atomic_read(&jme->link_changing) != 1)) |
|---|
| 1407 | 1387 | return; |
|---|
| .. | .. |
|---|
| 1411 | 1391 | |
|---|
| 1412 | 1392 | netif_info(jme, rx_status, jme->dev, "RX Queue Full!\n"); |
|---|
| 1413 | 1393 | |
|---|
| 1414 | | - jme_rx_clean_tasklet(arg); |
|---|
| 1394 | + jme_rx_clean_tasklet(&jme->rxclean_task); |
|---|
| 1415 | 1395 | |
|---|
| 1416 | 1396 | while (atomic_read(&jme->rx_empty) > 0) { |
|---|
| 1417 | 1397 | atomic_dec(&jme->rx_empty); |
|---|
| .. | .. |
|---|
| 1435 | 1415 | |
|---|
| 1436 | 1416 | } |
|---|
| 1437 | 1417 | |
|---|
| 1438 | | -static void |
|---|
| 1439 | | -jme_tx_clean_tasklet(unsigned long arg) |
|---|
| 1418 | +static void jme_tx_clean_tasklet(struct tasklet_struct *t) |
|---|
| 1440 | 1419 | { |
|---|
| 1441 | | - struct jme_adapter *jme = (struct jme_adapter *)arg; |
|---|
| 1420 | + struct jme_adapter *jme = from_tasklet(jme, t, txclean_task); |
|---|
| 1442 | 1421 | struct jme_ring *txring = &(jme->txring[0]); |
|---|
| 1443 | 1422 | struct txdesc *txdesc = txring->desc; |
|---|
| 1444 | 1423 | struct jme_buffer_info *txbi = txring->bufinf, *ctxbi, *ttxbi; |
|---|
| .. | .. |
|---|
| 1853 | 1832 | jme_clear_pm_disable_wol(jme); |
|---|
| 1854 | 1833 | JME_NAPI_ENABLE(jme); |
|---|
| 1855 | 1834 | |
|---|
| 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); |
|---|
| 1864 | 1839 | |
|---|
| 1865 | 1840 | rc = jme_request_irq(jme); |
|---|
| 1866 | 1841 | if (rc) |
|---|
| .. | .. |
|---|
| 2034 | 2009 | ctxbi->len, |
|---|
| 2035 | 2010 | PCI_DMA_TODEVICE); |
|---|
| 2036 | 2011 | |
|---|
| 2037 | | - ctxbi->mapping = 0; |
|---|
| 2038 | | - ctxbi->len = 0; |
|---|
| 2012 | + ctxbi->mapping = 0; |
|---|
| 2013 | + ctxbi->len = 0; |
|---|
| 2039 | 2014 | } |
|---|
| 2040 | | - |
|---|
| 2041 | 2015 | } |
|---|
| 2042 | 2016 | |
|---|
| 2043 | 2017 | static int |
|---|
| .. | .. |
|---|
| 2049 | 2023 | bool hidma = jme->dev->features & NETIF_F_HIGHDMA; |
|---|
| 2050 | 2024 | int i, nr_frags = skb_shinfo(skb)->nr_frags; |
|---|
| 2051 | 2025 | int mask = jme->tx_ring_mask; |
|---|
| 2052 | | - const struct skb_frag_struct *frag; |
|---|
| 2053 | 2026 | u32 len; |
|---|
| 2054 | 2027 | int ret = 0; |
|---|
| 2055 | 2028 | |
|---|
| 2056 | 2029 | 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 | + |
|---|
| 2058 | 2032 | ctxdesc = txdesc + ((idx + i + 2) & (mask)); |
|---|
| 2059 | 2033 | ctxbi = txbi + ((idx + i + 2) & (mask)); |
|---|
| 2060 | 2034 | |
|---|
| 2061 | 2035 | 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); |
|---|
| 2064 | 2038 | if (ret) { |
|---|
| 2065 | 2039 | jme_drop_tx_map(jme, idx, i); |
|---|
| 2066 | 2040 | goto out; |
|---|
| 2067 | 2041 | } |
|---|
| 2068 | | - |
|---|
| 2069 | 2042 | } |
|---|
| 2070 | 2043 | |
|---|
| 2071 | 2044 | len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len; |
|---|
| .. | .. |
|---|
| 2098 | 2071 | IPPROTO_TCP, |
|---|
| 2099 | 2072 | 0); |
|---|
| 2100 | 2073 | } 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); |
|---|
| 2107 | 2075 | } |
|---|
| 2108 | 2076 | |
|---|
| 2109 | 2077 | return 0; |
|---|
| .. | .. |
|---|
| 2358 | 2326 | } |
|---|
| 2359 | 2327 | |
|---|
| 2360 | 2328 | static void |
|---|
| 2361 | | -jme_tx_timeout(struct net_device *netdev) |
|---|
| 2329 | +jme_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
|---|
| 2362 | 2330 | { |
|---|
| 2363 | 2331 | struct jme_adapter *jme = netdev_priv(netdev); |
|---|
| 2364 | 2332 | |
|---|
| .. | .. |
|---|
| 2865 | 2833 | } |
|---|
| 2866 | 2834 | |
|---|
| 2867 | 2835 | 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, |
|---|
| 2868 | 2839 | .get_drvinfo = jme_get_drvinfo, |
|---|
| 2869 | 2840 | .get_regs_len = jme_get_regs_len, |
|---|
| 2870 | 2841 | .get_regs = jme_get_regs, |
|---|
| .. | .. |
|---|
| 3063 | 3034 | atomic_set(&jme->tx_cleaning, 1); |
|---|
| 3064 | 3035 | atomic_set(&jme->rx_empty, 1); |
|---|
| 3065 | 3036 | |
|---|
| 3066 | | - tasklet_init(&jme->pcc_task, |
|---|
| 3067 | | - jme_pcc_tasklet, |
|---|
| 3068 | | - (unsigned long) jme); |
|---|
| 3037 | + tasklet_setup(&jme->pcc_task, jme_pcc_tasklet); |
|---|
| 3069 | 3038 | jme->dpi.cur = PCC_P1; |
|---|
| 3070 | 3039 | |
|---|
| 3071 | 3040 | jme->reg_ghc = 0; |
|---|
| .. | .. |
|---|
| 3212 | 3181 | static int |
|---|
| 3213 | 3182 | jme_suspend(struct device *dev) |
|---|
| 3214 | 3183 | { |
|---|
| 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); |
|---|
| 3217 | 3185 | struct jme_adapter *jme = netdev_priv(netdev); |
|---|
| 3218 | 3186 | |
|---|
| 3219 | 3187 | if (!netif_running(netdev)) |
|---|
| .. | .. |
|---|
| 3255 | 3223 | static int |
|---|
| 3256 | 3224 | jme_resume(struct device *dev) |
|---|
| 3257 | 3225 | { |
|---|
| 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); |
|---|
| 3260 | 3227 | struct jme_adapter *jme = netdev_priv(netdev); |
|---|
| 3261 | 3228 | |
|---|
| 3262 | 3229 | if (!netif_running(netdev)) |
|---|