forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/hisilicon/hns/hns_enet.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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.
84 */
95
106 #include <linux/clk.h>
....@@ -15,6 +11,7 @@
1511 #include <linux/io.h>
1612 #include <linux/ip.h>
1713 #include <linux/ipv6.h>
14
+#include <linux/irq.h>
1815 #include <linux/module.h>
1916 #include <linux/phy.h>
2017 #include <linux/platform_device.h>
....@@ -249,7 +246,7 @@
249246 int frag_num;
250247 struct sk_buff *skb = *out_skb;
251248 struct sk_buff *new_skb = NULL;
252
- struct skb_frag_struct *frag;
249
+ skb_frag_t *frag;
253250
254251 size = skb_headlen(skb);
255252 buf_num = (size + BD_MAX_SEND_SIZE - 1) / BD_MAX_SEND_SIZE;
....@@ -313,7 +310,7 @@
313310 struct hnae_ring *ring = ring_data->ring;
314311 struct device *dev = ring_to_dev(ring);
315312 struct netdev_queue *dev_queue;
316
- struct skb_frag_struct *frag;
313
+ skb_frag_t *frag;
317314 int buf_num;
318315 int seg_num;
319316 dma_addr_t dma;
....@@ -561,10 +558,7 @@
561558 va = (unsigned char *)desc_cb->buf + desc_cb->page_offset;
562559
563560 /* 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);
568562
569563 skb = *out_skb = napi_alloc_skb(&ring_data->napi,
570564 HNS_RX_HEAD_SIZE);
....@@ -597,7 +591,7 @@
597591 } else {
598592 ring->stats.seg_pkt_cnt++;
599593
600
- pull_len = eth_get_headlen(va, HNS_RX_HEAD_SIZE);
594
+ pull_len = eth_get_headlen(ndev, va, HNS_RX_HEAD_SIZE);
601595 memcpy(__skb_put(skb, pull_len), va,
602596 ALIGN(pull_len, sizeof(long)));
603597
....@@ -703,7 +697,7 @@
703697 struct net_device *ndev = ring_data->napi.dev;
704698
705699 skb->protocol = eth_type_trans(skb, ndev);
706
- (void)napi_gro_receive(&ring_data->napi, skb);
700
+ napi_gro_receive(&ring_data->napi, skb);
707701 }
708702
709703 static int hns_desc_unused(struct hnae_ring *ring)
....@@ -758,6 +752,8 @@
758752
759753 /**
760754 * smooth_alg - smoothing algrithm for adjusting coalesce parameter
755
+ * @new_param: new value
756
+ * @old_param: old value
761757 **/
762758 static u32 smooth_alg(u32 new_param, u32 old_param)
763759 {
....@@ -1139,14 +1135,16 @@
11391135 */
11401136 int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h)
11411137 {
1138
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
11421139 struct phy_device *phy_dev = h->phy_dev;
11431140 int ret;
11441141
11451142 if (!h->phy_dev)
11461143 return 0;
11471144
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);
11501148
11511149 if (h->phy_if == PHY_INTERFACE_MODE_XGMII)
11521150 phy_dev->autoneg = false;
....@@ -1161,6 +1159,8 @@
11611159 }
11621160 if (unlikely(ret))
11631161 return -ENODEV;
1162
+
1163
+ phy_attached_info(phy_dev);
11641164
11651165 return 0;
11661166 }
....@@ -1293,6 +1293,7 @@
12931293
12941294 rd->ring->ring_name[RCB_RING_NAME_LEN - 1] = '\0';
12951295
1296
+ irq_set_status_flags(rd->ring->irq, IRQ_NOAUTOEN);
12961297 ret = request_irq(rd->ring->irq,
12971298 hns_irq_handle, 0, rd->ring->ring_name, rd);
12981299 if (ret) {
....@@ -1300,7 +1301,6 @@
13001301 rd->ring->irq);
13011302 goto out_free_irq;
13021303 }
1303
- disable_irq(rd->ring->irq);
13041304
13051305 cpu = hns_nic_init_affinity_mask(h->q_num, i,
13061306 rd->ring, &rd->mask);
....@@ -1483,7 +1483,7 @@
14831483
14841484 static void hns_tx_timeout_reset(struct hns_nic_priv *priv);
14851485 #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)
14871487 {
14881488 struct hns_nic_priv *priv = netdev_priv(ndev);
14891489
....@@ -1495,20 +1495,6 @@
14951495 ndev->watchdog_timeo = HNS_NIC_TX_TIMEOUT;
14961496 hns_tx_timeout_reset(priv);
14971497 }
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);
15121498 }
15131499
15141500 static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
....@@ -1847,9 +1833,8 @@
18471833 }
18481834
18491835 /**
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
18531838 *
18541839 * return void
18551840 */
....@@ -1940,8 +1925,7 @@
19401925
19411926 static u16
19421927 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)
19451929 {
19461930 struct ethhdr *eth_hdr = (struct ethhdr *)skb->data;
19471931 struct hns_nic_priv *priv = netdev_priv(ndev);
....@@ -1951,7 +1935,7 @@
19511935 is_multicast_ether_addr(eth_hdr->h_dest))
19521936 return 0;
19531937 else
1954
- return fallback(ndev, skb, NULL);
1938
+ return netdev_pick_tx(ndev, skb, NULL);
19551939 }
19561940
19571941 static const struct net_device_ops hns_nic_netdev_ops = {
....@@ -1961,7 +1945,7 @@
19611945 .ndo_tx_timeout = hns_nic_net_timeout,
19621946 .ndo_set_mac_address = hns_nic_net_set_mac_address,
19631947 .ndo_change_mtu = hns_nic_change_mtu,
1964
- .ndo_do_ioctl = hns_nic_do_ioctl,
1948
+ .ndo_do_ioctl = phy_do_ioctl_running,
19651949 .ndo_set_features = hns_nic_set_features,
19661950 .ndo_fix_features = hns_nic_fix_features,
19671951 .ndo_get_stats64 = hns_nic_get_stats64,
....@@ -2356,6 +2340,7 @@
23562340 ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
23572341 NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
23582342 NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6;
2343
+ ndev->vlan_features |= NETIF_F_TSO | NETIF_F_TSO6;
23592344 ndev->max_mtu = MAC_MAX_MTU_V2 -
23602345 (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
23612346 break;