blob: 2011205ec8d467afc048dda44bcc72b6a191b452 [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;
80 atomic_t vlan_count; /* 0 means vlan-0 is set ~ untagged */
Yuval Mintze8379c72014-01-05 18:33:54 +020081 unsigned long accept_flags; /* last accept flags configured */
Ariel Elior290ca2b2013-01-01 05:22:31 +000082
83 /* Queue Slow-path State object */
84 struct bnx2x_queue_sp_obj sp_obj;
85
86 u32 cid;
87 u16 index;
88 u16 sb_idx;
Ariel Eliorb9871bc2013-09-04 14:09:21 +030089 bool is_leading;
Yuval Mintz3a3534e2014-02-12 18:19:54 +020090 bool sp_initialized;
Ariel Elior290ca2b2013-01-01 05:22:31 +000091};
92
Yuval Mintz2dc33bb2014-03-23 18:12:25 +020093/* struct bnx2x_vf_queue_construct_params - prepare queue construction
94 * parameters: q-init, q-setup and SB index
Ariel Elior290ca2b2013-01-01 05:22:31 +000095 */
Yuval Mintz2dc33bb2014-03-23 18:12:25 +020096struct bnx2x_vf_queue_construct_params {
Ariel Elior290ca2b2013-01-01 05:22:31 +000097 struct bnx2x_queue_state_params qstate;
98 struct bnx2x_queue_setup_params prep_qsetup;
99};
100
Ariel Elior290ca2b2013-01-01 05:22:31 +0000101/* forward */
102struct bnx2x_virtf;
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000103
104/* VFOP definitions */
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000105
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200106struct bnx2x_vf_mac_vlan_filter {
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000107 int type;
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200108#define BNX2X_VF_FILTER_MAC 1
109#define BNX2X_VF_FILTER_VLAN 2
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000110
111 bool add;
112 u8 *mac;
113 u16 vid;
114};
115
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200116struct bnx2x_vf_mac_vlan_filters {
117 int count;
118 struct bnx2x_vf_mac_vlan_filter filters[];
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000119};
120
Ariel Elior290ca2b2013-01-01 05:22:31 +0000121/* vf context */
122struct bnx2x_virtf {
123 u16 cfg_flags;
124#define VF_CFG_STATS 0x0001
125#define VF_CFG_FW_FC 0x0002
126#define VF_CFG_TPA 0x0004
127#define VF_CFG_INT_SIMD 0x0008
128#define VF_CACHE_LINE 0x0010
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000129#define VF_CFG_VLAN 0x0020
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300130#define VF_CFG_STATS_COALESCE 0x0040
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300131#define VF_CFG_EXT_BULLETIN 0x0080
132 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 */
145 dma_addr_t fw_stat_map; /* valid iff VF_CFG_STATS */
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300146 u16 stats_stride;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000147 dma_addr_t spq_map;
148 dma_addr_t bulletin_map;
149
150 /* Allocated resources counters. Before the VF is acquired, the
151 * counters hold the following values:
152 *
153 * - xxq_count = 0 as the queues memory is not allocated yet.
154 *
155 * - sb_count = The number of status blocks configured for this VF in
156 * the IGU CAM. Initially read during probe.
157 *
158 * - xx_rules_count = The number of rules statically and equally
159 * allocated for each VF, during PF load.
160 */
161 struct vf_pf_resc_request alloc_resc;
162#define vf_rxq_count(vf) ((vf)->alloc_resc.num_rxqs)
163#define vf_txq_count(vf) ((vf)->alloc_resc.num_txqs)
164#define vf_sb_count(vf) ((vf)->alloc_resc.num_sbs)
165#define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
166#define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
167#define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
Yuval Mintz1a3d9422014-04-24 19:29:53 +0300168 /* Hide a single vlan filter credit for the hypervisor */
169#define vf_vlan_rules_visible_cnt(vf) (vf_vlan_rules_cnt(vf) - 1)
Ariel Elior290ca2b2013-01-01 05:22:31 +0000170
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;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300175#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)
Ariel Elior290ca2b2013-01-01 05:22:31 +0000179
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 bus;
187 unsigned int devfn;
188
189 /* bars */
190 struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
191
192 /* set-mac ramrod state 1-pending, 0-done */
193 unsigned long filter_state;
194
195 /* leading rss client id ~~ the client id of the first rxq, must be
196 * set for each txq.
197 */
198 int leading_rss;
199
200 /* MCAST object */
Yuval Mintz858f4de2013-12-26 09:57:12 +0200201 int mcast_list_len;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000202 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 */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000208 struct mutex op_mutex; /* one vfop at a time mutex */
209 enum channel_tlvs op_current;
Yuval Mintz02dc4022014-12-04 12:52:06 +0200210
211 u8 fp_hsi;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000212};
213
214#define BNX2X_NR_VIRTFN(bp) ((bp)->vfdb->sriov.nr_virtfn)
215
216#define for_each_vf(bp, var) \
217 for ((var) = 0; (var) < BNX2X_NR_VIRTFN(bp); (var)++)
218
Ariel Elior8ca5e172013-01-01 05:22:34 +0000219#define for_each_vfq(vf, var) \
220 for ((var) = 0; (var) < vf_rxq_count(vf); (var)++)
221
222#define for_each_vf_sb(vf, var) \
223 for ((var) = 0; (var) < vf_sb_count(vf); (var)++)
224
Ariel Eliorb93288d2013-01-01 05:22:35 +0000225#define is_vf_multi(vf) (vf_rxq_count(vf) > 1)
226
Ariel Eliorb56e9672013-01-01 05:22:32 +0000227#define HW_VF_HANDLE(bp, abs_vfid) \
228 (u16)(BP_ABS_FUNC((bp)) | (1<<3) | ((u16)(abs_vfid) << 4))
229
230#define FW_PF_MAX_HANDLE 8
231
232#define FW_VF_HANDLE(abs_vfid) \
233 (abs_vfid + FW_PF_MAX_HANDLE)
234
Ariel Elior8ca5e172013-01-01 05:22:34 +0000235/* locking and unlocking the channel mutex */
236void bnx2x_lock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
237 enum channel_tlvs tlv);
238
239void bnx2x_unlock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
240 enum channel_tlvs expected_tlv);
241
Ariel Eliorb56e9672013-01-01 05:22:32 +0000242/* VF mail box (aka vf-pf channel) */
243
244/* a container for the bi-directional vf<-->pf messages.
245 * The actual response will be placed according to the offset parameter
246 * provided in the request
247 */
248
249#define MBX_MSG_ALIGN 8
250#define MBX_MSG_ALIGNED_SIZE (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
251 MBX_MSG_ALIGN))
252
Ariel Elior1ab44342013-01-01 05:22:23 +0000253struct bnx2x_vf_mbx_msg {
254 union vfpf_tlvs req;
255 union pfvf_tlvs resp;
256};
257
Ariel Elior290ca2b2013-01-01 05:22:31 +0000258struct bnx2x_vf_mbx {
259 struct bnx2x_vf_mbx_msg *msg;
260 dma_addr_t msg_mapping;
261
262 /* VF GPA address */
263 u32 vf_addr_lo;
264 u32 vf_addr_hi;
265
266 struct vfpf_first_tlv first_tlv; /* saved VF request header */
Ariel Elior290ca2b2013-01-01 05:22:31 +0000267};
268
Ariel Eliorb56e9672013-01-01 05:22:32 +0000269struct bnx2x_vf_sp {
270 union {
271 struct eth_classify_rules_ramrod_data e2;
272 } mac_rdata;
273
274 union {
275 struct eth_classify_rules_ramrod_data e2;
276 } vlan_rdata;
277
278 union {
279 struct eth_filter_rules_ramrod_data e2;
280 } rx_mode_rdata;
281
282 union {
283 struct eth_multicast_rules_ramrod_data e2;
284 } mcast_rdata;
285
286 union {
287 struct client_init_ramrod_data init_data;
288 struct client_update_ramrod_data update_data;
289 } q_data;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300290
291 union {
292 struct eth_rss_update_ramrod_data e2;
293 } rss_rdata;
Ariel Eliorb56e9672013-01-01 05:22:32 +0000294};
295
Ariel Elior290ca2b2013-01-01 05:22:31 +0000296struct hw_dma {
297 void *addr;
298 dma_addr_t mapping;
299 size_t size;
300};
301
302struct bnx2x_vfdb {
303#define BP_VFDB(bp) ((bp)->vfdb)
304 /* vf array */
305 struct bnx2x_virtf *vfs;
Yuval Mintz58fee002014-08-17 16:47:50 +0300306#define BP_VF(bp, idx) ((BP_VFDB(bp) && (bp)->vfdb->vfs) ? \
307 &((bp)->vfdb->vfs[idx]) : NULL)
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300308#define bnx2x_vf(bp, idx, var) ((bp)->vfdb->vfs[idx].var)
Ariel Elior290ca2b2013-01-01 05:22:31 +0000309
310 /* queue array - for all vfs */
311 struct bnx2x_vf_queue *vfqs;
312
313 /* vf HW contexts */
314 struct hw_dma context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300315#define BP_VF_CXT_PAGE(bp, i) (&(bp)->vfdb->context[i])
Ariel Elior290ca2b2013-01-01 05:22:31 +0000316
317 /* SR-IOV information */
318 struct bnx2x_sriov sriov;
319 struct hw_dma mbx_dma;
320#define BP_VF_MBX_DMA(bp) (&((bp)->vfdb->mbx_dma))
321 struct bnx2x_vf_mbx mbxs[BNX2X_MAX_NUM_OF_VFS];
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300322#define BP_VF_MBX(bp, vfid) (&((bp)->vfdb->mbxs[vfid]))
Ariel Elior290ca2b2013-01-01 05:22:31 +0000323
Ariel Eliorabc5a022013-01-01 05:22:43 +0000324 struct hw_dma bulletin_dma;
325#define BP_VF_BULLETIN_DMA(bp) (&((bp)->vfdb->bulletin_dma))
326#define BP_VF_BULLETIN(bp, vf) \
327 (((struct pf_vf_bulletin_content *)(BP_VF_BULLETIN_DMA(bp)->addr)) \
328 + (vf))
329
Ariel Elior290ca2b2013-01-01 05:22:31 +0000330 struct hw_dma sp_dma;
331#define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr + \
332 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
333 offsetof(struct bnx2x_vf_sp, field))
334#define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping + \
335 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
336 offsetof(struct bnx2x_vf_sp, field))
337
338#define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
339 u32 flrd_vfs[FLRD_VFS_DWORDS];
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300340
341 /* the number of msix vectors belonging to this PF designated for VFs */
342 u16 vf_sbs_pool;
343 u16 first_vf_igu_entry;
Yuval Mintz370d4a22014-03-23 18:12:24 +0200344
345 /* sp_rtnl synchronization */
346 struct mutex event_mutex;
347 u64 event_occur;
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300348
349 /* bulletin board update synchronization */
350 struct mutex bulletin_mutex;
Ariel Elior290ca2b2013-01-01 05:22:31 +0000351};
352
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000353/* queue access */
354static inline struct bnx2x_vf_queue *vfq_get(struct bnx2x_virtf *vf, u8 index)
355{
356 return &(vf->vfqs[index]);
357}
358
Ariel Elior8ca5e172013-01-01 05:22:34 +0000359/* FW ids */
Ariel Eliorb56e9672013-01-01 05:22:32 +0000360static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
361{
362 return vf->igu_base_id + sb_idx;
363}
364
Ariel Elior8ca5e172013-01-01 05:22:34 +0000365static inline u8 vf_hc_qzone(struct bnx2x_virtf *vf, u16 sb_idx)
366{
367 return vf_igu_sb(vf, sb_idx);
368}
369
370static u8 vfq_cl_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
371{
372 return vf->igu_base_id + q->index;
373}
374
Ariel Elior8db573b2013-01-01 05:22:37 +0000375static inline u8 vfq_stat_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
376{
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300377 if (vf->cfg_flags & VF_CFG_STATS_COALESCE)
378 return vf->leading_rss;
379 else
380 return vfq_cl_id(vf, q);
Ariel Elior8db573b2013-01-01 05:22:37 +0000381}
382
Ariel Elior8ca5e172013-01-01 05:22:34 +0000383static inline u8 vfq_qzone_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
384{
385 return vfq_cl_id(vf, q);
386}
387
Ariel Elior290ca2b2013-01-01 05:22:31 +0000388/* global iov routines */
389int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
390int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
391void bnx2x_iov_remove_one(struct bnx2x *bp);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000392void bnx2x_iov_free_mem(struct bnx2x *bp);
393int bnx2x_iov_alloc_mem(struct bnx2x *bp);
394int bnx2x_iov_nic_init(struct bnx2x *bp);
Ariel Eliorf1929b02013-01-01 05:22:41 +0000395int bnx2x_iov_chip_cleanup(struct bnx2x *bp);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000396void bnx2x_iov_init_dq(struct bnx2x *bp);
397void bnx2x_iov_init_dmae(struct bnx2x *bp);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000398void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
399 struct bnx2x_queue_sp_obj **q_obj);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000400int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem);
Ariel Elior67c431a2013-01-01 05:22:36 +0000401void bnx2x_iov_adjust_stats_req(struct bnx2x *bp);
402void bnx2x_iov_storm_stats_update(struct bnx2x *bp);
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000403/* global vf mailbox routines */
Yuval Mintz370d4a22014-03-23 18:12:24 +0200404void bnx2x_vf_mbx(struct bnx2x *bp);
405void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
406 struct vf_pf_event_data *vfpf_event);
Ariel Eliorb56e9672013-01-01 05:22:32 +0000407void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
Ariel Elior954ea742013-01-01 05:22:38 +0000408
409/* CORE VF API */
410typedef u8 bnx2x_mac_addr_t[ETH_ALEN];
411
Ariel Elior8ca5e172013-01-01 05:22:34 +0000412/* acquire */
413int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
Ariel Eliorb93288d2013-01-01 05:22:35 +0000414 struct vf_pf_resc_request *resc);
415/* init */
416int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
417 dma_addr_t *sb_map);
Ariel Elior8db573b2013-01-01 05:22:37 +0000418
Ariel Elior8db573b2013-01-01 05:22:37 +0000419/* VFOP queue construction helpers */
420void bnx2x_vfop_qctor_dump_tx(struct bnx2x *bp, struct bnx2x_virtf *vf,
421 struct bnx2x_queue_init_params *init_params,
422 struct bnx2x_queue_setup_params *setup_params,
423 u16 q_idx, u16 sb_idx);
424
425void bnx2x_vfop_qctor_dump_rx(struct bnx2x *bp, struct bnx2x_virtf *vf,
426 struct bnx2x_queue_init_params *init_params,
427 struct bnx2x_queue_setup_params *setup_params,
428 u16 q_idx, u16 sb_idx);
429
430void bnx2x_vfop_qctor_prep(struct bnx2x *bp,
431 struct bnx2x_virtf *vf,
432 struct bnx2x_vf_queue *q,
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200433 struct bnx2x_vf_queue_construct_params *p,
Ariel Elior8db573b2013-01-01 05:22:37 +0000434 unsigned long q_type);
Ariel Elior954ea742013-01-01 05:22:38 +0000435
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200436int bnx2x_vf_mac_vlan_config_list(struct bnx2x *bp, struct bnx2x_virtf *vf,
437 struct bnx2x_vf_mac_vlan_filters *filters,
438 int qid, bool drv_only);
Ariel Elior954ea742013-01-01 05:22:38 +0000439
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200440int bnx2x_vf_queue_setup(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid,
441 struct bnx2x_vf_queue_construct_params *qctor);
Ariel Elior8db573b2013-01-01 05:22:37 +0000442
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200443int bnx2x_vf_queue_teardown(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid);
Ariel Elior463a68a2013-01-01 05:22:39 +0000444
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200445int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
446 bnx2x_mac_addr_t *mcasts, int mc_num, bool drv_only);
Ariel Elior954ea742013-01-01 05:22:38 +0000447
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200448int bnx2x_vf_rxmode(struct bnx2x *bp, struct bnx2x_virtf *vf,
449 int qid, unsigned long accept_flags);
Ariel Elior954ea742013-01-01 05:22:38 +0000450
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200451int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Elior99e9d212013-01-01 05:22:40 +0000452
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200453int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Eliorf1929b02013-01-01 05:22:41 +0000454
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200455int bnx2x_vf_rss_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
456 struct bnx2x_config_rss_params *rss);
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300457
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200458int bnx2x_vf_tpa_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
459 struct vfpf_tpa_tlv *tlv,
460 struct bnx2x_queue_update_tpa_params *params);
Michal Kalderon14a94eb2014-02-12 18:19:53 +0200461
Ariel Eliorf1929b02013-01-01 05:22:41 +0000462/* VF release ~ VF close + VF release-resources
463 *
464 * Release is the ultimate SW shutdown and is called whenever an
465 * irrecoverable error is encountered.
466 */
Yuval Mintz2dc33bb2014-03-23 18:12:25 +0200467int bnx2x_vf_release(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Elior290ca2b2013-01-01 05:22:31 +0000468int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
Ariel Elior8ca5e172013-01-01 05:22:34 +0000469u8 bnx2x_vf_max_queue_cnt(struct bnx2x *bp, struct bnx2x_virtf *vf);
Ariel Eliord16132c2013-01-01 05:22:42 +0000470
471/* FLR routines */
472
Ariel Eliorb56e9672013-01-01 05:22:32 +0000473/* VF FLR helpers */
474int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
475void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
Ariel Eliord16132c2013-01-01 05:22:42 +0000476
477/* Handles an FLR (or VF_DISABLE) notification form the MCP */
478void bnx2x_vf_handle_flr_event(struct bnx2x *bp);
479
Ariel Eliorfd1fc792013-01-01 05:22:33 +0000480bool bnx2x_tlv_supported(u16 tlvtype);
481
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300482u32 bnx2x_crc_vf_bulletin(struct pf_vf_bulletin_content *bulletin);
Ariel Eliorabc5a022013-01-01 05:22:43 +0000483int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf);
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300484void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
485 bool support_long);
Ariel Eliorabc5a022013-01-01 05:22:43 +0000486
Ariel Eliorabc5a022013-01-01 05:22:43 +0000487enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
488
Ariel Elior64112802013-01-07 00:50:23 +0000489/* VF side vfpf channel functions */
490int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
491int bnx2x_vfpf_release(struct bnx2x *bp);
492int bnx2x_vfpf_release(struct bnx2x *bp);
493int bnx2x_vfpf_init(struct bnx2x *bp);
494void bnx2x_vfpf_close_vf(struct bnx2x *bp);
Ariel Elior60cad4e2013-09-04 14:09:22 +0300495int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
496 bool is_leading);
Dmitry Kravkovf8f4f612013-04-24 01:45:00 +0000497int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set);
Ariel Elior60cad4e2013-09-04 14:09:22 +0300498int bnx2x_vfpf_config_rss(struct bnx2x *bp,
499 struct bnx2x_config_rss_params *params);
Ariel Elior64112802013-01-07 00:50:23 +0000500int bnx2x_vfpf_set_mcast(struct net_device *dev);
501int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp);
502
503static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
504 size_t buf_len)
505{
506 strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
507}
508
509static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
510 struct bnx2x_fastpath *fp)
511{
512 return PXP_VF_ADDR_USDM_QUEUES_START +
513 bp->acquire_resp.resc.hw_qid[fp->index] *
514 sizeof(struct ustorm_queue_zone_data);
515}
516
517enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
Yuval Mintz371734882013-06-24 11:04:10 +0300518void bnx2x_timer_sriov(struct bnx2x *bp);
Dmitry Kravkov1d6f3cd2013-03-27 01:05:17 +0000519void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp);
Yuval Mintze2a367f2014-04-24 19:29:52 +0300520void bnx2x_vf_pci_dealloc(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000521int bnx2x_vf_pci_alloc(struct bnx2x *bp);
Ariel Elior3c76fef2013-03-11 05:17:46 +0000522int bnx2x_enable_sriov(struct bnx2x *bp);
523void bnx2x_disable_sriov(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000524static inline int bnx2x_vf_headroom(struct bnx2x *bp)
525{
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300526 return bp->vfdb->sriov.nr_virtfn * BNX2X_CIDS_PER_VF;
Ariel Elior64112802013-01-07 00:50:23 +0000527}
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000528void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
Ariel Elior3c76fef2013-03-11 05:17:46 +0000529int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
Ariel Elior78c3bcc2013-06-20 17:39:08 +0300530void bnx2x_iov_channel_down(struct bnx2x *bp);
Ariel Elior64112802013-01-07 00:50:23 +0000531
Yuval Mintz370d4a22014-03-23 18:12:24 +0200532void bnx2x_iov_task(struct work_struct *work);
533
534void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag);
535
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300536void bnx2x_iov_link_update(struct bnx2x *bp);
537int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx);
538
539int bnx2x_set_vf_link_state(struct net_device *dev, int vf, int link_state);
540
Ariel Elior64112802013-01-07 00:50:23 +0000541#else /* CONFIG_BNX2X_SRIOV */
542
543static inline void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
544 struct bnx2x_queue_sp_obj **q_obj) {}
Ariel Elior64112802013-01-07 00:50:23 +0000545static inline void bnx2x_vf_handle_flr_event(struct bnx2x *bp) {}
546static inline int bnx2x_iov_eq_sp_event(struct bnx2x *bp,
547 union event_ring_elem *elem) {return 1; }
Yuval Mintz370d4a22014-03-23 18:12:24 +0200548static inline void bnx2x_vf_mbx(struct bnx2x *bp) {}
549static inline void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
550 struct vf_pf_event_data *vfpf_event) {}
Ariel Elior64112802013-01-07 00:50:23 +0000551static inline int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line) {return line; }
552static inline void bnx2x_iov_init_dq(struct bnx2x *bp) {}
553static inline int bnx2x_iov_alloc_mem(struct bnx2x *bp) {return 0; }
Yuval Mintz580d9d02013-01-23 03:21:51 +0000554static inline void bnx2x_iov_free_mem(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000555static inline int bnx2x_iov_chip_cleanup(struct bnx2x *bp) {return 0; }
556static inline void bnx2x_iov_init_dmae(struct bnx2x *bp) {}
557static inline int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
558 int num_vfs_param) {return 0; }
559static inline void bnx2x_iov_remove_one(struct bnx2x *bp) {}
Ariel Elior3c76fef2013-03-11 05:17:46 +0000560static inline int bnx2x_enable_sriov(struct bnx2x *bp) {return 0; }
561static inline void bnx2x_disable_sriov(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000562static inline int bnx2x_vfpf_acquire(struct bnx2x *bp,
563 u8 tx_count, u8 rx_count) {return 0; }
564static inline int bnx2x_vfpf_release(struct bnx2x *bp) {return 0; }
565static inline int bnx2x_vfpf_init(struct bnx2x *bp) {return 0; }
566static inline void bnx2x_vfpf_close_vf(struct bnx2x *bp) {}
Ariel Elior60cad4e2013-09-04 14:09:22 +0300567static 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 +0000568static inline int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr,
569 u8 vf_qid, bool set) {return 0; }
Dmitry Kravkov9b0be652013-09-06 10:35:28 +0300570static inline int bnx2x_vfpf_config_rss(struct bnx2x *bp,
571 struct bnx2x_config_rss_params *params) {return 0; }
Ariel Elior64112802013-01-07 00:50:23 +0000572static inline int bnx2x_vfpf_set_mcast(struct net_device *dev) {return 0; }
573static inline int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp) {return 0; }
574static inline int bnx2x_iov_nic_init(struct bnx2x *bp) {return 0; }
575static inline int bnx2x_vf_headroom(struct bnx2x *bp) {return 0; }
576static inline void bnx2x_iov_adjust_stats_req(struct bnx2x *bp) {}
577static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
578 size_t buf_len) {}
579static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
580 struct bnx2x_fastpath *fp) {return 0; }
581static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp)
582{
583 return PFVF_BULLETIN_UNCHANGED;
584}
Yuval Mintz371734882013-06-24 11:04:10 +0300585static inline void bnx2x_timer_sriov(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000586
Dmitry Kravkov1d6f3cd2013-03-27 01:05:17 +0000587static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
588{
589 return NULL;
590}
591
Randy Dunlap62555582014-05-10 11:33:54 -0700592static inline void bnx2x_vf_pci_dealloc(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000593static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000594static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
Ariel Elior3c76fef2013-03-11 05:17:46 +0000595static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
Ariel Elior78c3bcc2013-06-20 17:39:08 +0300596static inline void bnx2x_iov_channel_down(struct bnx2x *bp) {}
Ariel Elior64112802013-01-07 00:50:23 +0000597
Yuval Mintz370d4a22014-03-23 18:12:24 +0200598static inline void bnx2x_iov_task(struct work_struct *work) {}
Yuval Mintz19915f52014-03-26 09:06:29 +0200599static inline void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag) {}
Dmitry Kravkov6495d152014-06-26 14:31:04 +0300600static inline void bnx2x_iov_link_update(struct bnx2x *bp) {}
601static inline int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx) {return 0; }
602
603static inline int bnx2x_set_vf_link_state(struct net_device *dev, int vf,
604 int link_state) {return 0; }
605struct pf_vf_bulletin_content;
606static inline void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
607 bool support_long) {}
Yuval Mintz370d4a22014-03-23 18:12:24 +0200608
Ariel Elior64112802013-01-07 00:50:23 +0000609#endif /* CONFIG_BNX2X_SRIOV */
Ariel Elior1ab44342013-01-01 05:22:23 +0000610#endif /* bnx2x_sriov.h */