1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017-2019 NXP
11 #include <dpaa_ethdev.h>
12 #include <dpaa_flow.h>
13 #include <rte_dpaa_logs.h>
14 #include <fmlib/fm_port_ext.h>
16 #define DPAA_MAX_NUM_ETH_DEV 8
19 ioc_fm_pcd_extract_entry_t *
20 SCH_EXT_ARR(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
22 return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
25 #define SCH_EXT_HDR(scheme_params, hdr_idx) \
26 SCH_EXT_ARR(scheme_params, hdr_idx)->extract_params.extract_by_hdr
28 #define SCH_EXT_FULL_FLD(scheme_params, hdr_idx) \
29 SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
37 /*FM model to read and write from file */
38 struct dpaa_fm_model {
40 uint8_t device_order[DPAA_MAX_NUM_ETH_DEV];
41 t_fm_port_params fm_port_params[DPAA_MAX_NUM_ETH_DEV];
42 t_handle netenv_devid[DPAA_MAX_NUM_ETH_DEV];
43 t_handle scheme_devid[DPAA_MAX_NUM_ETH_DEV][2];
46 static struct dpaa_fm_info fm_info;
47 static struct dpaa_fm_model fm_model;
48 static const char *fm_log = "/tmp/fmdpdk.bin";
50 static void fm_prev_cleanup(void)
52 uint32_t fman_id = 0, i = 0, devid;
53 struct dpaa_if dpaa_intf = {0};
54 t_fm_pcd_params fm_pcd_params = {0};
55 PMD_INIT_FUNC_TRACE();
57 fm_info.fman_handle = fm_open(fman_id);
58 if (!fm_info.fman_handle) {
59 printf("\n%s- unable to open FMAN", __func__);
63 fm_pcd_params.h_fm = fm_info.fman_handle;
64 fm_pcd_params.prs_support = true;
65 fm_pcd_params.kg_support = true;
67 fm_info.pcd_handle = fm_pcd_open(&fm_pcd_params);
68 if (!fm_info.pcd_handle) {
69 printf("\n%s- unable to open PCD", __func__);
73 while (i < fm_model.dev_count) {
74 devid = fm_model.device_order[i];
76 fm_model.fm_port_params[devid].h_fm = fm_info.fman_handle;
77 dpaa_intf.port_handle =
78 fm_port_open(&fm_model.fm_port_params[devid]);
79 dpaa_intf.scheme_handle[0] = create_device(fm_info.pcd_handle,
80 fm_model.scheme_devid[devid][0]);
81 dpaa_intf.scheme_count = 1;
82 if (fm_model.scheme_devid[devid][1]) {
83 dpaa_intf.scheme_handle[1] =
84 create_device(fm_info.pcd_handle,
85 fm_model.scheme_devid[devid][1]);
86 if (dpaa_intf.scheme_handle[1])
87 dpaa_intf.scheme_count++;
90 dpaa_intf.netenv_handle = create_device(fm_info.pcd_handle,
91 fm_model.netenv_devid[devid]);
93 if (!dpaa_intf.netenv_handle ||
94 !dpaa_intf.scheme_handle[0] ||
95 !dpaa_intf.port_handle)
98 if (dpaa_fm_deconfig(&dpaa_intf, NULL))
99 printf("\nDPAA FM deconfig failed\n");
103 printf("\nDPAA FM term failed\n");
105 memset(&fm_model, 0, sizeof(struct dpaa_fm_model));
108 void dpaa_write_fm_config_to_file(void)
111 FILE *fp = fopen(fm_log, "wb");
112 PMD_INIT_FUNC_TRACE();
115 DPAA_PMD_ERR("File open failed");
118 bytes_write = fwrite(&fm_model, sizeof(struct dpaa_fm_model), 1, fp);
120 DPAA_PMD_WARN("No bytes write");
127 static void dpaa_read_fm_config_from_file(void)
130 FILE *fp = fopen(fm_log, "rb");
131 PMD_INIT_FUNC_TRACE();
135 DPAA_PMD_INFO("Previous DPDK-FM config instance present, cleaning up.");
137 bytes_read = fread(&fm_model, sizeof(struct dpaa_fm_model), 1, fp);
139 DPAA_PMD_WARN("No bytes read");
145 /*FM cleanup from previous configured app */
150 set_hash_params_eth(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
154 for (k = 0; k < 2; k++) {
155 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
156 e_IOC_FM_PCD_EXTRACT_BY_HDR;
157 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
159 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
160 e_IOC_FM_PCD_HDR_INDEX_NONE;
161 SCH_EXT_HDR(scheme_params, hdr_idx).type =
162 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
164 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth =
167 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth =
175 set_hash_params_ipv4(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
179 for (k = 0; k < 2; k++) {
180 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
181 e_IOC_FM_PCD_EXTRACT_BY_HDR;
182 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
184 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
185 e_IOC_FM_PCD_HDR_INDEX_NONE;
186 SCH_EXT_HDR(scheme_params, hdr_idx).type =
187 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
189 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 =
190 ioc_net_hf_ipv_4_src_ip;
192 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 =
193 ioc_net_hf_ipv_4_dst_ip;
200 set_hash_params_ipv6(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
204 for (k = 0; k < 2; k++) {
205 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
206 e_IOC_FM_PCD_EXTRACT_BY_HDR;
207 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
209 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
210 e_IOC_FM_PCD_HDR_INDEX_NONE;
211 SCH_EXT_HDR(scheme_params, hdr_idx).type =
212 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
214 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 =
215 ioc_net_hf_ipv_6_src_ip;
217 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 =
218 ioc_net_hf_ipv_6_dst_ip;
225 set_hash_params_udp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
229 for (k = 0; k < 2; k++) {
230 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
231 e_IOC_FM_PCD_EXTRACT_BY_HDR;
232 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
234 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
235 e_IOC_FM_PCD_HDR_INDEX_NONE;
236 SCH_EXT_HDR(scheme_params, hdr_idx).type =
237 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
239 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp =
240 IOC_NET_HF_UDP_PORT_SRC;
242 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp =
243 IOC_NET_HF_UDP_PORT_DST;
250 set_hash_params_tcp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
254 for (k = 0; k < 2; k++) {
255 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
256 e_IOC_FM_PCD_EXTRACT_BY_HDR;
257 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
259 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
260 e_IOC_FM_PCD_HDR_INDEX_NONE;
261 SCH_EXT_HDR(scheme_params, hdr_idx).type =
262 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
264 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp =
265 IOC_NET_HF_TCP_PORT_SRC;
267 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp =
268 IOC_NET_HF_TCP_PORT_DST;
275 set_hash_params_sctp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx)
279 for (k = 0; k < 2; k++) {
280 SCH_EXT_ARR(scheme_params, hdr_idx)->type =
281 e_IOC_FM_PCD_EXTRACT_BY_HDR;
282 SCH_EXT_HDR(scheme_params, hdr_idx).hdr =
284 SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index =
285 e_IOC_FM_PCD_HDR_INDEX_NONE;
286 SCH_EXT_HDR(scheme_params, hdr_idx).type =
287 e_IOC_FM_PCD_EXTRACT_FULL_FIELD;
289 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp =
290 IOC_NET_HF_SCTP_PORT_SRC;
292 SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp =
293 IOC_NET_HF_SCTP_PORT_DST;
299 /* Set scheme params for hash distribution */
300 static int set_scheme_params(ioc_fm_pcd_kg_scheme_params_t *scheme_params,
301 ioc_fm_pcd_net_env_params_t *dist_units,
302 struct dpaa_if *dpaa_intf,
303 struct fman_if *fif __rte_unused)
305 int dist_idx, hdr_idx = 0;
306 PMD_INIT_FUNC_TRACE();
308 scheme_params->param.use_hash = 1;
309 scheme_params->param.modify = false;
310 scheme_params->param.always_direct = false;
311 scheme_params->param.scheme_counter.update = 1;
312 scheme_params->param.scheme_counter.value = 0;
313 scheme_params->param.next_engine = e_IOC_FM_PCD_DONE;
314 scheme_params->param.base_fqid = dpaa_intf->rx_queues[0].fqid;
315 scheme_params->param.net_env_params.net_env_id =
316 dpaa_intf->netenv_handle;
317 scheme_params->param.net_env_params.num_of_distinction_units =
318 dist_units->param.num_of_distinction_units;
320 scheme_params->param.key_ext_and_hash.hash_dist_num_of_fqids =
321 dpaa_intf->nb_rx_queues;
322 scheme_params->param.key_ext_and_hash.num_of_used_extracts =
323 2 * dist_units->param.num_of_distinction_units;
325 for (dist_idx = 0; dist_idx <
326 dist_units->param.num_of_distinction_units;
328 switch (dist_units->param.units[dist_idx].hdrs[0].hdr) {
329 case HEADER_TYPE_ETH:
330 hdr_idx = set_hash_params_eth(scheme_params, hdr_idx);
333 case HEADER_TYPE_IPV4:
334 hdr_idx = set_hash_params_ipv4(scheme_params, hdr_idx);
337 case HEADER_TYPE_IPV6:
338 hdr_idx = set_hash_params_ipv6(scheme_params, hdr_idx);
341 case HEADER_TYPE_UDP:
342 hdr_idx = set_hash_params_udp(scheme_params, hdr_idx);
345 case HEADER_TYPE_TCP:
346 hdr_idx = set_hash_params_tcp(scheme_params, hdr_idx);
349 case HEADER_TYPE_SCTP:
350 hdr_idx = set_hash_params_sctp(scheme_params, hdr_idx);
354 DPAA_PMD_ERR("Invalid Distinction Unit");
362 static void set_dist_units(ioc_fm_pcd_net_env_params_t *dist_units,
363 uint64_t req_dist_set)
365 uint32_t loop = 0, dist_idx = 0, dist_field = 0;
366 int l2_configured = 0, ipv4_configured = 0, ipv6_configured = 0;
367 int udp_configured = 0, tcp_configured = 0, sctp_configured = 0;
368 PMD_INIT_FUNC_TRACE();
371 dist_units->param.units[dist_idx++].hdrs[0].hdr =
374 while (req_dist_set) {
375 if (req_dist_set % 2 != 0) {
376 dist_field = 1U << loop;
377 switch (dist_field) {
378 case ETH_RSS_L2_PAYLOAD:
384 dist_units->param.units[dist_idx++].hdrs[0].hdr
389 case ETH_RSS_FRAG_IPV4:
390 case ETH_RSS_NONFRAG_IPV4_OTHER:
395 dist_units->param.units[dist_idx++].hdrs[0].hdr
400 case ETH_RSS_FRAG_IPV6:
401 case ETH_RSS_NONFRAG_IPV6_OTHER:
402 case ETH_RSS_IPV6_EX:
407 dist_units->param.units[dist_idx++].hdrs[0].hdr
411 case ETH_RSS_NONFRAG_IPV4_TCP:
412 case ETH_RSS_NONFRAG_IPV6_TCP:
413 case ETH_RSS_IPV6_TCP_EX:
418 dist_units->param.units[dist_idx++].hdrs[0].hdr
422 case ETH_RSS_NONFRAG_IPV4_UDP:
423 case ETH_RSS_NONFRAG_IPV6_UDP:
424 case ETH_RSS_IPV6_UDP_EX:
429 dist_units->param.units[dist_idx++].hdrs[0].hdr
433 case ETH_RSS_NONFRAG_IPV4_SCTP:
434 case ETH_RSS_NONFRAG_IPV6_SCTP:
440 dist_units->param.units[dist_idx++].hdrs[0].hdr
445 DPAA_PMD_ERR("Bad flow distribution option");
448 req_dist_set = req_dist_set >> 1;
452 /* Dist units is set to dist_idx */
453 dist_units->param.num_of_distinction_units = dist_idx;
456 /* Apply PCD configuration on interface */
457 static inline int set_port_pcd(struct dpaa_if *dpaa_intf)
461 ioc_fm_port_pcd_params_t pcd_param;
462 ioc_fm_port_pcd_prs_params_t prs_param;
463 ioc_fm_port_pcd_kg_params_t kg_param;
465 PMD_INIT_FUNC_TRACE();
467 /* PCD support for hash distribution */
468 uint8_t pcd_support = e_FM_PORT_PCD_SUPPORT_PRS_AND_KG;
470 memset(&pcd_param, 0, sizeof(pcd_param));
471 memset(&prs_param, 0, sizeof(prs_param));
472 memset(&kg_param, 0, sizeof(kg_param));
474 /* Set parse params */
475 prs_param.first_prs_hdr = HEADER_TYPE_ETH;
478 for (idx = 0; idx < dpaa_intf->scheme_count; idx++)
479 kg_param.scheme_ids[idx] = dpaa_intf->scheme_handle[idx];
480 kg_param.num_schemes = dpaa_intf->scheme_count;
483 pcd_param.net_env_id = dpaa_intf->netenv_handle;
484 pcd_param.pcd_support = pcd_support;
485 pcd_param.p_kg_params = &kg_param;
486 pcd_param.p_prs_params = &prs_param;
488 /* FM PORT Disable */
489 ret = fm_port_disable(dpaa_intf->port_handle);
491 DPAA_PMD_ERR("fm_port_disable: Failed");
496 ret = fm_port_set_pcd(dpaa_intf->port_handle, &pcd_param);
498 DPAA_PMD_ERR("fm_port_set_pcd: Failed");
503 ret = fm_port_enable(dpaa_intf->port_handle);
505 DPAA_PMD_ERR("fm_port_enable: Failed");
506 goto fm_port_delete_pcd;
512 /* FM PORT DeletePCD */
513 ret = fm_port_delete_pcd(dpaa_intf->port_handle);
515 DPAA_PMD_ERR("fm_port_delete_pcd: Failed\n");
521 /* Unset PCD NerEnv and scheme */
522 static inline void unset_pcd_netenv_scheme(struct dpaa_if *dpaa_intf)
525 PMD_INIT_FUNC_TRACE();
527 /* reduce scheme count */
528 if (dpaa_intf->scheme_count)
529 dpaa_intf->scheme_count--;
531 DPAA_PMD_DEBUG("KG SCHEME DEL %d handle =%p",
532 dpaa_intf->scheme_count,
533 dpaa_intf->scheme_handle[dpaa_intf->scheme_count]);
535 ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle
536 [dpaa_intf->scheme_count]);
538 DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed");
540 dpaa_intf->scheme_handle[dpaa_intf->scheme_count] = NULL;
543 /* Set PCD NetEnv and Scheme and default scheme */
544 static inline int set_default_scheme(struct dpaa_if *dpaa_intf)
546 ioc_fm_pcd_kg_scheme_params_t scheme_params;
547 int idx = dpaa_intf->scheme_count;
548 PMD_INIT_FUNC_TRACE();
550 /* Set PCD NetEnvCharacteristics */
551 memset(&scheme_params, 0, sizeof(scheme_params));
553 /* Adding 10 to default schemes as the number of interface would be
554 * lesser than 10 and the relative scheme ids should be unique for
557 scheme_params.param.scm_id.relative_scheme_id =
558 10 + dpaa_intf->ifid;
559 scheme_params.param.use_hash = 0;
560 scheme_params.param.next_engine = e_IOC_FM_PCD_DONE;
561 scheme_params.param.net_env_params.num_of_distinction_units = 0;
562 scheme_params.param.net_env_params.net_env_id =
563 dpaa_intf->netenv_handle;
564 scheme_params.param.base_fqid = dpaa_intf->rx_queues[0].fqid;
565 scheme_params.param.key_ext_and_hash.hash_dist_num_of_fqids = 1;
566 scheme_params.param.key_ext_and_hash.num_of_used_extracts = 0;
567 scheme_params.param.modify = false;
568 scheme_params.param.always_direct = false;
569 scheme_params.param.scheme_counter.update = 1;
570 scheme_params.param.scheme_counter.value = 0;
572 /* FM PCD KgSchemeSet */
573 dpaa_intf->scheme_handle[idx] =
574 fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params);
575 DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p",
576 idx, dpaa_intf->scheme_handle[idx]);
577 if (!dpaa_intf->scheme_handle[idx]) {
578 DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed");
582 fm_model.scheme_devid[dpaa_intf->ifid][idx] =
583 get_device_id(dpaa_intf->scheme_handle[idx]);
584 dpaa_intf->scheme_count++;
589 /* Set PCD NetEnv and Scheme and default scheme */
590 static inline int set_pcd_netenv_scheme(struct dpaa_if *dpaa_intf,
591 uint64_t req_dist_set,
595 ioc_fm_pcd_net_env_params_t dist_units;
596 ioc_fm_pcd_kg_scheme_params_t scheme_params;
597 int idx = dpaa_intf->scheme_count;
598 PMD_INIT_FUNC_TRACE();
600 /* Set PCD NetEnvCharacteristics */
601 memset(&dist_units, 0, sizeof(dist_units));
602 memset(&scheme_params, 0, sizeof(scheme_params));
604 /* Set dist unit header type */
605 set_dist_units(&dist_units, req_dist_set);
607 scheme_params.param.scm_id.relative_scheme_id = dpaa_intf->ifid;
609 /* Set PCD Scheme params */
610 ret = set_scheme_params(&scheme_params, &dist_units, dpaa_intf, fif);
612 DPAA_PMD_ERR("Set scheme params: Failed");
616 /* FM PCD KgSchemeSet */
617 dpaa_intf->scheme_handle[idx] =
618 fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params);
619 DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p",
620 idx, dpaa_intf->scheme_handle[idx]);
621 if (!dpaa_intf->scheme_handle[idx]) {
622 DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed");
626 fm_model.scheme_devid[dpaa_intf->ifid][idx] =
627 get_device_id(dpaa_intf->scheme_handle[idx]);
628 dpaa_intf->scheme_count++;
633 static inline int get_port_type(struct fman_if *fif)
635 if (fif->mac_type == fman_mac_1g)
636 return e_FM_PORT_TYPE_RX;
637 else if (fif->mac_type == fman_mac_2_5g)
638 return e_FM_PORT_TYPE_RX_2_5G;
639 else if (fif->mac_type == fman_mac_10g)
640 return e_FM_PORT_TYPE_RX_10G;
642 DPAA_PMD_ERR("MAC type unsupported");
646 static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf,
647 uint64_t req_dist_set,
650 t_fm_port_params fm_port_params;
651 ioc_fm_pcd_net_env_params_t dist_units;
652 PMD_INIT_FUNC_TRACE();
654 /* FMAN mac indexes mappings (0 is unused,
655 * first 8 are for 1G, next for 10G ports
657 uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
659 /* Memset FM port params */
660 memset(&fm_port_params, 0, sizeof(fm_port_params));
662 /* Set FM port params */
663 fm_port_params.h_fm = fm_info.fman_handle;
664 fm_port_params.port_type = get_port_type(fif);
665 fm_port_params.port_id = mac_idx[fif->mac_idx];
668 dpaa_intf->port_handle = fm_port_open(&fm_port_params);
669 if (!dpaa_intf->port_handle) {
670 DPAA_PMD_ERR("fm_port_open: Failed\n");
674 fm_model.fm_port_params[dpaa_intf->ifid] = fm_port_params;
676 /* Set PCD NetEnvCharacteristics */
677 memset(&dist_units, 0, sizeof(dist_units));
679 /* Set dist unit header type */
680 set_dist_units(&dist_units, req_dist_set);
682 /* FM PCD NetEnvCharacteristicsSet */
683 dpaa_intf->netenv_handle =
684 fm_pcd_net_env_characteristics_set(fm_info.pcd_handle,
686 if (!dpaa_intf->netenv_handle) {
687 DPAA_PMD_ERR("fm_pcd_net_env_characteristics_set: Failed");
691 fm_model.netenv_devid[dpaa_intf->ifid] =
692 get_device_id(dpaa_intf->netenv_handle);
697 /* De-Configure DPAA FM */
698 int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf,
699 struct fman_if *fif __rte_unused)
704 PMD_INIT_FUNC_TRACE();
706 /* FM PORT Disable */
707 ret = fm_port_disable(dpaa_intf->port_handle);
709 DPAA_PMD_ERR("fm_port_disable: Failed");
713 /* FM PORT DeletePCD */
714 ret = fm_port_delete_pcd(dpaa_intf->port_handle);
716 DPAA_PMD_ERR("fm_port_delete_pcd: Failed");
720 for (idx = 0; idx < dpaa_intf->scheme_count; idx++) {
721 DPAA_PMD_DEBUG("KG SCHEME DEL %d, handle =%p",
722 idx, dpaa_intf->scheme_handle[idx]);
723 /* FM PCD KgSchemeDelete */
724 ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle[idx]);
726 DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed");
729 dpaa_intf->scheme_handle[idx] = NULL;
731 /* FM PCD NetEnvCharacteristicsDelete */
732 ret = fm_pcd_net_env_characteristics_delete(dpaa_intf->netenv_handle);
734 DPAA_PMD_ERR("fm_pcd_net_env_characteristics_delete: Failed");
737 dpaa_intf->netenv_handle = NULL;
740 fm_port_close(dpaa_intf->port_handle);
741 dpaa_intf->port_handle = NULL;
743 /* Set scheme count to 0 */
744 dpaa_intf->scheme_count = 0;
749 int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set)
751 struct dpaa_if *dpaa_intf = dev->data->dev_private;
752 struct fman_if *fif = dev->process_private;
755 PMD_INIT_FUNC_TRACE();
757 if (dpaa_intf->port_handle) {
758 if (dpaa_fm_deconfig(dpaa_intf, fif))
759 DPAA_PMD_ERR("DPAA FM deconfig failed");
762 if (!dev->data->nb_rx_queues)
765 if (dev->data->nb_rx_queues & (dev->data->nb_rx_queues - 1)) {
766 DPAA_PMD_ERR("No of queues should be power of 2");
770 dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
772 /* Open FM Port and set it in port info */
773 ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
775 DPAA_PMD_ERR("Set FM Port handle: Failed");
779 /* Set PCD netenv and scheme */
781 ret = set_pcd_netenv_scheme(dpaa_intf, req_dist_set, fif);
783 DPAA_PMD_ERR("Set PCD NetEnv and Scheme dist: Failed");
784 goto unset_fm_port_handle;
787 /* Set default netenv and scheme */
788 ret = set_default_scheme(dpaa_intf);
790 DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed");
791 goto unset_pcd_netenv_scheme1;
795 ret = set_port_pcd(dpaa_intf);
797 DPAA_PMD_ERR("Set Port PCD: Failed");
798 goto unset_pcd_netenv_scheme;
801 for (; i < fm_model.dev_count; i++)
802 if (fm_model.device_order[i] == dpaa_intf->ifid)
805 fm_model.device_order[fm_model.dev_count] = dpaa_intf->ifid;
806 fm_model.dev_count++;
810 unset_pcd_netenv_scheme:
811 unset_pcd_netenv_scheme(dpaa_intf);
813 unset_pcd_netenv_scheme1:
814 unset_pcd_netenv_scheme(dpaa_intf);
816 unset_fm_port_handle:
818 fm_port_close(dpaa_intf->port_handle);
819 dpaa_intf->port_handle = NULL;
823 int dpaa_fm_init(void)
825 t_handle fman_handle;
827 t_fm_pcd_params fm_pcd_params = {0};
828 /* Hard-coded : fman id 0 since one fman is present in LS104x */
829 int fman_id = 0, ret;
830 PMD_INIT_FUNC_TRACE();
832 dpaa_read_fm_config_from_file();
835 fman_handle = fm_open(fman_id);
837 DPAA_PMD_ERR("fm_open: Failed");
842 fm_pcd_params.h_fm = fman_handle;
843 fm_pcd_params.prs_support = true;
844 fm_pcd_params.kg_support = true;
845 pcd_handle = fm_pcd_open(&fm_pcd_params);
847 fm_close(fman_handle);
848 DPAA_PMD_ERR("fm_pcd_open: Failed");
853 ret = fm_pcd_enable(pcd_handle);
855 fm_close(fman_handle);
856 fm_pcd_close(pcd_handle);
857 DPAA_PMD_ERR("fm_pcd_enable: Failed");
861 /* Set fman and pcd handle in fm info */
862 fm_info.fman_handle = fman_handle;
863 fm_info.pcd_handle = pcd_handle;
869 /* De-initialization of FM */
870 int dpaa_fm_term(void)
874 PMD_INIT_FUNC_TRACE();
876 if (fm_info.pcd_handle && fm_info.fman_handle) {
878 ret = fm_pcd_disable(fm_info.pcd_handle);
880 DPAA_PMD_ERR("fm_pcd_disable: Failed");
885 fm_pcd_close(fm_info.pcd_handle);
886 fm_info.pcd_handle = NULL;
889 if (fm_info.fman_handle) {
891 fm_close(fm_info.fman_handle);
892 fm_info.fman_handle = NULL;
895 if (access(fm_log, F_OK) != -1) {
896 ret = remove(fm_log);
898 DPAA_PMD_ERR("File remove: Failed");