xref: /freebsd/sys/dev/ice/ice_switch.h (revision 9c30461dd25bac49045acbeac10e00b6cc13d2bc)
171d10453SEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */
29dc2f6e2SEric Joyner /*  Copyright (c) 2023, Intel Corporation
371d10453SEric Joyner  *  All rights reserved.
471d10453SEric Joyner  *
571d10453SEric Joyner  *  Redistribution and use in source and binary forms, with or without
671d10453SEric Joyner  *  modification, are permitted provided that the following conditions are met:
771d10453SEric Joyner  *
871d10453SEric Joyner  *   1. Redistributions of source code must retain the above copyright notice,
971d10453SEric Joyner  *      this list of conditions and the following disclaimer.
1071d10453SEric Joyner  *
1171d10453SEric Joyner  *   2. Redistributions in binary form must reproduce the above copyright
1271d10453SEric Joyner  *      notice, this list of conditions and the following disclaimer in the
1371d10453SEric Joyner  *      documentation and/or other materials provided with the distribution.
1471d10453SEric Joyner  *
1571d10453SEric Joyner  *   3. Neither the name of the Intel Corporation nor the names of its
1671d10453SEric Joyner  *      contributors may be used to endorse or promote products derived from
1771d10453SEric Joyner  *      this software without specific prior written permission.
1871d10453SEric Joyner  *
1971d10453SEric Joyner  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2071d10453SEric Joyner  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2171d10453SEric Joyner  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2271d10453SEric Joyner  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2371d10453SEric Joyner  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2471d10453SEric Joyner  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2571d10453SEric Joyner  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2671d10453SEric Joyner  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2771d10453SEric Joyner  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2871d10453SEric Joyner  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2971d10453SEric Joyner  *  POSSIBILITY OF SUCH DAMAGE.
3071d10453SEric Joyner  */
3171d10453SEric Joyner 
3271d10453SEric Joyner #ifndef _ICE_SWITCH_H_
3371d10453SEric Joyner #define _ICE_SWITCH_H_
3471d10453SEric Joyner 
358923de59SPiotr Kubaj #include "ice_type.h"
3671d10453SEric Joyner #include "ice_protocol_type.h"
3771d10453SEric Joyner 
3871d10453SEric Joyner #define ICE_SW_CFG_MAX_BUF_LEN 2048
3971d10453SEric Joyner #define ICE_MAX_SW 256
4071d10453SEric Joyner #define ICE_DFLT_VSI_INVAL 0xff
4171d10453SEric Joyner #define ICE_FLTR_RX BIT(0)
4271d10453SEric Joyner #define ICE_FLTR_TX BIT(1)
4371d10453SEric Joyner #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
4471d10453SEric Joyner 
458923de59SPiotr Kubaj #define ICE_PROFID_IPV4_GTPC_TEID	41
468923de59SPiotr Kubaj #define ICE_PROFID_IPV4_GTPC_NO_TEID		42
478923de59SPiotr Kubaj #define ICE_PROFID_IPV4_GTPU_TEID		43
488923de59SPiotr Kubaj #define ICE_PROFID_IPV6_GTPC_TEID		44
498923de59SPiotr Kubaj #define ICE_PROFID_IPV6_GTPC_NO_TEID		45
508923de59SPiotr Kubaj #define ICE_PROFID_IPV6_GTPU_TEID		46
518923de59SPiotr Kubaj #define ICE_PROFID_IPV6_GTPU_IPV6_TCP		70
528923de59SPiotr Kubaj 
537d7af7f8SEric Joyner #define DUMMY_ETH_HDR_LEN		16
547d7af7f8SEric Joyner 
5571d10453SEric Joyner /* Worst case buffer length for ice_aqc_opc_get_res_alloc */
5671d10453SEric Joyner #define ICE_MAX_RES_TYPES 0x80
5771d10453SEric Joyner #define ICE_AQ_GET_RES_ALLOC_BUF_LEN \
5871d10453SEric Joyner 	(ICE_MAX_RES_TYPES * sizeof(struct ice_aqc_get_res_resp_elem))
5971d10453SEric Joyner 
6071d10453SEric Joyner #define ICE_VSI_INVAL_ID 0xFFFF
6171d10453SEric Joyner #define ICE_INVAL_Q_HANDLE 0xFFFF
6271d10453SEric Joyner 
6371d10453SEric Joyner /* VSI context structure for add/get/update/free operations */
6471d10453SEric Joyner struct ice_vsi_ctx {
6571d10453SEric Joyner 	u16 vsi_num;
6671d10453SEric Joyner 	u16 vsis_allocd;
6771d10453SEric Joyner 	u16 vsis_unallocated;
6871d10453SEric Joyner 	u16 flags;
6971d10453SEric Joyner 	struct ice_aqc_vsi_props info;
7071d10453SEric Joyner 	struct ice_sched_vsi_info sched;
7171d10453SEric Joyner 	u8 alloc_from_pool;
7271d10453SEric Joyner 	u8 vf_num;
7371d10453SEric Joyner 	u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
7471d10453SEric Joyner 	struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
758a13362dSEric Joyner 	u16 num_rdma_q_entries[ICE_MAX_TRAFFIC_CLASS];
768a13362dSEric Joyner 	struct ice_q_ctx *rdma_q_ctx[ICE_MAX_TRAFFIC_CLASS];
7771d10453SEric Joyner };
7871d10453SEric Joyner 
7971d10453SEric Joyner /* This is to be used by add/update mirror rule Admin Queue command */
8071d10453SEric Joyner struct ice_mir_rule_buf {
8171d10453SEric Joyner 	u16 vsi_idx; /* VSI index */
8271d10453SEric Joyner 
8371d10453SEric Joyner 	/* For each VSI, user can specify whether corresponding VSI
8471d10453SEric Joyner 	 * should be added/removed to/from mirror rule
8571d10453SEric Joyner 	 *
8671d10453SEric Joyner 	 * add mirror rule: this should always be TRUE.
8771d10453SEric Joyner 	 * update mirror rule:  add(true) or remove(false) VSI to/from
8871d10453SEric Joyner 	 * mirror rule
8971d10453SEric Joyner 	 */
9071d10453SEric Joyner 	u8 add;
9171d10453SEric Joyner };
9271d10453SEric Joyner 
9371d10453SEric Joyner /* Switch recipe ID enum values are specific to hardware */
9471d10453SEric Joyner enum ice_sw_lkup_type {
9571d10453SEric Joyner 	ICE_SW_LKUP_ETHERTYPE = 0,
9671d10453SEric Joyner 	ICE_SW_LKUP_MAC = 1,
9771d10453SEric Joyner 	ICE_SW_LKUP_MAC_VLAN = 2,
9871d10453SEric Joyner 	ICE_SW_LKUP_PROMISC = 3,
9971d10453SEric Joyner 	ICE_SW_LKUP_VLAN = 4,
10071d10453SEric Joyner 	ICE_SW_LKUP_DFLT = 5,
10171d10453SEric Joyner 	ICE_SW_LKUP_ETHERTYPE_MAC = 8,
10271d10453SEric Joyner 	ICE_SW_LKUP_PROMISC_VLAN = 9,
10371d10453SEric Joyner 	ICE_SW_LKUP_LAST
10471d10453SEric Joyner };
10571d10453SEric Joyner 
10671d10453SEric Joyner /* type of filter src ID */
10771d10453SEric Joyner enum ice_src_id {
10871d10453SEric Joyner 	ICE_SRC_ID_UNKNOWN = 0,
10971d10453SEric Joyner 	ICE_SRC_ID_VSI,
11071d10453SEric Joyner 	ICE_SRC_ID_QUEUE,
11171d10453SEric Joyner 	ICE_SRC_ID_LPORT,
11271d10453SEric Joyner };
11371d10453SEric Joyner 
11471d10453SEric Joyner struct ice_fltr_info {
11571d10453SEric Joyner 	/* Look up information: how to look up packet */
11671d10453SEric Joyner 	enum ice_sw_lkup_type lkup_type;
11771d10453SEric Joyner 	/* Forward action: filter action to do after lookup */
11871d10453SEric Joyner 	enum ice_sw_fwd_act_type fltr_act;
11971d10453SEric Joyner 	/* rule ID returned by firmware once filter rule is created */
12071d10453SEric Joyner 	u16 fltr_rule_id;
12171d10453SEric Joyner 	u16 flag;
12271d10453SEric Joyner 
12371d10453SEric Joyner 	/* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
12471d10453SEric Joyner 	u16 src;
12571d10453SEric Joyner 	enum ice_src_id src_id;
12671d10453SEric Joyner 
12771d10453SEric Joyner 	union {
12871d10453SEric Joyner 		struct {
12971d10453SEric Joyner 			u8 mac_addr[ETH_ALEN];
13071d10453SEric Joyner 		} mac;
13171d10453SEric Joyner 		struct {
13271d10453SEric Joyner 			u8 mac_addr[ETH_ALEN];
13371d10453SEric Joyner 			u16 vlan_id;
13471d10453SEric Joyner 		} mac_vlan;
13571d10453SEric Joyner 		struct {
13671d10453SEric Joyner 			u16 vlan_id;
1379cf1841cSEric Joyner 			u16 tpid;
1389cf1841cSEric Joyner 			u8 tpid_valid;
13971d10453SEric Joyner 		} vlan;
14071d10453SEric Joyner 		/* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
14171d10453SEric Joyner 		 * if just using ethertype as filter. Set lkup_type as
14271d10453SEric Joyner 		 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
14371d10453SEric Joyner 		 * passed in as filter.
14471d10453SEric Joyner 		 */
14571d10453SEric Joyner 		struct {
14671d10453SEric Joyner 			u16 ethertype;
14771d10453SEric Joyner 			u8 mac_addr[ETH_ALEN]; /* optional */
14871d10453SEric Joyner 		} ethertype_mac;
14971d10453SEric Joyner 	} l_data; /* Make sure to zero out the memory of l_data before using
15071d10453SEric Joyner 		   * it or only set the data associated with lookup match
15171d10453SEric Joyner 		   * rest everything should be zero
15271d10453SEric Joyner 		   */
15371d10453SEric Joyner 
15471d10453SEric Joyner 	/* Depending on filter action */
15571d10453SEric Joyner 	union {
15671d10453SEric Joyner 		/* queue ID in case of ICE_FWD_TO_Q and starting
15771d10453SEric Joyner 		 * queue ID in case of ICE_FWD_TO_QGRP.
15871d10453SEric Joyner 		 */
15971d10453SEric Joyner 		u16 q_id:11;
16071d10453SEric Joyner 		u16 hw_vsi_id:10;
16171d10453SEric Joyner 		u16 vsi_list_id:10;
16271d10453SEric Joyner 	} fwd_id;
16371d10453SEric Joyner 
16471d10453SEric Joyner 	/* Sw VSI handle */
16571d10453SEric Joyner 	u16 vsi_handle;
16671d10453SEric Joyner 
16771d10453SEric Joyner 	/* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
16871d10453SEric Joyner 	 * determines the range of queues the packet needs to be forwarded to.
16971d10453SEric Joyner 	 * Note that qgrp_size must be set to a power of 2.
17071d10453SEric Joyner 	 */
17171d10453SEric Joyner 	u8 qgrp_size;
17271d10453SEric Joyner 
17371d10453SEric Joyner 	/* Rule creations populate these indicators basing on the switch type */
17471d10453SEric Joyner 	u8 lb_en;	/* Indicate if packet can be looped back */
17571d10453SEric Joyner 	u8 lan_en;	/* Indicate if packet can be forwarded to the uplink */
17671d10453SEric Joyner };
17771d10453SEric Joyner 
17871d10453SEric Joyner struct ice_adv_lkup_elem {
17971d10453SEric Joyner 	enum ice_protocol_type type;
18071d10453SEric Joyner 	union ice_prot_hdr h_u;	/* Header values */
18171d10453SEric Joyner 	union ice_prot_hdr m_u;	/* Mask of header values to match */
18271d10453SEric Joyner };
18371d10453SEric Joyner 
184*9c30461dSEric Joyner struct entry_vsi_fwd {
185*9c30461dSEric Joyner 	u16 vsi_list;
186*9c30461dSEric Joyner 	u8 list;
187*9c30461dSEric Joyner 	u8 valid;
188*9c30461dSEric Joyner };
189*9c30461dSEric Joyner 
190*9c30461dSEric Joyner struct entry_to_q {
191*9c30461dSEric Joyner 	u16 q_idx;
192*9c30461dSEric Joyner 	u8 q_region_sz;
193*9c30461dSEric Joyner 	u8 q_pri;
194*9c30461dSEric Joyner };
195*9c30461dSEric Joyner 
196*9c30461dSEric Joyner struct entry_prune {
197*9c30461dSEric Joyner 	u16 vsi_list;
198*9c30461dSEric Joyner 	u8 list;
199*9c30461dSEric Joyner 	u8 egr;
200*9c30461dSEric Joyner 	u8 ing;
201*9c30461dSEric Joyner 	u8 prune_t;
202*9c30461dSEric Joyner };
203*9c30461dSEric Joyner 
204*9c30461dSEric Joyner struct entry_mirror {
205*9c30461dSEric Joyner 	u16 mirror_vsi;
206*9c30461dSEric Joyner };
207*9c30461dSEric Joyner 
208*9c30461dSEric Joyner struct entry_generic_act {
209*9c30461dSEric Joyner 	u16 generic_value;
210*9c30461dSEric Joyner 	u8 offset;
211*9c30461dSEric Joyner 	u8 priority;
212*9c30461dSEric Joyner };
213*9c30461dSEric Joyner 
214*9c30461dSEric Joyner struct entry_statistics {
215*9c30461dSEric Joyner 	u8 counter_idx;
216*9c30461dSEric Joyner };
217*9c30461dSEric Joyner 
21871d10453SEric Joyner struct ice_sw_act_ctrl {
21971d10453SEric Joyner 	/* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
22071d10453SEric Joyner 	u16 src;
22171d10453SEric Joyner 	u16 flag;
22271d10453SEric Joyner 	enum ice_sw_fwd_act_type fltr_act;
22371d10453SEric Joyner 	/* Depending on filter action */
22471d10453SEric Joyner 	union {
22571d10453SEric Joyner 		/* This is a queue ID in case of ICE_FWD_TO_Q and starting
22671d10453SEric Joyner 		 * queue ID in case of ICE_FWD_TO_QGRP.
22771d10453SEric Joyner 		 */
22871d10453SEric Joyner 		u16 q_id:11;
22971d10453SEric Joyner 		u16 vsi_id:10;
23071d10453SEric Joyner 		u16 hw_vsi_id:10;
23171d10453SEric Joyner 		u16 vsi_list_id:10;
23271d10453SEric Joyner 	} fwd_id;
23371d10453SEric Joyner 	/* software VSI handle */
23471d10453SEric Joyner 	u16 vsi_handle;
23571d10453SEric Joyner 	u8 qgrp_size;
23671d10453SEric Joyner };
23771d10453SEric Joyner 
23871d10453SEric Joyner struct ice_rule_query_data {
23971d10453SEric Joyner 	/* Recipe ID for which the requested rule was added */
24071d10453SEric Joyner 	u16 rid;
24171d10453SEric Joyner 	/* Rule ID that was added or is supposed to be removed */
24271d10453SEric Joyner 	u16 rule_id;
24371d10453SEric Joyner 	/* vsi_handle for which Rule was added or is supposed to be removed */
24471d10453SEric Joyner 	u16 vsi_handle;
24571d10453SEric Joyner };
24671d10453SEric Joyner 
24756429daeSEric Joyner /*
24856429daeSEric Joyner  * This structure allows to pass info about lb_en and lan_en
24956429daeSEric Joyner  * flags to ice_add_adv_rule. Values in act would be used
25056429daeSEric Joyner  * only if act_valid was set to true, otherwise dflt
25156429daeSEric Joyner  * values would be used.
25256429daeSEric Joyner  */
25356429daeSEric Joyner struct ice_adv_rule_flags_info {
25456429daeSEric Joyner 	u32 act;
25556429daeSEric Joyner 	u8 act_valid;		/* indicate if flags in act are valid */
25656429daeSEric Joyner };
25756429daeSEric Joyner 
25871d10453SEric Joyner struct ice_adv_rule_info {
25971d10453SEric Joyner 	enum ice_sw_tunnel_type tun_type;
26071d10453SEric Joyner 	struct ice_sw_act_ctrl sw_act;
26171d10453SEric Joyner 	u32 priority;
26271d10453SEric Joyner 	u8 rx; /* true means LOOKUP_RX otherwise LOOKUP_TX */
2639dc2f6e2SEric Joyner 	u8 add_dir_lkup;
26471d10453SEric Joyner 	u16 fltr_rule_id;
2658923de59SPiotr Kubaj 	u16 lg_id;
2669dc2f6e2SEric Joyner 	u16 vlan_type;
26756429daeSEric Joyner 	struct ice_adv_rule_flags_info flags_info;
26871d10453SEric Joyner };
26971d10453SEric Joyner 
27071d10453SEric Joyner /* A collection of one or more four word recipe */
27171d10453SEric Joyner struct ice_sw_recipe {
27271d10453SEric Joyner 	/* For a chained recipe the root recipe is what should be used for
27371d10453SEric Joyner 	 * programming rules
27471d10453SEric Joyner 	 */
27571d10453SEric Joyner 	u8 is_root;
27671d10453SEric Joyner 	u8 root_rid;
27771d10453SEric Joyner 	u8 recp_created;
27871d10453SEric Joyner 
27971d10453SEric Joyner 	/* Number of extraction words */
28071d10453SEric Joyner 	u8 n_ext_words;
28171d10453SEric Joyner 	/* Protocol ID and Offset pair (extraction word) to describe the
28271d10453SEric Joyner 	 * recipe
28371d10453SEric Joyner 	 */
28471d10453SEric Joyner 	struct ice_fv_word ext_words[ICE_MAX_CHAIN_WORDS];
28571d10453SEric Joyner 	u16 word_masks[ICE_MAX_CHAIN_WORDS];
28671d10453SEric Joyner 
28771d10453SEric Joyner 	/* if this recipe is a collection of other recipe */
28871d10453SEric Joyner 	u8 big_recp;
28971d10453SEric Joyner 
29071d10453SEric Joyner 	/* if this recipe is part of another bigger recipe then chain index
29171d10453SEric Joyner 	 * corresponding to this recipe
29271d10453SEric Joyner 	 */
29371d10453SEric Joyner 	u8 chain_idx;
29471d10453SEric Joyner 
29571d10453SEric Joyner 	/* if this recipe is a collection of other recipe then count of other
29671d10453SEric Joyner 	 * recipes and recipe IDs of those recipes
29771d10453SEric Joyner 	 */
29871d10453SEric Joyner 	u8 n_grp_count;
29971d10453SEric Joyner 
30071d10453SEric Joyner 	/* Bit map specifying the IDs associated with this group of recipe */
30171d10453SEric Joyner 	ice_declare_bitmap(r_bitmap, ICE_MAX_NUM_RECIPES);
30271d10453SEric Joyner 
30371d10453SEric Joyner 	enum ice_sw_tunnel_type tun_type;
30471d10453SEric Joyner 
30571d10453SEric Joyner 	/* List of type ice_fltr_mgmt_list_entry or adv_rule */
30671d10453SEric Joyner 	u8 adv_rule;
30771d10453SEric Joyner 	struct LIST_HEAD_TYPE filt_rules;
30871d10453SEric Joyner 	struct LIST_HEAD_TYPE filt_replay_rules;
30971d10453SEric Joyner 
31071d10453SEric Joyner 	struct ice_lock filt_rule_lock;	/* protect filter rule structure */
31171d10453SEric Joyner 
31271d10453SEric Joyner 	/* Profiles this recipe should be associated with */
31371d10453SEric Joyner 	struct LIST_HEAD_TYPE fv_list;
31471d10453SEric Joyner 
31571d10453SEric Joyner 	/* Profiles this recipe is associated with */
31671d10453SEric Joyner 	u8 num_profs, *prof_ids;
31771d10453SEric Joyner 
3187d7af7f8SEric Joyner 	/* Bit map for possible result indexes */
31971d10453SEric Joyner 	ice_declare_bitmap(res_idxs, ICE_MAX_FV_WORDS);
32071d10453SEric Joyner 
32171d10453SEric Joyner 	/* This allows user to specify the recipe priority.
32271d10453SEric Joyner 	 * For now, this becomes 'fwd_priority' when recipe
32371d10453SEric Joyner 	 * is created, usually recipes can have 'fwd' and 'join'
32471d10453SEric Joyner 	 * priority.
32571d10453SEric Joyner 	 */
32671d10453SEric Joyner 	u8 priority;
32771d10453SEric Joyner 
32871d10453SEric Joyner 	struct LIST_HEAD_TYPE rg_list;
32971d10453SEric Joyner 
33071d10453SEric Joyner 	/* AQ buffer associated with this recipe */
33171d10453SEric Joyner 	struct ice_aqc_recipe_data_elem *root_buf;
33271d10453SEric Joyner 	/* This struct saves the fv_words for a given lookup */
33371d10453SEric Joyner 	struct ice_prot_lkup_ext lkup_exts;
33471d10453SEric Joyner };
33571d10453SEric Joyner 
33671d10453SEric Joyner /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list ID */
33771d10453SEric Joyner struct ice_vsi_list_map_info {
33871d10453SEric Joyner 	struct LIST_ENTRY_TYPE list_entry;
33971d10453SEric Joyner 	ice_declare_bitmap(vsi_map, ICE_MAX_VSI);
34071d10453SEric Joyner 	u16 vsi_list_id;
34171d10453SEric Joyner 	/* counter to track how many rules are reusing this VSI list */
34271d10453SEric Joyner 	u16 ref_cnt;
34371d10453SEric Joyner };
34471d10453SEric Joyner 
34571d10453SEric Joyner struct ice_fltr_list_entry {
34671d10453SEric Joyner 	struct LIST_ENTRY_TYPE list_entry;
34771d10453SEric Joyner 	enum ice_status status;
34871d10453SEric Joyner 	struct ice_fltr_info fltr_info;
34971d10453SEric Joyner };
35071d10453SEric Joyner 
35171d10453SEric Joyner /**
35271d10453SEric Joyner  * enum ice_fltr_marker - Marker for syncing OS and driver filter lists
35371d10453SEric Joyner  * @ICE_FLTR_NOT_FOUND: initial state, indicates filter has not been found
35471d10453SEric Joyner  * @ICE_FLTR_FOUND: set when a filter has been found in both lists
35571d10453SEric Joyner  *
35671d10453SEric Joyner  * This enumeration is used to help sync an operating system provided filter
35771d10453SEric Joyner  * list with the filters previously added.
35871d10453SEric Joyner  *
35971d10453SEric Joyner  * This is required for FreeBSD because the operating system does not provide
36071d10453SEric Joyner  * individual indications of whether a filter has been added or deleted, but
36171d10453SEric Joyner  * instead just notifies the driver with the entire new list.
36271d10453SEric Joyner  *
36371d10453SEric Joyner  * To use this marker state, the driver shall initially reset all filters to
36471d10453SEric Joyner  * the ICE_FLTR_NOT_FOUND state. Then, for each filter in the OS list, it
36571d10453SEric Joyner  * shall search the driver list for the filter. If found, the filter state
36671d10453SEric Joyner  * will be set to ICE_FLTR_FOUND. If not found, that filter will be added.
36771d10453SEric Joyner  * Finally, the driver shall search the internal filter list for all filters
36871d10453SEric Joyner  * still marked as ICE_FLTR_NOT_FOUND and remove them.
36971d10453SEric Joyner  */
37071d10453SEric Joyner enum ice_fltr_marker {
37171d10453SEric Joyner 	ICE_FLTR_NOT_FOUND,
37271d10453SEric Joyner 	ICE_FLTR_FOUND,
37371d10453SEric Joyner };
37471d10453SEric Joyner 
37571d10453SEric Joyner /* This defines an entry in the list that maintains MAC or VLAN membership
37671d10453SEric Joyner  * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
37771d10453SEric Joyner  * VLAN. As an optimization the VSI list should be created only when a
37871d10453SEric Joyner  * second VSI becomes a subscriber to the same MAC address. VSI lists are always
37971d10453SEric Joyner  * used for VLAN membership.
38071d10453SEric Joyner  */
38171d10453SEric Joyner struct ice_fltr_mgmt_list_entry {
38271d10453SEric Joyner 	/* back pointer to VSI list ID to VSI list mapping */
38371d10453SEric Joyner 	struct ice_vsi_list_map_info *vsi_list_info;
38471d10453SEric Joyner 	u16 vsi_count;
38571d10453SEric Joyner #define ICE_INVAL_LG_ACT_INDEX 0xffff
38671d10453SEric Joyner 	u16 lg_act_idx;
38771d10453SEric Joyner #define ICE_INVAL_SW_MARKER_ID 0xffff
38871d10453SEric Joyner 	u16 sw_marker_id;
38971d10453SEric Joyner 	struct LIST_ENTRY_TYPE list_entry;
39071d10453SEric Joyner 	struct ice_fltr_info fltr_info;
39171d10453SEric Joyner #define ICE_INVAL_COUNTER_ID 0xff
39271d10453SEric Joyner 	u8 counter_index;
39371d10453SEric Joyner 	enum ice_fltr_marker marker;
39471d10453SEric Joyner };
39571d10453SEric Joyner 
39671d10453SEric Joyner struct ice_adv_fltr_mgmt_list_entry {
39771d10453SEric Joyner 	struct LIST_ENTRY_TYPE list_entry;
39871d10453SEric Joyner 
39971d10453SEric Joyner 	struct ice_adv_lkup_elem *lkups;
40071d10453SEric Joyner 	struct ice_adv_rule_info rule_info;
40171d10453SEric Joyner 	u16 lkups_cnt;
40271d10453SEric Joyner 	struct ice_vsi_list_map_info *vsi_list_info;
40371d10453SEric Joyner 	u16 vsi_count;
40471d10453SEric Joyner };
40571d10453SEric Joyner 
40671d10453SEric Joyner enum ice_promisc_flags {
407*9c30461dSEric Joyner 	ICE_PROMISC_UCAST_RX = 0,
408*9c30461dSEric Joyner 	ICE_PROMISC_UCAST_TX,
409*9c30461dSEric Joyner 	ICE_PROMISC_MCAST_RX,
410*9c30461dSEric Joyner 	ICE_PROMISC_MCAST_TX,
411*9c30461dSEric Joyner 	ICE_PROMISC_BCAST_RX,
412*9c30461dSEric Joyner 	ICE_PROMISC_BCAST_TX,
413*9c30461dSEric Joyner 	ICE_PROMISC_VLAN_RX,
414*9c30461dSEric Joyner 	ICE_PROMISC_VLAN_TX,
415*9c30461dSEric Joyner 	/* Max value */
416*9c30461dSEric Joyner 	ICE_PROMISC_MAX,
41771d10453SEric Joyner };
41871d10453SEric Joyner 
4198923de59SPiotr Kubaj struct ice_dummy_pkt_offsets {
4208923de59SPiotr Kubaj 	enum ice_protocol_type type;
4218923de59SPiotr Kubaj 	u16 offset; /* ICE_PROTOCOL_LAST indicates end of list */
4228923de59SPiotr Kubaj };
4238923de59SPiotr Kubaj 
4248923de59SPiotr Kubaj void
4258923de59SPiotr Kubaj ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
4268923de59SPiotr Kubaj 		      enum ice_sw_tunnel_type tun_type, const u8 **pkt,
4278923de59SPiotr Kubaj 		      u16 *pkt_len,
4288923de59SPiotr Kubaj 		      const struct ice_dummy_pkt_offsets **offsets);
4298923de59SPiotr Kubaj 
4308923de59SPiotr Kubaj enum ice_status
4318923de59SPiotr Kubaj ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
432*9c30461dSEric Joyner 			  struct ice_sw_rule_lkup_rx_tx *s_rule,
4338923de59SPiotr Kubaj 			  const u8 *dummy_pkt, u16 pkt_len,
4348923de59SPiotr Kubaj 			  const struct ice_dummy_pkt_offsets *offsets);
4358923de59SPiotr Kubaj 
4368923de59SPiotr Kubaj enum ice_status
4378923de59SPiotr Kubaj ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
4388923de59SPiotr Kubaj 		   u16 lkups_cnt, struct ice_adv_rule_info *rinfo, u16 *rid);
4398923de59SPiotr Kubaj 
4408923de59SPiotr Kubaj struct ice_adv_fltr_mgmt_list_entry *
4418923de59SPiotr Kubaj ice_find_adv_rule_entry(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
4428923de59SPiotr Kubaj 			u16 lkups_cnt, u16 recp_id,
4438923de59SPiotr Kubaj 			struct ice_adv_rule_info *rinfo);
4448923de59SPiotr Kubaj 
4458923de59SPiotr Kubaj enum ice_status
4468923de59SPiotr Kubaj ice_adv_add_update_vsi_list(struct ice_hw *hw,
4478923de59SPiotr Kubaj 			    struct ice_adv_fltr_mgmt_list_entry *m_entry,
4488923de59SPiotr Kubaj 			    struct ice_adv_rule_info *cur_fltr,
4498923de59SPiotr Kubaj 			    struct ice_adv_rule_info *new_fltr);
4508923de59SPiotr Kubaj 
4518923de59SPiotr Kubaj struct ice_vsi_list_map_info *
4528923de59SPiotr Kubaj ice_find_vsi_list_entry(struct ice_sw_recipe *recp_list, u16 vsi_handle,
4538923de59SPiotr Kubaj 			u16 *vsi_list_id);
4548923de59SPiotr Kubaj 
45571d10453SEric Joyner /* VSI related commands */
45671d10453SEric Joyner enum ice_status
45771d10453SEric Joyner ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
45871d10453SEric Joyner 	       struct ice_sq_cd *cd);
45971d10453SEric Joyner enum ice_status
46071d10453SEric Joyner ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
46171d10453SEric Joyner 		bool keep_vsi_alloc, struct ice_sq_cd *cd);
46271d10453SEric Joyner enum ice_status
46371d10453SEric Joyner ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
46471d10453SEric Joyner 		  struct ice_sq_cd *cd);
46571d10453SEric Joyner enum ice_status
46671d10453SEric Joyner ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
46771d10453SEric Joyner 	    struct ice_sq_cd *cd);
46871d10453SEric Joyner enum ice_status
46971d10453SEric Joyner ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
47071d10453SEric Joyner 	     bool keep_vsi_alloc, struct ice_sq_cd *cd);
47171d10453SEric Joyner enum ice_status
47271d10453SEric Joyner ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
47371d10453SEric Joyner 	       struct ice_sq_cd *cd);
47471d10453SEric Joyner struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
47571d10453SEric Joyner void ice_clear_all_vsi_ctx(struct ice_hw *hw);
47671d10453SEric Joyner enum ice_status
47771d10453SEric Joyner ice_aq_get_vsi_params(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
47871d10453SEric Joyner 		      struct ice_sq_cd *cd);
47971d10453SEric Joyner enum ice_status
48071d10453SEric Joyner ice_aq_add_update_mir_rule(struct ice_hw *hw, u16 rule_type, u16 dest_vsi,
48171d10453SEric Joyner 			   u16 count, struct ice_mir_rule_buf *mr_buf,
48271d10453SEric Joyner 			   struct ice_sq_cd *cd, u16 *rule_id);
48371d10453SEric Joyner enum ice_status
48471d10453SEric Joyner ice_aq_delete_mir_rule(struct ice_hw *hw, u16 rule_id, bool keep_allocd,
48571d10453SEric Joyner 		       struct ice_sq_cd *cd);
48671d10453SEric Joyner enum ice_status
48771d10453SEric Joyner ice_aq_get_storm_ctrl(struct ice_hw *hw, u32 *bcast_thresh, u32 *mcast_thresh,
48871d10453SEric Joyner 		      u32 *ctl_bitmask);
48971d10453SEric Joyner enum ice_status
49071d10453SEric Joyner ice_aq_set_storm_ctrl(struct ice_hw *hw, u32 bcast_thresh, u32 mcast_thresh,
49171d10453SEric Joyner 		      u32 ctl_bitmask);
49271d10453SEric Joyner /* Switch config */
49371d10453SEric Joyner enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
49471d10453SEric Joyner 
49571d10453SEric Joyner enum ice_status
49671d10453SEric Joyner ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id);
49771d10453SEric Joyner enum ice_status
49871d10453SEric Joyner ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
49971d10453SEric Joyner 
50071d10453SEric Joyner enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
501d08b8680SEric Joyner enum ice_status ice_alloc_rss_global_lut(struct ice_hw *hw, bool shared_res, u16 *global_lut_id);
502d08b8680SEric Joyner enum ice_status ice_free_rss_global_lut(struct ice_hw *hw, u16 global_lut_id);
50371d10453SEric Joyner enum ice_status
50471d10453SEric Joyner ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
50571d10453SEric Joyner 	     u16 *counter_id);
50671d10453SEric Joyner enum ice_status
50771d10453SEric Joyner ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
50871d10453SEric Joyner enum ice_status
5097d7af7f8SEric Joyner ice_aq_get_res_alloc(struct ice_hw *hw, u16 *num_entries,
5107d7af7f8SEric Joyner 		     struct ice_aqc_get_res_resp_elem *buf, u16 buf_size,
5117d7af7f8SEric Joyner 		     struct ice_sq_cd *cd);
51271d10453SEric Joyner enum ice_status
51371d10453SEric Joyner ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
5147d7af7f8SEric Joyner 		     struct ice_aqc_res_elem *buf, u16 buf_size, u16 res_type,
5157d7af7f8SEric Joyner 		     bool res_shared, u16 *desc_id, struct ice_sq_cd *cd);
51671d10453SEric Joyner enum ice_status
51771d10453SEric Joyner ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
5189dc2f6e2SEric Joyner enum ice_status ice_remove_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
51971d10453SEric Joyner void ice_rem_all_sw_rules_info(struct ice_hw *hw);
52071d10453SEric Joyner enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
52171d10453SEric Joyner enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
52271d10453SEric Joyner enum ice_status
52371d10453SEric Joyner ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
52471d10453SEric Joyner enum ice_status
52571d10453SEric Joyner ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
5268a13362dSEric Joyner enum ice_status
5278a13362dSEric Joyner ice_cfg_iwarp_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable);
52871d10453SEric Joyner 
52971d10453SEric Joyner enum ice_status
53071d10453SEric Joyner ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,
53171d10453SEric Joyner 			   u16 sw_marker);
53271d10453SEric Joyner enum ice_status
53371d10453SEric Joyner ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info);
53471d10453SEric Joyner void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
53571d10453SEric Joyner 
53671d10453SEric Joyner /* Promisc/defport setup for VSIs */
53771d10453SEric Joyner enum ice_status
53871d10453SEric Joyner ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
53971d10453SEric Joyner 		 u8 direction);
5408923de59SPiotr Kubaj bool ice_check_if_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle,
5418923de59SPiotr Kubaj 			   bool *rule_exists);
54271d10453SEric Joyner enum ice_status
543*9c30461dSEric Joyner ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle,
544*9c30461dSEric Joyner 		    ice_bitmap_t *promisc_mask, u16 vid);
54571d10453SEric Joyner enum ice_status
546*9c30461dSEric Joyner ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle,
547*9c30461dSEric Joyner 		      ice_bitmap_t *promisc_mask, u16 vid);
54871d10453SEric Joyner enum ice_status
549*9c30461dSEric Joyner ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle,
550*9c30461dSEric Joyner 			 ice_bitmap_t *promisc_mask, bool rm_vlan_promisc);
55171d10453SEric Joyner 
55271d10453SEric Joyner /* Get VSIs Promisc/defport settings */
55371d10453SEric Joyner enum ice_status
554*9c30461dSEric Joyner ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle,
555*9c30461dSEric Joyner 		    ice_bitmap_t *promisc_mask, u16 *vid);
55671d10453SEric Joyner enum ice_status
557*9c30461dSEric Joyner ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle,
558*9c30461dSEric Joyner 			 ice_bitmap_t *promisc_mask, u16 *vid);
55971d10453SEric Joyner 
56071d10453SEric Joyner enum ice_status ice_replay_all_fltr(struct ice_hw *hw);
56171d10453SEric Joyner 
56271d10453SEric Joyner enum ice_status
56371d10453SEric Joyner ice_init_def_sw_recp(struct ice_hw *hw, struct ice_sw_recipe **recp_list);
56471d10453SEric Joyner u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
56571d10453SEric Joyner bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
56671d10453SEric Joyner 
5677d7af7f8SEric Joyner enum ice_status
5687d7af7f8SEric Joyner ice_replay_vsi_all_fltr(struct ice_hw *hw, struct ice_port_info *pi,
5697d7af7f8SEric Joyner 			u16 vsi_handle);
5707d7af7f8SEric Joyner void ice_rm_sw_replay_rule_info(struct ice_hw *hw, struct ice_switch_info *sw);
57171d10453SEric Joyner void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
5728923de59SPiotr Kubaj enum ice_status
5738923de59SPiotr Kubaj ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
5748923de59SPiotr Kubaj 		u8 num_rules, enum ice_adminq_opc opc, struct ice_sq_cd *cd);
57571d10453SEric Joyner #endif /* _ICE_SWITCH_H_ */
576