qed_vf.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _QED_VF_H
  33. #define _QED_VF_H
  34. #include "qed_l2.h"
  35. #include "qed_mcp.h"
  36. #define T_ETH_INDIRECTION_TABLE_SIZE 128
  37. #define T_ETH_RSS_KEY_SIZE 10
  38. struct vf_pf_resc_request {
  39. u8 num_rxqs;
  40. u8 num_txqs;
  41. u8 num_sbs;
  42. u8 num_mac_filters;
  43. u8 num_vlan_filters;
  44. u8 num_mc_filters;
  45. u8 num_cids;
  46. u8 padding;
  47. };
  48. struct hw_sb_info {
  49. u16 hw_sb_id;
  50. u8 sb_qid;
  51. u8 padding[5];
  52. };
  53. #define TLV_BUFFER_SIZE 1024
  54. enum {
  55. PFVF_STATUS_WAITING,
  56. PFVF_STATUS_SUCCESS,
  57. PFVF_STATUS_FAILURE,
  58. PFVF_STATUS_NOT_SUPPORTED,
  59. PFVF_STATUS_NO_RESOURCE,
  60. PFVF_STATUS_FORCED,
  61. PFVF_STATUS_MALICIOUS,
  62. };
  63. /* vf pf channel tlvs */
  64. /* general tlv header (used for both vf->pf request and pf->vf response) */
  65. struct channel_tlv {
  66. u16 type;
  67. u16 length;
  68. };
  69. /* header of first vf->pf tlv carries the offset used to calculate reponse
  70. * buffer address
  71. */
  72. struct vfpf_first_tlv {
  73. struct channel_tlv tl;
  74. u32 padding;
  75. u64 reply_address;
  76. };
  77. /* header of pf->vf tlvs, carries the status of handling the request */
  78. struct pfvf_tlv {
  79. struct channel_tlv tl;
  80. u8 status;
  81. u8 padding[3];
  82. };
  83. /* response tlv used for most tlvs */
  84. struct pfvf_def_resp_tlv {
  85. struct pfvf_tlv hdr;
  86. };
  87. /* used to terminate and pad a tlv list */
  88. struct channel_list_end_tlv {
  89. struct channel_tlv tl;
  90. u8 padding[4];
  91. };
  92. #define VFPF_ACQUIRE_OS_LINUX (0)
  93. #define VFPF_ACQUIRE_OS_WINDOWS (1)
  94. #define VFPF_ACQUIRE_OS_ESX (2)
  95. #define VFPF_ACQUIRE_OS_SOLARIS (3)
  96. #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
  97. struct vfpf_acquire_tlv {
  98. struct vfpf_first_tlv first_tlv;
  99. struct vf_pf_vfdev_info {
  100. #define VFPF_ACQUIRE_CAP_PRE_FP_HSI (1 << 0) /* VF pre-FP hsi version */
  101. #define VFPF_ACQUIRE_CAP_100G (1 << 1) /* VF can support 100g */
  102. /* A requirement for supporting multi-Tx queues on a single queue-zone,
  103. * VF would pass qids as additional information whenever passing queue
  104. * references.
  105. */
  106. #define VFPF_ACQUIRE_CAP_QUEUE_QIDS BIT(2)
  107. /* The VF is using the physical bar. While this is mostly internal
  108. * to the VF, might affect the number of CIDs supported assuming
  109. * QUEUE_QIDS is set.
  110. */
  111. #define VFPF_ACQUIRE_CAP_PHYSICAL_BAR BIT(3)
  112. u64 capabilities;
  113. u8 fw_major;
  114. u8 fw_minor;
  115. u8 fw_revision;
  116. u8 fw_engineering;
  117. u32 driver_version;
  118. u16 opaque_fid; /* ME register value */
  119. u8 os_type; /* VFPF_ACQUIRE_OS_* value */
  120. u8 eth_fp_hsi_major;
  121. u8 eth_fp_hsi_minor;
  122. u8 padding[3];
  123. } vfdev_info;
  124. struct vf_pf_resc_request resc_request;
  125. u64 bulletin_addr;
  126. u32 bulletin_size;
  127. u32 padding;
  128. };
  129. /* receive side scaling tlv */
  130. struct vfpf_vport_update_rss_tlv {
  131. struct channel_tlv tl;
  132. u8 update_rss_flags;
  133. #define VFPF_UPDATE_RSS_CONFIG_FLAG BIT(0)
  134. #define VFPF_UPDATE_RSS_CAPS_FLAG BIT(1)
  135. #define VFPF_UPDATE_RSS_IND_TABLE_FLAG BIT(2)
  136. #define VFPF_UPDATE_RSS_KEY_FLAG BIT(3)
  137. u8 rss_enable;
  138. u8 rss_caps;
  139. u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
  140. u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  141. u32 rss_key[T_ETH_RSS_KEY_SIZE];
  142. };
  143. struct pfvf_storm_stats {
  144. u32 address;
  145. u32 len;
  146. };
  147. struct pfvf_stats_info {
  148. struct pfvf_storm_stats mstats;
  149. struct pfvf_storm_stats pstats;
  150. struct pfvf_storm_stats tstats;
  151. struct pfvf_storm_stats ustats;
  152. };
  153. struct pfvf_acquire_resp_tlv {
  154. struct pfvf_tlv hdr;
  155. struct pf_vf_pfdev_info {
  156. u32 chip_num;
  157. u32 mfw_ver;
  158. u16 fw_major;
  159. u16 fw_minor;
  160. u16 fw_rev;
  161. u16 fw_eng;
  162. u64 capabilities;
  163. #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
  164. #define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
  165. /* There are old PF versions where the PF might mistakenly override the sanity
  166. * mechanism [version-based] and allow a VF that can't be supported to pass
  167. * the acquisition phase.
  168. * To overcome this, PFs now indicate that they're past that point and the new
  169. * VFs would fail probe on the older PFs that fail to do so.
  170. */
  171. #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
  172. /* PF expects queues to be received with additional qids */
  173. #define PFVF_ACQUIRE_CAP_QUEUE_QIDS BIT(3)
  174. u16 db_size;
  175. u8 indices_per_sb;
  176. u8 os_type;
  177. /* These should match the PF's qed_dev values */
  178. u16 chip_rev;
  179. u8 dev_type;
  180. /* Doorbell bar size configured in HW: log(size) or 0 */
  181. u8 bar_size;
  182. struct pfvf_stats_info stats_info;
  183. u8 port_mac[ETH_ALEN];
  184. /* It's possible PF had to configure an older fastpath HSI
  185. * [in case VF is newer than PF]. This is communicated back
  186. * to the VF. It can also be used in case of error due to
  187. * non-matching versions to shed light in VF about failure.
  188. */
  189. u8 major_fp_hsi;
  190. u8 minor_fp_hsi;
  191. } pfdev_info;
  192. struct pf_vf_resc {
  193. #define PFVF_MAX_QUEUES_PER_VF 16
  194. #define PFVF_MAX_SBS_PER_VF 16
  195. struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
  196. u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
  197. u8 cid[PFVF_MAX_QUEUES_PER_VF];
  198. u8 num_rxqs;
  199. u8 num_txqs;
  200. u8 num_sbs;
  201. u8 num_mac_filters;
  202. u8 num_vlan_filters;
  203. u8 num_mc_filters;
  204. u8 num_cids;
  205. u8 padding;
  206. } resc;
  207. u32 bulletin_size;
  208. u32 padding;
  209. };
  210. struct pfvf_start_queue_resp_tlv {
  211. struct pfvf_tlv hdr;
  212. u32 offset; /* offset to consumer/producer of queue */
  213. u8 padding[4];
  214. };
  215. /* Extended queue information - additional index for reference inside qzone.
  216. * If commmunicated between VF/PF, each TLV relating to queues should be
  217. * extended by one such [or have a future base TLV that already contains info].
  218. */
  219. struct vfpf_qid_tlv {
  220. struct channel_tlv tl;
  221. u8 qid;
  222. u8 padding[3];
  223. };
  224. /* Setup Queue */
  225. struct vfpf_start_rxq_tlv {
  226. struct vfpf_first_tlv first_tlv;
  227. /* physical addresses */
  228. u64 rxq_addr;
  229. u64 deprecated_sge_addr;
  230. u64 cqe_pbl_addr;
  231. u16 cqe_pbl_size;
  232. u16 hw_sb;
  233. u16 rx_qid;
  234. u16 hc_rate; /* desired interrupts per sec. */
  235. u16 bd_max_bytes;
  236. u16 stat_id;
  237. u8 sb_index;
  238. u8 padding[3];
  239. };
  240. struct vfpf_start_txq_tlv {
  241. struct vfpf_first_tlv first_tlv;
  242. /* physical addresses */
  243. u64 pbl_addr;
  244. u16 pbl_size;
  245. u16 stat_id;
  246. u16 tx_qid;
  247. u16 hw_sb;
  248. u32 flags; /* VFPF_QUEUE_FLG_X flags */
  249. u16 hc_rate; /* desired interrupts per sec. */
  250. u8 sb_index;
  251. u8 padding[3];
  252. };
  253. /* Stop RX Queue */
  254. struct vfpf_stop_rxqs_tlv {
  255. struct vfpf_first_tlv first_tlv;
  256. u16 rx_qid;
  257. /* this field is deprecated and should *always* be set to '1' */
  258. u8 num_rxqs;
  259. u8 cqe_completion;
  260. u8 padding[4];
  261. };
  262. /* Stop TX Queues */
  263. struct vfpf_stop_txqs_tlv {
  264. struct vfpf_first_tlv first_tlv;
  265. u16 tx_qid;
  266. /* this field is deprecated and should *always* be set to '1' */
  267. u8 num_txqs;
  268. u8 padding[5];
  269. };
  270. struct vfpf_update_rxq_tlv {
  271. struct vfpf_first_tlv first_tlv;
  272. u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
  273. u16 rx_qid;
  274. u8 num_rxqs;
  275. u8 flags;
  276. #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
  277. #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
  278. #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
  279. u8 padding[4];
  280. };
  281. /* Set Queue Filters */
  282. struct vfpf_q_mac_vlan_filter {
  283. u32 flags;
  284. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  285. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  286. #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
  287. u8 mac[ETH_ALEN];
  288. u16 vlan_tag;
  289. u8 padding[4];
  290. };
  291. /* Start a vport */
  292. struct vfpf_vport_start_tlv {
  293. struct vfpf_first_tlv first_tlv;
  294. u64 sb_addr[PFVF_MAX_SBS_PER_VF];
  295. u32 tpa_mode;
  296. u16 dep1;
  297. u16 mtu;
  298. u8 vport_id;
  299. u8 inner_vlan_removal;
  300. u8 only_untagged;
  301. u8 max_buffers_per_cqe;
  302. u8 padding[4];
  303. };
  304. /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
  305. struct vfpf_vport_update_activate_tlv {
  306. struct channel_tlv tl;
  307. u8 update_rx;
  308. u8 update_tx;
  309. u8 active_rx;
  310. u8 active_tx;
  311. };
  312. struct vfpf_vport_update_tx_switch_tlv {
  313. struct channel_tlv tl;
  314. u8 tx_switching;
  315. u8 padding[3];
  316. };
  317. struct vfpf_vport_update_vlan_strip_tlv {
  318. struct channel_tlv tl;
  319. u8 remove_vlan;
  320. u8 padding[3];
  321. };
  322. struct vfpf_vport_update_mcast_bin_tlv {
  323. struct channel_tlv tl;
  324. u8 padding[4];
  325. u64 bins[8];
  326. };
  327. struct vfpf_vport_update_accept_param_tlv {
  328. struct channel_tlv tl;
  329. u8 update_rx_mode;
  330. u8 update_tx_mode;
  331. u8 rx_accept_filter;
  332. u8 tx_accept_filter;
  333. };
  334. struct vfpf_vport_update_accept_any_vlan_tlv {
  335. struct channel_tlv tl;
  336. u8 update_accept_any_vlan_flg;
  337. u8 accept_any_vlan;
  338. u8 padding[2];
  339. };
  340. struct vfpf_vport_update_sge_tpa_tlv {
  341. struct channel_tlv tl;
  342. u16 sge_tpa_flags;
  343. #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
  344. #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
  345. #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
  346. #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
  347. #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
  348. u8 update_sge_tpa_flags;
  349. #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
  350. #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
  351. #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
  352. u8 max_buffers_per_cqe;
  353. u16 deprecated_sge_buff_size;
  354. u16 tpa_max_size;
  355. u16 tpa_min_size_to_start;
  356. u16 tpa_min_size_to_cont;
  357. u8 tpa_max_aggs_num;
  358. u8 padding[7];
  359. };
  360. /* Primary tlv as a header for various extended tlvs for
  361. * various functionalities in vport update ramrod.
  362. */
  363. struct vfpf_vport_update_tlv {
  364. struct vfpf_first_tlv first_tlv;
  365. };
  366. struct vfpf_ucast_filter_tlv {
  367. struct vfpf_first_tlv first_tlv;
  368. u8 opcode;
  369. u8 type;
  370. u8 mac[ETH_ALEN];
  371. u16 vlan;
  372. u16 padding[3];
  373. };
  374. /* tunnel update param tlv */
  375. struct vfpf_update_tunn_param_tlv {
  376. struct vfpf_first_tlv first_tlv;
  377. u8 tun_mode_update_mask;
  378. u8 tunn_mode;
  379. u8 update_tun_cls;
  380. u8 vxlan_clss;
  381. u8 l2gre_clss;
  382. u8 ipgre_clss;
  383. u8 l2geneve_clss;
  384. u8 ipgeneve_clss;
  385. u8 update_geneve_port;
  386. u8 update_vxlan_port;
  387. u16 geneve_port;
  388. u16 vxlan_port;
  389. u8 padding[2];
  390. };
  391. struct pfvf_update_tunn_param_tlv {
  392. struct pfvf_tlv hdr;
  393. u16 tunn_feature_mask;
  394. u8 vxlan_mode;
  395. u8 l2geneve_mode;
  396. u8 ipgeneve_mode;
  397. u8 l2gre_mode;
  398. u8 ipgre_mode;
  399. u8 vxlan_clss;
  400. u8 l2gre_clss;
  401. u8 ipgre_clss;
  402. u8 l2geneve_clss;
  403. u8 ipgeneve_clss;
  404. u16 vxlan_udp_port;
  405. u16 geneve_udp_port;
  406. };
  407. struct tlv_buffer_size {
  408. u8 tlv_buffer[TLV_BUFFER_SIZE];
  409. };
  410. struct vfpf_update_coalesce {
  411. struct vfpf_first_tlv first_tlv;
  412. u16 rx_coal;
  413. u16 tx_coal;
  414. u16 qid;
  415. u8 padding[2];
  416. };
  417. struct vfpf_read_coal_req_tlv {
  418. struct vfpf_first_tlv first_tlv;
  419. u16 qid;
  420. u8 is_rx;
  421. u8 padding[5];
  422. };
  423. struct pfvf_read_coal_resp_tlv {
  424. struct pfvf_tlv hdr;
  425. u16 coal;
  426. u8 padding[6];
  427. };
  428. union vfpf_tlvs {
  429. struct vfpf_first_tlv first_tlv;
  430. struct vfpf_acquire_tlv acquire;
  431. struct vfpf_start_rxq_tlv start_rxq;
  432. struct vfpf_start_txq_tlv start_txq;
  433. struct vfpf_stop_rxqs_tlv stop_rxqs;
  434. struct vfpf_stop_txqs_tlv stop_txqs;
  435. struct vfpf_update_rxq_tlv update_rxq;
  436. struct vfpf_vport_start_tlv start_vport;
  437. struct vfpf_vport_update_tlv vport_update;
  438. struct vfpf_ucast_filter_tlv ucast_filter;
  439. struct vfpf_update_tunn_param_tlv tunn_param_update;
  440. struct vfpf_update_coalesce update_coalesce;
  441. struct vfpf_read_coal_req_tlv read_coal_req;
  442. struct tlv_buffer_size tlv_buf_size;
  443. };
  444. union pfvf_tlvs {
  445. struct pfvf_def_resp_tlv default_resp;
  446. struct pfvf_acquire_resp_tlv acquire_resp;
  447. struct tlv_buffer_size tlv_buf_size;
  448. struct pfvf_start_queue_resp_tlv queue_start;
  449. struct pfvf_update_tunn_param_tlv tunn_param_resp;
  450. struct pfvf_read_coal_resp_tlv read_coal_resp;
  451. };
  452. enum qed_bulletin_bit {
  453. /* Alert the VF that a forced MAC was set by the PF */
  454. MAC_ADDR_FORCED = 0,
  455. /* Alert the VF that a forced VLAN was set by the PF */
  456. VLAN_ADDR_FORCED = 2,
  457. /* Indicate that `default_only_untagged' contains actual data */
  458. VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
  459. VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
  460. /* Alert the VF that suggested mac was sent by the PF.
  461. * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
  462. */
  463. VFPF_BULLETIN_MAC_ADDR = 5
  464. };
  465. struct qed_bulletin_content {
  466. /* crc of structure to ensure is not in mid-update */
  467. u32 crc;
  468. u32 version;
  469. /* bitmap indicating which fields hold valid values */
  470. u64 valid_bitmap;
  471. /* used for MAC_ADDR or MAC_ADDR_FORCED */
  472. u8 mac[ETH_ALEN];
  473. /* If valid, 1 => only untagged Rx if no vlan is configured */
  474. u8 default_only_untagged;
  475. u8 padding;
  476. /* The following is a 'copy' of qed_mcp_link_state,
  477. * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
  478. * possible the structs will increase further along the road we cannot
  479. * have it here; Instead we need to have all of its fields.
  480. */
  481. u8 req_autoneg;
  482. u8 req_autoneg_pause;
  483. u8 req_forced_rx;
  484. u8 req_forced_tx;
  485. u8 padding2[4];
  486. u32 req_adv_speed;
  487. u32 req_forced_speed;
  488. u32 req_loopback;
  489. u32 padding3;
  490. u8 link_up;
  491. u8 full_duplex;
  492. u8 autoneg;
  493. u8 autoneg_complete;
  494. u8 parallel_detection;
  495. u8 pfc_enabled;
  496. u8 partner_tx_flow_ctrl_en;
  497. u8 partner_rx_flow_ctrl_en;
  498. u8 partner_adv_pause;
  499. u8 sfp_tx_fault;
  500. u16 vxlan_udp_port;
  501. u16 geneve_udp_port;
  502. u8 padding4[2];
  503. u32 speed;
  504. u32 partner_adv_speed;
  505. u32 capability_speed;
  506. /* Forced vlan */
  507. u16 pvid;
  508. u16 padding5;
  509. };
  510. struct qed_bulletin {
  511. dma_addr_t phys;
  512. struct qed_bulletin_content *p_virt;
  513. u32 size;
  514. };
  515. enum {
  516. CHANNEL_TLV_NONE, /* ends tlv sequence */
  517. CHANNEL_TLV_ACQUIRE,
  518. CHANNEL_TLV_VPORT_START,
  519. CHANNEL_TLV_VPORT_UPDATE,
  520. CHANNEL_TLV_VPORT_TEARDOWN,
  521. CHANNEL_TLV_START_RXQ,
  522. CHANNEL_TLV_START_TXQ,
  523. CHANNEL_TLV_STOP_RXQS,
  524. CHANNEL_TLV_STOP_TXQS,
  525. CHANNEL_TLV_UPDATE_RXQ,
  526. CHANNEL_TLV_INT_CLEANUP,
  527. CHANNEL_TLV_CLOSE,
  528. CHANNEL_TLV_RELEASE,
  529. CHANNEL_TLV_LIST_END,
  530. CHANNEL_TLV_UCAST_FILTER,
  531. CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
  532. CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
  533. CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
  534. CHANNEL_TLV_VPORT_UPDATE_MCAST,
  535. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
  536. CHANNEL_TLV_VPORT_UPDATE_RSS,
  537. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
  538. CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
  539. CHANNEL_TLV_UPDATE_TUNN_PARAM,
  540. CHANNEL_TLV_COALESCE_UPDATE,
  541. CHANNEL_TLV_QID,
  542. CHANNEL_TLV_COALESCE_READ,
  543. CHANNEL_TLV_MAX,
  544. /* Required for iterating over vport-update tlvs.
  545. * Will break in case non-sequential vport-update tlvs.
  546. */
  547. CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
  548. };
  549. /* Default number of CIDs [total of both Rx and Tx] to be requested
  550. * by default, and maximum possible number.
  551. */
  552. #define QED_ETH_VF_DEFAULT_NUM_CIDS (32)
  553. #define QED_ETH_VF_MAX_NUM_CIDS (250)
  554. /* This data is held in the qed_hwfn structure for VFs only. */
  555. struct qed_vf_iov {
  556. union vfpf_tlvs *vf2pf_request;
  557. dma_addr_t vf2pf_request_phys;
  558. union pfvf_tlvs *pf2vf_reply;
  559. dma_addr_t pf2vf_reply_phys;
  560. /* Should be taken whenever the mailbox buffers are accessed */
  561. struct mutex mutex;
  562. u8 *offset;
  563. /* Bulletin Board */
  564. struct qed_bulletin bulletin;
  565. struct qed_bulletin_content bulletin_shadow;
  566. /* we set aside a copy of the acquire response */
  567. struct pfvf_acquire_resp_tlv acquire_resp;
  568. /* In case PF originates prior to the fp-hsi version comparison,
  569. * this has to be propagated as it affects the fastpath.
  570. */
  571. bool b_pre_fp_hsi;
  572. /* Current day VFs are passing the SBs physical address on vport
  573. * start, and as they lack an IGU mapping they need to store the
  574. * addresses of previously registered SBs.
  575. * Even if we were to change configuration flow, due to backward
  576. * compatibility [with older PFs] we'd still need to store these.
  577. */
  578. struct qed_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
  579. /* Determines whether VF utilizes doorbells via limited register
  580. * bar or via the doorbell bar.
  581. */
  582. bool b_doorbell_bar;
  583. };
  584. /**
  585. * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
  586. * Coalesce value '0' will omit the configuration.
  587. *
  588. * @param p_hwfn
  589. * @param rx_coal - coalesce value in micro second for rx queue
  590. * @param tx_coal - coalesce value in micro second for tx queue
  591. * @param p_cid - queue cid
  592. *
  593. **/
  594. int qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
  595. u16 rx_coal,
  596. u16 tx_coal, struct qed_queue_cid *p_cid);
  597. /**
  598. * @brief VF - Get coalesce per VF's relative queue.
  599. *
  600. * @param p_hwfn
  601. * @param p_coal - coalesce value in micro second for VF queues.
  602. * @param p_cid - queue cid
  603. *
  604. **/
  605. int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
  606. u16 *p_coal, struct qed_queue_cid *p_cid);
  607. #ifdef CONFIG_QED_SRIOV
  608. /**
  609. * @brief Read the VF bulletin and act on it if needed
  610. *
  611. * @param p_hwfn
  612. * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
  613. *
  614. * @return enum _qed_status
  615. */
  616. int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
  617. /**
  618. * @brief Get link paramters for VF from qed
  619. *
  620. * @param p_hwfn
  621. * @param params - the link params structure to be filled for the VF
  622. */
  623. void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  624. struct qed_mcp_link_params *params);
  625. /**
  626. * @brief Get link state for VF from qed
  627. *
  628. * @param p_hwfn
  629. * @param link - the link state structure to be filled for the VF
  630. */
  631. void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  632. struct qed_mcp_link_state *link);
  633. /**
  634. * @brief Get link capabilities for VF from qed
  635. *
  636. * @param p_hwfn
  637. * @param p_link_caps - the link capabilities structure to be filled for the VF
  638. */
  639. void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  640. struct qed_mcp_link_capabilities *p_link_caps);
  641. /**
  642. * @brief Get number of Rx queues allocated for VF by qed
  643. *
  644. * @param p_hwfn
  645. * @param num_rxqs - allocated RX queues
  646. */
  647. void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
  648. /**
  649. * @brief Get number of Rx queues allocated for VF by qed
  650. *
  651. * @param p_hwfn
  652. * @param num_txqs - allocated RX queues
  653. */
  654. void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs);
  655. /**
  656. * @brief Get number of available connections [both Rx and Tx] for VF
  657. *
  658. * @param p_hwfn
  659. * @param num_cids - allocated number of connections
  660. */
  661. void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids);
  662. /**
  663. * @brief Get port mac address for VF
  664. *
  665. * @param p_hwfn
  666. * @param port_mac - destination location for port mac
  667. */
  668. void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
  669. /**
  670. * @brief Get number of VLAN filters allocated for VF by qed
  671. *
  672. * @param p_hwfn
  673. * @param num_rxqs - allocated VLAN filters
  674. */
  675. void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  676. u8 *num_vlan_filters);
  677. /**
  678. * @brief Get number of MAC filters allocated for VF by qed
  679. *
  680. * @param p_hwfn
  681. * @param num_rxqs - allocated MAC filters
  682. */
  683. void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
  684. /**
  685. * @brief Check if VF can set a MAC address
  686. *
  687. * @param p_hwfn
  688. * @param mac
  689. *
  690. * @return bool
  691. */
  692. bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
  693. /**
  694. * @brief Set firmware version information in dev_info from VFs acquire response tlv
  695. *
  696. * @param p_hwfn
  697. * @param fw_major
  698. * @param fw_minor
  699. * @param fw_rev
  700. * @param fw_eng
  701. */
  702. void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  703. u16 *fw_major, u16 *fw_minor,
  704. u16 *fw_rev, u16 *fw_eng);
  705. /**
  706. * @brief hw preparation for VF
  707. * sends ACQUIRE message
  708. *
  709. * @param p_hwfn
  710. *
  711. * @return int
  712. */
  713. int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
  714. /**
  715. * @brief VF - start the RX Queue by sending a message to the PF
  716. * @param p_hwfn
  717. * @param p_cid - Only relative fields are relevant
  718. * @param bd_max_bytes - maximum number of bytes per bd
  719. * @param bd_chain_phys_addr - physical address of bd chain
  720. * @param cqe_pbl_addr - physical address of pbl
  721. * @param cqe_pbl_size - pbl size
  722. * @param pp_prod - pointer to the producer to be
  723. * used in fastpath
  724. *
  725. * @return int
  726. */
  727. int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  728. struct qed_queue_cid *p_cid,
  729. u16 bd_max_bytes,
  730. dma_addr_t bd_chain_phys_addr,
  731. dma_addr_t cqe_pbl_addr,
  732. u16 cqe_pbl_size, void __iomem **pp_prod);
  733. /**
  734. * @brief VF - start the TX queue by sending a message to the
  735. * PF.
  736. *
  737. * @param p_hwfn
  738. * @param tx_queue_id - zero based within the VF
  739. * @param sb - status block for this queue
  740. * @param sb_index - index within the status block
  741. * @param bd_chain_phys_addr - physical address of tx chain
  742. * @param pp_doorbell - pointer to address to which to
  743. * write the doorbell too..
  744. *
  745. * @return int
  746. */
  747. int
  748. qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  749. struct qed_queue_cid *p_cid,
  750. dma_addr_t pbl_addr,
  751. u16 pbl_size, void __iomem **pp_doorbell);
  752. /**
  753. * @brief VF - stop the RX queue by sending a message to the PF
  754. *
  755. * @param p_hwfn
  756. * @param p_cid
  757. * @param cqe_completion
  758. *
  759. * @return int
  760. */
  761. int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  762. struct qed_queue_cid *p_cid, bool cqe_completion);
  763. /**
  764. * @brief VF - stop the TX queue by sending a message to the PF
  765. *
  766. * @param p_hwfn
  767. * @param tx_qid
  768. *
  769. * @return int
  770. */
  771. int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
  772. /**
  773. * @brief VF - send a vport update command
  774. *
  775. * @param p_hwfn
  776. * @param params
  777. *
  778. * @return int
  779. */
  780. int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  781. struct qed_sp_vport_update_params *p_params);
  782. /**
  783. *
  784. * @brief VF - send a close message to PF
  785. *
  786. * @param p_hwfn
  787. *
  788. * @return enum _qed_status
  789. */
  790. int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
  791. /**
  792. * @brief VF - free vf`s memories
  793. *
  794. * @param p_hwfn
  795. *
  796. * @return enum _qed_status
  797. */
  798. int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
  799. /**
  800. * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
  801. * sb_id. For VFs igu sbs don't have to be contiguous
  802. *
  803. * @param p_hwfn
  804. * @param sb_id
  805. *
  806. * @return INLINE u16
  807. */
  808. u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
  809. /**
  810. * @brief Stores [or removes] a configured sb_info.
  811. *
  812. * @param p_hwfn
  813. * @param sb_id - zero-based SB index [for fastpath]
  814. * @param sb_info - may be NULL [during removal].
  815. */
  816. void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn,
  817. u16 sb_id, struct qed_sb_info *p_sb);
  818. /**
  819. * @brief qed_vf_pf_vport_start - perform vport start for VF.
  820. *
  821. * @param p_hwfn
  822. * @param vport_id
  823. * @param mtu
  824. * @param inner_vlan_removal
  825. * @param tpa_mode
  826. * @param max_buffers_per_cqe,
  827. * @param only_untagged - default behavior regarding vlan acceptance
  828. *
  829. * @return enum _qed_status
  830. */
  831. int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  832. u8 vport_id,
  833. u16 mtu,
  834. u8 inner_vlan_removal,
  835. enum qed_tpa_mode tpa_mode,
  836. u8 max_buffers_per_cqe, u8 only_untagged);
  837. /**
  838. * @brief qed_vf_pf_vport_stop - stop the VF's vport
  839. *
  840. * @param p_hwfn
  841. *
  842. * @return enum _qed_status
  843. */
  844. int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
  845. int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  846. struct qed_filter_ucast *p_param);
  847. void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  848. struct qed_filter_mcast *p_filter_cmd);
  849. /**
  850. * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
  851. *
  852. * @param p_hwfn
  853. *
  854. * @return enum _qed_status
  855. */
  856. int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
  857. /**
  858. * @brief - return the link params in a given bulletin board
  859. *
  860. * @param p_hwfn
  861. * @param p_params - pointer to a struct to fill with link params
  862. * @param p_bulletin
  863. */
  864. void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  865. struct qed_mcp_link_params *p_params,
  866. struct qed_bulletin_content *p_bulletin);
  867. /**
  868. * @brief - return the link state in a given bulletin board
  869. *
  870. * @param p_hwfn
  871. * @param p_link - pointer to a struct to fill with link state
  872. * @param p_bulletin
  873. */
  874. void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  875. struct qed_mcp_link_state *p_link,
  876. struct qed_bulletin_content *p_bulletin);
  877. /**
  878. * @brief - return the link capabilities in a given bulletin board
  879. *
  880. * @param p_hwfn
  881. * @param p_link - pointer to a struct to fill with link capabilities
  882. * @param p_bulletin
  883. */
  884. void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  885. struct qed_mcp_link_capabilities *p_link_caps,
  886. struct qed_bulletin_content *p_bulletin);
  887. void qed_iov_vf_task(struct work_struct *work);
  888. void qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun);
  889. int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
  890. struct qed_tunnel_info *p_tunn);
  891. u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
  892. #else
  893. static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  894. struct qed_mcp_link_params *params)
  895. {
  896. }
  897. static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  898. struct qed_mcp_link_state *link)
  899. {
  900. }
  901. static inline void
  902. qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  903. struct qed_mcp_link_capabilities *p_link_caps)
  904. {
  905. }
  906. static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
  907. {
  908. }
  909. static inline void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs)
  910. {
  911. }
  912. static inline void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids)
  913. {
  914. }
  915. static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
  916. {
  917. }
  918. static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  919. u8 *num_vlan_filters)
  920. {
  921. }
  922. static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
  923. u8 *num_mac_filters)
  924. {
  925. }
  926. static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
  927. {
  928. return false;
  929. }
  930. static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  931. u16 *fw_major, u16 *fw_minor,
  932. u16 *fw_rev, u16 *fw_eng)
  933. {
  934. }
  935. static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
  936. {
  937. return -EINVAL;
  938. }
  939. static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  940. struct qed_queue_cid *p_cid,
  941. u16 bd_max_bytes,
  942. dma_addr_t bd_chain_phys_adr,
  943. dma_addr_t cqe_pbl_addr,
  944. u16 cqe_pbl_size, void __iomem **pp_prod)
  945. {
  946. return -EINVAL;
  947. }
  948. static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  949. struct qed_queue_cid *p_cid,
  950. dma_addr_t pbl_addr,
  951. u16 pbl_size, void __iomem **pp_doorbell)
  952. {
  953. return -EINVAL;
  954. }
  955. static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  956. struct qed_queue_cid *p_cid,
  957. bool cqe_completion)
  958. {
  959. return -EINVAL;
  960. }
  961. static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
  962. struct qed_queue_cid *p_cid)
  963. {
  964. return -EINVAL;
  965. }
  966. static inline int
  967. qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  968. struct qed_sp_vport_update_params *p_params)
  969. {
  970. return -EINVAL;
  971. }
  972. static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
  973. {
  974. return -EINVAL;
  975. }
  976. static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
  977. {
  978. return -EINVAL;
  979. }
  980. static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
  981. {
  982. return 0;
  983. }
  984. static inline void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn, u16 sb_id,
  985. struct qed_sb_info *p_sb)
  986. {
  987. }
  988. static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  989. u8 vport_id,
  990. u16 mtu,
  991. u8 inner_vlan_removal,
  992. enum qed_tpa_mode tpa_mode,
  993. u8 max_buffers_per_cqe,
  994. u8 only_untagged)
  995. {
  996. return -EINVAL;
  997. }
  998. static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
  999. {
  1000. return -EINVAL;
  1001. }
  1002. static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  1003. struct qed_filter_ucast *p_param)
  1004. {
  1005. return -EINVAL;
  1006. }
  1007. static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  1008. struct qed_filter_mcast *p_filter_cmd)
  1009. {
  1010. }
  1011. static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
  1012. {
  1013. return -EINVAL;
  1014. }
  1015. static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  1016. struct qed_mcp_link_params
  1017. *p_params,
  1018. struct qed_bulletin_content
  1019. *p_bulletin)
  1020. {
  1021. }
  1022. static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  1023. struct qed_mcp_link_state *p_link,
  1024. struct qed_bulletin_content
  1025. *p_bulletin)
  1026. {
  1027. }
  1028. static inline void
  1029. __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  1030. struct qed_mcp_link_capabilities *p_link_caps,
  1031. struct qed_bulletin_content *p_bulletin)
  1032. {
  1033. }
  1034. static inline void qed_iov_vf_task(struct work_struct *work)
  1035. {
  1036. }
  1037. static inline void
  1038. qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun)
  1039. {
  1040. }
  1041. static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
  1042. struct qed_tunnel_info *p_tunn)
  1043. {
  1044. return -EINVAL;
  1045. }
  1046. static inline u32
  1047. qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn,
  1048. enum BAR_ID bar_id)
  1049. {
  1050. return 0;
  1051. }
  1052. #endif
  1053. #endif