blob: 7a6d406f4c111774ea606c98253608273ae8787b [file] [log] [blame]
Yuval Mintz4ad79e12015-07-22 09:16:23 +03001/* bnx2x_sriov.h: QLogic Everest network driver.
Ariel Elior1ab44342013-01-01 05:22:23 +00002 *
Yuval Mintz247fa822013-01-14 05:11:50 +00003 * Copyright 2009-2013 Broadcom Corporation
Yuval Mintz4ad79e12015-07-22 09:16:23 +03004 * Copyright 2014 QLogic Corporation
5 * All rights reserved
Ariel Elior1ab44342013-01-01 05:22:23 +00006 *
Yuval Mintz4ad79e12015-07-22 09:16:23 +03007 * Unless you and QLogic execute a separate written software license
Ariel Elior1ab44342013-01-01 05:22:23 +00008 * agreement governing use of this software, this software is licensed to you
9 * under the terms of the GNU General Public License version 2, available
10 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
11 *
12 * Notwithstanding the above, under no circumstances may you combine this
Yuval Mintz4ad79e12015-07-22 09:16:23 +030013 * software in any way with any other QLogic software provided under a
14 * license other than the GPL, without QLogic's express prior written
Ariel Elior1ab44342013-01-01 05:22:23 +000015 * consent.
16 *
Ariel Elior08f6dd82014-05-27 13:11:36 +030017 * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
18 * Written by: Shmulik Ravid
19 * Ariel Elior <ariel.elior@qlogic.com>
Ariel Elior1ab44342013-01-01 05:22:23 +000020 */
21#ifndef BNX2X_SRIOV_H
22#define BNX2X_SRIOV_H
23
Ariel Elior8ca5e172013-01-01 05:22:34 +000024#include "bnx2x_vfpf.h"
Ariel Elior64112802013-01-07 00:50:23 +000025#include "bnx2x.h"
26
27enum sample_bulletin_result {
28 PFVF_BULLETIN_UNCHANGED,
29 PFVF_BULLETIN_UPDATED,
30 PFVF_BULLETIN_CRC_ERR
31};
32
33#ifdef CONFIG_BNX2X_SRIOV
Ariel Elior8ca5e172013-01-01 05:22:34 +000034
Yuval Mintz370d4a22014-03-23 18:12:24 +020035extern struct workqueue_struct *bnx2x_iov_wq;
36
Ariel Elior290ca2b2013-01-01 05:22:31 +000037/* The bnx2x device structure holds vfdb structure described below.
38 * The VF array is indexed by the relative vfid.
39 */
Ariel Elior8ca5e172013-01-01 05:22:34 +000040#define BNX2X_VF_MAX_QUEUES 16
Ariel Elior8db573b2013-01-01 05:22:37 +000041#define BNX2X_VF_MAX_TPA_AGG_QUEUES 8
42
Ariel Elior290ca2b2013-01-01 05:22:31 +000043struct bnx2x_sriov {
44 u32 first_vf_in_pf;
45
46 /* standard SRIOV capability fields, mostly for debugging */
47 int pos; /* capability position */
48 int nres; /* number of resources */
49 u32 cap; /* SR-IOV Capabilities */
50 u16 ctrl; /* SR-IOV Control */
51 u16 total; /* total VFs associated with the PF */
52 u16 initial; /* initial VFs associated with the PF */
53 u16 nr_virtfn; /* number of VFs available */
54 u16 offset; /* first VF Routing ID offset */
55 u16 stride; /* following VF stride */
56 u32 pgsz; /* page size for BAR alignment */
57 u8 link; /* Function Dependency Link */
58};
59
60/* bars */
61struct bnx2x_vf_bar {
62 u64 bar;
63 u32 size;
64};
65
Ariel Eliorf1929b02013-01-01 05:22:41 +000066struct bnx2x_vf_bar_info {
67 struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
68 u8 nr_bars;
69};
70
Ariel Elior290ca2b2013-01-01 05:22:31 +000071/* vf queue (used both for rx or tx) */
72struct bnx2x_vf_queue {
73 struct eth_context *cxt;
74
75 /* MACs object */
76 struct bnx2x_vlan_mac_obj mac_obj;
77
78 /* VLANs object */
79 struct bnx2x_vlan_mac_obj vlan_obj;
Yuval Mintz05cc5a32015-07-29 15:52:46 +030080
81 /* VLAN-MACs object */
82 struct bnx2x_vlan_mac_obj vlan_mac_obj;
83
Yuval Mintze8379c72014-01-05 18:33:54 +020084 unsigned long accept_flags; /* last accept flags configured */
Ariel Elior290ca2b2013-01-01 05:22:31 +000085
86 /* Queue Slow-path State object */
87 struct bnx2x_queue_sp_obj sp_obj;
88
89 u32 cid;
90 u16 index;
91 u16 sb_idx;
Ariel Eliorb9871bc2013-09-04 14:09:21 +030092 bool is_leading;
Yuval Mintz3a3534e2014-02-12 18:19:54 +020093 bool sp_initialized;
Ariel Elior290ca2b2013-01-01 05:22:31 +000094};
95
Yuval Mintz2dc33bb2014-03-23 18:12:25 +020096/* struct bnx2x_vf_queue_construct_params - prepare queue construction
97 * parameters: q-init, q-setup and SB index
Ariel Elior290ca2b2013-01-01 05:22:31 +000098 */
Yuval Mintz2dc33bb2014-03-23 18:12:25 +020099struct bnx2x_vf_queue_construct_params {
Ariel Elior290ca2b2013-01-01 05:22:31 +0000100 struct bnx2x_queue_state_params qstate;
101 struct bnx2x_queue_setup_params prep_qsetup;
102};
103
Ariel Elior290ca2b2013-01-01 05:22:31 +0000104/* forward */
105struct bnx2x_virtf;
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000106
107/* VFOP definitions */
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000108
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200109struct bnx2x_vf_mac_vlan_filter {
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000110 int type;
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300111#define BNX2X_VF_FILTER_MAC BIT(0)
112#define BNX2X_VF_FILTER_VLAN BIT(1)
113#define BNX2X_VF_FILTER_VLAN_MAC \
114 (BNX2X_VF_FILTER_MAC | BNX2X_VF_FILTER_VLAN) /*shortcut*/
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000115
116 bool add;
117 u8 *mac;
118 u16 vid;
119};
120
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200121struct bnx2x_vf_mac_vlan_filters {
122 int count;
123 struct bnx2x_vf_mac_vlan_filter filters[];
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000124};
125
Ariel Elior290ca2b2013-01-01 05:22:31 +0000126/* vf context */
127struct bnx2x_virtf {
128 u16 cfg_flags;
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300129#define VF_CFG_STATS_COALESCE 0x1
130#define VF_CFG_EXT_BULLETIN 0x2
131#define VF_CFG_VLAN_FILTER 0x4
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300132 u8 link_cfg; /* IFLA_VF_LINK_STATE_AUTO
133 * IFLA_VF_LINK_STATE_ENABLE
134 * IFLA_VF_LINK_STATE_DISABLE
135 */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000136 u8 state;
137#define VF_FREE 0 /* VF ready to be acquired holds no resc */
Yuval Mintz16a5fd92013-06-02 00:06:18 +0000138#define VF_ACQUIRED 1 /* VF acquired, but not initialized */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000139#define VF_ENABLED 2 /* VF Enabled */
140#define VF_RESET 3 /* VF FLR'd, pending cleanup */
141
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200142 bool flr_clnup_stage; /* true during flr cleanup */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000143
144 /* dma */
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300145 dma_addr_t fw_stat_map;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300146 u16 stats_stride;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000147 dma_addr_t bulletin_map;
148
149 /* Allocated resources counters. Before the VF is acquired, the
150 * counters hold the following values:
151 *
152 * - xxq_count = 0 as the queues memory is not allocated yet.
153 *
154 * - sb_count = The number of status blocks configured for this VF in
155 * the IGU CAM. Initially read during probe.
156 *
157 * - xx_rules_count = The number of rules statically and equally
158 * allocated for each VF, during PF load.
159 */
160 struct vf_pf_resc_request alloc_resc;
161#define vf_rxq_count(vf) ((vf)->alloc_resc.num_rxqs)
162#define vf_txq_count(vf) ((vf)->alloc_resc.num_txqs)
163#define vf_sb_count(vf) ((vf)->alloc_resc.num_sbs)
164#define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
165#define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
166#define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
167
168 u8 sb_count; /* actual number of SBs */
169 u8 igu_base_id; /* base igu status block id */
170
171 struct bnx2x_vf_queue *vfqs;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300172#define LEADING_IDX 0
173#define bnx2x_vfq_is_leading(vfq) ((vfq)->index == LEADING_IDX)
174#define bnx2x_vfq(vf, nr, var) ((vf)->vfqs[(nr)].var)
175#define bnx2x_leading_vfq(vf, var) ((vf)->vfqs[LEADING_IDX].var)
Ariel Elior290ca2b2013-01-01 05:22:31 +0000176
177 u8 index; /* index in the vf array */
178 u8 abs_vfid;
179 u8 sp_cl_id;
180 u32 error; /* 0 means all's-well */
181
182 /* BDF */
183 unsigned int bus;
184 unsigned int devfn;
185
186 /* bars */
187 struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
188
189 /* set-mac ramrod state 1-pending, 0-done */
190 unsigned long filter_state;
191
192 /* leading rss client id ~~ the client id of the first rxq, must be
193 * set for each txq.
194 */
195 int leading_rss;
196
197 /* MCAST object */
198 struct bnx2x_mcast_obj mcast_obj;
199
200 /* RSS configuration object */
201 struct bnx2x_rss_config_obj rss_conf_obj;
202
203 /* slow-path operations */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000204 struct mutex op_mutex; /* one vfop at a time mutex */
205 enum channel_tlvs op_current;
Yuval Mintz02dc4022014-12-04 12:52:06 +0200206
207 u8 fp_hsi;
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300208
209 struct bnx2x_credit_pool_obj vf_vlans_pool;
210 struct bnx2x_credit_pool_obj vf_macs_pool;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000211};
212
213#define BNX2X_NR_VIRTFN(bp) ((bp)->vfdb->sriov.nr_virtfn)
214
215#define for_each_vf(bp, var) \
216 for ((var) = 0; (var) < BNX2X_NR_VIRTFN(bp); (var)++)
217
Ariel Elior8ca5e172013-01-01 05:22:34 +0000218#define for_each_vfq(vf, var) \
219 for ((var) = 0; (var) < vf_rxq_count(vf); (var)++)
220
221#define for_each_vf_sb(vf, var) \
222 for ((var) = 0; (var) < vf_sb_count(vf); (var)++)
223
Ariel Eliorb93288d2013-01-01 05:22:35 +0000224#define is_vf_multi(vf) (vf_rxq_count(vf) > 1)
225
Ariel Eliorb56e9672013-01-01 05:22:32 +0000226#define HW_VF_HANDLE(bp, abs_vfid) \
227 (u16)(BP_ABS_FUNC((bp)) | (1<<3) | ((u16)(abs_vfid) << 4))
228
229#define FW_PF_MAX_HANDLE 8
230
231#define FW_VF_HANDLE(abs_vfid) \
232 (abs_vfid + FW_PF_MAX_HANDLE)
233
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300234#define GET_NUM_VFS_PER_PATH(bp) 64 /* use max possible value */
235#define GET_NUM_VFS_PER_PF(bp) ((bp)->vfdb ? (bp)->vfdb->sriov.total \
236 : 0)
237#define VF_MAC_CREDIT_CNT 1
238#define VF_VLAN_CREDIT_CNT 2 /* VLAN0 + 'real' VLAN */
239
Ariel Elior8ca5e172013-01-01 05:22:34 +0000240/* locking and unlocking the channel mutex */
241void bnx2x_lock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
242 enum channel_tlvs tlv);
243
244void bnx2x_unlock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
245 enum channel_tlvs expected_tlv);
246
Ariel Eliorb56e9672013-01-01 05:22:32 +0000247/* VF mail box (aka vf-pf channel) */
248
249/* a container for the bi-directional vf<-->pf messages.
250 * The actual response will be placed according to the offset parameter
251 * provided in the request
252 */
253
254#define MBX_MSG_ALIGN 8
255#define MBX_MSG_ALIGNED_SIZE (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
256 MBX_MSG_ALIGN))
257
Ariel Elior1ab44342013-01-01 05:22:23 +0000258struct bnx2x_vf_mbx_msg {
259 union vfpf_tlvs req;
260 union pfvf_tlvs resp;
261};
262
Ariel Elior290ca2b2013-01-01 05:22:31 +0000263struct bnx2x_vf_mbx {
264 struct bnx2x_vf_mbx_msg *msg;
265 dma_addr_t msg_mapping;
266
267 /* VF GPA address */
268 u32 vf_addr_lo;
269 u32 vf_addr_hi;
270
271 struct vfpf_first_tlv first_tlv; /* saved VF request header */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000272};
273
Ariel Eliorb56e9672013-01-01 05:22:32 +0000274struct bnx2x_vf_sp {
275 union {
276 struct eth_classify_rules_ramrod_data e2;
277 } mac_rdata;
278
279 union {
280 struct eth_classify_rules_ramrod_data e2;
281 } vlan_rdata;
282
283 union {
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300284 struct eth_classify_rules_ramrod_data e2;
285 } vlan_mac_rdata;
286
287 union {
Ariel Eliorb56e9672013-01-01 05:22:32 +0000288 struct eth_filter_rules_ramrod_data e2;
289 } rx_mode_rdata;
290
291 union {
292 struct eth_multicast_rules_ramrod_data e2;
293 } mcast_rdata;
294
295 union {
296 struct client_init_ramrod_data init_data;
297 struct client_update_ramrod_data update_data;
298 } q_data;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300299
300 union {
301 struct eth_rss_update_ramrod_data e2;
302 } rss_rdata;
Ariel Eliorb56e9672013-01-01 05:22:32 +0000303};
304
Ariel Elior290ca2b2013-01-01 05:22:31 +0000305struct hw_dma {
306 void *addr;
307 dma_addr_t mapping;
308 size_t size;
309};
310
311struct bnx2x_vfdb {
312#define BP_VFDB(bp) ((bp)->vfdb)
313 /* vf array */
314 struct bnx2x_virtf *vfs;
Yuval Mintz58fee002014-08-17 16:47:50 +0300315#define BP_VF(bp, idx) ((BP_VFDB(bp) && (bp)->vfdb->vfs) ? \
316 &((bp)->vfdb->vfs[idx]) : NULL)
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300317#define bnx2x_vf(bp, idx, var) ((bp)->vfdb->vfs[idx].var)
Ariel Elior290ca2b2013-01-01 05:22:31 +0000318
319 /* queue array - for all vfs */
320 struct bnx2x_vf_queue *vfqs;
321
322 /* vf HW contexts */
323 struct hw_dma context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300324#define BP_VF_CXT_PAGE(bp, i) (&(bp)->vfdb->context[i])
Ariel Elior290ca2b2013-01-01 05:22:31 +0000325
326 /* SR-IOV information */
327 struct bnx2x_sriov sriov;
328 struct hw_dma mbx_dma;
329#define BP_VF_MBX_DMA(bp) (&((bp)->vfdb->mbx_dma))
330 struct bnx2x_vf_mbx mbxs[BNX2X_MAX_NUM_OF_VFS];
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300331#define BP_VF_MBX(bp, vfid) (&((bp)->vfdb->mbxs[vfid]))
Ariel Elior290ca2b2013-01-01 05:22:31 +0000332
Ariel Eliorabc5a022013-01-01 05:22:43 +0000333 struct hw_dma bulletin_dma;
334#define BP_VF_BULLETIN_DMA(bp) (&((bp)->vfdb->bulletin_dma))
335#define BP_VF_BULLETIN(bp, vf) \
336 (((struct pf_vf_bulletin_content *)(BP_VF_BULLETIN_DMA(bp)->addr)) \
337 + (vf))
338
Ariel Elior290ca2b2013-01-01 05:22:31 +0000339 struct hw_dma sp_dma;
340#define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr + \
341 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
342 offsetof(struct bnx2x_vf_sp, field))
343#define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping + \
344 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
345 offsetof(struct bnx2x_vf_sp, field))
346
347#define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
348 u32 flrd_vfs[FLRD_VFS_DWORDS];
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300349
350 /* the number of msix vectors belonging to this PF designated for VFs */
351 u16 vf_sbs_pool;
352 u16 first_vf_igu_entry;
Yuval Mintz370d4a22014-03-23 18:12:24 +0200353
354 /* sp_rtnl synchronization */
355 struct mutex event_mutex;
356 u64 event_occur;
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300357
358 /* bulletin board update synchronization */
359 struct mutex bulletin_mutex;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000360};
361
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000362/* queue access */
363static inline struct bnx2x_vf_queue *vfq_get(struct bnx2x_virtf *vf, u8 index)
364{
365 return &(vf->vfqs[index]);
366}
367
Ariel Elior8ca5e172013-01-01 05:22:34 +0000368/* FW ids */
Ariel Eliorb56e9672013-01-01 05:22:32 +0000369static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
370{
371 return vf->igu_base_id + sb_idx;
372}
373
Ariel Elior8ca5e172013-01-01 05:22:34 +0000374static inline u8 vf_hc_qzone(struct bnx2x_virtf *vf, u16 sb_idx)
375{
376 return vf_igu_sb(vf, sb_idx);
377}
378
379static u8 vfq_cl_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
380{
381 return vf->igu_base_id + q->index;
382}
383
Ariel Elior8db573b2013-01-01 05:22:37 +0000384static inline u8 vfq_stat_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
385{
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300386 if (vf->cfg_flags & VF_CFG_STATS_COALESCE)
387 return vf->leading_rss;
388 else
389 return vfq_cl_id(vf, q);
Ariel Elior8db573b2013-01-01 05:22:37 +0000390}
391
Ariel Elior8ca5e172013-01-01 05:22:34 +0000392static inline u8 vfq_qzone_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
393{
394 return vfq_cl_id(vf, q);
395}
396
Ariel Elior290ca2b2013-01-01 05:22:31 +0000397/* global iov routines */
398int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
399int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
400void bnx2x_iov_remove_one(struct bnx2x *bp);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000401void bnx2x_iov_free_mem(struct bnx2x *bp);
402int bnx2x_iov_alloc_mem(struct bnx2x *bp);
403int bnx2x_iov_nic_init(struct bnx2x *bp);
Ariel Eliorf1929b02013-01-01 05:22:41 +0000404int bnx2x_iov_chip_cleanup(struct bnx2x *bp);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000405void bnx2x_iov_init_dq(struct bnx2x *bp);
406void bnx2x_iov_init_dmae(struct bnx2x *bp);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000407void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
408 struct bnx2x_queue_sp_obj **q_obj);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000409int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem);
Ariel Elior67c431a2013-01-01 05:22:36 +0000410void bnx2x_iov_adjust_stats_req(struct bnx2x *bp);
411void bnx2x_iov_storm_stats_update(struct bnx2x *bp);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000412/* global vf mailbox routines */
Yuval Mintz370d4a22014-03-23 18:12:24 +0200413void bnx2x_vf_mbx(struct bnx2x *bp);
414void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
415 struct vf_pf_event_data *vfpf_event);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000416void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
Ariel Elior954ea742013-01-01 05:22:38 +0000417
418/* CORE VF API */
419typedef u8 bnx2x_mac_addr_t[ETH_ALEN];
420
Ariel Elior8ca5e172013-01-01 05:22:34 +0000421/* acquire */
422int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
Ariel Eliorb93288d2013-01-01 05:22:35 +0000423 struct vf_pf_resc_request *resc);
424/* init */
425int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
426 dma_addr_t *sb_map);
Ariel Elior8db573b2013-01-01 05:22:37 +0000427
Ariel Elior8db573b2013-01-01 05:22:37 +0000428/* VFOP queue construction helpers */
429void bnx2x_vfop_qctor_dump_tx(struct bnx2x *bp, struct bnx2x_virtf *vf,
430 struct bnx2x_queue_init_params *init_params,
431 struct bnx2x_queue_setup_params *setup_params,
432 u16 q_idx, u16 sb_idx);
433
434void bnx2x_vfop_qctor_dump_rx(struct bnx2x *bp, struct bnx2x_virtf *vf,
435 struct bnx2x_queue_init_params *init_params,
436 struct bnx2x_queue_setup_params *setup_params,
437 u16 q_idx, u16 sb_idx);
438
439void bnx2x_vfop_qctor_prep(struct bnx2x *bp,
440 struct bnx2x_virtf *vf,
441 struct bnx2x_vf_queue *q,
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200442 struct bnx2x_vf_queue_construct_params *p,
Ariel Elior8db573b2013-01-01 05:22:37 +0000443 unsigned long q_type);
Ariel Elior954ea742013-01-01 05:22:38 +0000444
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200445int bnx2x_vf_mac_vlan_config_list(struct bnx2x *bp, struct bnx2x_virtf *vf,
446 struct bnx2x_vf_mac_vlan_filters *filters,
447 int qid, bool drv_only);
Ariel Elior954ea742013-01-01 05:22:38 +0000448
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200449int bnx2x_vf_queue_setup(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid,
450 struct bnx2x_vf_queue_construct_params *qctor);
Ariel Elior8db573b2013-01-01 05:22:37 +0000451
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200452int bnx2x_vf_queue_teardown(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid);
Ariel Elior463a68a2013-01-01 05:22:39 +0000453
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200454int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
455 bnx2x_mac_addr_t *mcasts, int mc_num, bool drv_only);
Ariel Elior954ea742013-01-01 05:22:38 +0000456
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200457int bnx2x_vf_rxmode(struct bnx2x *bp, struct bnx2x_virtf *vf,
458 int qid, unsigned long accept_flags);
Ariel Elior954ea742013-01-01 05:22:38 +0000459
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200460int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Elior99e9d212013-01-01 05:22:40 +0000461
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200462int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Eliorf1929b02013-01-01 05:22:41 +0000463
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200464int bnx2x_vf_rss_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
465 struct bnx2x_config_rss_params *rss);
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300466
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200467int bnx2x_vf_tpa_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
468 struct vfpf_tpa_tlv *tlv,
469 struct bnx2x_queue_update_tpa_params *params);
Michal Kalderon14a94eb2014-02-12 18:19:53 +0200470
Ariel Eliorf1929b02013-01-01 05:22:41 +0000471/* VF release ~ VF close + VF release-resources
472 *
473 * Release is the ultimate SW shutdown and is called whenever an
474 * irrecoverable error is encountered.
475 */
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200476int bnx2x_vf_release(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Elior290ca2b2013-01-01 05:22:31 +0000477int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
Ariel Elior8ca5e172013-01-01 05:22:34 +0000478u8 bnx2x_vf_max_queue_cnt(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Eliord16132c2013-01-01 05:22:42 +0000479
480/* FLR routines */
481
Ariel Eliorb56e9672013-01-01 05:22:32 +0000482/* VF FLR helpers */
483int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
484void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
Ariel Eliord16132c2013-01-01 05:22:42 +0000485
486/* Handles an FLR (or VF_DISABLE) notification form the MCP */
487void bnx2x_vf_handle_flr_event(struct bnx2x *bp);
488
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000489bool bnx2x_tlv_supported(u16 tlvtype);
490
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300491u32 bnx2x_crc_vf_bulletin(struct pf_vf_bulletin_content *bulletin);
Ariel Eliorabc5a022013-01-01 05:22:43 +0000492int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf);
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300493void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
494 bool support_long);
Ariel Eliorabc5a022013-01-01 05:22:43 +0000495
Ariel Eliorabc5a022013-01-01 05:22:43 +0000496enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
497
Ariel Elior64112802013-01-07 00:50:23 +0000498/* VF side vfpf channel functions */
499int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
500int bnx2x_vfpf_release(struct bnx2x *bp);
501int bnx2x_vfpf_release(struct bnx2x *bp);
502int bnx2x_vfpf_init(struct bnx2x *bp);
503void bnx2x_vfpf_close_vf(struct bnx2x *bp);
Ariel Elior60cad4e2013-09-04 14:09:22 +0300504int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
505 bool is_leading);
Dmitry Kravkovf8f4f612013-04-24 01:45:00 +0000506int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set);
Ariel Elior60cad4e2013-09-04 14:09:22 +0300507int bnx2x_vfpf_config_rss(struct bnx2x *bp,
508 struct bnx2x_config_rss_params *params);
Ariel Elior64112802013-01-07 00:50:23 +0000509int bnx2x_vfpf_set_mcast(struct net_device *dev);
510int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp);
511
512static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
513 size_t buf_len)
514{
515 strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
516}
517
518static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
519 struct bnx2x_fastpath *fp)
520{
521 return PXP_VF_ADDR_USDM_QUEUES_START +
522 bp->acquire_resp.resc.hw_qid[fp->index] *
523 sizeof(struct ustorm_queue_zone_data);
524}
525
526enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
Yuval Mintz371734882013-06-24 11:04:10 +0300527void bnx2x_timer_sriov(struct bnx2x *bp);
Dmitry Kravkov1d6f3cd2013-03-27 01:05:17 +0000528void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp);
Yuval Mintze2a367f2014-04-24 19:29:52 +0300529void bnx2x_vf_pci_dealloc(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000530int bnx2x_vf_pci_alloc(struct bnx2x *bp);
Ariel Elior3c76fef2013-03-11 05:17:46 +0000531int bnx2x_enable_sriov(struct bnx2x *bp);
532void bnx2x_disable_sriov(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000533static inline int bnx2x_vf_headroom(struct bnx2x *bp)
534{
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300535 return bp->vfdb->sriov.nr_virtfn * BNX2X_CIDS_PER_VF;
Ariel Elior64112802013-01-07 00:50:23 +0000536}
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000537void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
Ariel Elior3c76fef2013-03-11 05:17:46 +0000538int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
Ariel Elior78c3bcc2013-06-20 17:39:08 +0300539void bnx2x_iov_channel_down(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000540
Yuval Mintz370d4a22014-03-23 18:12:24 +0200541void bnx2x_iov_task(struct work_struct *work);
542
543void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag);
544
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300545void bnx2x_iov_link_update(struct bnx2x *bp);
546int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx);
547
548int bnx2x_set_vf_link_state(struct net_device *dev, int vf, int link_state);
549
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300550int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add);
Ariel Elior64112802013-01-07 00:50:23 +0000551#else /* CONFIG_BNX2X_SRIOV */
552
Yuval Mintzce7fa782015-07-30 14:30:29 +0300553#define GET_NUM_VFS_PER_PATH(bp) 0
554#define GET_NUM_VFS_PER_PF(bp) 0
555#define VF_MAC_CREDIT_CNT 0
556#define VF_VLAN_CREDIT_CNT 0
557
Ariel Elior64112802013-01-07 00:50:23 +0000558static inline void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
559 struct bnx2x_queue_sp_obj **q_obj) {}
Ariel Elior64112802013-01-07 00:50:23 +0000560static inline void bnx2x_vf_handle_flr_event(struct bnx2x *bp) {}
561static inline int bnx2x_iov_eq_sp_event(struct bnx2x *bp,
562 union event_ring_elem *elem) {return 1; }
Yuval Mintz370d4a22014-03-23 18:12:24 +0200563static inline void bnx2x_vf_mbx(struct bnx2x *bp) {}
564static inline void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
565 struct vf_pf_event_data *vfpf_event) {}
Ariel Elior64112802013-01-07 00:50:23 +0000566static inline int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line) {return line; }
567static inline void bnx2x_iov_init_dq(struct bnx2x *bp) {}
568static inline int bnx2x_iov_alloc_mem(struct bnx2x *bp) {return 0; }
Yuval Mintz580d9d02013-01-23 03:21:51 +0000569static inline void bnx2x_iov_free_mem(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000570static inline int bnx2x_iov_chip_cleanup(struct bnx2x *bp) {return 0; }
571static inline void bnx2x_iov_init_dmae(struct bnx2x *bp) {}
572static inline int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
573 int num_vfs_param) {return 0; }
574static inline void bnx2x_iov_remove_one(struct bnx2x *bp) {}
Ariel Elior3c76fef2013-03-11 05:17:46 +0000575static inline int bnx2x_enable_sriov(struct bnx2x *bp) {return 0; }
576static inline void bnx2x_disable_sriov(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000577static inline int bnx2x_vfpf_acquire(struct bnx2x *bp,
578 u8 tx_count, u8 rx_count) {return 0; }
579static inline int bnx2x_vfpf_release(struct bnx2x *bp) {return 0; }
580static inline int bnx2x_vfpf_init(struct bnx2x *bp) {return 0; }
581static inline void bnx2x_vfpf_close_vf(struct bnx2x *bp) {}
Ariel Elior60cad4e2013-09-04 14:09:22 +0300582static inline int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool is_leading) {return 0; }
Dmitry Kravkovf8f4f612013-04-24 01:45:00 +0000583static inline int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr,
584 u8 vf_qid, bool set) {return 0; }
Dmitry Kravkov9b0be652013-09-06 10:35:28 +0300585static inline int bnx2x_vfpf_config_rss(struct bnx2x *bp,
586 struct bnx2x_config_rss_params *params) {return 0; }
Ariel Elior64112802013-01-07 00:50:23 +0000587static inline int bnx2x_vfpf_set_mcast(struct net_device *dev) {return 0; }
588static inline int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp) {return 0; }
589static inline int bnx2x_iov_nic_init(struct bnx2x *bp) {return 0; }
590static inline int bnx2x_vf_headroom(struct bnx2x *bp) {return 0; }
591static inline void bnx2x_iov_adjust_stats_req(struct bnx2x *bp) {}
592static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
593 size_t buf_len) {}
594static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
595 struct bnx2x_fastpath *fp) {return 0; }
596static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp)
597{
598 return PFVF_BULLETIN_UNCHANGED;
599}
Yuval Mintz371734882013-06-24 11:04:10 +0300600static inline void bnx2x_timer_sriov(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000601
Dmitry Kravkov1d6f3cd2013-03-27 01:05:17 +0000602static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
603{
604 return NULL;
605}
606
Randy Dunlap62555582014-05-10 11:33:54 -0700607static inline void bnx2x_vf_pci_dealloc(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000608static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000609static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
Ariel Elior3c76fef2013-03-11 05:17:46 +0000610static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
Ariel Elior78c3bcc2013-06-20 17:39:08 +0300611static inline void bnx2x_iov_channel_down(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000612
Yuval Mintz370d4a22014-03-23 18:12:24 +0200613static inline void bnx2x_iov_task(struct work_struct *work) {}
Yuval Mintz19915f52014-03-26 09:06:29 +0200614static inline void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag) {}
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300615static inline void bnx2x_iov_link_update(struct bnx2x *bp) {}
616static inline int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx) {return 0; }
617
618static inline int bnx2x_set_vf_link_state(struct net_device *dev, int vf,
619 int link_state) {return 0; }
620struct pf_vf_bulletin_content;
621static inline void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
622 bool support_long) {}
Yuval Mintz370d4a22014-03-23 18:12:24 +0200623
Yuval Mintz05cc5a32015-07-29 15:52:46 +0300624static inline int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add) {return 0; }
625
Ariel Elior64112802013-01-07 00:50:23 +0000626#endif /* CONFIG_BNX2X_SRIOV */
Ariel Elior1ab44342013-01-01 05:22:23 +0000627#endif /* bnx2x_sriov.h */