rtl83xx.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef _NET_DSA_RTL83XX_H
  3. #define _NET_DSA_RTL83XX_H
  4. #include <net/dsa.h>
  5. #include "rtl838x.h"
  6. #define RTL8380_VERSION_A 'A'
  7. #define RTL8390_VERSION_A 'A'
  8. #define RTL8380_VERSION_B 'B'
  9. struct fdb_update_work {
  10. struct work_struct work;
  11. struct net_device *ndev;
  12. u64 macs[];
  13. };
  14. #define MIB_DESC(_size, _offset, _name) {.size = _size, .offset = _offset, .name = _name}
  15. struct rtl83xx_mib_desc {
  16. unsigned int size;
  17. unsigned int offset;
  18. const char *name;
  19. };
  20. /* API for switch table access */
  21. struct table_reg {
  22. u16 addr;
  23. u16 data;
  24. u8 max_data;
  25. u8 c_bit;
  26. u8 t_bit;
  27. u8 rmode;
  28. u8 tbl;
  29. struct mutex lock;
  30. };
  31. #define TBL_DESC(_addr, _data, _max_data, _c_bit, _t_bit, _rmode) \
  32. { .addr = _addr, .data = _data, .max_data = _max_data, .c_bit = _c_bit, \
  33. .t_bit = _t_bit, .rmode = _rmode \
  34. }
  35. typedef enum {
  36. RTL8380_TBL_L2 = 0,
  37. RTL8380_TBL_0,
  38. RTL8380_TBL_1,
  39. RTL8390_TBL_L2,
  40. RTL8390_TBL_0,
  41. RTL8390_TBL_1,
  42. RTL8390_TBL_2,
  43. RTL9300_TBL_L2,
  44. RTL9300_TBL_0,
  45. RTL9300_TBL_1,
  46. RTL9300_TBL_2,
  47. RTL9300_TBL_HSB,
  48. RTL9300_TBL_HSA,
  49. RTL9310_TBL_0,
  50. RTL9310_TBL_1,
  51. RTL9310_TBL_2,
  52. RTL9310_TBL_3,
  53. RTL9310_TBL_4,
  54. RTL9310_TBL_5,
  55. RTL_TBL_END
  56. } rtl838x_tbl_reg_t;
  57. void rtl_table_init(void);
  58. struct table_reg *rtl_table_get(rtl838x_tbl_reg_t r, int t);
  59. void rtl_table_release(struct table_reg *r);
  60. int rtl_table_read(struct table_reg *r, int idx);
  61. int rtl_table_write(struct table_reg *r, int idx);
  62. inline u16 rtl_table_data(struct table_reg *r, int i);
  63. inline u32 rtl_table_data_r(struct table_reg *r, int i);
  64. inline void rtl_table_data_w(struct table_reg *r, u32 v, int i);
  65. void __init rtl83xx_setup_qos(struct rtl838x_switch_priv *priv);
  66. int rtl83xx_packet_cntr_alloc(struct rtl838x_switch_priv *priv);
  67. int rtl83xx_port_is_under(const struct net_device * dev, struct rtl838x_switch_priv *priv);
  68. int read_phy(u32 port, u32 page, u32 reg, u32 *val);
  69. int write_phy(u32 port, u32 page, u32 reg, u32 val);
  70. /* Port register accessor functions for the RTL839x and RTL931X SoCs */
  71. void rtl839x_mask_port_reg_be(u64 clear, u64 set, int reg);
  72. u64 rtl839x_get_port_reg_be(int reg);
  73. void rtl839x_set_port_reg_be(u64 set, int reg);
  74. void rtl839x_mask_port_reg_le(u64 clear, u64 set, int reg);
  75. void rtl839x_set_port_reg_le(u64 set, int reg);
  76. u64 rtl839x_get_port_reg_le(int reg);
  77. /* Port register accessor functions for the RTL838x and RTL930X SoCs */
  78. void rtl838x_mask_port_reg(u64 clear, u64 set, int reg);
  79. void rtl838x_set_port_reg(u64 set, int reg);
  80. u64 rtl838x_get_port_reg(int reg);
  81. /* RTL838x-specific */
  82. u32 rtl838x_hash(struct rtl838x_switch_priv *priv, u64 seed);
  83. irqreturn_t rtl838x_switch_irq(int irq, void *dev_id);
  84. void rtl8380_get_version(struct rtl838x_switch_priv *priv);
  85. void rtl838x_vlan_profile_dump(int index);
  86. int rtl83xx_dsa_phy_read(struct dsa_switch *ds, int phy_addr, int phy_reg);
  87. void rtl8380_sds_rst(int mac);
  88. int rtl8380_sds_power(int mac, int val);
  89. void rtl838x_print_matrix(void);
  90. /* RTL839x-specific */
  91. u32 rtl839x_hash(struct rtl838x_switch_priv *priv, u64 seed);
  92. irqreturn_t rtl839x_switch_irq(int irq, void *dev_id);
  93. void rtl8390_get_version(struct rtl838x_switch_priv *priv);
  94. void rtl839x_vlan_profile_dump(int index);
  95. int rtl83xx_dsa_phy_write(struct dsa_switch *ds, int phy_addr, int phy_reg, u16 val);
  96. void rtl839x_exec_tbl2_cmd(u32 cmd);
  97. void rtl839x_print_matrix(void);
  98. /* RTL930x-specific */
  99. u32 rtl930x_hash(struct rtl838x_switch_priv *priv, u64 seed);
  100. irqreturn_t rtl930x_switch_irq(int irq, void *dev_id);
  101. irqreturn_t rtl839x_switch_irq(int irq, void *dev_id);
  102. void rtl930x_vlan_profile_dump(int index);
  103. int rtl9300_sds_power(int mac, int val);
  104. void rtl9300_sds_rst(int sds_num, u32 mode);
  105. int rtl9300_serdes_setup(int sds_num, phy_interface_t phy_mode);
  106. void rtl930x_print_matrix(void);
  107. /* RTL931x-specific */
  108. irqreturn_t rtl931x_switch_irq(int irq, void *dev_id);
  109. int rtl931x_sds_cmu_band_get(int sds, phy_interface_t mode);
  110. int rtl931x_sds_cmu_band_set(int sds, bool enable, u32 band, phy_interface_t mode);
  111. void rtl931x_sds_init(u32 sds, phy_interface_t mode);
  112. int rtl83xx_lag_add(struct dsa_switch *ds, int group, int port, struct netdev_lag_upper_info *info);
  113. int rtl83xx_lag_del(struct dsa_switch *ds, int group, int port);
  114. #endif /* _NET_DSA_RTL83XX_H */