18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/* QLogic qed NIC Driver
38c2ecf20Sopenharmony_ci * Copyright (c) 2015-2017  QLogic Corporation
48c2ecf20Sopenharmony_ci * Copyright (c) 2019-2020 Marvell International Ltd.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _QED_SRIOV_H
88c2ecf20Sopenharmony_ci#define _QED_SRIOV_H
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci#include "qed_vf.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define QED_ETH_VF_NUM_MAC_FILTERS 1
138c2ecf20Sopenharmony_ci#define QED_ETH_VF_NUM_VLAN_FILTERS 2
148c2ecf20Sopenharmony_ci#define QED_VF_ARRAY_LENGTH (3)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifdef CONFIG_QED_SRIOV
178c2ecf20Sopenharmony_ci#define IS_VF(cdev)             ((cdev)->b_is_vf)
188c2ecf20Sopenharmony_ci#define IS_PF(cdev)             (!((cdev)->b_is_vf))
198c2ecf20Sopenharmony_ci#define IS_PF_SRIOV(p_hwfn)     (!!((p_hwfn)->cdev->p_iov_info))
208c2ecf20Sopenharmony_ci#else
218c2ecf20Sopenharmony_ci#define IS_VF(cdev)             (0)
228c2ecf20Sopenharmony_ci#define IS_PF(cdev)             (1)
238c2ecf20Sopenharmony_ci#define IS_PF_SRIOV(p_hwfn)     (0)
248c2ecf20Sopenharmony_ci#endif
258c2ecf20Sopenharmony_ci#define IS_PF_SRIOV_ALLOC(p_hwfn)       (!!((p_hwfn)->pf_iov_info))
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define QED_MAX_VF_CHAINS_PER_PF 16
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define QED_ETH_MAX_VF_NUM_VLAN_FILTERS	\
308c2ecf20Sopenharmony_ci	(MAX_NUM_VFS * QED_ETH_VF_NUM_VLAN_FILTERS)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cienum qed_iov_vport_update_flag {
338c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_ACTIVATE,
348c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_VLAN_STRIP,
358c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_TX_SWITCH,
368c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_MCAST,
378c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_ACCEPT_PARAM,
388c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_RSS,
398c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_ACCEPT_ANY_VLAN,
408c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_SGE_TPA,
418c2ecf20Sopenharmony_ci	QED_IOV_VP_UPDATE_MAX,
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct qed_public_vf_info {
458c2ecf20Sopenharmony_ci	/* These copies will later be reflected in the bulletin board,
468c2ecf20Sopenharmony_ci	 * but this copy should be newer.
478c2ecf20Sopenharmony_ci	 */
488c2ecf20Sopenharmony_ci	u8 forced_mac[ETH_ALEN];
498c2ecf20Sopenharmony_ci	u16 forced_vlan;
508c2ecf20Sopenharmony_ci	u8 mac[ETH_ALEN];
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	/* IFLA_VF_LINK_STATE_<X> */
538c2ecf20Sopenharmony_ci	int link_state;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	/* Currently configured Tx rate in MB/sec. 0 if unconfigured */
568c2ecf20Sopenharmony_ci	int tx_rate;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	/* Trusted VFs can configure promiscuous mode.
598c2ecf20Sopenharmony_ci	 * Also store shadow promisc configuration if needed.
608c2ecf20Sopenharmony_ci	 */
618c2ecf20Sopenharmony_ci	bool is_trusted_configured;
628c2ecf20Sopenharmony_ci	bool is_trusted_request;
638c2ecf20Sopenharmony_ci	u8 rx_accept_mode;
648c2ecf20Sopenharmony_ci	u8 tx_accept_mode;
658c2ecf20Sopenharmony_ci	bool accept_any_vlan;
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct qed_iov_vf_init_params {
698c2ecf20Sopenharmony_ci	u16 rel_vf_id;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	/* Number of requested Queues; Currently, don't support different
728c2ecf20Sopenharmony_ci	 * number of Rx/Tx queues.
738c2ecf20Sopenharmony_ci	 */
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	u16 num_queues;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	/* Allow the client to choose which qzones to use for Rx/Tx,
788c2ecf20Sopenharmony_ci	 * and which queue_base to use for Tx queues on a per-queue basis.
798c2ecf20Sopenharmony_ci	 * Notice values should be relative to the PF resources.
808c2ecf20Sopenharmony_ci	 */
818c2ecf20Sopenharmony_ci	u16 req_rx_queue[QED_MAX_VF_CHAINS_PER_PF];
828c2ecf20Sopenharmony_ci	u16 req_tx_queue[QED_MAX_VF_CHAINS_PER_PF];
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/* This struct is part of qed_dev and contains data relevant to all hwfns;
868c2ecf20Sopenharmony_ci * Initialized only if SR-IOV cpabability is exposed in PCIe config space.
878c2ecf20Sopenharmony_ci */
888c2ecf20Sopenharmony_cistruct qed_hw_sriov_info {
898c2ecf20Sopenharmony_ci	int pos;		/* capability position */
908c2ecf20Sopenharmony_ci	int nres;		/* number of resources */
918c2ecf20Sopenharmony_ci	u32 cap;		/* SR-IOV Capabilities */
928c2ecf20Sopenharmony_ci	u16 ctrl;		/* SR-IOV Control */
938c2ecf20Sopenharmony_ci	u16 total_vfs;		/* total VFs associated with the PF */
948c2ecf20Sopenharmony_ci	u16 num_vfs;		/* number of vfs that have been started */
958c2ecf20Sopenharmony_ci	u16 initial_vfs;	/* initial VFs associated with the PF */
968c2ecf20Sopenharmony_ci	u16 nr_virtfn;		/* number of VFs available */
978c2ecf20Sopenharmony_ci	u16 offset;		/* first VF Routing ID offset */
988c2ecf20Sopenharmony_ci	u16 stride;		/* following VF stride */
998c2ecf20Sopenharmony_ci	u16 vf_device_id;	/* VF device id */
1008c2ecf20Sopenharmony_ci	u32 pgsz;		/* page size for BAR alignment */
1018c2ecf20Sopenharmony_ci	u8 link;		/* Function Dependency Link */
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	u32 first_vf_in_pf;
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* This mailbox is maintained per VF in its PF contains all information
1078c2ecf20Sopenharmony_ci * required for sending / receiving a message.
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_cistruct qed_iov_vf_mbx {
1108c2ecf20Sopenharmony_ci	union vfpf_tlvs *req_virt;
1118c2ecf20Sopenharmony_ci	dma_addr_t req_phys;
1128c2ecf20Sopenharmony_ci	union pfvf_tlvs *reply_virt;
1138c2ecf20Sopenharmony_ci	dma_addr_t reply_phys;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	/* Address in VF where a pending message is located */
1168c2ecf20Sopenharmony_ci	dma_addr_t pending_req;
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	/* Message from VF awaits handling */
1198c2ecf20Sopenharmony_ci	bool b_pending_msg;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	u8 *offset;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	/* saved VF request header */
1248c2ecf20Sopenharmony_ci	struct vfpf_first_tlv first_tlv;
1258c2ecf20Sopenharmony_ci};
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define QED_IOV_LEGACY_QID_RX (0)
1288c2ecf20Sopenharmony_ci#define QED_IOV_LEGACY_QID_TX (1)
1298c2ecf20Sopenharmony_ci#define QED_IOV_QID_INVALID (0xFE)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistruct qed_vf_queue_cid {
1328c2ecf20Sopenharmony_ci	bool b_is_tx;
1338c2ecf20Sopenharmony_ci	struct qed_queue_cid *p_cid;
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci/* Describes a qzone associated with the VF */
1378c2ecf20Sopenharmony_cistruct qed_vf_queue {
1388c2ecf20Sopenharmony_ci	u16 fw_rx_qid;
1398c2ecf20Sopenharmony_ci	u16 fw_tx_qid;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	struct qed_vf_queue_cid cids[MAX_QUEUES_PER_QZONE];
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cienum vf_state {
1458c2ecf20Sopenharmony_ci	VF_FREE = 0,		/* VF ready to be acquired holds no resc */
1468c2ecf20Sopenharmony_ci	VF_ACQUIRED,		/* VF, acquired, but not initalized */
1478c2ecf20Sopenharmony_ci	VF_ENABLED,		/* VF, Enabled */
1488c2ecf20Sopenharmony_ci	VF_RESET,		/* VF, FLR'd, pending cleanup */
1498c2ecf20Sopenharmony_ci	VF_STOPPED		/* VF, Stopped */
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistruct qed_vf_vlan_shadow {
1538c2ecf20Sopenharmony_ci	bool used;
1548c2ecf20Sopenharmony_ci	u16 vid;
1558c2ecf20Sopenharmony_ci};
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistruct qed_vf_shadow_config {
1588c2ecf20Sopenharmony_ci	/* Shadow copy of all guest vlans */
1598c2ecf20Sopenharmony_ci	struct qed_vf_vlan_shadow vlans[QED_ETH_VF_NUM_VLAN_FILTERS + 1];
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	/* Shadow copy of all configured MACs; Empty if forcing MACs */
1628c2ecf20Sopenharmony_ci	u8 macs[QED_ETH_VF_NUM_MAC_FILTERS][ETH_ALEN];
1638c2ecf20Sopenharmony_ci	u8 inner_vlan_removal;
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/* PFs maintain an array of this structure, per VF */
1678c2ecf20Sopenharmony_cistruct qed_vf_info {
1688c2ecf20Sopenharmony_ci	struct qed_iov_vf_mbx vf_mbx;
1698c2ecf20Sopenharmony_ci	enum vf_state state;
1708c2ecf20Sopenharmony_ci	bool b_init;
1718c2ecf20Sopenharmony_ci	bool b_malicious;
1728c2ecf20Sopenharmony_ci	u8 to_disable;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	struct qed_bulletin bulletin;
1758c2ecf20Sopenharmony_ci	dma_addr_t vf_bulletin;
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci	/* PF saves a copy of the last VF acquire message */
1788c2ecf20Sopenharmony_ci	struct vfpf_acquire_tlv acquire;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	u32 concrete_fid;
1818c2ecf20Sopenharmony_ci	u16 opaque_fid;
1828c2ecf20Sopenharmony_ci	u16 mtu;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	u8 vport_id;
1858c2ecf20Sopenharmony_ci	u8 relative_vf_id;
1868c2ecf20Sopenharmony_ci	u8 abs_vf_id;
1878c2ecf20Sopenharmony_ci#define QED_VF_ABS_ID(p_hwfn, p_vf)	(QED_PATH_ID(p_hwfn) ?		      \
1888c2ecf20Sopenharmony_ci					 (p_vf)->abs_vf_id + MAX_NUM_VFS_BB : \
1898c2ecf20Sopenharmony_ci					 (p_vf)->abs_vf_id)
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	u8 vport_instance;
1928c2ecf20Sopenharmony_ci	u8 num_rxqs;
1938c2ecf20Sopenharmony_ci	u8 num_txqs;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	u16 rx_coal;
1968c2ecf20Sopenharmony_ci	u16 tx_coal;
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	u8 num_sbs;
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	u8 num_mac_filters;
2018c2ecf20Sopenharmony_ci	u8 num_vlan_filters;
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	struct qed_vf_queue vf_queues[QED_MAX_VF_CHAINS_PER_PF];
2048c2ecf20Sopenharmony_ci	u16 igu_sbs[QED_MAX_VF_CHAINS_PER_PF];
2058c2ecf20Sopenharmony_ci	u8 num_active_rxqs;
2068c2ecf20Sopenharmony_ci	struct qed_public_vf_info p_vf_info;
2078c2ecf20Sopenharmony_ci	bool spoof_chk;
2088c2ecf20Sopenharmony_ci	bool req_spoofchk_val;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	/* Stores the configuration requested by VF */
2118c2ecf20Sopenharmony_ci	struct qed_vf_shadow_config shadow_config;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	/* A bitfield using bulletin's valid-map bits, used to indicate
2148c2ecf20Sopenharmony_ci	 * which of the bulletin board features have been configured.
2158c2ecf20Sopenharmony_ci	 */
2168c2ecf20Sopenharmony_ci	u64 configured_features;
2178c2ecf20Sopenharmony_ci#define QED_IOV_CONFIGURED_FEATURES_MASK        ((1 << MAC_ADDR_FORCED) | \
2188c2ecf20Sopenharmony_ci						 (1 << VLAN_ADDR_FORCED))
2198c2ecf20Sopenharmony_ci};
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci/* This structure is part of qed_hwfn and used only for PFs that have sriov
2228c2ecf20Sopenharmony_ci * capability enabled.
2238c2ecf20Sopenharmony_ci */
2248c2ecf20Sopenharmony_cistruct qed_pf_iov {
2258c2ecf20Sopenharmony_ci	struct qed_vf_info vfs_array[MAX_NUM_VFS];
2268c2ecf20Sopenharmony_ci	u64 pending_flr[QED_VF_ARRAY_LENGTH];
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci	/* Allocate message address continuosuly and split to each VF */
2298c2ecf20Sopenharmony_ci	void *mbx_msg_virt_addr;
2308c2ecf20Sopenharmony_ci	dma_addr_t mbx_msg_phys_addr;
2318c2ecf20Sopenharmony_ci	u32 mbx_msg_size;
2328c2ecf20Sopenharmony_ci	void *mbx_reply_virt_addr;
2338c2ecf20Sopenharmony_ci	dma_addr_t mbx_reply_phys_addr;
2348c2ecf20Sopenharmony_ci	u32 mbx_reply_size;
2358c2ecf20Sopenharmony_ci	void *p_bulletins;
2368c2ecf20Sopenharmony_ci	dma_addr_t bulletins_phys;
2378c2ecf20Sopenharmony_ci	u32 bulletins_size;
2388c2ecf20Sopenharmony_ci};
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_cienum qed_iov_wq_flag {
2418c2ecf20Sopenharmony_ci	QED_IOV_WQ_MSG_FLAG,
2428c2ecf20Sopenharmony_ci	QED_IOV_WQ_SET_UNICAST_FILTER_FLAG,
2438c2ecf20Sopenharmony_ci	QED_IOV_WQ_BULLETIN_UPDATE_FLAG,
2448c2ecf20Sopenharmony_ci	QED_IOV_WQ_STOP_WQ_FLAG,
2458c2ecf20Sopenharmony_ci	QED_IOV_WQ_FLR_FLAG,
2468c2ecf20Sopenharmony_ci	QED_IOV_WQ_TRUST_FLAG,
2478c2ecf20Sopenharmony_ci	QED_IOV_WQ_VF_FORCE_LINK_QUERY_FLAG,
2488c2ecf20Sopenharmony_ci};
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ciextern const struct qed_iov_hv_ops qed_iov_ops_pass;
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci#ifdef CONFIG_QED_SRIOV
2538c2ecf20Sopenharmony_ci/**
2548c2ecf20Sopenharmony_ci * @brief Check if given VF ID @vfid is valid
2558c2ecf20Sopenharmony_ci *        w.r.t. @b_enabled_only value
2568c2ecf20Sopenharmony_ci *        if b_enabled_only = true - only enabled VF id is valid
2578c2ecf20Sopenharmony_ci *        else any VF id less than max_vfs is valid
2588c2ecf20Sopenharmony_ci *
2598c2ecf20Sopenharmony_ci * @param p_hwfn
2608c2ecf20Sopenharmony_ci * @param rel_vf_id - Relative VF ID
2618c2ecf20Sopenharmony_ci * @param b_enabled_only - consider only enabled VF
2628c2ecf20Sopenharmony_ci * @param b_non_malicious - true iff we want to validate vf isn't malicious.
2638c2ecf20Sopenharmony_ci *
2648c2ecf20Sopenharmony_ci * @return bool - true for valid VF ID
2658c2ecf20Sopenharmony_ci */
2668c2ecf20Sopenharmony_cibool qed_iov_is_valid_vfid(struct qed_hwfn *p_hwfn,
2678c2ecf20Sopenharmony_ci			   int rel_vf_id,
2688c2ecf20Sopenharmony_ci			   bool b_enabled_only, bool b_non_malicious);
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci/**
2718c2ecf20Sopenharmony_ci * @brief - Given a VF index, return index of next [including that] active VF.
2728c2ecf20Sopenharmony_ci *
2738c2ecf20Sopenharmony_ci * @param p_hwfn
2748c2ecf20Sopenharmony_ci * @param rel_vf_id
2758c2ecf20Sopenharmony_ci *
2768c2ecf20Sopenharmony_ci * @return MAX_NUM_VFS in case no further active VFs, otherwise index.
2778c2ecf20Sopenharmony_ci */
2788c2ecf20Sopenharmony_ciu16 qed_iov_get_next_active_vf(struct qed_hwfn *p_hwfn, u16 rel_vf_id);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_civoid qed_iov_bulletin_set_udp_ports(struct qed_hwfn *p_hwfn,
2818c2ecf20Sopenharmony_ci				    int vfid, u16 vxlan_port, u16 geneve_port);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci/**
2848c2ecf20Sopenharmony_ci * @brief Read sriov related information and allocated resources
2858c2ecf20Sopenharmony_ci *  reads from configuration space, shmem, etc.
2868c2ecf20Sopenharmony_ci *
2878c2ecf20Sopenharmony_ci * @param p_hwfn
2888c2ecf20Sopenharmony_ci *
2898c2ecf20Sopenharmony_ci * @return int
2908c2ecf20Sopenharmony_ci */
2918c2ecf20Sopenharmony_ciint qed_iov_hw_info(struct qed_hwfn *p_hwfn);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/**
2948c2ecf20Sopenharmony_ci * @brief qed_add_tlv - place a given tlv on the tlv buffer at next offset
2958c2ecf20Sopenharmony_ci *
2968c2ecf20Sopenharmony_ci * @param p_hwfn
2978c2ecf20Sopenharmony_ci * @param p_iov
2988c2ecf20Sopenharmony_ci * @param type
2998c2ecf20Sopenharmony_ci * @param length
3008c2ecf20Sopenharmony_ci *
3018c2ecf20Sopenharmony_ci * @return pointer to the newly placed tlv
3028c2ecf20Sopenharmony_ci */
3038c2ecf20Sopenharmony_civoid *qed_add_tlv(struct qed_hwfn *p_hwfn, u8 **offset, u16 type, u16 length);
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci/**
3068c2ecf20Sopenharmony_ci * @brief list the types and lengths of the tlvs on the buffer
3078c2ecf20Sopenharmony_ci *
3088c2ecf20Sopenharmony_ci * @param p_hwfn
3098c2ecf20Sopenharmony_ci * @param tlvs_list
3108c2ecf20Sopenharmony_ci */
3118c2ecf20Sopenharmony_civoid qed_dp_tlv_list(struct qed_hwfn *p_hwfn, void *tlvs_list);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci/**
3148c2ecf20Sopenharmony_ci * @brief qed_iov_alloc - allocate sriov related resources
3158c2ecf20Sopenharmony_ci *
3168c2ecf20Sopenharmony_ci * @param p_hwfn
3178c2ecf20Sopenharmony_ci *
3188c2ecf20Sopenharmony_ci * @return int
3198c2ecf20Sopenharmony_ci */
3208c2ecf20Sopenharmony_ciint qed_iov_alloc(struct qed_hwfn *p_hwfn);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/**
3238c2ecf20Sopenharmony_ci * @brief qed_iov_setup - setup sriov related resources
3248c2ecf20Sopenharmony_ci *
3258c2ecf20Sopenharmony_ci * @param p_hwfn
3268c2ecf20Sopenharmony_ci */
3278c2ecf20Sopenharmony_civoid qed_iov_setup(struct qed_hwfn *p_hwfn);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/**
3308c2ecf20Sopenharmony_ci * @brief qed_iov_free - free sriov related resources
3318c2ecf20Sopenharmony_ci *
3328c2ecf20Sopenharmony_ci * @param p_hwfn
3338c2ecf20Sopenharmony_ci */
3348c2ecf20Sopenharmony_civoid qed_iov_free(struct qed_hwfn *p_hwfn);
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci/**
3378c2ecf20Sopenharmony_ci * @brief free sriov related memory that was allocated during hw_prepare
3388c2ecf20Sopenharmony_ci *
3398c2ecf20Sopenharmony_ci * @param cdev
3408c2ecf20Sopenharmony_ci */
3418c2ecf20Sopenharmony_civoid qed_iov_free_hw_info(struct qed_dev *cdev);
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci/**
3448c2ecf20Sopenharmony_ci * @brief Mark structs of vfs that have been FLR-ed.
3458c2ecf20Sopenharmony_ci *
3468c2ecf20Sopenharmony_ci * @param p_hwfn
3478c2ecf20Sopenharmony_ci * @param disabled_vfs - bitmask of all VFs on path that were FLRed
3488c2ecf20Sopenharmony_ci *
3498c2ecf20Sopenharmony_ci * @return true iff one of the PF's vfs got FLRed. false otherwise.
3508c2ecf20Sopenharmony_ci */
3518c2ecf20Sopenharmony_cibool qed_iov_mark_vf_flr(struct qed_hwfn *p_hwfn, u32 *disabled_vfs);
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci/**
3548c2ecf20Sopenharmony_ci * @brief Search extended TLVs in request/reply buffer.
3558c2ecf20Sopenharmony_ci *
3568c2ecf20Sopenharmony_ci * @param p_hwfn
3578c2ecf20Sopenharmony_ci * @param p_tlvs_list - Pointer to tlvs list
3588c2ecf20Sopenharmony_ci * @param req_type - Type of TLV
3598c2ecf20Sopenharmony_ci *
3608c2ecf20Sopenharmony_ci * @return pointer to tlv type if found, otherwise returns NULL.
3618c2ecf20Sopenharmony_ci */
3628c2ecf20Sopenharmony_civoid *qed_iov_search_list_tlvs(struct qed_hwfn *p_hwfn,
3638c2ecf20Sopenharmony_ci			       void *p_tlvs_list, u16 req_type);
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_civoid qed_iov_wq_stop(struct qed_dev *cdev, bool schedule_first);
3668c2ecf20Sopenharmony_ciint qed_iov_wq_start(struct qed_dev *cdev);
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_civoid qed_schedule_iov(struct qed_hwfn *hwfn, enum qed_iov_wq_flag flag);
3698c2ecf20Sopenharmony_civoid qed_vf_start_iov_wq(struct qed_dev *cdev);
3708c2ecf20Sopenharmony_ciint qed_sriov_disable(struct qed_dev *cdev, bool pci_enabled);
3718c2ecf20Sopenharmony_civoid qed_inform_vf_link_state(struct qed_hwfn *hwfn);
3728c2ecf20Sopenharmony_ci#else
3738c2ecf20Sopenharmony_cistatic inline bool
3748c2ecf20Sopenharmony_ciqed_iov_is_valid_vfid(struct qed_hwfn *p_hwfn,
3758c2ecf20Sopenharmony_ci		      int rel_vf_id, bool b_enabled_only, bool b_non_malicious)
3768c2ecf20Sopenharmony_ci{
3778c2ecf20Sopenharmony_ci	return false;
3788c2ecf20Sopenharmony_ci}
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_cistatic inline u16 qed_iov_get_next_active_vf(struct qed_hwfn *p_hwfn,
3818c2ecf20Sopenharmony_ci					     u16 rel_vf_id)
3828c2ecf20Sopenharmony_ci{
3838c2ecf20Sopenharmony_ci	return MAX_NUM_VFS;
3848c2ecf20Sopenharmony_ci}
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_cistatic inline void
3878c2ecf20Sopenharmony_ciqed_iov_bulletin_set_udp_ports(struct qed_hwfn *p_hwfn, int vfid,
3888c2ecf20Sopenharmony_ci			       u16 vxlan_port, u16 geneve_port)
3898c2ecf20Sopenharmony_ci{
3908c2ecf20Sopenharmony_ci}
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic inline int qed_iov_hw_info(struct qed_hwfn *p_hwfn)
3938c2ecf20Sopenharmony_ci{
3948c2ecf20Sopenharmony_ci	return 0;
3958c2ecf20Sopenharmony_ci}
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_cistatic inline int qed_iov_alloc(struct qed_hwfn *p_hwfn)
3988c2ecf20Sopenharmony_ci{
3998c2ecf20Sopenharmony_ci	return 0;
4008c2ecf20Sopenharmony_ci}
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_cistatic inline void qed_iov_setup(struct qed_hwfn *p_hwfn)
4038c2ecf20Sopenharmony_ci{
4048c2ecf20Sopenharmony_ci}
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_cistatic inline void qed_iov_free(struct qed_hwfn *p_hwfn)
4078c2ecf20Sopenharmony_ci{
4088c2ecf20Sopenharmony_ci}
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_cistatic inline void qed_iov_free_hw_info(struct qed_dev *cdev)
4118c2ecf20Sopenharmony_ci{
4128c2ecf20Sopenharmony_ci}
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_cistatic inline bool qed_iov_mark_vf_flr(struct qed_hwfn *p_hwfn,
4158c2ecf20Sopenharmony_ci				       u32 *disabled_vfs)
4168c2ecf20Sopenharmony_ci{
4178c2ecf20Sopenharmony_ci	return false;
4188c2ecf20Sopenharmony_ci}
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistatic inline void qed_iov_wq_stop(struct qed_dev *cdev, bool schedule_first)
4218c2ecf20Sopenharmony_ci{
4228c2ecf20Sopenharmony_ci}
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistatic inline int qed_iov_wq_start(struct qed_dev *cdev)
4258c2ecf20Sopenharmony_ci{
4268c2ecf20Sopenharmony_ci	return 0;
4278c2ecf20Sopenharmony_ci}
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_cistatic inline void qed_schedule_iov(struct qed_hwfn *hwfn,
4308c2ecf20Sopenharmony_ci				    enum qed_iov_wq_flag flag)
4318c2ecf20Sopenharmony_ci{
4328c2ecf20Sopenharmony_ci}
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_cistatic inline void qed_vf_start_iov_wq(struct qed_dev *cdev)
4358c2ecf20Sopenharmony_ci{
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic inline int qed_sriov_disable(struct qed_dev *cdev, bool pci_enabled)
4398c2ecf20Sopenharmony_ci{
4408c2ecf20Sopenharmony_ci	return 0;
4418c2ecf20Sopenharmony_ci}
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic inline void qed_inform_vf_link_state(struct qed_hwfn *hwfn)
4448c2ecf20Sopenharmony_ci{
4458c2ecf20Sopenharmony_ci}
4468c2ecf20Sopenharmony_ci#endif
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci#define qed_for_each_vf(_p_hwfn, _i)			  \
4498c2ecf20Sopenharmony_ci	for (_i = qed_iov_get_next_active_vf(_p_hwfn, 0); \
4508c2ecf20Sopenharmony_ci	     _i < MAX_NUM_VFS;				  \
4518c2ecf20Sopenharmony_ci	     _i = qed_iov_get_next_active_vf(_p_hwfn, _i + 1))
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#endif
454