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_instance_state {
30 __I40E_CLIENT_INSTANCE_NONE,
31 __I40E_CLIENT_INSTANCE_OPENED,
37 #define I40E_QUEUE_INVALID_IDX 0xFFFF
40 u32 v_idx; /* msix_vector */
46 struct i40e_qvlist_info {
48 struct i40e_qv_info qv_info[] __counted_by(num_vectors);
52 /* set of LAN parameters useful for clients managed by LAN */
54 /* Struct to hold per priority info */
55 struct i40e_prio_qos_params {
56 u16 qs_handle; /* qs handle for prio */
57 u8 tc; /* TC mapped to prio */
61 #define I40E_CLIENT_MAX_USER_PRIORITY 8
62 /* Struct to hold Client QoS */
63 struct i40e_qos_params {
64 struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
68 struct i40e_qos_params qos;
72 /* Structure to hold Lan device info for a client device */
74 struct i40e_client_version version;
76 struct net_device *netdev;
77 struct pci_dev *pcidev;
78 struct auxiliary_device *aux_dev;
80 u8 fid; /* function id, PF id or VF id */
81 #define I40E_CLIENT_FTYPE_PF 0
82 u8 ftype; /* function type, PF or VF */
85 /* All L2 params that could change during the life span of the PF
86 * and needs to be communicated to the client when they change
88 struct i40e_qvlist_info *qvlist_info;
89 struct i40e_params params;
92 u16 msix_count; /* number of msix vectors*/
93 /* Array down below will be dynamically allocated based on msix_count */
94 struct msix_entry *msix_entries;
95 u16 itr_index; /* Which ITR index the PE driver is suppose to use */
96 u16 fw_maj_ver; /* firmware major version */
97 u16 fw_min_ver; /* firmware minor version */
98 u32 fw_build; /* firmware build number */
101 struct i40e_auxiliary_device {
102 struct auxiliary_device aux_dev;
103 struct i40e_info *ldev;
106 #define I40E_CLIENT_RESET_LEVEL_PF 1
107 #define I40E_CLIENT_RESET_LEVEL_CORE 2
108 #define I40E_CLIENT_VSI_FLAG_TCP_ENABLE BIT(1)
111 /* setup_q_vector_list enables queues with a particular vector */
112 int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
113 struct i40e_qvlist_info *qv_info);
115 int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
116 u32 vf_id, u8 *msg, u16 len);
118 /* If the PE Engine is unresponsive, RDMA driver can request a reset.
119 * The level helps determine the level of reset being requested.
121 void (*request_reset)(struct i40e_info *ldev,
122 struct i40e_client *client, u32 level);
124 /* API for the RDMA driver to set certain VSI flags that control
127 int (*update_vsi_ctxt)(struct i40e_info *ldev,
128 struct i40e_client *client,
129 bool is_vf, u32 vf_id,
130 u32 flag, u32 valid_flag);
133 struct i40e_client_ops {
134 /* Should be called from register_client() or whenever PF is ready
135 * to create a specific client instance.
137 int (*open)(struct i40e_info *ldev, struct i40e_client *client);
139 /* Should be called when netdev is unavailable or when unregister
140 * call comes in. If the close is happenening due to a reset being
141 * triggered set the reset bit to true.
143 void (*close)(struct i40e_info *ldev, struct i40e_client *client,
146 /* called when some l2 managed parameters changes - mtu */
147 void (*l2_param_change)(struct i40e_info *ldev,
148 struct i40e_client *client,
149 struct i40e_params *params);
151 int (*virtchnl_receive)(struct i40e_info *ldev,
152 struct i40e_client *client, u32 vf_id,
155 /* called when a VF is reset by the PF */
156 void (*vf_reset)(struct i40e_info *ldev,
157 struct i40e_client *client, u32 vf_id);
159 /* called when the number of VFs changes */
160 void (*vf_enable)(struct i40e_info *ldev,
161 struct i40e_client *client, u32 num_vfs);
163 /* returns true if VF is capable of specified offload */
164 int (*vf_capable)(struct i40e_info *ldev,
165 struct i40e_client *client, u32 vf_id);
169 struct i40e_client_instance {
170 struct list_head list;
171 struct i40e_info lan_info;
172 struct i40e_client *client;
177 struct list_head list; /* list of registered clients */
178 char name[I40E_CLIENT_STR_LENGTH];
179 struct i40e_client_version version;
180 unsigned long state; /* client state */
181 atomic_t ref_cnt; /* Count of all the client devices of this kind */
184 #define I40E_CLIENT_IWARP 0
185 const struct i40e_client_ops *ops; /* client ops provided by the client */
188 void i40e_client_device_register(struct i40e_info *ldev, struct i40e_client *client);
189 void i40e_client_device_unregister(struct i40e_info *ldev);
191 #endif /* _I40E_CLIENT_H_ */