1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015-2017  QLogic Corporation
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and /or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef _QED_VF_H
34 #define _QED_VF_H
35 
36 #include "qed_l2.h"
37 #include "qed_mcp.h"
38 
39 #define T_ETH_INDIRECTION_TABLE_SIZE 128
40 #define T_ETH_RSS_KEY_SIZE 10
41 
42 struct vf_pf_resc_request {
43 	u8 num_rxqs;
44 	u8 num_txqs;
45 	u8 num_sbs;
46 	u8 num_mac_filters;
47 	u8 num_vlan_filters;
48 	u8 num_mc_filters;
49 	u8 num_cids;
50 	u8 padding;
51 };
52 
53 struct hw_sb_info {
54 	u16 hw_sb_id;
55 	u8 sb_qid;
56 	u8 padding[5];
57 };
58 
59 #define TLV_BUFFER_SIZE                 1024
60 
61 enum {
62 	PFVF_STATUS_WAITING,
63 	PFVF_STATUS_SUCCESS,
64 	PFVF_STATUS_FAILURE,
65 	PFVF_STATUS_NOT_SUPPORTED,
66 	PFVF_STATUS_NO_RESOURCE,
67 	PFVF_STATUS_FORCED,
68 	PFVF_STATUS_MALICIOUS,
69 };
70 
71 /* vf pf channel tlvs */
72 /* general tlv header (used for both vf->pf request and pf->vf response) */
73 struct channel_tlv {
74 	u16 type;
75 	u16 length;
76 };
77 
78 /* header of first vf->pf tlv carries the offset used to calculate reponse
79  * buffer address
80  */
81 struct vfpf_first_tlv {
82 	struct channel_tlv tl;
83 	u32 padding;
84 	u64 reply_address;
85 };
86 
87 /* header of pf->vf tlvs, carries the status of handling the request */
88 struct pfvf_tlv {
89 	struct channel_tlv tl;
90 	u8 status;
91 	u8 padding[3];
92 };
93 
94 /* response tlv used for most tlvs */
95 struct pfvf_def_resp_tlv {
96 	struct pfvf_tlv hdr;
97 };
98 
99 /* used to terminate and pad a tlv list */
100 struct channel_list_end_tlv {
101 	struct channel_tlv tl;
102 	u8 padding[4];
103 };
104 
105 #define VFPF_ACQUIRE_OS_LINUX (0)
106 #define VFPF_ACQUIRE_OS_WINDOWS (1)
107 #define VFPF_ACQUIRE_OS_ESX (2)
108 #define VFPF_ACQUIRE_OS_SOLARIS (3)
109 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
110 
111 struct vfpf_acquire_tlv {
112 	struct vfpf_first_tlv first_tlv;
113 
114 	struct vf_pf_vfdev_info {
115 #define VFPF_ACQUIRE_CAP_PRE_FP_HSI     (1 << 0) /* VF pre-FP hsi version */
116 #define VFPF_ACQUIRE_CAP_100G		(1 << 1) /* VF can support 100g */
117 	/* A requirement for supporting multi-Tx queues on a single queue-zone,
118 	 * VF would pass qids as additional information whenever passing queue
119 	 * references.
120 	 */
121 #define VFPF_ACQUIRE_CAP_QUEUE_QIDS     BIT(2)
122 
123 	/* The VF is using the physical bar. While this is mostly internal
124 	 * to the VF, might affect the number of CIDs supported assuming
125 	 * QUEUE_QIDS is set.
126 	 */
127 #define VFPF_ACQUIRE_CAP_PHYSICAL_BAR   BIT(3)
128 		u64 capabilities;
129 		u8 fw_major;
130 		u8 fw_minor;
131 		u8 fw_revision;
132 		u8 fw_engineering;
133 		u32 driver_version;
134 		u16 opaque_fid;	/* ME register value */
135 		u8 os_type;	/* VFPF_ACQUIRE_OS_* value */
136 		u8 eth_fp_hsi_major;
137 		u8 eth_fp_hsi_minor;
138 		u8 padding[3];
139 	} vfdev_info;
140 
141 	struct vf_pf_resc_request resc_request;
142 
143 	u64 bulletin_addr;
144 	u32 bulletin_size;
145 	u32 padding;
146 };
147 
148 /* receive side scaling tlv */
149 struct vfpf_vport_update_rss_tlv {
150 	struct channel_tlv tl;
151 
152 	u8 update_rss_flags;
153 #define VFPF_UPDATE_RSS_CONFIG_FLAG       BIT(0)
154 #define VFPF_UPDATE_RSS_CAPS_FLAG         BIT(1)
155 #define VFPF_UPDATE_RSS_IND_TABLE_FLAG    BIT(2)
156 #define VFPF_UPDATE_RSS_KEY_FLAG          BIT(3)
157 
158 	u8 rss_enable;
159 	u8 rss_caps;
160 	u8 rss_table_size_log;	/* The table size is 2 ^ rss_table_size_log */
161 	u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
162 	u32 rss_key[T_ETH_RSS_KEY_SIZE];
163 };
164 
165 struct pfvf_storm_stats {
166 	u32 address;
167 	u32 len;
168 };
169 
170 struct pfvf_stats_info {
171 	struct pfvf_storm_stats mstats;
172 	struct pfvf_storm_stats pstats;
173 	struct pfvf_storm_stats tstats;
174 	struct pfvf_storm_stats ustats;
175 };
176 
177 struct pfvf_acquire_resp_tlv {
178 	struct pfvf_tlv hdr;
179 
180 	struct pf_vf_pfdev_info {
181 		u32 chip_num;
182 		u32 mfw_ver;
183 
184 		u16 fw_major;
185 		u16 fw_minor;
186 		u16 fw_rev;
187 		u16 fw_eng;
188 
189 		u64 capabilities;
190 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED	BIT(0)
191 #define PFVF_ACQUIRE_CAP_100G			BIT(1)	/* If set, 100g PF */
192 /* There are old PF versions where the PF might mistakenly override the sanity
193  * mechanism [version-based] and allow a VF that can't be supported to pass
194  * the acquisition phase.
195  * To overcome this, PFs now indicate that they're past that point and the new
196  * VFs would fail probe on the older PFs that fail to do so.
197  */
198 #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE	BIT(2)
199 
200 	/* PF expects queues to be received with additional qids */
201 #define PFVF_ACQUIRE_CAP_QUEUE_QIDS             BIT(3)
202 
203 		u16 db_size;
204 		u8 indices_per_sb;
205 		u8 os_type;
206 
207 		/* These should match the PF's qed_dev values */
208 		u16 chip_rev;
209 		u8 dev_type;
210 
211 		/* Doorbell bar size configured in HW: log(size) or 0 */
212 		u8 bar_size;
213 
214 		struct pfvf_stats_info stats_info;
215 
216 		u8 port_mac[ETH_ALEN];
217 
218 		/* It's possible PF had to configure an older fastpath HSI
219 		 * [in case VF is newer than PF]. This is communicated back
220 		 * to the VF. It can also be used in case of error due to
221 		 * non-matching versions to shed light in VF about failure.
222 		 */
223 		u8 major_fp_hsi;
224 		u8 minor_fp_hsi;
225 	} pfdev_info;
226 
227 	struct pf_vf_resc {
228 #define PFVF_MAX_QUEUES_PER_VF		16
229 #define PFVF_MAX_SBS_PER_VF		16
230 		struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
231 		u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
232 		u8 cid[PFVF_MAX_QUEUES_PER_VF];
233 
234 		u8 num_rxqs;
235 		u8 num_txqs;
236 		u8 num_sbs;
237 		u8 num_mac_filters;
238 		u8 num_vlan_filters;
239 		u8 num_mc_filters;
240 		u8 num_cids;
241 		u8 padding;
242 	} resc;
243 
244 	u32 bulletin_size;
245 	u32 padding;
246 };
247 
248 struct pfvf_start_queue_resp_tlv {
249 	struct pfvf_tlv hdr;
250 	u32 offset;		/* offset to consumer/producer of queue */
251 	u8 padding[4];
252 };
253 
254 /* Extended queue information - additional index for reference inside qzone.
255  * If commmunicated between VF/PF, each TLV relating to queues should be
256  * extended by one such [or have a future base TLV that already contains info].
257  */
258 struct vfpf_qid_tlv {
259 	struct channel_tlv tl;
260 	u8 qid;
261 	u8 padding[3];
262 };
263 
264 /* Setup Queue */
265 struct vfpf_start_rxq_tlv {
266 	struct vfpf_first_tlv first_tlv;
267 
268 	/* physical addresses */
269 	u64 rxq_addr;
270 	u64 deprecated_sge_addr;
271 	u64 cqe_pbl_addr;
272 
273 	u16 cqe_pbl_size;
274 	u16 hw_sb;
275 	u16 rx_qid;
276 	u16 hc_rate;		/* desired interrupts per sec. */
277 
278 	u16 bd_max_bytes;
279 	u16 stat_id;
280 	u8 sb_index;
281 	u8 padding[3];
282 };
283 
284 struct vfpf_start_txq_tlv {
285 	struct vfpf_first_tlv first_tlv;
286 
287 	/* physical addresses */
288 	u64 pbl_addr;
289 	u16 pbl_size;
290 	u16 stat_id;
291 	u16 tx_qid;
292 	u16 hw_sb;
293 
294 	u32 flags;		/* VFPF_QUEUE_FLG_X flags */
295 	u16 hc_rate;		/* desired interrupts per sec. */
296 	u8 sb_index;
297 	u8 padding[3];
298 };
299 
300 /* Stop RX Queue */
301 struct vfpf_stop_rxqs_tlv {
302 	struct vfpf_first_tlv first_tlv;
303 
304 	u16 rx_qid;
305 
306 	/* this field is deprecated and should *always* be set to '1' */
307 	u8 num_rxqs;
308 	u8 cqe_completion;
309 	u8 padding[4];
310 };
311 
312 /* Stop TX Queues */
313 struct vfpf_stop_txqs_tlv {
314 	struct vfpf_first_tlv first_tlv;
315 
316 	u16 tx_qid;
317 
318 	/* this field is deprecated and should *always* be set to '1' */
319 	u8 num_txqs;
320 	u8 padding[5];
321 };
322 
323 struct vfpf_update_rxq_tlv {
324 	struct vfpf_first_tlv first_tlv;
325 
326 	u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
327 
328 	u16 rx_qid;
329 	u8 num_rxqs;
330 	u8 flags;
331 #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG    BIT(0)
332 #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG          BIT(1)
333 #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG        BIT(2)
334 
335 	u8 padding[4];
336 };
337 
338 /* Set Queue Filters */
339 struct vfpf_q_mac_vlan_filter {
340 	u32 flags;
341 #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
342 #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
343 #define VFPF_Q_FILTER_SET_MAC           0x100	/* set/clear */
344 
345 	u8 mac[ETH_ALEN];
346 	u16 vlan_tag;
347 
348 	u8 padding[4];
349 };
350 
351 /* Start a vport */
352 struct vfpf_vport_start_tlv {
353 	struct vfpf_first_tlv first_tlv;
354 
355 	u64 sb_addr[PFVF_MAX_SBS_PER_VF];
356 
357 	u32 tpa_mode;
358 	u16 dep1;
359 	u16 mtu;
360 
361 	u8 vport_id;
362 	u8 inner_vlan_removal;
363 
364 	u8 only_untagged;
365 	u8 max_buffers_per_cqe;
366 
367 	u8 padding[4];
368 };
369 
370 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
371 struct vfpf_vport_update_activate_tlv {
372 	struct channel_tlv tl;
373 	u8 update_rx;
374 	u8 update_tx;
375 	u8 active_rx;
376 	u8 active_tx;
377 };
378 
379 struct vfpf_vport_update_tx_switch_tlv {
380 	struct channel_tlv tl;
381 	u8 tx_switching;
382 	u8 padding[3];
383 };
384 
385 struct vfpf_vport_update_vlan_strip_tlv {
386 	struct channel_tlv tl;
387 	u8 remove_vlan;
388 	u8 padding[3];
389 };
390 
391 struct vfpf_vport_update_mcast_bin_tlv {
392 	struct channel_tlv tl;
393 	u8 padding[4];
394 
395 	u64 bins[8];
396 };
397 
398 struct vfpf_vport_update_accept_param_tlv {
399 	struct channel_tlv tl;
400 	u8 update_rx_mode;
401 	u8 update_tx_mode;
402 	u8 rx_accept_filter;
403 	u8 tx_accept_filter;
404 };
405 
406 struct vfpf_vport_update_accept_any_vlan_tlv {
407 	struct channel_tlv tl;
408 	u8 update_accept_any_vlan_flg;
409 	u8 accept_any_vlan;
410 
411 	u8 padding[2];
412 };
413 
414 struct vfpf_vport_update_sge_tpa_tlv {
415 	struct channel_tlv tl;
416 
417 	u16 sge_tpa_flags;
418 #define VFPF_TPA_IPV4_EN_FLAG		BIT(0)
419 #define VFPF_TPA_IPV6_EN_FLAG		BIT(1)
420 #define VFPF_TPA_PKT_SPLIT_FLAG		BIT(2)
421 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG	BIT(3)
422 #define VFPF_TPA_GRO_CONSIST_FLAG	BIT(4)
423 
424 	u8 update_sge_tpa_flags;
425 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG	BIT(0)
426 #define VFPF_UPDATE_TPA_EN_FLAG		BIT(1)
427 #define VFPF_UPDATE_TPA_PARAM_FLAG	BIT(2)
428 
429 	u8 max_buffers_per_cqe;
430 
431 	u16 deprecated_sge_buff_size;
432 	u16 tpa_max_size;
433 	u16 tpa_min_size_to_start;
434 	u16 tpa_min_size_to_cont;
435 
436 	u8 tpa_max_aggs_num;
437 	u8 padding[7];
438 };
439 
440 /* Primary tlv as a header for various extended tlvs for
441  * various functionalities in vport update ramrod.
442  */
443 struct vfpf_vport_update_tlv {
444 	struct vfpf_first_tlv first_tlv;
445 };
446 
447 struct vfpf_ucast_filter_tlv {
448 	struct vfpf_first_tlv first_tlv;
449 
450 	u8 opcode;
451 	u8 type;
452 
453 	u8 mac[ETH_ALEN];
454 
455 	u16 vlan;
456 	u16 padding[3];
457 };
458 
459 /* tunnel update param tlv */
460 struct vfpf_update_tunn_param_tlv {
461 	struct vfpf_first_tlv first_tlv;
462 
463 	u8 tun_mode_update_mask;
464 	u8 tunn_mode;
465 	u8 update_tun_cls;
466 	u8 vxlan_clss;
467 	u8 l2gre_clss;
468 	u8 ipgre_clss;
469 	u8 l2geneve_clss;
470 	u8 ipgeneve_clss;
471 	u8 update_geneve_port;
472 	u8 update_vxlan_port;
473 	u16 geneve_port;
474 	u16 vxlan_port;
475 	u8 padding[2];
476 };
477 
478 struct pfvf_update_tunn_param_tlv {
479 	struct pfvf_tlv hdr;
480 
481 	u16 tunn_feature_mask;
482 	u8 vxlan_mode;
483 	u8 l2geneve_mode;
484 	u8 ipgeneve_mode;
485 	u8 l2gre_mode;
486 	u8 ipgre_mode;
487 	u8 vxlan_clss;
488 	u8 l2gre_clss;
489 	u8 ipgre_clss;
490 	u8 l2geneve_clss;
491 	u8 ipgeneve_clss;
492 	u16 vxlan_udp_port;
493 	u16 geneve_udp_port;
494 };
495 
496 struct tlv_buffer_size {
497 	u8 tlv_buffer[TLV_BUFFER_SIZE];
498 };
499 
500 union vfpf_tlvs {
501 	struct vfpf_first_tlv first_tlv;
502 	struct vfpf_acquire_tlv acquire;
503 	struct vfpf_start_rxq_tlv start_rxq;
504 	struct vfpf_start_txq_tlv start_txq;
505 	struct vfpf_stop_rxqs_tlv stop_rxqs;
506 	struct vfpf_stop_txqs_tlv stop_txqs;
507 	struct vfpf_update_rxq_tlv update_rxq;
508 	struct vfpf_vport_start_tlv start_vport;
509 	struct vfpf_vport_update_tlv vport_update;
510 	struct vfpf_ucast_filter_tlv ucast_filter;
511 	struct vfpf_update_tunn_param_tlv tunn_param_update;
512 	struct channel_list_end_tlv list_end;
513 	struct tlv_buffer_size tlv_buf_size;
514 };
515 
516 union pfvf_tlvs {
517 	struct pfvf_def_resp_tlv default_resp;
518 	struct pfvf_acquire_resp_tlv acquire_resp;
519 	struct tlv_buffer_size tlv_buf_size;
520 	struct pfvf_start_queue_resp_tlv queue_start;
521 	struct pfvf_update_tunn_param_tlv tunn_param_resp;
522 };
523 
524 enum qed_bulletin_bit {
525 	/* Alert the VF that a forced MAC was set by the PF */
526 	MAC_ADDR_FORCED = 0,
527 	/* Alert the VF that a forced VLAN was set by the PF */
528 	VLAN_ADDR_FORCED = 2,
529 
530 	/* Indicate that `default_only_untagged' contains actual data */
531 	VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
532 	VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
533 
534 	/* Alert the VF that suggested mac was sent by the PF.
535 	 * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
536 	 */
537 	VFPF_BULLETIN_MAC_ADDR = 5
538 };
539 
540 struct qed_bulletin_content {
541 	/* crc of structure to ensure is not in mid-update */
542 	u32 crc;
543 
544 	u32 version;
545 
546 	/* bitmap indicating which fields hold valid values */
547 	u64 valid_bitmap;
548 
549 	/* used for MAC_ADDR or MAC_ADDR_FORCED */
550 	u8 mac[ETH_ALEN];
551 
552 	/* If valid, 1 => only untagged Rx if no vlan is configured */
553 	u8 default_only_untagged;
554 	u8 padding;
555 
556 	/* The following is a 'copy' of qed_mcp_link_state,
557 	 * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
558 	 * possible the structs will increase further along the road we cannot
559 	 * have it here; Instead we need to have all of its fields.
560 	 */
561 	u8 req_autoneg;
562 	u8 req_autoneg_pause;
563 	u8 req_forced_rx;
564 	u8 req_forced_tx;
565 	u8 padding2[4];
566 
567 	u32 req_adv_speed;
568 	u32 req_forced_speed;
569 	u32 req_loopback;
570 	u32 padding3;
571 
572 	u8 link_up;
573 	u8 full_duplex;
574 	u8 autoneg;
575 	u8 autoneg_complete;
576 	u8 parallel_detection;
577 	u8 pfc_enabled;
578 	u8 partner_tx_flow_ctrl_en;
579 	u8 partner_rx_flow_ctrl_en;
580 	u8 partner_adv_pause;
581 	u8 sfp_tx_fault;
582 	u16 vxlan_udp_port;
583 	u16 geneve_udp_port;
584 	u8 padding4[2];
585 
586 	u32 speed;
587 	u32 partner_adv_speed;
588 
589 	u32 capability_speed;
590 
591 	/* Forced vlan */
592 	u16 pvid;
593 	u16 padding5;
594 };
595 
596 struct qed_bulletin {
597 	dma_addr_t phys;
598 	struct qed_bulletin_content *p_virt;
599 	u32 size;
600 };
601 
602 enum {
603 	CHANNEL_TLV_NONE,	/* ends tlv sequence */
604 	CHANNEL_TLV_ACQUIRE,
605 	CHANNEL_TLV_VPORT_START,
606 	CHANNEL_TLV_VPORT_UPDATE,
607 	CHANNEL_TLV_VPORT_TEARDOWN,
608 	CHANNEL_TLV_START_RXQ,
609 	CHANNEL_TLV_START_TXQ,
610 	CHANNEL_TLV_STOP_RXQS,
611 	CHANNEL_TLV_STOP_TXQS,
612 	CHANNEL_TLV_UPDATE_RXQ,
613 	CHANNEL_TLV_INT_CLEANUP,
614 	CHANNEL_TLV_CLOSE,
615 	CHANNEL_TLV_RELEASE,
616 	CHANNEL_TLV_LIST_END,
617 	CHANNEL_TLV_UCAST_FILTER,
618 	CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
619 	CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
620 	CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
621 	CHANNEL_TLV_VPORT_UPDATE_MCAST,
622 	CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
623 	CHANNEL_TLV_VPORT_UPDATE_RSS,
624 	CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
625 	CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
626 	CHANNEL_TLV_UPDATE_TUNN_PARAM,
627 	CHANNEL_TLV_RESERVED,
628 	CHANNEL_TLV_QID,
629 	CHANNEL_TLV_MAX,
630 
631 	/* Required for iterating over vport-update tlvs.
632 	 * Will break in case non-sequential vport-update tlvs.
633 	 */
634 	CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
635 };
636 
637 /* Default number of CIDs [total of both Rx and Tx] to be requested
638  * by default, and maximum possible number.
639  */
640 #define QED_ETH_VF_DEFAULT_NUM_CIDS (32)
641 #define QED_ETH_VF_MAX_NUM_CIDS (250)
642 
643 /* This data is held in the qed_hwfn structure for VFs only. */
644 struct qed_vf_iov {
645 	union vfpf_tlvs *vf2pf_request;
646 	dma_addr_t vf2pf_request_phys;
647 	union pfvf_tlvs *pf2vf_reply;
648 	dma_addr_t pf2vf_reply_phys;
649 
650 	/* Should be taken whenever the mailbox buffers are accessed */
651 	struct mutex mutex;
652 	u8 *offset;
653 
654 	/* Bulletin Board */
655 	struct qed_bulletin bulletin;
656 	struct qed_bulletin_content bulletin_shadow;
657 
658 	/* we set aside a copy of the acquire response */
659 	struct pfvf_acquire_resp_tlv acquire_resp;
660 
661 	/* In case PF originates prior to the fp-hsi version comparison,
662 	 * this has to be propagated as it affects the fastpath.
663 	 */
664 	bool b_pre_fp_hsi;
665 
666 	/* Current day VFs are passing the SBs physical address on vport
667 	 * start, and as they lack an IGU mapping they need to store the
668 	 * addresses of previously registered SBs.
669 	 * Even if we were to change configuration flow, due to backward
670 	 * compatibility [with older PFs] we'd still need to store these.
671 	 */
672 	struct qed_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
673 
674 	/* Determines whether VF utilizes doorbells via limited register
675 	 * bar or via the doorbell bar.
676 	 */
677 	bool b_doorbell_bar;
678 };
679 
680 #ifdef CONFIG_QED_SRIOV
681 /**
682  * @brief Read the VF bulletin and act on it if needed
683  *
684  * @param p_hwfn
685  * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
686  *
687  * @return enum _qed_status
688  */
689 int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
690 
691 /**
692  * @brief Get link paramters for VF from qed
693  *
694  * @param p_hwfn
695  * @param params - the link params structure to be filled for the VF
696  */
697 void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
698 			    struct qed_mcp_link_params *params);
699 
700 /**
701  * @brief Get link state for VF from qed
702  *
703  * @param p_hwfn
704  * @param link - the link state structure to be filled for the VF
705  */
706 void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
707 			   struct qed_mcp_link_state *link);
708 
709 /**
710  * @brief Get link capabilities for VF from qed
711  *
712  * @param p_hwfn
713  * @param p_link_caps - the link capabilities structure to be filled for the VF
714  */
715 void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
716 			  struct qed_mcp_link_capabilities *p_link_caps);
717 
718 /**
719  * @brief Get number of Rx queues allocated for VF by qed
720  *
721  *  @param p_hwfn
722  *  @param num_rxqs - allocated RX queues
723  */
724 void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
725 
726 /**
727  * @brief Get number of Rx queues allocated for VF by qed
728  *
729  *  @param p_hwfn
730  *  @param num_txqs - allocated RX queues
731  */
732 void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs);
733 
734 /**
735  * @brief Get number of available connections [both Rx and Tx] for VF
736  *
737  * @param p_hwfn
738  * @param num_cids - allocated number of connections
739  */
740 void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids);
741 
742 /**
743  * @brief Get port mac address for VF
744  *
745  * @param p_hwfn
746  * @param port_mac - destination location for port mac
747  */
748 void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
749 
750 /**
751  * @brief Get number of VLAN filters allocated for VF by qed
752  *
753  *  @param p_hwfn
754  *  @param num_rxqs - allocated VLAN filters
755  */
756 void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
757 				 u8 *num_vlan_filters);
758 
759 /**
760  * @brief Get number of MAC filters allocated for VF by qed
761  *
762  *  @param p_hwfn
763  *  @param num_rxqs - allocated MAC filters
764  */
765 void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
766 
767 /**
768  * @brief Check if VF can set a MAC address
769  *
770  * @param p_hwfn
771  * @param mac
772  *
773  * @return bool
774  */
775 bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
776 
777 /**
778  * @brief Set firmware version information in dev_info from VFs acquire response tlv
779  *
780  * @param p_hwfn
781  * @param fw_major
782  * @param fw_minor
783  * @param fw_rev
784  * @param fw_eng
785  */
786 void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
787 			   u16 *fw_major, u16 *fw_minor,
788 			   u16 *fw_rev, u16 *fw_eng);
789 
790 /**
791  * @brief hw preparation for VF
792  *      sends ACQUIRE message
793  *
794  * @param p_hwfn
795  *
796  * @return int
797  */
798 int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
799 
800 /**
801  * @brief VF - start the RX Queue by sending a message to the PF
802  * @param p_hwfn
803  * @param p_cid			- Only relative fields are relevant
804  * @param bd_max_bytes          - maximum number of bytes per bd
805  * @param bd_chain_phys_addr    - physical address of bd chain
806  * @param cqe_pbl_addr          - physical address of pbl
807  * @param cqe_pbl_size          - pbl size
808  * @param pp_prod               - pointer to the producer to be
809  *				  used in fastpath
810  *
811  * @return int
812  */
813 int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
814 			struct qed_queue_cid *p_cid,
815 			u16 bd_max_bytes,
816 			dma_addr_t bd_chain_phys_addr,
817 			dma_addr_t cqe_pbl_addr,
818 			u16 cqe_pbl_size, void __iomem **pp_prod);
819 
820 /**
821  * @brief VF - start the TX queue by sending a message to the
822  *        PF.
823  *
824  * @param p_hwfn
825  * @param tx_queue_id           - zero based within the VF
826  * @param sb                    - status block for this queue
827  * @param sb_index              - index within the status block
828  * @param bd_chain_phys_addr    - physical address of tx chain
829  * @param pp_doorbell           - pointer to address to which to
830  *                      write the doorbell too..
831  *
832  * @return int
833  */
834 int
835 qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
836 		    struct qed_queue_cid *p_cid,
837 		    dma_addr_t pbl_addr,
838 		    u16 pbl_size, void __iomem **pp_doorbell);
839 
840 /**
841  * @brief VF - stop the RX queue by sending a message to the PF
842  *
843  * @param p_hwfn
844  * @param p_cid
845  * @param cqe_completion
846  *
847  * @return int
848  */
849 int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
850 		       struct qed_queue_cid *p_cid, bool cqe_completion);
851 
852 /**
853  * @brief VF - stop the TX queue by sending a message to the PF
854  *
855  * @param p_hwfn
856  * @param tx_qid
857  *
858  * @return int
859  */
860 int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
861 
862 /**
863  * @brief VF - send a vport update command
864  *
865  * @param p_hwfn
866  * @param params
867  *
868  * @return int
869  */
870 int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
871 			   struct qed_sp_vport_update_params *p_params);
872 
873 /**
874  *
875  * @brief VF - send a close message to PF
876  *
877  * @param p_hwfn
878  *
879  * @return enum _qed_status
880  */
881 int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
882 
883 /**
884  * @brief VF - free vf`s memories
885  *
886  * @param p_hwfn
887  *
888  * @return enum _qed_status
889  */
890 int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
891 
892 /**
893  * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
894  *        sb_id. For VFs igu sbs don't have to be contiguous
895  *
896  * @param p_hwfn
897  * @param sb_id
898  *
899  * @return INLINE u16
900  */
901 u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
902 
903 /**
904  * @brief Stores [or removes] a configured sb_info.
905  *
906  * @param p_hwfn
907  * @param sb_id - zero-based SB index [for fastpath]
908  * @param sb_info - may be NULL [during removal].
909  */
910 void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn,
911 			u16 sb_id, struct qed_sb_info *p_sb);
912 
913 /**
914  * @brief qed_vf_pf_vport_start - perform vport start for VF.
915  *
916  * @param p_hwfn
917  * @param vport_id
918  * @param mtu
919  * @param inner_vlan_removal
920  * @param tpa_mode
921  * @param max_buffers_per_cqe,
922  * @param only_untagged - default behavior regarding vlan acceptance
923  *
924  * @return enum _qed_status
925  */
926 int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
927 			  u8 vport_id,
928 			  u16 mtu,
929 			  u8 inner_vlan_removal,
930 			  enum qed_tpa_mode tpa_mode,
931 			  u8 max_buffers_per_cqe, u8 only_untagged);
932 
933 /**
934  * @brief qed_vf_pf_vport_stop - stop the VF's vport
935  *
936  * @param p_hwfn
937  *
938  * @return enum _qed_status
939  */
940 int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
941 
942 int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
943 			   struct qed_filter_ucast *p_param);
944 
945 void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
946 			    struct qed_filter_mcast *p_filter_cmd);
947 
948 /**
949  * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
950  *
951  * @param p_hwfn
952  *
953  * @return enum _qed_status
954  */
955 int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
956 
957 /**
958  * @brief - return the link params in a given bulletin board
959  *
960  * @param p_hwfn
961  * @param p_params - pointer to a struct to fill with link params
962  * @param p_bulletin
963  */
964 void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
965 			      struct qed_mcp_link_params *p_params,
966 			      struct qed_bulletin_content *p_bulletin);
967 
968 /**
969  * @brief - return the link state in a given bulletin board
970  *
971  * @param p_hwfn
972  * @param p_link - pointer to a struct to fill with link state
973  * @param p_bulletin
974  */
975 void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
976 			     struct qed_mcp_link_state *p_link,
977 			     struct qed_bulletin_content *p_bulletin);
978 
979 /**
980  * @brief - return the link capabilities in a given bulletin board
981  *
982  * @param p_hwfn
983  * @param p_link - pointer to a struct to fill with link capabilities
984  * @param p_bulletin
985  */
986 void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
987 			    struct qed_mcp_link_capabilities *p_link_caps,
988 			    struct qed_bulletin_content *p_bulletin);
989 
990 void qed_iov_vf_task(struct work_struct *work);
991 void qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun);
992 int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
993 				  struct qed_tunnel_info *p_tunn);
994 
995 u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
996 #else
997 static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
998 					  struct qed_mcp_link_params *params)
999 {
1000 }
1001 
1002 static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1003 					 struct qed_mcp_link_state *link)
1004 {
1005 }
1006 
1007 static inline void
1008 qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1009 		     struct qed_mcp_link_capabilities *p_link_caps)
1010 {
1011 }
1012 
1013 static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
1014 {
1015 }
1016 
1017 static inline void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs)
1018 {
1019 }
1020 
1021 static inline void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids)
1022 {
1023 }
1024 
1025 static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
1026 {
1027 }
1028 
1029 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
1030 					       u8 *num_vlan_filters)
1031 {
1032 }
1033 
1034 static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
1035 					      u8 *num_mac_filters)
1036 {
1037 }
1038 
1039 static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
1040 {
1041 	return false;
1042 }
1043 
1044 static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
1045 					 u16 *fw_major, u16 *fw_minor,
1046 					 u16 *fw_rev, u16 *fw_eng)
1047 {
1048 }
1049 
1050 static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
1051 {
1052 	return -EINVAL;
1053 }
1054 
1055 static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
1056 				      struct qed_queue_cid *p_cid,
1057 				      u16 bd_max_bytes,
1058 				      dma_addr_t bd_chain_phys_adr,
1059 				      dma_addr_t cqe_pbl_addr,
1060 				      u16 cqe_pbl_size, void __iomem **pp_prod)
1061 {
1062 	return -EINVAL;
1063 }
1064 
1065 static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
1066 				      struct qed_queue_cid *p_cid,
1067 				      dma_addr_t pbl_addr,
1068 				      u16 pbl_size, void __iomem **pp_doorbell)
1069 {
1070 	return -EINVAL;
1071 }
1072 
1073 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
1074 				     struct qed_queue_cid *p_cid,
1075 				     bool cqe_completion)
1076 {
1077 	return -EINVAL;
1078 }
1079 
1080 static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
1081 				     struct qed_queue_cid *p_cid)
1082 {
1083 	return -EINVAL;
1084 }
1085 
1086 static inline int
1087 qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
1088 		       struct qed_sp_vport_update_params *p_params)
1089 {
1090 	return -EINVAL;
1091 }
1092 
1093 static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
1094 {
1095 	return -EINVAL;
1096 }
1097 
1098 static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
1099 {
1100 	return -EINVAL;
1101 }
1102 
1103 static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
1104 {
1105 	return 0;
1106 }
1107 
1108 static inline void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn, u16 sb_id,
1109 				      struct qed_sb_info *p_sb)
1110 {
1111 }
1112 
1113 static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
1114 					u8 vport_id,
1115 					u16 mtu,
1116 					u8 inner_vlan_removal,
1117 					enum qed_tpa_mode tpa_mode,
1118 					u8 max_buffers_per_cqe,
1119 					u8 only_untagged)
1120 {
1121 	return -EINVAL;
1122 }
1123 
1124 static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
1125 {
1126 	return -EINVAL;
1127 }
1128 
1129 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
1130 					 struct qed_filter_ucast *p_param)
1131 {
1132 	return -EINVAL;
1133 }
1134 
1135 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
1136 					  struct qed_filter_mcast *p_filter_cmd)
1137 {
1138 }
1139 
1140 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
1141 {
1142 	return -EINVAL;
1143 }
1144 
1145 static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
1146 					    struct qed_mcp_link_params
1147 					    *p_params,
1148 					    struct qed_bulletin_content
1149 					    *p_bulletin)
1150 {
1151 }
1152 
1153 static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1154 					   struct qed_mcp_link_state *p_link,
1155 					   struct qed_bulletin_content
1156 					   *p_bulletin)
1157 {
1158 }
1159 
1160 static inline void
1161 __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1162 		       struct qed_mcp_link_capabilities *p_link_caps,
1163 		       struct qed_bulletin_content *p_bulletin)
1164 {
1165 }
1166 
1167 static inline void qed_iov_vf_task(struct work_struct *work)
1168 {
1169 }
1170 
1171 static inline void
1172 qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun)
1173 {
1174 }
1175 
1176 static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
1177 						struct qed_tunnel_info *p_tunn)
1178 {
1179 	return -EINVAL;
1180 }
1181 
1182 static inline u32
1183 qed_vf_hw_bar_size(struct qed_hwfn  *p_hwfn,
1184 		   enum BAR_ID bar_id)
1185 {
1186 	return 0;
1187 }
1188 #endif
1189 
1190 #endif
1191