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 #define I40E_CLIENT_STR_LENGTH 10
9 /* Client interface version should be updated anytime there is a change in the
10 * existing APIs or data structures.
12 #define I40E_CLIENT_VERSION_MAJOR 0
13 #define I40E_CLIENT_VERSION_MINOR 01
14 #define I40E_CLIENT_VERSION_BUILD 00
15 #define I40E_CLIENT_VERSION_STR \
16 __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
17 __stringify(I40E_CLIENT_VERSION_MINOR) "." \
18 __stringify(I40E_CLIENT_VERSION_BUILD)
20 struct i40e_client_version {
27 enum i40e_client_state {
29 __I40E_CLIENT_REGISTERED
32 enum i40e_client_instance_state {
33 __I40E_CLIENT_INSTANCE_NONE,
34 __I40E_CLIENT_INSTANCE_OPENED,
40 #define I40E_QUEUE_INVALID_IDX 0xFFFF
43 u32 v_idx; /* msix_vector */
49 struct i40e_qvlist_info {
51 struct i40e_qv_info qv_info[1];
55 /* set of LAN parameters useful for clients managed by LAN */
57 /* Struct to hold per priority info */
58 struct i40e_prio_qos_params {
59 u16 qs_handle; /* qs handle for prio */
60 u8 tc; /* TC mapped to prio */
64 #define I40E_CLIENT_MAX_USER_PRIORITY 8
65 /* Struct to hold Client QoS */
66 struct i40e_qos_params {
67 struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
71 struct i40e_qos_params qos;
75 /* Structure to hold Lan device info for a client device */
77 struct i40e_client_version version;
79 struct net_device *netdev;
80 struct pci_dev *pcidev;
82 u8 fid; /* function id, PF id or VF id */
83 #define I40E_CLIENT_FTYPE_PF 0
84 u8 ftype; /* function type, PF or VF */
87 /* All L2 params that could change during the life span of the PF
88 * and needs to be communicated to the client when they change
90 struct i40e_qvlist_info *qvlist_info;
91 struct i40e_params params;
94 u16 msix_count; /* number of msix vectors*/
95 /* Array down below will be dynamically allocated based on msix_count */
96 struct msix_entry *msix_entries;
97 u16 itr_index; /* Which ITR index the PE driver is suppose to use */
98 u16 fw_maj_ver; /* firmware major version */
99 u16 fw_min_ver; /* firmware minor version */
100 u32 fw_build; /* firmware build number */
103 #define I40E_CLIENT_RESET_LEVEL_PF 1
104 #define I40E_CLIENT_RESET_LEVEL_CORE 2
105 #define I40E_CLIENT_VSI_FLAG_TCP_ENABLE BIT(1)
108 /* setup_q_vector_list enables queues with a particular vector */
109 int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
110 struct i40e_qvlist_info *qv_info);
112 int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
113 u32 vf_id, u8 *msg, u16 len);
115 /* If the PE Engine is unresponsive, RDMA driver can request a reset.
116 * The level helps determine the level of reset being requested.
118 void (*request_reset)(struct i40e_info *ldev,
119 struct i40e_client *client, u32 level);
121 /* API for the RDMA driver to set certain VSI flags that control
124 int (*update_vsi_ctxt)(struct i40e_info *ldev,
125 struct i40e_client *client,
126 bool is_vf, u32 vf_id,
127 u32 flag, u32 valid_flag);
130 struct i40e_client_ops {
131 /* Should be called from register_client() or whenever PF is ready
132 * to create a specific client instance.
134 int (*open)(struct i40e_info *ldev, struct i40e_client *client);
136 /* Should be called when netdev is unavailable or when unregister
137 * call comes in. If the close is happenening due to a reset being
138 * triggered set the reset bit to true.
140 void (*close)(struct i40e_info *ldev, struct i40e_client *client,
143 /* called when some l2 managed parameters changes - mtu */
144 void (*l2_param_change)(struct i40e_info *ldev,
145 struct i40e_client *client,
146 struct i40e_params *params);
148 int (*virtchnl_receive)(struct i40e_info *ldev,
149 struct i40e_client *client, u32 vf_id,
152 /* called when a VF is reset by the PF */
153 void (*vf_reset)(struct i40e_info *ldev,
154 struct i40e_client *client, u32 vf_id);
156 /* called when the number of VFs changes */
157 void (*vf_enable)(struct i40e_info *ldev,
158 struct i40e_client *client, u32 num_vfs);
160 /* returns true if VF is capable of specified offload */
161 int (*vf_capable)(struct i40e_info *ldev,
162 struct i40e_client *client, u32 vf_id);
166 struct i40e_client_instance {
167 struct list_head list;
168 struct i40e_info lan_info;
169 struct i40e_client *client;
174 struct list_head list; /* list of registered clients */
175 char name[I40E_CLIENT_STR_LENGTH];
176 struct i40e_client_version version;
177 unsigned long state; /* client state */
178 atomic_t ref_cnt; /* Count of all the client devices of this kind */
181 #define I40E_CLIENT_IWARP 0
182 const struct i40e_client_ops *ops; /* client ops provided by the client */
185 static inline bool i40e_client_is_registered(struct i40e_client *client)
187 return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
190 /* used by clients */
191 int i40e_register_client(struct i40e_client *client);
192 int i40e_unregister_client(struct i40e_client *client);
194 #endif /* _I40E_CLIENT_H_ */