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