1
2
3
4 #ifndef _ICE_SWITCH_H_
5 #define _ICE_SWITCH_H_
6
7 #include "ice_common.h"
8
9 #define ICE_SW_CFG_MAX_BUF_LEN 2048
10 #define ICE_DFLT_VSI_INVAL 0xff
11 #define ICE_FLTR_RX BIT(0)
12 #define ICE_FLTR_TX BIT(1)
13 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
14 #define ICE_VSI_INVAL_ID 0xffff
15 #define ICE_INVAL_Q_HANDLE 0xFFFF
16
17
18 struct ice_q_ctx {
19 u16 q_handle;
20 };
21
22
23 struct ice_vsi_ctx {
24 u16 vsi_num;
25 u16 vsis_allocd;
26 u16 vsis_unallocated;
27 u16 flags;
28 struct ice_aqc_vsi_props info;
29 struct ice_sched_vsi_info sched;
30 u8 alloc_from_pool;
31 u8 vf_num;
32 u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
33 struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
34 };
35
36 enum ice_sw_fwd_act_type {
37 ICE_FWD_TO_VSI = 0,
38 ICE_FWD_TO_VSI_LIST,
39 ICE_FWD_TO_Q,
40 ICE_FWD_TO_QGRP,
41 ICE_DROP_PACKET,
42 ICE_INVAL_ACT
43 };
44
45
46 enum ice_sw_lkup_type {
47 ICE_SW_LKUP_ETHERTYPE = 0,
48 ICE_SW_LKUP_MAC = 1,
49 ICE_SW_LKUP_MAC_VLAN = 2,
50 ICE_SW_LKUP_PROMISC = 3,
51 ICE_SW_LKUP_VLAN = 4,
52 ICE_SW_LKUP_DFLT = 5,
53 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
54 ICE_SW_LKUP_PROMISC_VLAN = 9,
55 ICE_SW_LKUP_LAST
56 };
57
58
59 enum ice_src_id {
60 ICE_SRC_ID_UNKNOWN = 0,
61 ICE_SRC_ID_VSI,
62 ICE_SRC_ID_QUEUE,
63 ICE_SRC_ID_LPORT,
64 };
65
66 struct ice_fltr_info {
67
68 enum ice_sw_lkup_type lkup_type;
69
70 enum ice_sw_fwd_act_type fltr_act;
71
72 u16 fltr_rule_id;
73 u16 flag;
74
75
76 u16 src;
77 enum ice_src_id src_id;
78
79 union {
80 struct {
81 u8 mac_addr[ETH_ALEN];
82 } mac;
83 struct {
84 u8 mac_addr[ETH_ALEN];
85 u16 vlan_id;
86 } mac_vlan;
87 struct {
88 u16 vlan_id;
89 } vlan;
90
91
92
93
94
95 struct {
96 u16 ethertype;
97 u8 mac_addr[ETH_ALEN];
98 } ethertype_mac;
99 } l_data;
100
101
102
103
104
105 union {
106
107
108
109 u16 q_id:11;
110 u16 hw_vsi_id:10;
111 u16 vsi_list_id:10;
112 } fwd_id;
113
114
115 u16 vsi_handle;
116
117
118
119
120
121 u8 qgrp_size;
122
123
124 u8 lb_en;
125 u8 lan_en;
126 };
127
128 struct ice_sw_recipe {
129 struct list_head l_entry;
130
131
132
133
134 struct mutex filt_rule_lock;
135
136
137 struct list_head filt_rules;
138 struct list_head filt_replay_rules;
139
140
141 struct list_head rg_list;
142
143 struct list_head fv_list;
144 struct ice_aqc_recipe_data_elem *r_buf;
145 u8 recp_count;
146 u8 root_rid;
147 u8 num_profs;
148 u8 *prof_ids;
149
150
151 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
152 };
153
154
155 struct ice_vsi_list_map_info {
156 struct list_head list_entry;
157 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
158 u16 vsi_list_id;
159
160 u16 ref_cnt;
161 };
162
163 struct ice_fltr_list_entry {
164 struct list_head list_entry;
165 enum ice_status status;
166 struct ice_fltr_info fltr_info;
167 };
168
169
170
171
172
173
174
175 struct ice_fltr_mgmt_list_entry {
176
177 struct ice_vsi_list_map_info *vsi_list_info;
178 u16 vsi_count;
179 #define ICE_INVAL_LG_ACT_INDEX 0xffff
180 u16 lg_act_idx;
181 #define ICE_INVAL_SW_MARKER_ID 0xffff
182 u16 sw_marker_id;
183 struct list_head list_entry;
184 struct ice_fltr_info fltr_info;
185 #define ICE_INVAL_COUNTER_ID 0xff
186 u8 counter_index;
187 };
188
189 enum ice_promisc_flags {
190 ICE_PROMISC_UCAST_RX = 0x1,
191 ICE_PROMISC_UCAST_TX = 0x2,
192 ICE_PROMISC_MCAST_RX = 0x4,
193 ICE_PROMISC_MCAST_TX = 0x8,
194 ICE_PROMISC_BCAST_RX = 0x10,
195 ICE_PROMISC_BCAST_TX = 0x20,
196 ICE_PROMISC_VLAN_RX = 0x40,
197 ICE_PROMISC_VLAN_TX = 0x80,
198 };
199
200
201 enum ice_status
202 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
203 struct ice_sq_cd *cd);
204 enum ice_status
205 ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
206 bool keep_vsi_alloc, struct ice_sq_cd *cd);
207 enum ice_status
208 ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
209 struct ice_sq_cd *cd);
210 bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
211 struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
212 void ice_clear_all_vsi_ctx(struct ice_hw *hw);
213
214 enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
215
216
217 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
218 enum ice_status ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
219 enum ice_status ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
220 enum ice_status
221 ice_add_eth_mac(struct ice_hw *hw, struct list_head *em_list);
222 enum ice_status
223 ice_remove_eth_mac(struct ice_hw *hw, struct list_head *em_list);
224 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
225 enum ice_status
226 ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
227 enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
228
229
230 enum ice_status
231 ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_handle, bool set, u8 direction);
232 enum ice_status
233 ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
234 u16 vid);
235 enum ice_status
236 ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
237 u16 vid);
238 enum ice_status
239 ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
240 bool rm_vlan_promisc);
241
242 enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
243 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
244 bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
245
246 enum ice_status ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
247 void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
248
249 #endif