bnx2x_sriov.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. #include "bnx2x_vfpf.h"
  24. #include "bnx2x.h"
  25. enum sample_bulletin_result {
  26. PFVF_BULLETIN_UNCHANGED,
  27. PFVF_BULLETIN_UPDATED,
  28. PFVF_BULLETIN_CRC_ERR
  29. };
  30. #ifdef CONFIG_BNX2X_SRIOV
  31. extern struct workqueue_struct *bnx2x_iov_wq;
  32. /* The bnx2x device structure holds vfdb structure described below.
  33. * The VF array is indexed by the relative vfid.
  34. */
  35. #define BNX2X_VF_MAX_QUEUES 16
  36. #define BNX2X_VF_MAX_TPA_AGG_QUEUES 8
  37. struct bnx2x_sriov {
  38. u32 first_vf_in_pf;
  39. /* standard SRIOV capability fields, mostly for debugging */
  40. int pos; /* capability position */
  41. int nres; /* number of resources */
  42. u32 cap; /* SR-IOV Capabilities */
  43. u16 ctrl; /* SR-IOV Control */
  44. u16 total; /* total VFs associated with the PF */
  45. u16 initial; /* initial VFs associated with the PF */
  46. u16 nr_virtfn; /* number of VFs available */
  47. u16 offset; /* first VF Routing ID offset */
  48. u16 stride; /* following VF stride */
  49. u32 pgsz; /* page size for BAR alignment */
  50. u8 link; /* Function Dependency Link */
  51. };
  52. /* bars */
  53. struct bnx2x_vf_bar {
  54. u64 bar;
  55. u32 size;
  56. };
  57. struct bnx2x_vf_bar_info {
  58. struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
  59. u8 nr_bars;
  60. };
  61. /* vf queue (used both for rx or tx) */
  62. struct bnx2x_vf_queue {
  63. struct eth_context *cxt;
  64. /* MACs object */
  65. struct bnx2x_vlan_mac_obj mac_obj;
  66. /* VLANs object */
  67. struct bnx2x_vlan_mac_obj vlan_obj;
  68. /* VLAN-MACs object */
  69. struct bnx2x_vlan_mac_obj vlan_mac_obj;
  70. unsigned long accept_flags; /* last accept flags configured */
  71. /* Queue Slow-path State object */
  72. struct bnx2x_queue_sp_obj sp_obj;
  73. u32 cid;
  74. u16 index;
  75. u16 sb_idx;
  76. bool is_leading;
  77. bool sp_initialized;
  78. };
  79. /* struct bnx2x_vf_queue_construct_params - prepare queue construction
  80. * parameters: q-init, q-setup and SB index
  81. */
  82. struct bnx2x_vf_queue_construct_params {
  83. struct bnx2x_queue_state_params qstate;
  84. struct bnx2x_queue_setup_params prep_qsetup;
  85. };
  86. /* forward */
  87. struct bnx2x_virtf;
  88. /* VFOP definitions */
  89. struct bnx2x_vf_mac_vlan_filter {
  90. int type;
  91. #define BNX2X_VF_FILTER_MAC BIT(0)
  92. #define BNX2X_VF_FILTER_VLAN BIT(1)
  93. #define BNX2X_VF_FILTER_VLAN_MAC \
  94. (BNX2X_VF_FILTER_MAC | BNX2X_VF_FILTER_VLAN) /*shortcut*/
  95. bool add;
  96. bool applied;
  97. u8 *mac;
  98. u16 vid;
  99. };
  100. struct bnx2x_vf_mac_vlan_filters {
  101. int count;
  102. struct bnx2x_vf_mac_vlan_filter filters[];
  103. };
  104. /* vf context */
  105. struct bnx2x_virtf {
  106. u16 cfg_flags;
  107. #define VF_CFG_STATS_COALESCE 0x1
  108. #define VF_CFG_EXT_BULLETIN 0x2
  109. #define VF_CFG_VLAN_FILTER 0x4
  110. u8 link_cfg; /* IFLA_VF_LINK_STATE_AUTO
  111. * IFLA_VF_LINK_STATE_ENABLE
  112. * IFLA_VF_LINK_STATE_DISABLE
  113. */
  114. u8 state;
  115. #define VF_FREE 0 /* VF ready to be acquired holds no resc */
  116. #define VF_ACQUIRED 1 /* VF acquired, but not initialized */
  117. #define VF_ENABLED 2 /* VF Enabled */
  118. #define VF_RESET 3 /* VF FLR'd, pending cleanup */
  119. #define VF_LOST 4 /* Recovery while VFs are loaded */
  120. bool flr_clnup_stage; /* true during flr cleanup */
  121. bool malicious; /* true if FW indicated so, until FLR */
  122. /* dma */
  123. dma_addr_t fw_stat_map;
  124. u16 stats_stride;
  125. dma_addr_t bulletin_map;
  126. /* Allocated resources counters. Before the VF is acquired, the
  127. * counters hold the following values:
  128. *
  129. * - xxq_count = 0 as the queues memory is not allocated yet.
  130. *
  131. * - sb_count = The number of status blocks configured for this VF in
  132. * the IGU CAM. Initially read during probe.
  133. *
  134. * - xx_rules_count = The number of rules statically and equally
  135. * allocated for each VF, during PF load.
  136. */
  137. struct vf_pf_resc_request alloc_resc;
  138. #define vf_rxq_count(vf) ((vf)->alloc_resc.num_rxqs)
  139. #define vf_txq_count(vf) ((vf)->alloc_resc.num_txqs)
  140. #define vf_sb_count(vf) ((vf)->alloc_resc.num_sbs)
  141. #define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
  142. #define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
  143. #define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
  144. u8 sb_count; /* actual number of SBs */
  145. u8 igu_base_id; /* base igu status block id */
  146. struct bnx2x_vf_queue *vfqs;
  147. #define LEADING_IDX 0
  148. #define bnx2x_vfq_is_leading(vfq) ((vfq)->index == LEADING_IDX)
  149. #define bnx2x_vfq(vf, nr, var) ((vf)->vfqs[(nr)].var)
  150. #define bnx2x_leading_vfq(vf, var) ((vf)->vfqs[LEADING_IDX].var)
  151. u8 index; /* index in the vf array */
  152. u8 abs_vfid;
  153. u8 sp_cl_id;
  154. u32 error; /* 0 means all's-well */
  155. /* BDF */
  156. unsigned int domain;
  157. unsigned int bus;
  158. unsigned int devfn;
  159. /* bars */
  160. struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
  161. /* set-mac ramrod state 1-pending, 0-done */
  162. unsigned long filter_state;
  163. /* leading rss client id ~~ the client id of the first rxq, must be
  164. * set for each txq.
  165. */
  166. int leading_rss;
  167. /* MCAST object */
  168. struct bnx2x_mcast_obj mcast_obj;
  169. /* RSS configuration object */
  170. struct bnx2x_rss_config_obj rss_conf_obj;
  171. /* slow-path operations */
  172. struct mutex op_mutex; /* one vfop at a time mutex */
  173. enum channel_tlvs op_current;
  174. u8 fp_hsi;
  175. struct bnx2x_credit_pool_obj vf_vlans_pool;
  176. struct bnx2x_credit_pool_obj vf_macs_pool;
  177. };
  178. #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)++)
  181. #define for_each_vfq(vf, var) \
  182. for ((var) = 0; (var) < vf_rxq_count(vf); (var)++)
  183. #define for_each_vf_sb(vf, var) \
  184. for ((var) = 0; (var) < vf_sb_count(vf); (var)++)
  185. #define is_vf_multi(vf) (vf_rxq_count(vf) > 1)
  186. #define HW_VF_HANDLE(bp, abs_vfid) \
  187. (u16)(BP_ABS_FUNC((bp)) | (1<<3) | ((u16)(abs_vfid) << 4))
  188. #define FW_PF_MAX_HANDLE 8
  189. #define FW_VF_HANDLE(abs_vfid) \
  190. (abs_vfid + FW_PF_MAX_HANDLE)
  191. #define GET_NUM_VFS_PER_PATH(bp) 64 /* use max possible value */
  192. #define GET_NUM_VFS_PER_PF(bp) ((bp)->vfdb ? (bp)->vfdb->sriov.total \
  193. : 0)
  194. #define VF_MAC_CREDIT_CNT 1
  195. #define VF_VLAN_CREDIT_CNT 2 /* VLAN0 + 'real' VLAN */
  196. /* locking and unlocking the channel mutex */
  197. void bnx2x_lock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
  198. enum channel_tlvs tlv);
  199. void bnx2x_unlock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
  200. enum channel_tlvs expected_tlv);
  201. /* VF mail box (aka vf-pf channel) */
  202. /* a container for the bi-directional vf<-->pf messages.
  203. * The actual response will be placed according to the offset parameter
  204. * provided in the request
  205. */
  206. #define MBX_MSG_ALIGN 8
  207. #define MBX_MSG_ALIGNED_SIZE (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
  208. MBX_MSG_ALIGN))
  209. struct bnx2x_vf_mbx_msg {
  210. union vfpf_tlvs req;
  211. union pfvf_tlvs resp;
  212. };
  213. struct bnx2x_vf_mbx {
  214. struct bnx2x_vf_mbx_msg *msg;
  215. dma_addr_t msg_mapping;
  216. /* VF GPA address */
  217. u32 vf_addr_lo;
  218. u32 vf_addr_hi;
  219. struct vfpf_first_tlv first_tlv; /* saved VF request header */
  220. };
  221. struct bnx2x_vf_sp {
  222. union {
  223. struct eth_classify_rules_ramrod_data e2;
  224. } mac_rdata;
  225. union {
  226. struct eth_classify_rules_ramrod_data e2;
  227. } vlan_rdata;
  228. union {
  229. struct eth_classify_rules_ramrod_data e2;
  230. } vlan_mac_rdata;
  231. union {
  232. struct eth_filter_rules_ramrod_data e2;
  233. } rx_mode_rdata;
  234. union {
  235. struct eth_multicast_rules_ramrod_data e2;
  236. } mcast_rdata;
  237. union {
  238. struct client_init_ramrod_data init_data;
  239. struct client_update_ramrod_data update_data;
  240. } q_data;
  241. union {
  242. struct eth_rss_update_ramrod_data e2;
  243. } rss_rdata;
  244. };
  245. struct hw_dma {
  246. void *addr;
  247. dma_addr_t mapping;
  248. size_t size;
  249. };
  250. struct bnx2x_vfdb {
  251. #define BP_VFDB(bp) ((bp)->vfdb)
  252. /* vf array */
  253. struct bnx2x_virtf *vfs;
  254. #define BP_VF(bp, idx) ((BP_VFDB(bp) && (bp)->vfdb->vfs) ? \
  255. &((bp)->vfdb->vfs[idx]) : NULL)
  256. #define bnx2x_vf(bp, idx, var) ((bp)->vfdb->vfs[idx].var)
  257. /* queue array - for all vfs */
  258. struct bnx2x_vf_queue *vfqs;
  259. /* vf HW contexts */
  260. struct hw_dma context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
  261. #define BP_VF_CXT_PAGE(bp, i) (&(bp)->vfdb->context[i])
  262. /* SR-IOV information */
  263. struct bnx2x_sriov sriov;
  264. struct hw_dma mbx_dma;
  265. #define BP_VF_MBX_DMA(bp) (&((bp)->vfdb->mbx_dma))
  266. struct bnx2x_vf_mbx mbxs[BNX2X_MAX_NUM_OF_VFS];
  267. #define BP_VF_MBX(bp, vfid) (&((bp)->vfdb->mbxs[vfid]))
  268. struct hw_dma bulletin_dma;
  269. #define BP_VF_BULLETIN_DMA(bp) (&((bp)->vfdb->bulletin_dma))
  270. #define BP_VF_BULLETIN(bp, vf) \
  271. (((struct pf_vf_bulletin_content *)(BP_VF_BULLETIN_DMA(bp)->addr)) \
  272. + (vf))
  273. struct hw_dma sp_dma;
  274. #define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr + \
  275. (vf)->index * sizeof(struct bnx2x_vf_sp) + \
  276. offsetof(struct bnx2x_vf_sp, field))
  277. #define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping + \
  278. (vf)->index * sizeof(struct bnx2x_vf_sp) + \
  279. offsetof(struct bnx2x_vf_sp, field))
  280. #define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
  281. u32 flrd_vfs[FLRD_VFS_DWORDS];
  282. /* the number of msix vectors belonging to this PF designated for VFs */
  283. u16 vf_sbs_pool;
  284. u16 first_vf_igu_entry;
  285. /* sp_rtnl synchronization */
  286. struct mutex event_mutex;
  287. u64 event_occur;
  288. /* bulletin board update synchronization */
  289. struct mutex bulletin_mutex;
  290. };
  291. /* queue access */
  292. static inline struct bnx2x_vf_queue *vfq_get(struct bnx2x_virtf *vf, u8 index)
  293. {
  294. return &(vf->vfqs[index]);
  295. }
  296. /* FW ids */
  297. static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
  298. {
  299. return vf->igu_base_id + sb_idx;
  300. }
  301. static inline u8 vf_hc_qzone(struct bnx2x_virtf *vf, u16 sb_idx)
  302. {
  303. return vf_igu_sb(vf, sb_idx);
  304. }
  305. static u8 vfq_cl_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  306. {
  307. return vf->igu_base_id + q->index;
  308. }
  309. static inline u8 vfq_stat_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  310. {
  311. if (vf->cfg_flags & VF_CFG_STATS_COALESCE)
  312. return vf->leading_rss;
  313. else
  314. return vfq_cl_id(vf, q);
  315. }
  316. static inline u8 vfq_qzone_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  317. {
  318. return vfq_cl_id(vf, q);
  319. }
  320. /* global iov routines */
  321. int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
  322. int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
  323. void bnx2x_iov_remove_one(struct bnx2x *bp);
  324. void bnx2x_iov_free_mem(struct bnx2x *bp);
  325. int bnx2x_iov_alloc_mem(struct bnx2x *bp);
  326. int bnx2x_iov_nic_init(struct bnx2x *bp);
  327. int bnx2x_iov_chip_cleanup(struct bnx2x *bp);
  328. void bnx2x_iov_init_dq(struct bnx2x *bp);
  329. void bnx2x_iov_init_dmae(struct bnx2x *bp);
  330. void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
  331. struct bnx2x_queue_sp_obj **q_obj);
  332. int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem);
  333. void bnx2x_iov_adjust_stats_req(struct bnx2x *bp);
  334. void bnx2x_iov_storm_stats_update(struct bnx2x *bp);
  335. /* global vf mailbox routines */
  336. void bnx2x_vf_mbx(struct bnx2x *bp);
  337. void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
  338. struct vf_pf_event_data *vfpf_event);
  339. void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
  340. /* CORE VF API */
  341. typedef u8 bnx2x_mac_addr_t[ETH_ALEN];
  342. /* acquire */
  343. int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
  344. struct vf_pf_resc_request *resc);
  345. /* init */
  346. int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
  347. dma_addr_t *sb_map);
  348. /* VFOP queue construction helpers */
  349. void bnx2x_vfop_qctor_dump_tx(struct bnx2x *bp, struct bnx2x_virtf *vf,
  350. struct bnx2x_queue_init_params *init_params,
  351. struct bnx2x_queue_setup_params *setup_params,
  352. u16 q_idx, u16 sb_idx);
  353. void bnx2x_vfop_qctor_dump_rx(struct bnx2x *bp, struct bnx2x_virtf *vf,
  354. struct bnx2x_queue_init_params *init_params,
  355. struct bnx2x_queue_setup_params *setup_params,
  356. u16 q_idx, u16 sb_idx);
  357. void bnx2x_vfop_qctor_prep(struct bnx2x *bp,
  358. struct bnx2x_virtf *vf,
  359. struct bnx2x_vf_queue *q,
  360. struct bnx2x_vf_queue_construct_params *p,
  361. unsigned long q_type);
  362. int bnx2x_vf_mac_vlan_config_list(struct bnx2x *bp, struct bnx2x_virtf *vf,
  363. struct bnx2x_vf_mac_vlan_filters *filters,
  364. int qid, bool drv_only);
  365. int bnx2x_vf_queue_setup(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid,
  366. struct bnx2x_vf_queue_construct_params *qctor);
  367. int bnx2x_vf_queue_teardown(struct bnx2x *bp, struct bnx2x_virtf *vf, int qid);
  368. int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
  369. bnx2x_mac_addr_t *mcasts, int mc_num, bool drv_only);
  370. int bnx2x_vf_rxmode(struct bnx2x *bp, struct bnx2x_virtf *vf,
  371. int qid, unsigned long accept_flags);
  372. int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf);
  373. int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf);
  374. int bnx2x_vf_rss_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
  375. struct bnx2x_config_rss_params *rss);
  376. int bnx2x_vf_tpa_update(struct bnx2x *bp, struct bnx2x_virtf *vf,
  377. struct vfpf_tpa_tlv *tlv,
  378. struct bnx2x_queue_update_tpa_params *params);
  379. /* VF release ~ VF close + VF release-resources
  380. *
  381. * Release is the ultimate SW shutdown and is called whenever an
  382. * irrecoverable error is encountered.
  383. */
  384. int bnx2x_vf_release(struct bnx2x *bp, struct bnx2x_virtf *vf);
  385. int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
  386. u8 bnx2x_vf_max_queue_cnt(struct bnx2x *bp, struct bnx2x_virtf *vf);
  387. /* FLR routines */
  388. /* VF FLR helpers */
  389. int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
  390. void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
  391. /* Handles an FLR (or VF_DISABLE) notification form the MCP */
  392. void bnx2x_vf_handle_flr_event(struct bnx2x *bp);
  393. bool bnx2x_tlv_supported(u16 tlvtype);
  394. u32 bnx2x_crc_vf_bulletin(struct pf_vf_bulletin_content *bulletin);
  395. int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf);
  396. void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
  397. bool support_long);
  398. enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
  399. /* VF side vfpf channel functions */
  400. int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
  401. int bnx2x_vfpf_release(struct bnx2x *bp);
  402. int bnx2x_vfpf_release(struct bnx2x *bp);
  403. int bnx2x_vfpf_init(struct bnx2x *bp);
  404. void bnx2x_vfpf_close_vf(struct bnx2x *bp);
  405. int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
  406. bool is_leading);
  407. int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set);
  408. int bnx2x_vfpf_config_rss(struct bnx2x *bp,
  409. struct bnx2x_config_rss_params *params);
  410. int bnx2x_vfpf_set_mcast(struct net_device *dev);
  411. int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp);
  412. static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
  413. size_t buf_len)
  414. {
  415. strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
  416. }
  417. static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
  418. struct bnx2x_fastpath *fp)
  419. {
  420. return PXP_VF_ADDR_USDM_QUEUES_START +
  421. bp->acquire_resp.resc.hw_qid[fp->index] *
  422. sizeof(struct ustorm_queue_zone_data);
  423. }
  424. enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
  425. void bnx2x_timer_sriov(struct bnx2x *bp);
  426. void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp);
  427. void bnx2x_vf_pci_dealloc(struct bnx2x *bp);
  428. int bnx2x_vf_pci_alloc(struct bnx2x *bp);
  429. int bnx2x_enable_sriov(struct bnx2x *bp);
  430. void bnx2x_disable_sriov(struct bnx2x *bp);
  431. static inline int bnx2x_vf_headroom(struct bnx2x *bp)
  432. {
  433. return bp->vfdb->sriov.nr_virtfn * BNX2X_CIDS_PER_VF;
  434. }
  435. void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
  436. int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
  437. void bnx2x_iov_channel_down(struct bnx2x *bp);
  438. void bnx2x_iov_task(struct work_struct *work);
  439. void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag);
  440. void bnx2x_iov_link_update(struct bnx2x *bp);
  441. int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx);
  442. int bnx2x_set_vf_link_state(struct net_device *dev, int vf, int link_state);
  443. int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add);
  444. #else /* CONFIG_BNX2X_SRIOV */
  445. #define GET_NUM_VFS_PER_PATH(bp) 0
  446. #define GET_NUM_VFS_PER_PF(bp) 0
  447. #define VF_MAC_CREDIT_CNT 0
  448. #define VF_VLAN_CREDIT_CNT 0
  449. static inline void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
  450. struct bnx2x_queue_sp_obj **q_obj) {}
  451. static inline void bnx2x_vf_handle_flr_event(struct bnx2x *bp) {}
  452. static inline int bnx2x_iov_eq_sp_event(struct bnx2x *bp,
  453. union event_ring_elem *elem) {return 1; }
  454. static inline void bnx2x_vf_mbx(struct bnx2x *bp) {}
  455. static inline void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
  456. struct vf_pf_event_data *vfpf_event) {}
  457. static inline int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line) {return line; }
  458. static inline void bnx2x_iov_init_dq(struct bnx2x *bp) {}
  459. static inline int bnx2x_iov_alloc_mem(struct bnx2x *bp) {return 0; }
  460. static inline void bnx2x_iov_free_mem(struct bnx2x *bp) {}
  461. static inline int bnx2x_iov_chip_cleanup(struct bnx2x *bp) {return 0; }
  462. static inline void bnx2x_iov_init_dmae(struct bnx2x *bp) {}
  463. static inline int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
  464. int num_vfs_param) {return 0; }
  465. static inline void bnx2x_iov_remove_one(struct bnx2x *bp) {}
  466. static inline int bnx2x_enable_sriov(struct bnx2x *bp) {return 0; }
  467. static inline void bnx2x_disable_sriov(struct bnx2x *bp) {}
  468. static inline int bnx2x_vfpf_acquire(struct bnx2x *bp,
  469. u8 tx_count, u8 rx_count) {return 0; }
  470. static inline int bnx2x_vfpf_release(struct bnx2x *bp) {return 0; }
  471. static inline int bnx2x_vfpf_init(struct bnx2x *bp) {return 0; }
  472. static inline void bnx2x_vfpf_close_vf(struct bnx2x *bp) {}
  473. static inline int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool is_leading) {return 0; }
  474. static inline int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr,
  475. u8 vf_qid, bool set) {return 0; }
  476. static inline int bnx2x_vfpf_config_rss(struct bnx2x *bp,
  477. struct bnx2x_config_rss_params *params) {return 0; }
  478. static inline int bnx2x_vfpf_set_mcast(struct net_device *dev) {return 0; }
  479. static inline int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp) {return 0; }
  480. static inline int bnx2x_iov_nic_init(struct bnx2x *bp) {return 0; }
  481. static inline int bnx2x_vf_headroom(struct bnx2x *bp) {return 0; }
  482. static inline void bnx2x_iov_adjust_stats_req(struct bnx2x *bp) {}
  483. static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
  484. size_t buf_len) {}
  485. static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
  486. struct bnx2x_fastpath *fp) {return 0; }
  487. static inline enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp)
  488. {
  489. return PFVF_BULLETIN_UNCHANGED;
  490. }
  491. static inline void bnx2x_timer_sriov(struct bnx2x *bp) {}
  492. static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
  493. {
  494. return NULL;
  495. }
  496. static inline void bnx2x_vf_pci_dealloc(struct bnx2x *bp) {}
  497. static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
  498. static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
  499. static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
  500. static inline void bnx2x_iov_channel_down(struct bnx2x *bp) {}
  501. static inline void bnx2x_iov_task(struct work_struct *work) {}
  502. static inline void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag) {}
  503. static inline void bnx2x_iov_link_update(struct bnx2x *bp) {}
  504. static inline int bnx2x_iov_link_update_vf(struct bnx2x *bp, int idx) {return 0; }
  505. static inline int bnx2x_set_vf_link_state(struct net_device *dev, int vf,
  506. int link_state) {return 0; }
  507. struct pf_vf_bulletin_content;
  508. static inline void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
  509. bool support_long) {}
  510. static inline int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add) {return 0; }
  511. #endif /* CONFIG_BNX2X_SRIOV */
  512. #endif /* bnx2x_sriov.h */