0001
0002
0003
0004 #ifndef _ICE_SWITCH_H_
0005 #define _ICE_SWITCH_H_
0006
0007 #include "ice_common.h"
0008
0009 #define ICE_SW_CFG_MAX_BUF_LEN 2048
0010 #define ICE_DFLT_VSI_INVAL 0xff
0011 #define ICE_FLTR_RX BIT(0)
0012 #define ICE_FLTR_TX BIT(1)
0013 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
0014 #define ICE_VSI_INVAL_ID 0xffff
0015 #define ICE_INVAL_Q_HANDLE 0xFFFF
0016
0017
0018 #define ICE_PROFID_IPV4_GTPC_TEID 41
0019 #define ICE_PROFID_IPV4_GTPC_NO_TEID 42
0020 #define ICE_PROFID_IPV4_GTPU_TEID 43
0021 #define ICE_PROFID_IPV6_GTPC_TEID 44
0022 #define ICE_PROFID_IPV6_GTPC_NO_TEID 45
0023 #define ICE_PROFID_IPV6_GTPU_TEID 46
0024 #define ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER 70
0025
0026
0027 struct ice_vsi_ctx {
0028 u16 vsi_num;
0029 u16 vsis_allocd;
0030 u16 vsis_unallocated;
0031 u16 flags;
0032 struct ice_aqc_vsi_props info;
0033 struct ice_sched_vsi_info sched;
0034 u8 alloc_from_pool;
0035 u8 vf_num;
0036 u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
0037 struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
0038 u16 num_rdma_q_entries[ICE_MAX_TRAFFIC_CLASS];
0039 struct ice_q_ctx *rdma_q_ctx[ICE_MAX_TRAFFIC_CLASS];
0040 };
0041
0042
0043 enum ice_sw_lkup_type {
0044 ICE_SW_LKUP_ETHERTYPE = 0,
0045 ICE_SW_LKUP_MAC = 1,
0046 ICE_SW_LKUP_MAC_VLAN = 2,
0047 ICE_SW_LKUP_PROMISC = 3,
0048 ICE_SW_LKUP_VLAN = 4,
0049 ICE_SW_LKUP_DFLT = 5,
0050 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
0051 ICE_SW_LKUP_PROMISC_VLAN = 9,
0052 ICE_SW_LKUP_LAST
0053 };
0054
0055
0056 enum ice_src_id {
0057 ICE_SRC_ID_UNKNOWN = 0,
0058 ICE_SRC_ID_VSI,
0059 ICE_SRC_ID_QUEUE,
0060 ICE_SRC_ID_LPORT,
0061 };
0062
0063 struct ice_fltr_info {
0064
0065 enum ice_sw_lkup_type lkup_type;
0066
0067 enum ice_sw_fwd_act_type fltr_act;
0068
0069 u16 fltr_rule_id;
0070 u16 flag;
0071
0072
0073 u16 src;
0074 enum ice_src_id src_id;
0075
0076 union {
0077 struct {
0078 u8 mac_addr[ETH_ALEN];
0079 } mac;
0080 struct {
0081 u8 mac_addr[ETH_ALEN];
0082 u16 vlan_id;
0083 } mac_vlan;
0084 struct {
0085 u16 vlan_id;
0086 u16 tpid;
0087 u8 tpid_valid;
0088 } vlan;
0089
0090
0091
0092
0093
0094 struct {
0095 u16 ethertype;
0096 u8 mac_addr[ETH_ALEN];
0097 } ethertype_mac;
0098 } l_data;
0099
0100
0101
0102
0103
0104 union {
0105
0106
0107
0108 u16 q_id:11;
0109 u16 hw_vsi_id:10;
0110 u16 vsi_list_id:10;
0111 } fwd_id;
0112
0113
0114 u16 vsi_handle;
0115
0116
0117
0118
0119
0120 u8 qgrp_size;
0121
0122
0123 u8 lb_en;
0124 u8 lan_en;
0125 };
0126
0127 struct ice_update_recipe_lkup_idx_params {
0128 u16 rid;
0129 u16 fv_idx;
0130 bool ignore_valid;
0131 u16 mask;
0132 bool mask_valid;
0133 u8 lkup_idx;
0134 };
0135
0136 struct ice_adv_lkup_elem {
0137 enum ice_protocol_type type;
0138 union {
0139 union ice_prot_hdr h_u;
0140
0141 u16 h_raw[sizeof(union ice_prot_hdr) / sizeof(u16)];
0142 };
0143 union {
0144 union ice_prot_hdr m_u;
0145
0146 u16 m_raw[sizeof(union ice_prot_hdr) / sizeof(u16)];
0147 };
0148 };
0149
0150 struct ice_sw_act_ctrl {
0151
0152 u16 src;
0153 u16 flag;
0154 enum ice_sw_fwd_act_type fltr_act;
0155
0156 union {
0157
0158
0159
0160 u16 q_id:11;
0161 u16 vsi_id:10;
0162 u16 hw_vsi_id:10;
0163 u16 vsi_list_id:10;
0164 } fwd_id;
0165
0166 u16 vsi_handle;
0167 u8 qgrp_size;
0168 };
0169
0170 struct ice_rule_query_data {
0171
0172 u16 rid;
0173
0174 u16 rule_id;
0175
0176 u16 vsi_handle;
0177 };
0178
0179
0180
0181
0182
0183
0184 struct ice_adv_rule_flags_info {
0185 u32 act;
0186 u8 act_valid;
0187 };
0188
0189 struct ice_adv_rule_info {
0190 enum ice_sw_tunnel_type tun_type;
0191 struct ice_sw_act_ctrl sw_act;
0192 u32 priority;
0193 u8 rx;
0194 u16 fltr_rule_id;
0195 u16 vlan_type;
0196 struct ice_adv_rule_flags_info flags_info;
0197 };
0198
0199
0200 struct ice_sw_recipe {
0201
0202
0203
0204 u8 is_root;
0205 u8 root_rid;
0206 u8 recp_created;
0207
0208
0209 u8 n_ext_words;
0210
0211
0212
0213 struct ice_fv_word ext_words[ICE_MAX_CHAIN_WORDS];
0214 u16 word_masks[ICE_MAX_CHAIN_WORDS];
0215
0216
0217 u8 big_recp;
0218
0219
0220
0221
0222 u8 chain_idx;
0223
0224
0225
0226
0227 u8 n_grp_count;
0228
0229
0230 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
0231
0232 enum ice_sw_tunnel_type tun_type;
0233
0234
0235 u8 adv_rule;
0236 struct list_head filt_rules;
0237 struct list_head filt_replay_rules;
0238
0239 struct mutex filt_rule_lock;
0240
0241
0242 struct list_head fv_list;
0243
0244
0245 u8 num_profs, *prof_ids;
0246
0247
0248 DECLARE_BITMAP(res_idxs, ICE_MAX_FV_WORDS);
0249
0250
0251
0252
0253
0254
0255 u8 priority;
0256
0257 struct list_head rg_list;
0258
0259
0260 struct ice_aqc_recipe_data_elem *root_buf;
0261
0262 struct ice_prot_lkup_ext lkup_exts;
0263 };
0264
0265
0266 struct ice_vsi_list_map_info {
0267 struct list_head list_entry;
0268 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
0269 u16 vsi_list_id;
0270
0271 u16 ref_cnt;
0272 };
0273
0274 struct ice_fltr_list_entry {
0275 struct list_head list_entry;
0276 int status;
0277 struct ice_fltr_info fltr_info;
0278 };
0279
0280
0281
0282
0283
0284
0285
0286 struct ice_fltr_mgmt_list_entry {
0287
0288 struct ice_vsi_list_map_info *vsi_list_info;
0289 u16 vsi_count;
0290 #define ICE_INVAL_LG_ACT_INDEX 0xffff
0291 u16 lg_act_idx;
0292 #define ICE_INVAL_SW_MARKER_ID 0xffff
0293 u16 sw_marker_id;
0294 struct list_head list_entry;
0295 struct ice_fltr_info fltr_info;
0296 #define ICE_INVAL_COUNTER_ID 0xff
0297 u8 counter_index;
0298 };
0299
0300 struct ice_adv_fltr_mgmt_list_entry {
0301 struct list_head list_entry;
0302
0303 struct ice_adv_lkup_elem *lkups;
0304 struct ice_adv_rule_info rule_info;
0305 u16 lkups_cnt;
0306 struct ice_vsi_list_map_info *vsi_list_info;
0307 u16 vsi_count;
0308 };
0309
0310 enum ice_promisc_flags {
0311 ICE_PROMISC_UCAST_RX = 0x1,
0312 ICE_PROMISC_UCAST_TX = 0x2,
0313 ICE_PROMISC_MCAST_RX = 0x4,
0314 ICE_PROMISC_MCAST_TX = 0x8,
0315 ICE_PROMISC_BCAST_RX = 0x10,
0316 ICE_PROMISC_BCAST_TX = 0x20,
0317 ICE_PROMISC_VLAN_RX = 0x40,
0318 ICE_PROMISC_VLAN_TX = 0x80,
0319 };
0320
0321
0322 int
0323 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
0324 struct ice_sq_cd *cd);
0325 int
0326 ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
0327 bool keep_vsi_alloc, struct ice_sq_cd *cd);
0328 int
0329 ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
0330 struct ice_sq_cd *cd);
0331 bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
0332 struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
0333 void ice_clear_all_vsi_ctx(struct ice_hw *hw);
0334
0335 int ice_get_initial_sw_cfg(struct ice_hw *hw);
0336
0337 int
0338 ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
0339 u16 *counter_id);
0340 int
0341 ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
0342 u16 counter_id);
0343
0344
0345 int
0346 ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
0347 u16 lkups_cnt, struct ice_adv_rule_info *rinfo,
0348 struct ice_rule_query_data *added_entry);
0349 int ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
0350 int ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
0351 int ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
0352 int ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
0353 int ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
0354 bool ice_mac_fltr_exist(struct ice_hw *hw, u8 *mac, u16 vsi_handle);
0355 bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle);
0356 int ice_add_eth_mac(struct ice_hw *hw, struct list_head *em_list);
0357 int ice_remove_eth_mac(struct ice_hw *hw, struct list_head *em_list);
0358 int ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable);
0359 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
0360
0361
0362 int
0363 ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
0364 u8 direction);
0365 bool
0366 ice_check_if_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle,
0367 bool *rule_exists);
0368
0369 int
0370 ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
0371 u16 vid);
0372 int
0373 ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
0374 u16 vid);
0375 int
0376 ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
0377 bool rm_vlan_promisc);
0378
0379 int ice_rem_adv_rule_for_vsi(struct ice_hw *hw, u16 vsi_handle);
0380 int
0381 ice_rem_adv_rule_by_id(struct ice_hw *hw,
0382 struct ice_rule_query_data *remove_entry);
0383
0384 int ice_init_def_sw_recp(struct ice_hw *hw);
0385 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
0386
0387 int ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
0388 void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
0389
0390 int
0391 ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
0392 u8 num_rules, enum ice_adminq_opc opc, struct ice_sq_cd *cd);
0393 int
0394 ice_update_recipe_lkup_idx(struct ice_hw *hw,
0395 struct ice_update_recipe_lkup_idx_params *params);
0396 void ice_change_proto_id_to_dvm(void);
0397 #endif