1 /* bnx2x_sriov.h: Broadcom Everest network driver.
3 * Copyright 2009-2012 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Shmulik Ravid <shmulikr@broadcom.com>
17 * Ariel Elior <ariele@broadcom.com>
22 /* The bnx2x device structure holds vfdb structure described below.
23 * The VF array is indexed by the relative vfid.
28 /* standard SRIOV capability fields, mostly for debugging */
29 int pos; /* capability position */
30 int nres; /* number of resources */
31 u32 cap; /* SR-IOV Capabilities */
32 u16 ctrl; /* SR-IOV Control */
33 u16 total; /* total VFs associated with the PF */
34 u16 initial; /* initial VFs associated with the PF */
35 u16 nr_virtfn; /* number of VFs available */
36 u16 offset; /* first VF Routing ID offset */
37 u16 stride; /* following VF stride */
38 u32 pgsz; /* page size for BAR alignment */
39 u8 link; /* Function Dependency Link */
48 /* vf queue (used both for rx or tx) */
49 struct bnx2x_vf_queue {
50 struct eth_context *cxt;
53 struct bnx2x_vlan_mac_obj mac_obj;
56 struct bnx2x_vlan_mac_obj vlan_obj;
57 atomic_t vlan_count; /* 0 means vlan-0 is set ~ untagged */
59 /* Queue Slow-path State object */
60 struct bnx2x_queue_sp_obj sp_obj;
67 /* struct bnx2x_vfop_qctor_params - prepare queue construction parameters:
68 * q-init, q-setup and SB index
70 struct bnx2x_vfop_qctor_params {
71 struct bnx2x_queue_state_params qstate;
72 struct bnx2x_queue_setup_params prep_qsetup;
75 /* VFOP parameters (one copy per VF) */
76 union bnx2x_vfop_params {
77 struct bnx2x_vlan_mac_ramrod_params vlan_mac;
78 struct bnx2x_rx_mode_ramrod_params rx_mode;
79 struct bnx2x_mcast_ramrod_params mcast;
80 struct bnx2x_config_rss_params rss;
81 struct bnx2x_vfop_qctor_params qctor;
89 #define VF_CFG_STATS 0x0001
90 #define VF_CFG_FW_FC 0x0002
91 #define VF_CFG_TPA 0x0004
92 #define VF_CFG_INT_SIMD 0x0008
93 #define VF_CACHE_LINE 0x0010
96 #define VF_FREE 0 /* VF ready to be acquired holds no resc */
97 #define VF_ACQUIRED 1 /* VF aquired, but not initalized */
98 #define VF_ENABLED 2 /* VF Enabled */
99 #define VF_RESET 3 /* VF FLR'd, pending cleanup */
101 /* non 0 during flr cleanup */
103 #define VF_FLR_CLN 1 /* reclaim resources and do 'final cleanup'
106 #define VF_FLR_ACK 2 /* ACK flr notification */
107 #define VF_FLR_EPILOG 3 /* wait for VF remnants to dissipate in the HW
108 * ~ final cleanup' end wait
112 dma_addr_t fw_stat_map; /* valid iff VF_CFG_STATS */
114 dma_addr_t bulletin_map;
116 /* Allocated resources counters. Before the VF is acquired, the
117 * counters hold the following values:
119 * - xxq_count = 0 as the queues memory is not allocated yet.
121 * - sb_count = The number of status blocks configured for this VF in
122 * the IGU CAM. Initially read during probe.
124 * - xx_rules_count = The number of rules statically and equally
125 * allocated for each VF, during PF load.
127 struct vf_pf_resc_request alloc_resc;
128 #define vf_rxq_count(vf) ((vf)->alloc_resc.num_rxqs)
129 #define vf_txq_count(vf) ((vf)->alloc_resc.num_txqs)
130 #define vf_sb_count(vf) ((vf)->alloc_resc.num_sbs)
131 #define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
132 #define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
133 #define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
135 u8 sb_count; /* actual number of SBs */
136 u8 igu_base_id; /* base igu status block id */
138 struct bnx2x_vf_queue *vfqs;
139 #define bnx2x_vfq(vf, nr, var) ((vf)->vfqs[(nr)].var)
141 u8 index; /* index in the vf array */
144 u32 error; /* 0 means all's-well */
151 struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
153 /* set-mac ramrod state 1-pending, 0-done */
154 unsigned long filter_state;
156 /* leading rss client id ~~ the client id of the first rxq, must be
162 struct bnx2x_mcast_obj mcast_obj;
164 /* RSS configuration object */
165 struct bnx2x_rss_config_obj rss_conf_obj;
167 /* slow-path operations */
168 atomic_t op_in_progress;
170 bool op_wait_blocking;
171 struct list_head op_list_head;
172 union bnx2x_vfop_params op_params;
173 struct mutex op_mutex; /* one vfop at a time mutex */
174 enum channel_tlvs op_current;
177 #define BNX2X_NR_VIRTFN(bp) ((bp)->vfdb->sriov.nr_virtfn)
179 #define for_each_vf(bp, var) \
180 for ((var) = 0; (var) < BNX2X_NR_VIRTFN(bp); (var)++)
182 #define HW_VF_HANDLE(bp, abs_vfid) \
183 (u16)(BP_ABS_FUNC((bp)) | (1<<3) | ((u16)(abs_vfid) << 4))
185 #define FW_PF_MAX_HANDLE 8
187 #define FW_VF_HANDLE(abs_vfid) \
188 (abs_vfid + FW_PF_MAX_HANDLE)
190 /* VF mail box (aka vf-pf channel) */
192 /* a container for the bi-directional vf<-->pf messages.
193 * The actual response will be placed according to the offset parameter
194 * provided in the request
197 #define MBX_MSG_ALIGN 8
198 #define MBX_MSG_ALIGNED_SIZE (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
201 struct bnx2x_vf_mbx_msg {
203 union pfvf_tlvs resp;
206 struct bnx2x_vf_mbx {
207 struct bnx2x_vf_mbx_msg *msg;
208 dma_addr_t msg_mapping;
214 struct vfpf_first_tlv first_tlv; /* saved VF request header */
217 #define VF_MSG_INPROCESS 0x1 /* failsafe - the FW should prevent
218 * more then one pending msg
224 struct eth_classify_rules_ramrod_data e2;
228 struct eth_classify_rules_ramrod_data e2;
232 struct eth_filter_rules_ramrod_data e2;
236 struct eth_multicast_rules_ramrod_data e2;
240 struct client_init_ramrod_data init_data;
241 struct client_update_ramrod_data update_data;
252 #define BP_VFDB(bp) ((bp)->vfdb)
254 struct bnx2x_virtf *vfs;
255 #define BP_VF(bp, idx) (&((bp)->vfdb->vfs[(idx)]))
256 #define bnx2x_vf(bp, idx, var) ((bp)->vfdb->vfs[(idx)].var)
258 /* queue array - for all vfs */
259 struct bnx2x_vf_queue *vfqs;
262 struct hw_dma context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
263 #define BP_VF_CXT_PAGE(bp, i) (&(bp)->vfdb->context[(i)])
265 /* SR-IOV information */
266 struct bnx2x_sriov sriov;
267 struct hw_dma mbx_dma;
268 #define BP_VF_MBX_DMA(bp) (&((bp)->vfdb->mbx_dma))
269 struct bnx2x_vf_mbx mbxs[BNX2X_MAX_NUM_OF_VFS];
270 #define BP_VF_MBX(bp, vfid) (&((bp)->vfdb->mbxs[(vfid)]))
272 struct hw_dma sp_dma;
273 #define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr + \
274 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
275 offsetof(struct bnx2x_vf_sp, field))
276 #define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping + \
277 (vf)->index * sizeof(struct bnx2x_vf_sp) + \
278 offsetof(struct bnx2x_vf_sp, field))
280 #define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
281 u32 flrd_vfs[FLRD_VFS_DWORDS];
284 static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
286 return vf->igu_base_id + sb_idx;
289 /* global iov routines */
290 int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
291 int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
292 void bnx2x_iov_remove_one(struct bnx2x *bp);
293 void bnx2x_iov_free_mem(struct bnx2x *bp);
294 int bnx2x_iov_alloc_mem(struct bnx2x *bp);
295 int bnx2x_iov_nic_init(struct bnx2x *bp);
296 void bnx2x_iov_init_dq(struct bnx2x *bp);
297 void bnx2x_iov_init_dmae(struct bnx2x *bp);
298 void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
299 int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
301 int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
302 void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
303 void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
305 void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
306 u16 type, u16 length);
307 void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list);
308 #endif /* bnx2x_sriov.h */