qed_vf.h 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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. u16 padding;
  46. };
  47. struct hw_sb_info {
  48. u16 hw_sb_id;
  49. u8 sb_qid;
  50. u8 padding[5];
  51. };
  52. #define TLV_BUFFER_SIZE 1024
  53. enum {
  54. PFVF_STATUS_WAITING,
  55. PFVF_STATUS_SUCCESS,
  56. PFVF_STATUS_FAILURE,
  57. PFVF_STATUS_NOT_SUPPORTED,
  58. PFVF_STATUS_NO_RESOURCE,
  59. PFVF_STATUS_FORCED,
  60. PFVF_STATUS_MALICIOUS,
  61. };
  62. /* vf pf channel tlvs */
  63. /* general tlv header (used for both vf->pf request and pf->vf response) */
  64. struct channel_tlv {
  65. u16 type;
  66. u16 length;
  67. };
  68. /* header of first vf->pf tlv carries the offset used to calculate reponse
  69. * buffer address
  70. */
  71. struct vfpf_first_tlv {
  72. struct channel_tlv tl;
  73. u32 padding;
  74. u64 reply_address;
  75. };
  76. /* header of pf->vf tlvs, carries the status of handling the request */
  77. struct pfvf_tlv {
  78. struct channel_tlv tl;
  79. u8 status;
  80. u8 padding[3];
  81. };
  82. /* response tlv used for most tlvs */
  83. struct pfvf_def_resp_tlv {
  84. struct pfvf_tlv hdr;
  85. };
  86. /* used to terminate and pad a tlv list */
  87. struct channel_list_end_tlv {
  88. struct channel_tlv tl;
  89. u8 padding[4];
  90. };
  91. #define VFPF_ACQUIRE_OS_LINUX (0)
  92. #define VFPF_ACQUIRE_OS_WINDOWS (1)
  93. #define VFPF_ACQUIRE_OS_ESX (2)
  94. #define VFPF_ACQUIRE_OS_SOLARIS (3)
  95. #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
  96. struct vfpf_acquire_tlv {
  97. struct vfpf_first_tlv first_tlv;
  98. struct vf_pf_vfdev_info {
  99. #define VFPF_ACQUIRE_CAP_PRE_FP_HSI (1 << 0) /* VF pre-FP hsi version */
  100. #define VFPF_ACQUIRE_CAP_100G (1 << 1) /* VF can support 100g */
  101. u64 capabilities;
  102. u8 fw_major;
  103. u8 fw_minor;
  104. u8 fw_revision;
  105. u8 fw_engineering;
  106. u32 driver_version;
  107. u16 opaque_fid; /* ME register value */
  108. u8 os_type; /* VFPF_ACQUIRE_OS_* value */
  109. u8 eth_fp_hsi_major;
  110. u8 eth_fp_hsi_minor;
  111. u8 padding[3];
  112. } vfdev_info;
  113. struct vf_pf_resc_request resc_request;
  114. u64 bulletin_addr;
  115. u32 bulletin_size;
  116. u32 padding;
  117. };
  118. /* receive side scaling tlv */
  119. struct vfpf_vport_update_rss_tlv {
  120. struct channel_tlv tl;
  121. u8 update_rss_flags;
  122. #define VFPF_UPDATE_RSS_CONFIG_FLAG BIT(0)
  123. #define VFPF_UPDATE_RSS_CAPS_FLAG BIT(1)
  124. #define VFPF_UPDATE_RSS_IND_TABLE_FLAG BIT(2)
  125. #define VFPF_UPDATE_RSS_KEY_FLAG BIT(3)
  126. u8 rss_enable;
  127. u8 rss_caps;
  128. u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
  129. u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  130. u32 rss_key[T_ETH_RSS_KEY_SIZE];
  131. };
  132. struct pfvf_storm_stats {
  133. u32 address;
  134. u32 len;
  135. };
  136. struct pfvf_stats_info {
  137. struct pfvf_storm_stats mstats;
  138. struct pfvf_storm_stats pstats;
  139. struct pfvf_storm_stats tstats;
  140. struct pfvf_storm_stats ustats;
  141. };
  142. struct pfvf_acquire_resp_tlv {
  143. struct pfvf_tlv hdr;
  144. struct pf_vf_pfdev_info {
  145. u32 chip_num;
  146. u32 mfw_ver;
  147. u16 fw_major;
  148. u16 fw_minor;
  149. u16 fw_rev;
  150. u16 fw_eng;
  151. u64 capabilities;
  152. #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
  153. #define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
  154. /* There are old PF versions where the PF might mistakenly override the sanity
  155. * mechanism [version-based] and allow a VF that can't be supported to pass
  156. * the acquisition phase.
  157. * To overcome this, PFs now indicate that they're past that point and the new
  158. * VFs would fail probe on the older PFs that fail to do so.
  159. */
  160. #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
  161. u16 db_size;
  162. u8 indices_per_sb;
  163. u8 os_type;
  164. /* These should match the PF's qed_dev values */
  165. u16 chip_rev;
  166. u8 dev_type;
  167. u8 padding;
  168. struct pfvf_stats_info stats_info;
  169. u8 port_mac[ETH_ALEN];
  170. /* It's possible PF had to configure an older fastpath HSI
  171. * [in case VF is newer than PF]. This is communicated back
  172. * to the VF. It can also be used in case of error due to
  173. * non-matching versions to shed light in VF about failure.
  174. */
  175. u8 major_fp_hsi;
  176. u8 minor_fp_hsi;
  177. } pfdev_info;
  178. struct pf_vf_resc {
  179. #define PFVF_MAX_QUEUES_PER_VF 16
  180. #define PFVF_MAX_SBS_PER_VF 16
  181. struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
  182. u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
  183. u8 cid[PFVF_MAX_QUEUES_PER_VF];
  184. u8 num_rxqs;
  185. u8 num_txqs;
  186. u8 num_sbs;
  187. u8 num_mac_filters;
  188. u8 num_vlan_filters;
  189. u8 num_mc_filters;
  190. u8 padding[2];
  191. } resc;
  192. u32 bulletin_size;
  193. u32 padding;
  194. };
  195. struct pfvf_start_queue_resp_tlv {
  196. struct pfvf_tlv hdr;
  197. u32 offset; /* offset to consumer/producer of queue */
  198. u8 padding[4];
  199. };
  200. /* Setup Queue */
  201. struct vfpf_start_rxq_tlv {
  202. struct vfpf_first_tlv first_tlv;
  203. /* physical addresses */
  204. u64 rxq_addr;
  205. u64 deprecated_sge_addr;
  206. u64 cqe_pbl_addr;
  207. u16 cqe_pbl_size;
  208. u16 hw_sb;
  209. u16 rx_qid;
  210. u16 hc_rate; /* desired interrupts per sec. */
  211. u16 bd_max_bytes;
  212. u16 stat_id;
  213. u8 sb_index;
  214. u8 padding[3];
  215. };
  216. struct vfpf_start_txq_tlv {
  217. struct vfpf_first_tlv first_tlv;
  218. /* physical addresses */
  219. u64 pbl_addr;
  220. u16 pbl_size;
  221. u16 stat_id;
  222. u16 tx_qid;
  223. u16 hw_sb;
  224. u32 flags; /* VFPF_QUEUE_FLG_X flags */
  225. u16 hc_rate; /* desired interrupts per sec. */
  226. u8 sb_index;
  227. u8 padding[3];
  228. };
  229. /* Stop RX Queue */
  230. struct vfpf_stop_rxqs_tlv {
  231. struct vfpf_first_tlv first_tlv;
  232. u16 rx_qid;
  233. /* this field is deprecated and should *always* be set to '1' */
  234. u8 num_rxqs;
  235. u8 cqe_completion;
  236. u8 padding[4];
  237. };
  238. /* Stop TX Queues */
  239. struct vfpf_stop_txqs_tlv {
  240. struct vfpf_first_tlv first_tlv;
  241. u16 tx_qid;
  242. /* this field is deprecated and should *always* be set to '1' */
  243. u8 num_txqs;
  244. u8 padding[5];
  245. };
  246. struct vfpf_update_rxq_tlv {
  247. struct vfpf_first_tlv first_tlv;
  248. u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
  249. u16 rx_qid;
  250. u8 num_rxqs;
  251. u8 flags;
  252. #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
  253. #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
  254. #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
  255. u8 padding[4];
  256. };
  257. /* Set Queue Filters */
  258. struct vfpf_q_mac_vlan_filter {
  259. u32 flags;
  260. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  261. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  262. #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
  263. u8 mac[ETH_ALEN];
  264. u16 vlan_tag;
  265. u8 padding[4];
  266. };
  267. /* Start a vport */
  268. struct vfpf_vport_start_tlv {
  269. struct vfpf_first_tlv first_tlv;
  270. u64 sb_addr[PFVF_MAX_SBS_PER_VF];
  271. u32 tpa_mode;
  272. u16 dep1;
  273. u16 mtu;
  274. u8 vport_id;
  275. u8 inner_vlan_removal;
  276. u8 only_untagged;
  277. u8 max_buffers_per_cqe;
  278. u8 padding[4];
  279. };
  280. /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
  281. struct vfpf_vport_update_activate_tlv {
  282. struct channel_tlv tl;
  283. u8 update_rx;
  284. u8 update_tx;
  285. u8 active_rx;
  286. u8 active_tx;
  287. };
  288. struct vfpf_vport_update_tx_switch_tlv {
  289. struct channel_tlv tl;
  290. u8 tx_switching;
  291. u8 padding[3];
  292. };
  293. struct vfpf_vport_update_vlan_strip_tlv {
  294. struct channel_tlv tl;
  295. u8 remove_vlan;
  296. u8 padding[3];
  297. };
  298. struct vfpf_vport_update_mcast_bin_tlv {
  299. struct channel_tlv tl;
  300. u8 padding[4];
  301. u64 bins[8];
  302. };
  303. struct vfpf_vport_update_accept_param_tlv {
  304. struct channel_tlv tl;
  305. u8 update_rx_mode;
  306. u8 update_tx_mode;
  307. u8 rx_accept_filter;
  308. u8 tx_accept_filter;
  309. };
  310. struct vfpf_vport_update_accept_any_vlan_tlv {
  311. struct channel_tlv tl;
  312. u8 update_accept_any_vlan_flg;
  313. u8 accept_any_vlan;
  314. u8 padding[2];
  315. };
  316. struct vfpf_vport_update_sge_tpa_tlv {
  317. struct channel_tlv tl;
  318. u16 sge_tpa_flags;
  319. #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
  320. #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
  321. #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
  322. #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
  323. #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
  324. u8 update_sge_tpa_flags;
  325. #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
  326. #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
  327. #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
  328. u8 max_buffers_per_cqe;
  329. u16 deprecated_sge_buff_size;
  330. u16 tpa_max_size;
  331. u16 tpa_min_size_to_start;
  332. u16 tpa_min_size_to_cont;
  333. u8 tpa_max_aggs_num;
  334. u8 padding[7];
  335. };
  336. /* Primary tlv as a header for various extended tlvs for
  337. * various functionalities in vport update ramrod.
  338. */
  339. struct vfpf_vport_update_tlv {
  340. struct vfpf_first_tlv first_tlv;
  341. };
  342. struct vfpf_ucast_filter_tlv {
  343. struct vfpf_first_tlv first_tlv;
  344. u8 opcode;
  345. u8 type;
  346. u8 mac[ETH_ALEN];
  347. u16 vlan;
  348. u16 padding[3];
  349. };
  350. /* tunnel update param tlv */
  351. struct vfpf_update_tunn_param_tlv {
  352. struct vfpf_first_tlv first_tlv;
  353. u8 tun_mode_update_mask;
  354. u8 tunn_mode;
  355. u8 update_tun_cls;
  356. u8 vxlan_clss;
  357. u8 l2gre_clss;
  358. u8 ipgre_clss;
  359. u8 l2geneve_clss;
  360. u8 ipgeneve_clss;
  361. u8 update_geneve_port;
  362. u8 update_vxlan_port;
  363. u16 geneve_port;
  364. u16 vxlan_port;
  365. u8 padding[2];
  366. };
  367. struct pfvf_update_tunn_param_tlv {
  368. struct pfvf_tlv hdr;
  369. u16 tunn_feature_mask;
  370. u8 vxlan_mode;
  371. u8 l2geneve_mode;
  372. u8 ipgeneve_mode;
  373. u8 l2gre_mode;
  374. u8 ipgre_mode;
  375. u8 vxlan_clss;
  376. u8 l2gre_clss;
  377. u8 ipgre_clss;
  378. u8 l2geneve_clss;
  379. u8 ipgeneve_clss;
  380. u16 vxlan_udp_port;
  381. u16 geneve_udp_port;
  382. };
  383. struct tlv_buffer_size {
  384. u8 tlv_buffer[TLV_BUFFER_SIZE];
  385. };
  386. union vfpf_tlvs {
  387. struct vfpf_first_tlv first_tlv;
  388. struct vfpf_acquire_tlv acquire;
  389. struct vfpf_start_rxq_tlv start_rxq;
  390. struct vfpf_start_txq_tlv start_txq;
  391. struct vfpf_stop_rxqs_tlv stop_rxqs;
  392. struct vfpf_stop_txqs_tlv stop_txqs;
  393. struct vfpf_update_rxq_tlv update_rxq;
  394. struct vfpf_vport_start_tlv start_vport;
  395. struct vfpf_vport_update_tlv vport_update;
  396. struct vfpf_ucast_filter_tlv ucast_filter;
  397. struct vfpf_update_tunn_param_tlv tunn_param_update;
  398. struct channel_list_end_tlv list_end;
  399. struct tlv_buffer_size tlv_buf_size;
  400. };
  401. union pfvf_tlvs {
  402. struct pfvf_def_resp_tlv default_resp;
  403. struct pfvf_acquire_resp_tlv acquire_resp;
  404. struct tlv_buffer_size tlv_buf_size;
  405. struct pfvf_start_queue_resp_tlv queue_start;
  406. struct pfvf_update_tunn_param_tlv tunn_param_resp;
  407. };
  408. enum qed_bulletin_bit {
  409. /* Alert the VF that a forced MAC was set by the PF */
  410. MAC_ADDR_FORCED = 0,
  411. /* Alert the VF that a forced VLAN was set by the PF */
  412. VLAN_ADDR_FORCED = 2,
  413. /* Indicate that `default_only_untagged' contains actual data */
  414. VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
  415. VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
  416. /* Alert the VF that suggested mac was sent by the PF.
  417. * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
  418. */
  419. VFPF_BULLETIN_MAC_ADDR = 5
  420. };
  421. struct qed_bulletin_content {
  422. /* crc of structure to ensure is not in mid-update */
  423. u32 crc;
  424. u32 version;
  425. /* bitmap indicating which fields hold valid values */
  426. u64 valid_bitmap;
  427. /* used for MAC_ADDR or MAC_ADDR_FORCED */
  428. u8 mac[ETH_ALEN];
  429. /* If valid, 1 => only untagged Rx if no vlan is configured */
  430. u8 default_only_untagged;
  431. u8 padding;
  432. /* The following is a 'copy' of qed_mcp_link_state,
  433. * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
  434. * possible the structs will increase further along the road we cannot
  435. * have it here; Instead we need to have all of its fields.
  436. */
  437. u8 req_autoneg;
  438. u8 req_autoneg_pause;
  439. u8 req_forced_rx;
  440. u8 req_forced_tx;
  441. u8 padding2[4];
  442. u32 req_adv_speed;
  443. u32 req_forced_speed;
  444. u32 req_loopback;
  445. u32 padding3;
  446. u8 link_up;
  447. u8 full_duplex;
  448. u8 autoneg;
  449. u8 autoneg_complete;
  450. u8 parallel_detection;
  451. u8 pfc_enabled;
  452. u8 partner_tx_flow_ctrl_en;
  453. u8 partner_rx_flow_ctrl_en;
  454. u8 partner_adv_pause;
  455. u8 sfp_tx_fault;
  456. u16 vxlan_udp_port;
  457. u16 geneve_udp_port;
  458. u8 padding4[2];
  459. u32 speed;
  460. u32 partner_adv_speed;
  461. u32 capability_speed;
  462. /* Forced vlan */
  463. u16 pvid;
  464. u16 padding5;
  465. };
  466. struct qed_bulletin {
  467. dma_addr_t phys;
  468. struct qed_bulletin_content *p_virt;
  469. u32 size;
  470. };
  471. enum {
  472. CHANNEL_TLV_NONE, /* ends tlv sequence */
  473. CHANNEL_TLV_ACQUIRE,
  474. CHANNEL_TLV_VPORT_START,
  475. CHANNEL_TLV_VPORT_UPDATE,
  476. CHANNEL_TLV_VPORT_TEARDOWN,
  477. CHANNEL_TLV_START_RXQ,
  478. CHANNEL_TLV_START_TXQ,
  479. CHANNEL_TLV_STOP_RXQS,
  480. CHANNEL_TLV_STOP_TXQS,
  481. CHANNEL_TLV_UPDATE_RXQ,
  482. CHANNEL_TLV_INT_CLEANUP,
  483. CHANNEL_TLV_CLOSE,
  484. CHANNEL_TLV_RELEASE,
  485. CHANNEL_TLV_LIST_END,
  486. CHANNEL_TLV_UCAST_FILTER,
  487. CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
  488. CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
  489. CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
  490. CHANNEL_TLV_VPORT_UPDATE_MCAST,
  491. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
  492. CHANNEL_TLV_VPORT_UPDATE_RSS,
  493. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
  494. CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
  495. CHANNEL_TLV_UPDATE_TUNN_PARAM,
  496. CHANNEL_TLV_MAX,
  497. /* Required for iterating over vport-update tlvs.
  498. * Will break in case non-sequential vport-update tlvs.
  499. */
  500. CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
  501. };
  502. /* This data is held in the qed_hwfn structure for VFs only. */
  503. struct qed_vf_iov {
  504. union vfpf_tlvs *vf2pf_request;
  505. dma_addr_t vf2pf_request_phys;
  506. union pfvf_tlvs *pf2vf_reply;
  507. dma_addr_t pf2vf_reply_phys;
  508. /* Should be taken whenever the mailbox buffers are accessed */
  509. struct mutex mutex;
  510. u8 *offset;
  511. /* Bulletin Board */
  512. struct qed_bulletin bulletin;
  513. struct qed_bulletin_content bulletin_shadow;
  514. /* we set aside a copy of the acquire response */
  515. struct pfvf_acquire_resp_tlv acquire_resp;
  516. /* In case PF originates prior to the fp-hsi version comparison,
  517. * this has to be propagated as it affects the fastpath.
  518. */
  519. bool b_pre_fp_hsi;
  520. };
  521. #ifdef CONFIG_QED_SRIOV
  522. /**
  523. * @brief Read the VF bulletin and act on it if needed
  524. *
  525. * @param p_hwfn
  526. * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
  527. *
  528. * @return enum _qed_status
  529. */
  530. int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
  531. /**
  532. * @brief Get link paramters for VF from qed
  533. *
  534. * @param p_hwfn
  535. * @param params - the link params structure to be filled for the VF
  536. */
  537. void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  538. struct qed_mcp_link_params *params);
  539. /**
  540. * @brief Get link state for VF from qed
  541. *
  542. * @param p_hwfn
  543. * @param link - the link state structure to be filled for the VF
  544. */
  545. void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  546. struct qed_mcp_link_state *link);
  547. /**
  548. * @brief Get link capabilities for VF from qed
  549. *
  550. * @param p_hwfn
  551. * @param p_link_caps - the link capabilities structure to be filled for the VF
  552. */
  553. void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  554. struct qed_mcp_link_capabilities *p_link_caps);
  555. /**
  556. * @brief Get number of Rx queues allocated for VF by qed
  557. *
  558. * @param p_hwfn
  559. * @param num_rxqs - allocated RX queues
  560. */
  561. void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
  562. /**
  563. * @brief Get port mac address for VF
  564. *
  565. * @param p_hwfn
  566. * @param port_mac - destination location for port mac
  567. */
  568. void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
  569. /**
  570. * @brief Get number of VLAN filters allocated for VF by qed
  571. *
  572. * @param p_hwfn
  573. * @param num_rxqs - allocated VLAN filters
  574. */
  575. void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  576. u8 *num_vlan_filters);
  577. /**
  578. * @brief Get number of MAC filters allocated for VF by qed
  579. *
  580. * @param p_hwfn
  581. * @param num_rxqs - allocated MAC filters
  582. */
  583. void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
  584. /**
  585. * @brief Check if VF can set a MAC address
  586. *
  587. * @param p_hwfn
  588. * @param mac
  589. *
  590. * @return bool
  591. */
  592. bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
  593. /**
  594. * @brief Set firmware version information in dev_info from VFs acquire response tlv
  595. *
  596. * @param p_hwfn
  597. * @param fw_major
  598. * @param fw_minor
  599. * @param fw_rev
  600. * @param fw_eng
  601. */
  602. void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  603. u16 *fw_major, u16 *fw_minor,
  604. u16 *fw_rev, u16 *fw_eng);
  605. /**
  606. * @brief hw preparation for VF
  607. * sends ACQUIRE message
  608. *
  609. * @param p_hwfn
  610. *
  611. * @return int
  612. */
  613. int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
  614. /**
  615. * @brief VF - start the RX Queue by sending a message to the PF
  616. * @param p_hwfn
  617. * @param p_cid - Only relative fields are relevant
  618. * @param bd_max_bytes - maximum number of bytes per bd
  619. * @param bd_chain_phys_addr - physical address of bd chain
  620. * @param cqe_pbl_addr - physical address of pbl
  621. * @param cqe_pbl_size - pbl size
  622. * @param pp_prod - pointer to the producer to be
  623. * used in fastpath
  624. *
  625. * @return int
  626. */
  627. int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  628. struct qed_queue_cid *p_cid,
  629. u16 bd_max_bytes,
  630. dma_addr_t bd_chain_phys_addr,
  631. dma_addr_t cqe_pbl_addr,
  632. u16 cqe_pbl_size, void __iomem **pp_prod);
  633. /**
  634. * @brief VF - start the TX queue by sending a message to the
  635. * PF.
  636. *
  637. * @param p_hwfn
  638. * @param tx_queue_id - zero based within the VF
  639. * @param sb - status block for this queue
  640. * @param sb_index - index within the status block
  641. * @param bd_chain_phys_addr - physical address of tx chain
  642. * @param pp_doorbell - pointer to address to which to
  643. * write the doorbell too..
  644. *
  645. * @return int
  646. */
  647. int
  648. qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  649. struct qed_queue_cid *p_cid,
  650. dma_addr_t pbl_addr,
  651. u16 pbl_size, void __iomem **pp_doorbell);
  652. /**
  653. * @brief VF - stop the RX queue by sending a message to the PF
  654. *
  655. * @param p_hwfn
  656. * @param p_cid
  657. * @param cqe_completion
  658. *
  659. * @return int
  660. */
  661. int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  662. struct qed_queue_cid *p_cid, bool cqe_completion);
  663. /**
  664. * @brief VF - stop the TX queue by sending a message to the PF
  665. *
  666. * @param p_hwfn
  667. * @param tx_qid
  668. *
  669. * @return int
  670. */
  671. int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
  672. /**
  673. * @brief VF - send a vport update command
  674. *
  675. * @param p_hwfn
  676. * @param params
  677. *
  678. * @return int
  679. */
  680. int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  681. struct qed_sp_vport_update_params *p_params);
  682. /**
  683. *
  684. * @brief VF - send a close message to PF
  685. *
  686. * @param p_hwfn
  687. *
  688. * @return enum _qed_status
  689. */
  690. int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
  691. /**
  692. * @brief VF - free vf`s memories
  693. *
  694. * @param p_hwfn
  695. *
  696. * @return enum _qed_status
  697. */
  698. int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
  699. /**
  700. * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
  701. * sb_id. For VFs igu sbs don't have to be contiguous
  702. *
  703. * @param p_hwfn
  704. * @param sb_id
  705. *
  706. * @return INLINE u16
  707. */
  708. u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
  709. /**
  710. * @brief qed_vf_pf_vport_start - perform vport start for VF.
  711. *
  712. * @param p_hwfn
  713. * @param vport_id
  714. * @param mtu
  715. * @param inner_vlan_removal
  716. * @param tpa_mode
  717. * @param max_buffers_per_cqe,
  718. * @param only_untagged - default behavior regarding vlan acceptance
  719. *
  720. * @return enum _qed_status
  721. */
  722. int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  723. u8 vport_id,
  724. u16 mtu,
  725. u8 inner_vlan_removal,
  726. enum qed_tpa_mode tpa_mode,
  727. u8 max_buffers_per_cqe, u8 only_untagged);
  728. /**
  729. * @brief qed_vf_pf_vport_stop - stop the VF's vport
  730. *
  731. * @param p_hwfn
  732. *
  733. * @return enum _qed_status
  734. */
  735. int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
  736. int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  737. struct qed_filter_ucast *p_param);
  738. void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  739. struct qed_filter_mcast *p_filter_cmd);
  740. /**
  741. * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
  742. *
  743. * @param p_hwfn
  744. *
  745. * @return enum _qed_status
  746. */
  747. int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
  748. /**
  749. * @brief - return the link params in a given bulletin board
  750. *
  751. * @param p_hwfn
  752. * @param p_params - pointer to a struct to fill with link params
  753. * @param p_bulletin
  754. */
  755. void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  756. struct qed_mcp_link_params *p_params,
  757. struct qed_bulletin_content *p_bulletin);
  758. /**
  759. * @brief - return the link state in a given bulletin board
  760. *
  761. * @param p_hwfn
  762. * @param p_link - pointer to a struct to fill with link state
  763. * @param p_bulletin
  764. */
  765. void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  766. struct qed_mcp_link_state *p_link,
  767. struct qed_bulletin_content *p_bulletin);
  768. /**
  769. * @brief - return the link capabilities in a given bulletin board
  770. *
  771. * @param p_hwfn
  772. * @param p_link - pointer to a struct to fill with link capabilities
  773. * @param p_bulletin
  774. */
  775. void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  776. struct qed_mcp_link_capabilities *p_link_caps,
  777. struct qed_bulletin_content *p_bulletin);
  778. void qed_iov_vf_task(struct work_struct *work);
  779. void qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun);
  780. int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
  781. struct qed_tunnel_info *p_tunn);
  782. #else
  783. static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  784. struct qed_mcp_link_params *params)
  785. {
  786. }
  787. static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  788. struct qed_mcp_link_state *link)
  789. {
  790. }
  791. static inline void
  792. qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  793. struct qed_mcp_link_capabilities *p_link_caps)
  794. {
  795. }
  796. static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
  797. {
  798. }
  799. static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
  800. {
  801. }
  802. static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  803. u8 *num_vlan_filters)
  804. {
  805. }
  806. static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
  807. u8 *num_mac_filters)
  808. {
  809. }
  810. static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
  811. {
  812. return false;
  813. }
  814. static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  815. u16 *fw_major, u16 *fw_minor,
  816. u16 *fw_rev, u16 *fw_eng)
  817. {
  818. }
  819. static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
  820. {
  821. return -EINVAL;
  822. }
  823. static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  824. struct qed_queue_cid *p_cid,
  825. u16 bd_max_bytes,
  826. dma_addr_t bd_chain_phys_adr,
  827. dma_addr_t cqe_pbl_addr,
  828. u16 cqe_pbl_size, void __iomem **pp_prod)
  829. {
  830. return -EINVAL;
  831. }
  832. static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  833. struct qed_queue_cid *p_cid,
  834. dma_addr_t pbl_addr,
  835. u16 pbl_size, void __iomem **pp_doorbell)
  836. {
  837. return -EINVAL;
  838. }
  839. static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  840. struct qed_queue_cid *p_cid,
  841. bool cqe_completion)
  842. {
  843. return -EINVAL;
  844. }
  845. static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
  846. struct qed_queue_cid *p_cid)
  847. {
  848. return -EINVAL;
  849. }
  850. static inline int
  851. qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  852. struct qed_sp_vport_update_params *p_params)
  853. {
  854. return -EINVAL;
  855. }
  856. static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
  857. {
  858. return -EINVAL;
  859. }
  860. static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
  861. {
  862. return -EINVAL;
  863. }
  864. static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
  865. {
  866. return 0;
  867. }
  868. static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  869. u8 vport_id,
  870. u16 mtu,
  871. u8 inner_vlan_removal,
  872. enum qed_tpa_mode tpa_mode,
  873. u8 max_buffers_per_cqe,
  874. u8 only_untagged)
  875. {
  876. return -EINVAL;
  877. }
  878. static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
  879. {
  880. return -EINVAL;
  881. }
  882. static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  883. struct qed_filter_ucast *p_param)
  884. {
  885. return -EINVAL;
  886. }
  887. static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  888. struct qed_filter_mcast *p_filter_cmd)
  889. {
  890. }
  891. static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
  892. {
  893. return -EINVAL;
  894. }
  895. static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  896. struct qed_mcp_link_params
  897. *p_params,
  898. struct qed_bulletin_content
  899. *p_bulletin)
  900. {
  901. }
  902. static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  903. struct qed_mcp_link_state *p_link,
  904. struct qed_bulletin_content
  905. *p_bulletin)
  906. {
  907. }
  908. static inline void
  909. __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  910. struct qed_mcp_link_capabilities *p_link_caps,
  911. struct qed_bulletin_content *p_bulletin)
  912. {
  913. }
  914. static inline void qed_iov_vf_task(struct work_struct *work)
  915. {
  916. }
  917. static inline void
  918. qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun)
  919. {
  920. }
  921. static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
  922. struct qed_tunnel_info *p_tunn)
  923. {
  924. return -EINVAL;
  925. }
  926. #endif
  927. #endif