linux/drivers/net/ethernet/intel/i40e/i40e_client.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*******************************************************************************
   3 *
   4 * Intel Ethernet Controller XL710 Family Linux Driver
   5 * Copyright(c) 2013 - 2015 Intel Corporation.
   6 *
   7 * This program is free software; you can redistribute it and/or modify it
   8 * under the terms and conditions of the GNU General Public License,
   9 * version 2, as published by the Free Software Foundation.
  10 *
  11 * This program is distributed in the hope it will be useful, but WITHOUT
  12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  14 * more details.
  15 *
  16 * You should have received a copy of the GNU General Public License along
  17 * with this program.  If not, see <http://www.gnu.org/licenses/>.
  18 *
  19 * The full GNU General Public License is included in this distribution in
  20 * the file called "COPYING".
  21 *
  22 * Contact Information:
  23 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  25 *
  26 ******************************************************************************/
  27
  28#ifndef _I40E_CLIENT_H_
  29#define _I40E_CLIENT_H_
  30
  31#define I40E_CLIENT_STR_LENGTH 10
  32
  33/* Client interface version should be updated anytime there is a change in the
  34 * existing APIs or data structures.
  35 */
  36#define I40E_CLIENT_VERSION_MAJOR 0
  37#define I40E_CLIENT_VERSION_MINOR 01
  38#define I40E_CLIENT_VERSION_BUILD 00
  39#define I40E_CLIENT_VERSION_STR     \
  40        __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
  41        __stringify(I40E_CLIENT_VERSION_MINOR) "." \
  42        __stringify(I40E_CLIENT_VERSION_BUILD)
  43
  44struct i40e_client_version {
  45        u8 major;
  46        u8 minor;
  47        u8 build;
  48        u8 rsvd;
  49};
  50
  51enum i40e_client_state {
  52        __I40E_CLIENT_NULL,
  53        __I40E_CLIENT_REGISTERED
  54};
  55
  56enum i40e_client_instance_state {
  57        __I40E_CLIENT_INSTANCE_NONE,
  58        __I40E_CLIENT_INSTANCE_OPENED,
  59};
  60
  61struct i40e_ops;
  62struct i40e_client;
  63
  64/* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  65 * In order for us to keep the interface simple, SW will define a
  66 * unique type value for AEQ.
  67 */
  68#define I40E_QUEUE_TYPE_PE_AEQ  0x80
  69#define I40E_QUEUE_INVALID_IDX  0xFFFF
  70
  71struct i40e_qv_info {
  72        u32 v_idx; /* msix_vector */
  73        u16 ceq_idx;
  74        u16 aeq_idx;
  75        u8 itr_idx;
  76};
  77
  78struct i40e_qvlist_info {
  79        u32 num_vectors;
  80        struct i40e_qv_info qv_info[1];
  81};
  82
  83#define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
  84
  85/* set of LAN parameters useful for clients managed by LAN */
  86
  87/* Struct to hold per priority info */
  88struct i40e_prio_qos_params {
  89        u16 qs_handle; /* qs handle for prio */
  90        u8 tc; /* TC mapped to prio */
  91        u8 reserved;
  92};
  93
  94#define I40E_CLIENT_MAX_USER_PRIORITY        8
  95/* Struct to hold Client QoS */
  96struct i40e_qos_params {
  97        struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  98};
  99
 100struct i40e_params {
 101        struct i40e_qos_params qos;
 102        u16 mtu;
 103};
 104
 105/* Structure to hold Lan device info for a client device */
 106struct i40e_info {
 107        struct i40e_client_version version;
 108        u8 lanmac[6];
 109        struct net_device *netdev;
 110        struct pci_dev *pcidev;
 111        u8 __iomem *hw_addr;
 112        u8 fid; /* function id, PF id or VF id */
 113#define I40E_CLIENT_FTYPE_PF 0
 114#define I40E_CLIENT_FTYPE_VF 1
 115        u8 ftype; /* function type, PF or VF */
 116        void *pf;
 117
 118        /* All L2 params that could change during the life span of the PF
 119         * and needs to be communicated to the client when they change
 120         */
 121        struct i40e_qvlist_info *qvlist_info;
 122        struct i40e_params params;
 123        struct i40e_ops *ops;
 124
 125        u16 msix_count;  /* number of msix vectors*/
 126        /* Array down below will be dynamically allocated based on msix_count */
 127        struct msix_entry *msix_entries;
 128        u16 itr_index; /* Which ITR index the PE driver is suppose to use */
 129        u16 fw_maj_ver;                 /* firmware major version */
 130        u16 fw_min_ver;                 /* firmware minor version */
 131        u32 fw_build;                   /* firmware build number */
 132};
 133
 134#define I40E_CLIENT_RESET_LEVEL_PF   1
 135#define I40E_CLIENT_RESET_LEVEL_CORE 2
 136#define I40E_CLIENT_VSI_FLAG_TCP_ENABLE  BIT(1)
 137
 138struct i40e_ops {
 139        /* setup_q_vector_list enables queues with a particular vector */
 140        int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
 141                            struct i40e_qvlist_info *qv_info);
 142
 143        int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
 144                             u32 vf_id, u8 *msg, u16 len);
 145
 146        /* If the PE Engine is unresponsive, RDMA driver can request a reset.
 147         * The level helps determine the level of reset being requested.
 148         */
 149        void (*request_reset)(struct i40e_info *ldev,
 150                              struct i40e_client *client, u32 level);
 151
 152        /* API for the RDMA driver to set certain VSI flags that control
 153         * PE Engine.
 154         */
 155        int (*update_vsi_ctxt)(struct i40e_info *ldev,
 156                               struct i40e_client *client,
 157                               bool is_vf, u32 vf_id,
 158                               u32 flag, u32 valid_flag);
 159};
 160
 161struct i40e_client_ops {
 162        /* Should be called from register_client() or whenever PF is ready
 163         * to create a specific client instance.
 164         */
 165        int (*open)(struct i40e_info *ldev, struct i40e_client *client);
 166
 167        /* Should be called when netdev is unavailable or when unregister
 168         * call comes in. If the close is happenening due to a reset being
 169         * triggered set the reset bit to true.
 170         */
 171        void (*close)(struct i40e_info *ldev, struct i40e_client *client,
 172                      bool reset);
 173
 174        /* called when some l2 managed parameters changes - mtu */
 175        void (*l2_param_change)(struct i40e_info *ldev,
 176                                struct i40e_client *client,
 177                                struct i40e_params *params);
 178
 179        int (*virtchnl_receive)(struct i40e_info *ldev,
 180                                struct i40e_client *client, u32 vf_id,
 181                                u8 *msg, u16 len);
 182
 183        /* called when a VF is reset by the PF */
 184        void (*vf_reset)(struct i40e_info *ldev,
 185                         struct i40e_client *client, u32 vf_id);
 186
 187        /* called when the number of VFs changes */
 188        void (*vf_enable)(struct i40e_info *ldev,
 189                          struct i40e_client *client, u32 num_vfs);
 190
 191        /* returns true if VF is capable of specified offload */
 192        int (*vf_capable)(struct i40e_info *ldev,
 193                          struct i40e_client *client, u32 vf_id);
 194};
 195
 196/* Client device */
 197struct i40e_client_instance {
 198        struct list_head list;
 199        struct i40e_info lan_info;
 200        struct i40e_client *client;
 201        unsigned long  state;
 202};
 203
 204struct i40e_client {
 205        struct list_head list;          /* list of registered clients */
 206        char name[I40E_CLIENT_STR_LENGTH];
 207        struct i40e_client_version version;
 208        unsigned long state;            /* client state */
 209        atomic_t ref_cnt;  /* Count of all the client devices of this kind */
 210        u32 flags;
 211#define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE       BIT(0)
 212#define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS       BIT(2)
 213        u8 type;
 214#define I40E_CLIENT_IWARP 0
 215        const struct i40e_client_ops *ops; /* client ops provided by the client */
 216};
 217
 218static inline bool i40e_client_is_registered(struct i40e_client *client)
 219{
 220        return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
 221}
 222
 223/* used by clients */
 224int i40e_register_client(struct i40e_client *client);
 225int i40e_unregister_client(struct i40e_client *client);
 226
 227#endif /* _I40E_CLIENT_H_ */
 228