Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 2013 - 2018 Intel Corporation. */
0003 
0004 #ifndef _I40E_VIRTCHNL_PF_H_
0005 #define _I40E_VIRTCHNL_PF_H_
0006 
0007 #include "i40e.h"
0008 
0009 #define I40E_MAX_VLANID 4095
0010 
0011 #define I40E_VIRTCHNL_SUPPORTED_QTYPES 2
0012 
0013 #define I40E_VLAN_PRIORITY_SHIFT    13
0014 #define I40E_VLAN_MASK          0xFFF
0015 #define I40E_PRIORITY_MASK      0xE000
0016 
0017 #define I40E_MAX_VF_PROMISC_FLAGS   3
0018 
0019 #define I40E_VF_STATE_WAIT_COUNT    20
0020 #define I40E_VFR_WAIT_COUNT     100
0021 
0022 /* Various queue ctrls */
0023 enum i40e_queue_ctrl {
0024     I40E_QUEUE_CTRL_UNKNOWN = 0,
0025     I40E_QUEUE_CTRL_ENABLE,
0026     I40E_QUEUE_CTRL_ENABLECHECK,
0027     I40E_QUEUE_CTRL_DISABLE,
0028     I40E_QUEUE_CTRL_DISABLECHECK,
0029     I40E_QUEUE_CTRL_FASTDISABLE,
0030     I40E_QUEUE_CTRL_FASTDISABLECHECK,
0031 };
0032 
0033 /* VF states */
0034 enum i40e_vf_states {
0035     I40E_VF_STATE_INIT = 0,
0036     I40E_VF_STATE_ACTIVE,
0037     I40E_VF_STATE_IWARPENA,
0038     I40E_VF_STATE_DISABLED,
0039     I40E_VF_STATE_MC_PROMISC,
0040     I40E_VF_STATE_UC_PROMISC,
0041     I40E_VF_STATE_PRE_ENABLE,
0042 };
0043 
0044 /* VF capabilities */
0045 enum i40e_vf_capabilities {
0046     I40E_VIRTCHNL_VF_CAP_PRIVILEGE = 0,
0047     I40E_VIRTCHNL_VF_CAP_L2,
0048     I40E_VIRTCHNL_VF_CAP_IWARP,
0049 };
0050 
0051 /* In ADq, max 4 VSI's can be allocated per VF including primary VF VSI.
0052  * These variables are used to store indices, id's and number of queues
0053  * for each VSI including that of primary VF VSI. Each Traffic class is
0054  * termed as channel and each channel can in-turn have 4 queues which
0055  * means max 16 queues overall per VF.
0056  */
0057 struct i40evf_channel {
0058     u16 vsi_idx; /* index in PF struct for all channel VSIs */
0059     u16 vsi_id; /* VSI ID used by firmware */
0060     u16 num_qps; /* number of queue pairs requested by user */
0061     u64 max_tx_rate; /* bandwidth rate allocation for VSIs */
0062 };
0063 
0064 /* VF information structure */
0065 struct i40e_vf {
0066     struct i40e_pf *pf;
0067 
0068     /* VF id in the PF space */
0069     s16 vf_id;
0070     /* all VF vsis connect to the same parent */
0071     enum i40e_switch_element_types parent_type;
0072     struct virtchnl_version_info vf_ver;
0073     u32 driver_caps; /* reported by VF driver */
0074 
0075     /* VF Port Extender (PE) stag if used */
0076     u16 stag;
0077 
0078     struct virtchnl_ether_addr default_lan_addr;
0079     u16 port_vlan_id;
0080     bool pf_set_mac;    /* The VMM admin set the VF MAC address */
0081     bool trusted;
0082 
0083     /* VSI indices - actual VSI pointers are maintained in the PF structure
0084      * When assigned, these will be non-zero, because VSI 0 is always
0085      * the main LAN VSI for the PF.
0086      */
0087     u16 lan_vsi_idx;    /* index into PF struct */
0088     u16 lan_vsi_id;     /* ID as used by firmware */
0089 
0090     u8 num_queue_pairs; /* num of qps assigned to VF vsis */
0091     u8 num_req_queues;  /* num of requested qps */
0092     u64 num_mdd_events; /* num of mdd events detected */
0093 
0094     unsigned long vf_caps;  /* vf's adv. capabilities */
0095     unsigned long vf_states;    /* vf's runtime states */
0096     unsigned int tx_rate;   /* Tx bandwidth limit in Mbps */
0097     bool link_forced;
0098     bool link_up;       /* only valid if VF link is forced */
0099     bool spoofchk;
0100     u16 num_vlan;
0101 
0102     /* ADq related variables */
0103     bool adq_enabled; /* flag to enable adq */
0104     u8 num_tc;
0105     struct i40evf_channel ch[I40E_MAX_VF_VSI];
0106     struct hlist_head cloud_filter_list;
0107     u16 num_cloud_filters;
0108 
0109     /* RDMA Client */
0110     struct virtchnl_iwarp_qvlist_info *qvlist_info;
0111 };
0112 
0113 void i40e_free_vfs(struct i40e_pf *pf);
0114 int i40e_pci_sriov_configure(struct pci_dev *dev, int num_vfs);
0115 int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs);
0116 int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
0117                u32 v_retval, u8 *msg, u16 msglen);
0118 int i40e_vc_process_vflr_event(struct i40e_pf *pf);
0119 bool i40e_reset_vf(struct i40e_vf *vf, bool flr);
0120 bool i40e_reset_all_vfs(struct i40e_pf *pf, bool flr);
0121 void i40e_vc_notify_vf_reset(struct i40e_vf *vf);
0122 
0123 /* VF configuration related iplink handlers */
0124 int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
0125 int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
0126                   u16 vlan_id, u8 qos, __be16 vlan_proto);
0127 int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
0128                int max_tx_rate);
0129 int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting);
0130 int i40e_ndo_get_vf_config(struct net_device *netdev,
0131                int vf_id, struct ifla_vf_info *ivi);
0132 int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link);
0133 int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable);
0134 
0135 void i40e_vc_notify_link_state(struct i40e_pf *pf);
0136 void i40e_vc_notify_reset(struct i40e_pf *pf);
0137 int i40e_get_vf_stats(struct net_device *netdev, int vf_id,
0138               struct ifla_vf_stats *vf_stats);
0139 
0140 #endif /* _I40E_VIRTCHNL_PF_H_ */