bnx2x_sriov.h 20 KB

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