linux/drivers/net/ethernet/qlogic/qed/qed_vf.h

/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/* QLogic qed NIC Driver
 * Copyright (c) 2015-2017  QLogic Corporation
 */

#ifndef _QED_VF_H
#define _QED_VF_H

#include "qed_l2.h"
#include "qed_mcp.h"

#define T_ETH_INDIRECTION_TABLE_SIZE
#define T_ETH_RSS_KEY_SIZE

struct vf_pf_resc_request {};

struct hw_sb_info {};

#define TLV_BUFFER_SIZE

enum {};

/* vf pf channel tlvs */
/* general tlv header (used for both vf->pf request and pf->vf response) */
struct channel_tlv {};

/* header of first vf->pf tlv carries the offset used to calculate response
 * buffer address
 */
struct vfpf_first_tlv {};

/* header of pf->vf tlvs, carries the status of handling the request */
struct pfvf_tlv {};

/* response tlv used for most tlvs */
struct pfvf_def_resp_tlv {};

/* used to terminate and pad a tlv list */
struct channel_list_end_tlv {};

#define VFPF_ACQUIRE_OS_LINUX
#define VFPF_ACQUIRE_OS_WINDOWS
#define VFPF_ACQUIRE_OS_ESX
#define VFPF_ACQUIRE_OS_SOLARIS
#define VFPF_ACQUIRE_OS_LINUX_USERSPACE

struct vfpf_acquire_tlv {};

/* receive side scaling tlv */
struct vfpf_vport_update_rss_tlv {};

struct pfvf_storm_stats {};

struct pfvf_stats_info {};

struct pfvf_acquire_resp_tlv {};

struct pfvf_start_queue_resp_tlv {};

/* Extended queue information - additional index for reference inside qzone.
 * If communicated between VF/PF, each TLV relating to queues should be
 * extended by one such [or have a future base TLV that already contains info].
 */
struct vfpf_qid_tlv {};

/* Setup Queue */
struct vfpf_start_rxq_tlv {};

struct vfpf_start_txq_tlv {};

/* Stop RX Queue */
struct vfpf_stop_rxqs_tlv {};

/* Stop TX Queues */
struct vfpf_stop_txqs_tlv {};

struct vfpf_update_rxq_tlv {};

/* Set Queue Filters */
struct vfpf_q_mac_vlan_filter {};

/* Start a vport */
struct vfpf_vport_start_tlv {};

/* Extended tlvs - need to add rss, mcast, accept mode tlvs */
struct vfpf_vport_update_activate_tlv {};

struct vfpf_vport_update_tx_switch_tlv {};

struct vfpf_vport_update_vlan_strip_tlv {};

struct vfpf_vport_update_mcast_bin_tlv {};

struct vfpf_vport_update_accept_param_tlv {};

struct vfpf_vport_update_accept_any_vlan_tlv {};

struct vfpf_vport_update_sge_tpa_tlv {};

/* Primary tlv as a header for various extended tlvs for
 * various functionalities in vport update ramrod.
 */
struct vfpf_vport_update_tlv {};

struct vfpf_ucast_filter_tlv {};

/* tunnel update param tlv */
struct vfpf_update_tunn_param_tlv {};

struct pfvf_update_tunn_param_tlv {};

struct tlv_buffer_size {};

struct vfpf_update_coalesce {};

struct vfpf_read_coal_req_tlv {};

struct pfvf_read_coal_resp_tlv {};

struct vfpf_bulletin_update_mac_tlv {};

vfpf_tlvs;

pfvf_tlvs;

enum qed_bulletin_bit {};

struct qed_bulletin_content {};

struct qed_bulletin {};

enum {};

/* Default number of CIDs [total of both Rx and Tx] to be requested
 * by default, and maximum possible number.
 */
#define QED_ETH_VF_DEFAULT_NUM_CIDS
#define QED_ETH_VF_MAX_NUM_CIDS

/* This data is held in the qed_hwfn structure for VFs only. */
struct qed_vf_iov {};

/**
 * qed_vf_pf_set_coalesce(): VF - Set Rx/Tx coalesce per VF's relative queue.
 *                                Coalesce value '0' will omit the
 *                                configuration.
 *
 * @p_hwfn: HW device data.
 * @rx_coal: coalesce value in micro second for rx queue.
 * @tx_coal: coalesce value in micro second for tx queue.
 * @p_cid: queue cid.
 *
 * Return: Int.
 *
 **/
int qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
			   u16 rx_coal,
			   u16 tx_coal, struct qed_queue_cid *p_cid);

/**
 * qed_vf_pf_get_coalesce(): VF - Get coalesce per VF's relative queue.
 *
 * @p_hwfn: HW device data.
 * @p_coal: coalesce value in micro second for VF queues.
 * @p_cid: queue cid.
 *
 * Return: Int.
 **/
int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
			   u16 *p_coal, struct qed_queue_cid *p_cid);

#ifdef CONFIG_QED_SRIOV
/**
 * qed_vf_read_bulletin(): Read the VF bulletin and act on it if needed.
 *
 * @p_hwfn: HW device data.
 * @p_change: qed fills 1 iff bulletin board has changed, 0 otherwise.
 *
 * Return: enum _qed_status.
 */
int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);

/**
 * qed_vf_get_link_params(): Get link parameters for VF from qed
 *
 * @p_hwfn: HW device data.
 * @params: the link params structure to be filled for the VF.
 *
 * Return: Void.
 */
void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
			    struct qed_mcp_link_params *params);

/**
 * qed_vf_get_link_state(): Get link state for VF from qed.
 *
 * @p_hwfn: HW device data.
 * @link: the link state structure to be filled for the VF
 *
 * Return: Void.
 */
void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
			   struct qed_mcp_link_state *link);

/**
 * qed_vf_get_link_caps(): Get link capabilities for VF from qed.
 *
 * @p_hwfn: HW device data.
 * @p_link_caps: the link capabilities structure to be filled for the VF
 *
 * Return: Void.
 */
void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
			  struct qed_mcp_link_capabilities *p_link_caps);

/**
 * qed_vf_get_num_rxqs(): Get number of Rx queues allocated for VF by qed
 *
 * @p_hwfn: HW device data.
 * @num_rxqs: allocated RX queues
 *
 * Return: Void.
 */
void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);

/**
 * qed_vf_get_num_txqs(): Get number of Rx queues allocated for VF by qed
 *
 * @p_hwfn: HW device data.
 * @num_txqs: allocated RX queues
 *
 * Return: Void.
 */
void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs);

/**
 * qed_vf_get_num_cids(): Get number of available connections
 *                        [both Rx and Tx] for VF
 *
 * @p_hwfn: HW device data.
 * @num_cids: allocated number of connections
 *
 * Return: Void.
 */
void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids);

/**
 * qed_vf_get_port_mac(): Get port mac address for VF.
 *
 * @p_hwfn: HW device data.
 * @port_mac: destination location for port mac
 *
 * Return: Void.
 */
void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);

/**
 * qed_vf_get_num_vlan_filters(): Get number of VLAN filters allocated
 *                                for VF by qed.
 *
 * @p_hwfn: HW device data.
 * @num_vlan_filters: allocated VLAN filters
 *
 * Return: Void.
 */
void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
				 u8 *num_vlan_filters);

/**
 * qed_vf_get_num_mac_filters(): Get number of MAC filters allocated
 *                               for VF by qed
 *
 * @p_hwfn: HW device data.
 * @num_mac_filters: allocated MAC filters
 *
 * Return: Void.
 */
void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);

/**
 * qed_vf_check_mac(): Check if VF can set a MAC address
 *
 * @p_hwfn: HW device data.
 * @mac: Mac.
 *
 * Return: bool.
 */
bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);

/**
 * qed_vf_get_fw_version(): Set firmware version information
 *                          in dev_info from VFs acquire response tlv
 *
 * @p_hwfn: HW device data.
 * @fw_major: FW major.
 * @fw_minor: FW minor.
 * @fw_rev: FW rev.
 * @fw_eng: FW eng.
 *
 * Return: Void.
 */
void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
			   u16 *fw_major, u16 *fw_minor,
			   u16 *fw_rev, u16 *fw_eng);

/**
 * qed_vf_hw_prepare(): hw preparation for VF  sends ACQUIRE message
 *
 * @p_hwfn: HW device data.
 *
 * Return: Int.
 */
int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);

