bnx2x_sriov.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /* bnx2x_sriov.h: Broadcom Everest network driver.
  2. *
  3. * Copyright 2009-2012 Broadcom Corporation
  4. *
  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").
  9. *
  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
  13. * consent.
  14. *
  15. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  16. * Written by: Shmulik Ravid <shmulikr@broadcom.com>
  17. * Ariel Elior <ariele@broadcom.com>
  18. */
  19. #ifndef BNX2X_SRIOV_H
  20. #define BNX2X_SRIOV_H
  21. #include "bnx2x_vfpf.h"
  22. #include "bnx2x_cmn.h"
  23. /* The bnx2x device structure holds vfdb structure described below.
  24. * The VF array is indexed by the relative vfid.
  25. */
  26. #define BNX2X_VF_MAX_QUEUES 16
  27. #define BNX2X_VF_MAX_TPA_AGG_QUEUES 8
  28. struct bnx2x_sriov {
  29. u32 first_vf_in_pf;
  30. /* standard SRIOV capability fields, mostly for debugging */
  31. int pos; /* capability position */
  32. int nres; /* number of resources */
  33. u32 cap; /* SR-IOV Capabilities */
  34. u16 ctrl; /* SR-IOV Control */
  35. u16 total; /* total VFs associated with the PF */
  36. u16 initial; /* initial VFs associated with the PF */
  37. u16 nr_virtfn; /* number of VFs available */
  38. u16 offset; /* first VF Routing ID offset */
  39. u16 stride; /* following VF stride */
  40. u32 pgsz; /* page size for BAR alignment */
  41. u8 link; /* Function Dependency Link */
  42. };
  43. /* bars */
  44. struct bnx2x_vf_bar {
  45. u64 bar;
  46. u32 size;
  47. };
  48. /* vf queue (used both for rx or tx) */
  49. struct bnx2x_vf_queue {
  50. struct eth_context *cxt;
  51. /* MACs object */
  52. struct bnx2x_vlan_mac_obj mac_obj;
  53. /* VLANs object */
  54. struct bnx2x_vlan_mac_obj vlan_obj;
  55. atomic_t vlan_count; /* 0 means vlan-0 is set ~ untagged */
  56. /* Queue Slow-path State object */
  57. struct bnx2x_queue_sp_obj sp_obj;
  58. u32 cid;
  59. u16 index;
  60. u16 sb_idx;
  61. };
  62. /* struct bnx2x_vfop_qctor_params - prepare queue construction parameters:
  63. * q-init, q-setup and SB index
  64. */
  65. struct bnx2x_vfop_qctor_params {
  66. struct bnx2x_queue_state_params qstate;
  67. struct bnx2x_queue_setup_params prep_qsetup;
  68. };
  69. /* VFOP parameters (one copy per VF) */
  70. union bnx2x_vfop_params {
  71. struct bnx2x_vlan_mac_ramrod_params vlan_mac;
  72. struct bnx2x_rx_mode_ramrod_params rx_mode;
  73. struct bnx2x_mcast_ramrod_params mcast;
  74. struct bnx2x_config_rss_params rss;
  75. struct bnx2x_vfop_qctor_params qctor;
  76. };
  77. /* forward */
  78. struct bnx2x_virtf;
  79. /* VFOP definitions */
  80. typedef void (*vfop_handler_t)(struct bnx2x *bp, struct bnx2x_virtf *vf);
  81. struct bnx2x_vfop_cmd {
  82. vfop_handler_t done;
  83. bool block;
  84. };
  85. /* VFOP queue filters command additional arguments */
  86. struct bnx2x_vfop_filter {
  87. struct list_head link;
  88. int type;
  89. #define BNX2X_VFOP_FILTER_MAC 1
  90. #define BNX2X_VFOP_FILTER_VLAN 2
  91. bool add;
  92. u8 *mac;
  93. u16 vid;
  94. };
  95. struct bnx2x_vfop_filters {
  96. int add_cnt;
  97. struct list_head head;
  98. struct bnx2x_vfop_filter filters[];
  99. };
  100. /* transient list allocated, built and saved until its
  101. * passed to the SP-VERBs layer.
  102. */
  103. struct bnx2x_vfop_args_mcast {
  104. int mc_num;
  105. struct bnx2x_mcast_list_elem *mc;
  106. };
  107. struct bnx2x_vfop_args_qctor {
  108. int qid;
  109. u16 sb_idx;
  110. };
  111. struct bnx2x_vfop_args_qdtor {
  112. int qid;
  113. struct eth_context *cxt;
  114. };
  115. struct bnx2x_vfop_args_defvlan {
  116. int qid;
  117. bool enable;
  118. u16 vid;
  119. u8 prio;
  120. };
  121. struct bnx2x_vfop_args_qx {
  122. int qid;
  123. bool en_add;
  124. };
  125. struct bnx2x_vfop_args_filters {
  126. struct bnx2x_vfop_filters *multi_filter;
  127. atomic_t *credit; /* non NULL means 'don't consume credit' */
  128. };
  129. union bnx2x_vfop_args {
  130. struct bnx2x_vfop_args_mcast mc_list;
  131. struct bnx2x_vfop_args_qctor qctor;
  132. struct bnx2x_vfop_args_qdtor qdtor;
  133. struct bnx2x_vfop_args_defvlan defvlan;
  134. struct bnx2x_vfop_args_qx qx;
  135. struct bnx2x_vfop_args_filters filters;
  136. };
  137. struct bnx2x_vfop {
  138. struct list_head link;
  139. int rc; /* return code */
  140. int state; /* next state */
  141. union bnx2x_vfop_args args; /* extra arguments */
  142. union bnx2x_vfop_params *op_p; /* ramrod params */
  143. /* state machine callbacks */
  144. vfop_handler_t transition;
  145. vfop_handler_t done;
  146. };
  147. /* vf context */
  148. struct bnx2x_virtf {
  149. u16 cfg_flags;
  150. #define VF_CFG_STATS 0x0001
  151. #define VF_CFG_FW_FC 0x0002
  152. #define VF_CFG_TPA 0x0004
  153. #define VF_CFG_INT_SIMD 0x0008
  154. #define VF_CACHE_LINE 0x0010
  155. u8 state;
  156. #define VF_FREE 0 /* VF ready to be acquired holds no resc */
  157. #define VF_ACQUIRED 1 /* VF aquired, but not initalized */
  158. #define VF_ENABLED 2 /* VF Enabled */
  159. #define VF_RESET 3 /* VF FLR'd, pending cleanup */
  160. /* non 0 during flr cleanup */
  161. u8 flr_clnup_stage;
  162. #define VF_FLR_CLN 1 /* reclaim resources and do 'final cleanup'
  163. * sans the end-wait
  164. */
  165. #define VF_FLR_ACK 2 /* ACK flr notification */
  166. #define VF_FLR_EPILOG 3 /* wait for VF remnants to dissipate in the HW
  167. * ~ final cleanup' end wait
  168. */
  169. /* dma */
  170. dma_addr_t fw_stat_map; /* valid iff VF_CFG_STATS */
  171. dma_addr_t spq_map;
  172. dma_addr_t bulletin_map;
  173. /* Allocated resources counters. Before the VF is acquired, the
  174. * counters hold the following values:
  175. *
  176. * - xxq_count = 0 as the queues memory is not allocated yet.
  177. *
  178. * - sb_count = The number of status blocks configured for this VF in
  179. * the IGU CAM. Initially read during probe.
  180. *
  181. * - xx_rules_count = The number of rules statically and equally
  182. * allocated for each VF, during PF load.
  183. */
  184. struct vf_pf_resc_request alloc_resc;
  185. #define vf_rxq_count(vf) ((vf)->alloc_resc.num_rxqs)
  186. #define vf_txq_count(vf) ((vf)->alloc_resc.num_txqs)
  187. #define vf_sb_count(vf) ((vf)->alloc_resc.num_sbs)
  188. #define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
  189. #define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
  190. #define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
  191. u8 sb_count; /* actual number of SBs */
  192. u8 igu_base_id; /* base igu status block id */
  193. struct bnx2x_vf_queue *vfqs;
  194. #define bnx2x_vfq(vf, nr, var) ((vf)->vfqs[(nr)].var)
  195. u8 index; /* index in the vf array */
  196. u8 abs_vfid;
  197. u8 sp_cl_id;
  198. u32 error; /* 0 means all's-well */
  199. /* BDF */
  200. unsigned int bus;
  201. unsigned int devfn;
  202. /* bars */
  203. struct bnx2x_vf_bar bars[PCI_SRIOV_NUM_BARS];
  204. /* set-mac ramrod state 1-pending, 0-done */
  205. unsigned long filter_state;
  206. /* leading rss client id ~~ the client id of the first rxq, must be
  207. * set for each txq.
  208. */
  209. int leading_rss;
  210. /* MCAST object */
  211. struct bnx2x_mcast_obj mcast_obj;
  212. /* RSS configuration object */
  213. struct bnx2x_rss_config_obj rss_conf_obj;
  214. /* slow-path operations */
  215. atomic_t op_in_progress;
  216. int op_rc;
  217. bool op_wait_blocking;
  218. struct list_head op_list_head;
  219. union bnx2x_vfop_params op_params;
  220. struct mutex op_mutex; /* one vfop at a time mutex */
  221. enum channel_tlvs op_current;
  222. };
  223. #define BNX2X_NR_VIRTFN(bp) ((bp)->vfdb->sriov.nr_virtfn)
  224. #define for_each_vf(bp, var) \
  225. for ((var) = 0; (var) < BNX2X_NR_VIRTFN(bp); (var)++)
  226. #define for_each_vfq(vf, var) \
  227. for ((var) = 0; (var) < vf_rxq_count(vf); (var)++)
  228. #define for_each_vf_sb(vf, var) \
  229. for ((var) = 0; (var) < vf_sb_count(vf); (var)++)
  230. #define is_vf_multi(vf) (vf_rxq_count(vf) > 1)
  231. #define HW_VF_HANDLE(bp, abs_vfid) \
  232. (u16)(BP_ABS_FUNC((bp)) | (1<<3) | ((u16)(abs_vfid) << 4))
  233. #define FW_PF_MAX_HANDLE 8
  234. #define FW_VF_HANDLE(abs_vfid) \
  235. (abs_vfid + FW_PF_MAX_HANDLE)
  236. /* locking and unlocking the channel mutex */
  237. void bnx2x_lock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
  238. enum channel_tlvs tlv);
  239. void bnx2x_unlock_vf_pf_channel(struct bnx2x *bp, struct bnx2x_virtf *vf,
  240. enum channel_tlvs expected_tlv);
  241. /* VF mail box (aka vf-pf channel) */
  242. /* a container for the bi-directional vf<-->pf messages.
  243. * The actual response will be placed according to the offset parameter
  244. * provided in the request
  245. */
  246. #define MBX_MSG_ALIGN 8
  247. #define MBX_MSG_ALIGNED_SIZE (roundup(sizeof(struct bnx2x_vf_mbx_msg), \
  248. MBX_MSG_ALIGN))
  249. struct bnx2x_vf_mbx_msg {
  250. union vfpf_tlvs req;
  251. union pfvf_tlvs resp;
  252. };
  253. struct bnx2x_vf_mbx {
  254. struct bnx2x_vf_mbx_msg *msg;
  255. dma_addr_t msg_mapping;
  256. /* VF GPA address */
  257. u32 vf_addr_lo;
  258. u32 vf_addr_hi;
  259. struct vfpf_first_tlv first_tlv; /* saved VF request header */
  260. u8 flags;
  261. #define VF_MSG_INPROCESS 0x1 /* failsafe - the FW should prevent
  262. * more then one pending msg
  263. */
  264. };
  265. struct bnx2x_vf_sp {
  266. union {
  267. struct eth_classify_rules_ramrod_data e2;
  268. } mac_rdata;
  269. union {
  270. struct eth_classify_rules_ramrod_data e2;
  271. } vlan_rdata;
  272. union {
  273. struct eth_filter_rules_ramrod_data e2;
  274. } rx_mode_rdata;
  275. union {
  276. struct eth_multicast_rules_ramrod_data e2;
  277. } mcast_rdata;
  278. union {
  279. struct client_init_ramrod_data init_data;
  280. struct client_update_ramrod_data update_data;
  281. } q_data;
  282. };
  283. struct hw_dma {
  284. void *addr;
  285. dma_addr_t mapping;
  286. size_t size;
  287. };
  288. struct bnx2x_vfdb {
  289. #define BP_VFDB(bp) ((bp)->vfdb)
  290. /* vf array */
  291. struct bnx2x_virtf *vfs;
  292. #define BP_VF(bp, idx) (&((bp)->vfdb->vfs[(idx)]))
  293. #define bnx2x_vf(bp, idx, var) ((bp)->vfdb->vfs[(idx)].var)
  294. /* queue array - for all vfs */
  295. struct bnx2x_vf_queue *vfqs;
  296. /* vf HW contexts */
  297. struct hw_dma context[BNX2X_VF_CIDS/ILT_PAGE_CIDS];
  298. #define BP_VF_CXT_PAGE(bp, i) (&(bp)->vfdb->context[(i)])
  299. /* SR-IOV information */
  300. struct bnx2x_sriov sriov;
  301. struct hw_dma mbx_dma;
  302. #define BP_VF_MBX_DMA(bp) (&((bp)->vfdb->mbx_dma))
  303. struct bnx2x_vf_mbx mbxs[BNX2X_MAX_NUM_OF_VFS];
  304. #define BP_VF_MBX(bp, vfid) (&((bp)->vfdb->mbxs[(vfid)]))
  305. struct hw_dma sp_dma;
  306. #define bnx2x_vf_sp(bp, vf, field) ((bp)->vfdb->sp_dma.addr + \
  307. (vf)->index * sizeof(struct bnx2x_vf_sp) + \
  308. offsetof(struct bnx2x_vf_sp, field))
  309. #define bnx2x_vf_sp_map(bp, vf, field) ((bp)->vfdb->sp_dma.mapping + \
  310. (vf)->index * sizeof(struct bnx2x_vf_sp) + \
  311. offsetof(struct bnx2x_vf_sp, field))
  312. #define FLRD_VFS_DWORDS (BNX2X_MAX_NUM_OF_VFS / 32)
  313. u32 flrd_vfs[FLRD_VFS_DWORDS];
  314. };
  315. /* queue access */
  316. static inline struct bnx2x_vf_queue *vfq_get(struct bnx2x_virtf *vf, u8 index)
  317. {
  318. return &(vf->vfqs[index]);
  319. }
  320. static inline bool vfq_is_leading(struct bnx2x_vf_queue *vfq)
  321. {
  322. return (vfq->index == 0);
  323. }
  324. /* FW ids */
  325. static inline u8 vf_igu_sb(struct bnx2x_virtf *vf, u16 sb_idx)
  326. {
  327. return vf->igu_base_id + sb_idx;
  328. }
  329. static inline u8 vf_hc_qzone(struct bnx2x_virtf *vf, u16 sb_idx)
  330. {
  331. return vf_igu_sb(vf, sb_idx);
  332. }
  333. static u8 vfq_cl_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  334. {
  335. return vf->igu_base_id + q->index;
  336. }
  337. static inline u8 vfq_stat_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  338. {
  339. return vfq_cl_id(vf, q);
  340. }
  341. static inline u8 vfq_qzone_id(struct bnx2x_virtf *vf, struct bnx2x_vf_queue *q)
  342. {
  343. return vfq_cl_id(vf, q);
  344. }
  345. /* global iov routines */
  346. int bnx2x_iov_init_ilt(struct bnx2x *bp, u16 line);
  347. int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, int num_vfs_param);
  348. void bnx2x_iov_remove_one(struct bnx2x *bp);
  349. void bnx2x_iov_free_mem(struct bnx2x *bp);
  350. int bnx2x_iov_alloc_mem(struct bnx2x *bp);
  351. int bnx2x_iov_nic_init(struct bnx2x *bp);
  352. void bnx2x_iov_init_dq(struct bnx2x *bp);
  353. void bnx2x_iov_init_dmae(struct bnx2x *bp);
  354. void bnx2x_iov_set_queue_sp_obj(struct bnx2x *bp, int vf_cid,
  355. struct bnx2x_queue_sp_obj **q_obj);
  356. void bnx2x_iov_sp_event(struct bnx2x *bp, int vf_cid, bool queue_work);
  357. int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem);
  358. void bnx2x_iov_adjust_stats_req(struct bnx2x *bp);
  359. void bnx2x_iov_storm_stats_update(struct bnx2x *bp);
  360. void bnx2x_iov_sp_task(struct bnx2x *bp);
  361. /* global vf mailbox routines */
  362. void bnx2x_vf_mbx(struct bnx2x *bp, struct vf_pf_event_data *vfpf_event);
  363. void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid);
  364. /* CORE VF API */
  365. typedef u8 bnx2x_mac_addr_t[ETH_ALEN];
  366. /* acquire */
  367. int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
  368. struct vf_pf_resc_request *resc);
  369. /* init */
  370. int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
  371. dma_addr_t *sb_map);
  372. /* VFOP generic helpers */
  373. #define bnx2x_vfop_default(state) do { \
  374. BNX2X_ERR("Bad state %d\n", (state)); \
  375. vfop->rc = -EINVAL; \
  376. goto op_err; \
  377. } while (0)
  378. enum {
  379. VFOP_DONE,
  380. VFOP_CONT,
  381. VFOP_VERIFY_PEND,
  382. };
  383. #define bnx2x_vfop_finalize(vf, rc, next) do { \
  384. if ((rc) < 0) \
  385. goto op_err; \
  386. else if ((rc) > 0) \
  387. goto op_pending; \
  388. else if ((next) == VFOP_DONE) \
  389. goto op_done; \
  390. else if ((next) == VFOP_VERIFY_PEND) \
  391. BNX2X_ERR("expected pending\n"); \
  392. else { \
  393. DP(BNX2X_MSG_IOV, "no ramrod. scheduling\n"); \
  394. atomic_set(&vf->op_in_progress, 1); \
  395. queue_delayed_work(bnx2x_wq, &bp->sp_task, 0); \
  396. return; \
  397. } \
  398. } while (0)
  399. #define bnx2x_vfop_opset(first_state, trans_hndlr, done_hndlr) \
  400. do { \
  401. vfop->state = first_state; \
  402. vfop->op_p = &vf->op_params; \
  403. vfop->transition = trans_hndlr; \
  404. vfop->done = done_hndlr; \
  405. } while (0)
  406. static inline struct bnx2x_vfop *bnx2x_vfop_cur(struct bnx2x *bp,
  407. struct bnx2x_virtf *vf)
  408. {
  409. WARN(!mutex_is_locked(&vf->op_mutex), "about to access vf op linked list but mutex was not locked!");
  410. WARN_ON(list_empty(&vf->op_list_head));
  411. return list_first_entry(&vf->op_list_head, struct bnx2x_vfop, link);
  412. }
  413. static inline struct bnx2x_vfop *bnx2x_vfop_add(struct bnx2x *bp,
  414. struct bnx2x_virtf *vf)
  415. {
  416. struct bnx2x_vfop *vfop = kzalloc(sizeof(*vfop), GFP_KERNEL);
  417. WARN(!mutex_is_locked(&vf->op_mutex), "about to access vf op linked list but mutex was not locked!");
  418. if (vfop) {
  419. INIT_LIST_HEAD(&vfop->link);
  420. list_add(&vfop->link, &vf->op_list_head);
  421. }
  422. return vfop;
  423. }
  424. static inline void bnx2x_vfop_end(struct bnx2x *bp, struct bnx2x_virtf *vf,
  425. struct bnx2x_vfop *vfop)
  426. {
  427. /* rc < 0 - error, otherwise set to 0 */
  428. DP(BNX2X_MSG_IOV, "rc was %d\n", vfop->rc);
  429. if (vfop->rc >= 0)
  430. vfop->rc = 0;
  431. DP(BNX2X_MSG_IOV, "rc is now %d\n", vfop->rc);
  432. /* unlink the current op context and propagate error code
  433. * must be done before invoking the 'done()' handler
  434. */
  435. WARN(!mutex_is_locked(&vf->op_mutex),
  436. "about to access vf op linked list but mutex was not locked!");
  437. list_del(&vfop->link);
  438. if (list_empty(&vf->op_list_head)) {
  439. DP(BNX2X_MSG_IOV, "list was empty %d\n", vfop->rc);
  440. vf->op_rc = vfop->rc;
  441. DP(BNX2X_MSG_IOV, "copying rc vf->op_rc %d, vfop->rc %d\n",
  442. vf->op_rc, vfop->rc);
  443. } else {
  444. struct bnx2x_vfop *cur_vfop;
  445. DP(BNX2X_MSG_IOV, "list not empty %d\n", vfop->rc);
  446. cur_vfop = bnx2x_vfop_cur(bp, vf);
  447. cur_vfop->rc = vfop->rc;
  448. DP(BNX2X_MSG_IOV, "copying rc vf->op_rc %d, vfop->rc %d\n",
  449. vf->op_rc, vfop->rc);
  450. }
  451. /* invoke done handler */
  452. if (vfop->done) {
  453. DP(BNX2X_MSG_IOV, "calling done handler\n");
  454. vfop->done(bp, vf);
  455. }
  456. DP(BNX2X_MSG_IOV, "done handler complete. vf->op_rc %d, vfop->rc %d\n",
  457. vf->op_rc, vfop->rc);
  458. /* if this is the last nested op reset the wait_blocking flag
  459. * to release any blocking wrappers, only after 'done()' is invoked
  460. */
  461. if (list_empty(&vf->op_list_head)) {
  462. DP(BNX2X_MSG_IOV, "list was empty after done %d\n", vfop->rc);
  463. vf->op_wait_blocking = false;
  464. }
  465. kfree(vfop);
  466. }
  467. static inline int bnx2x_vfop_wait_blocking(struct bnx2x *bp,
  468. struct bnx2x_virtf *vf)
  469. {
  470. /* can take a while if any port is running */
  471. int cnt = 5000;
  472. might_sleep();
  473. while (cnt--) {
  474. if (vf->op_wait_blocking == false) {
  475. #ifdef BNX2X_STOP_ON_ERROR
  476. DP(BNX2X_MSG_IOV, "exit (cnt %d)\n", 5000 - cnt);
  477. #endif
  478. return 0;
  479. }
  480. usleep_range(1000, 2000);
  481. if (bp->panic)
  482. return -EIO;
  483. }
  484. /* timeout! */
  485. #ifdef BNX2X_STOP_ON_ERROR
  486. bnx2x_panic();
  487. #endif
  488. return -EBUSY;
  489. }
  490. static inline int bnx2x_vfop_transition(struct bnx2x *bp,
  491. struct bnx2x_virtf *vf,
  492. vfop_handler_t transition,
  493. bool block)
  494. {
  495. if (block)
  496. vf->op_wait_blocking = true;
  497. transition(bp, vf);
  498. if (block)
  499. return bnx2x_vfop_wait_blocking(bp, vf);
  500. return 0;
  501. }
  502. /* VFOP queue construction helpers */
  503. void bnx2x_vfop_qctor_dump_tx(struct bnx2x *bp, struct bnx2x_virtf *vf,
  504. struct bnx2x_queue_init_params *init_params,
  505. struct bnx2x_queue_setup_params *setup_params,
  506. u16 q_idx, u16 sb_idx);
  507. void bnx2x_vfop_qctor_dump_rx(struct bnx2x *bp, struct bnx2x_virtf *vf,
  508. struct bnx2x_queue_init_params *init_params,
  509. struct bnx2x_queue_setup_params *setup_params,
  510. u16 q_idx, u16 sb_idx);
  511. void bnx2x_vfop_qctor_prep(struct bnx2x *bp,
  512. struct bnx2x_virtf *vf,
  513. struct bnx2x_vf_queue *q,
  514. struct bnx2x_vfop_qctor_params *p,
  515. unsigned long q_type);
  516. int bnx2x_vfop_mac_list_cmd(struct bnx2x *bp,
  517. struct bnx2x_virtf *vf,
  518. struct bnx2x_vfop_cmd *cmd,
  519. struct bnx2x_vfop_filters *macs,
  520. int qid, bool drv_only);
  521. int bnx2x_vfop_vlan_set_cmd(struct bnx2x *bp,
  522. struct bnx2x_virtf *vf,
  523. struct bnx2x_vfop_cmd *cmd,
  524. int qid, u16 vid, bool add);
  525. int bnx2x_vfop_vlan_list_cmd(struct bnx2x *bp,
  526. struct bnx2x_virtf *vf,
  527. struct bnx2x_vfop_cmd *cmd,
  528. struct bnx2x_vfop_filters *vlans,
  529. int qid, bool drv_only);
  530. int bnx2x_vfop_qsetup_cmd(struct bnx2x *bp,
  531. struct bnx2x_virtf *vf,
  532. struct bnx2x_vfop_cmd *cmd,
  533. int qid);
  534. int bnx2x_vfop_mcast_cmd(struct bnx2x *bp,
  535. struct bnx2x_virtf *vf,
  536. struct bnx2x_vfop_cmd *cmd,
  537. bnx2x_mac_addr_t *mcasts,
  538. int mcast_num, bool drv_only);
  539. int bnx2x_vfop_rxmode_cmd(struct bnx2x *bp,
  540. struct bnx2x_virtf *vf,
  541. struct bnx2x_vfop_cmd *cmd,
  542. int qid, unsigned long accept_flags);
  543. int bnx2x_vf_idx_by_abs_fid(struct bnx2x *bp, u16 abs_vfid);
  544. u8 bnx2x_vf_max_queue_cnt(struct bnx2x *bp, struct bnx2x_virtf *vf);
  545. /* VF FLR helpers */
  546. int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid);
  547. void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid);
  548. void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
  549. u16 length);
  550. void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
  551. u16 type, u16 length);
  552. void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list);
  553. bool bnx2x_tlv_supported(u16 tlvtype);
  554. #endif /* bnx2x_sriov.h */