src/dpdk/drivers/net/bnxt/tf_ulp/ulp_mapper.c
static int32_t
ulp_mapper_glb_template_table_init(struct bnxt_ulp_context *ulp_ctx)
{
	uint32_t *glbl_tmpl_list;
	uint32_t num_glb_tmpls, idx, dev_id;
	struct bnxt_ulp_mapper_parms parms;
	struct bnxt_ulp_mapper_data *mapper_data;
	int32_t rc = 0;

	glbl_tmpl_list = ulp_mapper_glb_template_table_get(&num_glb_tmpls);
	if (!glbl_tmpl_list || !num_glb_tmpls)
		return rc; /* No global templates to process */

	/* Get the device id from the ulp context */
	if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
		BNXT_TF_DBG(ERR, "Invalid ulp context\n");
		return -EINVAL;
	}

	mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get(ulp_ctx);
	if (!mapper_data) {
		BNXT_TF_DBG(ERR, "Failed to get the ulp mapper data\n");
		return -EINVAL;
	}

	/* Iterate the global resources and process each one */
	for (idx = 0; idx < num_glb_tmpls; idx++) {
		/* Initialize the parms structure */
		memset(&parms, 0, sizeof(parms));
		parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
		parms.ulp_ctx = ulp_ctx;
		parms.dev_id = dev_id;
		parms.mapper_data = mapper_data;
		parms.flow_type = BNXT_ULP_FDB_TYPE_DEFAULT;
		parms.tmpl_type = BNXT_ULP_TEMPLATE_TYPE_CLASS;

		/* Get the class table entry from dev id and class id */
		parms.class_tid = glbl_tmpl_list[idx];

		parms.device_params = bnxt_ulp_device_params_get(parms.dev_id);
		if (!parms.device_params) {
			BNXT_TF_DBG(ERR, "No device for device id %d\n",
				    parms.dev_id);
			return -EINVAL;
		}

		rc = ulp_mapper_tbls_process(&parms, parms.class_tid);
		if (rc)
			return rc;
	}
	return rc;
}
/* Function to handle the default global templates that are allocated during
 * the startup and reused later.
 */
Function to handle the default global templates that are allocated during
the startup and reused later.
Function to handle the default global templates that are allocated during the startup and reused later .
static int32_t
ulp_mapper_glb_template_table_init(struct bnxt_ulp_context *ulp_ctx)
{
	uint32_t *glbl_tmpl_list;
	uint32_t num_glb_tmpls, idx, dev_id;
	struct bnxt_ulp_mapper_parms parms;
	struct bnxt_ulp_mapper_data *mapper_data;
	int32_t rc = 0;
	glbl_tmpl_list = ulp_mapper_glb_template_table_get(&num_glb_tmpls);
	if (!glbl_tmpl_list || !num_glb_tmpls)
		return rc; 
	if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
		BNXT_TF_DBG(ERR, "Invalid ulp context\n");
		return -EINVAL;
	}
	mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get(ulp_ctx);
	if (!mapper_data) {
		BNXT_TF_DBG(ERR, "Failed to get the ulp mapper data\n");
		return -EINVAL;
	}
	for (idx = 0; idx < num_glb_tmpls; idx++) {
		memset(&parms, 0, sizeof(parms));
		parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
		parms.ulp_ctx = ulp_ctx;
		parms.dev_id = dev_id;
		parms.mapper_data = mapper_data;
		parms.flow_type = BNXT_ULP_FDB_TYPE_DEFAULT;
		parms.tmpl_type = BNXT_ULP_TEMPLATE_TYPE_CLASS;
		parms.class_tid = glbl_tmpl_list[idx];
		parms.device_params = bnxt_ulp_device_params_get(parms.dev_id);
		if (!parms.device_params) {
			BNXT_TF_DBG(ERR, "No device for device id %d\n",
				    parms.dev_id);
			return -EINVAL;
		}
		rc = ulp_mapper_tbls_process(&parms, parms.class_tid);
		if (rc)
			return rc;
	}
	return rc;
}
static int32_t ulp_mapper_glb_template_table_init ( struct bnxt_ulp_context * ulp_ctx ) { uint32_t * glbl_tmpl_list ; uint32_t num_glb_tmpls , idx , dev_id ; struct bnxt_ulp_mapper_parms parms ; struct bnxt_ulp_mapper_data * mapper_data ; int32_t rc = 0 ; glbl_tmpl_list = ulp_mapper_glb_template_table_get ( & num_glb_tmpls ) ; if ( ! glbl_tmpl_list || ! num_glb_tmpls ) return rc ; if ( bnxt_ulp_cntxt_dev_id_get ( ulp_ctx , & dev_id ) ) { BNXT_TF_DBG ( ERR , " \n " ) ; return - EINVAL ; } mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get ( ulp_ctx ) ; if ( ! mapper_data ) { BNXT_TF_DBG ( ERR , " \n " ) ; return - EINVAL ; } for ( idx = 0 ; idx < num_glb_tmpls ; idx ++ ) { memset ( & parms , 0 , sizeof ( parms ) ) ; parms . tfp = bnxt_ulp_cntxt_tfp_get ( ulp_ctx ) ; parms . ulp_ctx = ulp_ctx ; parms . dev_id = dev_id ; parms . mapper_data = mapper_data ; parms . flow_type = BNXT_ULP_FDB_TYPE_DEFAULT ; parms . tmpl_type = BNXT_ULP_TEMPLATE_TYPE_CLASS ; parms . class_tid = glbl_tmpl_list [ idx ] ; parms . device_params = bnxt_ulp_device_params_get ( parms . dev_id ) ; if ( ! parms . device_params ) { BNXT_TF_DBG ( ERR , " \n " , parms . dev_id ) ; return - EINVAL ; } rc = ulp_mapper_tbls_process ( & parms , parms . class_tid ) ; if ( rc ) return rc ; } return rc ; }
Function to handle the default global templates that are allocated during
 the startup and reused later.
Function to handle the default global templates that are allocated during the startup and reused later .
/* No global templates to process */ /* Get the device id from the ulp context */ /* Iterate the global resources and process each one */ /* Initialize the parms structure */ /* Get the class table entry from dev id and class id */