qed_vf.h 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  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. u8 num_rxqs;
  234. u8 cqe_completion;
  235. u8 padding[4];
  236. };
  237. /* Stop TX Queues */
  238. struct vfpf_stop_txqs_tlv {
  239. struct vfpf_first_tlv first_tlv;
  240. u16 tx_qid;
  241. u8 num_txqs;
  242. u8 padding[5];
  243. };
  244. struct vfpf_update_rxq_tlv {
  245. struct vfpf_first_tlv first_tlv;
  246. u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
  247. u16 rx_qid;
  248. u8 num_rxqs;
  249. u8 flags;
  250. #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
  251. #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
  252. #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
  253. u8 padding[4];
  254. };
  255. /* Set Queue Filters */
  256. struct vfpf_q_mac_vlan_filter {
  257. u32 flags;
  258. #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
  259. #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
  260. #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
  261. u8 mac[ETH_ALEN];
  262. u16 vlan_tag;
  263. u8 padding[4];
  264. };
  265. /* Start a vport */
  266. struct vfpf_vport_start_tlv {
  267. struct vfpf_first_tlv first_tlv;
  268. u64 sb_addr[PFVF_MAX_SBS_PER_VF];
  269. u32 tpa_mode;
  270. u16 dep1;
  271. u16 mtu;
  272. u8 vport_id;
  273. u8 inner_vlan_removal;
  274. u8 only_untagged;
  275. u8 max_buffers_per_cqe;
  276. u8 padding[4];
  277. };
  278. /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
  279. struct vfpf_vport_update_activate_tlv {
  280. struct channel_tlv tl;
  281. u8 update_rx;
  282. u8 update_tx;
  283. u8 active_rx;
  284. u8 active_tx;
  285. };
  286. struct vfpf_vport_update_tx_switch_tlv {
  287. struct channel_tlv tl;
  288. u8 tx_switching;
  289. u8 padding[3];
  290. };
  291. struct vfpf_vport_update_vlan_strip_tlv {
  292. struct channel_tlv tl;
  293. u8 remove_vlan;
  294. u8 padding[3];
  295. };
  296. struct vfpf_vport_update_mcast_bin_tlv {
  297. struct channel_tlv tl;
  298. u8 padding[4];
  299. u64 bins[8];
  300. };
  301. struct vfpf_vport_update_accept_param_tlv {
  302. struct channel_tlv tl;
  303. u8 update_rx_mode;
  304. u8 update_tx_mode;
  305. u8 rx_accept_filter;
  306. u8 tx_accept_filter;
  307. };
  308. struct vfpf_vport_update_accept_any_vlan_tlv {
  309. struct channel_tlv tl;
  310. u8 update_accept_any_vlan_flg;
  311. u8 accept_any_vlan;
  312. u8 padding[2];
  313. };
  314. struct vfpf_vport_update_sge_tpa_tlv {
  315. struct channel_tlv tl;
  316. u16 sge_tpa_flags;
  317. #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
  318. #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
  319. #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
  320. #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
  321. #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
  322. u8 update_sge_tpa_flags;
  323. #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
  324. #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
  325. #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
  326. u8 max_buffers_per_cqe;
  327. u16 deprecated_sge_buff_size;
  328. u16 tpa_max_size;
  329. u16 tpa_min_size_to_start;
  330. u16 tpa_min_size_to_cont;
  331. u8 tpa_max_aggs_num;
  332. u8 padding[7];
  333. };
  334. /* Primary tlv as a header for various extended tlvs for
  335. * various functionalities in vport update ramrod.
  336. */
  337. struct vfpf_vport_update_tlv {
  338. struct vfpf_first_tlv first_tlv;
  339. };
  340. struct vfpf_ucast_filter_tlv {
  341. struct vfpf_first_tlv first_tlv;
  342. u8 opcode;
  343. u8 type;
  344. u8 mac[ETH_ALEN];
  345. u16 vlan;
  346. u16 padding[3];
  347. };
  348. struct tlv_buffer_size {
  349. u8 tlv_buffer[TLV_BUFFER_SIZE];
  350. };
  351. union vfpf_tlvs {
  352. struct vfpf_first_tlv first_tlv;
  353. struct vfpf_acquire_tlv acquire;
  354. struct vfpf_start_rxq_tlv start_rxq;
  355. struct vfpf_start_txq_tlv start_txq;
  356. struct vfpf_stop_rxqs_tlv stop_rxqs;
  357. struct vfpf_stop_txqs_tlv stop_txqs;
  358. struct vfpf_update_rxq_tlv update_rxq;
  359. struct vfpf_vport_start_tlv start_vport;
  360. struct vfpf_vport_update_tlv vport_update;
  361. struct vfpf_ucast_filter_tlv ucast_filter;
  362. struct channel_list_end_tlv list_end;
  363. struct tlv_buffer_size tlv_buf_size;
  364. };
  365. union pfvf_tlvs {
  366. struct pfvf_def_resp_tlv default_resp;
  367. struct pfvf_acquire_resp_tlv acquire_resp;
  368. struct tlv_buffer_size tlv_buf_size;
  369. struct pfvf_start_queue_resp_tlv queue_start;
  370. };
  371. enum qed_bulletin_bit {
  372. /* Alert the VF that a forced MAC was set by the PF */
  373. MAC_ADDR_FORCED = 0,
  374. /* Alert the VF that a forced VLAN was set by the PF */
  375. VLAN_ADDR_FORCED = 2,
  376. /* Indicate that `default_only_untagged' contains actual data */
  377. VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
  378. VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
  379. /* Alert the VF that suggested mac was sent by the PF.
  380. * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
  381. */
  382. VFPF_BULLETIN_MAC_ADDR = 5
  383. };
  384. struct qed_bulletin_content {
  385. /* crc of structure to ensure is not in mid-update */
  386. u32 crc;
  387. u32 version;
  388. /* bitmap indicating which fields hold valid values */
  389. u64 valid_bitmap;
  390. /* used for MAC_ADDR or MAC_ADDR_FORCED */
  391. u8 mac[ETH_ALEN];
  392. /* If valid, 1 => only untagged Rx if no vlan is configured */
  393. u8 default_only_untagged;
  394. u8 padding;
  395. /* The following is a 'copy' of qed_mcp_link_state,
  396. * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
  397. * possible the structs will increase further along the road we cannot
  398. * have it here; Instead we need to have all of its fields.
  399. */
  400. u8 req_autoneg;
  401. u8 req_autoneg_pause;
  402. u8 req_forced_rx;
  403. u8 req_forced_tx;
  404. u8 padding2[4];
  405. u32 req_adv_speed;
  406. u32 req_forced_speed;
  407. u32 req_loopback;
  408. u32 padding3;
  409. u8 link_up;
  410. u8 full_duplex;
  411. u8 autoneg;
  412. u8 autoneg_complete;
  413. u8 parallel_detection;
  414. u8 pfc_enabled;
  415. u8 partner_tx_flow_ctrl_en;
  416. u8 partner_rx_flow_ctrl_en;
  417. u8 partner_adv_pause;
  418. u8 sfp_tx_fault;
  419. u8 padding4[6];
  420. u32 speed;
  421. u32 partner_adv_speed;
  422. u32 capability_speed;
  423. /* Forced vlan */
  424. u16 pvid;
  425. u16 padding5;
  426. };
  427. struct qed_bulletin {
  428. dma_addr_t phys;
  429. struct qed_bulletin_content *p_virt;
  430. u32 size;
  431. };
  432. enum {
  433. CHANNEL_TLV_NONE, /* ends tlv sequence */
  434. CHANNEL_TLV_ACQUIRE,
  435. CHANNEL_TLV_VPORT_START,
  436. CHANNEL_TLV_VPORT_UPDATE,
  437. CHANNEL_TLV_VPORT_TEARDOWN,
  438. CHANNEL_TLV_START_RXQ,
  439. CHANNEL_TLV_START_TXQ,
  440. CHANNEL_TLV_STOP_RXQS,
  441. CHANNEL_TLV_STOP_TXQS,
  442. CHANNEL_TLV_UPDATE_RXQ,
  443. CHANNEL_TLV_INT_CLEANUP,
  444. CHANNEL_TLV_CLOSE,
  445. CHANNEL_TLV_RELEASE,
  446. CHANNEL_TLV_LIST_END,
  447. CHANNEL_TLV_UCAST_FILTER,
  448. CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
  449. CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
  450. CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
  451. CHANNEL_TLV_VPORT_UPDATE_MCAST,
  452. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
  453. CHANNEL_TLV_VPORT_UPDATE_RSS,
  454. CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
  455. CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
  456. CHANNEL_TLV_MAX,
  457. /* Required for iterating over vport-update tlvs.
  458. * Will break in case non-sequential vport-update tlvs.
  459. */
  460. CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
  461. };
  462. /* This data is held in the qed_hwfn structure for VFs only. */
  463. struct qed_vf_iov {
  464. union vfpf_tlvs *vf2pf_request;
  465. dma_addr_t vf2pf_request_phys;
  466. union pfvf_tlvs *pf2vf_reply;
  467. dma_addr_t pf2vf_reply_phys;
  468. /* Should be taken whenever the mailbox buffers are accessed */
  469. struct mutex mutex;
  470. u8 *offset;
  471. /* Bulletin Board */
  472. struct qed_bulletin bulletin;
  473. struct qed_bulletin_content bulletin_shadow;
  474. /* we set aside a copy of the acquire response */
  475. struct pfvf_acquire_resp_tlv acquire_resp;
  476. /* In case PF originates prior to the fp-hsi version comparison,
  477. * this has to be propagated as it affects the fastpath.
  478. */
  479. bool b_pre_fp_hsi;
  480. };
  481. #ifdef CONFIG_QED_SRIOV
  482. /**
  483. * @brief Read the VF bulletin and act on it if needed
  484. *
  485. * @param p_hwfn
  486. * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
  487. *
  488. * @return enum _qed_status
  489. */
  490. int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
  491. /**
  492. * @brief Get link paramters for VF from qed
  493. *
  494. * @param p_hwfn
  495. * @param params - the link params structure to be filled for the VF
  496. */
  497. void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  498. struct qed_mcp_link_params *params);
  499. /**
  500. * @brief Get link state for VF from qed
  501. *
  502. * @param p_hwfn
  503. * @param link - the link state structure to be filled for the VF
  504. */
  505. void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  506. struct qed_mcp_link_state *link);
  507. /**
  508. * @brief Get link capabilities for VF from qed
  509. *
  510. * @param p_hwfn
  511. * @param p_link_caps - the link capabilities structure to be filled for the VF
  512. */
  513. void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  514. struct qed_mcp_link_capabilities *p_link_caps);
  515. /**
  516. * @brief Get number of Rx queues allocated for VF by qed
  517. *
  518. * @param p_hwfn
  519. * @param num_rxqs - allocated RX queues
  520. */
  521. void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
  522. /**
  523. * @brief Get port mac address for VF
  524. *
  525. * @param p_hwfn
  526. * @param port_mac - destination location for port mac
  527. */
  528. void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
  529. /**
  530. * @brief Get number of VLAN filters allocated for VF by qed
  531. *
  532. * @param p_hwfn
  533. * @param num_rxqs - allocated VLAN filters
  534. */
  535. void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  536. u8 *num_vlan_filters);
  537. /**
  538. * @brief Get number of MAC filters allocated for VF by qed
  539. *
  540. * @param p_hwfn
  541. * @param num_rxqs - allocated MAC filters
  542. */
  543. void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
  544. /**
  545. * @brief Check if VF can set a MAC address
  546. *
  547. * @param p_hwfn
  548. * @param mac
  549. *
  550. * @return bool
  551. */
  552. bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
  553. /**
  554. * @brief Set firmware version information in dev_info from VFs acquire response tlv
  555. *
  556. * @param p_hwfn
  557. * @param fw_major
  558. * @param fw_minor
  559. * @param fw_rev
  560. * @param fw_eng
  561. */
  562. void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  563. u16 *fw_major, u16 *fw_minor,
  564. u16 *fw_rev, u16 *fw_eng);
  565. /**
  566. * @brief hw preparation for VF
  567. * sends ACQUIRE message
  568. *
  569. * @param p_hwfn
  570. *
  571. * @return int
  572. */
  573. int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
  574. /**
  575. * @brief VF - start the RX Queue by sending a message to the PF
  576. * @param p_hwfn
  577. * @param p_cid - Only relative fields are relevant
  578. * @param bd_max_bytes - maximum number of bytes per bd
  579. * @param bd_chain_phys_addr - physical address of bd chain
  580. * @param cqe_pbl_addr - physical address of pbl
  581. * @param cqe_pbl_size - pbl size
  582. * @param pp_prod - pointer to the producer to be
  583. * used in fastpath
  584. *
  585. * @return int
  586. */
  587. int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  588. struct qed_queue_cid *p_cid,
  589. u16 bd_max_bytes,
  590. dma_addr_t bd_chain_phys_addr,
  591. dma_addr_t cqe_pbl_addr,
  592. u16 cqe_pbl_size, void __iomem **pp_prod);
  593. /**
  594. * @brief VF - start the TX queue by sending a message to the
  595. * PF.
  596. *
  597. * @param p_hwfn
  598. * @param tx_queue_id - zero based within the VF
  599. * @param sb - status block for this queue
  600. * @param sb_index - index within the status block
  601. * @param bd_chain_phys_addr - physical address of tx chain
  602. * @param pp_doorbell - pointer to address to which to
  603. * write the doorbell too..
  604. *
  605. * @return int
  606. */
  607. int
  608. qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  609. struct qed_queue_cid *p_cid,
  610. dma_addr_t pbl_addr,
  611. u16 pbl_size, void __iomem **pp_doorbell);
  612. /**
  613. * @brief VF - stop the RX queue by sending a message to the PF
  614. *
  615. * @param p_hwfn
  616. * @param p_cid
  617. * @param cqe_completion
  618. *
  619. * @return int
  620. */
  621. int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  622. struct qed_queue_cid *p_cid, bool cqe_completion);
  623. /**
  624. * @brief VF - stop the TX queue by sending a message to the PF
  625. *
  626. * @param p_hwfn
  627. * @param tx_qid
  628. *
  629. * @return int
  630. */
  631. int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
  632. /**
  633. * @brief VF - send a vport update command
  634. *
  635. * @param p_hwfn
  636. * @param params
  637. *
  638. * @return int
  639. */
  640. int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  641. struct qed_sp_vport_update_params *p_params);
  642. /**
  643. *
  644. * @brief VF - send a close message to PF
  645. *
  646. * @param p_hwfn
  647. *
  648. * @return enum _qed_status
  649. */
  650. int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
  651. /**
  652. * @brief VF - free vf`s memories
  653. *
  654. * @param p_hwfn
  655. *
  656. * @return enum _qed_status
  657. */
  658. int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
  659. /**
  660. * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
  661. * sb_id. For VFs igu sbs don't have to be contiguous
  662. *
  663. * @param p_hwfn
  664. * @param sb_id
  665. *
  666. * @return INLINE u16
  667. */
  668. u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
  669. /**
  670. * @brief qed_vf_pf_vport_start - perform vport start for VF.
  671. *
  672. * @param p_hwfn
  673. * @param vport_id
  674. * @param mtu
  675. * @param inner_vlan_removal
  676. * @param tpa_mode
  677. * @param max_buffers_per_cqe,
  678. * @param only_untagged - default behavior regarding vlan acceptance
  679. *
  680. * @return enum _qed_status
  681. */
  682. int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  683. u8 vport_id,
  684. u16 mtu,
  685. u8 inner_vlan_removal,
  686. enum qed_tpa_mode tpa_mode,
  687. u8 max_buffers_per_cqe, u8 only_untagged);
  688. /**
  689. * @brief qed_vf_pf_vport_stop - stop the VF's vport
  690. *
  691. * @param p_hwfn
  692. *
  693. * @return enum _qed_status
  694. */
  695. int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
  696. int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  697. struct qed_filter_ucast *p_param);
  698. void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  699. struct qed_filter_mcast *p_filter_cmd);
  700. /**
  701. * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
  702. *
  703. * @param p_hwfn
  704. *
  705. * @return enum _qed_status
  706. */
  707. int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
  708. /**
  709. * @brief - return the link params in a given bulletin board
  710. *
  711. * @param p_hwfn
  712. * @param p_params - pointer to a struct to fill with link params
  713. * @param p_bulletin
  714. */
  715. void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  716. struct qed_mcp_link_params *p_params,
  717. struct qed_bulletin_content *p_bulletin);
  718. /**
  719. * @brief - return the link state in a given bulletin board
  720. *
  721. * @param p_hwfn
  722. * @param p_link - pointer to a struct to fill with link state
  723. * @param p_bulletin
  724. */
  725. void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  726. struct qed_mcp_link_state *p_link,
  727. struct qed_bulletin_content *p_bulletin);
  728. /**
  729. * @brief - return the link capabilities in a given bulletin board
  730. *
  731. * @param p_hwfn
  732. * @param p_link - pointer to a struct to fill with link capabilities
  733. * @param p_bulletin
  734. */
  735. void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  736. struct qed_mcp_link_capabilities *p_link_caps,
  737. struct qed_bulletin_content *p_bulletin);
  738. void qed_iov_vf_task(struct work_struct *work);
  739. #else
  740. static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  741. struct qed_mcp_link_params *params)
  742. {
  743. }
  744. static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  745. struct qed_mcp_link_state *link)
  746. {
  747. }
  748. static inline void
  749. qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  750. struct qed_mcp_link_capabilities *p_link_caps)
  751. {
  752. }
  753. static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
  754. {
  755. }
  756. static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
  757. {
  758. }
  759. static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
  760. u8 *num_vlan_filters)
  761. {
  762. }
  763. static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
  764. u8 *num_mac_filters)
  765. {
  766. }
  767. static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
  768. {
  769. return false;
  770. }
  771. static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
  772. u16 *fw_major, u16 *fw_minor,
  773. u16 *fw_rev, u16 *fw_eng)
  774. {
  775. }
  776. static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
  777. {
  778. return -EINVAL;
  779. }
  780. static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
  781. struct qed_queue_cid *p_cid,
  782. u16 bd_max_bytes,
  783. dma_addr_t bd_chain_phys_adr,
  784. dma_addr_t cqe_pbl_addr,
  785. u16 cqe_pbl_size, void __iomem **pp_prod)
  786. {
  787. return -EINVAL;
  788. }
  789. static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
  790. struct qed_queue_cid *p_cid,
  791. dma_addr_t pbl_addr,
  792. u16 pbl_size, void __iomem **pp_doorbell)
  793. {
  794. return -EINVAL;
  795. }
  796. static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
  797. struct qed_queue_cid *p_cid,
  798. bool cqe_completion)
  799. {
  800. return -EINVAL;
  801. }
  802. static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
  803. struct qed_queue_cid *p_cid)
  804. {
  805. return -EINVAL;
  806. }
  807. static inline int
  808. qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
  809. struct qed_sp_vport_update_params *p_params)
  810. {
  811. return -EINVAL;
  812. }
  813. static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
  814. {
  815. return -EINVAL;
  816. }
  817. static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
  818. {
  819. return -EINVAL;
  820. }
  821. static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
  822. {
  823. return 0;
  824. }
  825. static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
  826. u8 vport_id,
  827. u16 mtu,
  828. u8 inner_vlan_removal,
  829. enum qed_tpa_mode tpa_mode,
  830. u8 max_buffers_per_cqe,
  831. u8 only_untagged)
  832. {
  833. return -EINVAL;
  834. }
  835. static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
  836. {
  837. return -EINVAL;
  838. }
  839. static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
  840. struct qed_filter_ucast *p_param)
  841. {
  842. return -EINVAL;
  843. }
  844. static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
  845. struct qed_filter_mcast *p_filter_cmd)
  846. {
  847. }
  848. static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
  849. {
  850. return -EINVAL;
  851. }
  852. static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
  853. struct qed_mcp_link_params
  854. *p_params,
  855. struct qed_bulletin_content
  856. *p_bulletin)
  857. {
  858. }
  859. static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
  860. struct qed_mcp_link_state *p_link,
  861. struct qed_bulletin_content
  862. *p_bulletin)
  863. {
  864. }
  865. static inline void
  866. __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
  867. struct qed_mcp_link_capabilities *p_link_caps,
  868. struct qed_bulletin_content *p_bulletin)
  869. {
  870. }
  871. static inline void qed_iov_vf_task(struct work_struct *work)
  872. {
  873. }
  874. #endif
  875. #endif