bnx2x_vfpf.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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 padding;
  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. #define VFPF_INIT_FLG_STATS_COALESCE (1 << 0) /* when set the VFs queues
  185. * stats will be coalesced on
  186. * the leading RSS queue
  187. */
  188. /* Init VF */
  189. struct vfpf_init_tlv {
  190. struct vfpf_first_tlv first_tlv;
  191. aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
  192. aligned_u64 spq_addr;
  193. aligned_u64 stats_addr;
  194. u16 stats_stride;
  195. u32 flags;
  196. u32 padding[2];
  197. };
  198. /* Setup Queue */
  199. struct vfpf_setup_q_tlv {
  200. struct vfpf_first_tlv first_tlv;
  201. struct vf_pf_rxq_params {
  202. /* physical addresses */
  203. aligned_u64 rcq_addr;
  204. aligned_u64 rcq_np_addr;
  205. aligned_u64 rxq_addr;
  206. aligned_u64 sge_addr;
  207. /* sb + hc info */
  208. u8 vf_sb; /* index in hw_sbs[] */
  209. u8 sb_index; /* Index in the SB */
  210. u16 hc_rate; /* desired interrupts per sec. */
  211. /* valid iff VFPF_QUEUE_FLG_HC */
  212. /* rx buffer info */
  213. u16 mtu;
  214. u16 buf_sz;
  215. u16 flags; /* VFPF_QUEUE_FLG_X flags */
  216. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  217. /* valid iff VFPF_QUEUE_FLG_TPA */
  218. u16 sge_buf_sz;
  219. u16 tpa_agg_sz;
  220. u8 max_sge_pkt;
  221. u8 drop_flags; /* VFPF_QUEUE_DROP_X, for Linux VMs
  222. * all the flags are turned off
  223. */
  224. u8 cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
  225. u8 padding;
  226. } rxq;
  227. struct vf_pf_txq_params {
  228. /* physical addresses */
  229. aligned_u64 txq_addr;
  230. /* sb + hc info */
  231. u8 vf_sb; /* index in hw_sbs[] */
  232. u8 sb_index; /* Index in the SB */
  233. u16 hc_rate; /* desired interrupts per sec. */
  234. /* valid iff VFPF_QUEUE_FLG_HC */
  235. u32 flags; /* VFPF_QUEUE_FLG_X flags */
  236. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  237. u8 traffic_type; /* see in setup_context() */
  238. u8 padding;
  239. } txq;
  240. u8 vf_qid; /* index in hw_qid[] */
  241. u8 param_valid;
  242. #define VFPF_RXQ_VALID 0x01
  243. #define VFPF_TXQ_VALID 0x02
  244. u8 padding[2];
  245. };
  246. /* Set Queue Filters */
  247. struct vfpf_q_mac_vlan_filter {
  248. u32 flags;
  249. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  250. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  251. #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
  252. u8 mac[ETH_ALEN];
  253. u16 vlan_tag;
  254. };
  255. /* configure queue filters */
  256. struct vfpf_set_q_filters_tlv {
  257. struct vfpf_first_tlv first_tlv;
  258. u32 flags;
  259. #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
  260. #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED 0x02
  261. #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED 0x04
  262. u8 vf_qid; /* index in hw_qid[] */
  263. u8 n_mac_vlan_filters;
  264. u8 n_multicast;
  265. u8 padding;
  266. #define PFVF_MAX_MAC_FILTERS 16
  267. #define PFVF_MAX_VLAN_FILTERS 16
  268. #define PFVF_MAX_FILTERS (PFVF_MAX_MAC_FILTERS +\
  269. PFVF_MAX_VLAN_FILTERS)
  270. struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
  271. #define PFVF_MAX_MULTICAST_PER_VF 32
  272. u8 multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
  273. u32 rx_mask; /* see mask constants at the top of the file */
  274. };
  275. struct vfpf_tpa_tlv {
  276. struct vfpf_first_tlv first_tlv;
  277. struct vf_pf_tpa_client_info {
  278. aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
  279. u8 update_ipv4;
  280. u8 update_ipv6;
  281. u8 max_tpa_queues;
  282. u8 max_sges_for_packet;
  283. u8 complete_on_both_clients;
  284. u8 dont_verify_thr;
  285. u8 tpa_mode;
  286. u16 sge_buff_size;
  287. u16 max_agg_size;
  288. u16 sge_pause_thr_low;
  289. u16 sge_pause_thr_high;
  290. } tpa_client_info;
  291. };
  292. /* close VF (disable VF) */
  293. struct vfpf_close_tlv {
  294. struct vfpf_first_tlv first_tlv;
  295. u16 vf_id; /* for debug */
  296. u8 padding[2];
  297. };
  298. /* release the VF's acquired resources */
  299. struct vfpf_release_tlv {
  300. struct vfpf_first_tlv first_tlv;
  301. u16 vf_id;
  302. u8 padding[2];
  303. };
  304. struct tlv_buffer_size {
  305. u8 tlv_buffer[TLV_BUFFER_SIZE];
  306. };
  307. union vfpf_tlvs {
  308. struct vfpf_first_tlv first_tlv;
  309. struct vfpf_acquire_tlv acquire;
  310. struct vfpf_init_tlv init;
  311. struct vfpf_close_tlv close;
  312. struct vfpf_q_op_tlv q_op;
  313. struct vfpf_setup_q_tlv setup_q;
  314. struct vfpf_set_q_filters_tlv set_q_filters;
  315. struct vfpf_release_tlv release;
  316. struct vfpf_rss_tlv update_rss;
  317. struct vfpf_tpa_tlv update_tpa;
  318. struct channel_list_end_tlv list_end;
  319. struct tlv_buffer_size tlv_buf_size;
  320. };
  321. union pfvf_tlvs {
  322. struct pfvf_general_resp_tlv general_resp;
  323. struct pfvf_acquire_resp_tlv acquire_resp;
  324. struct channel_list_end_tlv list_end;
  325. struct tlv_buffer_size tlv_buf_size;
  326. };
  327. /* This is a structure which is allocated in the VF, which the PF may update
  328. * when it deems it necessary to do so. The bulletin board is sampled
  329. * periodically by the VF. A copy per VF is maintained in the PF (to prevent
  330. * loss of data upon multiple updates (or the need for read modify write)).
  331. */
  332. struct pf_vf_bulletin_size {
  333. u8 size[PF_VF_BULLETIN_SIZE];
  334. };
  335. struct pf_vf_bulletin_content {
  336. u32 crc; /* crc of structure to ensure is not in
  337. * mid-update
  338. */
  339. u16 version;
  340. u16 length;
  341. aligned_u64 valid_bitmap; /* bitmap indicating which fields
  342. * hold valid values
  343. */
  344. #define MAC_ADDR_VALID 0 /* alert the vf that a new mac address
  345. * is available for it
  346. */
  347. #define VLAN_VALID 1 /* when set, the vf should not access
  348. * the vfpf channel
  349. */
  350. #define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
  351. * to attempt to send messages on the
  352. * channel after this bit is set
  353. */
  354. #define LINK_VALID 3 /* alert the VF thet a new link status
  355. * update is available for it
  356. */
  357. u8 mac[ETH_ALEN];
  358. u8 mac_padding[2];
  359. u16 vlan;
  360. u8 vlan_padding[6];
  361. u16 link_speed; /* Effective line speed */
  362. u8 link_speed_padding[6];
  363. u32 link_flags; /* VFPF_LINK_REPORT_XXX flags */
  364. #define VFPF_LINK_REPORT_LINK_DOWN (1 << 0)
  365. #define VFPF_LINK_REPORT_FULL_DUPLEX (1 << 1)
  366. #define VFPF_LINK_REPORT_RX_FC_ON (1 << 2)
  367. #define VFPF_LINK_REPORT_TX_FC_ON (1 << 3)
  368. u8 link_flags_padding[4];
  369. };
  370. union pf_vf_bulletin {
  371. struct pf_vf_bulletin_content content;
  372. struct pf_vf_bulletin_size size;
  373. };
  374. #define MAX_TLVS_IN_LIST 50
  375. enum channel_tlvs {
  376. CHANNEL_TLV_NONE,
  377. CHANNEL_TLV_ACQUIRE,
  378. CHANNEL_TLV_INIT,
  379. CHANNEL_TLV_SETUP_Q,
  380. CHANNEL_TLV_SET_Q_FILTERS,
  381. CHANNEL_TLV_ACTIVATE_Q,
  382. CHANNEL_TLV_DEACTIVATE_Q,
  383. CHANNEL_TLV_TEARDOWN_Q,
  384. CHANNEL_TLV_CLOSE,
  385. CHANNEL_TLV_RELEASE,
  386. CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
  387. CHANNEL_TLV_PF_RELEASE_VF,
  388. CHANNEL_TLV_LIST_END,
  389. CHANNEL_TLV_FLR,
  390. CHANNEL_TLV_PF_SET_MAC,
  391. CHANNEL_TLV_PF_SET_VLAN,
  392. CHANNEL_TLV_UPDATE_RSS,
  393. CHANNEL_TLV_PHYS_PORT_ID,
  394. CHANNEL_TLV_UPDATE_TPA,
  395. CHANNEL_TLV_MAX
  396. };
  397. #endif /* CONFIG_BNX2X_SRIOV */
  398. #endif /* VF_PF_IF_H */