.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2014-2015 Hisilicon Limited. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
7 | | - * (at your option) any later version. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
10 | 6 | #include <linux/clk.h> |
---|
.. | .. |
---|
15 | 11 | #include <linux/io.h> |
---|
16 | 12 | #include <linux/ip.h> |
---|
17 | 13 | #include <linux/ipv6.h> |
---|
| 14 | +#include <linux/irq.h> |
---|
18 | 15 | #include <linux/module.h> |
---|
19 | 16 | #include <linux/phy.h> |
---|
20 | 17 | #include <linux/platform_device.h> |
---|
.. | .. |
---|
249 | 246 | int frag_num; |
---|
250 | 247 | struct sk_buff *skb = *out_skb; |
---|
251 | 248 | struct sk_buff *new_skb = NULL; |
---|
252 | | - struct skb_frag_struct *frag; |
---|
| 249 | + skb_frag_t *frag; |
---|
253 | 250 | |
---|
254 | 251 | size = skb_headlen(skb); |
---|
255 | 252 | buf_num = (size + BD_MAX_SEND_SIZE - 1) / BD_MAX_SEND_SIZE; |
---|
.. | .. |
---|
313 | 310 | struct hnae_ring *ring = ring_data->ring; |
---|
314 | 311 | struct device *dev = ring_to_dev(ring); |
---|
315 | 312 | struct netdev_queue *dev_queue; |
---|
316 | | - struct skb_frag_struct *frag; |
---|
| 313 | + skb_frag_t *frag; |
---|
317 | 314 | int buf_num; |
---|
318 | 315 | int seg_num; |
---|
319 | 316 | dma_addr_t dma; |
---|
.. | .. |
---|
561 | 558 | va = (unsigned char *)desc_cb->buf + desc_cb->page_offset; |
---|
562 | 559 | |
---|
563 | 560 | /* prefetch first cache line of first page */ |
---|
564 | | - prefetch(va); |
---|
565 | | -#if L1_CACHE_BYTES < 128 |
---|
566 | | - prefetch(va + L1_CACHE_BYTES); |
---|
567 | | -#endif |
---|
| 561 | + net_prefetch(va); |
---|
568 | 562 | |
---|
569 | 563 | skb = *out_skb = napi_alloc_skb(&ring_data->napi, |
---|
570 | 564 | HNS_RX_HEAD_SIZE); |
---|
.. | .. |
---|
597 | 591 | } else { |
---|
598 | 592 | ring->stats.seg_pkt_cnt++; |
---|
599 | 593 | |
---|
600 | | - pull_len = eth_get_headlen(va, HNS_RX_HEAD_SIZE); |
---|
| 594 | + pull_len = eth_get_headlen(ndev, va, HNS_RX_HEAD_SIZE); |
---|
601 | 595 | memcpy(__skb_put(skb, pull_len), va, |
---|
602 | 596 | ALIGN(pull_len, sizeof(long))); |
---|
603 | 597 | |
---|
.. | .. |
---|
703 | 697 | struct net_device *ndev = ring_data->napi.dev; |
---|
704 | 698 | |
---|
705 | 699 | skb->protocol = eth_type_trans(skb, ndev); |
---|
706 | | - (void)napi_gro_receive(&ring_data->napi, skb); |
---|
| 700 | + napi_gro_receive(&ring_data->napi, skb); |
---|
707 | 701 | } |
---|
708 | 702 | |
---|
709 | 703 | static int hns_desc_unused(struct hnae_ring *ring) |
---|
.. | .. |
---|
758 | 752 | |
---|
759 | 753 | /** |
---|
760 | 754 | * smooth_alg - smoothing algrithm for adjusting coalesce parameter |
---|
| 755 | + * @new_param: new value |
---|
| 756 | + * @old_param: old value |
---|
761 | 757 | **/ |
---|
762 | 758 | static u32 smooth_alg(u32 new_param, u32 old_param) |
---|
763 | 759 | { |
---|
.. | .. |
---|
1139 | 1135 | */ |
---|
1140 | 1136 | int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h) |
---|
1141 | 1137 | { |
---|
| 1138 | + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, }; |
---|
1142 | 1139 | struct phy_device *phy_dev = h->phy_dev; |
---|
1143 | 1140 | int ret; |
---|
1144 | 1141 | |
---|
1145 | 1142 | if (!h->phy_dev) |
---|
1146 | 1143 | return 0; |
---|
1147 | 1144 | |
---|
1148 | | - phy_dev->supported &= h->if_support; |
---|
1149 | | - phy_dev->advertising = phy_dev->supported; |
---|
| 1145 | + ethtool_convert_legacy_u32_to_link_mode(supported, h->if_support); |
---|
| 1146 | + linkmode_and(phy_dev->supported, phy_dev->supported, supported); |
---|
| 1147 | + linkmode_copy(phy_dev->advertising, phy_dev->supported); |
---|
1150 | 1148 | |
---|
1151 | 1149 | if (h->phy_if == PHY_INTERFACE_MODE_XGMII) |
---|
1152 | 1150 | phy_dev->autoneg = false; |
---|
.. | .. |
---|
1161 | 1159 | } |
---|
1162 | 1160 | if (unlikely(ret)) |
---|
1163 | 1161 | return -ENODEV; |
---|
| 1162 | + |
---|
| 1163 | + phy_attached_info(phy_dev); |
---|
1164 | 1164 | |
---|
1165 | 1165 | return 0; |
---|
1166 | 1166 | } |
---|
.. | .. |
---|
1293 | 1293 | |
---|
1294 | 1294 | rd->ring->ring_name[RCB_RING_NAME_LEN - 1] = '\0'; |
---|
1295 | 1295 | |
---|
| 1296 | + irq_set_status_flags(rd->ring->irq, IRQ_NOAUTOEN); |
---|
1296 | 1297 | ret = request_irq(rd->ring->irq, |
---|
1297 | 1298 | hns_irq_handle, 0, rd->ring->ring_name, rd); |
---|
1298 | 1299 | if (ret) { |
---|
.. | .. |
---|
1300 | 1301 | rd->ring->irq); |
---|
1301 | 1302 | goto out_free_irq; |
---|
1302 | 1303 | } |
---|
1303 | | - disable_irq(rd->ring->irq); |
---|
1304 | 1304 | |
---|
1305 | 1305 | cpu = hns_nic_init_affinity_mask(h->q_num, i, |
---|
1306 | 1306 | rd->ring, &rd->mask); |
---|
.. | .. |
---|
1483 | 1483 | |
---|
1484 | 1484 | static void hns_tx_timeout_reset(struct hns_nic_priv *priv); |
---|
1485 | 1485 | #define HNS_TX_TIMEO_LIMIT (40 * HZ) |
---|
1486 | | -static void hns_nic_net_timeout(struct net_device *ndev) |
---|
| 1486 | +static void hns_nic_net_timeout(struct net_device *ndev, unsigned int txqueue) |
---|
1487 | 1487 | { |
---|
1488 | 1488 | struct hns_nic_priv *priv = netdev_priv(ndev); |
---|
1489 | 1489 | |
---|
.. | .. |
---|
1495 | 1495 | ndev->watchdog_timeo = HNS_NIC_TX_TIMEOUT; |
---|
1496 | 1496 | hns_tx_timeout_reset(priv); |
---|
1497 | 1497 | } |
---|
1498 | | -} |
---|
1499 | | - |
---|
1500 | | -static int hns_nic_do_ioctl(struct net_device *netdev, struct ifreq *ifr, |
---|
1501 | | - int cmd) |
---|
1502 | | -{ |
---|
1503 | | - struct phy_device *phy_dev = netdev->phydev; |
---|
1504 | | - |
---|
1505 | | - if (!netif_running(netdev)) |
---|
1506 | | - return -EINVAL; |
---|
1507 | | - |
---|
1508 | | - if (!phy_dev) |
---|
1509 | | - return -ENOTSUPP; |
---|
1510 | | - |
---|
1511 | | - return phy_mii_ioctl(phy_dev, ifr, cmd); |
---|
1512 | 1498 | } |
---|
1513 | 1499 | |
---|
1514 | 1500 | static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb, |
---|
.. | .. |
---|
1847 | 1833 | } |
---|
1848 | 1834 | |
---|
1849 | 1835 | /** |
---|
1850 | | - * nic_set_multicast_list - set mutl mac address |
---|
1851 | | - * @netdev: net device |
---|
1852 | | - * @p: mac address |
---|
| 1836 | + * hns_set_multicast_list - set mutl mac address |
---|
| 1837 | + * @ndev: net device |
---|
1853 | 1838 | * |
---|
1854 | 1839 | * return void |
---|
1855 | 1840 | */ |
---|
.. | .. |
---|
1940 | 1925 | |
---|
1941 | 1926 | static u16 |
---|
1942 | 1927 | hns_nic_select_queue(struct net_device *ndev, struct sk_buff *skb, |
---|
1943 | | - struct net_device *sb_dev, |
---|
1944 | | - select_queue_fallback_t fallback) |
---|
| 1928 | + struct net_device *sb_dev) |
---|
1945 | 1929 | { |
---|
1946 | 1930 | struct ethhdr *eth_hdr = (struct ethhdr *)skb->data; |
---|
1947 | 1931 | struct hns_nic_priv *priv = netdev_priv(ndev); |
---|
.. | .. |
---|
1951 | 1935 | is_multicast_ether_addr(eth_hdr->h_dest)) |
---|
1952 | 1936 | return 0; |
---|
1953 | 1937 | else |
---|
1954 | | - return fallback(ndev, skb, NULL); |
---|
| 1938 | + return netdev_pick_tx(ndev, skb, NULL); |
---|
1955 | 1939 | } |
---|
1956 | 1940 | |
---|
1957 | 1941 | static const struct net_device_ops hns_nic_netdev_ops = { |
---|
.. | .. |
---|
1961 | 1945 | .ndo_tx_timeout = hns_nic_net_timeout, |
---|
1962 | 1946 | .ndo_set_mac_address = hns_nic_net_set_mac_address, |
---|
1963 | 1947 | .ndo_change_mtu = hns_nic_change_mtu, |
---|
1964 | | - .ndo_do_ioctl = hns_nic_do_ioctl, |
---|
| 1948 | + .ndo_do_ioctl = phy_do_ioctl_running, |
---|
1965 | 1949 | .ndo_set_features = hns_nic_set_features, |
---|
1966 | 1950 | .ndo_fix_features = hns_nic_fix_features, |
---|
1967 | 1951 | .ndo_get_stats64 = hns_nic_get_stats64, |
---|
.. | .. |
---|
2356 | 2340 | ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
---|
2357 | 2341 | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO | |
---|
2358 | 2342 | NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6; |
---|
| 2343 | + ndev->vlan_features |= NETIF_F_TSO | NETIF_F_TSO6; |
---|
2359 | 2344 | ndev->max_mtu = MAC_MAX_MTU_V2 - |
---|
2360 | 2345 | (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN); |
---|
2361 | 2346 | break; |
---|