cpsw_ale.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine APIs
  3. *
  4. * Copyright (C) 2012 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __TI_CPSW_ALE_H__
  16. #define __TI_CPSW_ALE_H__
  17. struct cpsw_ale_params {
  18. struct device *dev;
  19. void __iomem *ale_regs;
  20. unsigned long ale_ageout; /* in secs */
  21. unsigned long ale_entries;
  22. unsigned long ale_ports;
  23. };
  24. struct cpsw_ale {
  25. struct cpsw_ale_params params;
  26. struct timer_list timer;
  27. unsigned long ageout;
  28. };
  29. enum cpsw_ale_control {
  30. /* global */
  31. ALE_ENABLE,
  32. ALE_CLEAR,
  33. ALE_AGEOUT,
  34. ALE_VLAN_NOLEARN,
  35. ALE_NO_PORT_VLAN,
  36. ALE_OUI_DENY,
  37. ALE_BYPASS,
  38. ALE_RATE_LIMIT_TX,
  39. ALE_VLAN_AWARE,
  40. ALE_AUTH_ENABLE,
  41. ALE_RATE_LIMIT,
  42. /* port controls */
  43. ALE_PORT_STATE,
  44. ALE_PORT_DROP_UNTAGGED,
  45. ALE_PORT_DROP_UNKNOWN_VLAN,
  46. ALE_PORT_NOLEARN,
  47. ALE_PORT_UNKNOWN_VLAN_MEMBER,
  48. ALE_PORT_UNKNOWN_MCAST_FLOOD,
  49. ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
  50. ALE_PORT_UNTAGGED_EGRESS,
  51. ALE_PORT_BCAST_LIMIT,
  52. ALE_PORT_MCAST_LIMIT,
  53. ALE_NUM_CONTROLS,
  54. };
  55. enum cpsw_ale_port_state {
  56. ALE_PORT_STATE_DISABLE = 0x00,
  57. ALE_PORT_STATE_BLOCK = 0x01,
  58. ALE_PORT_STATE_LEARN = 0x02,
  59. ALE_PORT_STATE_FORWARD = 0x03,
  60. };
  61. /* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */
  62. #define ALE_SECURE BIT(0)
  63. #define ALE_BLOCKED BIT(1)
  64. #define ALE_SUPER BIT(2)
  65. #define ALE_VLAN BIT(3)
  66. #define ALE_PORT_HOST BIT(0)
  67. #define ALE_PORT_1 BIT(1)
  68. #define ALE_PORT_2 BIT(2)
  69. #define ALE_MCAST_FWD 0
  70. #define ALE_MCAST_BLOCK_LEARN_FWD 1
  71. #define ALE_MCAST_FWD_LEARN 2
  72. #define ALE_MCAST_FWD_2 3
  73. struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
  74. int cpsw_ale_destroy(struct cpsw_ale *ale);
  75. void cpsw_ale_start(struct cpsw_ale *ale);
  76. void cpsw_ale_stop(struct cpsw_ale *ale);
  77. int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout);
  78. int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask);
  79. int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask);
  80. int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
  81. int flags, u16 vid);
  82. int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
  83. int flags, u16 vid);
  84. int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
  85. int flags, u16 vid, int mcast_state);
  86. int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
  87. int flags, u16 vid);
  88. int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
  89. int reg_mcast, int unreg_mcast);
  90. int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
  91. int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
  92. int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
  93. int control, int value);
  94. #endif