1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
4 #ifndef _I40E_CLIENT_H_
5 #define _I40E_CLIENT_H_
7 #include <linux/auxiliary_bus.h>
9 #define I40E_CLIENT_STR_LENGTH 10
11 /* Client interface version should be updated anytime there is a change in the
12 * existing APIs or data structures.
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)
22 struct i40e_client_version {
29 enum i40e_client_state {
31 __I40E_CLIENT_REGISTERED
34 enum i40e_client_instance_state {
35 __I40E_CLIENT_INSTANCE_NONE,
36 __I40E_CLIENT_INSTANCE_OPENED,
42 #define I40E_QUEUE_INVALID_IDX 0xFFFF
45 u32 v_idx; /* msix_vector */
51 struct i40e_qvlist_info {
53 struct i40e_qv_info qv_info[];
57 /* set of LAN parameters useful for clients managed by LAN */
59 /* Struct to hold per priority info */
60 struct i40e_prio_qos_params {
61 u16 qs_handle; /* qs handle for prio */
62 u8 tc; /* TC mapped to prio */
66 #define I40E_CLIENT_MAX_USER_PRIORITY 8
67 /* Struct to hold Client QoS */
68 struct i40e_qos_params {
69 struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
73 struct i40e_qos_params qos;
77 /* Structure to hold Lan device info for a client device */
79 struct i40e_client_version version;
81 struct net_device *netdev;
82 struct pci_dev *pcidev;
83 struct auxiliary_device *aux_dev;
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 */
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
93 struct i40e_qvlist_info *qvlist_info;
94 struct i40e_params params;
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 */
106 struct i40e_auxiliary_device {
107 struct auxiliary_device aux_dev;
108 struct i40e_info *ldev;
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)
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);
120 int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
121 u32 vf_id, u8 *msg, u16 len);
123 /* If the PE Engine is unresponsive, RDMA driver can request a reset.
124 * The level helps determine the level of reset being requested.
126 void (*request_reset)(struct i40e_info *ldev,
127 struct i40e_client *client, u32 level);
129 /* API for the RDMA driver to set certain VSI flags that control
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);
138 struct i40e_client_ops {
139 /* Should be called from register_client() or whenever PF is ready
140 * to create a specific client instance.
142 int (*open)(struct i40e_info *ldev, struct i40e_client *client);
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.
148 void (*close)(struct i40e_info *ldev, struct i40e_client *client,
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);
156 int (*virtchnl_receive)(struct i40e_info *ldev,
157 struct i40e_client *client, u32 vf_id,
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);
164 /* called when the number of VFs changes */
165 void (*vf_enable)(struct i40e_info *ldev,
166 struct i40e_client *client, u32 num_vfs);
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);
174 struct i40e_client_instance {
175 struct list_head list;
176 struct i40e_info lan_info;
177 struct i40e_client *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 */
189 #define I40E_CLIENT_IWARP 0
190 const struct i40e_client_ops *ops; /* client ops provided by the client */
193 static inline bool i40e_client_is_registered(struct i40e_client *client)
195 return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
198 void i40e_client_device_register(struct i40e_info *ldev, struct i40e_client *client);
199 void i40e_client_device_unregister(struct i40e_info *ldev);
201 #endif /* _I40E_CLIENT_H_ */