bnx2x_vfpf.h 10 KB

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