hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*******************************************************************************
23 This is the driver for the GMAC on-chip Ethernet controller for ST SoCs.
34 DWC Ether MAC 10/100/1000 Universal version 3.41a has been used for
....@@ -7,17 +8,6 @@
78
89 Copyright (C) 2007-2009 STMicroelectronics Ltd
910
10
- This program is free software; you can redistribute it and/or modify it
11
- under the terms and conditions of the GNU General Public License,
12
- version 2, as published by the Free Software Foundation.
13
-
14
- This program is distributed in the hope it will be useful, but WITHOUT
15
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17
- more details.
18
-
19
- The full GNU General Public License is included in this distribution in
20
- the file called "COPYING".
2111
2212 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
2313 *******************************************************************************/
....@@ -141,7 +131,6 @@
141131 writel(mcfilterbits[0], ioaddr + GMAC_HASH_LOW);
142132 writel(mcfilterbits[1], ioaddr + GMAC_HASH_HIGH);
143133 return;
144
- break;
145134 case 7:
146135 numhashregs = 4;
147136 break;
....@@ -151,7 +140,6 @@
151140 default:
152141 pr_debug("STMMAC: err in setting multicast filter\n");
153142 return;
154
- break;
155143 }
156144 for (regs = 0; regs < numhashregs; regs++)
157145 writel(mcfilterbits[regs],
....@@ -173,7 +161,7 @@
173161 memset(mc_filter, 0, sizeof(mc_filter));
174162
175163 if (dev->flags & IFF_PROMISC) {
176
- value = GMAC_FRAME_FILTER_PR;
164
+ value = GMAC_FRAME_FILTER_PR | GMAC_FRAME_FILTER_PCF;
177165 } else if (dev->flags & IFF_ALLMULTI) {
178166 value = GMAC_FRAME_FILTER_PM; /* pass all multi */
179167 } else if (!netdev_mc_empty(dev) && (mcbitslog2 == 0)) {
....@@ -202,6 +190,7 @@
202190 }
203191 }
204192
193
+ value |= GMAC_FRAME_FILTER_HPF;
205194 dwmac1000_set_mchash(ioaddr, mc_filter, mcbitslog2);
206195
207196 /* Handle multiple unicast addresses (perfect filtering) */
....@@ -509,6 +498,18 @@
509498 x->mac_gmii_rx_proto_engine++;
510499 }
511500
501
+static void dwmac1000_set_mac_loopback(void __iomem *ioaddr, bool enable)
502
+{
503
+ u32 value = readl(ioaddr + GMAC_CONTROL);
504
+
505
+ if (enable)
506
+ value |= GMAC_CONTROL_LM;
507
+ else
508
+ value &= ~GMAC_CONTROL_LM;
509
+
510
+ writel(value, ioaddr + GMAC_CONTROL);
511
+}
512
+
512513 const struct stmmac_ops dwmac1000_ops = {
513514 .core_init = dwmac1000_core_init,
514515 .set_mac = stmmac_set_mac,
....@@ -528,6 +529,7 @@
528529 .pcs_ctrl_ane = dwmac1000_ctrl_ane,
529530 .pcs_rane = dwmac1000_rane,
530531 .pcs_get_adv_lp = dwmac1000_get_adv_lp,
532
+ .set_mac_loopback = dwmac1000_set_mac_loopback,
531533 };
532534
533535 int dwmac1000_setup(struct stmmac_priv *priv)