/**
 * qed_vf_pf_rxq_start(): start the RX Queue by sending a message to the PF
 *
 * @p_hwfn: HW device data.
 * @p_cid: Only relative fields are relevant
 * @bd_max_bytes: maximum number of bytes per bd
 * @bd_chain_phys_addr: physical address of bd chain
 * @cqe_pbl_addr: physical address of pbl
 * @cqe_pbl_size: pbl size
 * @pp_prod: pointer to the producer to be used in fastpath
 *
 * Return: Int.
 */
int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
			struct qed_queue_cid *p_cid,
			u16 bd_max_bytes,
			dma_addr_t bd_chain_phys_addr,
			dma_addr_t cqe_pbl_addr,
			u16 cqe_pbl_size, void __iomem **pp_prod);

/**
 * qed_vf_pf_txq_start(): VF - start the TX queue by sending a message to the
 *                        PF.
 *
 * @p_hwfn: HW device data.
 * @p_cid: CID.
 * @pbl_addr: PBL address.
 * @pbl_size: PBL Size.
 * @pp_doorbell: pointer to address to which to write the doorbell too.
 *
 * Return: Int.
 */
int
qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
		    struct qed_queue_cid *p_cid,
		    dma_addr_t pbl_addr,
		    u16 pbl_size, void __iomem **pp_doorbell);

/**
 * qed_vf_pf_rxq_stop(): VF - stop the RX queue by sending a message to the PF.
 *
 * @p_hwfn: HW device data.
 * @p_cid: CID.
 * @cqe_completion: CQE Completion.
 *
 * Return: Int.
 */
int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
		       struct qed_queue_cid *p_cid, bool cqe_completion);

/**
 * qed_vf_pf_txq_stop(): VF - stop the TX queue by sending a message to the PF.
 *
 * @p_hwfn: HW device data.
 * @p_cid: CID.
 *
 * Return: Int.
 */
int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);

/**
 * qed_vf_pf_vport_update(): VF - send a vport update command.
 *
 * @p_hwfn: HW device data.
 * @p_params: Params
 *
 * Return: Int.
 */
int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
			   struct qed_sp_vport_update_params *p_params);

/**
 * qed_vf_pf_reset(): VF - send a close message to PF.
 *
 * @p_hwfn: HW device data.
 *
 * Return: enum _qed_status
 */
int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);

/**
 * qed_vf_pf_release(): VF - free vf`s memories.
 *
 * @p_hwfn: HW device data.
 *
 * Return: enum _qed_status
 */
int qed_vf_pf_release(struct qed_hwfn *p_hwfn);

/**
 * qed_vf_get_igu_sb_id(): Get the IGU SB ID for a given
 *        sb_id. For VFs igu sbs don't have to be contiguous
 *
 * @p_hwfn: HW device data.
 * @sb_id: SB ID.
 *
 * Return: INLINE u16
 */
u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);

/**
 * qed_vf_set_sb_info(): Stores [or removes] a configured sb_info.
 *
 * @p_hwfn: HW device data.
 * @sb_id: zero-based SB index [for fastpath]
 * @p_sb:  may be NULL [during removal].
 *
 * Return: Void.
 */
void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn,
			u16 sb_id, struct qed_sb_info *p_sb);

/**
 * qed_vf_pf_vport_start(): perform vport start for VF.
 *
 * @p_hwfn: HW device data.
 * @vport_id: Vport ID.
 * @mtu: MTU.
 * @inner_vlan_removal: Innter VLAN removal.
 * @tpa_mode: TPA mode
 * @max_buffers_per_cqe: Max buffer pre CQE.
 * @only_untagged: default behavior regarding vlan acceptance
 *
 * Return: enum _qed_status
 */
int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
			  u8 vport_id,
			  u16 mtu,
			  u8 inner_vlan_removal,
			  enum qed_tpa_mode tpa_mode,
			  u8 max_buffers_per_cqe, u8 only_untagged);

/**
 * qed_vf_pf_vport_stop(): stop the VF's vport
 *
 * @p_hwfn: HW device data.
 *
 * Return: enum _qed_status
 */
int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);

int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
			   struct qed_filter_ucast *p_param);

void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
			    struct qed_filter_mcast *p_filter_cmd);

/**
 * qed_vf_pf_int_cleanup(): clean the SB of the VF
 *
 * @p_hwfn: HW device data.
 *
 * Return: enum _qed_status
 */
int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);

/**
 * __qed_vf_get_link_params(): return the link params in a given bulletin board
 *
 * @p_hwfn: HW device data.
 * @p_params: pointer to a struct to fill with link params
 * @p_bulletin: Bulletin.
 *
 * Return: Void.
 */
