bnx2x_vfpf.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /* bnx2x_vfpf.h: Qlogic Everest network driver.
  2. *
  3. * Copyright (c) 2011-2013 Broadcom Corporation
  4. * Copyright (c) 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 (the “GPL”),
  10. * available at http://www.gnu.org/licenses/gpl-2.0.html, with the following
  11. * added to such license:
  12. *
  13. * As a special exception, the copyright holders of this software give you
  14. * permission to link this software with independent modules, and to copy and
  15. * distribute the resulting executable under terms of your choice, provided that
  16. * you also meet, for each linked independent module, the terms and conditions
  17. * of the license of that module. An independent module is a module which is
  18. * not derived from this software. The special exception does not apply to any
  19. * modifications of the software.
  20. *
  21. * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
  22. * Written by: Ariel Elior <ariel.elior@qlogic.com>
  23. */
  24. #ifndef VF_PF_IF_H
  25. #define VF_PF_IF_H
  26. #ifdef CONFIG_BNX2X_SRIOV
  27. /* Common definitions for all HVs */
  28. struct vf_pf_resc_request {
  29. u8 num_rxqs;
  30. u8 num_txqs;
  31. u8 num_sbs;
  32. u8 num_mac_filters;
  33. u8 num_vlan_filters;
  34. u8 num_mc_filters; /* No limit so superfluous */
  35. };
  36. struct hw_sb_info {
  37. u8 hw_sb_id; /* aka absolute igu id, used to ack the sb */
  38. u8 sb_qid; /* used to update DHC for sb */
  39. };
  40. /* HW VF-PF channel definitions
  41. * A.K.A VF-PF mailbox
  42. */
  43. #define TLV_BUFFER_SIZE 1024
  44. #define PF_VF_BULLETIN_SIZE 512
  45. #define VFPF_QUEUE_FLG_TPA 0x0001
  46. #define VFPF_QUEUE_FLG_TPA_IPV6 0x0002
  47. #define VFPF_QUEUE_FLG_TPA_GRO 0x0004
  48. #define VFPF_QUEUE_FLG_CACHE_ALIGN 0x0008
  49. #define VFPF_QUEUE_FLG_STATS 0x0010
  50. #define VFPF_QUEUE_FLG_OV 0x0020
  51. #define VFPF_QUEUE_FLG_VLAN 0x0040
  52. #define VFPF_QUEUE_FLG_COS 0x0080
  53. #define VFPF_QUEUE_FLG_HC 0x0100
  54. #define VFPF_QUEUE_FLG_DHC 0x0200
  55. #define VFPF_QUEUE_FLG_LEADING_RSS 0x0400
  56. #define VFPF_QUEUE_DROP_IP_CS_ERR (1 << 0)
  57. #define VFPF_QUEUE_DROP_TCP_CS_ERR (1 << 1)
  58. #define VFPF_QUEUE_DROP_TTL0 (1 << 2)
  59. #define VFPF_QUEUE_DROP_UDP_CS_ERR (1 << 3)
  60. #define VFPF_RX_MASK_ACCEPT_NONE 0x00000000
  61. #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST 0x00000001
  62. #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST 0x00000002
  63. #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST 0x00000004
  64. #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST 0x00000008
  65. #define VFPF_RX_MASK_ACCEPT_BROADCAST 0x00000010
  66. #define VFPF_RX_MASK_ACCEPT_ANY_VLAN 0x00000020
  67. #define BULLETIN_CONTENT_SIZE (sizeof(struct pf_vf_bulletin_content))
  68. #define BULLETIN_CONTENT_LEGACY_SIZE (32)
  69. #define BULLETIN_ATTEMPTS 5 /* crc failures before throwing towel */
  70. #define BULLETIN_CRC_SEED 0
  71. enum {
  72. PFVF_STATUS_WAITING = 0,
  73. PFVF_STATUS_SUCCESS,
  74. PFVF_STATUS_FAILURE,
  75. PFVF_STATUS_NOT_SUPPORTED,
  76. PFVF_STATUS_NO_RESOURCE
  77. };
  78. /* vf pf channel tlvs */
  79. /* general tlv header (used for both vf->pf request and pf->vf response) */
  80. struct channel_tlv {
  81. u16 type;
  82. u16 length;
  83. };
  84. /* header of first vf->pf tlv carries the offset used to calculate response
  85. * buffer address
  86. */
  87. struct vfpf_first_tlv {
  88. struct channel_tlv tl;
  89. u32 resp_msg_offset;
  90. };
  91. /* header of pf->vf tlvs, carries the status of handling the request */
  92. struct pfvf_tlv {
  93. struct channel_tlv tl;
  94. u8 status;
  95. u8 padding[3];
  96. };
  97. /* response tlv used for most tlvs */
  98. struct pfvf_general_resp_tlv {
  99. struct pfvf_tlv hdr;
  100. };
  101. /* used to terminate and pad a tlv list */
  102. struct channel_list_end_tlv {
  103. struct channel_tlv tl;
  104. u8 padding[4];
  105. };
  106. /* Acquire */
  107. struct vfpf_acquire_tlv {
  108. struct vfpf_first_tlv first_tlv;
  109. struct vf_pf_vfdev_info {
  110. /* the following fields are for debug purposes */
  111. u8 vf_id; /* ME register value */
  112. u8 vf_os; /* e.g. Linux, W2K8 */
  113. #define VF_OS_SUBVERSION_MASK (0x1f)
  114. #define VF_OS_MASK (0xe0)
  115. #define VF_OS_SHIFT (5)
  116. #define VF_OS_UNDEFINED (0 << VF_OS_SHIFT)
  117. #define VF_OS_WINDOWS (1 << VF_OS_SHIFT)
  118. u8 fp_hsi_ver;
  119. u8 caps;
  120. #define VF_CAP_SUPPORT_EXT_BULLETIN (1 << 0)
  121. #define VF_CAP_SUPPORT_VLAN_FILTER (1 << 1)
  122. } vfdev_info;
  123. struct vf_pf_resc_request resc_request;
  124. aligned_u64 bulletin_addr;
  125. };
  126. /* simple operation request on queue */
  127. struct vfpf_q_op_tlv {
  128. struct vfpf_first_tlv first_tlv;
  129. u8 vf_qid;
  130. u8 padding[3];
  131. };
  132. /* receive side scaling tlv */
  133. struct vfpf_rss_tlv {
  134. struct vfpf_first_tlv first_tlv;
  135. u32 rss_flags;
  136. #define VFPF_RSS_MODE_DISABLED (1 << 0)
  137. #define VFPF_RSS_MODE_REGULAR (1 << 1)
  138. #define VFPF_RSS_SET_SRCH (1 << 2)
  139. #define VFPF_RSS_IPV4 (1 << 3)
  140. #define VFPF_RSS_IPV4_TCP (1 << 4)
  141. #define VFPF_RSS_IPV4_UDP (1 << 5)
  142. #define VFPF_RSS_IPV6 (1 << 6)
  143. #define VFPF_RSS_IPV6_TCP (1 << 7)
  144. #define VFPF_RSS_IPV6_UDP (1 << 8)
  145. u8 rss_result_mask;
  146. u8 ind_table_size;
  147. u8 rss_key_size;
  148. u8 padding;
  149. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  150. u32 rss_key[T_ETH_RSS_KEY]; /* hash values */
  151. };
  152. /* acquire response tlv - carries the allocated resources */
  153. struct pfvf_acquire_resp_tlv {
  154. struct pfvf_tlv hdr;
  155. struct pf_vf_pfdev_info {
  156. u32 chip_num;
  157. u32 pf_cap;
  158. #define PFVF_CAP_RSS 0x00000001
  159. #define PFVF_CAP_DHC 0x00000002
  160. #define PFVF_CAP_TPA 0x00000004
  161. #define PFVF_CAP_TPA_UPDATE 0x00000008
  162. #define PFVF_CAP_VLAN_FILTER 0x00000010
  163. char fw_ver[32];
  164. u16 db_size;
  165. u8 indices_per_sb;
  166. u8 padding;
  167. } pfdev_info;
  168. struct pf_vf_resc {
  169. /* in case of status NO_RESOURCE in message hdr, pf will fill
  170. * this struct with suggested amount of resources for next
  171. * acquire request
  172. */
  173. #define PFVF_MAX_QUEUES_PER_VF 16
  174. #define PFVF_MAX_SBS_PER_VF 16
  175. struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
  176. u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
  177. u8 num_rxqs;
  178. u8 num_txqs;
  179. u8 num_sbs;
  180. u8 num_mac_filters;
  181. u8 num_vlan_filters;
  182. u8 num_mc_filters;
  183. u8 permanent_mac_addr[ETH_ALEN];
  184. u8 current_mac_addr[ETH_ALEN];
  185. u8 padding[2];
  186. } resc;
  187. };
  188. struct vfpf_port_phys_id_resp_tlv {
  189. struct channel_tlv tl;
  190. u8 id[ETH_ALEN];
  191. u8 padding[2];
  192. };
  193. struct vfpf_fp_hsi_resp_tlv {
  194. struct channel_tlv tl;
  195. u8 is_supported;
  196. u8 padding[3];
  197. };
  198. #define VFPF_INIT_FLG_STATS_COALESCE (1 << 0) /* when set the VFs queues
  199. * stats will be coalesced on
  200. * the leading RSS queue
  201. */
  202. /* Init VF */
  203. struct vfpf_init_tlv {
  204. struct vfpf_first_tlv first_tlv;
  205. aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
  206. aligned_u64 spq_addr;
  207. aligned_u64 stats_addr;
  208. u16 stats_stride;
  209. u32 flags;
  210. u32 padding[2];
  211. };
  212. /* Setup Queue */
  213. struct vfpf_setup_q_tlv {
  214. struct vfpf_first_tlv first_tlv;
  215. struct vf_pf_rxq_params {
  216. /* physical addresses */
  217. aligned_u64 rcq_addr;
  218. aligned_u64 rcq_np_addr;
  219. aligned_u64 rxq_addr;
  220. aligned_u64 sge_addr;
  221. /* sb + hc info */
  222. u8 vf_sb; /* index in hw_sbs[] */
  223. u8 sb_index; /* Index in the SB */
  224. u16 hc_rate; /* desired interrupts per sec. */
  225. /* valid iff VFPF_QUEUE_FLG_HC */
  226. /* rx buffer info */
  227. u16 mtu;
  228. u16 buf_sz;
  229. u16 flags; /* VFPF_QUEUE_FLG_X flags */
  230. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  231. /* valid iff VFPF_QUEUE_FLG_TPA */
  232. u16 sge_buf_sz;
  233. u16 tpa_agg_sz;
  234. u8 max_sge_pkt;
  235. u8 drop_flags; /* VFPF_QUEUE_DROP_X, for Linux VMs
  236. * all the flags are turned off
  237. */
  238. u8 cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
  239. u8 padding;
  240. } rxq;
  241. struct vf_pf_txq_params {
  242. /* physical addresses */
  243. aligned_u64 txq_addr;
  244. /* sb + hc info */
  245. u8 vf_sb; /* index in hw_sbs[] */
  246. u8 sb_index; /* Index in the SB */
  247. u16 hc_rate; /* desired interrupts per sec. */
  248. /* valid iff VFPF_QUEUE_FLG_HC */
  249. u32 flags; /* VFPF_QUEUE_FLG_X flags */
  250. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  251. u8 traffic_type; /* see in setup_context() */
  252. u8 padding;
  253. } txq;
  254. u8 vf_qid; /* index in hw_qid[] */
  255. u8 param_valid;
  256. #define VFPF_RXQ_VALID 0x01
  257. #define VFPF_TXQ_VALID 0x02
  258. u8 padding[2];
  259. };
  260. /* Set Queue Filters */
  261. struct vfpf_q_mac_vlan_filter {
  262. u32 flags;
  263. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  264. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  265. #define VFPF_Q_FILTER_SET 0x100 /* set/clear */
  266. u8 mac[ETH_ALEN];
  267. u16 vlan_tag;
  268. };
  269. /* configure queue filters */
  270. struct vfpf_set_q_filters_tlv {
  271. struct vfpf_first_tlv first_tlv;
  272. u32 flags;
  273. #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
  274. #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED 0x02
  275. #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED 0x04
  276. u8 vf_qid; /* index in hw_qid[] */
  277. u8 n_mac_vlan_filters;
  278. u8 n_multicast;
  279. u8 padding;
  280. #define PFVF_MAX_MAC_FILTERS 16
  281. #define PFVF_MAX_VLAN_FILTERS 16
  282. #define PFVF_MAX_FILTERS (PFVF_MAX_MAC_FILTERS +\
  283. PFVF_MAX_VLAN_FILTERS)
  284. struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
  285. #define PFVF_MAX_MULTICAST_PER_VF 32
  286. u8 multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
  287. u32 rx_mask; /* see mask constants at the top of the file */
  288. };
  289. struct vfpf_tpa_tlv {
  290. struct vfpf_first_tlv first_tlv;
  291. struct vf_pf_tpa_client_info {
  292. aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
  293. u8 update_ipv4;
  294. u8 update_ipv6;
  295. u8 max_tpa_queues;
  296. u8 max_sges_for_packet;
  297. u8 complete_on_both_clients;
  298. u8 dont_verify_thr;
  299. u8 tpa_mode;
  300. u16 sge_buff_size;
  301. u16 max_agg_size;
  302. u16 sge_pause_thr_low;
  303. u16 sge_pause_thr_high;
  304. } tpa_client_info;
  305. };
  306. /* close VF (disable VF) */
  307. struct vfpf_close_tlv {
  308. struct vfpf_first_tlv first_tlv;
  309. u16 vf_id; /* for debug */
  310. u8 padding[2];
  311. };
  312. /* release the VF's acquired resources */
  313. struct vfpf_release_tlv {
  314. struct vfpf_first_tlv first_tlv;
  315. u16 vf_id;
  316. u8 padding[2];
  317. };
  318. struct tlv_buffer_size {
  319. u8 tlv_buffer[TLV_BUFFER_SIZE];
  320. };
  321. union vfpf_tlvs {
  322. struct vfpf_first_tlv first_tlv;
  323. struct vfpf_acquire_tlv acquire;
  324. struct vfpf_init_tlv init;
  325. struct vfpf_close_tlv close;
  326. struct vfpf_q_op_tlv q_op;
  327. struct vfpf_setup_q_tlv setup_q;
  328. struct vfpf_set_q_filters_tlv set_q_filters;
  329. struct vfpf_release_tlv release;
  330. struct vfpf_rss_tlv update_rss;
  331. struct vfpf_tpa_tlv update_tpa;
  332. struct channel_list_end_tlv list_end;
  333. struct tlv_buffer_size tlv_buf_size;
  334. };
  335. union pfvf_tlvs {
  336. struct pfvf_general_resp_tlv general_resp;
  337. struct pfvf_acquire_resp_tlv acquire_resp;
  338. struct channel_list_end_tlv list_end;
  339. struct tlv_buffer_size tlv_buf_size;
  340. };
  341. /* This is a structure which is allocated in the VF, which the PF may update
  342. * when it deems it necessary to do so. The bulletin board is sampled
  343. * periodically by the VF. A copy per VF is maintained in the PF (to prevent
  344. * loss of data upon multiple updates (or the need for read modify write)).
  345. */
  346. struct pf_vf_bulletin_size {
  347. u8 size[PF_VF_BULLETIN_SIZE];
  348. };
  349. struct pf_vf_bulletin_content {
  350. u32 crc; /* crc of structure to ensure is not in
  351. * mid-update
  352. */
  353. u16 version;
  354. u16 length;
  355. aligned_u64 valid_bitmap; /* bitmap indicating which fields
  356. * hold valid values
  357. */
  358. #define MAC_ADDR_VALID 0 /* alert the vf that a new mac address
  359. * is available for it
  360. */
  361. #define VLAN_VALID 1 /* when set, the vf should not access
  362. * the vfpf channel
  363. */
  364. #define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
  365. * to attempt to send messages on the
  366. * channel after this bit is set
  367. */
  368. #define LINK_VALID 3 /* alert the VF thet a new link status
  369. * update is available for it
  370. */
  371. u8 mac[ETH_ALEN];
  372. u8 mac_padding[2];
  373. u16 vlan;
  374. u8 vlan_padding[6];
  375. u16 link_speed; /* Effective line speed */
  376. u8 link_speed_padding[6];
  377. u32 link_flags; /* VFPF_LINK_REPORT_XXX flags */
  378. #define VFPF_LINK_REPORT_LINK_DOWN (1 << 0)
  379. #define VFPF_LINK_REPORT_FULL_DUPLEX (1 << 1)
  380. #define VFPF_LINK_REPORT_RX_FC_ON (1 << 2)
  381. #define VFPF_LINK_REPORT_TX_FC_ON (1 << 3)
  382. u8 link_flags_padding[4];
  383. };
  384. union pf_vf_bulletin {
  385. struct pf_vf_bulletin_content content;
  386. struct pf_vf_bulletin_size size;
  387. };
  388. #define MAX_TLVS_IN_LIST 50
  389. enum channel_tlvs {
  390. CHANNEL_TLV_NONE,
  391. CHANNEL_TLV_ACQUIRE,
  392. CHANNEL_TLV_INIT,
  393. CHANNEL_TLV_SETUP_Q,
  394. CHANNEL_TLV_SET_Q_FILTERS,
  395. CHANNEL_TLV_ACTIVATE_Q,
  396. CHANNEL_TLV_DEACTIVATE_Q,
  397. CHANNEL_TLV_TEARDOWN_Q,
  398. CHANNEL_TLV_CLOSE,
  399. CHANNEL_TLV_RELEASE,
  400. CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
  401. CHANNEL_TLV_PF_RELEASE_VF,
  402. CHANNEL_TLV_LIST_END,
  403. CHANNEL_TLV_FLR,
  404. CHANNEL_TLV_PF_SET_MAC,
  405. CHANNEL_TLV_PF_SET_VLAN,
  406. CHANNEL_TLV_UPDATE_RSS,
  407. CHANNEL_TLV_PHYS_PORT_ID,
  408. CHANNEL_TLV_UPDATE_TPA,
  409. CHANNEL_TLV_FP_HSI_SUPPORT,
  410. CHANNEL_TLV_MAX
  411. };
  412. #endif /* CONFIG_BNX2X_SRIOV */
  413. #endif /* VF_PF_IF_H */