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 /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
41 * In order for us to keep the interface simple, SW will define a
42 * unique type value for AEQ.
44 #define I40E_QUEUE_TYPE_PE_AEQ 0x80
45 #define I40E_QUEUE_INVALID_IDX 0xFFFF
48 u32 v_idx
; /* msix_vector */
54 struct i40e_qvlist_info
{
56 struct i40e_qv_info qv_info
[1];
59 #define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
61 /* set of LAN parameters useful for clients managed by LAN */
63 /* Struct to hold per priority info */
64 struct i40e_prio_qos_params
{
65 u16 qs_handle
; /* qs handle for prio */
66 u8 tc
; /* TC mapped to prio */
70 #define I40E_CLIENT_MAX_USER_PRIORITY 8
71 /* Struct to hold Client QoS */
72 struct i40e_qos_params
{
73 struct i40e_prio_qos_params prio_qos
[I40E_CLIENT_MAX_USER_PRIORITY
];
77 struct i40e_qos_params qos
;
81 /* Structure to hold Lan device info for a client device */
83 struct i40e_client_version version
;
85 struct net_device
*netdev
;
86 struct pci_dev
*pcidev
;
88 u8 fid
; /* function id, PF id or VF id */
89 #define I40E_CLIENT_FTYPE_PF 0
90 #define I40E_CLIENT_FTYPE_VF 1
91 u8 ftype
; /* function type, PF or VF */
94 /* All L2 params that could change during the life span of the PF
95 * and needs to be communicated to the client when they change
97 struct i40e_qvlist_info
*qvlist_info
;
98 struct i40e_params params
;
101 u16 msix_count
; /* number of msix vectors*/
102 /* Array down below will be dynamically allocated based on msix_count */
103 struct msix_entry
*msix_entries
;
104 u16 itr_index
; /* Which ITR index the PE driver is suppose to use */
105 u16 fw_maj_ver
; /* firmware major version */
106 u16 fw_min_ver
; /* firmware minor version */
107 u32 fw_build
; /* firmware build number */
110 #define I40E_CLIENT_RESET_LEVEL_PF 1
111 #define I40E_CLIENT_RESET_LEVEL_CORE 2
112 #define I40E_CLIENT_VSI_FLAG_TCP_ENABLE BIT(1)
115 /* setup_q_vector_list enables queues with a particular vector */
116 int (*setup_qvlist
)(struct i40e_info
*ldev
, struct i40e_client
*client
,
117 struct i40e_qvlist_info
*qv_info
);
119 int (*virtchnl_send
)(struct i40e_info
*ldev
, struct i40e_client
*client
,
120 u32 vf_id
, u8
*msg
, u16 len
);
122 /* If the PE Engine is unresponsive, RDMA driver can request a reset.
123 * The level helps determine the level of reset being requested.
125 void (*request_reset
)(struct i40e_info
*ldev
,
126 struct i40e_client
*client
, u32 level
);
128 /* API for the RDMA driver to set certain VSI flags that control
131 int (*update_vsi_ctxt
)(struct i40e_info
*ldev
,
132 struct i40e_client
*client
,
133 bool is_vf
, u32 vf_id
,
134 u32 flag
, u32 valid_flag
);
137 struct i40e_client_ops
{
138 /* Should be called from register_client() or whenever PF is ready
139 * to create a specific client instance.
141 int (*open
)(struct i40e_info
*ldev
, struct i40e_client
*client
);
143 /* Should be called when netdev is unavailable or when unregister
144 * call comes in. If the close is happenening due to a reset being
145 * triggered set the reset bit to true.
147 void (*close
)(struct i40e_info
*ldev
, struct i40e_client
*client
,
150 /* called when some l2 managed parameters changes - mtu */
151 void (*l2_param_change
)(struct i40e_info
*ldev
,
152 struct i40e_client
*client
,
153 struct i40e_params
*params
);
155 int (*virtchnl_receive
)(struct i40e_info
*ldev
,
156 struct i40e_client
*client
, u32 vf_id
,
159 /* called when a VF is reset by the PF */
160 void (*vf_reset
)(struct i40e_info
*ldev
,
161 struct i40e_client
*client
, u32 vf_id
);
163 /* called when the number of VFs changes */
164 void (*vf_enable
)(struct i40e_info
*ldev
,
165 struct i40e_client
*client
, u32 num_vfs
);
167 /* returns true if VF is capable of specified offload */
168 int (*vf_capable
)(struct i40e_info
*ldev
,
169 struct i40e_client
*client
, u32 vf_id
);
173 struct i40e_client_instance
{
174 struct list_head list
;
175 struct i40e_info lan_info
;
176 struct i40e_client
*client
;
181 struct list_head list
; /* list of registered clients */
182 char name
[I40E_CLIENT_STR_LENGTH
];
183 struct i40e_client_version version
;
184 unsigned long state
; /* client state */
185 atomic_t ref_cnt
; /* Count of all the client devices of this kind */
187 #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
188 #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
190 #define I40E_CLIENT_IWARP 0
191 const struct i40e_client_ops
*ops
; /* client ops provided by the client */
194 static inline bool i40e_client_is_registered(struct i40e_client
*client
)
196 return test_bit(__I40E_CLIENT_REGISTERED
, &client
->state
);
199 /* used by clients */
200 int i40e_register_client(struct i40e_client
*client
);
201 int i40e_unregister_client(struct i40e_client
*client
);
203 #endif /* _I40E_CLIENT_H_ */