blob: a6bbdd67fe50da6448048bf94b371dbfd4ade541 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 66f4bb358787f4f52de0614a92f9e4130d1e0e01 Mon Sep 17 00:00:00 2001
2From: Vladimir Oltean <vladimir.oltean@nxp.com>
3Date: Sat, 9 Nov 2019 15:02:56 +0200
4Subject: [PATCH] net: mscc: ocelot: move port initialization into separate
5 function
6
7We need a function for the DSA front-end that does none of the
8net_device registration, but initializes the hardware ports.
9
10Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11Signed-off-by: David S. Miller <davem@davemloft.net>
12---
13 drivers/net/ethernet/mscc/ocelot.c | 45 ++++++++++++++++++++------------------
14 1 file changed, 24 insertions(+), 21 deletions(-)
15
16--- a/drivers/net/ethernet/mscc/ocelot.c
17+++ b/drivers/net/ethernet/mscc/ocelot.c
18@@ -2132,6 +2132,28 @@ static int ocelot_init_timestamp(struct
19 return 0;
20 }
21
22+static void ocelot_init_port(struct ocelot *ocelot, int port)
23+{
24+ struct ocelot_port *ocelot_port = ocelot->ports[port];
25+
26+ INIT_LIST_HEAD(&ocelot_port->skbs);
27+
28+ /* Basic L2 initialization */
29+
30+ /* Drop frames with multicast source address */
31+ ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
32+ ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
33+ ANA_PORT_DROP_CFG, port);
34+
35+ /* Set default VLAN and tag type to 8021Q. */
36+ ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q),
37+ REW_PORT_VLAN_CFG_PORT_TPID_M,
38+ REW_PORT_VLAN_CFG, port);
39+
40+ /* Enable vcap lookups */
41+ ocelot_vcap_enable(ocelot, port);
42+}
43+
44 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
45 void __iomem *regs,
46 struct phy_device *phy)
47@@ -2139,7 +2161,6 @@ int ocelot_probe_port(struct ocelot *oce
48 struct ocelot_port_private *priv;
49 struct ocelot_port *ocelot_port;
50 struct net_device *dev;
51- u32 val;
52 int err;
53
54 dev = alloc_etherdev(sizeof(struct ocelot_port_private));
55@@ -2167,32 +2188,14 @@ int ocelot_probe_port(struct ocelot *oce
56 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, ocelot_port->pvid,
57 ENTRYTYPE_LOCKED);
58
59- INIT_LIST_HEAD(&ocelot_port->skbs);
60+ ocelot_init_port(ocelot, port);
61
62 err = register_netdev(dev);
63 if (err) {
64 dev_err(ocelot->dev, "register_netdev failed\n");
65- goto err_register_netdev;
66+ free_netdev(dev);
67 }
68
69- /* Basic L2 initialization */
70-
71- /* Drop frames with multicast source address */
72- val = ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA;
73- ocelot_rmw_gix(ocelot, val, val, ANA_PORT_DROP_CFG, port);
74-
75- /* Set default VLAN and tag type to 8021Q. */
76- ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q),
77- REW_PORT_VLAN_CFG_PORT_TPID_M,
78- REW_PORT_VLAN_CFG, port);
79-
80- /* Enable vcap lookups */
81- ocelot_vcap_enable(ocelot, port);
82-
83- return 0;
84-
85-err_register_netdev:
86- free_netdev(dev);
87 return err;
88 }
89 EXPORT_SYMBOL(ocelot_probe_port);