ecore_iov_api.h revision 337519
180708Sjake/* 280708Sjake * Copyright (c) 2017-2018 Cavium, Inc. 385586Sjake * All rights reserved. 485586Sjake * 580708Sjake * Redistribution and use in source and binary forms, with or without 680708Sjake * modification, are permitted provided that the following conditions 785586Sjake * are met: 885586Sjake * 985586Sjake * 1. Redistributions of source code must retain the above copyright 1080708Sjake * notice, this list of conditions and the following disclaimer. 1180708Sjake * 2. Redistributions in binary form must reproduce the above copyright 1280708Sjake * notice, this list of conditions and the following disclaimer in the 1380708Sjake * documentation and/or other materials provided with the distribution. 1480708Sjake * 1580708Sjake * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1680708Sjake * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1780708Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1885586Sjake * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 1985586Sjake * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2085586Sjake * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2185586Sjake * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2285586Sjake * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2385586Sjake * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2485586Sjake * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2580708Sjake * POSSIBILITY OF SUCH DAMAGE. 2685586Sjake * 2785586Sjake * $FreeBSD: stable/10/sys/dev/qlnx/qlnxe/ecore_iov_api.h 337519 2018-08-09 01:39:47Z davidcs $ 2885586Sjake * 2985586Sjake */ 3085586Sjake 3185586Sjake#ifndef __ECORE_SRIOV_API_H__ 3285586Sjake#define __ECORE_SRIOV_API_H__ 3385586Sjake 3485586Sjake#include "common_hsi.h" 3585586Sjake#include "ecore_status.h" 3685586Sjake 3780708Sjake#define ECORE_ETH_VF_NUM_MAC_FILTERS 1 3885586Sjake#define ECORE_ETH_VF_NUM_VLAN_FILTERS 2 3980708Sjake#define ECORE_VF_ARRAY_LENGTH (3) 4080708Sjake 4180708Sjake#define IS_VF(p_dev) ((p_dev)->b_is_vf) 4280708Sjake#define IS_PF(p_dev) (!((p_dev)->b_is_vf)) 43100384Speter#ifdef CONFIG_ECORE_SRIOV 4480708Sjake#define IS_PF_SRIOV(p_hwfn) (!!((p_hwfn)->p_dev->p_iov_info)) 45102808Sjake#else 46102808Sjake#define IS_PF_SRIOV(p_hwfn) (0) 4780708Sjake#endif 48100384Speter#define IS_PF_SRIOV_ALLOC(p_hwfn) (!!((p_hwfn)->pf_iov_info)) 49100384Speter#define IS_PF_PDA(p_hwfn) 0 /* @@TBD Michalk */ 50100384Speter 51100384Speter/* @@@ TBD MichalK - what should this number be*/ 52100384Speter#define ECORE_MAX_VF_CHAINS_PER_PF 16 53102808Sjake 54102808Sjake/* vport update extended feature tlvs flags */ 55102808Sjakeenum ecore_iov_vport_update_flag { 56102808Sjake ECORE_IOV_VP_UPDATE_ACTIVATE = 0, 5780708Sjake ECORE_IOV_VP_UPDATE_VLAN_STRIP = 1, 5880708Sjake ECORE_IOV_VP_UPDATE_TX_SWITCH = 2, 5985586Sjake ECORE_IOV_VP_UPDATE_MCAST = 3, 6085586Sjake ECORE_IOV_VP_UPDATE_ACCEPT_PARAM = 4, 61100384Speter ECORE_IOV_VP_UPDATE_RSS = 5, 62100384Speter ECORE_IOV_VP_UPDATE_ACCEPT_ANY_VLAN = 6, 63100384Speter ECORE_IOV_VP_UPDATE_SGE_TPA = 7, 64100384Speter ECORE_IOV_VP_UPDATE_MAX = 8, 65100384Speter}; 66102808Sjake 67100384Speter/*PF to VF STATUS is part of vfpf-channel API 68102808Sjakeand must be forward compatible */ 69102808Sjakeenum ecore_iov_pf_to_vf_status { 70102808Sjake PFVF_STATUS_WAITING = 0, 71100384Speter PFVF_STATUS_SUCCESS, 72102555Sjake PFVF_STATUS_FAILURE, 73102555Sjake PFVF_STATUS_NOT_SUPPORTED, 74102808Sjake PFVF_STATUS_NO_RESOURCE, 75100384Speter PFVF_STATUS_FORCED, 76100384Speter PFVF_STATUS_MALICIOUS, 77100384Speter}; 78102808Sjake 79102808Sjakestruct ecore_mcp_link_params; 80102808Sjakestruct ecore_mcp_link_state; 81102808Sjakestruct ecore_mcp_link_capabilities; 82102808Sjake 83102808Sjake/* These defines are used by the hw-channel; should never change order */ 84102808Sjake#define VFPF_ACQUIRE_OS_LINUX (0) 85102808Sjake#define VFPF_ACQUIRE_OS_WINDOWS (1) 86102808Sjake#define VFPF_ACQUIRE_OS_ESX (2) 87100384Speter#define VFPF_ACQUIRE_OS_SOLARIS (3) 88100384Speter#define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4) 89100384Speter#define VFPF_ACQUIRE_OS_FREEBSD (5) 90100384Speter 91100384Speterstruct ecore_vf_acquire_sw_info { 92100384Speter u32 driver_version; 93100384Speter u8 os_type; 94100384Speter}; 95100384Speter 96100384Speterstruct ecore_public_vf_info { 97100384Speter /* These copies will later be reflected in the bulletin board, 98100384Speter * but this copy should be newer. 99100384Speter */ 100100384Speter u8 forced_mac[ETH_ALEN]; 101100384Speter u16 forced_vlan; 10285586Sjake}; 10385586Sjake 10485586Sjakestruct ecore_iov_vf_init_params { 10585586Sjake u16 rel_vf_id; 10685586Sjake 10785586Sjake /* Number of requested Queues; Currently, don't support different 10885586Sjake * number of Rx/Tx queues. 10985586Sjake */ 11085586Sjake /* TODO - remove this limitation */ 11185586Sjake u16 num_queues; 11285586Sjake 11385586Sjake /* Allow the client to choose which qzones to use for Rx/Tx, 11485586Sjake * and which queue_base to use for Tx queues on a per-queue basis. 11585586Sjake * Notice values should be relative to the PF resources. 11685586Sjake */ 11785586Sjake u16 req_rx_queue[ECORE_MAX_VF_CHAINS_PER_PF]; 11885586Sjake u16 req_tx_queue[ECORE_MAX_VF_CHAINS_PER_PF]; 11985586Sjake 12085586Sjake u8 vport_id; 12185586Sjake 12285586Sjake /* Should be set in case RSS is going to be used for VF */ 12385586Sjake u8 rss_eng_id; 12485586Sjake}; 12585586Sjake 12685586Sjake#ifdef CONFIG_ECORE_SW_CHANNEL 12785586Sjake/* This is SW channel related only... */ 12885586Sjakeenum mbx_state { 12985586Sjake VF_PF_UNKNOWN_STATE = 0, 13085586Sjake VF_PF_WAIT_FOR_START_REQUEST = 1, 13185586Sjake VF_PF_WAIT_FOR_NEXT_CHUNK_OF_REQUEST = 2, 13285586Sjake VF_PF_REQUEST_IN_PROCESSING = 3, 13385586Sjake VF_PF_RESPONSE_READY = 4, 134104072Sjake}; 13585586Sjake 13685586Sjakestruct ecore_iov_sw_mbx { 137104072Sjake enum mbx_state mbx_state; 13885586Sjake 13985586Sjake u32 request_size; 14085586Sjake u32 request_offset; 14185586Sjake 14285586Sjake u32 response_size; 14385586Sjake u32 response_offset; 14485586Sjake}; 14585586Sjake 14685586Sjake/** 147104072Sjake * @brief Get the vf sw mailbox params 148104072Sjake * 14985586Sjake * @param p_hwfn 15085586Sjake * @param rel_vf_id 15185586Sjake * 15285586Sjake * @return struct ecore_iov_sw_mbx* 15385586Sjake */ 15485586Sjakestruct ecore_iov_sw_mbx* 15585586Sjakeecore_iov_get_vf_sw_mbx(struct ecore_hwfn *p_hwfn, 15685586Sjake u16 rel_vf_id); 15785586Sjake#endif 15885586Sjake 15985586Sjake/* This struct is part of ecore_dev and contains data relevant to all hwfns; 16085586Sjake * Initialized only if SR-IOV cpabability is exposed in PCIe config space. 16185586Sjake */ 16285586Sjakestruct ecore_hw_sriov_info { 16385586Sjake /* standard SRIOV capability fields, mostly for debugging */ 16485586Sjake int pos; /* capability position */ 16585586Sjake int nres; /* number of resources */ 16685586Sjake u32 cap; /* SR-IOV Capabilities */ 16785586Sjake u16 ctrl; /* SR-IOV Control */ 16885586Sjake u16 total_vfs; /* total VFs associated with the PF */ 16985586Sjake u16 num_vfs; /* number of vfs that have been started */ 17085586Sjake u16 initial_vfs; /* initial VFs associated with the PF */ 17185586Sjake u16 nr_virtfn; /* number of VFs available */ 17285586Sjake u16 offset; /* first VF Routing ID offset */ 17385586Sjake u16 stride; /* following VF stride */ 17485586Sjake u16 vf_device_id; /* VF device id */ 17585586Sjake u32 pgsz; /* page size for BAR alignment */ 17685586Sjake u8 link; /* Function Dependency Link */ 17785586Sjake 17885586Sjake u32 first_vf_in_pf; 17985586Sjake}; 18085586Sjake 18185586Sjake#ifdef CONFIG_ECORE_SRIOV 18285586Sjake#ifndef LINUX_REMOVE 18385586Sjake/** 184104072Sjake * @brief mark/clear all VFs before/after an incoming PCIe sriov 185104072Sjake * disable. 186104072Sjake * 187104072Sjake * @param p_dev 188104072Sjake * @param to_disable 189104072Sjake */ 190104072Sjakevoid ecore_iov_set_vfs_to_disable(struct ecore_dev *p_dev, 191104072Sjake u8 to_disable); 192104072Sjake 193104072Sjake/** 194104072Sjake * @brief mark/clear chosen VF before/after an incoming PCIe 195104072Sjake * sriov disable. 196104072Sjake * 197104072Sjake * @param p_dev 198104072Sjake * @param rel_vf_id 199104072Sjake * @param to_disable 20085586Sjake */ 20185586Sjakevoid ecore_iov_set_vf_to_disable(struct ecore_dev *p_dev, 20285586Sjake u16 rel_vf_id, 20385586Sjake u8 to_disable); 20485586Sjake 20585586Sjake/** 20685586Sjake * @brief ecore_iov_init_hw_for_vf - initialize the HW for 20785586Sjake * enabling access of a VF. Also includes preparing the 20885586Sjake * IGU for VF access. This needs to be called AFTER hw is 20985586Sjake * initialized and BEFORE VF is loaded inside the VM. 21085586Sjake * 21185586Sjake * @param p_hwfn 21285586Sjake * @param p_ptt 21385586Sjake * @param p_params 21485586Sjake * 21585586Sjake * @return enum _ecore_status_t 21685586Sjake */ 21785586Sjakeenum _ecore_status_t 21885586Sjakeecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn, 21985586Sjake struct ecore_ptt *p_ptt, 22085586Sjake struct ecore_iov_vf_init_params *p_params); 22185586Sjake 22285586Sjake/** 22385586Sjake * @brief ecore_iov_process_mbx_req - process a request received 22485586Sjake * from the VF 22585586Sjake * 22685586Sjake * @param p_hwfn 22785586Sjake * @param p_ptt 22885586Sjake * @param vfid 22985586Sjake */ 23085586Sjakevoid ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn, 23185586Sjake struct ecore_ptt *p_ptt, 23285586Sjake int vfid); 23385586Sjake 23485586Sjake/** 23585586Sjake * @brief ecore_iov_release_hw_for_vf - called once upper layer 23685586Sjake * knows VF is done with - can release any resources 23785586Sjake * allocated for VF at this point. this must be done once 23885586Sjake * we know VF is no longer loaded in VM. 23980708Sjake * 24095410Smarcel * @param p_hwfn 24180708Sjake * @param p_ptt 24285586Sjake * @param rel_vf_id 243104072Sjake * 24485586Sjake * @return enum _ecore_status_t 24585586Sjake */ 24685586Sjakeenum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn, 24795410Smarcel struct ecore_ptt *p_ptt, 24885586Sjake u16 rel_vf_id); 24985586Sjake 25098635Smux/** 25185586Sjake * @brief ecore_iov_set_vf_ctx - set a context for a given VF 25285586Sjake * 25385586Sjake * @param p_hwfn 25485586Sjake * @param vf_id 25585586Sjake * @param ctx 25685586Sjake * 25785586Sjake * @return enum _ecore_status_t 25885586Sjake */ 25985586Sjakeenum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn *p_hwfn, 26095410Smarcel u16 vf_id, 26185586Sjake void *ctx); 26285586Sjake 26385586Sjake/** 26485586Sjake * @brief FLR cleanup for all VFs 26585586Sjake * 26685586Sjake * @param p_hwfn 26785586Sjake * @param p_ptt 26885586Sjake * 26985586Sjake * @return enum _ecore_status_t 27085586Sjake */ 27185586Sjakeenum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, 27285586Sjake struct ecore_ptt *p_ptt); 27385586Sjake 27485586Sjake/** 275104072Sjake * @brief FLR cleanup for single VF 276104072Sjake * 277104072Sjake * @param p_hwfn 278104072Sjake * @param p_ptt 279104072Sjake * @param rel_vf_id 280104072Sjake * 281104072Sjake * @return enum _ecore_status_t 282104072Sjake */ 283104072Sjakeenum _ecore_status_t 284104072Sjakeecore_iov_single_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, 285104072Sjake struct ecore_ptt *p_ptt, 286104072Sjake u16 rel_vf_id); 287104072Sjake 288104072Sjake/** 289104072Sjake * @brief Update the bulletin with link information. Notice this does NOT 290104072Sjake * send a bulletin update, only updates the PF's bulletin. 291104072Sjake * 292104072Sjake * @param p_hwfn 29385586Sjake * @param p_vf 29485586Sjake * @param params - the link params to use for the VF link configuration 29585586Sjake * @param link - the link output to use for the VF link configuration 29685586Sjake * @param p_caps - the link default capabilities. 29785586Sjake */ 29885586Sjakevoid ecore_iov_set_link(struct ecore_hwfn *p_hwfn, 29998635Smux u16 vfid, 30085586Sjake struct ecore_mcp_link_params *params, 30185586Sjake struct ecore_mcp_link_state *link, 30285586Sjake struct ecore_mcp_link_capabilities *p_caps); 30385586Sjake 30485586Sjake/** 30585586Sjake * @brief Returns link information as perceived by VF. 30685586Sjake * 30785586Sjake * @param p_hwfn 30885586Sjake * @param p_vf 30985586Sjake * @param p_params - the link params visible to vf. 31085586Sjake * @param p_link - the link state visible to vf. 31185586Sjake * @param p_caps - the link default capabilities visible to vf. 31285586Sjake */ 31380708Sjakevoid ecore_iov_get_link(struct ecore_hwfn *p_hwfn, 31480708Sjake u16 vfid, 315105469Smarcel struct ecore_mcp_link_params *params, 316105469Smarcel struct ecore_mcp_link_state *link, 317105469Smarcel struct ecore_mcp_link_capabilities *p_caps); 318105469Smarcel 319105469Smarcel/** 320105469Smarcel * @brief return if the VF is pending FLR 321105469Smarcel * 322105469Smarcel * @param p_hwfn 323105469Smarcel * @param rel_vf_id 324105469Smarcel * 325105469Smarcel * @return bool 326105469Smarcel */ 327105469Smarcelbool ecore_iov_is_vf_pending_flr(struct ecore_hwfn *p_hwfn, 328105469Smarcel u16 rel_vf_id); 329#endif 330 331/** 332 * @brief Check if given VF ID @vfid is valid 333 * w.r.t. @b_enabled_only value 334 * if b_enabled_only = true - only enabled VF id is valid 335 * else any VF id less than max_vfs is valid 336 * 337 * @param p_hwfn 338 * @param rel_vf_id - Relative VF ID 339 * @param b_enabled_only - consider only enabled VF 340 * @param b_non_malicious - true iff we want to validate vf isn't malicious. 341 * 342 * @return bool - true for valid VF ID 343 */ 344bool ecore_iov_is_valid_vfid(struct ecore_hwfn *p_hwfn, 345 int rel_vf_id, 346 bool b_enabled_only, bool b_non_malicious); 347 348#ifndef LINUX_REMOVE 349/** 350 * @brief Get VF's public info structure 351 * 352 * @param p_hwfn 353 * @param vfid - Relative VF ID 354 * @param b_enabled_only - false if want to access even if vf is disabled 355 * 356 * @return struct ecore_public_vf_info * 357 */ 358struct ecore_public_vf_info* 359ecore_iov_get_public_vf_info(struct ecore_hwfn *p_hwfn, 360 u16 vfid, bool b_enabled_only); 361 362/** 363 * @brief fills a bitmask of all VFs which have pending unhandled 364 * messages. 365 * 366 * @param p_hwfn 367 */ 368void ecore_iov_pf_get_pending_events(struct ecore_hwfn *p_hwfn, 369 u64 *events); 370 371/** 372 * @brief Copy VF's message to PF's buffer 373 * 374 * @param p_hwfn 375 * @param ptt 376 * @param vfid 377 * 378 * @return enum _ecore_status_t 379 */ 380enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn *p_hwfn, 381 struct ecore_ptt *ptt, 382 int vfid); 383/** 384 * @brief Set forced MAC address in PFs copy of bulletin board 385 * and configures FW/HW to support the configuration. 386 * 387 * @param p_hwfn 388 * @param mac 389 * @param vfid 390 */ 391void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn, 392 u8 *mac, int vfid); 393 394/** 395 * @brief Set MAC address in PFs copy of bulletin board without 396 * configuring FW/HW. 397 * 398 * @param p_hwfn 399 * @param mac 400 * @param vfid 401 */ 402enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn, 403 u8 *mac, int vfid); 404 405/** 406 * @brief Set default behaviour of VF in case no vlans are configured for it 407 * whether to accept only untagged traffic or all. 408 * Must be called prior to the VF vport-start. 409 * 410 * @param p_hwfn 411 * @param b_untagged_only 412 * @param vfid 413 * 414 * @return ECORE_SUCCESS if configuration would stick. 415 */ 416enum _ecore_status_t 417ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn *p_hwfn, 418 bool b_untagged_only, 419 int vfid); 420 421/** 422 * @brief Get VFs opaque fid. 423 * 424 * @param p_hwfn 425 * @param vfid 426 * @param opaque_fid 427 */ 428void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid, 429 u16 *opaque_fid); 430 431/** 432 * @brief Set forced VLAN [pvid] in PFs copy of bulletin board 433 * and configures FW/HW to support the configuration. 434 * Setting of pvid 0 would clear the feature. 435 * @param p_hwfn 436 * @param pvid 437 * @param vfid 438 */ 439void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn, 440 u16 pvid, int vfid); 441 442/** 443 * @brief Check if VF has VPORT instance. This can be used 444 * to check if VPORT is active. 445 * 446 * @param p_hwfn 447 */ 448bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid); 449 450/** 451 * @brief PF posts the bulletin to the VF 452 * 453 * @param p_hwfn 454 * @param p_vf 455 * @param p_ptt 456 * 457 * @return enum _ecore_status_t 458 */ 459enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn, 460 int vfid, 461 struct ecore_ptt *p_ptt); 462 463/** 464 * @brief Check if given VF (@vfid) is marked as stopped 465 * 466 * @param p_hwfn 467 * @param vfid 468 * 469 * @return bool : true if stopped 470 */ 471bool ecore_iov_is_vf_stopped(struct ecore_hwfn *p_hwfn, int vfid); 472 473/** 474 * @brief Configure VF anti spoofing 475 * 476 * @param p_hwfn 477 * @param vfid 478 * @param val - spoofchk value - true/false 479 * 480 * @return enum _ecore_status_t 481 */ 482enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn *p_hwfn, 483 int vfid, bool val); 484 485/** 486 * @brief Get VF's configured spoof value. 487 * 488 * @param p_hwfn 489 * @param vfid 490 * 491 * @return bool - spoofchk value - true/false 492 */ 493bool ecore_iov_spoofchk_get(struct ecore_hwfn *p_hwfn, int vfid); 494 495/** 496 * @brief Check for SRIOV sanity by PF. 497 * 498 * @param p_hwfn 499 * @param vfid 500 * 501 * @return bool - true if sanity checks passes, else false 502 */ 503bool ecore_iov_pf_sanity_check(struct ecore_hwfn *p_hwfn, int vfid); 504 505/** 506 * @brief Get the num of VF chains. 507 * 508 * @param p_hwfn 509 * 510 * @return u8 511 */ 512u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn *p_hwfn); 513 514/** 515 * @brief Get vf request mailbox params 516 * 517 * @param p_hwfn 518 * @param rel_vf_id 519 * @param pp_req_virt_addr 520 * @param p_req_virt_size 521 */ 522void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn *p_hwfn, 523 u16 rel_vf_id, 524 void **pp_req_virt_addr, 525 u16 *p_req_virt_size); 526 527/** 528 * @brief Get vf mailbox params 529 * 530 * @param p_hwfn 531 * @param rel_vf_id 532 * @param pp_reply_virt_addr 533 * @param p_reply_virt_size 534 */ 535void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn *p_hwfn, 536 u16 rel_vf_id, 537 void **pp_reply_virt_addr, 538 u16 *p_reply_virt_size); 539 540/** 541 * @brief Validate if the given length is a valid vfpf message 542 * length 543 * 544 * @param length 545 * 546 * @return bool 547 */ 548bool ecore_iov_is_valid_vfpf_msg_length(u32 length); 549 550/** 551 * @brief Return the max pfvf message length 552 * 553 * @return u32 554 */ 555u32 ecore_iov_pfvf_msg_length(void); 556 557/** 558 * @brief Returns forced MAC address if one is configured 559 * 560 * @parm p_hwfn 561 * @parm rel_vf_id 562 * 563 * @return OSAL_NULL if mac isn't forced; Otherwise, returns MAC. 564 */ 565u8 *ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn *p_hwfn, 566 u16 rel_vf_id); 567 568/** 569 * @brief Returns pvid if one is configured 570 * 571 * @parm p_hwfn 572 * @parm rel_vf_id 573 * 574 * @return 0 if no pvid is configured, otherwise the pvid. 575 */ 576u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn *p_hwfn, 577 u16 rel_vf_id); 578/** 579 * @brief Configure VFs tx rate 580 * 581 * @param p_hwfn 582 * @param p_ptt 583 * @param vfid 584 * @param val - tx rate value in Mb/sec. 585 * 586 * @return enum _ecore_status_t 587 */ 588enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn *p_hwfn, 589 struct ecore_ptt *p_ptt, 590 int vfid, int val); 591 592/** 593 * @brief - Retrieves the statistics associated with a VF 594 * 595 * @param p_hwfn 596 * @param p_ptt 597 * @param vfid 598 * @param p_stats - this will be filled with the VF statistics 599 * 600 * @return ECORE_SUCCESS iff statistics were retrieved. Error otherwise. 601 */ 602enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn *p_hwfn, 603 struct ecore_ptt *p_ptt, 604 int vfid, 605 struct ecore_eth_stats *p_stats); 606 607/** 608 * @brief - Retrieves num of rxqs chains 609 * 610 * @param p_hwfn 611 * @param rel_vf_id 612 * 613 * @return num of rxqs chains. 614 */ 615u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn *p_hwfn, 616 u16 rel_vf_id); 617 618/** 619 * @brief - Retrieves num of active rxqs chains 620 * 621 * @param p_hwfn 622 * @param rel_vf_id 623 * 624 * @return 625 */ 626u8 ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn *p_hwfn, 627 u16 rel_vf_id); 628 629/** 630 * @brief - Retrieves ctx pointer 631 * 632 * @param p_hwfn 633 * @param rel_vf_id 634 * 635 * @return 636 */ 637void *ecore_iov_get_vf_ctx(struct ecore_hwfn *p_hwfn, 638 u16 rel_vf_id); 639 640/** 641 * @brief - Retrieves VF`s num sbs 642 * 643 * @param p_hwfn 644 * @param rel_vf_id 645 * 646 * @return 647 */ 648u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn *p_hwfn, 649 u16 rel_vf_id); 650 651/** 652 * @brief - Returm true if VF is waiting for acquire 653 * 654 * @param p_hwfn 655 * @param rel_vf_id 656 * 657 * @return 658 */ 659bool ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn *p_hwfn, 660 u16 rel_vf_id); 661 662/** 663 * @brief - Returm true if VF is acquired but not initialized 664 * 665 * @param p_hwfn 666 * @param rel_vf_id 667 * 668 * @return 669 */ 670bool ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn *p_hwfn, 671 u16 rel_vf_id); 672 673/** 674 * @brief - Returm true if VF is acquired and initialized 675 * 676 * @param p_hwfn 677 * @param rel_vf_id 678 * 679 * @return 680 */ 681bool ecore_iov_is_vf_initialized(struct ecore_hwfn *p_hwfn, 682 u16 rel_vf_id); 683 684/** 685 * @brief - Returm true if VF has started in FW 686 * 687 * @param p_hwfn 688 * @param rel_vf_id 689 * 690 * @return 691 */ 692bool ecore_iov_is_vf_started(struct ecore_hwfn *p_hwfn, 693 u16 rel_vf_id); 694 695/** 696 * @brief - Get VF's vport min rate configured. 697 * @param p_hwfn 698 * @param rel_vf_id 699 * 700 * @return - rate in Mbps 701 */ 702int ecore_iov_get_vf_min_rate(struct ecore_hwfn *p_hwfn, int vfid); 703 704/** 705 * @brief - Configure min rate for VF's vport. 706 * @param p_dev 707 * @param vfid 708 * @param - rate in Mbps 709 * 710 * @return 711 */ 712enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev *p_dev, 713 int vfid, u32 rate); 714 715#endif 716 717/** 718 * @brief ecore_pf_configure_vf_queue_coalesce - PF configure coalesce parameters 719 * of VFs for Rx and Tx queue. 720 * While the API allows setting coalescing per-qid, all queues sharing a SB 721 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff] 722 * otherwise configuration would break. 723 * 724 * @param p_hwfn 725 * @param rx_coal - Rx Coalesce value in micro seconds. 726 * @param tx_coal - TX Coalesce value in micro seconds. 727 * @param vf_id 728 * @param qid 729 * 730 * @return int 731 **/ 732enum _ecore_status_t 733ecore_iov_pf_configure_vf_queue_coalesce(struct ecore_hwfn *p_hwfn, 734 u16 rx_coal, u16 tx_coal, 735 u16 vf_id, u16 qid); 736 737/** 738 * @brief - Given a VF index, return index of next [including that] active VF. 739 * 740 * @param p_hwfn 741 * @param rel_vf_id 742 * 743 * @return MAX_NUM_VFS_E4 in case no further active VFs, otherwise index. 744 */ 745u16 ecore_iov_get_next_active_vf(struct ecore_hwfn *p_hwfn, u16 rel_vf_id); 746void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn, int vfid, 747 u16 vxlan_port, u16 geneve_port); 748 749#ifdef CONFIG_ECORE_SW_CHANNEL 750/** 751 * @brief Set whether PF should communicate with VF using SW/HW channel 752 * Needs to be called for an enabled VF before acquire is over 753 * [latest good point for doing that is OSAL_IOV_VF_ACQUIRE()] 754 * 755 * @param p_hwfn 756 * @param vfid - relative vf index 757 * @param b_is_hw - true iff PF is to use HW channel for communication 758 */ 759void ecore_iov_set_vf_hw_channel(struct ecore_hwfn *p_hwfn, int vfid, 760 bool b_is_hw); 761#endif 762#else 763#ifndef LINUX_REMOVE 764static OSAL_INLINE void ecore_iov_set_vfs_to_disable(struct ecore_dev OSAL_UNUSED *p_dev, u8 OSAL_UNUSED to_disable) {} 765static OSAL_INLINE void ecore_iov_set_vf_to_disable(struct ecore_dev OSAL_UNUSED *p_dev, u16 OSAL_UNUSED rel_vf_id, u8 OSAL_UNUSED to_disable) {} 766static OSAL_INLINE enum _ecore_status_t ecore_iov_init_hw_for_vf(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, struct ecore_iov_vf_init_params OSAL_UNUSED *p_params) {return ECORE_INVAL;} 767static OSAL_INLINE void ecore_iov_process_mbx_req(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, int OSAL_UNUSED vfid) {} 768static OSAL_INLINE enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, u16 OSAL_UNUSED rel_vf_id) {return ECORE_SUCCESS;} 769static OSAL_INLINE enum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED vf_id, OSAL_UNUSED void *ctx) {return ECORE_INVAL;} 770static OSAL_INLINE enum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt) {return ECORE_INVAL;} 771static OSAL_INLINE enum _ecore_status_t ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, u16 OSAL_UNUSED rel_vf_id) {return ECORE_INVAL;} 772static OSAL_INLINE void ecore_iov_set_link(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED vfid, struct ecore_mcp_link_params OSAL_UNUSED *params, struct ecore_mcp_link_state OSAL_UNUSED *link, struct ecore_mcp_link_capabilities OSAL_UNUSED *p_caps) {} 773static OSAL_INLINE void ecore_iov_get_link(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED vfid, struct ecore_mcp_link_params OSAL_UNUSED *params, struct ecore_mcp_link_state OSAL_UNUSED *link, struct ecore_mcp_link_capabilities OSAL_UNUSED *p_caps) {} 774static OSAL_INLINE bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 775#endif 776static OSAL_INLINE bool 777ecore_iov_is_valid_vfid(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED rel_vf_id, 778 bool OSAL_UNUSED b_enabled_only, 779 bool OSAL_UNUSED b_non_malicious) 780{ 781 return false; 782} 783#ifndef LINUX_REMOVE 784static OSAL_INLINE struct ecore_public_vf_info* ecore_iov_get_public_vf_info(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED vfid, bool OSAL_UNUSED b_enabled_only) {return OSAL_NULL;} 785static OSAL_INLINE void ecore_iov_pf_add_pending_events(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED vfid) {} 786static OSAL_INLINE void ecore_iov_pf_get_and_clear_pending_events(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u64 OSAL_UNUSED *events) {} 787static OSAL_INLINE enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *ptt, int OSAL_UNUSED vfid) {return ECORE_INVAL;} 788static OSAL_INLINE void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac, int OSAL_UNUSED vfid) {} 789static OSAL_INLINE enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac, OSAL_UNUSED int vfid) {return ECORE_INVAL;} 790static OSAL_INLINE enum _ecore_status_t ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn OSAL_UNUSED *p_hwfn, bool OSAL_UNUSED b_untagged_only, int OSAL_UNUSED vfid) {return ECORE_INVAL;} 791static OSAL_INLINE void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid, u16 OSAL_UNUSED *opaque_fid) {} 792static OSAL_INLINE void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn OSAL_UNUSED p_hwfn, u16 OSAL_UNUSED pvid, int OSAL_UNUSED vfid) {} 793 794static OSAL_INLINE bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 795static OSAL_INLINE enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid, struct ecore_ptt OSAL_UNUSED *p_ptt) {return ECORE_INVAL;} 796static OSAL_INLINE bool ecore_iov_is_vf_stopped(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 797static OSAL_INLINE enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid, bool OSAL_UNUSED val) {return ECORE_INVAL;} 798static OSAL_INLINE bool ecore_iov_spoofchk_get(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 799static OSAL_INLINE bool ecore_iov_pf_sanity_check(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 800static OSAL_INLINE u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return 0;} 801static OSAL_INLINE void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id, void OSAL_UNUSED **pp_req_virt_addr, u16 OSAL_UNUSED *p_req_virt_size) {} 802static OSAL_INLINE void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id, void OSAL_UNUSED **pp_reply_virt_addr, u16 OSAL_UNUSED *p_reply_virt_size) {} 803static OSAL_INLINE bool ecore_iov_is_valid_vfpf_msg_length(u32 OSAL_UNUSED length) {return false;} 804static OSAL_INLINE u32 ecore_iov_pfvf_msg_length(void) {return 0;} 805static OSAL_INLINE u8 *ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return OSAL_NULL;} 806static OSAL_INLINE u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 807static OSAL_INLINE enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, int OSAL_UNUSED vfid, int OSAL_UNUSED val) { return ECORE_INVAL; } 808static OSAL_INLINE enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_ptt OSAL_UNUSED *p_ptt, int OSAL_UNUSED vfid, struct ecore_eth_stats OSAL_UNUSED *p_stats) { return ECORE_INVAL; } 809 810static OSAL_INLINE u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 811static OSAL_INLINE u8 ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 812static OSAL_INLINE void *ecore_iov_get_vf_ctx(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return OSAL_NULL;} 813static OSAL_INLINE u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 814static OSAL_INLINE bool ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 815static OSAL_INLINE bool ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 816static OSAL_INLINE bool ecore_iov_is_vf_initialized(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 817static OSAL_INLINE int ecore_iov_get_vf_min_rate(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) { return 0; } 818static OSAL_INLINE enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev OSAL_UNUSED *p_dev, int OSAL_UNUSED vfid, OSAL_UNUSED u32 rate) { return ECORE_INVAL; } 819#endif 820static OSAL_INLINE void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid, u16 OSAL_UNUSED vxlan_port, u16 OSAL_UNUSED geneve_port) { return; } 821static OSAL_INLINE u16 ecore_iov_get_next_active_vf(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) { return MAX_NUM_VFS_E4; } 822 823#ifdef CONFIG_ECORE_SW_CHANNEL 824static OSAL_INLINE void 825ecore_iov_set_vf_hw_channel(struct ecore_hwfn OSAL_UNUSED *p_hwfn, 826 int OSAL_UNUSED vfid, bool OSAL_UNUSED b_is_hw) {} 827#endif 828#endif 829 830#define ecore_for_each_vf(_p_hwfn, _i) \ 831 for (_i = ecore_iov_get_next_active_vf(_p_hwfn, 0); \ 832 _i < MAX_NUM_VFS_E4; \ 833 _i = ecore_iov_get_next_active_vf(_p_hwfn, _i + 1)) 834 835#endif 836