blob: 7da0b165d8bc2718d28fbbd108040cc4d948a03a [file] [log] [blame]
Yuval Mintz32a47e72016-05-11 16:36:12 +03001/* QLogic qed NIC Driver
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02002 * Copyright (c) 2015-2017 QLogic Corporation
Yuval Mintz32a47e72016-05-11 16:36:12 +03003 *
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02004 * 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.
Yuval Mintz32a47e72016-05-11 16:36:12 +030031 */
32
33#ifndef _QED_VF_H
34#define _QED_VF_H
35
Yuval Mintzdacd88d2016-05-11 16:36:16 +030036#include "qed_l2.h"
Yuval Mintz36558c32016-05-11 16:36:17 +030037#include "qed_mcp.h"
Yuval Mintzdacd88d2016-05-11 16:36:16 +030038
39#define T_ETH_INDIRECTION_TABLE_SIZE 128
40#define T_ETH_RSS_KEY_SIZE 10
41
Yuval Mintz1408cc1f2016-05-11 16:36:14 +030042struct 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 u16 padding;
50};
51
52struct hw_sb_info {
53 u16 hw_sb_id;
54 u8 sb_qid;
55 u8 padding[5];
56};
57
Yuval Mintzdacd88d2016-05-11 16:36:16 +030058#define TLV_BUFFER_SIZE 1024
59
Yuval Mintz37bff2b2016-05-11 16:36:13 +030060enum {
61 PFVF_STATUS_WAITING,
62 PFVF_STATUS_SUCCESS,
63 PFVF_STATUS_FAILURE,
64 PFVF_STATUS_NOT_SUPPORTED,
65 PFVF_STATUS_NO_RESOURCE,
66 PFVF_STATUS_FORCED,
Yuval Mintz7eff82b2016-10-14 05:19:22 -040067 PFVF_STATUS_MALICIOUS,
Yuval Mintz37bff2b2016-05-11 16:36:13 +030068};
69
70/* vf pf channel tlvs */
71/* general tlv header (used for both vf->pf request and pf->vf response) */
72struct channel_tlv {
73 u16 type;
74 u16 length;
75};
76
77/* header of first vf->pf tlv carries the offset used to calculate reponse
78 * buffer address
79 */
80struct vfpf_first_tlv {
81 struct channel_tlv tl;
82 u32 padding;
83 u64 reply_address;
84};
85
86/* header of pf->vf tlvs, carries the status of handling the request */
87struct pfvf_tlv {
88 struct channel_tlv tl;
89 u8 status;
90 u8 padding[3];
91};
92
93/* response tlv used for most tlvs */
94struct pfvf_def_resp_tlv {
95 struct pfvf_tlv hdr;
96};
97
98/* used to terminate and pad a tlv list */
99struct channel_list_end_tlv {
100 struct channel_tlv tl;
101 u8 padding[4];
102};
103
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300104#define VFPF_ACQUIRE_OS_LINUX (0)
105#define VFPF_ACQUIRE_OS_WINDOWS (1)
106#define VFPF_ACQUIRE_OS_ESX (2)
107#define VFPF_ACQUIRE_OS_SOLARIS (3)
108#define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
109
110struct vfpf_acquire_tlv {
111 struct vfpf_first_tlv first_tlv;
112
113 struct vf_pf_vfdev_info {
Yuval Mintza044df82016-08-22 13:25:09 +0300114#define VFPF_ACQUIRE_CAP_PRE_FP_HSI (1 << 0) /* VF pre-FP hsi version */
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300115#define VFPF_ACQUIRE_CAP_100G (1 << 1) /* VF can support 100g */
116 u64 capabilities;
117 u8 fw_major;
118 u8 fw_minor;
119 u8 fw_revision;
120 u8 fw_engineering;
121 u32 driver_version;
122 u16 opaque_fid; /* ME register value */
123 u8 os_type; /* VFPF_ACQUIRE_OS_* value */
Yuval Mintz1fe614d2016-06-05 13:11:11 +0300124 u8 eth_fp_hsi_major;
125 u8 eth_fp_hsi_minor;
126 u8 padding[3];
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300127 } vfdev_info;
128
129 struct vf_pf_resc_request resc_request;
130
131 u64 bulletin_addr;
132 u32 bulletin_size;
133 u32 padding;
134};
135
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300136/* receive side scaling tlv */
137struct vfpf_vport_update_rss_tlv {
138 struct channel_tlv tl;
139
140 u8 update_rss_flags;
141#define VFPF_UPDATE_RSS_CONFIG_FLAG BIT(0)
142#define VFPF_UPDATE_RSS_CAPS_FLAG BIT(1)
143#define VFPF_UPDATE_RSS_IND_TABLE_FLAG BIT(2)
144#define VFPF_UPDATE_RSS_KEY_FLAG BIT(3)
145
146 u8 rss_enable;
147 u8 rss_caps;
148 u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
149 u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
150 u32 rss_key[T_ETH_RSS_KEY_SIZE];
151};
152
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300153struct pfvf_storm_stats {
154 u32 address;
155 u32 len;
156};
157
158struct pfvf_stats_info {
159 struct pfvf_storm_stats mstats;
160 struct pfvf_storm_stats pstats;
161 struct pfvf_storm_stats tstats;
162 struct pfvf_storm_stats ustats;
163};
164
165struct pfvf_acquire_resp_tlv {
166 struct pfvf_tlv hdr;
167
168 struct pf_vf_pfdev_info {
169 u32 chip_num;
170 u32 mfw_ver;
171
172 u16 fw_major;
173 u16 fw_minor;
174 u16 fw_rev;
175 u16 fw_eng;
176
177 u64 capabilities;
178#define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
179#define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
180/* There are old PF versions where the PF might mistakenly override the sanity
181 * mechanism [version-based] and allow a VF that can't be supported to pass
182 * the acquisition phase.
183 * To overcome this, PFs now indicate that they're past that point and the new
184 * VFs would fail probe on the older PFs that fail to do so.
185 */
186#define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
187
188 u16 db_size;
189 u8 indices_per_sb;
190 u8 os_type;
191
192 /* These should match the PF's qed_dev values */
193 u16 chip_rev;
194 u8 dev_type;
195
196 u8 padding;
197
198 struct pfvf_stats_info stats_info;
199
200 u8 port_mac[ETH_ALEN];
Yuval Mintz1fe614d2016-06-05 13:11:11 +0300201
202 /* It's possible PF had to configure an older fastpath HSI
203 * [in case VF is newer than PF]. This is communicated back
204 * to the VF. It can also be used in case of error due to
205 * non-matching versions to shed light in VF about failure.
206 */
207 u8 major_fp_hsi;
208 u8 minor_fp_hsi;
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300209 } pfdev_info;
210
211 struct pf_vf_resc {
212#define PFVF_MAX_QUEUES_PER_VF 16
213#define PFVF_MAX_SBS_PER_VF 16
214 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
215 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
216 u8 cid[PFVF_MAX_QUEUES_PER_VF];
217
218 u8 num_rxqs;
219 u8 num_txqs;
220 u8 num_sbs;
221 u8 num_mac_filters;
222 u8 num_vlan_filters;
223 u8 num_mc_filters;
224 u8 padding[2];
225 } resc;
226
227 u32 bulletin_size;
228 u32 padding;
229};
230
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300231struct pfvf_start_queue_resp_tlv {
232 struct pfvf_tlv hdr;
233 u32 offset; /* offset to consumer/producer of queue */
234 u8 padding[4];
235};
236
237/* Setup Queue */
238struct vfpf_start_rxq_tlv {
239 struct vfpf_first_tlv first_tlv;
240
241 /* physical addresses */
242 u64 rxq_addr;
243 u64 deprecated_sge_addr;
244 u64 cqe_pbl_addr;
245
246 u16 cqe_pbl_size;
247 u16 hw_sb;
248 u16 rx_qid;
249 u16 hc_rate; /* desired interrupts per sec. */
250
251 u16 bd_max_bytes;
252 u16 stat_id;
253 u8 sb_index;
254 u8 padding[3];
255};
256
257struct vfpf_start_txq_tlv {
258 struct vfpf_first_tlv first_tlv;
259
260 /* physical addresses */
261 u64 pbl_addr;
262 u16 pbl_size;
263 u16 stat_id;
264 u16 tx_qid;
265 u16 hw_sb;
266
267 u32 flags; /* VFPF_QUEUE_FLG_X flags */
268 u16 hc_rate; /* desired interrupts per sec. */
269 u8 sb_index;
270 u8 padding[3];
271};
272
273/* Stop RX Queue */
274struct vfpf_stop_rxqs_tlv {
275 struct vfpf_first_tlv first_tlv;
276
277 u16 rx_qid;
278 u8 num_rxqs;
279 u8 cqe_completion;
280 u8 padding[4];
281};
282
283/* Stop TX Queues */
284struct vfpf_stop_txqs_tlv {
285 struct vfpf_first_tlv first_tlv;
286
287 u16 tx_qid;
288 u8 num_txqs;
289 u8 padding[5];
290};
291
292struct vfpf_update_rxq_tlv {
293 struct vfpf_first_tlv first_tlv;
294
295 u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
296
297 u16 rx_qid;
298 u8 num_rxqs;
299 u8 flags;
300#define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
301#define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
302#define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
303
304 u8 padding[4];
305};
306
307/* Set Queue Filters */
308struct vfpf_q_mac_vlan_filter {
309 u32 flags;
310#define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
311#define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
312#define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
313
314 u8 mac[ETH_ALEN];
315 u16 vlan_tag;
316
317 u8 padding[4];
318};
319
320/* Start a vport */
321struct vfpf_vport_start_tlv {
322 struct vfpf_first_tlv first_tlv;
323
324 u64 sb_addr[PFVF_MAX_SBS_PER_VF];
325
326 u32 tpa_mode;
327 u16 dep1;
328 u16 mtu;
329
330 u8 vport_id;
331 u8 inner_vlan_removal;
332
333 u8 only_untagged;
334 u8 max_buffers_per_cqe;
335
336 u8 padding[4];
337};
338
339/* Extended tlvs - need to add rss, mcast, accept mode tlvs */
340struct vfpf_vport_update_activate_tlv {
341 struct channel_tlv tl;
342 u8 update_rx;
343 u8 update_tx;
344 u8 active_rx;
345 u8 active_tx;
346};
347
Yuval Mintz17b235c2016-05-11 16:36:18 +0300348struct vfpf_vport_update_tx_switch_tlv {
349 struct channel_tlv tl;
350 u8 tx_switching;
351 u8 padding[3];
352};
353
354struct vfpf_vport_update_vlan_strip_tlv {
355 struct channel_tlv tl;
356 u8 remove_vlan;
357 u8 padding[3];
358};
359
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300360struct vfpf_vport_update_mcast_bin_tlv {
361 struct channel_tlv tl;
362 u8 padding[4];
363
364 u64 bins[8];
365};
366
367struct vfpf_vport_update_accept_param_tlv {
368 struct channel_tlv tl;
369 u8 update_rx_mode;
370 u8 update_tx_mode;
371 u8 rx_accept_filter;
372 u8 tx_accept_filter;
373};
374
Yuval Mintz17b235c2016-05-11 16:36:18 +0300375struct vfpf_vport_update_accept_any_vlan_tlv {
376 struct channel_tlv tl;
377 u8 update_accept_any_vlan_flg;
378 u8 accept_any_vlan;
379
380 u8 padding[2];
381};
382
383struct vfpf_vport_update_sge_tpa_tlv {
384 struct channel_tlv tl;
385
386 u16 sge_tpa_flags;
387#define VFPF_TPA_IPV4_EN_FLAG BIT(0)
388#define VFPF_TPA_IPV6_EN_FLAG BIT(1)
389#define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
390#define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
391#define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
392
393 u8 update_sge_tpa_flags;
394#define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
395#define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
396#define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
397
398 u8 max_buffers_per_cqe;
399
400 u16 deprecated_sge_buff_size;
401 u16 tpa_max_size;
402 u16 tpa_min_size_to_start;
403 u16 tpa_min_size_to_cont;
404
405 u8 tpa_max_aggs_num;
406 u8 padding[7];
407};
408
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300409/* Primary tlv as a header for various extended tlvs for
410 * various functionalities in vport update ramrod.
411 */
412struct vfpf_vport_update_tlv {
413 struct vfpf_first_tlv first_tlv;
414};
415
416struct vfpf_ucast_filter_tlv {
417 struct vfpf_first_tlv first_tlv;
418
419 u8 opcode;
420 u8 type;
421
422 u8 mac[ETH_ALEN];
423
424 u16 vlan;
425 u16 padding[3];
426};
427
Yuval Mintz32a47e72016-05-11 16:36:12 +0300428struct tlv_buffer_size {
429 u8 tlv_buffer[TLV_BUFFER_SIZE];
430};
431
432union vfpf_tlvs {
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300433 struct vfpf_first_tlv first_tlv;
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300434 struct vfpf_acquire_tlv acquire;
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300435 struct vfpf_start_rxq_tlv start_rxq;
436 struct vfpf_start_txq_tlv start_txq;
437 struct vfpf_stop_rxqs_tlv stop_rxqs;
438 struct vfpf_stop_txqs_tlv stop_txqs;
Yuval Mintz17b235c2016-05-11 16:36:18 +0300439 struct vfpf_update_rxq_tlv update_rxq;
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300440 struct vfpf_vport_start_tlv start_vport;
441 struct vfpf_vport_update_tlv vport_update;
442 struct vfpf_ucast_filter_tlv ucast_filter;
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300443 struct channel_list_end_tlv list_end;
Yuval Mintz32a47e72016-05-11 16:36:12 +0300444 struct tlv_buffer_size tlv_buf_size;
445};
446
447union pfvf_tlvs {
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300448 struct pfvf_def_resp_tlv default_resp;
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300449 struct pfvf_acquire_resp_tlv acquire_resp;
Yuval Mintz32a47e72016-05-11 16:36:12 +0300450 struct tlv_buffer_size tlv_buf_size;
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300451 struct pfvf_start_queue_resp_tlv queue_start;
Yuval Mintz32a47e72016-05-11 16:36:12 +0300452};
453
Yuval Mintz08feecd2016-05-11 16:36:20 +0300454enum qed_bulletin_bit {
Yuval Mintzeff16962016-05-11 16:36:21 +0300455 /* Alert the VF that a forced MAC was set by the PF */
456 MAC_ADDR_FORCED = 0,
Yuval Mintz08feecd2016-05-11 16:36:20 +0300457 /* Alert the VF that a forced VLAN was set by the PF */
458 VLAN_ADDR_FORCED = 2,
459
460 /* Indicate that `default_only_untagged' contains actual data */
461 VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
462 VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
463
Yuval Mintzeff16962016-05-11 16:36:21 +0300464 /* Alert the VF that suggested mac was sent by the PF.
465 * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
466 */
467 VFPF_BULLETIN_MAC_ADDR = 5
Yuval Mintz08feecd2016-05-11 16:36:20 +0300468};
469
Yuval Mintz32a47e72016-05-11 16:36:12 +0300470struct qed_bulletin_content {
471 /* crc of structure to ensure is not in mid-update */
472 u32 crc;
473
474 u32 version;
475
476 /* bitmap indicating which fields hold valid values */
477 u64 valid_bitmap;
Yuval Mintz36558c32016-05-11 16:36:17 +0300478
479 /* used for MAC_ADDR or MAC_ADDR_FORCED */
480 u8 mac[ETH_ALEN];
481
482 /* If valid, 1 => only untagged Rx if no vlan is configured */
483 u8 default_only_untagged;
484 u8 padding;
485
486 /* The following is a 'copy' of qed_mcp_link_state,
487 * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
488 * possible the structs will increase further along the road we cannot
489 * have it here; Instead we need to have all of its fields.
490 */
491 u8 req_autoneg;
492 u8 req_autoneg_pause;
493 u8 req_forced_rx;
494 u8 req_forced_tx;
495 u8 padding2[4];
496
497 u32 req_adv_speed;
498 u32 req_forced_speed;
499 u32 req_loopback;
500 u32 padding3;
501
502 u8 link_up;
503 u8 full_duplex;
504 u8 autoneg;
505 u8 autoneg_complete;
506 u8 parallel_detection;
507 u8 pfc_enabled;
508 u8 partner_tx_flow_ctrl_en;
509 u8 partner_rx_flow_ctrl_en;
510 u8 partner_adv_pause;
511 u8 sfp_tx_fault;
512 u8 padding4[6];
513
514 u32 speed;
515 u32 partner_adv_speed;
516
517 u32 capability_speed;
Yuval Mintz08feecd2016-05-11 16:36:20 +0300518
519 /* Forced vlan */
520 u16 pvid;
521 u16 padding5;
Yuval Mintz32a47e72016-05-11 16:36:12 +0300522};
523
524struct qed_bulletin {
525 dma_addr_t phys;
526 struct qed_bulletin_content *p_virt;
527 u32 size;
528};
529
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300530enum {
531 CHANNEL_TLV_NONE, /* ends tlv sequence */
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300532 CHANNEL_TLV_ACQUIRE,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300533 CHANNEL_TLV_VPORT_START,
534 CHANNEL_TLV_VPORT_UPDATE,
535 CHANNEL_TLV_VPORT_TEARDOWN,
536 CHANNEL_TLV_START_RXQ,
537 CHANNEL_TLV_START_TXQ,
538 CHANNEL_TLV_STOP_RXQS,
539 CHANNEL_TLV_STOP_TXQS,
Yuval Mintz17b235c2016-05-11 16:36:18 +0300540 CHANNEL_TLV_UPDATE_RXQ,
Yuval Mintz0b55e272016-05-11 16:36:15 +0300541 CHANNEL_TLV_INT_CLEANUP,
542 CHANNEL_TLV_CLOSE,
543 CHANNEL_TLV_RELEASE,
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300544 CHANNEL_TLV_LIST_END,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300545 CHANNEL_TLV_UCAST_FILTER,
546 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
Yuval Mintz17b235c2016-05-11 16:36:18 +0300547 CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
548 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300549 CHANNEL_TLV_VPORT_UPDATE_MCAST,
550 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
551 CHANNEL_TLV_VPORT_UPDATE_RSS,
Yuval Mintz17b235c2016-05-11 16:36:18 +0300552 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
553 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300554 CHANNEL_TLV_MAX,
555
556 /* Required for iterating over vport-update tlvs.
557 * Will break in case non-sequential vport-update tlvs.
558 */
Yuval Mintz17b235c2016-05-11 16:36:18 +0300559 CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
Yuval Mintz37bff2b2016-05-11 16:36:13 +0300560};
561
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300562/* This data is held in the qed_hwfn structure for VFs only. */
563struct qed_vf_iov {
564 union vfpf_tlvs *vf2pf_request;
565 dma_addr_t vf2pf_request_phys;
566 union pfvf_tlvs *pf2vf_reply;
567 dma_addr_t pf2vf_reply_phys;
568
569 /* Should be taken whenever the mailbox buffers are accessed */
570 struct mutex mutex;
571 u8 *offset;
572
573 /* Bulletin Board */
574 struct qed_bulletin bulletin;
575 struct qed_bulletin_content bulletin_shadow;
576
577 /* we set aside a copy of the acquire response */
578 struct pfvf_acquire_resp_tlv acquire_resp;
Yuval Mintzd8c2c7e2016-08-22 13:25:11 +0300579
580 /* In case PF originates prior to the fp-hsi version comparison,
581 * this has to be propagated as it affects the fastpath.
582 */
583 bool b_pre_fp_hsi;
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300584};
585
586#ifdef CONFIG_QED_SRIOV
587/**
Yuval Mintz36558c32016-05-11 16:36:17 +0300588 * @brief Read the VF bulletin and act on it if needed
589 *
590 * @param p_hwfn
591 * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
592 *
593 * @return enum _qed_status
594 */
595int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
596
597/**
598 * @brief Get link paramters for VF from qed
599 *
600 * @param p_hwfn
601 * @param params - the link params structure to be filled for the VF
602 */
603void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
604 struct qed_mcp_link_params *params);
605
606/**
607 * @brief Get link state for VF from qed
608 *
609 * @param p_hwfn
610 * @param link - the link state structure to be filled for the VF
611 */
612void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
613 struct qed_mcp_link_state *link);
614
615/**
616 * @brief Get link capabilities for VF from qed
617 *
618 * @param p_hwfn
619 * @param p_link_caps - the link capabilities structure to be filled for the VF
620 */
621void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
622 struct qed_mcp_link_capabilities *p_link_caps);
623
624/**
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300625 * @brief Get number of Rx queues allocated for VF by qed
626 *
627 * @param p_hwfn
628 * @param num_rxqs - allocated RX queues
629 */
630void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
631
632/**
633 * @brief Get port mac address for VF
634 *
635 * @param p_hwfn
636 * @param port_mac - destination location for port mac
637 */
638void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
639
640/**
641 * @brief Get number of VLAN filters allocated for VF by qed
642 *
643 * @param p_hwfn
644 * @param num_rxqs - allocated VLAN filters
645 */
646void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
647 u8 *num_vlan_filters);
648
649/**
Mintz, Yuvalb0fca312016-10-31 22:26:54 +0200650 * @brief Get number of MAC filters allocated for VF by qed
651 *
652 * @param p_hwfn
653 * @param num_rxqs - allocated MAC filters
654 */
655void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
656
657/**
Yuval Mintzeff16962016-05-11 16:36:21 +0300658 * @brief Check if VF can set a MAC address
659 *
660 * @param p_hwfn
661 * @param mac
662 *
663 * @return bool
664 */
665bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
666
667/**
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300668 * @brief Set firmware version information in dev_info from VFs acquire response tlv
669 *
670 * @param p_hwfn
671 * @param fw_major
672 * @param fw_minor
673 * @param fw_rev
674 * @param fw_eng
675 */
676void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
677 u16 *fw_major, u16 *fw_minor,
678 u16 *fw_rev, u16 *fw_eng);
679
680/**
681 * @brief hw preparation for VF
682 * sends ACQUIRE message
683 *
684 * @param p_hwfn
685 *
686 * @return int
687 */
688int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
689
690/**
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300691 * @brief VF - start the RX Queue by sending a message to the PF
692 * @param p_hwfn
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200693 * @param p_cid - Only relative fields are relevant
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300694 * @param bd_max_bytes - maximum number of bytes per bd
695 * @param bd_chain_phys_addr - physical address of bd chain
696 * @param cqe_pbl_addr - physical address of pbl
697 * @param cqe_pbl_size - pbl size
698 * @param pp_prod - pointer to the producer to be
699 * used in fastpath
700 *
701 * @return int
702 */
703int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200704 struct qed_queue_cid *p_cid,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300705 u16 bd_max_bytes,
706 dma_addr_t bd_chain_phys_addr,
707 dma_addr_t cqe_pbl_addr,
708 u16 cqe_pbl_size, void __iomem **pp_prod);
709
710/**
711 * @brief VF - start the TX queue by sending a message to the
712 * PF.
713 *
714 * @param p_hwfn
715 * @param tx_queue_id - zero based within the VF
716 * @param sb - status block for this queue
717 * @param sb_index - index within the status block
718 * @param bd_chain_phys_addr - physical address of tx chain
719 * @param pp_doorbell - pointer to address to which to
720 * write the doorbell too..
721 *
722 * @return int
723 */
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200724int
725qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
726 struct qed_queue_cid *p_cid,
727 dma_addr_t pbl_addr,
728 u16 pbl_size, void __iomem **pp_doorbell);
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300729
730/**
731 * @brief VF - stop the RX queue by sending a message to the PF
732 *
733 * @param p_hwfn
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200734 * @param p_cid
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300735 * @param cqe_completion
736 *
737 * @return int
738 */
739int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200740 struct qed_queue_cid *p_cid, bool cqe_completion);
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300741
742/**
743 * @brief VF - stop the TX queue by sending a message to the PF
744 *
745 * @param p_hwfn
746 * @param tx_qid
747 *
748 * @return int
749 */
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200750int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300751
752/**
753 * @brief VF - send a vport update command
754 *
755 * @param p_hwfn
756 * @param params
757 *
758 * @return int
759 */
760int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
761 struct qed_sp_vport_update_params *p_params);
762
763/**
Yuval Mintz0b55e272016-05-11 16:36:15 +0300764 *
765 * @brief VF - send a close message to PF
766 *
767 * @param p_hwfn
768 *
769 * @return enum _qed_status
770 */
771int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
772
773/**
774 * @brief VF - free vf`s memories
775 *
776 * @param p_hwfn
777 *
778 * @return enum _qed_status
779 */
780int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
Yuval Mintz36558c32016-05-11 16:36:17 +0300781
Yuval Mintz0b55e272016-05-11 16:36:15 +0300782/**
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300783 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
784 * sb_id. For VFs igu sbs don't have to be contiguous
785 *
786 * @param p_hwfn
787 * @param sb_id
788 *
789 * @return INLINE u16
790 */
791u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
Yuval Mintz0b55e272016-05-11 16:36:15 +0300792
793/**
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300794 * @brief qed_vf_pf_vport_start - perform vport start for VF.
795 *
796 * @param p_hwfn
797 * @param vport_id
798 * @param mtu
799 * @param inner_vlan_removal
800 * @param tpa_mode
801 * @param max_buffers_per_cqe,
802 * @param only_untagged - default behavior regarding vlan acceptance
803 *
804 * @return enum _qed_status
805 */
806int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
807 u8 vport_id,
808 u16 mtu,
809 u8 inner_vlan_removal,
810 enum qed_tpa_mode tpa_mode,
Yuval Mintz08feecd2016-05-11 16:36:20 +0300811 u8 max_buffers_per_cqe, u8 only_untagged);
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300812
813/**
814 * @brief qed_vf_pf_vport_stop - stop the VF's vport
815 *
816 * @param p_hwfn
817 *
818 * @return enum _qed_status
819 */
820int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
821
822int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
823 struct qed_filter_ucast *p_param);
824
825void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
826 struct qed_filter_mcast *p_filter_cmd);
827
828/**
Yuval Mintz0b55e272016-05-11 16:36:15 +0300829 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
830 *
831 * @param p_hwfn
832 *
833 * @return enum _qed_status
834 */
835int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
Yuval Mintz36558c32016-05-11 16:36:17 +0300836
837/**
838 * @brief - return the link params in a given bulletin board
839 *
840 * @param p_hwfn
841 * @param p_params - pointer to a struct to fill with link params
842 * @param p_bulletin
843 */
844void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
845 struct qed_mcp_link_params *p_params,
846 struct qed_bulletin_content *p_bulletin);
847
848/**
849 * @brief - return the link state in a given bulletin board
850 *
851 * @param p_hwfn
852 * @param p_link - pointer to a struct to fill with link state
853 * @param p_bulletin
854 */
855void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
856 struct qed_mcp_link_state *p_link,
857 struct qed_bulletin_content *p_bulletin);
858
859/**
860 * @brief - return the link capabilities in a given bulletin board
861 *
862 * @param p_hwfn
863 * @param p_link - pointer to a struct to fill with link capabilities
864 * @param p_bulletin
865 */
866void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
867 struct qed_mcp_link_capabilities *p_link_caps,
868 struct qed_bulletin_content *p_bulletin);
869
870void qed_iov_vf_task(struct work_struct *work);
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300871#else
Yuval Mintz36558c32016-05-11 16:36:17 +0300872static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
873 struct qed_mcp_link_params *params)
874{
875}
876
877static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
878 struct qed_mcp_link_state *link)
879{
880}
881
882static inline void
883qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
884 struct qed_mcp_link_capabilities *p_link_caps)
885{
886}
887
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300888static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
889{
890}
891
892static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
893{
894}
895
896static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
897 u8 *num_vlan_filters)
898{
899}
900
Mintz, Yuvalb0fca312016-10-31 22:26:54 +0200901static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
902 u8 *num_mac_filters)
903{
904}
905
Yuval Mintzeff16962016-05-11 16:36:21 +0300906static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
907{
908 return false;
909}
910
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300911static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
912 u16 *fw_major, u16 *fw_minor,
913 u16 *fw_rev, u16 *fw_eng)
914{
915}
916
917static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
918{
919 return -EINVAL;
920}
921
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300922static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200923 struct qed_queue_cid *p_cid,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300924 u16 bd_max_bytes,
925 dma_addr_t bd_chain_phys_adr,
926 dma_addr_t cqe_pbl_addr,
927 u16 cqe_pbl_size, void __iomem **pp_prod)
928{
929 return -EINVAL;
930}
931
932static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200933 struct qed_queue_cid *p_cid,
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300934 dma_addr_t pbl_addr,
935 u16 pbl_size, void __iomem **pp_doorbell)
936{
937 return -EINVAL;
938}
939
940static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200941 struct qed_queue_cid *p_cid,
942 bool cqe_completion)
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300943{
944 return -EINVAL;
945}
946
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200947static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
948 struct qed_queue_cid *p_cid)
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300949{
950 return -EINVAL;
951}
952
953static inline int
954qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
955 struct qed_sp_vport_update_params *p_params)
956{
957 return -EINVAL;
958}
959
Yuval Mintz0b55e272016-05-11 16:36:15 +0300960static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
961{
962 return -EINVAL;
963}
964
965static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
966{
967 return -EINVAL;
968}
969
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300970static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
971{
972 return 0;
973}
Yuval Mintz0b55e272016-05-11 16:36:15 +0300974
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300975static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
976 u8 vport_id,
977 u16 mtu,
978 u8 inner_vlan_removal,
979 enum qed_tpa_mode tpa_mode,
Yuval Mintz08feecd2016-05-11 16:36:20 +0300980 u8 max_buffers_per_cqe,
981 u8 only_untagged)
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300982{
983 return -EINVAL;
984}
985
986static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
987{
988 return -EINVAL;
989}
990
991static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
992 struct qed_filter_ucast *p_param)
993{
994 return -EINVAL;
995}
996
997static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
998 struct qed_filter_mcast *p_filter_cmd)
999{
1000}
1001
Yuval Mintz0b55e272016-05-11 16:36:15 +03001002static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
1003{
1004 return -EINVAL;
1005}
Yuval Mintz36558c32016-05-11 16:36:17 +03001006
1007static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
1008 struct qed_mcp_link_params
1009 *p_params,
1010 struct qed_bulletin_content
1011 *p_bulletin)
1012{
1013}
1014
1015static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1016 struct qed_mcp_link_state *p_link,
1017 struct qed_bulletin_content
1018 *p_bulletin)
1019{
1020}
1021
1022static inline void
1023__qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1024 struct qed_mcp_link_capabilities *p_link_caps,
1025 struct qed_bulletin_content *p_bulletin)
1026{
1027}
1028
1029static inline void qed_iov_vf_task(struct work_struct *work)
1030{
1031}
Yuval Mintz1408cc1f2016-05-11 16:36:14 +03001032#endif
1033
Yuval Mintz32a47e72016-05-11 16:36:12 +03001034#endif