Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 2013 - 2018 Intel Corporation. */
0003 
0004 #ifndef _IAVF_CLIENT_H_
0005 #define _IAVF_CLIENT_H_
0006 
0007 #define IAVF_CLIENT_STR_LENGTH 10
0008 
0009 /* Client interface version should be updated anytime there is a change in the
0010  * existing APIs or data structures.
0011  */
0012 #define IAVF_CLIENT_VERSION_MAJOR 0
0013 #define IAVF_CLIENT_VERSION_MINOR 01
0014 #define IAVF_CLIENT_VERSION_BUILD 00
0015 #define IAVF_CLIENT_VERSION_STR     \
0016     __stringify(IAVF_CLIENT_VERSION_MAJOR) "." \
0017     __stringify(IAVF_CLIENT_VERSION_MINOR) "." \
0018     __stringify(IAVF_CLIENT_VERSION_BUILD)
0019 
0020 struct iavf_client_version {
0021     u8 major;
0022     u8 minor;
0023     u8 build;
0024     u8 rsvd;
0025 };
0026 
0027 enum iavf_client_state {
0028     __IAVF_CLIENT_NULL,
0029     __IAVF_CLIENT_REGISTERED
0030 };
0031 
0032 enum iavf_client_instance_state {
0033     __IAVF_CLIENT_INSTANCE_NONE,
0034     __IAVF_CLIENT_INSTANCE_OPENED,
0035 };
0036 
0037 struct iavf_ops;
0038 struct iavf_client;
0039 
0040 /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
0041  * In order for us to keep the interface simple, SW will define a
0042  * unique type value for AEQ.
0043  */
0044 #define IAVF_QUEUE_TYPE_PE_AEQ  0x80
0045 #define IAVF_QUEUE_INVALID_IDX  0xFFFF
0046 
0047 struct iavf_qv_info {
0048     u32 v_idx; /* msix_vector */
0049     u16 ceq_idx;
0050     u16 aeq_idx;
0051     u8 itr_idx;
0052 };
0053 
0054 struct iavf_qvlist_info {
0055     u32 num_vectors;
0056     struct iavf_qv_info qv_info[1];
0057 };
0058 
0059 #define IAVF_CLIENT_MSIX_ALL 0xFFFFFFFF
0060 
0061 /* set of LAN parameters useful for clients managed by LAN */
0062 
0063 /* Struct to hold per priority info */
0064 struct iavf_prio_qos_params {
0065     u16 qs_handle; /* qs handle for prio */
0066     u8 tc; /* TC mapped to prio */
0067     u8 reserved;
0068 };
0069 
0070 #define IAVF_CLIENT_MAX_USER_PRIORITY   8
0071 /* Struct to hold Client QoS */
0072 struct iavf_qos_params {
0073     struct iavf_prio_qos_params prio_qos[IAVF_CLIENT_MAX_USER_PRIORITY];
0074 };
0075 
0076 struct iavf_params {
0077     struct iavf_qos_params qos;
0078     u16 mtu;
0079     u16 link_up; /* boolean */
0080 };
0081 
0082 /* Structure to hold LAN device info for a client device */
0083 struct iavf_info {
0084     struct iavf_client_version version;
0085     u8 lanmac[6];
0086     struct net_device *netdev;
0087     struct pci_dev *pcidev;
0088     u8 __iomem *hw_addr;
0089     u8 fid; /* function id, PF id or VF id */
0090 #define IAVF_CLIENT_FTYPE_PF 0
0091 #define IAVF_CLIENT_FTYPE_VF 1
0092     u8 ftype; /* function type, PF or VF */
0093     void *vf; /* cast to iavf_adapter */
0094 
0095     /* All L2 params that could change during the life span of the device
0096      * and needs to be communicated to the client when they change
0097      */
0098     struct iavf_params params;
0099     struct iavf_ops *ops;
0100 
0101     u16 msix_count;  /* number of msix vectors*/
0102     /* Array down below will be dynamically allocated based on msix_count */
0103     struct msix_entry *msix_entries;
0104     u16 itr_index; /* Which ITR index the PE driver is suppose to use */
0105 };
0106 
0107 struct iavf_ops {
0108     /* setup_q_vector_list enables queues with a particular vector */
0109     int (*setup_qvlist)(struct iavf_info *ldev, struct iavf_client *client,
0110                 struct iavf_qvlist_info *qv_info);
0111 
0112     u32 (*virtchnl_send)(struct iavf_info *ldev, struct iavf_client *client,
0113                  u8 *msg, u16 len);
0114 
0115     /* If the PE Engine is unresponsive, RDMA driver can request a reset.*/
0116     void (*request_reset)(struct iavf_info *ldev,
0117                   struct iavf_client *client);
0118 };
0119 
0120 struct iavf_client_ops {
0121     /* Should be called from register_client() or whenever the driver is
0122      * ready to create a specific client instance.
0123      */
0124     int (*open)(struct iavf_info *ldev, struct iavf_client *client);
0125 
0126     /* Should be closed when netdev is unavailable or when unregister
0127      * call comes in. If the close happens due to a reset, set the reset
0128      * bit to true.
0129      */
0130     void (*close)(struct iavf_info *ldev, struct iavf_client *client,
0131               bool reset);
0132 
0133     /* called when some l2 managed parameters changes - mss */
0134     void (*l2_param_change)(struct iavf_info *ldev,
0135                 struct iavf_client *client,
0136                 struct iavf_params *params);
0137 
0138     /* called when a message is received from the PF */
0139     int (*virtchnl_receive)(struct iavf_info *ldev,
0140                 struct iavf_client *client,
0141                 u8 *msg, u16 len);
0142 };
0143 
0144 /* Client device */
0145 struct iavf_client_instance {
0146     struct list_head list;
0147     struct iavf_info lan_info;
0148     struct iavf_client *client;
0149     unsigned long  state;
0150 };
0151 
0152 struct iavf_client {
0153     struct list_head list;      /* list of registered clients */
0154     char name[IAVF_CLIENT_STR_LENGTH];
0155     struct iavf_client_version version;
0156     unsigned long state;        /* client state */
0157     atomic_t ref_cnt;  /* Count of all the client devices of this kind */
0158     u32 flags;
0159 #define IAVF_CLIENT_FLAGS_LAUNCH_ON_PROBE   BIT(0)
0160 #define IAVF_TX_FLAGS_NOTIFY_OTHER_EVENTS   BIT(2)
0161     u8 type;
0162 #define IAVF_CLIENT_IWARP 0
0163     struct iavf_client_ops *ops;    /* client ops provided by the client */
0164 };
0165 
0166 /* used by clients */
0167 int iavf_register_client(struct iavf_client *client);
0168 int iavf_unregister_client(struct iavf_client *client);
0169 #endif /* _IAVF_CLIENT_H_ */