2
0

701-net-0247-net-mscc-ocelot-move-port-initialization-into-separa.patch 2.7 KB

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