void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
			      struct qed_mcp_link_params *p_params,
			      struct qed_bulletin_content *p_bulletin);

/**
 * __qed_vf_get_link_state(): return the link state in a given bulletin board
 *
 * @p_hwfn: HW device data.
 * @p_link: pointer to a struct to fill with link state
 * @p_bulletin: Bulletin.
 *
 * Return: Void.
 */
void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
			     struct qed_mcp_link_state *p_link,
			     struct qed_bulletin_content *p_bulletin);

/**
 * __qed_vf_get_link_caps(): return the link capabilities in a given
 *                           bulletin board
 *
 * @p_hwfn: HW device data.
 * @p_link_caps: pointer to a struct to fill with link capabilities
 * @p_bulletin: Bulletin.
 *
 * Return: Void.
 */
void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
			    struct qed_mcp_link_capabilities *p_link_caps,
			    struct qed_bulletin_content *p_bulletin);

void qed_iov_vf_task(struct work_struct *work);
void qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun);
int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
				  struct qed_tunnel_info *p_tunn);

u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
/**
 * qed_vf_pf_bulletin_update_mac(): Ask PF to update the MAC address in
 *                                  it's bulletin board
 *
 * @p_hwfn: HW device data.
 * @p_mac: mac address to be updated in bulletin board
 *
 * Return: Int.
 */
int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn, const u8 *p_mac);

#else
static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
					  struct qed_mcp_link_params *params)
{
}

static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
					 struct qed_mcp_link_state *link)
{
}

static inline void
qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
		     struct qed_mcp_link_capabilities *p_link_caps)
{
}

static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
{
}

static inline void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs)
{
}

static inline void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids)
{
}

static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
{
}

static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
					       u8 *num_vlan_filters)
{
}

static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
					      u8 *num_mac_filters)
{
}

static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
{
	return false;
}

static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
					 u16 *fw_major, u16 *fw_minor,
					 u16 *fw_rev, u16 *fw_eng)
{
}

static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
				      struct qed_queue_cid *p_cid,
				      u16 bd_max_bytes,
				      dma_addr_t bd_chain_phys_adr,
				      dma_addr_t cqe_pbl_addr,
				      u16 cqe_pbl_size, void __iomem **pp_prod)
{
	return -EINVAL;
}

static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
				      struct qed_queue_cid *p_cid,
				      dma_addr_t pbl_addr,
				      u16 pbl_size, void __iomem **pp_doorbell)
{
	return -EINVAL;
}

static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
				     struct qed_queue_cid *p_cid,
				     bool cqe_completion)
{
	return -EINVAL;
}

static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
				     struct qed_queue_cid *p_cid)
{
	return -EINVAL;
}

static inline int
qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
		       struct qed_sp_vport_update_params *p_params)
{
	return -EINVAL;
}

static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
{
	return 0;
}

static inline void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn, u16 sb_id,
				      struct qed_sb_info *p_sb)
{
}

static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
					u8 vport_id,
					u16 mtu,
					u8 inner_vlan_removal,
					enum qed_tpa_mode tpa_mode,
					u8 max_buffers_per_cqe,
					u8 only_untagged)
{
	return -EINVAL;
}

static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
					 struct qed_filter_ucast *p_param)
{
	return -EINVAL;
}

static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
					  struct qed_filter_mcast *p_filter_cmd)
{
}

static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
					    struct qed_mcp_link_params
					    *p_params,
					    struct qed_bulletin_content
					    *p_bulletin)
{
}

static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
					   struct qed_mcp_link_state *p_link,
					   struct qed_bulletin_content
					   *p_bulletin)
{
}

static inline void
__qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
		       struct qed_mcp_link_capabilities *p_link_caps,
		       struct qed_bulletin_content *p_bulletin)
{
}

static inline void qed_iov_vf_task(struct work_struct *work)
{
}

static inline void
qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun)
{
}

static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
						struct qed_tunnel_info *p_tunn)
{
	return -EINVAL;
}

static inline int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
						const u8 *p_mac)
{
	return -EINVAL;
}

static inline u32
qed_vf_hw_bar_size(struct qed_hwfn  *p_hwfn,
		   enum BAR_ID bar_id)
{
	return 0;
}
#endif

#endif