Path: blob/main/sys/dev/bnxt/bnxt_en/bnxt_sriov.h
283101 views
#ifndef _BNXT_SRIOV_H_1#define _BNXT_SRIOV_H_23#include <sys/iov_schema.h>4#include <linux/pci.h>5#include <dev/pci/pci_iov.h>67#include "opt_global.h"8#include "bnxt.h"910/* macro definations */1112#define BNXT_MAX_VFS 413#define BNXT_HWRM_REQ_MAX_SIZE 12814#define BNXT_MAX_VF_CMD_FWD_PAGES 415#define BNXT_VF_QOS 0x116#define BNXT_VF_SPOOFCHK 0x217#define BNXT_VF_LINK_FORCED 0x418#define BNXT_VF_LINK_UP 0x819#define BNXT_VF_TRUST 0x1020#define BNXT_VLAN_VID_MASK 0x0fff2122#define BNXT_EXEC_FWD_RESP_SIZE_ERR(n) \23((offsetof(struct hwrm_exec_fwd_resp_input, encap_request) + n) >\24offsetof(struct hwrm_exec_fwd_resp_input, encap_resp_target_id))2526#define BNXT_VF_RESV_STRATEGY_MAXIMAL 027#define BNXT_VF_RESV_STRATEGY_MINIMAL 128#define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC 229#define FUNC_RESOURCE_QCAPS_RESP_FLAGS_MIN_GUARANTEED 0x1UL3031#define BNXT_SRIOV_LOCK_INIT(sc, _name) \32mtx_init(&(sc)->sriov_lock, _name, "sriov_lock", MTX_DEF | MTX_NOWITNESS)33#define BNXT_SRIOV_LOCK(sc) mtx_lock(&(sc)->sriov_lock)34#define BNXT_SRIOV_UNLOCK(sc) mtx_unlock(&(sc)->sriov_lock)35#define BNXT_SRIOV_LOCK_DESTROY(sc) \36do { \37if (mtx_initialized(&(sc)->sriov_lock)) \38mtx_destroy(&(sc)->sriov_lock); \39} while (0)404142/* structure declartions/definations */4344struct bnxt_softc;4546struct bnxt_vf_info {47uint8_t vfnum;48uint16_t fw_fid;49uint8_t mac_addr[ETHER_ADDR_LEN];50uint8_t vf_mac_addr[ETHER_ADDR_LEN];51uint32_t vlan;52uint32_t flags;53uint32_t func_qcfg_flags;54uint32_t min_tx_rate;55uint32_t max_tx_rate;56uint16_t min_tx_rings;57uint16_t max_tx_rings;58uint16_t min_rx_rings;59uint16_t max_rx_rings;60uint16_t min_cp_rings;61uint16_t max_cp_rings;62uint16_t min_rsscos_ctxs;63uint16_t max_rsscos_ctxs;64uint16_t min_stat_ctxs;65uint16_t max_stat_ctxs;66uint16_t min_ring_grps;67uint16_t max_hw_ring_grps;68uint16_t min_vnics;69uint16_t max_vnics;70uint16_t min_irqs;71uint16_t max_irqs;72uint16_t min_l2_ctxs;73uint16_t max_l2_ctxs;74void *hwrm_cmd_req_addr;75bus_addr_t hwrm_cmd_req_dma_addr;76struct iflib_dma_info hwrm_cmd_req;77uint16_t trusted;78bool spoofchk;79};8081struct bnxt_resc_map {82uint16_t *min_field;83uint16_t *max_field;84uint16_t hw_max;85uint16_t pf_alloc;86};8788/* function prototypes */8990void bnxt_sriov_attach(struct bnxt_softc *softc);91int bnxt_iov_init(if_ctx_t ctx, uint16_t num_vfs, const nvlist_t *params);92void bnxt_iov_uninit(if_ctx_t ctx);93int bnxt_iov_vf_add(if_ctx_t ctx, uint16_t vfnum, const nvlist_t *params);94int bnxt_hwrm_func_vf_resource_free(struct bnxt_softc *softc, int num_vfs);95void bnxt_free_vf_resources(struct bnxt_softc *softc);96int bnxt_create_trusted_vf_sysctls(struct bnxt_softc *softc, uint16_t num_vfs);97int bnxt_create_spoofchk_vf_sysctls(struct bnxt_softc *softc, uint16_t num_vfs);98bool bnxt_is_trusted_vf(struct bnxt_softc *bp, struct bnxt_vf_info *vf);99void bnxt_hwrm_exec_fwd_req(struct bnxt_softc *bp);100void bnxt_destroy_trusted_vf_sysctls(struct bnxt_softc *softc);101int bnxt_set_vf_trust(struct bnxt_softc *softc, int vf_id, bool trusted);102int bnxt_approve_mac(struct bnxt_softc *sc);103void bnxt_update_vf_mac(struct bnxt_softc *sc);104bool bnxt_promisc_ok(struct bnxt_softc *softc);105int bnxt_set_vf_spoofchk(struct bnxt_softc *sc, int vf_id, bool enable);106int bnxt_cfg_hw_sriov(struct bnxt_softc *softc, uint16_t *num_vfs, bool reset);107void bnxt_reenable_sriov(struct bnxt_softc *bp);108109110#endif /* _BNXT_SRIOV_H_ */111112113