1 /* 2 * Copyright (c) 2017-2018 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 * 27 * $FreeBSD$ 28 * 29 */ 30 31 #ifndef __ECORE_SRIOV_API_H__ 32 #define __ECORE_SRIOV_API_H__ 33 34 #include "common_hsi.h" 35 #include "ecore_status.h" 36 37 #define ECORE_ETH_VF_NUM_MAC_FILTERS 1 38 #define ECORE_ETH_VF_NUM_VLAN_FILTERS 2 39 #define ECORE_VF_ARRAY_LENGTH (3) 40 41 #define IS_VF(p_dev) ((p_dev)->b_is_vf) 42 #define IS_PF(p_dev) (!((p_dev)->b_is_vf)) 43 #ifdef CONFIG_ECORE_SRIOV 44 #define IS_PF_SRIOV(p_hwfn) (!!((p_hwfn)->p_dev->p_iov_info)) 45 #else 46 #define IS_PF_SRIOV(p_hwfn) (0) 47 #endif 48 #define IS_PF_SRIOV_ALLOC(p_hwfn) (!!((p_hwfn)->pf_iov_info)) 49 #define IS_PF_PDA(p_hwfn) 0 /* @@TBD Michalk */ 50 51 /* @@@ TBD MichalK - what should this number be*/ 52 #define ECORE_MAX_VF_CHAINS_PER_PF 16 53 54 /* vport update extended feature tlvs flags */ 55 enum ecore_iov_vport_update_flag { 56 ECORE_IOV_VP_UPDATE_ACTIVATE = 0, 57 ECORE_IOV_VP_UPDATE_VLAN_STRIP = 1, 58 ECORE_IOV_VP_UPDATE_TX_SWITCH = 2, 59 ECORE_IOV_VP_UPDATE_MCAST = 3, 60 ECORE_IOV_VP_UPDATE_ACCEPT_PARAM = 4, 61 ECORE_IOV_VP_UPDATE_RSS = 5, 62 ECORE_IOV_VP_UPDATE_ACCEPT_ANY_VLAN = 6, 63 ECORE_IOV_VP_UPDATE_SGE_TPA = 7, 64 ECORE_IOV_VP_UPDATE_MAX = 8, 65 }; 66 67 /*PF to VF STATUS is part of vfpf-channel API 68 and must be forward compatible */ 69 enum ecore_iov_pf_to_vf_status { 70 PFVF_STATUS_WAITING = 0, 71 PFVF_STATUS_SUCCESS, 72 PFVF_STATUS_FAILURE, 73 PFVF_STATUS_NOT_SUPPORTED, 74 PFVF_STATUS_NO_RESOURCE, 75 PFVF_STATUS_FORCED, 76 PFVF_STATUS_MALICIOUS, 77 }; 78 79 struct ecore_mcp_link_params; 80 struct ecore_mcp_link_state; 81 struct ecore_mcp_link_capabilities; 82 83 /* These defines are used by the hw-channel; should never change order */ 84 #define VFPF_ACQUIRE_OS_LINUX (0) 85 #define VFPF_ACQUIRE_OS_WINDOWS (1) 86 #define VFPF_ACQUIRE_OS_ESX (2) 87 #define VFPF_ACQUIRE_OS_SOLARIS (3) 88 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4) 89 90 struct ecore_vf_acquire_sw_info { 91 u32 driver_version; 92 u8 os_type; 93 }; 94 95 struct ecore_public_vf_info { 96 /* These copies will later be reflected in the bulletin board, 97 * but this copy should be newer. 98 */ 99 u8 forced_mac[ETH_ALEN]; 100 u16 forced_vlan; 101 }; 102 103 struct ecore_iov_vf_init_params { 104 u16 rel_vf_id; 105 106 /* Number of requested Queues; Currently, don't support different 107 * number of Rx/Tx queues. 108 */ 109 /* TODO - remove this limitation */ 110 u16 num_queues; 111 112 /* Allow the client to choose which qzones to use for Rx/Tx, 113 * and which queue_base to use for Tx queues on a per-queue basis. 114 * Notice values should be relative to the PF resources. 115 */ 116 u16 req_rx_queue[ECORE_MAX_VF_CHAINS_PER_PF]; 117 u16 req_tx_queue[ECORE_MAX_VF_CHAINS_PER_PF]; 118 119 u8 vport_id; 120 121 /* Should be set in case RSS is going to be used for VF */ 122 u8 rss_eng_id; 123 }; 124 125 #ifdef CONFIG_ECORE_SW_CHANNEL 126 /* This is SW channel related only... */ 127 enum mbx_state { 128 VF_PF_UNKNOWN_STATE = 0, 129 VF_PF_WAIT_FOR_START_REQUEST = 1, 130 VF_PF_WAIT_FOR_NEXT_CHUNK_OF_REQUEST = 2, 131 VF_PF_REQUEST_IN_PROCESSING = 3, 132 VF_PF_RESPONSE_READY = 4, 133 }; 134 135 struct ecore_iov_sw_mbx { 136 enum mbx_state mbx_state; 137 138 u32 request_size; 139 u32 request_offset; 140 141 u32 response_size; 142 u32 response_offset; 143 }; 144 145 /** 146 * @brief Get the vf sw mailbox params 147 * 148 * @param p_hwfn 149 * @param rel_vf_id 150 * 151 * @return struct ecore_iov_sw_mbx* 152 */ 153 struct ecore_iov_sw_mbx* 154 ecore_iov_get_vf_sw_mbx(struct ecore_hwfn *p_hwfn, 155 u16 rel_vf_id); 156 #endif 157 158 /* This struct is part of ecore_dev and contains data relevant to all hwfns; 159 * Initialized only if SR-IOV cpabability is exposed in PCIe config space. 160 */ 161 struct ecore_hw_sriov_info { 162 /* standard SRIOV capability fields, mostly for debugging */ 163 int pos; /* capability position */ 164 int nres; /* number of resources */ 165 u32 cap; /* SR-IOV Capabilities */ 166 u16 ctrl; /* SR-IOV Control */ 167 u16 total_vfs; /* total VFs associated with the PF */ 168 u16 num_vfs; /* number of vfs that have been started */ 169 u16 initial_vfs; /* initial VFs associated with the PF */ 170 u16 nr_virtfn; /* number of VFs available */ 171 u16 offset; /* first VF Routing ID offset */ 172 u16 stride; /* following VF stride */ 173 u16 vf_device_id; /* VF device id */ 174 u32 pgsz; /* page size for BAR alignment */ 175 u8 link; /* Function Dependency Link */ 176 177 u32 first_vf_in_pf; 178 }; 179 180 #ifdef CONFIG_ECORE_SRIOV 181 #ifndef LINUX_REMOVE 182 /** 183 * @brief mark/clear all VFs before/after an incoming PCIe sriov 184 * disable. 185 * 186 * @param p_dev 187 * @param to_disable 188 */ 189 void ecore_iov_set_vfs_to_disable(struct ecore_dev *p_dev, 190 u8 to_disable); 191 192 /** 193 * @brief mark/clear chosen VF before/after an incoming PCIe 194 * sriov disable. 195 * 196 * @param p_dev 197 * @param rel_vf_id 198 * @param to_disable 199 */ 200 void ecore_iov_set_vf_to_disable(struct ecore_dev *p_dev, 201 u16 rel_vf_id, 202 u8 to_disable); 203 204 /** 205 * @brief ecore_iov_init_hw_for_vf - initialize the HW for 206 * enabling access of a VF. Also includes preparing the 207 * IGU for VF access. This needs to be called AFTER hw is 208 * initialized and BEFORE VF is loaded inside the VM. 209 * 210 * @param p_hwfn 211 * @param p_ptt 212 * @param p_params 213 * 214 * @return enum _ecore_status_t 215 */ 216 enum _ecore_status_t 217 ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn, 218 struct ecore_ptt *p_ptt, 219 struct ecore_iov_vf_init_params *p_params); 220 221 /** 222 * @brief ecore_iov_process_mbx_req - process a request received 223 * from the VF 224 * 225 * @param p_hwfn 226 * @param p_ptt 227 * @param vfid 228 */ 229 void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn, 230 struct ecore_ptt *p_ptt, 231 int vfid); 232 233 /** 234 * @brief ecore_iov_release_hw_for_vf - called once upper layer 235 * knows VF is done with - can release any resources 236 * allocated for VF at this point. this must be done once 237 * we know VF is no longer loaded in VM. 238 * 239 * @param p_hwfn 240 * @param p_ptt 241 * @param rel_vf_id 242 * 243 * @return enum _ecore_status_t 244 */ 245 enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn, 246 struct ecore_ptt *p_ptt, 247 u16 rel_vf_id); 248 249 /** 250 * @brief ecore_iov_set_vf_ctx - set a context for a given VF 251 * 252 * @param p_hwfn 253 * @param vf_id 254 * @param ctx 255 * 256 * @return enum _ecore_status_t 257 */ 258 enum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn *p_hwfn, 259 u16 vf_id, 260 void *ctx); 261 262 /** 263 * @brief FLR cleanup for all VFs 264 * 265 * @param p_hwfn 266 * @param p_ptt 267 * 268 * @return enum _ecore_status_t 269 */ 270 enum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, 271 struct ecore_ptt *p_ptt); 272 273 /** 274 * @brief FLR cleanup for single VF 275 * 276 * @param p_hwfn 277 * @param p_ptt 278 * @param rel_vf_id 279 * 280 * @return enum _ecore_status_t 281 */ 282 enum _ecore_status_t 283 ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, 284 struct ecore_ptt *p_ptt, 285 u16 rel_vf_id); 286 287 /** 288 * @brief Update the bulletin with link information. Notice this does NOT 289 * send a bulletin update, only updates the PF's bulletin. 290 * 291 * @param p_hwfn 292 * @param p_vf 293 * @param params - the link params to use for the VF link configuration 294 * @param link - the link output to use for the VF link configuration 295 * @param p_caps - the link default capabilities. 296 */ 297 void ecore_iov_set_link(struct ecore_hwfn *p_hwfn, 298 u16 vfid, 299 struct ecore_mcp_link_params *params, 300 struct ecore_mcp_link_state *link, 301 struct ecore_mcp_link_capabilities *p_caps); 302 303 /** 304 * @brief Returns link information as perceived by VF. 305 * 306 * @param p_hwfn 307 * @param p_vf 308 * @param p_params - the link params visible to vf. 309 * @param p_link - the link state visible to vf. 310 * @param p_caps - the link default capabilities visible to vf. 311 */ 312 void ecore_iov_get_link(struct ecore_hwfn *p_hwfn, 313 u16 vfid, 314 struct ecore_mcp_link_params *params, 315 struct ecore_mcp_link_state *link, 316 struct ecore_mcp_link_capabilities *p_caps); 317 318 /** 319 * @brief return if the VF is pending FLR 320 * 321 * @param p_hwfn 322 * @param rel_vf_id 323 * 324 * @return bool 325 */ 326 bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn *p_hwfn, 327 u16 rel_vf_id); 328 329 /** 330 * @brief Check if given VF ID @vfid is valid 331 * w.r.t. @b_enabled_only value 332 * if b_enabled_only = true - only enabled VF id is valid 333 * else any VF id less than max_vfs is valid 334 * 335 * @param p_hwfn 336 * @param rel_vf_id - Relative VF ID 337 * @param b_enabled_only - consider only enabled VF 338 * @param b_non_malicious - true iff we want to validate vf isn't malicious. 339 * 340 * @return bool - true for valid VF ID 341 */ 342 bool ecore_iov_is_valid_vfid(struct ecore_hwfn *p_hwfn, 343 int rel_vf_id, 344 bool b_enabled_only, bool b_non_malicious); 345 346 /** 347 * @brief Get VF's public info structure 348 * 349 * @param p_hwfn 350 * @param vfid - Relative VF ID 351 * @param b_enabled_only - false if want to access even if vf is disabled 352 * 353 * @return struct ecore_public_vf_info * 354 */ 355 struct ecore_public_vf_info* 356 ecore_iov_get_public_vf_info(struct ecore_hwfn *p_hwfn, 357 u16 vfid, bool b_enabled_only); 358 359 /** 360 * @brief fills a bitmask of all VFs which have pending unhandled 361 * messages. 362 * 363 * @param p_hwfn 364 */ 365 void ecore_iov_pf_get_pending_events(struct ecore_hwfn *p_hwfn, 366 u64 *events); 367 368 /** 369 * @brief Copy VF's message to PF's buffer 370 * 371 * @param p_hwfn 372 * @param ptt 373 * @param vfid 374 * 375 * @return enum _ecore_status_t 376 */ 377 enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn *p_hwfn, 378 struct ecore_ptt *ptt, 379 int vfid); 380 /** 381 * @brief Set forced MAC address in PFs copy of bulletin board 382 * and configures FW/HW to support the configuration. 383 * 384 * @param p_hwfn 385 * @param mac 386 * @param vfid 387 */ 388 void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn, 389 u8 *mac, int vfid); 390 391 /** 392 * @brief Set MAC address in PFs copy of bulletin board without 393 * configuring FW/HW. 394 * 395 * @param p_hwfn 396 * @param mac 397 * @param vfid 398 */ 399 enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn, 400 u8 *mac, int vfid); 401 402 /** 403 * @brief Set default behaviour of VF in case no vlans are configured for it 404 * whether to accept only untagged traffic or all. 405 * Must be called prior to the VF vport-start. 406 * 407 * @param p_hwfn 408 * @param b_untagged_only 409 * @param vfid 410 * 411 * @return ECORE_SUCCESS if configuration would stick. 412 */ 413 enum _ecore_status_t 414 ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn *p_hwfn, 415 bool b_untagged_only, 416 int vfid); 417 418 /** 419 * @brief Get VFs opaque fid. 420 * 421 * @param p_hwfn 422 * @param vfid 423 * @param opaque_fid 424 */ 425 void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid, 426 u16 *opaque_fid); 427 428 /** 429 * @brief Set forced VLAN [pvid] in PFs copy of bulletin board 430 * and configures FW/HW to support the configuration. 431 * Setting of pvid 0 would clear the feature. 432 * @param p_hwfn 433 * @param pvid 434 * @param vfid 435 */ 436 void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn, 437 u16 pvid, int vfid); 438 439 /** 440 * @brief Check if VF has VPORT instance. This can be used 441 * to check if VPORT is active. 442 * 443 * @param p_hwfn 444 */ 445 bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid); 446 447 /** 448 * @brief PF posts the bulletin to the VF 449 * 450 * @param p_hwfn 451 * @param p_vf 452 * @param p_ptt 453 * 454 * @return enum _ecore_status_t 455 */ 456 enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn, 457 int vfid, 458 struct ecore_ptt *p_ptt); 459 460 /** 461 * @brief Check if given VF (@vfid) is marked as stopped 462 * 463 * @param p_hwfn 464 * @param vfid 465 * 466 * @return bool : true if stopped 467 */ 468 bool ecore_iov_is_vf_stopped(struct ecore_hwfn *p_hwfn, int vfid); 469 470 /** 471 * @brief Configure VF anti spoofing 472 * 473 * @param p_hwfn 474 * @param vfid 475 * @param val - spoofchk value - true/false 476 * 477 * @return enum _ecore_status_t 478 */ 479 enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn *p_hwfn, 480 int vfid, bool val); 481 482 /** 483 * @brief Get VF's configured spoof value. 484 * 485 * @param p_hwfn 486 * @param vfid 487 * 488 * @return bool - spoofchk value - true/false 489 */ 490 bool ecore_iov_spoofchk_get(struct ecore_hwfn *p_hwfn, int vfid); 491 492 /** 493 * @brief Check for SRIOV sanity by PF. 494 * 495 * @param p_hwfn 496 * @param vfid 497 * 498 * @return bool - true if sanity checks passes, else false 499 */ 500 bool ecore_iov_pf_sanity_check(struct ecore_hwfn *p_hwfn, int vfid); 501 502 /** 503 * @brief Get the num of VF chains. 504 * 505 * @param p_hwfn 506 * 507 * @return u8 508 */ 509 u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn *p_hwfn); 510 511 /** 512 * @brief Get vf request mailbox params 513 * 514 * @param p_hwfn 515 * @param rel_vf_id 516 * @param pp_req_virt_addr 517 * @param p_req_virt_size 518 */ 519 void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn *p_hwfn, 520 u16 rel_vf_id, 521 void **pp_req_virt_addr, 522 u16 *p_req_virt_size); 523 524 /** 525 * @brief Get vf mailbox params 526 * 527 * @param p_hwfn 528 * @param rel_vf_id 529 * @param pp_reply_virt_addr 530 * @param p_reply_virt_size 531 */ 532 void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn *p_hwfn, 533 u16 rel_vf_id, 534 void **pp_reply_virt_addr, 535 u16 *p_reply_virt_size); 536 537 /** 538 * @brief Validate if the given length is a valid vfpf message 539 * length 540 * 541 * @param length 542 * 543 * @return bool 544 */ 545 bool ecore_iov_is_valid_vfpf_msg_length(u32 length); 546 547 /** 548 * @brief Return the max pfvf message length 549 * 550 * @return u32 551 */ 552 u32 ecore_iov_pfvf_msg_length(void); 553 554 /** 555 * @brief Returns forced MAC address if one is configured 556 * 557 * @parm p_hwfn 558 * @parm rel_vf_id 559 * 560 * @return OSAL_NULL if mac isn't forced; Otherwise, returns MAC. 561 */ 562 u8 *ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn *p_hwfn, 563 u16 rel_vf_id); 564 565 /** 566 * @brief Returns pvid if one is configured 567 * 568 * @parm p_hwfn 569 * @parm rel_vf_id 570 * 571 * @return 0 if no pvid is configured, otherwise the pvid. 572 */ 573 u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn *p_hwfn, 574 u16 rel_vf_id); 575 /** 576 * @brief Configure VFs tx rate 577 * 578 * @param p_hwfn 579 * @param p_ptt 580 * @param vfid 581 * @param val - tx rate value in Mb/sec. 582 * 583 * @return enum _ecore_status_t 584 */ 585 enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn *p_hwfn, 586 struct ecore_ptt *p_ptt, 587 int vfid, int val); 588 589 /** 590 * @brief - Retrieves the statistics associated with a VF 591 * 592 * @param p_hwfn 593 * @param p_ptt 594 * @param vfid 595 * @param p_stats - this will be filled with the VF statistics 596 * 597 * @return ECORE_SUCCESS iff statistics were retrieved. Error otherwise. 598 */ 599 enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn *p_hwfn, 600 struct ecore_ptt *p_ptt, 601 int vfid, 602 struct ecore_eth_stats *p_stats); 603 604 /** 605 * @brief - Retrieves num of rxqs chains 606 * 607 * @param p_hwfn 608 * @param rel_vf_id 609 * 610 * @return num of rxqs chains. 611 */ 612 u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn *p_hwfn, 613 u16 rel_vf_id); 614 615 /** 616 * @brief - Retrieves num of active rxqs chains 617 * 618 * @param p_hwfn 619 * @param rel_vf_id 620 * 621 * @return 622 */ 623 u8 ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn *p_hwfn, 624 u16 rel_vf_id); 625 626 /** 627 * @brief - Retrieves ctx pointer 628 * 629 * @param p_hwfn 630 * @param rel_vf_id 631 * 632 * @return 633 */ 634 void *ecore_iov_get_vf_ctx(struct ecore_hwfn *p_hwfn, 635 u16 rel_vf_id); 636 637 /** 638 * @brief - Retrieves VF`s num sbs 639 * 640 * @param p_hwfn 641 * @param rel_vf_id 642 * 643 * @return 644 */ 645 u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn *p_hwfn, 646 u16 rel_vf_id); 647 648 /** 649 * @brief - Returm true if VF is waiting for acquire 650 * 651 * @param p_hwfn 652 * @param rel_vf_id 653 * 654 * @return 655 */ 656 bool ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn *p_hwfn, 657 u16 rel_vf_id); 658 659 /** 660 * @brief - Returm true if VF is acquired but not initialized 661 * 662 * @param p_hwfn 663 * @param rel_vf_id 664 * 665 * @return 666 */ 667 bool ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn *p_hwfn, 668 u16 rel_vf_id); 669 670 /** 671 * @brief - Returm true if VF is acquired and initialized 672 * 673 * @param p_hwfn 674 * @param rel_vf_id 675 * 676 * @return 677 */ 678 bool ecore_iov_is_vf_initialized(struct ecore_hwfn *p_hwfn, 679 u16 rel_vf_id); 680 681 /** 682 * @brief - Returm true if VF has started in FW 683 * 684 * @param p_hwfn 685 * @param rel_vf_id 686 * 687 * @return 688 */ 689 bool ecore_iov_is_vf_started(struct ecore_hwfn *p_hwfn, 690 u16 rel_vf_id); 691 692 /** 693 * @brief - Get VF's vport min rate configured. 694 * @param p_hwfn 695 * @param rel_vf_id 696 * 697 * @return - rate in Mbps 698 */ 699 int ecore_iov_get_vf_min_rate(struct ecore_hwfn *p_hwfn, int vfid); 700 701 /** 702 * @brief - Configure min rate for VF's vport. 703 * @param p_dev 704 * @param vfid 705 * @param - rate in Mbps 706 * 707 * @return 708 */ 709 enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev *p_dev, 710 int vfid, u32 rate); 711 712 #endif 713 714 /** 715 * @brief ecore_pf_configure_vf_queue_coalesce - PF configure coalesce parameters 716 * of VFs for Rx and Tx queue. 717 * While the API allows setting coalescing per-qid, all queues sharing a SB 718 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff] 719 * otherwise configuration would break. 720 * 721 * @param p_hwfn 722 * @param rx_coal - Rx Coalesce value in micro seconds. 723 * @param tx_coal - TX Coalesce value in micro seconds. 724 * @param vf_id 725 * @param qid 726 * 727 * @return int 728 **/ 729 enum _ecore_status_t 730 ecore_iov_pf_configure_vf_queue_coalesce(struct ecore_hwfn *p_hwfn, 731 u16 rx_coal, u16 tx_coal, 732 u16 vf_id, u16 qid); 733 734 /** 735 * @brief - Given a VF index, return index of next [including that] active VF. 736 * 737 * @param p_hwfn 738 * @param rel_vf_id 739 * 740 * @return MAX_NUM_VFS_E4 in case no further active VFs, otherwise index. 741 */ 742 u16 ecore_iov_get_next_active_vf(struct ecore_hwfn *p_hwfn, u16 rel_vf_id); 743 void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn, int vfid, 744 u16 vxlan_port, u16 geneve_port); 745 #else 746 #ifndef LINUX_REMOVE 747 static OSAL_INLINE void ecore_iov_set_vfs_to_disable(struct ecore_dev OSAL_UNUSED *p_dev, u8 OSAL_UNUSED to_disable) {} 748 static 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) {} 749 static 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;} 750 static 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) {} 751 static 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;} 752 static 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;} 753 static 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;} 754 static 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;} 755 static 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) {} 756 static 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) {} 757 static OSAL_INLINE bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 758 static OSAL_INLINE bool ecore_iov_is_valid_vfid(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED rel_vf_id, bool OSAL_UNUSED b_enabled_only) {return false;} 759 static 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;} 760 static OSAL_INLINE void ecore_iov_pf_add_pending_events(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED vfid) {} 761 static OSAL_INLINE void ecore_iov_pf_get_and_clear_pending_events(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u64 OSAL_UNUSED *events) {} 762 static 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;} 763 static OSAL_INLINE void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac, int OSAL_UNUSED vfid) {} 764 static 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;} 765 static 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;} 766 static 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) {} 767 static OSAL_INLINE void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn OSAL_UNUSED p_hwfn, u16 OSAL_UNUSED pvid, int OSAL_UNUSED vfid) {} 768 769 static OSAL_INLINE bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 770 static 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;} 771 static OSAL_INLINE bool ecore_iov_is_vf_stopped(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 772 static 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;} 773 static OSAL_INLINE bool ecore_iov_spoofchk_get(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 774 static OSAL_INLINE bool ecore_iov_pf_sanity_check(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) {return false;} 775 static OSAL_INLINE u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return 0;} 776 static 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) {} 777 static 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) {} 778 static OSAL_INLINE bool ecore_iov_is_valid_vfpf_msg_length(u32 OSAL_UNUSED length) {return false;} 779 static OSAL_INLINE u32 ecore_iov_pfvf_msg_length(void) {return 0;} 780 static 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;} 781 static OSAL_INLINE u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 782 static 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; } 783 static 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; } 784 785 static OSAL_INLINE u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 786 static 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;} 787 static OSAL_INLINE void *ecore_iov_get_vf_ctx(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return OSAL_NULL;} 788 static OSAL_INLINE u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return 0;} 789 static 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;} 790 static 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;} 791 static OSAL_INLINE bool ecore_iov_is_vf_initialized(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED rel_vf_id) {return false;} 792 static OSAL_INLINE int ecore_iov_get_vf_min_rate(struct ecore_hwfn OSAL_UNUSED *p_hwfn, int OSAL_UNUSED vfid) { return 0; } 793 static 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; } 794 #endif 795 static 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; } 796 static 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; } 797 #endif 798 799 #define ecore_for_each_vf(_p_hwfn, _i) \ 800 for (_i = ecore_iov_get_next_active_vf(_p_hwfn, 0); \ 801 _i < MAX_NUM_VFS_E4; \ 802 _i = ecore_iov_get_next_active_vf(_p_hwfn, _i + 1)) 803 804 #endif 805