1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018, Intel Corporation. */
7 #include "ice_common.h"
9 #define ICE_SW_CFG_MAX_BUF_LEN 2048
10 #define ICE_DFLT_VSI_INVAL 0xff
11 #define ICE_VSI_INVAL_ID 0xffff
13 /* VSI context structure for add/get/update/free operations */
19 struct ice_aqc_vsi_props info
;
23 enum ice_sw_fwd_act_type
{
25 ICE_FWD_TO_VSI_LIST
, /* Do not use this when adding filter */
32 /* Switch recipe ID enum values are specific to hardware */
33 enum ice_sw_lkup_type
{
34 ICE_SW_LKUP_ETHERTYPE
= 0,
36 ICE_SW_LKUP_MAC_VLAN
= 2,
37 ICE_SW_LKUP_PROMISC
= 3,
40 ICE_SW_LKUP_ETHERTYPE_MAC
= 8,
41 ICE_SW_LKUP_PROMISC_VLAN
= 9,
44 struct ice_fltr_info
{
45 /* Look up information: how to look up packet */
46 enum ice_sw_lkup_type lkup_type
;
47 /* Forward action: filter action to do after lookup */
48 enum ice_sw_fwd_act_type fltr_act
;
49 /* rule ID returned by firmware once filter rule is created */
52 #define ICE_FLTR_RX BIT(0)
53 #define ICE_FLTR_TX BIT(1)
54 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
56 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
61 u8 mac_addr
[ETH_ALEN
];
64 u8 mac_addr
[ETH_ALEN
];
70 /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
71 * if just using ethertype as filter. Set lkup_type as
72 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
73 * passed in as filter.
77 u8 mac_addr
[ETH_ALEN
]; /* optional */
81 /* Depending on filter action */
83 /* queue id in case of ICE_FWD_TO_Q and starting
84 * queue id in case of ICE_FWD_TO_QGRP.
91 /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
92 * determines the range of queues the packet needs to be forwarded to
96 /* Rule creations populate these indicators basing on the switch type */
97 u8 lb_en
; /* Indicate if packet can be looped back */
98 u8 lan_en
; /* Indicate if packet can be forwarded to the uplink */
101 /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
102 struct ice_vsi_list_map_info
{
103 struct list_head list_entry
;
104 DECLARE_BITMAP(vsi_map
, ICE_MAX_VSI
);
108 enum ice_sw_fltr_status
{
109 ICE_FLTR_STATUS_NEW
= 0,
110 ICE_FLTR_STATUS_FW_SUCCESS
,
111 ICE_FLTR_STATUS_FW_FAIL
,
114 struct ice_fltr_list_entry
{
115 struct list_head list_entry
;
116 enum ice_sw_fltr_status status
;
117 struct ice_fltr_info fltr_info
;
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 VLAN address.
125 struct ice_fltr_mgmt_list_entry
{
126 /* back pointer to VSI list id to VSI list mapping */
127 struct ice_vsi_list_map_info
*vsi_list_info
;
129 #define ICE_INVAL_LG_ACT_INDEX 0xffff
131 #define ICE_INVAL_SW_MARKER_ID 0xffff
133 struct list_head list_entry
;
134 struct ice_fltr_info fltr_info
;
135 #define ICE_INVAL_COUNTER_ID 0xff
139 /* VSI related commands */
141 ice_aq_add_vsi(struct ice_hw
*hw
, struct ice_vsi_ctx
*vsi_ctx
,
142 struct ice_sq_cd
*cd
);
144 ice_aq_update_vsi(struct ice_hw
*hw
, struct ice_vsi_ctx
*vsi_ctx
,
145 struct ice_sq_cd
*cd
);
147 ice_aq_free_vsi(struct ice_hw
*hw
, struct ice_vsi_ctx
*vsi_ctx
,
148 bool keep_vsi_alloc
, struct ice_sq_cd
*cd
);
150 enum ice_status
ice_get_initial_sw_cfg(struct ice_hw
*hw
);
152 /* Switch/bridge related commands */
153 enum ice_status
ice_add_mac(struct ice_hw
*hw
, struct list_head
*m_lst
);
154 enum ice_status
ice_remove_mac(struct ice_hw
*hw
, struct list_head
*m_lst
);
155 void ice_remove_vsi_fltr(struct ice_hw
*hw
, u16 vsi_id
);
156 enum ice_status
ice_add_vlan(struct ice_hw
*hw
, struct list_head
*m_list
);
157 enum ice_status
ice_remove_vlan(struct ice_hw
*hw
, struct list_head
*v_list
);
159 ice_cfg_dflt_vsi(struct ice_hw
*hw
, u16 vsi_id
, bool set
, u8 direction
);
161 #endif /* _ICE_SWITCH_H_ */