Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2017-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 <rte_dpaa_logs.h>
14 : : #include <fmlib/fm_port_ext.h>
15 : : #include <fmlib/fm_vsp_ext.h>
16 : :
17 : : #define FMC_OUTPUT_FORMAT_VER 0x106
18 : :
19 : : #define FMC_NAME_LEN 64
20 : : #define FMC_FMAN_NUM 2
21 : : #define FMC_PORTS_PER_FMAN 16
22 : : #define FMC_SCHEMES_NUM 32
23 : : #define FMC_SCHEME_PROTOCOLS_NUM 16
24 : : #define FMC_CC_NODES_NUM 512
25 : : #define FMC_REPLICATORS_NUM 16
26 : : #define FMC_PLC_NUM 64
27 : : #define MAX_SP_CODE_SIZE 0x7C0
28 : : #define FMC_MANIP_MAX 64
29 : : #define FMC_HMANIP_MAX 512
30 : : #define FMC_INSERT_MAX 56
31 : : #define FM_PCD_MAX_REPS 64
32 : :
33 : : typedef struct fmc_port_t {
34 : : e_fm_port_type type;
35 : : unsigned int number;
36 : : struct fm_pcd_net_env_params_t distinction_units;
37 : : struct ioc_fm_port_pcd_params_t pcd_param;
38 : : struct ioc_fm_port_pcd_prs_params_t prs_param;
39 : : struct ioc_fm_port_pcd_kg_params_t kg_param;
40 : : struct ioc_fm_port_pcd_cc_params_t cc_param;
41 : : char name[FMC_NAME_LEN];
42 : : char cctree_name[FMC_NAME_LEN];
43 : : t_handle handle;
44 : : t_handle env_id_handle;
45 : : t_handle env_id_dev_id;
46 : : t_handle cctree_handle;
47 : : t_handle cctree_dev_id;
48 : :
49 : : unsigned int schemes_count;
50 : : unsigned int schemes[FMC_SCHEMES_NUM];
51 : : unsigned int ccnodes_count;
52 : : unsigned int ccnodes[FMC_CC_NODES_NUM];
53 : : unsigned int htnodes_count;
54 : : unsigned int htnodes[FMC_CC_NODES_NUM];
55 : :
56 : : unsigned int replicators_count;
57 : : unsigned int replicators[FMC_REPLICATORS_NUM];
58 : : ioc_fm_port_vsp_alloc_params_t vsp_param;
59 : :
60 : : unsigned int ccroot_count;
61 : : unsigned int ccroot[FMC_CC_NODES_NUM];
62 : : enum ioc_fm_pcd_engine ccroot_type[FMC_CC_NODES_NUM];
63 : : unsigned int ccroot_manip[FMC_CC_NODES_NUM];
64 : :
65 : : unsigned int reasm_index;
66 : : } fmc_port;
67 : :
68 : : typedef struct fmc_fman_t {
69 : : unsigned int number;
70 : : unsigned int port_count;
71 : : unsigned int ports[FMC_PORTS_PER_FMAN];
72 : : char name[FMC_NAME_LEN];
73 : : t_handle handle;
74 : : char pcd_name[FMC_NAME_LEN];
75 : : t_handle pcd_handle;
76 : : unsigned int kg_payload_offset;
77 : :
78 : : unsigned int offload_support;
79 : :
80 : : unsigned int reasm_count;
81 : : struct fm_pcd_manip_params_t reasm[FMC_MANIP_MAX];
82 : : char reasm_name[FMC_MANIP_MAX][FMC_NAME_LEN];
83 : : t_handle reasm_handle[FMC_MANIP_MAX];
84 : : t_handle reasm_dev_id[FMC_MANIP_MAX];
85 : :
86 : : unsigned int frag_count;
87 : : struct fm_pcd_manip_params_t frag[FMC_MANIP_MAX];
88 : : char frag_name[FMC_MANIP_MAX][FMC_NAME_LEN];
89 : : t_handle frag_handle[FMC_MANIP_MAX];
90 : : t_handle frag_dev_id[FMC_MANIP_MAX];
91 : :
92 : : unsigned int hdr_count;
93 : : struct fm_pcd_manip_params_t hdr[FMC_HMANIP_MAX];
94 : : uint8_t insert_data[FMC_HMANIP_MAX][FMC_INSERT_MAX];
95 : : char hdr_name[FMC_HMANIP_MAX][FMC_NAME_LEN];
96 : : t_handle hdr_handle[FMC_HMANIP_MAX];
97 : : t_handle hdr_dev_id[FMC_HMANIP_MAX];
98 : : unsigned int hdr_has_next[FMC_HMANIP_MAX];
99 : : unsigned int hdr_next[FMC_HMANIP_MAX];
100 : : } fmc_fman;
101 : :
102 : : typedef enum fmc_apply_order_e {
103 : : fmcengine_start,
104 : : fmcengine_end,
105 : : fmcport_start,
106 : : fmcport_end,
107 : : fmcscheme,
108 : : fmcccnode,
109 : : fmchtnode,
110 : : fmccctree,
111 : : fmcpolicer,
112 : : fmcreplicator,
113 : : fmcmanipulation
114 : : } fmc_apply_order_e;
115 : :
116 : : typedef struct fmc_apply_order_t {
117 : : fmc_apply_order_e type;
118 : : unsigned int index;
119 : : } fmc_apply_order;
120 : :
121 : : struct fmc_model_t {
122 : : unsigned int format_version;
123 : : unsigned int sp_enable;
124 : : t_fm_pcd_prs_sw_params sp;
125 : : uint8_t spcode[MAX_SP_CODE_SIZE];
126 : :
127 : : unsigned int fman_count;
128 : : fmc_fman fman[FMC_FMAN_NUM];
129 : :
130 : : unsigned int port_count;
131 : : fmc_port port[FMC_FMAN_NUM * FMC_PORTS_PER_FMAN];
132 : :
133 : : unsigned int scheme_count;
134 : : char scheme_name[FMC_SCHEMES_NUM][FMC_NAME_LEN];
135 : : t_handle scheme_handle[FMC_SCHEMES_NUM];
136 : : t_handle scheme_dev_id[FMC_SCHEMES_NUM];
137 : : struct fm_pcd_kg_scheme_params_t scheme[FMC_SCHEMES_NUM];
138 : :
139 : : unsigned int ccnode_count;
140 : : char ccnode_name[FMC_CC_NODES_NUM][FMC_NAME_LEN];
141 : : t_handle ccnode_handle[FMC_CC_NODES_NUM];
142 : : t_handle ccnode_dev_id[FMC_CC_NODES_NUM];
143 : : struct fm_pcd_cc_node_params_t ccnode[FMC_CC_NODES_NUM];
144 : : uint8_t cckeydata[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]
145 : : [FM_PCD_MAX_SIZE_OF_KEY];
146 : : unsigned char ccmask[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]
147 : : [FM_PCD_MAX_SIZE_OF_KEY];
148 : : unsigned int
149 : : ccentry_action_index[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
150 : : enum ioc_fm_pcd_engine
151 : : ccentry_action_type[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
152 : : unsigned char ccentry_frag[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
153 : : unsigned int ccentry_manip[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
154 : : unsigned int ccmiss_action_index[FMC_CC_NODES_NUM];
155 : : enum ioc_fm_pcd_engine ccmiss_action_type[FMC_CC_NODES_NUM];
156 : : unsigned char ccmiss_frag[FMC_CC_NODES_NUM];
157 : : unsigned int ccmiss_manip[FMC_CC_NODES_NUM];
158 : :
159 : : unsigned int htnode_count;
160 : : char htnode_name[FMC_CC_NODES_NUM][FMC_NAME_LEN];
161 : : t_handle htnode_handle[FMC_CC_NODES_NUM];
162 : : t_handle htnode_dev_id[FMC_CC_NODES_NUM];
163 : : struct fm_pcd_hash_table_params_t htnode[FMC_CC_NODES_NUM];
164 : :
165 : : unsigned int htentry_count[FMC_CC_NODES_NUM];
166 : : struct ioc_fm_pcd_cc_key_params_t
167 : : htentry[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
168 : : uint8_t htkeydata[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]
169 : : [FM_PCD_MAX_SIZE_OF_KEY];
170 : : unsigned int
171 : : htentry_action_index[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
172 : : enum ioc_fm_pcd_engine
173 : : htentry_action_type[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
174 : : unsigned char htentry_frag[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
175 : : unsigned int htentry_manip[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS];
176 : :
177 : : unsigned int htmiss_action_index[FMC_CC_NODES_NUM];
178 : : enum ioc_fm_pcd_engine htmiss_action_type[FMC_CC_NODES_NUM];
179 : : unsigned char htmiss_frag[FMC_CC_NODES_NUM];
180 : : unsigned int htmiss_manip[FMC_CC_NODES_NUM];
181 : :
182 : : unsigned int replicator_count;
183 : : char replicator_name[FMC_REPLICATORS_NUM][FMC_NAME_LEN];
184 : : t_handle replicator_handle[FMC_REPLICATORS_NUM];
185 : : t_handle replicator_dev_id[FMC_REPLICATORS_NUM];
186 : : struct fm_pcd_frm_replic_group_params_t replicator[FMC_REPLICATORS_NUM];
187 : : unsigned int
188 : : repentry_action_index[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS];
189 : : unsigned char repentry_frag[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS];
190 : : unsigned int repentry_manip[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS];
191 : :
192 : : unsigned int policer_count;
193 : : char policer_name[FMC_PLC_NUM][FMC_NAME_LEN];
194 : : struct fm_pcd_plcr_profile_params_t policer[FMC_PLC_NUM];
195 : : t_handle policer_handle[FMC_PLC_NUM];
196 : : t_handle policer_dev_id[FMC_PLC_NUM];
197 : : unsigned int policer_action_index[FMC_PLC_NUM][3];
198 : :
199 : : unsigned int apply_order_count;
200 : : fmc_apply_order apply_order[FMC_FMAN_NUM *
201 : : FMC_PORTS_PER_FMAN *
202 : : (FMC_SCHEMES_NUM + FMC_CC_NODES_NUM)];
203 : : };
204 : :
205 : : static struct fmc_model_t *g_fmc_model;
206 : :
207 : : #define FMC_PORT_NAME_MAC "MAC/"
208 : : #define FMC_PORT_NAME_OFFLINE "OFFLINE/"
209 : :
210 : : static int
211 : 0 : dpaa_port_fmc_get_idx_from_name(const char *name)
212 : : {
213 : : const char *found;
214 : : char *endptr;
215 : : int idx_str_start = -1, idx;
216 : :
217 : 0 : found = strstr(name, FMC_PORT_NAME_MAC);
218 [ # # ]: 0 : if (!found) {
219 : 0 : found = strstr(name, FMC_PORT_NAME_OFFLINE);
220 [ # # ]: 0 : if (found)
221 : : idx_str_start = strlen(FMC_PORT_NAME_OFFLINE);
222 : : } else {
223 : : idx_str_start = strlen(FMC_PORT_NAME_MAC);
224 : : }
225 : :
226 [ # # ]: 0 : if (!found) {
227 : : /* Not a port name this driver recognises. The caller treats a
228 : : * negative return as "not this port", so this is not an error.
229 : : */
230 : 0 : DPAA_PMD_DEBUG("Not a MAC or offline fmc port name: %s", name);
231 : 0 : return -EINVAL;
232 : : }
233 : :
234 : 0 : idx = (int)strtol(&found[idx_str_start], &endptr, 10);
235 [ # # # # ]: 0 : if (endptr == &found[idx_str_start] || (*endptr != '\0' && *endptr != '/')) {
236 : 0 : DPAA_PMD_DEBUG("No index in fmc port name: %s", name);
237 : 0 : return -EINVAL;
238 : : }
239 : :
240 : 0 : DPAA_PMD_DEBUG("MAC index of %s is %d", name, idx);
241 : :
242 : 0 : return idx;
243 : : }
244 : :
245 : : static int
246 : 0 : dpaa_port_fmc_port_parse(struct fman_if *fif,
247 : : const struct fmc_model_t *fmc_model,
248 : : int apply_idx)
249 : : {
250 : 0 : int current_port = fmc_model->apply_order[apply_idx].index;
251 : : const fmc_port *pport = &fmc_model->port[current_port];
252 : : int num;
253 : :
254 : : /* Offline and ONIC ports are matched on the port number from the FMC
255 : : * model, so no name parsing is needed for them.
256 : : */
257 [ # # ]: 0 : if (pport->type == e_FM_PORT_TYPE_OH_OFFLINE_PARSING &&
258 [ # # ]: 0 : pport->number == fif->mac_idx &&
259 [ # # ]: 0 : (fif->mac_type == fman_offline_internal ||
260 : : fif->mac_type == fman_onic))
261 : : return current_port;
262 : :
263 [ # # # # ]: 0 : if (fif->mac_type == fman_mac_1g &&
264 : : pport->type != e_FM_PORT_TYPE_RX)
265 : : return -ENODEV;
266 : :
267 [ # # # # ]: 0 : if (fif->mac_type == fman_mac_2_5g &&
268 : : pport->type != e_FM_PORT_TYPE_RX_2_5G)
269 : : return -ENODEV;
270 : :
271 [ # # # # ]: 0 : if (fif->mac_type == fman_mac_10g &&
272 : : pport->type != e_FM_PORT_TYPE_RX_10G)
273 : : return -ENODEV;
274 : :
275 [ # # ]: 0 : if (fif->mac_type != fman_mac_1g &&
276 [ # # ]: 0 : fif->mac_type != fman_mac_2_5g &&
277 : : fif->mac_type != fman_mac_10g) {
278 : 0 : DPAA_PMD_ERR("Unknown mac_type(%d) for port %s",
279 : : fif->mac_type, pport->name);
280 : 0 : return -EINVAL;
281 : : }
282 : :
283 : 0 : num = dpaa_port_fmc_get_idx_from_name(pport->name);
284 [ # # ]: 0 : if (num < 0)
285 : : return num;
286 : :
287 [ # # ]: 0 : if (fif->mac_idx == num)
288 : 0 : return current_port;
289 : :
290 : : return -ENODEV;
291 : : }
292 : :
293 : : static int
294 : : dpaa_fq_is_in_kernel(uint32_t fqid,
295 : : struct fman_if *fif)
296 : : {
297 [ # # # # ]: 0 : if (!fif->is_shared_mac)
298 : : return false;
299 : :
300 [ # # # # : 0 : if ((fqid == fif->fqid_rx_def ||
# # ]
301 [ # # # # : 0 : (fqid >= fif->fqid_rx_pcd &&
# # ]
302 [ # # # # : 0 : fqid < (fif->fqid_rx_pcd + fif->fqid_rx_pcd_count)) ||
# # ]
303 [ # # # # : 0 : fqid == fif->fqid_rx_err ||
# # ]
304 [ # # # # : 0 : fqid == fif->fqid_tx_err))
# # ]
305 : : return true;
306 : :
307 : : return false;
308 : : }
309 : :
310 : : static int
311 : : dpaa_vsp_id_is_in_kernel(uint8_t vsp_id,
312 : : struct fman_if *fif)
313 : : {
314 [ # # ]: 0 : if (!fif->is_shared_mac)
315 : : return false;
316 : :
317 [ # # ]: 0 : if (vsp_id == fif->base_profile_id)
318 : : return true;
319 : :
320 : : return false;
321 : : }
322 : :
323 : : static uint8_t
324 : : dpaa_enqueue_vsp_id(struct fman_if *fif,
325 : : const struct ioc_fm_pcd_cc_next_enqueue_params_t *eq_param)
326 : : {
327 : 0 : if (eq_param->override_fqid)
328 : 0 : return eq_param->new_relative_storage_profile_id;
329 : :
330 : 0 : return fif->base_profile_id;
331 : : }
332 : :
333 : : static int
334 : : dpaa_kg_storage_is_in_kernel(struct fman_if *fif,
335 : : const struct ioc_fm_pcd_kg_storage_profile_t *kg_storage)
336 : : {
337 [ # # ]: 0 : if (!fif->is_shared_mac)
338 : : return false;
339 : :
340 [ # # ]: 0 : if (!kg_storage->direct ||
341 : 0 : (kg_storage->direct &&
342 : 0 : kg_storage->profile_select.direct_relative_profile_id ==
343 [ # # ]: 0 : fif->base_profile_id))
344 : : return true;
345 : :
346 : : return false;
347 : : }
348 : :
349 : : static void
350 : 0 : dpaa_fmc_remove_fq_from_allocated(uint32_t *fqids,
351 : : uint16_t *rxq_idx, uint32_t rm_fqid)
352 : : {
353 : : uint32_t i;
354 : :
355 [ # # ]: 0 : for (i = 0; i < (*rxq_idx); i++) {
356 [ # # ]: 0 : if (fqids[i] != rm_fqid)
357 : : continue;
358 : 0 : DPAA_PMD_WARN("Remove fq(0x%08x) allocated.",
359 : : rm_fqid);
360 [ # # ]: 0 : if ((*rxq_idx) > (i + 1)) {
361 : 0 : memmove(&fqids[i], &fqids[i + 1],
362 : 0 : ((*rxq_idx) - (i + 1)) * sizeof(uint32_t));
363 : : }
364 : 0 : (*rxq_idx)--;
365 : 0 : break;
366 : : }
367 : 0 : }
368 : :
369 : : static int
370 : 0 : dpaa_port_fmc_scheme_parse(struct fman_if *fif,
371 : : const struct fmc_model_t *fmc,
372 : : int apply_idx,
373 : : uint16_t *rxq_idx, int max_nb_rxq,
374 : : uint32_t *fqids, int8_t *vspids)
375 : : {
376 : 0 : int scheme_idx = fmc->apply_order[apply_idx].index;
377 : : int k, found = 0;
378 : 0 : uint32_t i, num_rxq, fqid, rxq_idx_start = *rxq_idx;
379 : : const struct fm_pcd_kg_scheme_params_t *scheme;
380 : : const struct ioc_fm_pcd_kg_key_extract_and_hash_params_t *params;
381 : : const struct ioc_fm_pcd_kg_storage_profile_t *kg_storage;
382 : : uint8_t vsp_id;
383 : :
384 : : scheme = &fmc->scheme[scheme_idx];
385 : : params = &scheme->key_ext_and_hash;
386 : 0 : num_rxq = params->hash_dist_num_of_fqids;
387 : : kg_storage = &scheme->storage_profile;
388 : :
389 [ # # # # ]: 0 : if (scheme->override_storage_profile && kg_storage->direct)
390 : 0 : vsp_id = kg_storage->profile_select.direct_relative_profile_id;
391 : : else
392 : 0 : vsp_id = fif->base_profile_id;
393 : :
394 : : if (dpaa_kg_storage_is_in_kernel(fif, kg_storage)) {
395 : 0 : DPAA_PMD_WARN("Scheme[%d]'s VSP is in kernel",
396 : : scheme_idx);
397 : : /* The FQ may be allocated from previous CC or scheme,
398 : : * find and remove it.
399 : : */
400 [ # # ]: 0 : for (i = 0; i < num_rxq; i++) {
401 : 0 : fqid = scheme->base_fqid + i;
402 : 0 : DPAA_PMD_WARN("Removed fqid(0x%08x) of Scheme[%d]",
403 : : fqid, scheme_idx);
404 : 0 : dpaa_fmc_remove_fq_from_allocated(fqids,
405 : : rxq_idx, fqid);
406 : : if (!dpaa_fq_is_in_kernel(fqid, fif)) {
407 : : char reason_msg[128];
408 : : char result_msg[128];
409 : :
410 : : sprintf(reason_msg,
411 : : "NOT handled in kernel");
412 : : sprintf(result_msg,
413 : : "will DRAIN kernel pool!");
414 : 0 : DPAA_PMD_WARN("Traffic to FQ(%08x)(%s) %s",
415 : : fqid, reason_msg, result_msg);
416 : : }
417 : : }
418 : :
419 : : return 0;
420 : : }
421 : :
422 [ # # ]: 0 : if (e_IOC_FM_PCD_DONE != scheme->next_engine) {
423 : : /* Do nothing.*/
424 : 0 : DPAA_PMD_DEBUG("Will parse scheme[%d]'s next engine(%d)",
425 : : scheme_idx, scheme->next_engine);
426 : 0 : return 0;
427 : : }
428 : :
429 [ # # ]: 0 : for (i = 0; i < num_rxq; i++) {
430 [ # # ]: 0 : fqid = scheme->base_fqid + i;
431 : : found = 0;
432 : :
433 : 0 : if (dpaa_fq_is_in_kernel(fqid, fif)) {
434 : 0 : DPAA_PMD_WARN("FQ(0x%08x) is handled in kernel.",
435 : : fqid);
436 : : /* The FQ may be allocated from previous CC or scheme,
437 : : * remove it.
438 : : */
439 : 0 : dpaa_fmc_remove_fq_from_allocated(fqids,
440 : : rxq_idx, fqid);
441 : 0 : continue;
442 : : }
443 : :
444 [ # # ]: 0 : if ((*rxq_idx) >= max_nb_rxq) {
445 : 0 : DPAA_PMD_WARN("Too many queues(%d) >= MAX number(%d)",
446 : : (*rxq_idx), max_nb_rxq);
447 : :
448 : 0 : break;
449 : : }
450 : :
451 [ # # ]: 0 : for (k = 0; k < (*rxq_idx); k++) {
452 [ # # ]: 0 : if (fqids[k] == fqid) {
453 : : found = 1;
454 : : break;
455 : : }
456 : : }
457 : :
458 [ # # ]: 0 : if (found)
459 : 0 : continue;
460 : 0 : fqids[(*rxq_idx)] = fqid;
461 : 0 : vspids[(*rxq_idx)] = vsp_id;
462 : :
463 : 0 : (*rxq_idx)++;
464 : : }
465 : :
466 : 0 : return (*rxq_idx) - rxq_idx_start;
467 : : }
468 : :
469 : : static int
470 : 0 : dpaa_port_fmc_ccnode_parse(struct fman_if *fif,
471 : : const struct fmc_model_t *fmc,
472 : : int apply_idx,
473 : : uint16_t *rxq_idx, int max_nb_rxq,
474 : : uint32_t *fqids, int8_t *vspids)
475 : : {
476 : : uint16_t j, k, found = 0;
477 : : const struct ioc_keys_params_t *keys_params;
478 : : const struct ioc_fm_pcd_cc_next_engine_params_t *params;
479 : 0 : uint32_t fqid, cc_idx = fmc->apply_order[apply_idx].index;
480 : 0 : uint32_t rxq_idx_start = *rxq_idx;
481 : : uint8_t vsp_id;
482 : :
483 : : keys_params = &fmc->ccnode[cc_idx].keys_params;
484 : :
485 [ # # ]: 0 : for (j = 0; j < keys_params->num_of_keys; ++j) {
486 [ # # ]: 0 : if ((*rxq_idx) >= max_nb_rxq) {
487 : 0 : DPAA_PMD_WARN("Too many queues(%d) >= MAX number(%d)",
488 : : (*rxq_idx), max_nb_rxq);
489 : :
490 : 0 : break;
491 : : }
492 : : found = 0;
493 : 0 : params = &keys_params->key_params[j].cc_next_engine_params;
494 : :
495 : : /* We read DPDK queue from last classification rule present in
496 : : * FMC policy file. Hence, this check is required here.
497 : : * Also, the last classification rule in FMC policy file must
498 : : * have userspace queue so that it can be used by DPDK
499 : : * application.
500 : : */
501 [ # # ]: 0 : if (params->next_engine != e_IOC_FM_PCD_DONE) {
502 : 0 : DPAA_PMD_WARN("CC next engine(%d) not support",
503 : : params->next_engine);
504 : 0 : continue;
505 : : }
506 [ # # ]: 0 : if (params->params.enqueue_params.action !=
507 : : e_IOC_FM_PCD_ENQ_FRAME)
508 : 0 : continue;
509 : :
510 [ # # ]: 0 : fqid = params->params.enqueue_params.new_fqid;
511 : : vsp_id = dpaa_enqueue_vsp_id(fif,
512 : : ¶ms->params.enqueue_params);
513 : 0 : if (dpaa_fq_is_in_kernel(fqid, fif) ||
514 : : dpaa_vsp_id_is_in_kernel(vsp_id, fif)) {
515 : 0 : DPAA_PMD_DEBUG("FQ(0x%08x)/VSP(%d) is in kernel.",
516 : : fqid, vsp_id);
517 : : /* The FQ may be allocated from previous CC or scheme,
518 : : * remove it.
519 : : */
520 : 0 : dpaa_fmc_remove_fq_from_allocated(fqids,
521 : : rxq_idx, fqid);
522 : 0 : continue;
523 : : }
524 : :
525 [ # # ]: 0 : for (k = 0; k < (*rxq_idx); k++) {
526 [ # # ]: 0 : if (fqids[k] == fqid) {
527 : : found = 1;
528 : : break;
529 : : }
530 : : }
531 [ # # ]: 0 : if (found)
532 : 0 : continue;
533 : :
534 : 0 : fqids[(*rxq_idx)] = fqid;
535 : 0 : vspids[(*rxq_idx)] = vsp_id;
536 : :
537 : 0 : (*rxq_idx)++;
538 : : }
539 : :
540 : 0 : return (*rxq_idx) - rxq_idx_start;
541 : : }
542 : :
543 : : int
544 : 0 : dpaa_port_fmc_init(struct fman_if *fif,
545 : : uint32_t *fqids, int8_t *vspids, int max_nb_rxq)
546 : : {
547 : : int current_port = -1, ret;
548 : 0 : uint16_t rxq_idx = 0;
549 : : const struct fmc_model_t *fmc;
550 : : uint32_t i;
551 : :
552 [ # # ]: 0 : if (!g_fmc_model) {
553 : : size_t bytes_read;
554 : 0 : FILE *fp = fopen(FMC_FILE, "rb");
555 : :
556 [ # # ]: 0 : if (!fp) {
557 : 0 : DPAA_PMD_ERR("%s not exists", FMC_FILE);
558 : 0 : return -ENOENT;
559 : : }
560 : :
561 : 0 : g_fmc_model = rte_malloc(NULL, sizeof(struct fmc_model_t), 64);
562 [ # # ]: 0 : if (!g_fmc_model) {
563 : 0 : DPAA_PMD_ERR("FMC memory alloc failed");
564 : 0 : fclose(fp);
565 : 0 : return -ENOBUFS;
566 : : }
567 : :
568 : : bytes_read = fread(g_fmc_model,
569 : : sizeof(struct fmc_model_t), 1, fp);
570 [ # # ]: 0 : if (!bytes_read) {
571 : 0 : DPAA_PMD_ERR("No bytes read");
572 : 0 : fclose(fp);
573 : 0 : rte_free(g_fmc_model);
574 : 0 : g_fmc_model = NULL;
575 : 0 : return -EIO;
576 : : }
577 : 0 : fclose(fp);
578 : : }
579 : :
580 : 0 : fmc = g_fmc_model;
581 : :
582 [ # # ]: 0 : if (fmc->format_version != FMC_OUTPUT_FORMAT_VER) {
583 : 0 : DPAA_PMD_ERR("FMC version(0x%08x) != Supported ver(0x%08x)",
584 : : fmc->format_version, FMC_OUTPUT_FORMAT_VER);
585 : 0 : return -EINVAL;
586 : : }
587 : :
588 [ # # ]: 0 : for (i = 0; i < fmc->apply_order_count; i++) {
589 [ # # # # ]: 0 : switch (fmc->apply_order[i].type) {
590 : : case fmcengine_start:
591 : : break;
592 : : case fmcengine_end:
593 : : break;
594 : 0 : case fmcport_start:
595 : 0 : current_port = dpaa_port_fmc_port_parse(fif,
596 : : fmc, i);
597 : 0 : break;
598 : : case fmcport_end:
599 : : break;
600 : 0 : case fmcscheme:
601 [ # # ]: 0 : if (current_port < 0)
602 : : break;
603 : :
604 : 0 : ret = dpaa_port_fmc_scheme_parse(fif, fmc,
605 : : i, &rxq_idx, max_nb_rxq, fqids, vspids);
606 [ # # ]: 0 : DPAA_PMD_INFO("%s %d RXQ(s) from scheme[%d]",
607 : : ret >= 0 ? "Alloc" : "Remove",
608 : : ret >= 0 ? ret : -ret,
609 : : fmc->apply_order[i].index);
610 : :
611 : 0 : break;
612 : 0 : case fmcccnode:
613 [ # # ]: 0 : if (current_port < 0)
614 : : break;
615 : :
616 : 0 : ret = dpaa_port_fmc_ccnode_parse(fif, fmc,
617 : : i, &rxq_idx, max_nb_rxq, fqids, vspids);
618 [ # # ]: 0 : DPAA_PMD_INFO("%s %d RXQ(s) from cc[%d]",
619 : : ret >= 0 ? "Alloc" : "Remove",
620 : : ret >= 0 ? ret : -ret,
621 : : fmc->apply_order[i].index);
622 : :
623 : 0 : break;
624 : : case fmchtnode:
625 : : break;
626 : : case fmcreplicator:
627 : : break;
628 : : case fmccctree:
629 : : break;
630 : : case fmcpolicer:
631 : : break;
632 : : case fmcmanipulation:
633 : : break;
634 : : default:
635 : : break;
636 : : }
637 : : }
638 : :
639 : 0 : return rxq_idx;
640 : : }
|