Commit | Line | Data |
---|---|---|
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 |
12 | struct 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 | ||
22 | struct hw_sb_info { | |
23 | u16 hw_sb_id; | |
24 | u8 sb_qid; | |
25 | u8 padding[5]; | |
26 | }; | |
27 | ||
37bff2b9 YM |
28 | enum { |
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) */ | |
39 | struct 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 | */ | |
47 | struct 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 */ | |
54 | struct pfvf_tlv { | |
55 | struct channel_tlv tl; | |
56 | u8 status; | |
57 | u8 padding[3]; | |
58 | }; | |
59 | ||
60 | /* response tlv used for most tlvs */ | |
61 | struct pfvf_def_resp_tlv { | |
62 | struct pfvf_tlv hdr; | |
63 | }; | |
64 | ||
65 | /* used to terminate and pad a tlv list */ | |
66 | struct 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 | ||
77 | struct 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 | ||
101 | struct pfvf_storm_stats { | |
102 | u32 address; | |
103 | u32 len; | |
104 | }; | |
105 | ||
106 | struct 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 | ||
113 | struct 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 |
173 | struct tlv_buffer_size { | |
174 | u8 tlv_buffer[TLV_BUFFER_SIZE]; | |
175 | }; | |
176 | ||
177 | union 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 | ||
184 | union 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 | ||
190 | struct 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 | ||
200 | struct qed_bulletin { | |
201 | dma_addr_t phys; | |
202 | struct qed_bulletin_content *p_virt; | |
203 | u32 size; | |
204 | }; | |
205 | ||
37bff2b9 YM |
206 | enum { |
207 | CHANNEL_TLV_NONE, /* ends tlv sequence */ | |
1408cc1f | 208 | CHANNEL_TLV_ACQUIRE, |
37bff2b9 YM |
209 | CHANNEL_TLV_LIST_END, |
210 | CHANNEL_TLV_MAX | |
211 | }; | |
212 | ||
1408cc1f YM |
213 | /* This data is held in the qed_hwfn structure for VFs only. */ |
214 | struct qed_vf_iov { | |
215 | union vfpf_tlvs *vf2pf_request; | |
216 | dma_addr_t vf2pf_request_phys; | |
217 | union pfvf_tlvs *pf2vf_reply; | |
218 | dma_addr_t pf2vf_reply_phys; | |
219 | ||
220 | /* Should be taken whenever the mailbox buffers are accessed */ | |
221 | struct mutex mutex; | |
222 | u8 *offset; | |
223 | ||
224 | /* Bulletin Board */ | |
225 | struct qed_bulletin bulletin; | |
226 | struct qed_bulletin_content bulletin_shadow; | |
227 | ||
228 | /* we set aside a copy of the acquire response */ | |
229 | struct pfvf_acquire_resp_tlv acquire_resp; | |
230 | }; | |
231 | ||
232 | #ifdef CONFIG_QED_SRIOV | |
233 | /** | |
234 | * @brief Get number of Rx queues allocated for VF by qed | |
235 | * | |
236 | * @param p_hwfn | |
237 | * @param num_rxqs - allocated RX queues | |
238 | */ | |
239 | void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs); | |
240 | ||
241 | /** | |
242 | * @brief Get port mac address for VF | |
243 | * | |
244 | * @param p_hwfn | |
245 | * @param port_mac - destination location for port mac | |
246 | */ | |
247 | void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac); | |
248 | ||
249 | /** | |
250 | * @brief Get number of VLAN filters allocated for VF by qed | |
251 | * | |
252 | * @param p_hwfn | |
253 | * @param num_rxqs - allocated VLAN filters | |
254 | */ | |
255 | void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn, | |
256 | u8 *num_vlan_filters); | |
257 | ||
258 | /** | |
259 | * @brief Set firmware version information in dev_info from VFs acquire response tlv | |
260 | * | |
261 | * @param p_hwfn | |
262 | * @param fw_major | |
263 | * @param fw_minor | |
264 | * @param fw_rev | |
265 | * @param fw_eng | |
266 | */ | |
267 | void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn, | |
268 | u16 *fw_major, u16 *fw_minor, | |
269 | u16 *fw_rev, u16 *fw_eng); | |
270 | ||
271 | /** | |
272 | * @brief hw preparation for VF | |
273 | * sends ACQUIRE message | |
274 | * | |
275 | * @param p_hwfn | |
276 | * | |
277 | * @return int | |
278 | */ | |
279 | int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn); | |
280 | ||
281 | /** | |
282 | * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given | |
283 | * sb_id. For VFs igu sbs don't have to be contiguous | |
284 | * | |
285 | * @param p_hwfn | |
286 | * @param sb_id | |
287 | * | |
288 | * @return INLINE u16 | |
289 | */ | |
290 | u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id); | |
291 | #else | |
292 | static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs) | |
293 | { | |
294 | } | |
295 | ||
296 | static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac) | |
297 | { | |
298 | } | |
299 | ||
300 | static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn, | |
301 | u8 *num_vlan_filters) | |
302 | { | |
303 | } | |
304 | ||
305 | static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn, | |
306 | u16 *fw_major, u16 *fw_minor, | |
307 | u16 *fw_rev, u16 *fw_eng) | |
308 | { | |
309 | } | |
310 | ||
311 | static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn) | |
312 | { | |
313 | return -EINVAL; | |
314 | } | |
315 | ||
316 | static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id) | |
317 | { | |
318 | return 0; | |
319 | } | |
320 | #endif | |
321 | ||
32a47e72 | 322 | #endif |