1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2020 Broadcom
6 #include <rte_common.h>
7 #include <rte_malloc.h>
10 #include "tf_ext_flow_handle.h"
11 #include "ulp_mark_mgr.h"
12 #include "bnxt_tf_common.h"
14 #include "ulp_template_db.h"
15 #include "ulp_template_struct.h"
18 * Allocate and Initialize all Mark Manager resources for this ulp context.
20 * ctxt [in] The ulp context for the mark manager.
24 ulp_mark_db_init(struct bnxt_ulp_context *ctxt)
26 struct bnxt_ulp_device_params *dparms;
27 struct bnxt_ulp_mark_tbl *mark_tbl = NULL;
31 BNXT_TF_DBG(DEBUG, "Invalid ULP CTXT\n");
35 if (bnxt_ulp_cntxt_dev_id_get(ctxt, &dev_id)) {
36 BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
40 dparms = bnxt_ulp_device_params_get(dev_id);
42 BNXT_TF_DBG(DEBUG, "Failed to device parms\n");
46 mark_tbl = rte_zmalloc("ulp_rx_mark_tbl_ptr",
47 sizeof(struct bnxt_ulp_mark_tbl), 0);
51 /* Need to allocate 2 * Num flows to account for hash type bit. */
52 mark_tbl->lfid_tbl = rte_zmalloc("ulp_rx_em_flow_mark_table",
53 dparms->lfid_entries *
54 sizeof(struct bnxt_lfid_mark_info),
57 if (!mark_tbl->lfid_tbl)
60 /* Need to allocate 2 * Num flows to account for hash type bit. */
61 mark_tbl->gfid_tbl = rte_zmalloc("ulp_rx_eem_flow_mark_table",
62 2 * dparms->num_flows *
63 sizeof(struct bnxt_gfid_mark_info),
65 if (!mark_tbl->gfid_tbl)
69 * TBD: This needs to be generalized for better mark handling
70 * These values are used to compress the FID to the allowable index
71 * space. The FID from hw may be the full hash.
73 mark_tbl->gfid_max = dparms->gfid_entries - 1;
74 mark_tbl->gfid_mask = (dparms->gfid_entries / 2) - 1;
75 mark_tbl->gfid_type_bit = (dparms->gfid_entries / 2);
77 BNXT_TF_DBG(DEBUG, "GFID Max = 0x%08x\nGFID MASK = 0x%08x\n",
81 /* Add the mart tbl to the ulp context. */
82 bnxt_ulp_cntxt_ptr2_mark_db_set(ctxt, mark_tbl);
87 rte_free(mark_tbl->gfid_tbl);
88 rte_free(mark_tbl->lfid_tbl);
91 "Failed to allocate memory for mark mgr\n");