1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
7 #include <rte_malloc.h>
9 #include <rte_flow_driver.h>
10 #include <rte_tailq.h>
13 #include "bnxt_tf_common.h"
16 #include "tf_ext_flow_handle.h"
18 #include "ulp_template_db_enum.h"
19 #include "ulp_template_struct.h"
20 #include "ulp_mark_mgr.h"
21 #include "ulp_flow_db.h"
22 #include "ulp_mapper.h"
23 #include "ulp_port_db.h"
25 /* Linked list of all TF sessions. */
26 STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
27 STAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);
29 /* Mutex to synchronize bnxt_ulp_session_list operations. */
30 static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
33 * Allow the deletion of context only for the bnxt device that
35 * TBD - The implementation of the function should change to
36 * using the reference count once tf_session_attach functionality
40 ulp_ctx_deinit_allowed(void *ptr)
42 struct bnxt *bp = (struct bnxt *)ptr;
47 if (&bp->tfp == bp->ulp_ctx->g_tfp)
54 * Initialize an ULP session.
55 * An ULP session will contain all the resources needed to support rte flow
56 * offloads. A session is initialized as part of rte_eth_device start.
57 * A single vswitch instance can have multiple uplinks which means
58 * rte_eth_device start will be called for each of these devices.
59 * ULP session manager will make sure that a single ULP session is only
60 * initialized once. Apart from this, it also initializes MARK database,
61 * EEM table & flow database. ULP session manager also manages a list of
62 * all opened ULP sessions.
65 ulp_ctx_session_open(struct bnxt *bp,
66 struct bnxt_ulp_session_state *session)
68 struct rte_eth_dev *ethdev = bp->eth_dev;
70 struct tf_open_session_parms params;
71 struct tf_session_resources *resources;
73 memset(¶ms, 0, sizeof(params));
75 rc = rte_eth_dev_get_name_by_port(ethdev->data->port_id,
76 params.ctrl_chan_name);
78 BNXT_TF_DBG(ERR, "Invalid port %d, rc = %d\n",
79 ethdev->data->port_id, rc);
83 params.shadow_copy = false;
84 params.device_type = TF_DEVICE_TYPE_WH;
85 resources = ¶ms.resources;
88 resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT] = 16;
89 resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_WC_PROF] = 8;
90 resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 8;
91 resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_EM_PROF] = 8;
94 resources->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 720;
95 resources->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 720;
98 resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 16;
99 resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
100 resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 416;
103 resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 2048;
107 resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT] = 8;
108 resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_WC_PROF] = 8;
109 resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 8;
110 resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_EM_PROF] = 8;
113 resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 16;
114 resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 16;
117 resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 16;
120 resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 8;
121 resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
122 resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 8;
125 resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 8;
128 resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
129 resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
131 rc = tf_open_session(&bp->tfp, ¶ms);
133 BNXT_TF_DBG(ERR, "Failed to open TF session - %s, rc = %d\n",
134 params.ctrl_chan_name, rc);
137 session->session_opened = 1;
138 session->g_tfp = &bp->tfp;
143 * Close the ULP session.
144 * It takes the ulp context pointer.
147 ulp_ctx_session_close(struct bnxt *bp,
148 struct bnxt_ulp_session_state *session)
150 /* close the session in the hardware */
151 if (session->session_opened)
152 tf_close_session(&bp->tfp);
153 session->session_opened = 0;
154 session->g_tfp = NULL;
155 bp->ulp_ctx->g_tfp = NULL;
159 bnxt_init_tbl_scope_parms(struct bnxt *bp,
160 struct tf_alloc_tbl_scope_parms *params)
162 struct bnxt_ulp_device_params *dparms;
166 rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
168 /* TBD: For now, just use default. */
171 dparms = bnxt_ulp_device_params_get(dev_id);
174 * Set the flush timer for EEM entries. The value is in 100ms intervals,
177 params->hw_flow_cache_flush_timer = 100;
180 params->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;
181 params->rx_max_action_entry_sz_in_bits =
182 BNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;
183 params->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;
184 params->rx_num_flows_in_k = BNXT_ULP_RX_NUM_FLOWS;
185 params->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;
187 params->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;
188 params->tx_max_action_entry_sz_in_bits =
189 BNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;
190 params->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;
191 params->tx_num_flows_in_k = BNXT_ULP_TX_NUM_FLOWS;
192 params->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;
194 params->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;
195 params->rx_max_action_entry_sz_in_bits =
196 BNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;
197 params->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;
198 params->rx_num_flows_in_k = dparms->flow_db_num_entries / 1024;
199 params->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;
201 params->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;
202 params->tx_max_action_entry_sz_in_bits =
203 BNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;
204 params->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;
205 params->tx_num_flows_in_k = dparms->flow_db_num_entries / 1024;
206 params->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;
210 /* Initialize Extended Exact Match host memory. */
212 ulp_eem_tbl_scope_init(struct bnxt *bp)
214 struct tf_alloc_tbl_scope_parms params = {0};
217 bnxt_init_tbl_scope_parms(bp, ¶ms);
219 rc = tf_alloc_tbl_scope(&bp->tfp, ¶ms);
221 BNXT_TF_DBG(ERR, "Unable to allocate eem table scope rc = %d\n",
226 rc = bnxt_ulp_cntxt_tbl_scope_id_set(bp->ulp_ctx, params.tbl_scope_id);
228 BNXT_TF_DBG(ERR, "Unable to set table scope id\n");
235 /* Free Extended Exact Match host memory */
237 ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
239 struct tf_free_tbl_scope_parms params = {0};
243 if (!ulp_ctx || !ulp_ctx->cfg_data)
246 /* Free the resources for the last device */
247 if (!ulp_ctx_deinit_allowed(bp))
250 tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
252 BNXT_TF_DBG(ERR, "Failed to get the truflow pointer\n");
256 rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, ¶ms.tbl_scope_id);
258 BNXT_TF_DBG(ERR, "Failed to get the table scope id\n");
262 rc = tf_free_tbl_scope(tfp, ¶ms);
264 BNXT_TF_DBG(ERR, "Unable to free table scope\n");
270 /* The function to free and deinit the ulp context data. */
272 ulp_ctx_deinit(struct bnxt *bp,
273 struct bnxt_ulp_session_state *session)
275 if (!session || !bp) {
276 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
280 /* close the tf session */
281 ulp_ctx_session_close(bp, session);
283 /* Free the contents */
284 if (session->cfg_data) {
285 rte_free(session->cfg_data);
286 bp->ulp_ctx->cfg_data = NULL;
287 session->cfg_data = NULL;
292 /* The function to allocate and initialize the ulp context data. */
294 ulp_ctx_init(struct bnxt *bp,
295 struct bnxt_ulp_session_state *session)
297 struct bnxt_ulp_data *ulp_data;
300 if (!session || !bp) {
301 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
305 /* Allocate memory to hold ulp context data. */
306 ulp_data = rte_zmalloc("bnxt_ulp_data",
307 sizeof(struct bnxt_ulp_data), 0);
309 BNXT_TF_DBG(ERR, "Failed to allocate memory for ulp data\n");
313 /* Increment the ulp context data reference count usage. */
314 bp->ulp_ctx->cfg_data = ulp_data;
315 session->cfg_data = ulp_data;
318 /* Open the ulp session. */
319 rc = ulp_ctx_session_open(bp, session);
321 (void)ulp_ctx_deinit(bp, session);
324 bnxt_ulp_cntxt_tfp_set(bp->ulp_ctx, session->g_tfp);
328 /* The function to initialize ulp dparms with devargs */
330 ulp_dparms_init(struct bnxt *bp,
331 struct bnxt_ulp_context *ulp_ctx)
333 struct bnxt_ulp_device_params *dparms;
336 if (!bp->max_num_kflows)
339 if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
340 BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
344 dparms = bnxt_ulp_device_params_get(dev_id);
346 BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
350 /* num_flows = max_num_kflows * 1024 */
351 dparms->flow_db_num_entries = bp->max_num_kflows * 1024;
352 /* GFID = 2 * num_flows */
353 dparms->mark_db_gfid_entries = dparms->flow_db_num_entries * 2;
354 BNXT_TF_DBG(DEBUG, "Set the number of flows = %"PRIu64"\n",
355 dparms->flow_db_num_entries);
360 /* The function to initialize bp flags with truflow features */
362 ulp_dparms_dev_port_intf_update(struct bnxt *bp,
363 struct bnxt_ulp_context *ulp_ctx)
365 struct bnxt_ulp_device_params *dparms;
368 if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
369 BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
373 dparms = bnxt_ulp_device_params_get(dev_id);
375 BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
379 /* Update the bp flag with gfid flag */
380 if (dparms->flow_mem_type == BNXT_ULP_FLOW_MEM_TYPE_EXT)
381 bp->flags |= BNXT_FLAG_GFID_ENABLE;
387 ulp_ctx_attach(struct bnxt_ulp_context *ulp_ctx,
388 struct bnxt_ulp_session_state *session)
390 if (!ulp_ctx || !session) {
391 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
395 /* Increment the ulp context data reference count usage. */
396 ulp_ctx->cfg_data = session->cfg_data;
397 ulp_ctx->cfg_data->ref_cnt++;
399 /* TBD call TF_session_attach. */
400 ulp_ctx->g_tfp = session->g_tfp;
405 ulp_ctx_detach(struct bnxt *bp,
406 struct bnxt_ulp_session_state *session)
408 struct bnxt_ulp_context *ulp_ctx;
410 if (!bp || !session) {
411 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
414 ulp_ctx = bp->ulp_ctx;
416 if (!ulp_ctx->cfg_data)
419 /* TBD call TF_session_detach */
421 /* Increment the ulp context data reference count usage. */
422 if (ulp_ctx->cfg_data->ref_cnt >= 1) {
423 ulp_ctx->cfg_data->ref_cnt--;
424 if (ulp_ctx_deinit_allowed(bp))
425 ulp_ctx_deinit(bp, session);
426 ulp_ctx->cfg_data = NULL;
427 ulp_ctx->g_tfp = NULL;
430 BNXT_TF_DBG(ERR, "context deatach on invalid data\n");
435 * Initialize the state of an ULP session.
436 * If the state of an ULP session is not initialized, set it's state to
437 * initialized. If the state is already initialized, do nothing.
440 ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
442 pthread_mutex_lock(&session->bnxt_ulp_mutex);
444 if (!session->bnxt_ulp_init) {
445 session->bnxt_ulp_init = true;
451 pthread_mutex_unlock(&session->bnxt_ulp_mutex);
455 * Check if an ULP session is already allocated for a specific PCI
456 * domain & bus. If it is already allocated simply return the session
457 * pointer, otherwise allocate a new session.
459 static struct bnxt_ulp_session_state *
460 ulp_get_session(struct rte_pci_addr *pci_addr)
462 struct bnxt_ulp_session_state *session;
464 STAILQ_FOREACH(session, &bnxt_ulp_session_list, next) {
465 if (session->pci_info.domain == pci_addr->domain &&
466 session->pci_info.bus == pci_addr->bus) {
474 * Allocate and Initialize an ULP session and set it's state to INITIALIZED.
475 * If it's already initialized simply return the already existing session.
477 static struct bnxt_ulp_session_state *
478 ulp_session_init(struct bnxt *bp,
481 struct rte_pci_device *pci_dev;
482 struct rte_pci_addr *pci_addr;
483 struct bnxt_ulp_session_state *session;
488 pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
489 pci_addr = &pci_dev->addr;
491 pthread_mutex_lock(&bnxt_ulp_global_mutex);
493 session = ulp_get_session(pci_addr);
495 /* Not Found the session Allocate a new one */
496 session = rte_zmalloc("bnxt_ulp_session",
497 sizeof(struct bnxt_ulp_session_state),
501 "Allocation failed for bnxt_ulp_session\n");
502 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
506 /* Add it to the queue */
507 session->pci_info.domain = pci_addr->domain;
508 session->pci_info.bus = pci_addr->bus;
509 pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
510 STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
514 ulp_context_initialized(session, init);
515 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
520 * When a device is closed, remove it's associated session from the global
524 ulp_session_deinit(struct bnxt_ulp_session_state *session)
529 if (!session->cfg_data) {
530 pthread_mutex_lock(&bnxt_ulp_global_mutex);
531 STAILQ_REMOVE(&bnxt_ulp_session_list, session,
532 bnxt_ulp_session_state, next);
533 pthread_mutex_destroy(&session->bnxt_ulp_mutex);
535 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
540 * When a port is initialized by dpdk. This functions is called
541 * and this function initializes the ULP context and rest of the
542 * infrastructure associated with it.
545 bnxt_ulp_init(struct bnxt *bp)
547 struct bnxt_ulp_session_state *session;
552 BNXT_TF_DBG(ERR, "ulp ctx already allocated\n");
557 * Multiple uplink ports can be associated with a single vswitch.
558 * Make sure only the port that is started first will initialize
561 session = ulp_session_init(bp, &init);
563 BNXT_TF_DBG(ERR, "Failed to initialize the tf session\n");
567 bp->ulp_ctx = rte_zmalloc("bnxt_ulp_ctx",
568 sizeof(struct bnxt_ulp_context), 0);
570 BNXT_TF_DBG(ERR, "Failed to allocate ulp ctx\n");
571 ulp_session_deinit(session);
576 * If ULP is already initialized for a specific domain then simply
577 * assign the ulp context to this rte_eth_dev.
580 rc = ulp_ctx_attach(bp->ulp_ctx, session);
583 "Failed to attach the ulp context\n");
584 ulp_session_deinit(session);
585 rte_free(bp->ulp_ctx);
589 /* Update bnxt driver flags */
590 rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
592 BNXT_TF_DBG(ERR, "Failed to update driver flags\n");
593 ulp_ctx_detach(bp, session);
594 ulp_session_deinit(session);
595 rte_free(bp->ulp_ctx);
599 /* update the port database */
600 rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
603 "Failed to update port database\n");
604 ulp_ctx_detach(bp, session);
605 ulp_session_deinit(session);
606 rte_free(bp->ulp_ctx);
611 /* Allocate and Initialize the ulp context. */
612 rc = ulp_ctx_init(bp, session);
614 BNXT_TF_DBG(ERR, "Failed to create the ulp context\n");
618 /* Initialize ulp dparms with values devargs passed */
619 rc = ulp_dparms_init(bp, bp->ulp_ctx);
621 /* create the port database */
622 rc = ulp_port_db_init(bp->ulp_ctx);
624 BNXT_TF_DBG(ERR, "Failed to create the port database\n");
628 /* Update bnxt driver flags */
629 rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
631 BNXT_TF_DBG(ERR, "Failed to update driver flags\n");
635 /* update the port database */
636 rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
638 BNXT_TF_DBG(ERR, "Failed to update port database\n");
642 /* Create the Mark database. */
643 rc = ulp_mark_db_init(bp->ulp_ctx);
645 BNXT_TF_DBG(ERR, "Failed to create the mark database\n");
649 /* Create the flow database. */
650 rc = ulp_flow_db_init(bp->ulp_ctx);
652 BNXT_TF_DBG(ERR, "Failed to create the flow database\n");
656 /* Create the eem table scope. */
657 rc = ulp_eem_tbl_scope_init(bp);
659 BNXT_TF_DBG(ERR, "Failed to create the eem scope table\n");
663 rc = ulp_mapper_init(bp->ulp_ctx);
665 BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
676 /* Below are the access functions to access internal data of ulp context. */
679 * When a port is deinit'ed by dpdk. This function is called
680 * and this function clears the ULP context and rest of the
681 * infrastructure associated with it.
684 bnxt_ulp_deinit(struct bnxt *bp)
686 struct bnxt_ulp_session_state *session;
687 struct rte_pci_device *pci_dev;
688 struct rte_pci_addr *pci_addr;
690 /* Get the session first */
691 pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
692 pci_addr = &pci_dev->addr;
693 pthread_mutex_lock(&bnxt_ulp_global_mutex);
694 session = ulp_get_session(pci_addr);
695 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
697 /* session not found then just exit */
701 /* clean up regular flows */
702 ulp_flow_db_flush_flows(bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
704 /* cleanup the eem table scope */
705 ulp_eem_tbl_scope_deinit(bp, bp->ulp_ctx);
707 /* cleanup the flow database */
708 ulp_flow_db_deinit(bp->ulp_ctx);
710 /* Delete the Mark database */
711 ulp_mark_db_deinit(bp->ulp_ctx);
713 /* cleanup the ulp mapper */
714 ulp_mapper_deinit(bp->ulp_ctx);
716 /* Delete the Port database */
717 ulp_port_db_deinit(bp->ulp_ctx);
719 /* Delete the ulp context and tf session */
720 ulp_ctx_detach(bp, session);
722 /* Finally delete the bnxt session*/
723 ulp_session_deinit(session);
725 rte_free(bp->ulp_ctx);
728 /* Function to set the Mark DB into the context */
730 bnxt_ulp_cntxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
731 struct bnxt_ulp_mark_tbl *mark_tbl)
733 if (!ulp_ctx || !ulp_ctx->cfg_data) {
734 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
738 ulp_ctx->cfg_data->mark_tbl = mark_tbl;
743 /* Function to retrieve the Mark DB from the context. */
744 struct bnxt_ulp_mark_tbl *
745 bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx)
747 if (!ulp_ctx || !ulp_ctx->cfg_data)
750 return ulp_ctx->cfg_data->mark_tbl;
753 /* Function to set the device id of the hardware. */
755 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx,
758 if (ulp_ctx && ulp_ctx->cfg_data) {
759 ulp_ctx->cfg_data->dev_id = dev_id;
766 /* Function to get the device id of the hardware. */
768 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx,
771 if (ulp_ctx && ulp_ctx->cfg_data) {
772 *dev_id = ulp_ctx->cfg_data->dev_id;
779 /* Function to get the table scope id of the EEM table. */
781 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
782 uint32_t *tbl_scope_id)
784 if (ulp_ctx && ulp_ctx->cfg_data) {
785 *tbl_scope_id = ulp_ctx->cfg_data->tbl_scope_id;
792 /* Function to set the table scope id of the EEM table. */
794 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
795 uint32_t tbl_scope_id)
797 if (ulp_ctx && ulp_ctx->cfg_data) {
798 ulp_ctx->cfg_data->tbl_scope_id = tbl_scope_id;
805 /* Function to set the tfp session details from the ulp context. */
807 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp)
810 BNXT_TF_DBG(ERR, "Invalid arguments\n");
814 /* TBD The tfp should be removed once tf_attach is implemented. */
819 /* Function to get the tfp session details from the ulp context. */
821 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp)
824 BNXT_TF_DBG(ERR, "Invalid arguments\n");
827 /* TBD The tfp should be removed once tf_attach is implemented. */
832 * Get the device table entry based on the device id.
834 * dev_id [in] The device id of the hardware
836 * Returns the pointer to the device parameters.
838 struct bnxt_ulp_device_params *
839 bnxt_ulp_device_params_get(uint32_t dev_id)
841 if (dev_id < BNXT_ULP_MAX_NUM_DEVICES)
842 return &ulp_device_params[dev_id];
846 /* Function to set the flow database to the ulp context. */
848 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
849 struct bnxt_ulp_flow_db *flow_db)
851 if (!ulp_ctx || !ulp_ctx->cfg_data)
854 ulp_ctx->cfg_data->flow_db = flow_db;
858 /* Function to get the flow database from the ulp context. */
859 struct bnxt_ulp_flow_db *
860 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx)
862 if (!ulp_ctx || !ulp_ctx->cfg_data)
865 return ulp_ctx->cfg_data->flow_db;
868 /* Function to get the ulp context from eth device. */
869 struct bnxt_ulp_context *
870 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev)
874 bp = (struct bnxt *)dev->data->dev_private;
876 BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
883 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
886 if (!ulp_ctx || !ulp_ctx->cfg_data) {
887 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
891 ulp_ctx->cfg_data->mapper_data = mapper_data;
896 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx)
898 if (!ulp_ctx || !ulp_ctx->cfg_data) {
899 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
903 return ulp_ctx->cfg_data->mapper_data;
906 /* Function to set the port database to the ulp context. */
908 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
909 struct bnxt_ulp_port_db *port_db)
911 if (!ulp_ctx || !ulp_ctx->cfg_data)
914 ulp_ctx->cfg_data->port_db = port_db;
918 /* Function to get the port database from the ulp context. */
919 struct bnxt_ulp_port_db *
920 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx)
922 if (!ulp_ctx || !ulp_ctx->cfg_data)
925 return ulp_ctx->cfg_data->port_db;