ice_switch.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_SWITCH_H_
  4. #define _ICE_SWITCH_H_
  5. #include "ice_common.h"
  6. #define ICE_SW_CFG_MAX_BUF_LEN 2048
  7. #define ICE_DFLT_VSI_INVAL 0xff
  8. #define ICE_VSI_INVAL_ID 0xffff
  9. /* VSI context structure for add/get/update/free operations */
  10. struct ice_vsi_ctx {
  11. u16 vsi_num;
  12. u16 vsis_allocd;
  13. u16 vsis_unallocated;
  14. u16 flags;
  15. struct ice_aqc_vsi_props info;
  16. u8 alloc_from_pool;
  17. };
  18. enum ice_sw_fwd_act_type {
  19. ICE_FWD_TO_VSI = 0,
  20. ICE_FWD_TO_VSI_LIST, /* Do not use this when adding filter */
  21. ICE_FWD_TO_Q,
  22. ICE_FWD_TO_QGRP,
  23. ICE_DROP_PACKET,
  24. ICE_INVAL_ACT
  25. };
  26. /* Switch recipe ID enum values are specific to hardware */
  27. enum ice_sw_lkup_type {
  28. ICE_SW_LKUP_ETHERTYPE = 0,
  29. ICE_SW_LKUP_MAC = 1,
  30. ICE_SW_LKUP_MAC_VLAN = 2,
  31. ICE_SW_LKUP_PROMISC = 3,
  32. ICE_SW_LKUP_VLAN = 4,
  33. ICE_SW_LKUP_DFLT = 5,
  34. ICE_SW_LKUP_ETHERTYPE_MAC = 8,
  35. ICE_SW_LKUP_PROMISC_VLAN = 9,
  36. };
  37. struct ice_fltr_info {
  38. /* Look up information: how to look up packet */
  39. enum ice_sw_lkup_type lkup_type;
  40. /* Forward action: filter action to do after lookup */
  41. enum ice_sw_fwd_act_type fltr_act;
  42. /* rule ID returned by firmware once filter rule is created */
  43. u16 fltr_rule_id;
  44. u16 flag;
  45. #define ICE_FLTR_RX BIT(0)
  46. #define ICE_FLTR_TX BIT(1)
  47. #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
  48. /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
  49. u16 src;
  50. union {
  51. struct {
  52. u8 mac_addr[ETH_ALEN];
  53. } mac;
  54. struct {
  55. u8 mac_addr[ETH_ALEN];
  56. u16 vlan_id;
  57. } mac_vlan;
  58. struct {
  59. u16 vlan_id;
  60. } vlan;
  61. /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
  62. * if just using ethertype as filter. Set lkup_type as
  63. * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
  64. * passed in as filter.
  65. */
  66. struct {
  67. u16 ethertype;
  68. u8 mac_addr[ETH_ALEN]; /* optional */
  69. } ethertype_mac;
  70. } l_data;
  71. /* Depending on filter action */
  72. union {
  73. /* queue id in case of ICE_FWD_TO_Q and starting
  74. * queue id in case of ICE_FWD_TO_QGRP.
  75. */
  76. u16 q_id:11;
  77. u16 vsi_id:10;
  78. u16 vsi_list_id:10;
  79. } fwd_id;
  80. /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
  81. * determines the range of queues the packet needs to be forwarded to
  82. */
  83. u8 qgrp_size;
  84. /* Rule creations populate these indicators basing on the switch type */
  85. u8 lb_en; /* Indicate if packet can be looped back */
  86. u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
  87. };
  88. /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
  89. struct ice_vsi_list_map_info {
  90. struct list_head list_entry;
  91. DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
  92. u16 vsi_list_id;
  93. };
  94. enum ice_sw_fltr_status {
  95. ICE_FLTR_STATUS_NEW = 0,
  96. ICE_FLTR_STATUS_FW_SUCCESS,
  97. ICE_FLTR_STATUS_FW_FAIL,
  98. };
  99. struct ice_fltr_list_entry {
  100. struct list_head list_entry;
  101. enum ice_sw_fltr_status status;
  102. struct ice_fltr_info fltr_info;
  103. };
  104. /* This defines an entry in the list that maintains MAC or VLAN membership
  105. * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
  106. * VLAN. As an optimization the VSI list should be created only when a
  107. * second VSI becomes a subscriber to the VLAN address.
  108. */
  109. struct ice_fltr_mgmt_list_entry {
  110. /* back pointer to VSI list id to VSI list mapping */
  111. struct ice_vsi_list_map_info *vsi_list_info;
  112. u16 vsi_count;
  113. #define ICE_INVAL_LG_ACT_INDEX 0xffff
  114. u16 lg_act_idx;
  115. #define ICE_INVAL_SW_MARKER_ID 0xffff
  116. u16 sw_marker_id;
  117. struct list_head list_entry;
  118. struct ice_fltr_info fltr_info;
  119. #define ICE_INVAL_COUNTER_ID 0xff
  120. u8 counter_index;
  121. };
  122. /* VSI related commands */
  123. enum ice_status
  124. ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  125. struct ice_sq_cd *cd);
  126. enum ice_status
  127. ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  128. struct ice_sq_cd *cd);
  129. enum ice_status
  130. ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  131. bool keep_vsi_alloc, struct ice_sq_cd *cd);
  132. enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
  133. /* Switch/bridge related commands */
  134. enum ice_status ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
  135. enum ice_status ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
  136. void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_id);
  137. enum ice_status ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
  138. enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
  139. enum ice_status
  140. ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction);
  141. #endif /* _ICE_SWITCH_H_ */