forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Applied Micro X-Gene SoC Ethernet Driver
23 *
34 * Copyright (c) 2014, Applied Micro Circuits Corporation
45 * Authors: Iyappan Subramanian <isubramanian@apm.com>
56 * Ravi Patel <rapatel@apm.com>
67 * Keyur Chudgar <kchudgar@apm.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
208 */
219
2210 #include <linux/gpio.h>
....@@ -352,7 +340,8 @@
352340 nr_frags = skb_shinfo(skb)->nr_frags;
353341
354342 for (i = 0; i < 2 && i < nr_frags; i++)
355
- len += skb_shinfo(skb)->frags[i].size;
343
+ len += skb_frag_size(
344
+ &skb_shinfo(skb)->frags[i]);
356345
357346 /* HW requires header must reside in 3 buffer */
358347 if (unlikely(hdr_len > len)) {
....@@ -707,6 +696,12 @@
707696 buf_pool->rx_skb[skb_index] = NULL;
708697
709698 datalen = xgene_enet_get_data_len(le64_to_cpu(raw_desc->m1));
699
+
700
+ /* strip off CRC as HW isn't doing this */
701
+ nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
702
+ if (!nv)
703
+ datalen -= 4;
704
+
710705 skb_put(skb, datalen);
711706 prefetch(skb->data - NET_IP_ALIGN);
712707 skb->protocol = eth_type_trans(skb, ndev);
....@@ -728,12 +723,8 @@
728723 }
729724 }
730725
731
- nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
732
- if (!nv) {
733
- /* strip off CRC as HW isn't doing this */
734
- datalen -= 4;
726
+ if (!nv)
735727 goto skip_jumbo;
736
- }
737728
738729 slots = page_pool->slots - 1;
739730 head = page_pool->head;
....@@ -870,7 +861,7 @@
870861 return processed;
871862 }
872863
873
-static void xgene_enet_timeout(struct net_device *ndev)
864
+static void xgene_enet_timeout(struct net_device *ndev, unsigned int txqueue)
874865 {
875866 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
876867 struct netdev_queue *txq;
....@@ -1013,8 +1004,10 @@
10131004
10141005 xgene_enet_napi_enable(pdata);
10151006 ret = xgene_enet_register_irq(ndev);
1016
- if (ret)
1007
+ if (ret) {
1008
+ xgene_enet_napi_disable(pdata);
10171009 return ret;
1010
+ }
10181011
10191012 if (ndev->phydev) {
10201013 phy_start(ndev->phydev);
....@@ -1628,7 +1621,6 @@
16281621 static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata)
16291622 {
16301623 struct platform_device *pdev = pdata->pdev;
1631
- struct device *dev = &pdev->dev;
16321624 int i, ret, max_irqs;
16331625
16341626 if (phy_interface_mode_is_rgmii(pdata->phy_mode))
....@@ -1648,9 +1640,7 @@
16481640 pdata->cq_cnt = max_irqs / 2;
16491641 break;
16501642 }
1651
- dev_err(dev, "Unable to get ENET IRQ\n");
1652
- ret = ret ? : -ENXIO;
1653
- return ret;
1643
+ return ret ? : -ENXIO;
16541644 }
16551645 pdata->irqs[i] = ret;
16561646 }
....@@ -2193,7 +2183,6 @@
21932183 module_platform_driver(xgene_enet_driver);
21942184
21952185 MODULE_DESCRIPTION("APM X-Gene SoC Ethernet driver");
2196
-MODULE_VERSION(XGENE_DRV_VERSION);
21972186 MODULE_AUTHOR("Iyappan Subramanian <isubramanian@apm.com>");
21982187 MODULE_AUTHOR("Keyur Chudgar <kchudgar@apm.com>");
21992188 MODULE_LICENSE("GPL");