felix.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright 2019 NXP
  3. */
  4. #ifndef _MSCC_FELIX_H
  5. #define _MSCC_FELIX_H
  6. #define ocelot_to_felix(o) container_of((o), struct felix, ocelot)
  7. #define FELIX_MAC_QUIRKS OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
  8. #define OCELOT_PORT_MODE_INTERNAL BIT(0)
  9. #define OCELOT_PORT_MODE_SGMII BIT(1)
  10. #define OCELOT_PORT_MODE_QSGMII BIT(2)
  11. #define OCELOT_PORT_MODE_2500BASEX BIT(3)
  12. #define OCELOT_PORT_MODE_USXGMII BIT(4)
  13. #define OCELOT_PORT_MODE_1000BASEX BIT(5)
  14. /* Platform-specific information */
  15. struct felix_info {
  16. /* Hardcoded resources provided by the hardware instantiation. */
  17. const struct resource *resources;
  18. size_t num_resources;
  19. /* Names of the mandatory resources that will be requested during
  20. * probe. Must have TARGET_MAX elements, since it is indexed by target.
  21. */
  22. const char *const *resource_names;
  23. const struct reg_field *regfields;
  24. const u32 *const *map;
  25. const struct ocelot_ops *ops;
  26. const u32 *port_modes;
  27. int num_mact_rows;
  28. const struct ocelot_stat_layout *stats_layout;
  29. int num_ports;
  30. int num_tx_queues;
  31. struct vcap_props *vcap;
  32. u16 vcap_pol_base;
  33. u16 vcap_pol_max;
  34. u16 vcap_pol_base2;
  35. u16 vcap_pol_max2;
  36. const struct ptp_clock_info *ptp_caps;
  37. /* Some Ocelot switches are integrated into the SoC without the
  38. * extraction IRQ line connected to the ARM GIC. By enabling this
  39. * workaround, the few packets that are delivered to the CPU port
  40. * module (currently only PTP) are copied not only to the hardware CPU
  41. * port module, but also to the 802.1Q Ethernet CPU port, and polling
  42. * the extraction registers is triggered once the DSA tagger sees a PTP
  43. * frame. The Ethernet frame is only used as a notification: it is
  44. * dropped, and the original frame is extracted over MMIO and annotated
  45. * with the RX timestamp.
  46. */
  47. bool quirk_no_xtr_irq;
  48. int (*mdio_bus_alloc)(struct ocelot *ocelot);
  49. void (*mdio_bus_free)(struct ocelot *ocelot);
  50. void (*phylink_validate)(struct ocelot *ocelot, int port,
  51. unsigned long *supported,
  52. struct phylink_link_state *state);
  53. int (*port_setup_tc)(struct dsa_switch *ds, int port,
  54. enum tc_setup_type type, void *type_data);
  55. void (*tas_guard_bands_update)(struct ocelot *ocelot, int port);
  56. void (*port_sched_speed_set)(struct ocelot *ocelot, int port,
  57. u32 speed);
  58. };
  59. /* Methods for initializing the hardware resources specific to a tagging
  60. * protocol (like the NPI port, for "ocelot" or "seville", or the VCAP TCAMs,
  61. * for "ocelot-8021q").
  62. * It is important that the resources configured here do not have side effects
  63. * for the other tagging protocols. If that is the case, their configuration
  64. * needs to go to felix_tag_proto_setup_shared().
  65. */
  66. struct felix_tag_proto_ops {
  67. int (*setup)(struct dsa_switch *ds);
  68. void (*teardown)(struct dsa_switch *ds);
  69. unsigned long (*get_host_fwd_mask)(struct dsa_switch *ds);
  70. int (*change_master)(struct dsa_switch *ds, int port,
  71. struct net_device *master,
  72. struct netlink_ext_ack *extack);
  73. };
  74. extern const struct dsa_switch_ops felix_switch_ops;
  75. /* DSA glue / front-end for struct ocelot */
  76. struct felix {
  77. struct dsa_switch *ds;
  78. const struct felix_info *info;
  79. struct ocelot ocelot;
  80. struct mii_bus *imdio;
  81. struct phylink_pcs **pcs;
  82. resource_size_t switch_base;
  83. enum dsa_tag_protocol tag_proto;
  84. const struct felix_tag_proto_ops *tag_proto_ops;
  85. struct kthread_worker *xmit_worker;
  86. unsigned long host_flood_uc_mask;
  87. unsigned long host_flood_mc_mask;
  88. };
  89. struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
  90. int felix_netdev_to_port(struct net_device *dev);
  91. #endif