1 From 66f4bb358787f4f52de0614a92f9e4130d1e0e01 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:56 +0200
4 Subject: [PATCH] net: mscc: ocelot: move port initialization into separate
7 We need a function for the DSA front-end that does none of the
8 net_device registration, but initializes the hardware ports.
10 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
13 drivers/net/ethernet/mscc/ocelot.c | 45 ++++++++++++++++++++------------------
14 1 file changed, 24 insertions(+), 21 deletions(-)
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
22 +static void ocelot_init_port(struct ocelot *ocelot, int port)
24 + struct ocelot_port *ocelot_port = ocelot->ports[port];
26 + INIT_LIST_HEAD(&ocelot_port->skbs);
28 + /* Basic L2 initialization */
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);
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);
40 + /* Enable vcap lookups */
41 + ocelot_vcap_enable(ocelot, port);
44 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
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;
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,
59 - INIT_LIST_HEAD(&ocelot_port->skbs);
60 + ocelot_init_port(ocelot, port);
62 err = register_netdev(dev);
64 dev_err(ocelot->dev, "register_netdev failed\n");
65 - goto err_register_netdev;
69 - /* Basic L2 initialization */
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);
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);
80 - /* Enable vcap lookups */
81 - ocelot_vcap_enable(ocelot, port);
89 EXPORT_SYMBOL(ocelot_probe_port);