bnx2x_vfpf.h 9.0 KB

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