Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2017-2019,2021-2026 NXP
3 : : */
4 : :
5 : : /* System headers */
6 : : #include <stdio.h>
7 : : #include <inttypes.h>
8 : : #include <unistd.h>
9 : : #include <sys/types.h>
10 : :
11 : : #include <dpaa_ethdev.h>
12 : : #include <dpaa_flow.h>
13 : : #include <dpaa_mempool.h>
14 : : #include <rte_dpaa_logs.h>
15 : : #include <fmlib/fm_port_ext.h>
16 : : #include <fmlib/fm_vsp_ext.h>
17 : : #include <rte_pmd_dpaa.h>
18 : :
19 : : #define DPAA_MAX_NUM_ETH_DEV 8
20 : :
21 : : static inline
22 : : ioc_fm_pcd_extract_entry_t *
23 : : SCH_EXT_ARR(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
24 : : {
25 : : return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
26 : : }
27 : :
28 : : #define SCH_EXT_HDR(scheme_params, hdr_idx) \
29 : : SCH_EXT_ARR(scheme_params, hdr_idx)->extract_params.extract_by_hdr
30 : :
31 : : #define SCH_EXT_FULL_FLD(scheme_params, hdr_idx) \
32 : : SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
33 : :
34 : : /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
35 : : * ports).
36 : : */
37 : : static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
38 : :
39 : : /* FM global info */
40 : : struct dpaa_fm_info {
41 : : t_handle fman_handle;
42 : : t_handle pcd_handle;
43 : : };
44 : :
45 : : /*FM model to read and write from file */
46 : : struct dpaa_fm_model {
47 : : uint32_t dev_count;
48 : : uint8_t device_order[DPAA_MAX_NUM_ETH_DEV];
49 : : t_fm_port_params fm_port_params[DPAA_MAX_NUM_ETH_DEV];
50 : : t_handle netenv_devid[DPAA_MAX_NUM_ETH_DEV];
51 : : t_handle scheme_devid[DPAA_MAX_NUM_ETH_DEV][2];
52 : : };
53 : :
54 : : static struct dpaa_fm_info fm_info;
55 : : static struct dpaa_fm_model fm_model;
56 : : static const char *fm_log = "/tmp/fmdpdk.bin";
57 : :
58 : 0 : static void fm_prev_cleanup(void)
59 : : {
60 : : uint32_t fman_id = 0, i = 0, devid;
61 : 0 : struct dpaa_if dpaa_intf = {0};
62 : 0 : t_fm_pcd_params fm_pcd_params = {0};
63 : 0 : PMD_INIT_FUNC_TRACE();
64 : :
65 : 0 : fm_info.fman_handle = fm_open(fman_id);
66 [ # # ]: 0 : if (!fm_info.fman_handle) {
67 : 0 : DPAA_PMD_ERR("unable to open FMAN");
68 : 0 : return;
69 : : }
70 : :
71 : 0 : fm_pcd_params.h_fm = fm_info.fman_handle;
72 : 0 : fm_pcd_params.prs_support = true;
73 : 0 : fm_pcd_params.kg_support = true;
74 : : /* FM PCD Open */
75 : 0 : fm_info.pcd_handle = fm_pcd_open(&fm_pcd_params);
76 [ # # ]: 0 : if (!fm_info.pcd_handle) {
77 : 0 : DPAA_PMD_ERR("unable to open PCD");
78 : 0 : return;
79 : : }
80 : :
81 [ # # ]: 0 : while (i < fm_model.dev_count) {
82 : 0 : devid = fm_model.device_order[i];
83 : : /* FM Port Open */
84 : 0 : fm_model.fm_port_params[devid].h_fm = fm_info.fman_handle;
85 [ # # ]: 0 : if (dpaa_intf.port_handle) {
86 : 0 : fm_port_close(dpaa_intf.port_handle);
87 : 0 : dpaa_intf.port_handle = NULL;
88 : : }
89 : 0 : dpaa_intf.port_handle =
90 : 0 : fm_port_open(&fm_model.fm_port_params[devid]);
91 : 0 : dpaa_intf.scheme_handle[0] = fm_create_device(fm_info.pcd_handle,
92 : : fm_model.scheme_devid[devid][0]);
93 : 0 : dpaa_intf.scheme_count = 1;
94 [ # # ]: 0 : if (fm_model.scheme_devid[devid][1]) {
95 : 0 : dpaa_intf.scheme_handle[1] =
96 : 0 : fm_create_device(fm_info.pcd_handle,
97 : : fm_model.scheme_devid[devid][1]);
98 [ # # ]: 0 : if (dpaa_intf.scheme_handle[1])
99 : 0 : dpaa_intf.scheme_count++;
100 : : }
101 : :
102 : 0 : dpaa_intf.netenv_handle = fm_create_device(fm_info.pcd_handle,
103 : : fm_model.netenv_devid[devid]);
104 : 0 : i++;
105 [ # # ]: 0 : if (!dpaa_intf.netenv_handle ||
106 [ # # ]: 0 : !dpaa_intf.scheme_handle[0] ||
107 [ # # ]: 0 : !dpaa_intf.port_handle)
108 : 0 : continue;
109 : :
110 [ # # ]: 0 : if (dpaa_fm_deconfig(&dpaa_intf, NULL))
111 : 0 : DPAA_PMD_ERR("DPAA FM deconfig failed");
112 : : }
113 : :
114 [ # # ]: 0 : if (dpaa_fm_term())
115 : 0 : DPAA_PMD_ERR("DPAA FM term failed");
116 : :
117 : : memset(&fm_model, 0, sizeof(struct dpaa_fm_model));
118 : : }
119 : :
120 : 0 : void dpaa_write_fm_config_to_file(void)
121 : : {
122 : : size_t bytes_write;
123 : 0 : FILE *fp = fopen(fm_log, "wb");
124 : 0 : PMD_INIT_FUNC_TRACE();
125 : :
126 [ # # ]: 0 : if (!fp) {
127 : 0 : DPAA_PMD_ERR("File open failed");
128 : 0 : return;
129 : : }
130 : 0 : bytes_write = fwrite(&fm_model, sizeof(struct dpaa_fm_model), 1, fp);
131 [ # # ]: 0 : if (!bytes_write) {
132 : 0 : DPAA_PMD_WARN("No bytes write");
133 : 0 : fclose(fp);
134 : 0 : return;
135 : : }
136 : 0 : fclose(fp);
137 : : }
138 : :
139 : 0 : static void dpaa_read_fm_config_from_file(void)
140 : : {
141 : : size_t bytes_read;
142 : 0 : FILE *fp = fopen(fm_log, "rb");
143 : 0 : PMD_INIT_FUNC_TRACE();
144 : :
145 [ # # ]: 0 : if (!fp)
146 : : return;
147 : 0 : DPAA_PMD_INFO("Previous DPDK-FM config instance present, cleaning up.");
148 : :
149 : : bytes_read = fread(&fm_model, sizeof(struct dpaa_fm_model), 1, fp);
150 [ # # ]: 0 : if (!bytes_read) {
151 : 0 : DPAA_PMD_WARN("No bytes read");
152 : 0 : fclose(fp);
153 : 0 : return;
154 : : }
155 : 0 : fclose(fp);
156 : :
157 : : /*FM cleanup from previous configured app */
158 : 0 : fm_prev_cleanup();
159 : : }
160 : :
161 : : static inline int
162 : : set_hash_params_eth(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
163 : : {
164 : : int k;
165 : :
166 [ # # ]: 0 : for (k = 0; k < 2; k++) {
167 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
168 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
169 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
170 : : HEADER_TYPE_ETH;
171 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
172 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
173 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
174 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
175 [ # # ]: 0 : if (k == 0)
176 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth =
177 : : IOC_NET_HF_ETH_SA;
178 : : else
179 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth =
180 : : IOC_NET_HF_ETH_DA;
181 : 0 : hdr_idx++;
182 : : }
183 : : return hdr_idx;
184 : : }
185 : :
186 : : static inline int
187 : : set_hash_params_ipv4(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
188 : : {
189 : : int k;
190 : :
191 [ # # ]: 0 : for (k = 0; k < 2; k++) {
192 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
193 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
194 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
195 : : HEADER_TYPE_IPV4;
196 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
197 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
198 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
199 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
200 [ # # ]: 0 : if (k == 0)
201 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 =
202 : : ioc_net_hf_ipv_4_src_ip;
203 : : else
204 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 =
205 : : ioc_net_hf_ipv_4_dst_ip;
206 : 0 : hdr_idx++;
207 : : }
208 : : return hdr_idx;
209 : : }
210 : :
211 : : static inline int
212 : : set_hash_params_ipv6(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
213 : : {
214 : : int k;
215 : :
216 [ # # ]: 0 : for (k = 0; k < 2; k++) {
217 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
218 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
219 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
220 : : HEADER_TYPE_IPV6;
221 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
222 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
223 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
224 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
225 [ # # ]: 0 : if (k == 0)
226 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 =
227 : : ioc_net_hf_ipv_6_src_ip;
228 : : else
229 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 =
230 : : ioc_net_hf_ipv_6_dst_ip;
231 : 0 : hdr_idx++;
232 : : }
233 : : return hdr_idx;
234 : : }
235 : :
236 : : static inline int
237 : : set_hash_params_udp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
238 : : {
239 : : int k;
240 : :
241 [ # # ]: 0 : for (k = 0; k < 2; k++) {
242 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
243 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
244 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
245 : : HEADER_TYPE_UDP;
246 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
247 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
248 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
249 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
250 [ # # ]: 0 : if (k == 0)
251 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp =
252 : : IOC_NET_HF_UDP_PORT_SRC;
253 : : else
254 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp =
255 : : IOC_NET_HF_UDP_PORT_DST;
256 : 0 : hdr_idx++;
257 : : }
258 : : return hdr_idx;
259 : : }
260 : :
261 : : static inline int
262 : : set_hash_params_tcp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
263 : : {
264 : : int k;
265 : :
266 [ # # ]: 0 : for (k = 0; k < 2; k++) {
267 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
268 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
269 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
270 : : HEADER_TYPE_TCP;
271 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
272 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
273 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
274 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
275 [ # # ]: 0 : if (k == 0)
276 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp =
277 : : IOC_NET_HF_TCP_PORT_SRC;
278 : : else
279 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp =
280 : : IOC_NET_HF_TCP_PORT_DST;
281 : 0 : hdr_idx++;
282 : : }
283 : : return hdr_idx;
284 : : }
285 : :
286 : : static inline int
287 : : set_hash_params_sctp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
288 : : {
289 : : int k;
290 : :
291 [ # # ]: 0 : for (k = 0; k < 2; k++) {
292 : 0 : SCH_EXT_ARR(scheme_params, hdr_idx)->type =
293 : : e_IOC_FM_PCD_EXTRACT_BY_HDR;
294 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
295 : : HEADER_TYPE_SCTP;
296 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
297 : : e_IOC_FM_PCD_HDR_INDEX_NONE;
298 : 0 : SCH_EXT_HDR(scheme_params, hdr_idx).type =
299 : : e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
300 [ # # ]: 0 : if (k == 0)
301 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp =
302 : : IOC_NET_HF_SCTP_PORT_SRC;
303 : : else
304 : 0 : SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp =
305 : : IOC_NET_HF_SCTP_PORT_DST;
306 : 0 : hdr_idx++;
307 : : }
308 : : return hdr_idx;
309 : : }
310 : :
311 : : /* Set scheme params for hash distribution */
312 : 0 : static int set_scheme_params(ioc_fm_pcd_kg_scheme_params_t *scheme_params,
313 : : ioc_fm_pcd_net_env_params_t *dist_units,
314 : : struct dpaa_if *dpaa_intf,
315 : : struct fman_if *fif)
316 : : {
317 : : int dist_idx, hdr_idx = 0;
318 : 0 : PMD_INIT_FUNC_TRACE();
319 : :
320 [ # # ]: 0 : if (fif->num_profiles) {
321 : 0 : scheme_params->param.override_storage_profile = true;
322 : 0 : scheme_params->param.storage_profile.direct = true;
323 : : scheme_params->param.storage_profile.profile_select
324 : 0 : .direct_relative_profile_id = fm_default_vsp_id(fif);
325 : : }
326 : :
327 : 0 : scheme_params->param.use_hash = 1;
328 : 0 : scheme_params->param.modify = false;
329 : 0 : scheme_params->param.always_direct = false;
330 : 0 : scheme_params->param.scheme_counter.update = 1;
331 : 0 : scheme_params->param.scheme_counter.value = 0;
332 : 0 : scheme_params->param.next_engine = e_IOC_FM_PCD_DONE;
333 : 0 : scheme_params->param.base_fqid = dpaa_intf->rx_queues[0].fqid;
334 : 0 : scheme_params->param.net_env_params.net_env_id =
335 : 0 : dpaa_intf->netenv_handle;
336 : 0 : scheme_params->param.net_env_params.num_of_distinction_units =
337 : 0 : dist_units->param.num_of_distinction_units;
338 : :
339 : 0 : scheme_params->param.key_ext_and_hash.hash_dist_num_of_fqids =
340 : 0 : dpaa_intf->nb_rx_queues;
341 : 0 : scheme_params->param.key_ext_and_hash.num_of_used_extracts =
342 : : 2 * dist_units->param.num_of_distinction_units;
343 : :
344 : 0 : for (dist_idx = 0; dist_idx <
345 [ # # ]: 0 : dist_units->param.num_of_distinction_units;
346 : 0 : dist_idx++) {
347 [ # # # # : 0 : switch (dist_units->param.units[dist_idx].hdrs[0].hdr) {
# # # ]
348 : : case HEADER_TYPE_ETH:
349 : : hdr_idx = set_hash_params_eth(scheme_params, hdr_idx);
350 : : break;
351 : :
352 : : case HEADER_TYPE_IPV4:
353 : : hdr_idx = set_hash_params_ipv4(scheme_params, hdr_idx);
354 : : break;
355 : :
356 : : case HEADER_TYPE_IPV6:
357 : : hdr_idx = set_hash_params_ipv6(scheme_params, hdr_idx);
358 : : break;
359 : :
360 : : case HEADER_TYPE_UDP:
361 : : hdr_idx = set_hash_params_udp(scheme_params, hdr_idx);
362 : : break;
363 : :
364 : : case HEADER_TYPE_TCP:
365 : : hdr_idx = set_hash_params_tcp(scheme_params, hdr_idx);
366 : : break;
367 : :
368 : : case HEADER_TYPE_SCTP:
369 : : hdr_idx = set_hash_params_sctp(scheme_params, hdr_idx);
370 : : break;
371 : :
372 : 0 : default:
373 : 0 : DPAA_PMD_ERR("Invalid Distinction Unit");
374 : 0 : return -1;
375 : : }
376 : : }
377 : :
378 : : return 0;
379 : : }
380 : :
381 : 0 : static void set_dist_units(ioc_fm_pcd_net_env_params_t *dist_units,
382 : : uint64_t req_dist_set)
383 : : {
384 : : uint32_t loop = 0, dist_idx = 0, dist_field = 0;
385 : : int l2_configured = 0, ipv4_configured = 0, ipv6_configured = 0;
386 : : int udp_configured = 0, tcp_configured = 0, sctp_configured = 0;
387 : 0 : PMD_INIT_FUNC_TRACE();
388 : :
389 [ # # ]: 0 : if (!req_dist_set)
390 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr =
391 : : HEADER_TYPE_ETH;
392 : :
393 [ # # ]: 0 : while (req_dist_set) {
394 [ # # ]: 0 : if (req_dist_set % 2 != 0) {
395 : 0 : dist_field = 1U << loop;
396 [ # # # # : 0 : switch (dist_field) {
# # # ]
397 : 0 : case RTE_ETH_RSS_L2_PAYLOAD:
398 : :
399 [ # # ]: 0 : if (l2_configured)
400 : : break;
401 : : l2_configured = 1;
402 : :
403 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
404 : 0 : = HEADER_TYPE_ETH;
405 : 0 : break;
406 : :
407 : 0 : case RTE_ETH_RSS_IPV4:
408 : : case RTE_ETH_RSS_FRAG_IPV4:
409 : : case RTE_ETH_RSS_NONFRAG_IPV4_OTHER:
410 : :
411 [ # # ]: 0 : if (ipv4_configured)
412 : : break;
413 : : ipv4_configured = 1;
414 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
415 : 0 : = HEADER_TYPE_IPV4;
416 : 0 : break;
417 : :
418 : 0 : case RTE_ETH_RSS_IPV6:
419 : : case RTE_ETH_RSS_FRAG_IPV6:
420 : : case RTE_ETH_RSS_NONFRAG_IPV6_OTHER:
421 : : case RTE_ETH_RSS_IPV6_EX:
422 : :
423 [ # # ]: 0 : if (ipv6_configured)
424 : : break;
425 : : ipv6_configured = 1;
426 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
427 : 0 : = HEADER_TYPE_IPV6;
428 : 0 : break;
429 : :
430 : 0 : case RTE_ETH_RSS_NONFRAG_IPV4_TCP:
431 : : case RTE_ETH_RSS_NONFRAG_IPV6_TCP:
432 : : case RTE_ETH_RSS_IPV6_TCP_EX:
433 : :
434 [ # # ]: 0 : if (tcp_configured)
435 : : break;
436 : : tcp_configured = 1;
437 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
438 : 0 : = HEADER_TYPE_TCP;
439 : 0 : break;
440 : :
441 : 0 : case RTE_ETH_RSS_NONFRAG_IPV4_UDP:
442 : : case RTE_ETH_RSS_NONFRAG_IPV6_UDP:
443 : : case RTE_ETH_RSS_IPV6_UDP_EX:
444 : :
445 [ # # ]: 0 : if (udp_configured)
446 : : break;
447 : : udp_configured = 1;
448 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
449 : 0 : = HEADER_TYPE_UDP;
450 : 0 : break;
451 : :
452 : 0 : case RTE_ETH_RSS_NONFRAG_IPV4_SCTP:
453 : : case RTE_ETH_RSS_NONFRAG_IPV6_SCTP:
454 : :
455 [ # # ]: 0 : if (sctp_configured)
456 : : break;
457 : : sctp_configured = 1;
458 : :
459 : 0 : dist_units->param.units[dist_idx++].hdrs[0].hdr
460 : 0 : = HEADER_TYPE_SCTP;
461 : 0 : break;
462 : :
463 : 0 : default:
464 : 0 : DPAA_PMD_ERR("Bad flow distribution option");
465 : : }
466 : : }
467 : 0 : req_dist_set = req_dist_set >> 1;
468 : 0 : loop++;
469 : : }
470 : :
471 : : /* Dist units is set to dist_idx */
472 : 0 : dist_units->param.num_of_distinction_units = dist_idx;
473 : 0 : }
474 : :
475 : : /* Apply PCD configuration on interface */
476 : 0 : static inline int set_port_pcd(struct dpaa_if *dpaa_intf)
477 : : {
478 : : int ret = 0;
479 : : unsigned int idx;
480 : : ioc_fm_port_pcd_params_t pcd_param;
481 : : ioc_fm_port_pcd_prs_params_t prs_param;
482 : : ioc_fm_port_pcd_kg_params_t kg_param;
483 : :
484 : 0 : PMD_INIT_FUNC_TRACE();
485 : :
486 : : /* PCD support for hash distribution */
487 : : uint8_t pcd_support = e_FM_PORT_PCD_SUPPORT_PRS_AND_KG;
488 : :
489 : : memset(&pcd_param, 0, sizeof(pcd_param));
490 : : memset(&prs_param, 0, sizeof(prs_param));
491 : : memset(&kg_param, 0, sizeof(kg_param));
492 : :
493 : : /* Set parse params */
494 : 0 : prs_param.first_prs_hdr = HEADER_TYPE_ETH;
495 : :
496 : : /* Set kg params */
497 [ # # ]: 0 : for (idx = 0; idx < dpaa_intf->scheme_count; idx++)
498 : 0 : kg_param.scheme_ids[idx] = dpaa_intf->scheme_handle[idx];
499 : 0 : kg_param.num_schemes = dpaa_intf->scheme_count;
500 : :
501 : : /* Set pcd params */
502 : 0 : pcd_param.net_env_id = dpaa_intf->netenv_handle;
503 : 0 : pcd_param.pcd_support = pcd_support;
504 : 0 : pcd_param.p_kg_params = &kg_param;
505 : 0 : pcd_param.p_prs_params = &prs_param;
506 : :
507 : : /* FM PORT Disable */
508 : 0 : ret = fm_port_disable(dpaa_intf->port_handle);
509 [ # # ]: 0 : if (ret != E_OK) {
510 : 0 : DPAA_PMD_ERR("fm_port_disable: Failed");
511 : 0 : return ret;
512 : : }
513 : :
514 : : /* FM PORT SetPCD */
515 : 0 : ret = fm_port_set_pcd(dpaa_intf->port_handle, &pcd_param);
516 [ # # ]: 0 : if (ret != E_OK) {
517 : 0 : DPAA_PMD_ERR("fm_port_set_pcd: Failed");
518 : 0 : return ret;
519 : : }
520 : :
521 : : /* FM PORT Enable */
522 : 0 : ret = fm_port_enable(dpaa_intf->port_handle);
523 [ # # ]: 0 : if (ret != E_OK) {
524 : 0 : DPAA_PMD_ERR("fm_port_enable: Failed");
525 : 0 : goto fm_port_delete_pcd;
526 : : }
527 : :
528 : : return 0;
529 : :
530 : : fm_port_delete_pcd:
531 : : /* FM PORT DeletePCD */
532 : 0 : ret = fm_port_delete_pcd(dpaa_intf->port_handle);
533 [ # # ]: 0 : if (ret != E_OK) {
534 : 0 : DPAA_PMD_ERR("fm_port_delete_pcd: Failed");
535 : 0 : return ret;
536 : : }
537 : : return -1;
538 : : }
539 : :
540 : : /* Unset PCD NerEnv and scheme */
541 : 0 : static inline void unset_pcd_netenv_scheme(struct dpaa_if *dpaa_intf)
542 : : {
543 : : int ret;
544 : 0 : PMD_INIT_FUNC_TRACE();
545 : :
546 : : /* reduce scheme count */
547 [ # # ]: 0 : if (dpaa_intf->scheme_count)
548 : 0 : dpaa_intf->scheme_count--;
549 : :
550 : 0 : DPAA_PMD_DEBUG("KG SCHEME DEL %d handle =%p",
551 : : dpaa_intf->scheme_count,
552 : : dpaa_intf->scheme_handle[dpaa_intf->scheme_count]);
553 : :
554 : 0 : ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle
555 : 0 : [dpaa_intf->scheme_count]);
556 [ # # ]: 0 : if (ret != E_OK)
557 : 0 : DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed");
558 : :
559 : 0 : dpaa_intf->scheme_handle[dpaa_intf->scheme_count] = NULL;
560 : 0 : }
561 : :
562 : : /* Set PCD NetEnv and Scheme and default scheme */
563 : 0 : static inline int set_default_scheme(struct dpaa_if *dpaa_intf)
564 : : {
565 : : ioc_fm_pcd_kg_scheme_params_t scheme_params;
566 : 0 : int idx = dpaa_intf->scheme_count;
567 : 0 : PMD_INIT_FUNC_TRACE();
568 : :
569 : : /* Set PCD NetEnvCharacteristics */
570 : : memset(&scheme_params, 0, sizeof(scheme_params));
571 : :
572 : : /* Adding 10 to default schemes as the number of interface would be
573 : : * lesser than 10 and the relative scheme ids should be unique for
574 : : * every scheme.
575 : : */
576 : 0 : scheme_params.param.scm_id.relative_scheme_id =
577 : 0 : 10 + dpaa_intf->ifid;
578 : : scheme_params.param.use_hash = 0;
579 : 0 : scheme_params.param.next_engine = e_IOC_FM_PCD_DONE;
580 : : scheme_params.param.net_env_params.num_of_distinction_units = 0;
581 : 0 : scheme_params.param.net_env_params.net_env_id =
582 : 0 : dpaa_intf->netenv_handle;
583 : 0 : scheme_params.param.base_fqid = dpaa_intf->rx_queues[0].fqid;
584 : 0 : scheme_params.param.key_ext_and_hash.hash_dist_num_of_fqids = 1;
585 : : scheme_params.param.key_ext_and_hash.num_of_used_extracts = 0;
586 : : scheme_params.param.modify = false;
587 : : scheme_params.param.always_direct = false;
588 : 0 : scheme_params.param.scheme_counter.update = 1;
589 : : scheme_params.param.scheme_counter.value = 0;
590 : :
591 : : /* FM PCD KgSchemeSet */
592 : 0 : dpaa_intf->scheme_handle[idx] =
593 : 0 : fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params);
594 : 0 : DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p",
595 : : idx, dpaa_intf->scheme_handle[idx]);
596 [ # # ]: 0 : if (!dpaa_intf->scheme_handle[idx]) {
597 : 0 : DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed");
598 : 0 : return -1;
599 : : }
600 : :
601 : 0 : fm_model.scheme_devid[dpaa_intf->ifid][idx] =
602 : 0 : fm_get_device_id(dpaa_intf->scheme_handle[idx]);
603 : 0 : dpaa_intf->scheme_count++;
604 : 0 : return 0;
605 : : }
606 : :
607 : :
608 : : /* Set PCD NetEnv and Scheme and default scheme */
609 : 0 : static inline int set_pcd_netenv_scheme(struct dpaa_if *dpaa_intf,
610 : : uint64_t req_dist_set,
611 : : struct fman_if *fif)
612 : : {
613 : : int ret = -1;
614 : : ioc_fm_pcd_net_env_params_t dist_units;
615 : : ioc_fm_pcd_kg_scheme_params_t scheme_params;
616 : 0 : int idx = dpaa_intf->scheme_count;
617 : 0 : PMD_INIT_FUNC_TRACE();
618 : :
619 : : /* Set PCD NetEnvCharacteristics */
620 : : memset(&dist_units, 0, sizeof(dist_units));
621 : : memset(&scheme_params, 0, sizeof(scheme_params));
622 : :
623 : : /* Set dist unit header type */
624 : 0 : set_dist_units(&dist_units, req_dist_set);
625 : :
626 : 0 : scheme_params.param.scm_id.relative_scheme_id = dpaa_intf->ifid;
627 : :
628 : : /* Set PCD Scheme params */
629 : 0 : ret = set_scheme_params(&scheme_params, &dist_units, dpaa_intf, fif);
630 [ # # ]: 0 : if (ret) {
631 : 0 : DPAA_PMD_ERR("Set scheme params: Failed");
632 : 0 : return -1;
633 : : }
634 : :
635 : : /* FM PCD KgSchemeSet */
636 : 0 : dpaa_intf->scheme_handle[idx] =
637 : 0 : fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params);
638 : 0 : DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p",
639 : : idx, dpaa_intf->scheme_handle[idx]);
640 [ # # ]: 0 : if (!dpaa_intf->scheme_handle[idx]) {
641 : 0 : DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed");
642 : 0 : return -1;
643 : : }
644 : :
645 : 0 : fm_model.scheme_devid[dpaa_intf->ifid][idx] =
646 : 0 : fm_get_device_id(dpaa_intf->scheme_handle[idx]);
647 : 0 : dpaa_intf->scheme_count++;
648 : 0 : return 0;
649 : : }
650 : :
651 : :
652 : 0 : static inline int get_rx_port_type(struct fman_if *fif)
653 : : {
654 : : /* For onic ports, configure the VSP as offline ports so that
655 : : * kernel can configure correct port.
656 : : */
657 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal ||
658 : : fif->mac_type == fman_onic)
659 : : return e_FM_PORT_TYPE_OH_OFFLINE_PARSING;
660 : : /* For 1G fm-mac9 and fm-mac10 ports, configure the VSP as 10G
661 : : * ports so that kernel can configure correct port.
662 : : */
663 [ # # ]: 0 : else if (fif->mac_type == fman_mac_1g &&
664 [ # # ]: 0 : fif->mac_idx >= DPAA_10G_MAC_START_IDX)
665 : : return e_FM_PORT_TYPE_RX_10G;
666 [ # # ]: 0 : else if (fif->mac_type == fman_mac_1g)
667 : : return e_FM_PORT_TYPE_RX;
668 [ # # ]: 0 : else if (fif->mac_type == fman_mac_2_5g)
669 : : return e_FM_PORT_TYPE_RX_2_5G;
670 [ # # ]: 0 : else if (fif->mac_type == fman_mac_10g)
671 : : return e_FM_PORT_TYPE_RX_10G;
672 : :
673 : 0 : DPAA_PMD_ERR("MAC type unsupported");
674 : 0 : return e_FM_PORT_TYPE_DUMMY;
675 : : }
676 : :
677 : 0 : static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf,
678 : : uint64_t req_dist_set,
679 : : struct fman_if *fif)
680 : : {
681 : : t_fm_port_params fm_port_params;
682 : : ioc_fm_pcd_net_env_params_t dist_units;
683 : 0 : PMD_INIT_FUNC_TRACE();
684 : :
685 : : /* Memset FM port params */
686 : : memset(&fm_port_params, 0, sizeof(fm_port_params));
687 : :
688 : : /* Set FM port params */
689 : 0 : fm_port_params.h_fm = fm_info.fman_handle;
690 : 0 : fm_port_params.port_type = get_rx_port_type(fif);
691 : 0 : fm_port_params.port_id = mac_idx[fif->mac_idx];
692 : :
693 : : /* FM PORT Open */
694 : 0 : dpaa_intf->port_handle = fm_port_open(&fm_port_params);
695 [ # # ]: 0 : if (!dpaa_intf->port_handle) {
696 : 0 : DPAA_PMD_ERR("fm_port_open: Failed");
697 : 0 : return -1;
698 : : }
699 : :
700 : 0 : fm_model.fm_port_params[dpaa_intf->ifid] = fm_port_params;
701 : :
702 : : /* Set PCD NetEnvCharacteristics */
703 : : memset(&dist_units, 0, sizeof(dist_units));
704 : :
705 : : /* Set dist unit header type */
706 : 0 : set_dist_units(&dist_units, req_dist_set);
707 : :
708 : : /* FM PCD NetEnvCharacteristicsSet */
709 : 0 : dpaa_intf->netenv_handle =
710 : 0 : fm_pcd_net_env_characteristics_set(fm_info.pcd_handle,
711 : : &dist_units);
712 [ # # ]: 0 : if (!dpaa_intf->netenv_handle) {
713 : 0 : DPAA_PMD_ERR("fm_pcd_net_env_characteristics_set: Failed");
714 : 0 : return -1;
715 : : }
716 : :
717 : 0 : fm_model.netenv_devid[dpaa_intf->ifid] =
718 : 0 : fm_get_device_id(dpaa_intf->netenv_handle);
719 : :
720 : 0 : return 0;
721 : : }
722 : :
723 : : /* De-Configure DPAA FM */
724 : 0 : int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf,
725 : : struct fman_if *fif __rte_unused)
726 : : {
727 : : int ret;
728 : : unsigned int idx;
729 : :
730 : 0 : PMD_INIT_FUNC_TRACE();
731 : :
732 [ # # ]: 0 : if (!dpaa_intf->port_handle)
733 : : return 0;
734 : :
735 : : /* FM PORT Disable */
736 : 0 : ret = fm_port_disable(dpaa_intf->port_handle);
737 [ # # ]: 0 : if (ret != E_OK) {
738 : 0 : DPAA_PMD_ERR("fm_port_disable: Failed");
739 : 0 : return ret;
740 : : }
741 : :
742 : : /* FM PORT DeletePCD */
743 : 0 : ret = fm_port_delete_pcd(dpaa_intf->port_handle);
744 [ # # ]: 0 : if (ret != E_OK) {
745 : 0 : DPAA_PMD_ERR("fm_port_delete_pcd: Failed");
746 : 0 : return ret;
747 : : }
748 : :
749 [ # # ]: 0 : for (idx = 0; idx < dpaa_intf->scheme_count; idx++) {
750 : 0 : DPAA_PMD_DEBUG("KG SCHEME DEL %d, handle =%p",
751 : : idx, dpaa_intf->scheme_handle[idx]);
752 : : /* FM PCD KgSchemeDelete */
753 : 0 : ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle[idx]);
754 [ # # ]: 0 : if (ret != E_OK) {
755 : 0 : DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed");
756 : 0 : return ret;
757 : : }
758 : 0 : dpaa_intf->scheme_handle[idx] = NULL;
759 : : }
760 : : /* FM PCD NetEnvCharacteristicsDelete */
761 : 0 : ret = fm_pcd_net_env_characteristics_delete(dpaa_intf->netenv_handle);
762 [ # # ]: 0 : if (ret != E_OK) {
763 : 0 : DPAA_PMD_ERR("fm_pcd_net_env_characteristics_delete: Failed");
764 : 0 : return ret;
765 : : }
766 : 0 : dpaa_intf->netenv_handle = NULL;
767 : :
768 [ # # # # ]: 0 : if (fif && fif->is_shared_mac) {
769 : 0 : ret = fm_port_enable(dpaa_intf->port_handle);
770 [ # # ]: 0 : if (ret != E_OK) {
771 : 0 : DPAA_PMD_ERR("shared mac re-enable failed");
772 : 0 : return ret;
773 : : }
774 : : }
775 : :
776 : : /* FM PORT Close */
777 : 0 : fm_port_close(dpaa_intf->port_handle);
778 : 0 : dpaa_intf->port_handle = NULL;
779 : :
780 : : /* Set scheme count to 0 */
781 : 0 : dpaa_intf->scheme_count = 0;
782 : :
783 : 0 : return 0;
784 : : }
785 : :
786 : 0 : int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set)
787 : : {
788 : 0 : struct dpaa_if *dpaa_intf = dev->data->dev_private;
789 : 0 : struct fman_if *fif = dev->process_private;
790 : : int ret;
791 : : unsigned int i = 0;
792 : 0 : PMD_INIT_FUNC_TRACE();
793 : :
794 [ # # ]: 0 : if (dpaa_fm_deconfig(dpaa_intf, fif))
795 : 0 : DPAA_PMD_ERR("DPAA FM deconfig failed");
796 : :
797 [ # # ]: 0 : if (!dev->data->nb_rx_queues)
798 : : return 0;
799 : :
800 [ # # ]: 0 : if (dev->data->nb_rx_queues & (dev->data->nb_rx_queues - 1)) {
801 : 0 : DPAA_PMD_ERR("No of queues should be power of 2");
802 : 0 : return -1;
803 : : }
804 : :
805 : : /* Open FM Port and set it in port info */
806 : 0 : ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
807 [ # # ]: 0 : if (ret) {
808 : 0 : DPAA_PMD_ERR("Set FM Port handle: Failed");
809 : 0 : return -1;
810 : : }
811 : :
812 [ # # ]: 0 : if (fif->num_profiles) {
813 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++)
814 : 0 : dpaa_intf->rx_queues[i].vsp_id = fm_default_vsp_id(fif);
815 : :
816 : : i = 0;
817 : : }
818 : :
819 : : /* Set PCD netenv and scheme */
820 [ # # ]: 0 : if (req_dist_set) {
821 : 0 : ret = set_pcd_netenv_scheme(dpaa_intf, req_dist_set, fif);
822 [ # # ]: 0 : if (ret) {
823 : 0 : DPAA_PMD_ERR("Set PCD NetEnv and Scheme dist: Failed");
824 : 0 : goto unset_fm_port_handle;
825 : : }
826 : : }
827 : : /* Set default netenv and scheme */
828 [ # # ]: 0 : if (!fif->is_shared_mac) {
829 : 0 : ret = set_default_scheme(dpaa_intf);
830 [ # # ]: 0 : if (ret) {
831 : 0 : DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed");
832 : 0 : goto unset_pcd_netenv_scheme1;
833 : : }
834 : : }
835 : :
836 : : /* Set Port PCD */
837 : 0 : ret = set_port_pcd(dpaa_intf);
838 [ # # ]: 0 : if (ret) {
839 : 0 : DPAA_PMD_ERR("Set Port PCD: Failed");
840 : 0 : goto unset_pcd_netenv_scheme;
841 : : }
842 : :
843 [ # # ]: 0 : for (; i < fm_model.dev_count; i++)
844 [ # # ]: 0 : if (fm_model.device_order[i] == dpaa_intf->ifid)
845 : : return 0;
846 : :
847 : 0 : fm_model.device_order[fm_model.dev_count] = dpaa_intf->ifid;
848 : 0 : fm_model.dev_count++;
849 : :
850 : 0 : return 0;
851 : :
852 : : unset_pcd_netenv_scheme:
853 : 0 : unset_pcd_netenv_scheme(dpaa_intf);
854 : :
855 : 0 : unset_pcd_netenv_scheme1:
856 : 0 : unset_pcd_netenv_scheme(dpaa_intf);
857 : :
858 : 0 : unset_fm_port_handle:
859 : : /* FM PORT Close */
860 : 0 : fm_port_close(dpaa_intf->port_handle);
861 : 0 : dpaa_intf->port_handle = NULL;
862 : 0 : return -1;
863 : : }
864 : :
865 : 0 : int dpaa_fm_init(void)
866 : : {
867 : : t_handle fman_handle;
868 : : t_handle pcd_handle;
869 : 0 : t_fm_pcd_params fm_pcd_params = {0};
870 : : /* Hard-coded : fman id 0 since one fman is present in LS104x */
871 : : int fman_id = 0, ret;
872 : 0 : PMD_INIT_FUNC_TRACE();
873 : :
874 : 0 : dpaa_read_fm_config_from_file();
875 : :
876 : : /* FM Open */
877 : 0 : fman_handle = fm_open(fman_id);
878 [ # # ]: 0 : if (!fman_handle) {
879 : 0 : DPAA_PMD_ERR("fm_open: Failed");
880 : 0 : return -1;
881 : : }
882 : :
883 : : /* FM PCD Open */
884 : 0 : fm_pcd_params.h_fm = fman_handle;
885 : 0 : fm_pcd_params.prs_support = true;
886 : 0 : fm_pcd_params.kg_support = true;
887 : 0 : pcd_handle = fm_pcd_open(&fm_pcd_params);
888 [ # # ]: 0 : if (!pcd_handle) {
889 : 0 : fm_close(fman_handle);
890 : 0 : DPAA_PMD_ERR("fm_pcd_open: Failed");
891 : 0 : return -1;
892 : : }
893 : :
894 : : /* FM PCD Enable */
895 : 0 : ret = fm_pcd_enable(pcd_handle);
896 [ # # ]: 0 : if (ret) {
897 : 0 : DPAA_PMD_ERR("fm_pcd_enable: Failed");
898 : 0 : fm_pcd_close(pcd_handle);
899 : 0 : fm_close(fman_handle);
900 : 0 : return -1;
901 : : }
902 : :
903 : : /* Set fman and pcd handle in fm info */
904 : 0 : fm_info.fman_handle = fman_handle;
905 : 0 : fm_info.pcd_handle = pcd_handle;
906 : :
907 : 0 : return 0;
908 : : }
909 : :
910 : :
911 : : /* De-initialization of FM */
912 : 0 : int dpaa_fm_term(void)
913 : : {
914 : : int ret;
915 : :
916 : 0 : PMD_INIT_FUNC_TRACE();
917 : :
918 [ # # # # ]: 0 : if (fm_info.pcd_handle && fm_info.fman_handle) {
919 : : /* FM PCD Disable */
920 : 0 : ret = fm_pcd_disable(fm_info.pcd_handle);
921 [ # # ]: 0 : if (ret) {
922 : 0 : DPAA_PMD_ERR("fm_pcd_disable: Failed");
923 : 0 : return -1;
924 : : }
925 : :
926 : : /* FM PCD Close */
927 : 0 : fm_pcd_close(fm_info.pcd_handle);
928 : 0 : fm_info.pcd_handle = NULL;
929 : : }
930 : :
931 [ # # ]: 0 : if (fm_info.fman_handle) {
932 : : /* FM Close */
933 : 0 : fm_close(fm_info.fman_handle);
934 : 0 : fm_info.fman_handle = NULL;
935 : : }
936 : :
937 [ # # ]: 0 : if (access(fm_log, F_OK) != -1) {
938 : 0 : ret = remove(fm_log);
939 [ # # ]: 0 : if (ret)
940 : 0 : DPAA_PMD_ERR("File remove: Failed");
941 : : }
942 : : return 0;
943 : : }
944 : :
945 : 0 : static int dpaa_port_vsp_configure(struct dpaa_if *dpaa_intf,
946 : : uint8_t vsp_id, t_handle fman_handle, struct fman_if *fif)
947 : : {
948 : : struct dpaa_if_vsp *vsp;
949 : : t_fm_vsp_params vsp_params;
950 : : t_fm_buffer_prefix_content buf_prefix_cont;
951 : 0 : uint8_t idx = mac_idx[fif->mac_idx], i;
952 : : int ret;
953 : : struct t_fm_ext_pools *pools;
954 : :
955 [ # # ]: 0 : if (vsp_id >= DPAA_VSP_PROFILE_MAX_NUM) {
956 : 0 : DPAA_PMD_ERR("Invalid VSP ID(%d) >= max(%d)",
957 : : vsp_id, DPAA_VSP_PROFILE_MAX_NUM);
958 : 0 : return -EINVAL;
959 : : }
960 : :
961 [ # # ]: 0 : vsp = &dpaa_intf->vsp[vsp_id];
962 : :
963 : : memset(&vsp_params, 0, sizeof(vsp_params));
964 : 0 : vsp_params.h_fm = fman_handle;
965 : 0 : vsp_params.relative_profile_id = vsp_id;
966 [ # # ]: 0 : if (fif->mac_type == fman_offline_internal ||
967 : : fif->mac_type == fman_onic)
968 : 0 : vsp_params.port_params.port_id = fif->mac_idx;
969 : : else
970 : 0 : vsp_params.port_params.port_id = idx;
971 : :
972 : 0 : vsp_params.port_params.port_type = get_rx_port_type(fif);
973 [ # # ]: 0 : if (vsp_params.port_params.port_type == e_FM_PORT_TYPE_DUMMY) {
974 : 0 : DPAA_PMD_ERR("Mac type %d error", fif->mac_type);
975 : 0 : return -EINVAL;
976 : : }
977 : :
978 : : pools = &vsp_params.ext_buf_pools;
979 : :
980 : 0 : pools->num_of_pools_used = vsp->bp_num;
981 [ # # ]: 0 : for (i = 0; i < vsp->bp_num; i++) {
982 : 0 : pools->ext_buf_pool[i].id = vsp->bpid[i];
983 : 0 : pools->ext_buf_pool[i].size = vsp->size[i];
984 : : }
985 : :
986 : 0 : vsp->vsp_handle = fm_vsp_config(&vsp_params);
987 [ # # ]: 0 : if (!vsp->vsp_handle) {
988 : 0 : DPAA_PMD_ERR("Configure VSP[%d] failed!", vsp_id);
989 : 0 : return -EIO;
990 : : }
991 : :
992 : : /* configure the application buffer (structure, size and
993 : : * content)
994 : : */
995 : :
996 : : memset(&buf_prefix_cont, 0, sizeof(buf_prefix_cont));
997 : :
998 : 0 : buf_prefix_cont.priv_data_size = 16;
999 : 0 : buf_prefix_cont.data_align = 64;
1000 : 0 : buf_prefix_cont.pass_prs_result = true;
1001 : 0 : buf_prefix_cont.pass_time_stamp = true;
1002 : : buf_prefix_cont.pass_hash_result = false;
1003 : : buf_prefix_cont.pass_all_other_pcdinfo = false;
1004 : 0 : buf_prefix_cont.manip_ext_space =
1005 : : RTE_PKTMBUF_HEADROOM - DPAA_MBUF_HW_ANNOTATION;
1006 : :
1007 : 0 : ret = fm_vsp_config_buffer_prefix_content(vsp->vsp_handle,
1008 : : &buf_prefix_cont);
1009 [ # # ]: 0 : if (ret != E_OK) {
1010 : 0 : DPAA_PMD_ERR("Configure VSP[%d]'s buffer prefix failed(%d)!",
1011 : : vsp_id, ret);
1012 : 0 : return ret;
1013 : : }
1014 : :
1015 : : /* initialize the FM VSP module */
1016 : 0 : ret = fm_vsp_init(vsp->vsp_handle);
1017 [ # # ]: 0 : if (ret != E_OK) {
1018 : 0 : DPAA_PMD_ERR("Init VSP[%d] failed(%d)!", vsp_id, ret);
1019 : 0 : return ret;
1020 : : }
1021 : :
1022 : : return 0;
1023 : : }
1024 : :
1025 : 0 : int dpaa_port_vsp_update(struct dpaa_if *dpaa_intf,
1026 : : bool fmc_mode, uint8_t vsp_id, struct fman_if *fif)
1027 : : {
1028 : : int ret = 0;
1029 : : t_handle fman_handle;
1030 : : struct dpaa_if_vsp *vsp;
1031 : :
1032 [ # # ]: 0 : if (!fif->num_profiles) {
1033 : 0 : DPAA_PMD_ERR("%s: No multiple VSPs specified!",
1034 : : dpaa_intf->name);
1035 : 0 : return -EINVAL;
1036 : : }
1037 : :
1038 [ # # ]: 0 : if (vsp_id >= (fif->base_profile_id + fif->num_profiles)) {
1039 : 0 : DPAA_PMD_ERR("%s: Invalid VSP ID(%d) >= base(%d) + num(%d)",
1040 : : dpaa_intf->name, vsp_id, fif->base_profile_id,
1041 : : fif->num_profiles);
1042 : 0 : return -EINVAL;
1043 : : }
1044 : :
1045 [ # # # # ]: 0 : if (vsp_id == fif->base_profile_id && fif->is_shared_mac) {
1046 : : /* For shared interface, VSP of base
1047 : : * profile is default pool located in kernel.
1048 : : */
1049 : 0 : dpaa_intf->vsp[vsp_id].bp_num = 0;
1050 : 0 : dpaa_intf->vsp[vsp_id].vsp_handle = NULL;
1051 : 0 : return 0;
1052 : : }
1053 : :
1054 : : vsp = &dpaa_intf->vsp[vsp_id];
1055 : :
1056 [ # # ]: 0 : if (vsp->vsp_handle) {
1057 : 0 : ret = fm_vsp_free(vsp->vsp_handle);
1058 [ # # ]: 0 : if (ret != E_OK) {
1059 : 0 : DPAA_PMD_ERR("Free VSP[%d]'s handle failed(%d)",
1060 : : vsp_id, ret);
1061 : 0 : return ret;
1062 : : }
1063 : 0 : vsp->vsp_handle = NULL;
1064 : : }
1065 : :
1066 [ # # ]: 0 : if (fmc_mode)
1067 : 0 : fman_handle = fm_open(0);
1068 : : else
1069 : 0 : fman_handle = fm_info.fman_handle;
1070 : :
1071 : 0 : return dpaa_port_vsp_configure(dpaa_intf, vsp_id, fman_handle, fif);
1072 : : }
1073 : :
1074 : 0 : int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf)
1075 : : {
1076 : : int ret;
1077 : : uint8_t idx;
1078 : :
1079 [ # # ]: 0 : for (idx = 0; idx < DPAA_VSP_PROFILE_MAX_NUM; idx++) {
1080 [ # # ]: 0 : if (dpaa_intf->vsp[idx].vsp_handle) {
1081 : 0 : ret = fm_vsp_free(dpaa_intf->vsp[idx].vsp_handle);
1082 [ # # ]: 0 : if (ret != E_OK) {
1083 : 0 : DPAA_PMD_ERR("Free VSP[%d] failed(%d)",
1084 : : idx, ret);
1085 : 0 : return ret;
1086 : : }
1087 : 0 : dpaa_intf->vsp[idx].vsp_handle = NULL;
1088 : : }
1089 : : /* Drop cached pool parameters too. */
1090 : 0 : dpaa_intf->vsp[idx].bp_num = 0;
1091 : : }
1092 : :
1093 : : return E_OK;
1094 : : }
|