src/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
int32_t
ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item,
			     struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_phy_port *port_spec = item->spec;
	const struct rte_flow_item_phy_port *port_mask = item->mask;
	uint16_t mask = 0;
	int32_t rc = BNXT_TF_RC_ERROR;
	uint16_t svif;
	enum bnxt_ulp_direction_type dir;
	struct ulp_rte_hdr_field *hdr_field;

	/* Copy the rte_flow_item for phy port into hdr_field */
	if (!port_spec) {
		BNXT_TF_DBG(ERR, "ParseErr:Phy Port id is not valid\n");
		return rc;
	}
	if (!port_mask) {
		BNXT_TF_DBG(ERR, "ParseErr:Phy Port mask is not valid\n");
		return rc;
	}
	mask = port_mask->index;

	/* Update the match port type */
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_MATCH_PORT_TYPE,
			    BNXT_ULP_INTF_TYPE_PHY_PORT);

	/* Compute the Hw direction */
	bnxt_ulp_rte_parser_direction_compute(params);

	/* Direction validation */
	dir = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION);
	if (dir == BNXT_ULP_DIR_EGRESS) {
		BNXT_TF_DBG(ERR,
			    "Parse Err:Phy ports are valid only for ingress\n");
		return BNXT_TF_RC_PARSE_ERR;
	}

	/* Get the physical port details from port db */
	rc = ulp_port_db_phy_port_svif_get(params->ulp_ctx, port_spec->index,
					   &svif);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to get port details\n");
		return BNXT_TF_RC_PARSE_ERR;
	}

	/* Update the SVIF details */
	svif = rte_cpu_to_be_16(svif);
	hdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
	memcpy(hdr_field->spec, &svif, sizeof(svif));
	memcpy(hdr_field->mask, &mask, sizeof(mask));
	hdr_field->size = sizeof(svif);
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_SVIF_FLAG,
			    rte_be_to_cpu_16(svif));
	return BNXT_TF_RC_SUCCESS;
}
/* Function to handle the parsing of RTE Flow item phy port Header. */
Function to handle the parsing of RTE Flow item phy port Header.
Function to handle the parsing of RTE Flow item phy port Header .
int32_t
ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item,
			     struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_phy_port *port_spec = item->spec;
	const struct rte_flow_item_phy_port *port_mask = item->mask;
	uint16_t mask = 0;
	int32_t rc = BNXT_TF_RC_ERROR;
	uint16_t svif;
	enum bnxt_ulp_direction_type dir;
	struct ulp_rte_hdr_field *hdr_field;
	if (!port_spec) {
		BNXT_TF_DBG(ERR, "ParseErr:Phy Port id is not valid\n");
		return rc;
	}
	if (!port_mask) {
		BNXT_TF_DBG(ERR, "ParseErr:Phy Port mask is not valid\n");
		return rc;
	}
	mask = port_mask->index;
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_MATCH_PORT_TYPE,
			    BNXT_ULP_INTF_TYPE_PHY_PORT);
	bnxt_ulp_rte_parser_direction_compute(params);
	dir = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION);
	if (dir == BNXT_ULP_DIR_EGRESS) {
		BNXT_TF_DBG(ERR,
			    "Parse Err:Phy ports are valid only for ingress\n");
		return BNXT_TF_RC_PARSE_ERR;
	}
	rc = ulp_port_db_phy_port_svif_get(params->ulp_ctx, port_spec->index,
					   &svif);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to get port details\n");
		return BNXT_TF_RC_PARSE_ERR;
	}
	svif = rte_cpu_to_be_16(svif);
	hdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
	memcpy(hdr_field->spec, &svif, sizeof(svif));
	memcpy(hdr_field->mask, &mask, sizeof(mask));
	hdr_field->size = sizeof(svif);
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_SVIF_FLAG,
			    rte_be_to_cpu_16(svif));
	return BNXT_TF_RC_SUCCESS;
}
int32_t ulp_rte_phy_port_hdr_handler ( const struct rte_flow_item * item , struct ulp_rte_parser_params * params ) { const struct rte_flow_item_phy_port * port_spec = item -> spec ; const struct rte_flow_item_phy_port * port_mask = item -> mask ; uint16_t mask = 0 ; int32_t rc = BNXT_TF_RC_ERROR ; uint16_t svif ; enum bnxt_ulp_direction_type dir ; struct ulp_rte_hdr_field * hdr_field ; if ( ! port_spec ) { BNXT_TF_DBG ( ERR , " \n " ) ; return rc ; } if ( ! port_mask ) { BNXT_TF_DBG ( ERR , " \n " ) ; return rc ; } mask = port_mask -> index ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_MATCH_PORT_TYPE , BNXT_ULP_INTF_TYPE_PHY_PORT ) ; bnxt_ulp_rte_parser_direction_compute ( params ) ; dir = ULP_COMP_FLD_IDX_RD ( params , BNXT_ULP_CF_IDX_DIRECTION ) ; if ( dir == BNXT_ULP_DIR_EGRESS ) { BNXT_TF_DBG ( ERR , " \n " ) ; return BNXT_TF_RC_PARSE_ERR ; } rc = ulp_port_db_phy_port_svif_get ( params -> ulp_ctx , port_spec -> index , & svif ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " ) ; return BNXT_TF_RC_PARSE_ERR ; } svif = rte_cpu_to_be_16 ( svif ) ; hdr_field = & params -> hdr_field [ BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX ] ; memcpy ( hdr_field -> spec , & svif , sizeof ( svif ) ) ; memcpy ( hdr_field -> mask , & mask , sizeof ( mask ) ) ; hdr_field -> size = sizeof ( svif ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_SVIF_FLAG , rte_be_to_cpu_16 ( svif ) ) ; return BNXT_TF_RC_SUCCESS ; }
Function to handle the parsing of RTE Flow item phy port Header.
Function to handle the parsing of RTE Flow item phy port Header .
/* Copy the rte_flow_item for phy port into hdr_field */ /* Update the match port type */ /* Compute the Hw direction */ /* Direction validation */ /* Get the physical port details from port db */ /* Update the SVIF details */