Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 2013 - 2018 Intel Corporation. */
0003 
0004 #ifndef _I40E_CLIENT_H_
0005 #define _I40E_CLIENT_H_
0006 
0007 #include <linux/auxiliary_bus.h>
0008 
0009 #define I40E_CLIENT_STR_LENGTH 10
0010 
0011 /* Client interface version should be updated anytime there is a change in the
0012  * existing APIs or data structures.
0013  */
0014 #define I40E_CLIENT_VERSION_MAJOR 0
0015 #define I40E_CLIENT_VERSION_MINOR 01
0016 #define I40E_CLIENT_VERSION_BUILD 00
0017 #define I40E_CLIENT_VERSION_STR     \
0018     __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
0019     __stringify(I40E_CLIENT_VERSION_MINOR) "." \
0020     __stringify(I40E_CLIENT_VERSION_BUILD)
0021 
0022 struct i40e_client_version {
0023     u8 major;
0024     u8 minor;
0025     u8 build;
0026     u8 rsvd;
0027 };
0028 
0029 enum i40e_client_instance_state {
0030     __I40E_CLIENT_INSTANCE_NONE,
0031     __I40E_CLIENT_INSTANCE_OPENED,
0032 };
0033 
0034 struct i40e_ops;
0035 struct i40e_client;
0036 
0037 #define I40E_QUEUE_INVALID_IDX  0xFFFF
0038 
0039 struct i40e_qv_info {
0040     u32 v_idx; /* msix_vector */
0041     u16 ceq_idx;
0042     u16 aeq_idx;
0043     u8 itr_idx;
0044 };
0045 
0046 struct i40e_qvlist_info {
0047     u32 num_vectors;
0048     struct i40e_qv_info qv_info[];
0049 };
0050 
0051 
0052 /* set of LAN parameters useful for clients managed by LAN */
0053 
0054 /* Struct to hold per priority info */
0055 struct i40e_prio_qos_params {
0056     u16 qs_handle; /* qs handle for prio */
0057     u8 tc; /* TC mapped to prio */
0058     u8 reserved;
0059 };
0060 
0061 #define I40E_CLIENT_MAX_USER_PRIORITY        8
0062 /* Struct to hold Client QoS */
0063 struct i40e_qos_params {
0064     struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
0065 };
0066 
0067 struct i40e_params {
0068     struct i40e_qos_params qos;
0069     u16 mtu;
0070 };
0071 
0072 /* Structure to hold Lan device info for a client device */
0073 struct i40e_info {
0074     struct i40e_client_version version;
0075     u8 lanmac[6];
0076     struct net_device *netdev;
0077     struct pci_dev *pcidev;
0078     struct auxiliary_device *aux_dev;
0079     u8 __iomem *hw_addr;
0080     u8 fid; /* function id, PF id or VF id */
0081 #define I40E_CLIENT_FTYPE_PF 0
0082     u8 ftype; /* function type, PF or VF */
0083     void *pf;
0084 
0085     /* All L2 params that could change during the life span of the PF
0086      * and needs to be communicated to the client when they change
0087      */
0088     struct i40e_qvlist_info *qvlist_info;
0089     struct i40e_params params;
0090     struct i40e_ops *ops;
0091 
0092     u16 msix_count;  /* number of msix vectors*/
0093     /* Array down below will be dynamically allocated based on msix_count */
0094     struct msix_entry *msix_entries;
0095     u16 itr_index; /* Which ITR index the PE driver is suppose to use */
0096     u16 fw_maj_ver;                 /* firmware major version */
0097     u16 fw_min_ver;                 /* firmware minor version */
0098     u32 fw_build;                   /* firmware build number */
0099 };
0100 
0101 struct i40e_auxiliary_device {
0102     struct auxiliary_device aux_dev;
0103     struct i40e_info *ldev;
0104 };
0105 
0106 #define I40E_CLIENT_RESET_LEVEL_PF   1
0107 #define I40E_CLIENT_RESET_LEVEL_CORE 2
0108 #define I40E_CLIENT_VSI_FLAG_TCP_ENABLE  BIT(1)
0109 
0110 struct i40e_ops {
0111     /* setup_q_vector_list enables queues with a particular vector */
0112     int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
0113                 struct i40e_qvlist_info *qv_info);
0114 
0115     int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
0116                  u32 vf_id, u8 *msg, u16 len);
0117 
0118     /* If the PE Engine is unresponsive, RDMA driver can request a reset.
0119      * The level helps determine the level of reset being requested.
0120      */
0121     void (*request_reset)(struct i40e_info *ldev,
0122                   struct i40e_client *client, u32 level);
0123 
0124     /* API for the RDMA driver to set certain VSI flags that control
0125      * PE Engine.
0126      */
0127     int (*update_vsi_ctxt)(struct i40e_info *ldev,
0128                    struct i40e_client *client,
0129                    bool is_vf, u32 vf_id,
0130                    u32 flag, u32 valid_flag);
0131 };
0132 
0133 struct i40e_client_ops {
0134     /* Should be called from register_client() or whenever PF is ready
0135      * to create a specific client instance.
0136      */
0137     int (*open)(struct i40e_info *ldev, struct i40e_client *client);
0138 
0139     /* Should be called when netdev is unavailable or when unregister
0140      * call comes in. If the close is happenening due to a reset being
0141      * triggered set the reset bit to true.
0142      */
0143     void (*close)(struct i40e_info *ldev, struct i40e_client *client,
0144               bool reset);
0145 
0146     /* called when some l2 managed parameters changes - mtu */
0147     void (*l2_param_change)(struct i40e_info *ldev,
0148                 struct i40e_client *client,
0149                 struct i40e_params *params);
0150 
0151     int (*virtchnl_receive)(struct i40e_info *ldev,
0152                 struct i40e_client *client, u32 vf_id,
0153                 u8 *msg, u16 len);
0154 
0155     /* called when a VF is reset by the PF */
0156     void (*vf_reset)(struct i40e_info *ldev,
0157              struct i40e_client *client, u32 vf_id);
0158 
0159     /* called when the number of VFs changes */
0160     void (*vf_enable)(struct i40e_info *ldev,
0161               struct i40e_client *client, u32 num_vfs);
0162 
0163     /* returns true if VF is capable of specified offload */
0164     int (*vf_capable)(struct i40e_info *ldev,
0165               struct i40e_client *client, u32 vf_id);
0166 };
0167 
0168 /* Client device */
0169 struct i40e_client_instance {
0170     struct list_head list;
0171     struct i40e_info lan_info;
0172     struct i40e_client *client;
0173     unsigned long  state;
0174 };
0175 
0176 struct i40e_client {
0177     struct list_head list;      /* list of registered clients */
0178     char name[I40E_CLIENT_STR_LENGTH];
0179     struct i40e_client_version version;
0180     unsigned long state;        /* client state */
0181     atomic_t ref_cnt;  /* Count of all the client devices of this kind */
0182     u32 flags;
0183     u8 type;
0184 #define I40E_CLIENT_IWARP 0
0185     const struct i40e_client_ops *ops; /* client ops provided by the client */
0186 };
0187 
0188 void i40e_client_device_register(struct i40e_info *ldev, struct i40e_client *client);
0189 void i40e_client_device_unregister(struct i40e_info *ldev);
0190 
0191 #endif /* _I40E_CLIENT_H_ */