bnx2x_vfpf.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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: Eilon Greenstein <eilong@broadcom.com>
  16. * Written by: Ariel Elior <ariele@broadcom.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_ATTEMPTS 5 /* crc failures before throwing towel */
  62. #define BULLETIN_CRC_SEED 0
  63. enum {
  64. PFVF_STATUS_WAITING = 0,
  65. PFVF_STATUS_SUCCESS,
  66. PFVF_STATUS_FAILURE,
  67. PFVF_STATUS_NOT_SUPPORTED,
  68. PFVF_STATUS_NO_RESOURCE
  69. };
  70. /* vf pf channel tlvs */
  71. /* general tlv header (used for both vf->pf request and pf->vf response) */
  72. struct channel_tlv {
  73. u16 type;
  74. u16 length;
  75. };
  76. /* header of first vf->pf tlv carries the offset used to calculate response
  77. * buffer address
  78. */
  79. struct vfpf_first_tlv {
  80. struct channel_tlv tl;
  81. u32 resp_msg_offset;
  82. };
  83. /* header of pf->vf tlvs, carries the status of handling the request */
  84. struct pfvf_tlv {
  85. struct channel_tlv tl;
  86. u8 status;
  87. u8 padding[3];
  88. };
  89. /* response tlv used for most tlvs */
  90. struct pfvf_general_resp_tlv {
  91. struct pfvf_tlv hdr;
  92. };
  93. /* used to terminate and pad a tlv list */
  94. struct channel_list_end_tlv {
  95. struct channel_tlv tl;
  96. u8 padding[4];
  97. };
  98. /* Acquire */
  99. struct vfpf_acquire_tlv {
  100. struct vfpf_first_tlv first_tlv;
  101. struct vf_pf_vfdev_info {
  102. /* the following fields are for debug purposes */
  103. u8 vf_id; /* ME register value */
  104. u8 vf_os; /* e.g. Linux, W2K8 */
  105. u8 padding[2];
  106. } vfdev_info;
  107. struct vf_pf_resc_request resc_request;
  108. aligned_u64 bulletin_addr;
  109. };
  110. /* simple operation request on queue */
  111. struct vfpf_q_op_tlv {
  112. struct vfpf_first_tlv first_tlv;
  113. u8 vf_qid;
  114. u8 padding[3];
  115. };
  116. /* receive side scaling tlv */
  117. struct vfpf_rss_tlv {
  118. struct vfpf_first_tlv first_tlv;
  119. u32 rss_flags;
  120. #define VFPF_RSS_MODE_DISABLED (1 << 0)
  121. #define VFPF_RSS_MODE_REGULAR (1 << 1)
  122. #define VFPF_RSS_SET_SRCH (1 << 2)
  123. #define VFPF_RSS_IPV4 (1 << 3)
  124. #define VFPF_RSS_IPV4_TCP (1 << 4)
  125. #define VFPF_RSS_IPV4_UDP (1 << 5)
  126. #define VFPF_RSS_IPV6 (1 << 6)
  127. #define VFPF_RSS_IPV6_TCP (1 << 7)
  128. #define VFPF_RSS_IPV6_UDP (1 << 8)
  129. u8 rss_result_mask;
  130. u8 ind_table_size;
  131. u8 rss_key_size;
  132. u8 padding;
  133. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  134. u32 rss_key[T_ETH_RSS_KEY]; /* hash values */
  135. };
  136. /* acquire response tlv - carries the allocated resources */
  137. struct pfvf_acquire_resp_tlv {
  138. struct pfvf_tlv hdr;
  139. struct pf_vf_pfdev_info {
  140. u32 chip_num;
  141. u32 pf_cap;
  142. #define PFVF_CAP_RSS 0x00000001
  143. #define PFVF_CAP_DHC 0x00000002
  144. #define PFVF_CAP_TPA 0x00000004
  145. char fw_ver[32];
  146. u16 db_size;
  147. u8 indices_per_sb;
  148. u8 padding;
  149. } pfdev_info;
  150. struct pf_vf_resc {
  151. /* in case of status NO_RESOURCE in message hdr, pf will fill
  152. * this struct with suggested amount of resources for next
  153. * acquire request
  154. */
  155. #define PFVF_MAX_QUEUES_PER_VF 16
  156. #define PFVF_MAX_SBS_PER_VF 16
  157. struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
  158. u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
  159. u8 num_rxqs;
  160. u8 num_txqs;
  161. u8 num_sbs;
  162. u8 num_mac_filters;
  163. u8 num_vlan_filters;
  164. u8 num_mc_filters;
  165. u8 permanent_mac_addr[ETH_ALEN];
  166. u8 current_mac_addr[ETH_ALEN];
  167. u8 padding[2];
  168. } resc;
  169. };
  170. #define VFPF_INIT_FLG_STATS_COALESCE (1 << 0) /* when set the VFs queues
  171. * stats will be coalesced on
  172. * the leading RSS queue
  173. */
  174. /* Init VF */
  175. struct vfpf_init_tlv {
  176. struct vfpf_first_tlv first_tlv;
  177. aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
  178. aligned_u64 spq_addr;
  179. aligned_u64 stats_addr;
  180. u16 stats_stride;
  181. u32 flags;
  182. u32 padding[2];
  183. };
  184. /* Setup Queue */
  185. struct vfpf_setup_q_tlv {
  186. struct vfpf_first_tlv first_tlv;
  187. struct vf_pf_rxq_params {
  188. /* physical addresses */
  189. aligned_u64 rcq_addr;
  190. aligned_u64 rcq_np_addr;
  191. aligned_u64 rxq_addr;
  192. aligned_u64 sge_addr;
  193. /* sb + hc info */
  194. u8 vf_sb; /* index in hw_sbs[] */
  195. u8 sb_index; /* Index in the SB */
  196. u16 hc_rate; /* desired interrupts per sec. */
  197. /* valid iff VFPF_QUEUE_FLG_HC */
  198. /* rx buffer info */
  199. u16 mtu;
  200. u16 buf_sz;
  201. u16 flags; /* VFPF_QUEUE_FLG_X flags */
  202. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  203. /* valid iff VFPF_QUEUE_FLG_TPA */
  204. u16 sge_buf_sz;
  205. u16 tpa_agg_sz;
  206. u8 max_sge_pkt;
  207. u8 drop_flags; /* VFPF_QUEUE_DROP_X, for Linux VMs
  208. * all the flags are turned off
  209. */
  210. u8 cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
  211. u8 padding;
  212. } rxq;
  213. struct vf_pf_txq_params {
  214. /* physical addresses */
  215. aligned_u64 txq_addr;
  216. /* sb + hc info */
  217. u8 vf_sb; /* index in hw_sbs[] */
  218. u8 sb_index; /* Index in the SB */
  219. u16 hc_rate; /* desired interrupts per sec. */
  220. /* valid iff VFPF_QUEUE_FLG_HC */
  221. u32 flags; /* VFPF_QUEUE_FLG_X flags */
  222. u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
  223. u8 traffic_type; /* see in setup_context() */
  224. u8 padding;
  225. } txq;
  226. u8 vf_qid; /* index in hw_qid[] */
  227. u8 param_valid;
  228. #define VFPF_RXQ_VALID 0x01
  229. #define VFPF_TXQ_VALID 0x02
  230. u8 padding[2];
  231. };
  232. /* Set Queue Filters */
  233. struct vfpf_q_mac_vlan_filter {
  234. u32 flags;
  235. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  236. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  237. #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
  238. u8 mac[ETH_ALEN];
  239. u16 vlan_tag;
  240. };
  241. /* configure queue filters */
  242. struct vfpf_set_q_filters_tlv {
  243. struct vfpf_first_tlv first_tlv;
  244. u32 flags;
  245. #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
  246. #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED 0x02
  247. #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED 0x04
  248. u8 vf_qid; /* index in hw_qid[] */
  249. u8 n_mac_vlan_filters;
  250. u8 n_multicast;
  251. u8 padding;
  252. #define PFVF_MAX_MAC_FILTERS 16
  253. #define PFVF_MAX_VLAN_FILTERS 16
  254. #define PFVF_MAX_FILTERS (PFVF_MAX_MAC_FILTERS +\
  255. PFVF_MAX_VLAN_FILTERS)
  256. struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
  257. #define PFVF_MAX_MULTICAST_PER_VF 32
  258. u8 multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
  259. u32 rx_mask; /* see mask constants at the top of the file */
  260. };
  261. /* close VF (disable VF) */
  262. struct vfpf_close_tlv {
  263. struct vfpf_first_tlv first_tlv;
  264. u16 vf_id; /* for debug */
  265. u8 padding[2];
  266. };
  267. /* release the VF's acquired resources */
  268. struct vfpf_release_tlv {
  269. struct vfpf_first_tlv first_tlv;
  270. u16 vf_id;
  271. u8 padding[2];
  272. };
  273. struct tlv_buffer_size {
  274. u8 tlv_buffer[TLV_BUFFER_SIZE];
  275. };
  276. union vfpf_tlvs {
  277. struct vfpf_first_tlv first_tlv;
  278. struct vfpf_acquire_tlv acquire;
  279. struct vfpf_init_tlv init;
  280. struct vfpf_close_tlv close;
  281. struct vfpf_q_op_tlv q_op;
  282. struct vfpf_setup_q_tlv setup_q;
  283. struct vfpf_set_q_filters_tlv set_q_filters;
  284. struct vfpf_release_tlv release;
  285. struct vfpf_rss_tlv update_rss;
  286. struct channel_list_end_tlv list_end;
  287. struct tlv_buffer_size tlv_buf_size;
  288. };
  289. union pfvf_tlvs {
  290. struct pfvf_general_resp_tlv general_resp;
  291. struct pfvf_acquire_resp_tlv acquire_resp;
  292. struct channel_list_end_tlv list_end;
  293. struct tlv_buffer_size tlv_buf_size;
  294. };
  295. /* This is a structure which is allocated in the VF, which the PF may update
  296. * when it deems it necessary to do so. The bulletin board is sampled
  297. * periodically by the VF. A copy per VF is maintained in the PF (to prevent
  298. * loss of data upon multiple updates (or the need for read modify write)).
  299. */
  300. struct pf_vf_bulletin_size {
  301. u8 size[PF_VF_BULLETIN_SIZE];
  302. };
  303. struct pf_vf_bulletin_content {
  304. u32 crc; /* crc of structure to ensure is not in
  305. * mid-update
  306. */
  307. u16 version;
  308. u16 length;
  309. aligned_u64 valid_bitmap; /* bitmap indicating which fields
  310. * hold valid values
  311. */
  312. #define MAC_ADDR_VALID 0 /* alert the vf that a new mac address
  313. * is available for it
  314. */
  315. #define VLAN_VALID 1 /* when set, the vf should not access
  316. * the vfpf channel
  317. */
  318. #define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
  319. * to attempt to send messages on the
  320. * channel after this bit is set
  321. */
  322. u8 mac[ETH_ALEN];
  323. u8 mac_padding[2];
  324. u16 vlan;
  325. u8 vlan_padding[6];
  326. };
  327. union pf_vf_bulletin {
  328. struct pf_vf_bulletin_content content;
  329. struct pf_vf_bulletin_size size;
  330. };
  331. #define MAX_TLVS_IN_LIST 50
  332. enum channel_tlvs {
  333. CHANNEL_TLV_NONE,
  334. CHANNEL_TLV_ACQUIRE,
  335. CHANNEL_TLV_INIT,
  336. CHANNEL_TLV_SETUP_Q,
  337. CHANNEL_TLV_SET_Q_FILTERS,
  338. CHANNEL_TLV_ACTIVATE_Q,
  339. CHANNEL_TLV_DEACTIVATE_Q,
  340. CHANNEL_TLV_TEARDOWN_Q,
  341. CHANNEL_TLV_CLOSE,
  342. CHANNEL_TLV_RELEASE,
  343. CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
  344. CHANNEL_TLV_PF_RELEASE_VF,
  345. CHANNEL_TLV_LIST_END,
  346. CHANNEL_TLV_FLR,
  347. CHANNEL_TLV_PF_SET_MAC,
  348. CHANNEL_TLV_PF_SET_VLAN,
  349. CHANNEL_TLV_UPDATE_RSS,
  350. CHANNEL_TLV_MAX
  351. };
  352. #endif /* CONFIG_BNX2X_SRIOV */
  353. #endif /* VF_PF_IF_H */