linux/drivers/net/ethernet/intel/i40evf/i40evf_client.h
<<
>>
Prefs
   1#ifndef _I40E_CLIENT_H_
   2#define _I40E_CLIENT_H_
   3
   4#define I40EVF_CLIENT_STR_LENGTH 10
   5
   6/* Client interface version should be updated anytime there is a change in the
   7 * existing APIs or data structures.
   8 */
   9#define I40EVF_CLIENT_VERSION_MAJOR 0
  10#define I40EVF_CLIENT_VERSION_MINOR 01
  11#define I40EVF_CLIENT_VERSION_BUILD 00
  12#define I40EVF_CLIENT_VERSION_STR     \
  13        __stringify(I40EVF_CLIENT_VERSION_MAJOR) "." \
  14        __stringify(I40EVF_CLIENT_VERSION_MINOR) "." \
  15        __stringify(I40EVF_CLIENT_VERSION_BUILD)
  16
  17struct i40e_client_version {
  18        u8 major;
  19        u8 minor;
  20        u8 build;
  21        u8 rsvd;
  22};
  23
  24enum i40e_client_state {
  25        __I40E_CLIENT_NULL,
  26        __I40E_CLIENT_REGISTERED
  27};
  28
  29enum i40e_client_instance_state {
  30        __I40E_CLIENT_INSTANCE_NONE,
  31        __I40E_CLIENT_INSTANCE_OPENED,
  32};
  33
  34struct i40e_ops;
  35struct i40e_client;
  36
  37/* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  38 * In order for us to keep the interface simple, SW will define a
  39 * unique type value for AEQ.
  40 */
  41#define I40E_QUEUE_TYPE_PE_AEQ  0x80
  42#define I40E_QUEUE_INVALID_IDX  0xFFFF
  43
  44struct i40e_qv_info {
  45        u32 v_idx; /* msix_vector */
  46        u16 ceq_idx;
  47        u16 aeq_idx;
  48        u8 itr_idx;
  49};
  50
  51struct i40e_qvlist_info {
  52        u32 num_vectors;
  53        struct i40e_qv_info qv_info[1];
  54};
  55
  56#define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
  57
  58/* set of LAN parameters useful for clients managed by LAN */
  59
  60/* Struct to hold per priority info */
  61struct i40e_prio_qos_params {
  62        u16 qs_handle; /* qs handle for prio */
  63        u8 tc; /* TC mapped to prio */
  64        u8 reserved;
  65};
  66
  67#define I40E_CLIENT_MAX_USER_PRIORITY        8
  68/* Struct to hold Client QoS */
  69struct i40e_qos_params {
  70        struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  71};
  72
  73struct i40e_params {
  74        struct i40e_qos_params qos;
  75        u16 mtu;
  76        u16 link_up; /* boolean */
  77};
  78
  79/* Structure to hold LAN device info for a client device */
  80struct i40e_info {
  81        struct i40e_client_version version;
  82        u8 lanmac[6];
  83        struct net_device *netdev;
  84        struct pci_dev *pcidev;
  85        u8 __iomem *hw_addr;
  86        u8 fid; /* function id, PF id or VF id */
  87#define I40E_CLIENT_FTYPE_PF 0
  88#define I40E_CLIENT_FTYPE_VF 1
  89        u8 ftype; /* function type, PF or VF */
  90        void *vf; /* cast to i40evf_adapter */
  91
  92        /* All L2 params that could change during the life span of the device
  93         * and needs to be communicated to the client when they change
  94         */
  95        struct i40e_params params;
  96        struct i40e_ops *ops;
  97
  98        u16 msix_count;  /* number of msix vectors*/
  99        /* Array down below will be dynamically allocated based on msix_count */
 100        struct msix_entry *msix_entries;
 101        u16 itr_index; /* Which ITR index the PE driver is suppose to use */
 102};
 103
 104struct i40e_ops {
 105        /* setup_q_vector_list enables queues with a particular vector */
 106        int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
 107                            struct i40e_qvlist_info *qv_info);
 108
 109        u32 (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
 110                             u8 *msg, u16 len);
 111
 112        /* If the PE Engine is unresponsive, RDMA driver can request a reset.*/
 113        void (*request_reset)(struct i40e_info *ldev,
 114                              struct i40e_client *client);
 115};
 116
 117struct i40e_client_ops {
 118        /* Should be called from register_client() or whenever the driver is
 119         * ready to create a specific client instance.
 120         */
 121        int (*open)(struct i40e_info *ldev, struct i40e_client *client);
 122
 123        /* Should be closed when netdev is unavailable or when unregister
 124         * call comes in. If the close happens due to a reset, set the reset
 125         * bit to true.
 126         */
 127        void (*close)(struct i40e_info *ldev, struct i40e_client *client,
 128                      bool reset);
 129
 130        /* called when some l2 managed parameters changes - mss */
 131        void (*l2_param_change)(struct i40e_info *ldev,
 132                                struct i40e_client *client,
 133                                struct i40e_params *params);
 134
 135        /* called when a message is received from the PF */
 136        int (*virtchnl_receive)(struct i40e_info *ldev,
 137                                struct i40e_client *client,
 138                                u8 *msg, u16 len);
 139};
 140
 141/* Client device */
 142struct i40e_client_instance {
 143        struct list_head list;
 144        struct i40e_info lan_info;
 145        struct i40e_client *client;
 146        unsigned long  state;
 147};
 148
 149struct i40e_client {
 150        struct list_head list;          /* list of registered clients */
 151        char name[I40EVF_CLIENT_STR_LENGTH];
 152        struct i40e_client_version version;
 153        unsigned long state;            /* client state */
 154        atomic_t ref_cnt;  /* Count of all the client devices of this kind */
 155        u32 flags;
 156#define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE       BIT(0)
 157#define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS       BIT(2)
 158        u8 type;
 159#define I40E_CLIENT_IWARP 0
 160        struct i40e_client_ops *ops;    /* client ops provided by the client */
 161};
 162
 163/* used by clients */
 164int i40evf_register_client(struct i40e_client *client);
 165int i40evf_unregister_client(struct i40e_client *client);
 166#endif /* _I40E_CLIENT_H_ */
 167