ice_switch.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. ICE_SW_LKUP_LAST
  37. };
  38. struct ice_fltr_info {
  39. /* Look up information: how to look up packet */
  40. enum ice_sw_lkup_type lkup_type;
  41. /* Forward action: filter action to do after lookup */
  42. enum ice_sw_fwd_act_type fltr_act;
  43. /* rule ID returned by firmware once filter rule is created */
  44. u16 fltr_rule_id;
  45. u16 flag;
  46. #define ICE_FLTR_RX BIT(0)
  47. #define ICE_FLTR_TX BIT(1)
  48. #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
  49. /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
  50. u16 src;
  51. union {
  52. struct {
  53. u8 mac_addr[ETH_ALEN];
  54. } mac;
  55. struct {
  56. u8 mac_addr[ETH_ALEN];
  57. u16 vlan_id;
  58. } mac_vlan;
  59. struct {
  60. u16 vlan_id;
  61. } vlan;
  62. /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
  63. * if just using ethertype as filter. Set lkup_type as
  64. * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
  65. * passed in as filter.
  66. */
  67. struct {
  68. u16 ethertype;
  69. u8 mac_addr[ETH_ALEN]; /* optional */
  70. } ethertype_mac;
  71. } l_data;
  72. /* Depending on filter action */
  73. union {
  74. /* queue id in case of ICE_FWD_TO_Q and starting
  75. * queue id in case of ICE_FWD_TO_QGRP.
  76. */
  77. u16 q_id:11;
  78. u16 vsi_id:10;
  79. u16 vsi_list_id:10;
  80. } fwd_id;
  81. /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
  82. * determines the range of queues the packet needs to be forwarded to
  83. */
  84. u8 qgrp_size;
  85. /* Rule creations populate these indicators basing on the switch type */
  86. u8 lb_en; /* Indicate if packet can be looped back */
  87. u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
  88. };
  89. struct ice_sw_recipe {
  90. struct list_head l_entry;
  91. /* To protect modification of filt_rule list
  92. * defined below
  93. */
  94. struct mutex filt_rule_lock;
  95. /* List of type ice_fltr_mgmt_list_entry */
  96. struct list_head filt_rules;
  97. /* linked list of type recipe_list_entry */
  98. struct list_head rg_list;
  99. /* linked list of type ice_sw_fv_list_entry*/
  100. struct list_head fv_list;
  101. struct ice_aqc_recipe_data_elem *r_buf;
  102. u8 recp_count;
  103. u8 root_rid;
  104. u8 num_profs;
  105. u8 *prof_ids;
  106. /* recipe bitmap: what all recipes makes this recipe */
  107. DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
  108. };
  109. /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
  110. struct ice_vsi_list_map_info {
  111. struct list_head list_entry;
  112. DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
  113. u16 vsi_list_id;
  114. };
  115. struct ice_fltr_list_entry {
  116. struct list_head list_entry;
  117. enum ice_status status;
  118. struct ice_fltr_info fltr_info;
  119. };
  120. /* This defines an entry in the list that maintains MAC or VLAN membership
  121. * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
  122. * VLAN. As an optimization the VSI list should be created only when a
  123. * second VSI becomes a subscriber to the same MAC address. VSI lists are always
  124. * used for VLAN membership.
  125. */
  126. struct ice_fltr_mgmt_list_entry {
  127. /* back pointer to VSI list id to VSI list mapping */
  128. struct ice_vsi_list_map_info *vsi_list_info;
  129. u16 vsi_count;
  130. #define ICE_INVAL_LG_ACT_INDEX 0xffff
  131. u16 lg_act_idx;
  132. #define ICE_INVAL_SW_MARKER_ID 0xffff
  133. u16 sw_marker_id;
  134. struct list_head list_entry;
  135. struct ice_fltr_info fltr_info;
  136. #define ICE_INVAL_COUNTER_ID 0xff
  137. u8 counter_index;
  138. };
  139. /* VSI related commands */
  140. enum ice_status
  141. ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  142. struct ice_sq_cd *cd);
  143. enum ice_status
  144. ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
  145. struct ice_sq_cd *cd);
  146. enum ice_status
  147. ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
  148. bool keep_vsi_alloc, struct ice_sq_cd *cd);
  149. enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
  150. /* Switch/bridge related commands */
  151. enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
  152. enum ice_status ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
  153. enum ice_status ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
  154. void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_id);
  155. enum ice_status ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
  156. enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
  157. enum ice_status
  158. ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction);
  159. enum ice_status ice_replay_all_fltr(struct ice_hw *hw);
  160. enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
  161. #endif /* _ICE_SWITCH_H_ */