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->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 8;
118 resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
119 resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 8;
122 resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 8;
125 resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
126 resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
128 rc = tf_open_session(&bp->tfp, ¶ms);
130 BNXT_TF_DBG(ERR, "Failed to open TF session - %s, rc = %d\n",
131 params.ctrl_chan_name, rc);
134 session->session_opened = 1;
135 session->g_tfp = &bp->tfp;
140 * Close the ULP session.
141 * It takes the ulp context pointer.
144 ulp_ctx_session_close(struct bnxt *bp,
145 struct bnxt_ulp_session_state *session)
147 /* close the session in the hardware */
148 if (session->session_opened)
149 tf_close_session(&bp->tfp);
150 session->session_opened = 0;
151 session->g_tfp = NULL;
152 bp->ulp_ctx->g_tfp = NULL;
156 bnxt_init_tbl_scope_parms(struct bnxt *bp,
157 struct tf_alloc_tbl_scope_parms *params)
159 struct bnxt_ulp_device_params *dparms;
163 rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
165 /* TBD: For now, just use default. */
168 dparms = bnxt_ulp_device_params_get(dev_id);
171 * Set the flush timer for EEM entries. The value is in 100ms intervals,
174 params->hw_flow_cache_flush_timer = 100;
177 params->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;
178 params->rx_max_action_entry_sz_in_bits =
179 BNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;
180 params->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;
181 params->rx_num_flows_in_k = BNXT_ULP_RX_NUM_FLOWS;
182 params->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;
184 params->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;
185 params->tx_max_action_entry_sz_in_bits =
186 BNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;
187 params->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;
188 params->tx_num_flows_in_k = BNXT_ULP_TX_NUM_FLOWS;
189 params->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;
191 params->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;
192 params->rx_max_action_entry_sz_in_bits =
193 BNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;
194 params->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;
195 params->rx_num_flows_in_k = dparms->flow_db_num_entries / 1024;
196 params->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;
198 params->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;
199 params->tx_max_action_entry_sz_in_bits =
200 BNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;
201 params->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;
202 params->tx_num_flows_in_k = dparms->flow_db_num_entries / 1024;
203 params->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;
207 /* Initialize Extended Exact Match host memory. */
209 ulp_eem_tbl_scope_init(struct bnxt *bp)
211 struct tf_alloc_tbl_scope_parms params = {0};
214 bnxt_init_tbl_scope_parms(bp, ¶ms);
216 rc = tf_alloc_tbl_scope(&bp->tfp, ¶ms);
218 BNXT_TF_DBG(ERR, "Unable to allocate eem table scope rc = %d\n",
223 rc = bnxt_ulp_cntxt_tbl_scope_id_set(bp->ulp_ctx, params.tbl_scope_id);
225 BNXT_TF_DBG(ERR, "Unable to set table scope id\n");
232 /* Free Extended Exact Match host memory */
234 ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
236 struct tf_free_tbl_scope_parms params = {0};
240 if (!ulp_ctx || !ulp_ctx->cfg_data)
243 /* Free the resources for the last device */
244 if (!ulp_ctx_deinit_allowed(bp))
247 tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
249 BNXT_TF_DBG(ERR, "Failed to get the truflow pointer\n");
253 rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, ¶ms.tbl_scope_id);
255 BNXT_TF_DBG(ERR, "Failed to get the table scope id\n");
259 rc = tf_free_tbl_scope(tfp, ¶ms);
261 BNXT_TF_DBG(ERR, "Unable to free table scope\n");
267 /* The function to free and deinit the ulp context data. */
269 ulp_ctx_deinit(struct bnxt *bp,
270 struct bnxt_ulp_session_state *session)
272 if (!session || !bp) {
273 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
277 /* close the tf session */
278 ulp_ctx_session_close(bp, session);
280 /* Free the contents */
281 if (session->cfg_data) {
282 rte_free(session->cfg_data);
283 bp->ulp_ctx->cfg_data = NULL;
284 session->cfg_data = NULL;
289 /* The function to allocate and initialize the ulp context data. */
291 ulp_ctx_init(struct bnxt *bp,
292 struct bnxt_ulp_session_state *session)
294 struct bnxt_ulp_data *ulp_data;
297 if (!session || !bp) {
298 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
302 /* Allocate memory to hold ulp context data. */
303 ulp_data = rte_zmalloc("bnxt_ulp_data",
304 sizeof(struct bnxt_ulp_data), 0);
306 BNXT_TF_DBG(ERR, "Failed to allocate memory for ulp data\n");
310 /* Increment the ulp context data reference count usage. */
311 bp->ulp_ctx->cfg_data = ulp_data;
312 session->cfg_data = ulp_data;
315 /* Open the ulp session. */
316 rc = ulp_ctx_session_open(bp, session);
318 (void)ulp_ctx_deinit(bp, session);
321 bnxt_ulp_cntxt_tfp_set(bp->ulp_ctx, session->g_tfp);
325 /* The function to initialize ulp dparms with devargs */
327 ulp_dparms_init(struct bnxt *bp,
328 struct bnxt_ulp_context *ulp_ctx)
330 struct bnxt_ulp_device_params *dparms;
333 if (!bp->max_num_kflows)
336 if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
337 BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
341 dparms = bnxt_ulp_device_params_get(dev_id);
343 BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
347 /* num_flows = max_num_kflows * 1024 */
348 dparms->flow_db_num_entries = bp->max_num_kflows * 1024;
349 /* GFID = 2 * num_flows */
350 dparms->mark_db_gfid_entries = dparms->flow_db_num_entries * 2;
351 BNXT_TF_DBG(DEBUG, "Set the number of flows = %"PRIu64"\n",
352 dparms->flow_db_num_entries);
357 /* The function to initialize bp flags with truflow features */
359 ulp_dparms_dev_port_intf_update(struct bnxt *bp,
360 struct bnxt_ulp_context *ulp_ctx)
362 struct bnxt_ulp_device_params *dparms;
365 if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
366 BNXT_TF_DBG(DEBUG, "Failed to get device id\n");
370 dparms = bnxt_ulp_device_params_get(dev_id);
372 BNXT_TF_DBG(DEBUG, "Failed to get device parms\n");
376 /* Update the bp flag with gfid flag */
377 if (dparms->flow_mem_type == BNXT_ULP_FLOW_MEM_TYPE_EXT)
378 bp->flags |= BNXT_FLAG_GFID_ENABLE;
384 ulp_ctx_attach(struct bnxt_ulp_context *ulp_ctx,
385 struct bnxt_ulp_session_state *session)
387 if (!ulp_ctx || !session) {
388 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
392 /* Increment the ulp context data reference count usage. */
393 ulp_ctx->cfg_data = session->cfg_data;
394 ulp_ctx->cfg_data->ref_cnt++;
396 /* TBD call TF_session_attach. */
397 ulp_ctx->g_tfp = session->g_tfp;
402 ulp_ctx_detach(struct bnxt *bp,
403 struct bnxt_ulp_session_state *session)
405 struct bnxt_ulp_context *ulp_ctx;
407 if (!bp || !session) {
408 BNXT_TF_DBG(ERR, "Invalid Arguments\n");
411 ulp_ctx = bp->ulp_ctx;
413 if (!ulp_ctx->cfg_data)
416 /* TBD call TF_session_detach */
418 /* Increment the ulp context data reference count usage. */
419 if (ulp_ctx->cfg_data->ref_cnt >= 1) {
420 ulp_ctx->cfg_data->ref_cnt--;
421 if (ulp_ctx_deinit_allowed(bp))
422 ulp_ctx_deinit(bp, session);
423 ulp_ctx->cfg_data = NULL;
424 ulp_ctx->g_tfp = NULL;
427 BNXT_TF_DBG(ERR, "context deatach on invalid data\n");
432 * Initialize the state of an ULP session.
433 * If the state of an ULP session is not initialized, set it's state to
434 * initialized. If the state is already initialized, do nothing.
437 ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
439 pthread_mutex_lock(&session->bnxt_ulp_mutex);
441 if (!session->bnxt_ulp_init) {
442 session->bnxt_ulp_init = true;
448 pthread_mutex_unlock(&session->bnxt_ulp_mutex);
452 * Check if an ULP session is already allocated for a specific PCI
453 * domain & bus. If it is already allocated simply return the session
454 * pointer, otherwise allocate a new session.
456 static struct bnxt_ulp_session_state *
457 ulp_get_session(struct rte_pci_addr *pci_addr)
459 struct bnxt_ulp_session_state *session;
461 STAILQ_FOREACH(session, &bnxt_ulp_session_list, next) {
462 if (session->pci_info.domain == pci_addr->domain &&
463 session->pci_info.bus == pci_addr->bus) {
471 * Allocate and Initialize an ULP session and set it's state to INITIALIZED.
472 * If it's already initialized simply return the already existing session.
474 static struct bnxt_ulp_session_state *
475 ulp_session_init(struct bnxt *bp,
478 struct rte_pci_device *pci_dev;
479 struct rte_pci_addr *pci_addr;
480 struct bnxt_ulp_session_state *session;
485 pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
486 pci_addr = &pci_dev->addr;
488 pthread_mutex_lock(&bnxt_ulp_global_mutex);
490 session = ulp_get_session(pci_addr);
492 /* Not Found the session Allocate a new one */
493 session = rte_zmalloc("bnxt_ulp_session",
494 sizeof(struct bnxt_ulp_session_state),
498 "Allocation failed for bnxt_ulp_session\n");
499 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
503 /* Add it to the queue */
504 session->pci_info.domain = pci_addr->domain;
505 session->pci_info.bus = pci_addr->bus;
506 pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
507 STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
511 ulp_context_initialized(session, init);
512 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
517 * When a device is closed, remove it's associated session from the global
521 ulp_session_deinit(struct bnxt_ulp_session_state *session)
526 if (!session->cfg_data) {
527 pthread_mutex_lock(&bnxt_ulp_global_mutex);
528 STAILQ_REMOVE(&bnxt_ulp_session_list, session,
529 bnxt_ulp_session_state, next);
530 pthread_mutex_destroy(&session->bnxt_ulp_mutex);
532 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
537 * When a port is initialized by dpdk. This functions is called
538 * and this function initializes the ULP context and rest of the
539 * infrastructure associated with it.
542 bnxt_ulp_init(struct bnxt *bp)
544 struct bnxt_ulp_session_state *session;
549 BNXT_TF_DBG(ERR, "ulp ctx already allocated\n");
554 * Multiple uplink ports can be associated with a single vswitch.
555 * Make sure only the port that is started first will initialize
558 session = ulp_session_init(bp, &init);
560 BNXT_TF_DBG(ERR, "Failed to initialize the tf session\n");
564 bp->ulp_ctx = rte_zmalloc("bnxt_ulp_ctx",
565 sizeof(struct bnxt_ulp_context), 0);
567 BNXT_TF_DBG(ERR, "Failed to allocate ulp ctx\n");
568 ulp_session_deinit(session);
573 * If ULP is already initialized for a specific domain then simply
574 * assign the ulp context to this rte_eth_dev.
577 rc = ulp_ctx_attach(bp->ulp_ctx, session);
580 "Failed to attach the ulp context\n");
581 ulp_session_deinit(session);
582 rte_free(bp->ulp_ctx);
586 /* Update bnxt driver flags */
587 rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
589 BNXT_TF_DBG(ERR, "Failed to update driver flags\n");
590 ulp_ctx_detach(bp, session);
591 ulp_session_deinit(session);
592 rte_free(bp->ulp_ctx);
596 /* update the port database */
597 rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
600 "Failed to update port database\n");
601 ulp_ctx_detach(bp, session);
602 ulp_session_deinit(session);
603 rte_free(bp->ulp_ctx);
608 /* Allocate and Initialize the ulp context. */
609 rc = ulp_ctx_init(bp, session);
611 BNXT_TF_DBG(ERR, "Failed to create the ulp context\n");
615 /* Initialize ulp dparms with values devargs passed */
616 rc = ulp_dparms_init(bp, bp->ulp_ctx);
618 /* create the port database */
619 rc = ulp_port_db_init(bp->ulp_ctx);
621 BNXT_TF_DBG(ERR, "Failed to create the port database\n");
625 /* Update bnxt driver flags */
626 rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
628 BNXT_TF_DBG(ERR, "Failed to update driver flags\n");
632 /* update the port database */
633 rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
635 BNXT_TF_DBG(ERR, "Failed to update port database\n");
639 /* Create the Mark database. */
640 rc = ulp_mark_db_init(bp->ulp_ctx);
642 BNXT_TF_DBG(ERR, "Failed to create the mark database\n");
646 /* Create the flow database. */
647 rc = ulp_flow_db_init(bp->ulp_ctx);
649 BNXT_TF_DBG(ERR, "Failed to create the flow database\n");
653 /* Create the eem table scope. */
654 rc = ulp_eem_tbl_scope_init(bp);
656 BNXT_TF_DBG(ERR, "Failed to create the eem scope table\n");
660 rc = ulp_mapper_init(bp->ulp_ctx);
662 BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
673 /* Below are the access functions to access internal data of ulp context. */
676 * When a port is deinit'ed by dpdk. This function is called
677 * and this function clears the ULP context and rest of the
678 * infrastructure associated with it.
681 bnxt_ulp_deinit(struct bnxt *bp)
683 struct bnxt_ulp_session_state *session;
684 struct rte_pci_device *pci_dev;
685 struct rte_pci_addr *pci_addr;
687 /* Get the session first */
688 pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
689 pci_addr = &pci_dev->addr;
690 pthread_mutex_lock(&bnxt_ulp_global_mutex);
691 session = ulp_get_session(pci_addr);
692 pthread_mutex_unlock(&bnxt_ulp_global_mutex);
694 /* session not found then just exit */
698 /* clean up regular flows */
699 ulp_flow_db_flush_flows(bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
701 /* cleanup the eem table scope */
702 ulp_eem_tbl_scope_deinit(bp, bp->ulp_ctx);
704 /* cleanup the flow database */
705 ulp_flow_db_deinit(bp->ulp_ctx);
707 /* Delete the Mark database */
708 ulp_mark_db_deinit(bp->ulp_ctx);
710 /* cleanup the ulp mapper */
711 ulp_mapper_deinit(bp->ulp_ctx);
713 /* Delete the Port database */
714 ulp_port_db_deinit(bp->ulp_ctx);
716 /* Delete the ulp context and tf session */
717 ulp_ctx_detach(bp, session);
719 /* Finally delete the bnxt session*/
720 ulp_session_deinit(session);
722 rte_free(bp->ulp_ctx);
725 /* Function to set the Mark DB into the context */
727 bnxt_ulp_cntxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
728 struct bnxt_ulp_mark_tbl *mark_tbl)
730 if (!ulp_ctx || !ulp_ctx->cfg_data) {
731 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
735 ulp_ctx->cfg_data->mark_tbl = mark_tbl;
740 /* Function to retrieve the Mark DB from the context. */
741 struct bnxt_ulp_mark_tbl *
742 bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx)
744 if (!ulp_ctx || !ulp_ctx->cfg_data)
747 return ulp_ctx->cfg_data->mark_tbl;
750 /* Function to set the device id of the hardware. */
752 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx,
755 if (ulp_ctx && ulp_ctx->cfg_data) {
756 ulp_ctx->cfg_data->dev_id = dev_id;
763 /* Function to get the device id of the hardware. */
765 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx,
768 if (ulp_ctx && ulp_ctx->cfg_data) {
769 *dev_id = ulp_ctx->cfg_data->dev_id;
776 /* Function to get the table scope id of the EEM table. */
778 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
779 uint32_t *tbl_scope_id)
781 if (ulp_ctx && ulp_ctx->cfg_data) {
782 *tbl_scope_id = ulp_ctx->cfg_data->tbl_scope_id;
789 /* Function to set the table scope id of the EEM table. */
791 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
792 uint32_t tbl_scope_id)
794 if (ulp_ctx && ulp_ctx->cfg_data) {
795 ulp_ctx->cfg_data->tbl_scope_id = tbl_scope_id;
802 /* Function to set the tfp session details from the ulp context. */
804 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp)
807 BNXT_TF_DBG(ERR, "Invalid arguments\n");
811 /* TBD The tfp should be removed once tf_attach is implemented. */
816 /* Function to get the tfp session details from the ulp context. */
818 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp)
821 BNXT_TF_DBG(ERR, "Invalid arguments\n");
824 /* TBD The tfp should be removed once tf_attach is implemented. */
829 * Get the device table entry based on the device id.
831 * dev_id [in] The device id of the hardware
833 * Returns the pointer to the device parameters.
835 struct bnxt_ulp_device_params *
836 bnxt_ulp_device_params_get(uint32_t dev_id)
838 if (dev_id < BNXT_ULP_MAX_NUM_DEVICES)
839 return &ulp_device_params[dev_id];
843 /* Function to set the flow database to the ulp context. */
845 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
846 struct bnxt_ulp_flow_db *flow_db)
848 if (!ulp_ctx || !ulp_ctx->cfg_data)
851 ulp_ctx->cfg_data->flow_db = flow_db;
855 /* Function to get the flow database from the ulp context. */
856 struct bnxt_ulp_flow_db *
857 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx)
859 if (!ulp_ctx || !ulp_ctx->cfg_data)
862 return ulp_ctx->cfg_data->flow_db;
865 /* Function to get the ulp context from eth device. */
866 struct bnxt_ulp_context *
867 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev)
871 bp = (struct bnxt *)dev->data->dev_private;
873 BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
880 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
883 if (!ulp_ctx || !ulp_ctx->cfg_data) {
884 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
888 ulp_ctx->cfg_data->mapper_data = mapper_data;
893 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx)
895 if (!ulp_ctx || !ulp_ctx->cfg_data) {
896 BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
900 return ulp_ctx->cfg_data->mapper_data;
903 /* Function to set the port database to the ulp context. */
905 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
906 struct bnxt_ulp_port_db *port_db)
908 if (!ulp_ctx || !ulp_ctx->cfg_data)
911 ulp_ctx->cfg_data->port_db = port_db;
915 /* Function to get the port database from the ulp context. */
916 struct bnxt_ulp_port_db *
917 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx)
919 if (!ulp_ctx || !ulp_ctx->cfg_data)
922 return ulp_ctx->cfg_data->port_db;