GNU Linux-libre 4.19.281-gnu1
[releases.git] / drivers / net / ethernet / broadcom / bnx2x / bnx2x_sriov.h
1 /* bnx2x_sriov.h: QLogic Everest network driver.
2  *
3  * Copyright 2009-2013 Broadcom Corporation
4  * Copyright 2014 QLogic Corporation
5  * All rights reserved
6  *
7  * Unless you and QLogic execute a separate written software license
8  * 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
13  * software in any way with any other QLogic software provided under a
14  * license other than the GPL, without QLogic's express prior written
15  * consent.
16  *
17  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
18  * Written by: Shmulik Ravid
19  *             Ariel Elior <ariel.elior@qlogic.com>
20  */
21 #ifndef BNX2X_SRIOV_H
22 #define BNX2X_SRIOV_H
23
24 #include "bnx2x_vfpf.h"
25 #include "bnx2x.h"
26
27 enum sample_bulletin_result {
28            PFVF_BULLETIN_UNCHANGED,
29            PFVF_BULLETIN_UPDATED,
30            PFVF_BULLETIN_CRC_ERR
31 };
32
33 #ifdef CONFIG_BNX2X_SRIOV
34
35 extern struct workqueue_struct *bnx2x_iov_wq;
36
37 /* The bnx2x device structure holds vfdb structure described below.
38  * The VF array is indexed by the relative vfid.
39  */
40 #define BNX2X_VF_MAX_QUEUES             16
41 #define BNX2X_VF_MAX_TPA_AGG_QUEUES     8
42
43 struct 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 */
61 struct bnx2x_vf_bar {
62         u64 bar;
63         u32 size;
64 };
65
66 struct bnx2x_vf_bar_info {
67         struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
68         u8 nr_bars;
69 };
70
71 /* vf queue (used both for rx or tx) */
72 struct 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;
80
81         /* VLAN-MACs object */
82         struct bnx2x_vlan_mac_obj       vlan_mac_obj;
83
84         unsigned long accept_flags;     /* last accept flags configured */
85
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;
92         bool is_leading;
93         bool sp_initialized;
94 };
95
96 /* struct bnx2x_vf_queue_construct_params - prepare queue construction
97  * parameters: q-init, q-setup and SB index
98  */
99 struct bnx2x_vf_queue_construct_params {
100         struct bnx2x_queue_state_params         qstate;
101         struct bnx2x_queue_setup_params         prep_qsetup;
102 };
103
104 /* forward */
105 struct bnx2x_virtf;
106
107 /* VFOP definitions */
108
109 struct bnx2x_vf_mac_vlan_filter {
110         int type;
111 #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*/
115
116         bool add;
117         bool applied;
118         u8 *mac;
119         u16 vid;
120 };
121
122 struct bnx2x_vf_mac_vlan_filters {
123         int count;
124         struct bnx2x_vf_mac_vlan_filter filters[];
125 };
126
127 /* vf context */
128 struct bnx2x_virtf {
129         u16 cfg_flags;
130 #define VF_CFG_STATS_COALESCE   0x1
131 #define VF_CFG_EXT_BULLETIN     0x2
132 #define VF_CFG_VLAN_FILTER      0x4
133         u8 link_cfg;            /* IFLA_VF_LINK_STATE_AUTO
134                                  * IFLA_VF_LINK_STATE_ENABLE
135                                  * IFLA_VF_LINK_STATE_DISABLE
136                                  */
137         u8 state;
138 #define VF_FREE         0       /* VF ready to be acquired holds no resc */
139 #define VF_ACQUIRED     1       /* VF acquired, but not initialized */
140 #define VF_ENABLED      2       /* VF Enabled */
141 #define VF_RESET        3       /* VF FLR'd, pending cleanup */
142 #define VF_LOST         4       /* Recovery while VFs are loaded */
143
144         bool flr_clnup_stage;   /* true during flr cleanup */
145         bool malicious;         /* true if FW indicated so, until FLR */
146
147         /* dma */
148         dma_addr_t fw_stat_map;
149         u16 stats_stride;
150         dma_addr_t bulletin_map;
151
152         /* Allocated resources counters. Before the VF is acquired, the
153          * counters hold the following values:
154          *
155          * - xxq_count = 0 as the queues memory is not allocated yet.
156          *
157          * - sb_count  = The number of status blocks configured for this VF in
158          *               the IGU CAM. Initially read during probe.
159          *
160          * - xx_rules_count = The number of rules statically and equally
161          *                    allocated for each VF, during PF load.
162          */
163         struct vf_pf_resc_request       alloc_resc;
164 #define vf_rxq_count(vf)                ((vf)->alloc_resc.num_rxqs)
165 #define vf_txq_count(vf)                ((vf)->alloc_resc.num_txqs)
166 #define vf_sb_count(vf)                 ((vf)->alloc_resc.num_sbs)
167 #define vf_mac_rules_cnt(vf)            ((vf)->alloc_resc.num_mac_filters)
168 #define vf_vlan_rules_cnt(vf)           ((vf)->alloc_resc.num_vlan_filters)
169 #define vf_mc_rules_cnt(vf)             ((vf)->alloc_resc.num_mc_filters)
170
171         u8 sb_count;    /* actual number of SBs */
172         u8 igu_base_id; /* base igu status block id */
173
174         struct bnx2x_vf_queue   *vfqs;
175 #define LEADING_IDX                     0
176 #define bnx2x_vfq_is_leading(vfq)       ((vfq)->index == LEADING_IDX)
177 #define bnx2x_vfq(vf, nr, var)          ((vf)->vfqs[(nr)].var)
178 #define bnx2x_leading_vfq(vf, var)      ((vf)->vfqs[LEADING_IDX].var)
179
180         u8 index;       /* index in the vf array */
181         u8 abs_vfid;
182         u8 sp_cl_id;
183         u32 error;      /* 0 means all's-well */
184
185         /* BDF */
186         unsigned int domain;
187         unsigned int bus;
188         unsigned int devfn;
189
190         /* bars */
191         struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
192
193         /* set-mac ramrod state 1-pending, 0-done */
194         unsigned long   filter_state;
195
196         /* leading rss client id ~~ the client id of the first rxq, must be
197          * set for each txq.
198          */
199         int leading_rss;
200
201         /* MCAST object */
202         struct bnx2x_mcast_obj          mcast_obj;
203
204         /* RSS configuration object */
205         struct bnx2x_rss_config_obj     rss_conf_obj;
206
207         /* slow-path operations */
208         struct mutex                    op_mutex; /* one vfop at a time mutex */
209         enum channel_tlvs               op_current;
210
211         u8 fp_hsi;
212
213         struct bnx2x_credit_pool_obj    vf_vlans_pool;
214         struct bnx2x_credit_pool_obj    vf_macs_pool;
215 };
216
217 #define BNX2X_NR_VIRTFN(bp)     ((bp)->vfdb->sriov.nr_virtfn)
218
219 #define for_each_vf(bp, var) \
220                 for ((var) = 0; (var) < BNX2X_NR_VIRTFN(bp); (var)++)
221
222 #define for_each_vfq(vf, var) \
223                 for ((var) = 0; (var) < vf_rxq_count(vf); (var)++)
224
225 #define for_each_vf_sb(vf, var) \
226                 for ((var) = 0; (var) < vf_sb_count(vf); (var)++)
227
228 #define is_vf_multi(vf) (vf_rxq_count(vf) > 1)
229
230 #define HW_VF_HANDLE(bp, abs_vfid) \
231         (u16)(BP_ABS_FUNC((bp)) | (1<<3) |  ((u16)(abs_vfid) << 4))
232
233 #define FW_PF_MAX_HANDLE        8
234
235 #define FW_VF_HANDLE(abs_vfid)  \
236         (abs_vfid + FW_PF_MAX_HANDLE)
237
238 #define GET_NUM_VFS_PER_PATH(bp)        64 /* use max possible value */
239 #define GET_NUM_VFS_PER_PF(bp)          ((bp)->vfdb ? (bp)->vfdb->sriov.total \
240                                                     : 0)
241 #define VF_MAC_CREDIT_CNT               1
242 #define VF_VLAN_CREDIT_CNT              2 /* VLAN0 + 'real' VLAN */
243
244 /* locking and unlocking the channel mutex */
245 void bnx2x_lock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
246                               enum channel_tlvs tlv);
247
248 void bnx2x_unlock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
249                                 enum channel_tlvs expected_tlv);
250
251 /* VF mail box (aka vf-pf channel) */
252
253 /* a container for the bi-directional vf<-->pf messages.
254  *  The actual response will be placed according to the offset parameter
255  *  provided in the request
256  */
257
258 #define MBX_MSG_ALIGN   8
259 #define MBX_MSG_ALIGNED_SIZE    (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
260                                 MBX_MSG_ALIGN))
261
262 struct bnx2x_vf_mbx_msg {
263         union vfpf_tlvs req;
264         union pfvf_tlvs resp;
265 };
266
267 struct bnx2x_vf_mbx {
268         struct bnx2x_vf_mbx_msg *msg;
269         dma_addr_t msg_mapping;
270
271         /* VF GPA address */
272         u32 vf_addr_lo;
273         u32 vf_addr_hi;
274
275         struct vfpf_first_tlv first_tlv;        /* saved VF request header */
276 };
277
278 struct bnx2x_vf_sp {
279         union {
280                 struct eth_classify_rules_ramrod_data   e2;
281         } mac_rdata;
282
283         union {
284                 struct eth_classify_rules_ramrod_data   e2;
285         } vlan_rdata;
286
287         union {
288                 struct eth_classify_rules_ramrod_data   e2;
289         } vlan_mac_rdata;
290
291         union {
292                 struct eth_filter_rules_ramrod_data     e2;
293         } rx_mode_rdata;
294
295         union {
296                 struct eth_multicast_rules_ramrod_data  e2;
297         } mcast_rdata;
298
299         union {
300                 struct client_init_ramrod_data  init_data;
301                 struct client_update_ramrod_data update_data;
302         } q_data;
303
304         union {
305                 struct eth_rss_update_ramrod_data e2;
306         } rss_rdata;
307 };
308
309 struct hw_dma {
310         void *addr;
311         dma_addr_t mapping;
312         size_t size;
313 };
314
315 struct bnx2x_vfdb {
316 #define BP_VFDB(bp)             ((bp)->vfdb)
317         /* vf array */
318         struct bnx2x_virtf      *vfs;
319 #define BP_VF(bp, idx)          ((BP_VFDB(bp) && (bp)->vfdb->vfs) ? \
320                                         &((bp)->vfdb->vfs[idx]) : NULL)
321 #define bnx2x_vf(bp, idx, var)  ((bp)->vfdb->vfs[idx].var)
322
323         /* queue array - for all vfs */
324         struct bnx2x_vf_queue *vfqs;
325
326         /* vf HW contexts */
327         struct hw_dma           context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
328 #define BP_VF_CXT_PAGE(bp, i)   (&(bp)->vfdb->context[i])
329
330         /* SR-IOV information */
331         struct bnx2x_sriov      sriov;
332         struct hw_dma           mbx_dma;
333 #define BP_VF_MBX_DMA(bp)       (&((bp)->vfdb->mbx_dma))
334         struct bnx2x_vf_mbx     mbxs[BNX2X_MAX_NUM_OF_VFS];
335 #define BP_VF_MBX(bp, vfid)     (&((bp)->vfdb->mbxs[vfid]))
336
337         struct hw_dma           bulletin_dma;
338 #define BP_VF_BULLETIN_DMA(bp)  (&((bp)->vfdb->bulletin_dma))
339 #define BP_VF_BULLETIN(bp, vf) \
340         (((struct pf_vf_bulletin_content *)(BP_VF_BULLETIN_DMA(bp)->addr)) \
341          + (vf))
342
343         struct hw_dma           sp_dma;
344 #define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr +           \
345                 (vf)->index * sizeof(struct bnx2x_vf_sp) +              \
346                 offsetof(struct bnx2x_vf_sp, field))
347 #define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping +    \
348                 (vf)->index * sizeof(struct bnx2x_vf_sp) +              \
349                 offsetof(struct bnx2x_vf_sp, field))
350
351 #define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
352         u32 flrd_vfs[FLRD_VFS_DWORDS];
353
354         /* the number of msix vectors belonging to this PF designated for VFs */
355         u16 vf_sbs_pool;
356         u16 first_vf_igu_entry;
357
358         /* sp_rtnl synchronization */
359         struct mutex                    event_mutex;
360         u64                             event_occur;
361
362         /* bulletin board update synchronization */
363         struct mutex                    bulletin_mutex;
364 };
365
366 /* queue access */
367 static inline struct bnx2x_vf_queue *vfq_get(struct bnx2x_virtf *vf, u8 index)
368 {
369         return &(vf->vfqs[index]);
370 }
371
372 /* FW ids */
373 static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
374 {
375         return vf->igu_base_id + sb_idx;
376 }
377
378 static inline u8 vf_hc_qzone(struct bnx2x_virtf *vf, u16 sb_idx)
379 {
380         return vf_igu_sb(vf, sb_idx);
381 }
382
383 static u8 vfq_cl_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
384 {
385         return vf->igu_base_id + q->index;
386 }
387
388 static inline u8 vfq_stat_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
389 {
390         if (vf->cfg_flags & VF_CFG_STATS_COALESCE)
391                 return vf->leading_rss;
392         else
393                 return vfq_cl_id(vf, q);
394 }
395
396 static inline u8 vfq_qzone_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
397 {
398         return vfq_cl_id(vf, q);
399 }
400
401 /* global iov routines */
402 int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
403 int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
404 void bnx2x_iov_remove_one(struct bnx2x *bp);
405 void bnx2x_iov_free_mem(struct bnx2x *bp);
406 int bnx2x_iov_alloc_mem(struct bnx2x *bp);
407 int bnx2x_iov_nic_init(struct bnx2x *bp);
408 int bnx2x_iov_chip_cleanup(struct bnx2x *bp);
409 void bnx2x_iov_init_dq(struct bnx2x *bp);
410 void bnx2x_iov_init_dmae(struct bnx2x *bp);
411 void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
412                                 struct bnx2x_queue_sp_obj **q_obj);
413 int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem);
414 void bnx2x_iov_adjust_stats_req(struct bnx2x *bp);
415 void bnx2x_iov_storm_stats_update(struct bnx2x *bp);
416 /* global vf mailbox routines */
417 void bnx2x_vf_mbx(struct bnx2x *bp);
418 void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
419                            struct vf_pf_event_data *vfpf_event);
420 void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
421
422 /* CORE VF API */
423 typedef u8 bnx2x_mac_addr_t[ETH_ALEN];
424
425 /* acquire */
426 int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
427                      struct vf_pf_resc_request *resc);
428 /* init */
429 int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
430                   dma_addr_t *sb_map);
431
432 /* VFOP queue construction helpers */
433 void bnx2x_vfop_qctor_dump_tx(struct bnx2x *bp, struct bnx2x_virtf *vf,
434                             struct bnx2x_queue_init_params *init_params,
435                             struct bnx2x_queue_setup_params *setup_params,
436                             u16 q_idx, u16 sb_idx);
437
438 void bnx2x_vfop_qctor_dump_rx(struct bnx2x *bp, struct bnx2x_virtf *vf,
439                             struct bnx2x_queue_init_params *init_params,
440                             struct bnx2x_queue_setup_params *setup_params,
441                             u16 q_idx, u16 sb_idx);
442
443 void bnx2x_vfop_qctor_prep(struct bnx2x *bp,
444                            struct bnx2x_virtf *vf,
445                            struct bnx2x_vf_queue *q,
446                            struct bnx2x_vf_queue_construct_params *p,
447                            unsigned long q_type);
448
449 int bnx2x_vf_mac_vlan_config_list(struct bnx2x *bp, struct bnx2x_virtf *vf,
450                                   struct bnx2x_vf_mac_vlan_filters *filters,
451                                   int qid, bool drv_only);
452
453 int bnx2x_vf_queue_setup(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid,
454                          struct bnx2x_vf_queue_construct_params *qctor);
455
456 int bnx2x_vf_queue_teardown(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid);
457
458 int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
459                    bnx2x_mac_addr_t *mcasts, int mc_num, bool drv_only);
460
461 int bnx2x_vf_rxmode(struct bnx2x *bp, struct bnx2x_virtf *vf,
462                     int qid, unsigned long accept_flags);
463
464 int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf);
465
466 int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf);
467
468 int bnx2x_vf_rss_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
469                         struct bnx2x_config_rss_params *rss);
470
471 int bnx2x_vf_tpa_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
472                         struct vfpf_tpa_tlv *tlv,
473                         struct bnx2x_queue_update_tpa_params *params);
474
475 /* VF release ~ VF close + VF release-resources
476  *
477  * Release is the ultimate SW shutdown and is called whenever an
478  * irrecoverable error is encountered.
479  */
480 int bnx2x_vf_release(struct bnx2x *bp, struct bnx2x_virtf *vf);
481 int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
482 u8 bnx2x_vf_max_queue_cnt(struct bnx2x *bp, struct bnx2x_virtf *vf);
483
484 /* FLR routines */
485
486 /* VF FLR helpers */
487 int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
488 void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
489
490 /* Handles an FLR (or VF_DISABLE) notification form the MCP */
491 void bnx2x_vf_handle_flr_event(struct bnx2x *bp);
492
493 bool bnx2x_tlv_supported(u16 tlvtype);
494
495 u32 bnx2x_crc_vf_bulletin(struct pf_vf_bulletin_content *bulletin);
496 int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf);
497 void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
498                                 bool support_long);
499
500 enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
501
502 /* VF side vfpf channel functions */
503 int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
504 int bnx2x_vfpf_release(struct bnx2x *bp);
505 int bnx2x_vfpf_release(struct bnx2x *bp);
506 int bnx2x_vfpf_init(struct bnx2x *bp);
507 void bnx2x_vfpf_close_vf(struct bnx2x *bp);
508 int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
509                        bool is_leading);
510 int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set);
511 int bnx2x_vfpf_config_rss(struct bnx2x *bp,
512                           struct bnx2x_config_rss_params *params);
513 int bnx2x_vfpf_set_mcast(struct net_device *dev);
514 int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp);
515
516 static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
517                                         size_t buf_len)
518 {
519         strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
520 }
521
522 static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
523                                                struct bnx2x_fastpath *fp)
524 {
525         return PXP_VF_ADDR_USDM_QUEUES_START +
526                 bp->acquire_resp.resc.hw_qid[fp->index] *
527                 sizeof(struct ustorm_queue_zone_data);
528 }
529
530 enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
531 void bnx2x_timer_sriov(struct bnx2x *bp);
532 void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp);
533 void bnx2x_vf_pci_dealloc(struct bnx2x *bp);
534 int bnx2x_vf_pci_alloc(struct bnx2x *bp);
535 int bnx2x_enable_sriov(struct bnx2x *bp);
536 void bnx2x_disable_sriov(struct bnx2x *bp);
537 static inline int bnx2x_vf_headroom(struct bnx2x *bp)
538 {
539         return bp->vfdb->sriov.nr_virtfn * BNX2X_CIDS_PER_VF;
540 }
541 void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
542 int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
543 void bnx2x_iov_channel_down(struct bnx2x *bp);
544
545 void bnx2x_iov_task(struct work_struct *work);
546
547 void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag);
548
549 void bnx2x_iov_link_update(struct bnx2x *bp);
550 int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx);
551
552 int bnx2x_set_vf_link_state(struct net_device *dev, int vf, int link_state);
553
554 int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add);
555 #else /* CONFIG_BNX2X_SRIOV */
556
557 #define GET_NUM_VFS_PER_PATH(bp)        0
558 #define GET_NUM_VFS_PER_PF(bp)          0
559 #define VF_MAC_CREDIT_CNT               0
560 #define VF_VLAN_CREDIT_CNT              0
561
562 static inline void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
563                                 struct bnx2x_queue_sp_obj **q_obj) {}
564 static inline void bnx2x_vf_handle_flr_event(struct bnx2x *bp) {}
565 static inline int bnx2x_iov_eq_sp_event(struct bnx2x *bp,
566                                         union event_ring_elem *elem) {return 1; }
567 static inline void bnx2x_vf_mbx(struct bnx2x *bp) {}
568 static inline void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
569                                          struct vf_pf_event_data *vfpf_event) {}
570 static inline int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line) {return line; }
571 static inline void bnx2x_iov_init_dq(struct bnx2x *bp) {}
572 static inline int bnx2x_iov_alloc_mem(struct bnx2x *bp) {return 0; }
573 static inline void bnx2x_iov_free_mem(struct bnx2x *bp) {}
574 static inline int bnx2x_iov_chip_cleanup(struct bnx2x *bp) {return 0; }
575 static inline void bnx2x_iov_init_dmae(struct bnx2x *bp) {}
576 static inline int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
577                                      int num_vfs_param) {return 0; }
578 static inline void bnx2x_iov_remove_one(struct bnx2x *bp) {}
579 static inline int bnx2x_enable_sriov(struct bnx2x *bp) {return 0; }
580 static inline void bnx2x_disable_sriov(struct bnx2x *bp) {}
581 static inline int bnx2x_vfpf_acquire(struct bnx2x *bp,
582                                      u8 tx_count, u8 rx_count) {return 0; }
583 static inline int bnx2x_vfpf_release(struct bnx2x *bp) {return 0; }
584 static inline int bnx2x_vfpf_init(struct bnx2x *bp) {return 0; }
585 static inline void bnx2x_vfpf_close_vf(struct bnx2x *bp) {}
586 static inline int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool is_leading) {return 0; }
587 static inline int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr,
588                                         u8 vf_qid, bool set) {return 0; }
589 static inline int bnx2x_vfpf_config_rss(struct bnx2x *bp,
590                                         struct bnx2x_config_rss_params *params) {return 0; }
591 static inline int bnx2x_vfpf_set_mcast(struct net_device *dev) {return 0; }
592 static inline int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp) {return 0; }
593 static inline int bnx2x_iov_nic_init(struct bnx2x *bp) {return 0; }
594 static inline int bnx2x_vf_headroom(struct bnx2x *bp) {return 0; }
595 static inline void bnx2x_iov_adjust_stats_req(struct bnx2x *bp) {}
596 static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
597                                         size_t buf_len) {}
598 static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
599                                                struct bnx2x_fastpath *fp) {return 0; }
600 static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp)
601 {
602         return PFVF_BULLETIN_UNCHANGED;
603 }
604 static inline void bnx2x_timer_sriov(struct bnx2x *bp) {}
605
606 static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
607 {
608         return NULL;
609 }
610
611 static inline void bnx2x_vf_pci_dealloc(struct bnx2x *bp) {}
612 static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
613 static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
614 static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
615 static inline void bnx2x_iov_channel_down(struct bnx2x *bp) {}
616
617 static inline void bnx2x_iov_task(struct work_struct *work) {}
618 static inline void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag) {}
619 static inline void bnx2x_iov_link_update(struct bnx2x *bp) {}
620 static inline int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx) {return 0; }
621
622 static inline int bnx2x_set_vf_link_state(struct net_device *dev, int vf,
623                                           int link_state) {return 0; }
624 struct pf_vf_bulletin_content;
625 static inline void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
626                                               bool support_long) {}
627
628 static inline int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add) {return 0; }
629
630 #endif /* CONFIG_BNX2X_SRIOV */
631 #endif /* bnx2x_sriov.h */