xref: /dpdk/drivers/net/bnx2x/bnx2x_vfpf.h (revision 7be78d027918dbc846e502780faf94d5acdf5f75)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
3  * Copyright (c) 2015-2018 Cavium Inc.
4  * All rights reserved.
5  * www.cavium.com
6  */
7 
8 #ifndef BNX2X_VFPF_H
9 #define BNX2X_VFPF_H
10 
11 #include "ecore_sp.h"
12 
13 struct vf_resource_query {
14 	uint8_t num_rxqs;
15 	uint8_t num_txqs;
16 	uint8_t num_sbs;
17 	uint8_t num_mac_filters;
18 	uint8_t num_vlan_filters;
19 	uint8_t num_mc_filters;
20 };
21 
22 #define	BNX2X_VF_STATUS_SUCCESS         1
23 #define	BNX2X_VF_STATUS_FAILURE         2
24 #define	BNX2X_VF_STATUS_NO_RESOURCES    4
25 #define	BNX2X_VF_BULLETIN_TRIES         5
26 
27 #define	BNX2X_VF_Q_FLAG_CACHE_ALIGN     0x0008
28 #define	BNX2X_VF_Q_FLAG_STATS           0x0010
29 #define	BNX2X_VF_Q_FLAG_OV              0x0020
30 #define	BNX2X_VF_Q_FLAG_VLAN            0x0040
31 #define	BNX2X_VF_Q_FLAG_COS             0x0080
32 #define	BNX2X_VF_Q_FLAG_HC              0x0100
33 #define	BNX2X_VF_Q_FLAG_DHC             0x0200
34 #define	BNX2X_VF_Q_FLAG_LEADING_RSS     0x0400
35 
36 #define TLV_BUFFER_SIZE			1024
37 
38 #define VFPF_RX_MASK_ACCEPT_NONE		0x00000000
39 #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST	0x00000001
40 #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST	0x00000002
41 #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST		0x00000004
42 #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST	0x00000008
43 #define VFPF_RX_MASK_ACCEPT_BROADCAST		0x00000010
44 
45 /* general tlv header (used for both vf->pf request and pf->vf response) */
46 struct channel_tlv {
47 	uint16_t type;
48 	uint16_t length;
49 };
50 
51 struct vf_first_tlv {
52 	struct channel_tlv tl;
53 	uint32_t reply_offset;
54 };
55 
56 struct tlv_buffer_size {
57 	uint8_t tlv_buffer[TLV_BUFFER_SIZE];
58 };
59 
60 /* tlv struct for all PF replies except acquire */
61 struct vf_common_reply_tlv {
62 	struct channel_tlv tl;
63 	uint8_t status;
64 	uint8_t pad[3];
65 };
66 
67 /* used to terminate and pad a tlv list */
68 struct channel_list_end_tlv {
69 	struct channel_tlv tl;
70 	uint32_t pad;
71 };
72 
73 /* Acquire */
74 struct vf_acquire_tlv {
75 	struct vf_first_tlv first_tlv;
76 
77 	uint8_t vf_id;
78 	uint8_t pad[3];
79 
80 	struct vf_resource_query res_query;
81 
82 	uint64_t bulletin_addr;
83 };
84 
85 /* simple operation request on queue */
86 struct vf_q_op_tlv {
87 	struct vf_first_tlv	first_tlv;
88 	uint8_t vf_qid;
89 	uint8_t pad[3];
90 };
91 
92 /* receive side scaling tlv */
93 struct vf_rss_tlv {
94 	struct vf_first_tlv	first_tlv;
95 	uint32_t		rss_flags;
96 	uint8_t			rss_result_mask;
97 	uint8_t			ind_table_size;
98 	uint8_t			rss_key_size;
99 	uint8_t			pad;
100 	uint8_t			ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
101 	uint32_t		rss_key[T_ETH_RSS_KEY];	/* hash values */
102 };
103 
104 struct vf_resc {
105 #define BNX2X_VF_MAX_QUEUES_PER_VF         16
106 #define BNX2X_VF_MAX_SBS_PER_VF            16
107 	uint16_t hw_sbs[BNX2X_VF_MAX_SBS_PER_VF];
108 	uint8_t hw_qid[BNX2X_VF_MAX_QUEUES_PER_VF];
109 	uint8_t num_rxqs;
110 	uint8_t num_txqs;
111 	uint8_t num_sbs;
112 	uint8_t num_mac_filters;
113 	uint8_t num_vlan_filters;
114 	uint8_t num_mc_filters;
115 	uint8_t permanent_mac_addr[ETH_ALEN];
116 	struct rte_ether_addr current_mac_addr;
117 	uint16_t pf_link_speed;
118 	uint32_t pf_link_supported;
119 };
120 
121 /* tlv struct holding reply for acquire */
122 struct vf_acquire_resp_tlv {
123 	uint16_t type;
124 	uint16_t length;
125 	uint8_t status;
126 	uint8_t pad1[3];
127 	uint32_t chip_num;
128 	uint8_t pad2[4];
129 	char fw_ver[32];
130 	uint16_t db_size;
131 	uint8_t pad3[2];
132 	struct vf_resc resc;
133 };
134 
135 /* Init VF */
136 struct vf_init_tlv {
137 	struct vf_first_tlv first_tlv;
138 	uint64_t sb_addr[BNX2X_VF_MAX_SBS_PER_VF];
139 	uint64_t spq_addr;
140 	uint64_t stats_addr;
141 	uint16_t stats_step;
142 	uint32_t flags;
143 	uint32_t pad[2];
144 };
145 
146 struct vf_rxq_params {
147 	/* physical addresses */
148 	uint64_t rcq_addr;
149 	uint64_t rcq_np_addr;
150 	uint64_t rxq_addr;
151 	uint64_t pad1;
152 
153 	/* sb + hc info */
154 	uint8_t  vf_sb_id;
155 	uint8_t  sb_cq_index;
156 	uint16_t hc_rate;	/* desired interrupts per sec. */
157 	/* rx buffer info */
158 	uint16_t mtu;
159 	uint16_t buf_sz;
160 	uint16_t flags;         /* for BNX2X_VF_Q_FLAG_X flags */
161 	uint16_t stat_id;	/* valid if BNX2X_VF_Q_FLAG_STATS */
162 
163 	uint8_t pad2[5];
164 
165 	uint8_t drop_flags;
166 	uint8_t cache_line_log;	/* BNX2X_VF_Q_FLAG_CACHE_ALIGN */
167 	uint8_t pad3;
168 };
169 
170 struct vf_txq_params {
171 	/* physical addresses */
172 	uint64_t txq_addr;
173 
174 	/* sb + hc info */
175 	uint8_t  vf_sb_id;	/* index in hw_sbs[] */
176 	uint8_t  sb_index;	/* Index in the SB */
177 	uint16_t hc_rate;	/* desired interrupts per sec. */
178 	uint32_t flags;		/* for BNX2X_VF_Q_FLAG_X flags */
179 	uint16_t stat_id;	/* valid if BNX2X_VF_Q_FLAG_STATS */
180 	uint8_t  traffic_type;	/* see in setup_context() */
181 	uint8_t  pad;
182 };
183 
184 /* Setup Queue */
185 struct vf_setup_q_tlv {
186 	struct vf_first_tlv first_tlv;
187 
188 	struct vf_rxq_params rxq;
189 	struct vf_txq_params txq;
190 
191 	uint8_t vf_qid;			/* index in hw_qid[] */
192 	uint8_t param_valid;
193 	#define VF_RXQ_VALID		0x01
194 	#define VF_TXQ_VALID		0x02
195 	uint8_t pad[2];
196 };
197 
198 /* Set Queue Filters */
199 struct vf_q_mac_vlan_filter {
200 	uint32_t flags;
201 	#define BNX2X_VF_Q_FILTER_DEST_MAC_VALID	0x01
202 	#define BNX2X_VF_Q_FILTER_VLAN_TAG_VALID	0x02
203 	#define BNX2X_VF_Q_FILTER_SET_MAC		0x100	/* set/clear */
204 	uint8_t  mac[ETH_ALEN];
205 	uint16_t vlan_tag;
206 };
207 
208 
209 #define _UP_ETH_ALEN	(6)
210 
211 /* configure queue filters */
212 struct vf_set_q_filters_tlv {
213 	struct vf_first_tlv first_tlv;
214 
215 	uint32_t flags;
216 	#define BNX2X_VF_MAC_VLAN_CHANGED 	0x01
217 	#define BNX2X_VF_MULTICAST_CHANGED	0x02
218 	#define BNX2X_VF_RX_MASK_CHANGED  	0x04
219 
220 	uint8_t vf_qid;			/* index in hw_qid[] */
221 	uint8_t mac_filters_cnt;
222 	uint8_t multicast_cnt;
223 	uint8_t pad;
224 
225 	#define VF_MAX_MAC_FILTERS			16
226 	#define VF_MAX_VLAN_FILTERS       		16
227 	#define VF_MAX_FILTERS 			(VF_MAX_MAC_FILTERS +\
228 							VF_MAX_VLAN_FILTERS)
229 	struct vf_q_mac_vlan_filter filters[VF_MAX_FILTERS];
230 
231 	#define VF_MAX_MULTICAST_PER_VF   		32
232 	uint8_t  multicast[VF_MAX_MULTICAST_PER_VF][_UP_ETH_ALEN];
233 	unsigned long rx_mask;
234 };
235 
236 
237 /* close VF (disable VF) */
238 struct vf_close_tlv {
239 	struct vf_first_tlv	first_tlv;
240 	uint16_t		vf_id;  /* for debug */
241 	uint8_t pad[2];
242 };
243 
244 /* release the VF's acquired resources */
245 struct vf_release_tlv {
246 	struct vf_first_tlv   first_tlv;
247 	uint16_t		vf_id;  /* for debug */
248 	uint8_t pad[2];
249 };
250 
251 union query_tlvs {
252 	struct vf_first_tlv		first_tlv;
253 	struct vf_acquire_tlv		acquire;
254 	struct vf_init_tlv		init;
255 	struct vf_close_tlv		close;
256 	struct vf_q_op_tlv		q_op;
257 	struct vf_setup_q_tlv		setup_q;
258 	struct vf_set_q_filters_tlv	set_q_filters;
259 	struct vf_release_tlv		release;
260 	struct vf_rss_tlv		update_rss;
261 	struct channel_list_end_tlv     list_end;
262 	struct tlv_buffer_size		tlv_buf_size;
263 };
264 
265 union resp_tlvs {
266 	struct vf_common_reply_tlv	common_reply;
267 	struct vf_acquire_resp_tlv	acquire_resp;
268 	struct channel_list_end_tlv	list_end;
269 	struct tlv_buffer_size		tlv_buf_size;
270 };
271 
272 /* struct allocated by VF driver, PF sends updates to VF via bulletin */
273 struct bnx2x_vf_bulletin {
274 	uint32_t crc;			/* crc of structure to ensure is not in
275 					 * mid-update
276 					 */
277 	uint16_t version;
278 	uint16_t length;
279 
280 	uint64_t valid_bitmap;	/* bitmap indicating which fields
281 					 * hold valid values
282 					 */
283 
284 #define MAC_ADDR_VALID		0	/* alert the vf that a new mac address
285 					 * is available for it
286 					 */
287 #define VLAN_VALID		1	/* when set, the vf should no access the
288 					 * vf channel
289 					 */
290 #define CHANNEL_DOWN		2	/* vf channel is disabled. VFs are not
291 					 * to attempt to send messages on the
292 					 * channel after this bit is set
293 					 */
294 	uint8_t mac[ETH_ALEN];
295 	uint8_t mac_pad[2];
296 
297 	uint16_t vlan;
298 	uint8_t vlan_pad[6];
299 };
300 
301 #define MAX_TLVS_IN_LIST 50
302 enum channel_tlvs {
303 	BNX2X_VF_TLV_NONE, /* ends tlv sequence */
304 	BNX2X_VF_TLV_ACQUIRE,
305 	BNX2X_VF_TLV_INIT,
306 	BNX2X_VF_TLV_SETUP_Q,
307 	BNX2X_VF_TLV_SET_Q_FILTERS,
308 	BNX2X_VF_TLV_ACTIVATE_Q,
309 	BNX2X_VF_TLV_DEACTIVATE_Q,
310 	BNX2X_VF_TLV_TEARDOWN_Q,
311 	BNX2X_VF_TLV_CLOSE,
312 	BNX2X_VF_TLV_RELEASE,
313 	BNX2X_VF_TLV_UPDATE_RSS_OLD,
314 	BNX2X_VF_TLV_PF_RELEASE_VF,
315 	BNX2X_VF_TLV_LIST_END,
316 	BNX2X_VF_TLV_FLR,
317 	BNX2X_VF_TLV_PF_SET_MAC,
318 	BNX2X_VF_TLV_PF_SET_VLAN,
319 	BNX2X_VF_TLV_UPDATE_RSS,
320 	BNX2X_VF_TLV_PHYS_PORT_ID,
321 	BNX2X_VF_TLV_MAX
322 };
323 
324 struct bnx2x_vf_mbx_msg {
325 	union query_tlvs query[BNX2X_VF_MAX_QUEUES_PER_VF];
326 	union resp_tlvs resp;
327 };
328 
329 int bnx2x_vf_teardown_queue(struct bnx2x_softc *sc, int qid);
330 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
331 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
332 int bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
333 			struct rte_ether_addr *mc_addrs,
334 			uint32_t mc_addrs_num);
335 
336 #endif /* BNX2X_VFPF_H */
337