linux/include/linux/net/intel/i40e_client.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/* Copyright(c) 2013 - 2018 Intel Corporation. */
   3
   4#ifndef _I40E_CLIENT_H_
   5#define _I40E_CLIENT_H_
   6
   7#include <linux/auxiliary_bus.h>
   8
   9#define I40E_CLIENT_STR_LENGTH 10
  10
  11/* Client interface version should be updated anytime there is a change in the
  12 * existing APIs or data structures.
  13 */
  14#define I40E_CLIENT_VERSION_MAJOR 0
  15#define I40E_CLIENT_VERSION_MINOR 01
  16#define I40E_CLIENT_VERSION_BUILD 00
  17#define I40E_CLIENT_VERSION_STR     \
  18        __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
  19        __stringify(I40E_CLIENT_VERSION_MINOR) "." \
  20        __stringify(I40E_CLIENT_VERSION_BUILD)
  21
  22struct i40e_client_version {
  23        u8 major;
  24        u8 minor;
  25        u8 build;
  26        u8 rsvd;
  27};
  28
  29enum i40e_client_state {
  30        __I40E_CLIENT_NULL,
  31        __I40E_CLIENT_REGISTERED
  32};
  33
  34enum i40e_client_instance_state {
  35        __I40E_CLIENT_INSTANCE_NONE,
  36        __I40E_CLIENT_INSTANCE_OPENED,
  37};
  38
  39struct i40e_ops;
  40struct i40e_client;
  41
  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[];
  54};
  55
  56
  57/* set of LAN parameters useful for clients managed by LAN */
  58
  59/* Struct to hold per priority info */
  60struct i40e_prio_qos_params {
  61        u16 qs_handle; /* qs handle for prio */
  62        u8 tc; /* TC mapped to prio */
  63        u8 reserved;
  64};
  65
  66#define I40E_CLIENT_MAX_USER_PRIORITY        8
  67/* Struct to hold Client QoS */
  68struct i40e_qos_params {
  69        struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  70};
  71
  72struct i40e_params {
  73        struct i40e_qos_params qos;
  74        u16 mtu;
  75};
  76
  77/* Structure to hold Lan device info for a client device */
  78struct i40e_info {
  79        struct i40e_client_version version;
  80        u8 lanmac[6];
  81        struct net_device *netdev;
  82        struct pci_dev *pcidev;
  83        struct auxiliary_device *aux_dev;
  84        u8 __iomem *hw_addr;
  85        u8 fid; /* function id, PF id or VF id */
  86#define I40E_CLIENT_FTYPE_PF 0
  87        u8 ftype; /* function type, PF or VF */
  88        void *pf;
  89
  90        /* All L2 params that could change during the life span of the PF
  91         * and needs to be communicated to the client when they change
  92         */
  93        struct i40e_qvlist_info *qvlist_info;
  94        struct i40e_params params;
  95        struct i40e_ops *ops;
  96
  97        u16 msix_count;  /* number of msix vectors*/
  98        /* Array down below will be dynamically allocated based on msix_count */
  99        struct msix_entry *msix_entries;
 100        u16 itr_index; /* Which ITR index the PE driver is suppose to use */
 101        u16 fw_maj_ver;                 /* firmware major version */
 102        u16 fw_min_ver;                 /* firmware minor version */
 103        u32 fw_build;                   /* firmware build number */
 104};
 105
 106struct i40e_auxiliary_device {
 107        struct auxiliary_device aux_dev;
 108        struct i40e_info *ldev;
 109};
 110
 111#define I40E_CLIENT_RESET_LEVEL_PF   1
 112#define I40E_CLIENT_RESET_LEVEL_CORE 2
 113#define I40E_CLIENT_VSI_FLAG_TCP_ENABLE  BIT(1)
 114
 115struct i40e_ops {
 116        /* setup_q_vector_list enables queues with a particular vector */
 117        int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
 118                            struct i40e_qvlist_info *qv_info);
 119
 120        int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
 121                             u32 vf_id, u8 *msg, u16 len);
 122
 123        /* If the PE Engine is unresponsive, RDMA driver can request a reset.
 124         * The level helps determine the level of reset being requested.
 125         */
 126        void (*request_reset)(struct i40e_info *ldev,
 127                              struct i40e_client *client, u32 level);
 128
 129        /* API for the RDMA driver to set certain VSI flags that control
 130         * PE Engine.
 131         */
 132        int (*update_vsi_ctxt)(struct i40e_info *ldev,
 133                               struct i40e_client *client,
 134                               bool is_vf, u32 vf_id,
 135                               u32 flag, u32 valid_flag);
 136};
 137
 138struct i40e_client_ops {
 139        /* Should be called from register_client() or whenever PF is ready
 140         * to create a specific client instance.
 141         */
 142        int (*open)(struct i40e_info *ldev, struct i40e_client *client);
 143
 144        /* Should be called when netdev is unavailable or when unregister
 145         * call comes in. If the close is happenening due to a reset being
 146         * triggered set the reset bit to true.
 147         */
 148        void (*close)(struct i40e_info *ldev, struct i40e_client *client,
 149                      bool reset);
 150
 151        /* called when some l2 managed parameters changes - mtu */
 152        void (*l2_param_change)(struct i40e_info *ldev,
 153                                struct i40e_client *client,
 154                                struct i40e_params *params);
 155
 156        int (*virtchnl_receive)(struct i40e_info *ldev,
 157                                struct i40e_client *client, u32 vf_id,
 158                                u8 *msg, u16 len);
 159
 160        /* called when a VF is reset by the PF */
 161        void (*vf_reset)(struct i40e_info *ldev,
 162                         struct i40e_client *client, u32 vf_id);
 163
 164        /* called when the number of VFs changes */
 165        void (*vf_enable)(struct i40e_info *ldev,
 166                          struct i40e_client *client, u32 num_vfs);
 167
 168        /* returns true if VF is capable of specified offload */
 169        int (*vf_capable)(struct i40e_info *ldev,
 170                          struct i40e_client *client, u32 vf_id);
 171};
 172
 173/* Client device */
 174struct i40e_client_instance {
 175        struct list_head list;
 176        struct i40e_info lan_info;
 177        struct i40e_client *client;
 178        unsigned long  state;
 179};
 180
 181struct i40e_client {
 182        struct list_head list;          /* list of registered clients */
 183        char name[I40E_CLIENT_STR_LENGTH];
 184        struct i40e_client_version version;
 185        unsigned long state;            /* client state */
 186        atomic_t ref_cnt;  /* Count of all the client devices of this kind */
 187        u32 flags;
 188        u8 type;
 189#define I40E_CLIENT_IWARP 0
 190        const struct i40e_client_ops *ops; /* client ops provided by the client */
 191};
 192
 193static inline bool i40e_client_is_registered(struct i40e_client *client)
 194{
 195        return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
 196}
 197
 198void i40e_client_device_register(struct i40e_info *ldev, struct i40e_client *client);
 199void i40e_client_device_unregister(struct i40e_info *ldev);
 200
 201#endif /* _I40E_CLIENT_H_ */
 202