ksz9477.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Microchip KSZ9477 series Header file
  4. *
  5. * Copyright (C) 2017-2022 Microchip Technology Inc.
  6. */
  7. #ifndef __KSZ9477_H
  8. #define __KSZ9477_H
  9. #include <net/dsa.h>
  10. #include "ksz_common.h"
  11. int ksz9477_setup(struct dsa_switch *ds);
  12. u32 ksz9477_get_port_addr(int port, int offset);
  13. void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member);
  14. void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port);
  15. void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port);
  16. int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs);
  17. int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
  18. int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
  19. void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
  20. void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
  21. u64 *dropped, u64 *cnt);
  22. void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze);
  23. void ksz9477_port_init_cnt(struct ksz_device *dev, int port);
  24. int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
  25. bool flag, struct netlink_ext_ack *extack);
  26. int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
  27. const struct switchdev_obj_port_vlan *vlan,
  28. struct netlink_ext_ack *extack);
  29. int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
  30. const struct switchdev_obj_port_vlan *vlan);
  31. int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
  32. struct dsa_mall_mirror_tc_entry *mirror,
  33. bool ingress, struct netlink_ext_ack *extack);
  34. void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
  35. struct dsa_mall_mirror_tc_entry *mirror);
  36. int ksz9477_errata_monitor(struct ksz_device *dev, int port,
  37. u64 tx_late_col);
  38. void ksz9477_get_caps(struct ksz_device *dev, int port,
  39. struct phylink_config *config);
  40. int ksz9477_fdb_dump(struct ksz_device *dev, int port,
  41. dsa_fdb_dump_cb_t *cb, void *data);
  42. int ksz9477_fdb_add(struct ksz_device *dev, int port,
  43. const unsigned char *addr, u16 vid, struct dsa_db db);
  44. int ksz9477_fdb_del(struct ksz_device *dev, int port,
  45. const unsigned char *addr, u16 vid, struct dsa_db db);
  46. int ksz9477_mdb_add(struct ksz_device *dev, int port,
  47. const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
  48. int ksz9477_mdb_del(struct ksz_device *dev, int port,
  49. const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
  50. int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
  51. void ksz9477_config_cpu_port(struct dsa_switch *ds);
  52. int ksz9477_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val);
  53. int ksz9477_enable_stp_addr(struct ksz_device *dev);
  54. int ksz9477_reset_switch(struct ksz_device *dev);
  55. int ksz9477_switch_init(struct ksz_device *dev);
  56. void ksz9477_switch_exit(struct ksz_device *dev);
  57. void ksz9477_port_queue_split(struct ksz_device *dev, int port);
  58. void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr);
  59. void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device *hsr);
  60. int ksz9477_port_acl_init(struct ksz_device *dev, int port);
  61. void ksz9477_port_acl_free(struct ksz_device *dev, int port);
  62. int ksz9477_cls_flower_add(struct dsa_switch *ds, int port,
  63. struct flow_cls_offload *cls, bool ingress);
  64. int ksz9477_cls_flower_del(struct dsa_switch *ds, int port,
  65. struct flow_cls_offload *cls, bool ingress);
  66. #define KSZ9477_ACL_ENTRY_SIZE 18
  67. #define KSZ9477_ACL_MAX_ENTRIES 16
  68. struct ksz9477_acl_entry {
  69. u8 entry[KSZ9477_ACL_ENTRY_SIZE];
  70. unsigned long cookie;
  71. u32 prio;
  72. };
  73. struct ksz9477_acl_entries {
  74. struct ksz9477_acl_entry entries[KSZ9477_ACL_MAX_ENTRIES];
  75. int entries_count;
  76. };
  77. struct ksz9477_acl_priv {
  78. struct ksz9477_acl_entries acles;
  79. };
  80. void ksz9477_acl_remove_entries(struct ksz_device *dev, int port,
  81. struct ksz9477_acl_entries *acles,
  82. unsigned long cookie);
  83. int ksz9477_acl_write_list(struct ksz_device *dev, int port);
  84. int ksz9477_sort_acl_entries(struct ksz_device *dev, int port);
  85. void ksz9477_acl_action_rule_cfg(u8 *entry, bool force_prio, u8 prio_val);
  86. void ksz9477_acl_processing_rule_set_action(u8 *entry, u8 action_idx);
  87. void ksz9477_acl_match_process_l2(struct ksz_device *dev, int port,
  88. u16 ethtype, u8 *src_mac, u8 *dst_mac,
  89. unsigned long cookie, u32 prio);
  90. #endif