src/dpdk/drivers/net/bnxt/tf_ulp/ulp_mapper.c
static int32_t
ulp_mapper_tcam_tbl_entry_write(struct bnxt_ulp_mapper_parms *parms,
				struct bnxt_ulp_mapper_tbl_info *tbl,
				struct ulp_blob *key,
				struct ulp_blob *mask,
				struct ulp_blob *data,
				uint16_t idx)
{
	struct tf_set_tcam_entry_parms sparms = { 0 };
	struct tf *tfp;
	uint16_t tmplen;
	int32_t rc;

	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
	if (!tfp) {
		BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n");
		return -EINVAL;
	}

	sparms.dir		= tbl->direction;
	sparms.tcam_tbl_type	= tbl->resource_type;
	sparms.idx		= idx;
	/* Already verified the key/mask lengths */
	sparms.key		= ulp_blob_data_get(key, &tmplen);
	sparms.mask		= ulp_blob_data_get(mask, &tmplen);
	sparms.key_sz_in_bits	= tbl->key_bit_size;
	sparms.result		= ulp_blob_data_get(data, &tmplen);

	if (tbl->result_bit_size != tmplen) {
		BNXT_TF_DBG(ERR, "Result len (%d) != Expected (%d)\n",
			    tmplen, tbl->result_bit_size);
		return -EINVAL;
	}
	sparms.result_sz_in_bits = tbl->result_bit_size;
	if (tf_set_tcam_entry(tfp, &sparms)) {
		BNXT_TF_DBG(ERR, "tcam[%s][%s][%x] write failed.\n",
			    tf_tcam_tbl_2_str(sparms.tcam_tbl_type),
			    tf_dir_2_str(sparms.dir), sparms.idx);
		return -EIO;
	}
	BNXT_TF_DBG(INFO, "tcam[%s][%s][%x] write success.\n",
		    tf_tcam_tbl_2_str(sparms.tcam_tbl_type),
		    tf_dir_2_str(sparms.dir), sparms.idx);

	/* Update cache with TCAM index if the was cache allocated. */
	if (parms->tcam_tbl_opc ==
	    BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC) {
		if (!parms->cache_ptr) {
			BNXT_TF_DBG(ERR, "Unable to update cache");
			return -EINVAL;
		}
		parms->cache_ptr->tcam_idx = idx;
	}

	/* Mark action */
	rc = ulp_mapper_mark_act_ptr_process(parms, tbl);
	if (rc) {
		BNXT_TF_DBG(ERR, "failed mark action processing\n");
		return rc;
	}

	return rc;
}
/* Internal function to write the tcam entry */
Internal function to write the tcam entry
Internal function to write the tcam entry
static int32_t
ulp_mapper_tcam_tbl_entry_write(struct bnxt_ulp_mapper_parms *parms,
				struct bnxt_ulp_mapper_tbl_info *tbl,
				struct ulp_blob *key,
				struct ulp_blob *mask,
				struct ulp_blob *data,
				uint16_t idx)
{
	struct tf_set_tcam_entry_parms sparms = { 0 };
	struct tf *tfp;
	uint16_t tmplen;
	int32_t rc;
	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
	if (!tfp) {
		BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n");
		return -EINVAL;
	}
	sparms.dir		= tbl->direction;
	sparms.tcam_tbl_type	= tbl->resource_type;
	sparms.idx		= idx;
	sparms.key		= ulp_blob_data_get(key, &tmplen);
	sparms.mask		= ulp_blob_data_get(mask, &tmplen);
	sparms.key_sz_in_bits	= tbl->key_bit_size;
	sparms.result		= ulp_blob_data_get(data, &tmplen);
	if (tbl->result_bit_size != tmplen) {
		BNXT_TF_DBG(ERR, "Result len (%d) != Expected (%d)\n",
			    tmplen, tbl->result_bit_size);
		return -EINVAL;
	}
	sparms.result_sz_in_bits = tbl->result_bit_size;
	if (tf_set_tcam_entry(tfp, &sparms)) {
		BNXT_TF_DBG(ERR, "tcam[%s][%s][%x] write failed.\n",
			    tf_tcam_tbl_2_str(sparms.tcam_tbl_type),
			    tf_dir_2_str(sparms.dir), sparms.idx);
		return -EIO;
	}
	BNXT_TF_DBG(INFO, "tcam[%s][%s][%x] write success.\n",
		    tf_tcam_tbl_2_str(sparms.tcam_tbl_type),
		    tf_dir_2_str(sparms.dir), sparms.idx);
	if (parms->tcam_tbl_opc ==
	    BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC) {
		if (!parms->cache_ptr) {
			BNXT_TF_DBG(ERR, "Unable to update cache");
			return -EINVAL;
		}
		parms->cache_ptr->tcam_idx = idx;
	}
	rc = ulp_mapper_mark_act_ptr_process(parms, tbl);
	if (rc) {
		BNXT_TF_DBG(ERR, "failed mark action processing\n");
		return rc;
	}
	return rc;
}
static int32_t ulp_mapper_tcam_tbl_entry_write ( struct bnxt_ulp_mapper_parms * parms , struct bnxt_ulp_mapper_tbl_info * tbl , struct ulp_blob * key , struct ulp_blob * mask , struct ulp_blob * data , uint16_t idx ) { struct tf_set_tcam_entry_parms sparms = { 0 } ; struct tf * tfp ; uint16_t tmplen ; int32_t rc ; tfp = bnxt_ulp_cntxt_tfp_get ( parms -> ulp_ctx ) ; if ( ! tfp ) { BNXT_TF_DBG ( ERR , " \n " ) ; return - EINVAL ; } sparms . dir = tbl -> direction ; sparms . tcam_tbl_type = tbl -> resource_type ; sparms . idx = idx ; sparms . key = ulp_blob_data_get ( key , & tmplen ) ; sparms . mask = ulp_blob_data_get ( mask , & tmplen ) ; sparms . key_sz_in_bits = tbl -> key_bit_size ; sparms . result = ulp_blob_data_get ( data , & tmplen ) ; if ( tbl -> result_bit_size != tmplen ) { BNXT_TF_DBG ( ERR , " \n " , tmplen , tbl -> result_bit_size ) ; return - EINVAL ; } sparms . result_sz_in_bits = tbl -> result_bit_size ; if ( tf_set_tcam_entry ( tfp , & sparms ) ) { BNXT_TF_DBG ( ERR , " \n " , tf_tcam_tbl_2_str ( sparms . tcam_tbl_type ) , tf_dir_2_str ( sparms . dir ) , sparms . idx ) ; return - EIO ; } BNXT_TF_DBG ( INFO , " \n " , tf_tcam_tbl_2_str ( sparms . tcam_tbl_type ) , tf_dir_2_str ( sparms . dir ) , sparms . idx ) ; if ( parms -> tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC ) { if ( ! parms -> cache_ptr ) { BNXT_TF_DBG ( ERR , " " ) ; return - EINVAL ; } parms -> cache_ptr -> tcam_idx = idx ; } rc = ulp_mapper_mark_act_ptr_process ( parms , tbl ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " ) ; return rc ; } return rc ; }
Internal function to write the tcam entry
Internal function to write the tcam entry
/* Already verified the key/mask lengths */ /* Update cache with TCAM index if the was cache allocated. */ /* Mark action */