bnx2x_vfpf.h 12 KB

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