ocelot.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Microsemi Ocelot Switch driver
  4. *
  5. * Copyright (c) 2017 Microsemi Corporation
  6. */
  7. #ifndef _MSCC_OCELOT_H_
  8. #define _MSCC_OCELOT_H_
  9. #include <linux/bitops.h>
  10. #include <linux/etherdevice.h>
  11. #include <linux/if_vlan.h>
  12. #include <linux/net_tstamp.h>
  13. #include <linux/phylink.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/regmap.h>
  16. #include <soc/mscc/ocelot_qsys.h>
  17. #include <soc/mscc/ocelot_sys.h>
  18. #include <soc/mscc/ocelot_dev.h>
  19. #include <soc/mscc/ocelot_ana.h>
  20. #include <soc/mscc/ocelot_ptp.h>
  21. #include <soc/mscc/ocelot_vcap.h>
  22. #include <soc/mscc/ocelot.h>
  23. #include "ocelot_rew.h"
  24. #include "ocelot_qs.h"
  25. #define OCELOT_STANDALONE_PVID 0
  26. #define OCELOT_BUFFER_CELL_SZ 60
  27. #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
  28. #define OCELOT_PTP_QUEUE_SZ 128
  29. #define OCELOT_JUMBO_MTU 9000
  30. struct ocelot_port_tc {
  31. bool block_shared;
  32. unsigned long offload_cnt;
  33. unsigned long ingress_mirred_id;
  34. unsigned long egress_mirred_id;
  35. unsigned long police_id;
  36. };
  37. struct ocelot_port_private {
  38. struct ocelot_port port;
  39. struct net_device *dev;
  40. struct phylink *phylink;
  41. struct phylink_config phylink_config;
  42. struct ocelot_port_tc tc;
  43. };
  44. /* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
  45. * possibilities of egress port masks for L2 multicast traffic.
  46. * For a switch with 9 user ports, there are 512 possible port masks, but the
  47. * hardware only has 46 individual PGIDs that it can forward multicast traffic
  48. * to. So we need a structure that maps the limited PGID indices to the port
  49. * destinations requested by the user for L2 multicast.
  50. */
  51. struct ocelot_pgid {
  52. unsigned long ports;
  53. int index;
  54. refcount_t refcount;
  55. struct list_head list;
  56. };
  57. struct ocelot_multicast {
  58. struct list_head list;
  59. enum macaccess_entry_type entry_type;
  60. unsigned char addr[ETH_ALEN];
  61. u16 vid;
  62. u16 ports;
  63. struct ocelot_pgid *pgid;
  64. };
  65. int ocelot_bridge_num_find(struct ocelot *ocelot,
  66. const struct net_device *bridge);
  67. int ocelot_mact_learn(struct ocelot *ocelot, int port,
  68. const unsigned char mac[ETH_ALEN],
  69. unsigned int vid, enum macaccess_entry_type type);
  70. int ocelot_mact_forget(struct ocelot *ocelot,
  71. const unsigned char mac[ETH_ALEN], unsigned int vid);
  72. struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
  73. int ocelot_netdev_to_port(struct net_device *dev);
  74. u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
  75. void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
  76. int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
  77. struct device_node *portnp);
  78. void ocelot_release_port(struct ocelot_port *ocelot_port);
  79. int ocelot_devlink_init(struct ocelot *ocelot);
  80. void ocelot_devlink_teardown(struct ocelot *ocelot);
  81. int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
  82. enum devlink_port_flavour flavour);
  83. void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
  84. int ocelot_trap_add(struct ocelot *ocelot, int port,
  85. unsigned long cookie, bool take_ts,
  86. void (*populate)(struct ocelot_vcap_filter *f));
  87. int ocelot_trap_del(struct ocelot *ocelot, int port, unsigned long cookie);
  88. struct ocelot_mirror *ocelot_mirror_get(struct ocelot *ocelot, int to,
  89. struct netlink_ext_ack *extack);
  90. void ocelot_mirror_put(struct ocelot *ocelot);
  91. int ocelot_stats_init(struct ocelot *ocelot);
  92. void ocelot_stats_deinit(struct ocelot *ocelot);
  93. extern struct notifier_block ocelot_netdevice_nb;
  94. extern struct notifier_block ocelot_switchdev_nb;
  95. extern struct notifier_block ocelot_switchdev_blocking_nb;
  96. extern const struct devlink_ops ocelot_devlink_ops;
  97. #endif