qed: IOV configure and FLR
[deliverable/linux.git] / drivers / net / ethernet / qlogic / qed / qed_vf.h
CommitLineData
32a47e72
YM
1/* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
3 *
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
6 * this source tree.
7 */
8
9#ifndef _QED_VF_H
10#define _QED_VF_H
11
1408cc1f
YM
12struct vf_pf_resc_request {
13 u8 num_rxqs;
14 u8 num_txqs;
15 u8 num_sbs;
16 u8 num_mac_filters;
17 u8 num_vlan_filters;
18 u8 num_mc_filters;
19 u16 padding;
20};
21
22struct hw_sb_info {
23 u16 hw_sb_id;
24 u8 sb_qid;
25 u8 padding[5];
26};
27
37bff2b9
YM
28enum {
29 PFVF_STATUS_WAITING,
30 PFVF_STATUS_SUCCESS,
31 PFVF_STATUS_FAILURE,
32 PFVF_STATUS_NOT_SUPPORTED,
33 PFVF_STATUS_NO_RESOURCE,
34 PFVF_STATUS_FORCED,
35};
36
37/* vf pf channel tlvs */
38/* general tlv header (used for both vf->pf request and pf->vf response) */
39struct channel_tlv {
40 u16 type;
41 u16 length;
42};
43
44/* header of first vf->pf tlv carries the offset used to calculate reponse
45 * buffer address
46 */
47struct vfpf_first_tlv {
48 struct channel_tlv tl;
49 u32 padding;
50 u64 reply_address;
51};
52
53/* header of pf->vf tlvs, carries the status of handling the request */
54struct pfvf_tlv {
55 struct channel_tlv tl;
56 u8 status;
57 u8 padding[3];
58};
59
60/* response tlv used for most tlvs */
61struct pfvf_def_resp_tlv {
62 struct pfvf_tlv hdr;
63};
64
65/* used to terminate and pad a tlv list */
66struct channel_list_end_tlv {
67 struct channel_tlv tl;
68 u8 padding[4];
69};
70
1408cc1f
YM
71#define VFPF_ACQUIRE_OS_LINUX (0)
72#define VFPF_ACQUIRE_OS_WINDOWS (1)
73#define VFPF_ACQUIRE_OS_ESX (2)
74#define VFPF_ACQUIRE_OS_SOLARIS (3)
75#define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
76
77struct vfpf_acquire_tlv {
78 struct vfpf_first_tlv first_tlv;
79
80 struct vf_pf_vfdev_info {
81#define VFPF_ACQUIRE_CAP_OBSOLETE (1 << 0)
82#define VFPF_ACQUIRE_CAP_100G (1 << 1) /* VF can support 100g */
83 u64 capabilities;
84 u8 fw_major;
85 u8 fw_minor;
86 u8 fw_revision;
87 u8 fw_engineering;
88 u32 driver_version;
89 u16 opaque_fid; /* ME register value */
90 u8 os_type; /* VFPF_ACQUIRE_OS_* value */
91 u8 padding[5];
92 } vfdev_info;
93
94 struct vf_pf_resc_request resc_request;
95
96 u64 bulletin_addr;
97 u32 bulletin_size;
98 u32 padding;
99};
100
101struct pfvf_storm_stats {
102 u32 address;
103 u32 len;
104};
105
106struct pfvf_stats_info {
107 struct pfvf_storm_stats mstats;
108 struct pfvf_storm_stats pstats;
109 struct pfvf_storm_stats tstats;
110 struct pfvf_storm_stats ustats;
111};
112
113struct pfvf_acquire_resp_tlv {
114 struct pfvf_tlv hdr;
115
116 struct pf_vf_pfdev_info {
117 u32 chip_num;
118 u32 mfw_ver;
119
120 u16 fw_major;
121 u16 fw_minor;
122 u16 fw_rev;
123 u16 fw_eng;
124
125 u64 capabilities;
126#define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
127#define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
128/* There are old PF versions where the PF might mistakenly override the sanity
129 * mechanism [version-based] and allow a VF that can't be supported to pass
130 * the acquisition phase.
131 * To overcome this, PFs now indicate that they're past that point and the new
132 * VFs would fail probe on the older PFs that fail to do so.
133 */
134#define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
135
136 u16 db_size;
137 u8 indices_per_sb;
138 u8 os_type;
139
140 /* These should match the PF's qed_dev values */
141 u16 chip_rev;
142 u8 dev_type;
143
144 u8 padding;
145
146 struct pfvf_stats_info stats_info;
147
148 u8 port_mac[ETH_ALEN];
149 u8 padding2[2];
150 } pfdev_info;
151
152 struct pf_vf_resc {
153#define PFVF_MAX_QUEUES_PER_VF 16
154#define PFVF_MAX_SBS_PER_VF 16
155 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
156 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
157 u8 cid[PFVF_MAX_QUEUES_PER_VF];
158
159 u8 num_rxqs;
160 u8 num_txqs;
161 u8 num_sbs;
162 u8 num_mac_filters;
163 u8 num_vlan_filters;
164 u8 num_mc_filters;
165 u8 padding[2];
166 } resc;
167
168 u32 bulletin_size;
169 u32 padding;
170};
171
32a47e72
YM
172#define TLV_BUFFER_SIZE 1024
173struct tlv_buffer_size {
174 u8 tlv_buffer[TLV_BUFFER_SIZE];
175};
176
177union vfpf_tlvs {
37bff2b9 178 struct vfpf_first_tlv first_tlv;
1408cc1f 179 struct vfpf_acquire_tlv acquire;
37bff2b9 180 struct channel_list_end_tlv list_end;
32a47e72
YM
181 struct tlv_buffer_size tlv_buf_size;
182};
183
184union pfvf_tlvs {
37bff2b9 185 struct pfvf_def_resp_tlv default_resp;
1408cc1f 186 struct pfvf_acquire_resp_tlv acquire_resp;
32a47e72
YM
187 struct tlv_buffer_size tlv_buf_size;
188};
189
190struct qed_bulletin_content {
191 /* crc of structure to ensure is not in mid-update */
192 u32 crc;
193
194 u32 version;
195
196 /* bitmap indicating which fields hold valid values */
197 u64 valid_bitmap;
198};
199
200struct qed_bulletin {
201 dma_addr_t phys;
202 struct qed_bulletin_content *p_virt;
203 u32 size;
204};
205
37bff2b9
YM
206enum {
207 CHANNEL_TLV_NONE, /* ends tlv sequence */
1408cc1f 208 CHANNEL_TLV_ACQUIRE,
0b55e27d
YM
209 CHANNEL_TLV_INT_CLEANUP,
210 CHANNEL_TLV_CLOSE,
211 CHANNEL_TLV_RELEASE,
37bff2b9
YM
212 CHANNEL_TLV_LIST_END,
213 CHANNEL_TLV_MAX
214};
215
1408cc1f
YM
216/* This data is held in the qed_hwfn structure for VFs only. */
217struct qed_vf_iov {
218 union vfpf_tlvs *vf2pf_request;
219 dma_addr_t vf2pf_request_phys;
220 union pfvf_tlvs *pf2vf_reply;
221 dma_addr_t pf2vf_reply_phys;
222
223 /* Should be taken whenever the mailbox buffers are accessed */
224 struct mutex mutex;
225 u8 *offset;
226
227 /* Bulletin Board */
228 struct qed_bulletin bulletin;
229 struct qed_bulletin_content bulletin_shadow;
230
231 /* we set aside a copy of the acquire response */
232 struct pfvf_acquire_resp_tlv acquire_resp;
233};
234
235#ifdef CONFIG_QED_SRIOV
236/**
237 * @brief Get number of Rx queues allocated for VF by qed
238 *
239 * @param p_hwfn
240 * @param num_rxqs - allocated RX queues
241 */
242void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
243
244/**
245 * @brief Get port mac address for VF
246 *
247 * @param p_hwfn
248 * @param port_mac - destination location for port mac
249 */
250void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
251
252/**
253 * @brief Get number of VLAN filters allocated for VF by qed
254 *
255 * @param p_hwfn
256 * @param num_rxqs - allocated VLAN filters
257 */
258void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
259 u8 *num_vlan_filters);
260
261/**
262 * @brief Set firmware version information in dev_info from VFs acquire response tlv
263 *
264 * @param p_hwfn
265 * @param fw_major
266 * @param fw_minor
267 * @param fw_rev
268 * @param fw_eng
269 */
270void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
271 u16 *fw_major, u16 *fw_minor,
272 u16 *fw_rev, u16 *fw_eng);
273
274/**
275 * @brief hw preparation for VF
276 * sends ACQUIRE message
277 *
278 * @param p_hwfn
279 *
280 * @return int
281 */
282int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
283
0b55e27d
YM
284/**
285 *
286 * @brief VF - send a close message to PF
287 *
288 * @param p_hwfn
289 *
290 * @return enum _qed_status
291 */
292int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
293
294/**
295 * @brief VF - free vf`s memories
296 *
297 * @param p_hwfn
298 *
299 * @return enum _qed_status
300 */
301int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
1408cc1f
YM
302/**
303 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
304 * sb_id. For VFs igu sbs don't have to be contiguous
305 *
306 * @param p_hwfn
307 * @param sb_id
308 *
309 * @return INLINE u16
310 */
311u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
0b55e27d
YM
312
313/**
314 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
315 *
316 * @param p_hwfn
317 *
318 * @return enum _qed_status
319 */
320int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
1408cc1f
YM
321#else
322static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
323{
324}
325
326static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
327{
328}
329
330static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
331 u8 *num_vlan_filters)
332{
333}
334
335static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
336 u16 *fw_major, u16 *fw_minor,
337 u16 *fw_rev, u16 *fw_eng)
338{
339}
340
341static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
342{
343 return -EINVAL;
344}
345
0b55e27d
YM
346static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
347{
348 return -EINVAL;
349}
350
351static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
352{
353 return -EINVAL;
354}
355
1408cc1f
YM
356static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
357{
358 return 0;
359}
0b55e27d
YM
360
361static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
362{
363 return -EINVAL;
364}
1408cc1f
YM
365#endif
366
32a47e72 367#endif
This page took 0.044262 seconds and 5 git commands to generate.