src/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
int32_t
ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
			struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_eth *eth_spec = item->spec;
	const struct rte_flow_item_eth *eth_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	uint32_t idx = params->field_idx;
	uint32_t size;
	uint16_t eth_type = 0;
	uint32_t inner_flag = 0;

	/*
	 * Copy the rte_flow_item for eth into hdr_field using ethernet
	 * header fields
	 */
	if (eth_spec) {
		size = sizeof(eth_spec->dst.addr_bytes);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						eth_spec->dst.addr_bytes,
						size);
		/* Todo: work around to avoid multicast and broadcast addr */
		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->dst))
			return BNXT_TF_RC_PARSE_ERR;

		size = sizeof(eth_spec->src.addr_bytes);
		field = ulp_rte_parser_fld_copy(field,
						eth_spec->src.addr_bytes,
						size);
		/* Todo: work around to avoid multicast and broadcast addr */
		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->src))
			return BNXT_TF_RC_PARSE_ERR;

		field = ulp_rte_parser_fld_copy(field,
						&eth_spec->type,
						sizeof(eth_spec->type));
		eth_type = eth_spec->type;
	}
	if (eth_mask) {
		ulp_rte_prsr_mask_copy(params, &idx, eth_mask->dst.addr_bytes,
				       sizeof(eth_mask->dst.addr_bytes));
		ulp_rte_prsr_mask_copy(params, &idx, eth_mask->src.addr_bytes,
				       sizeof(eth_mask->src.addr_bytes));
		ulp_rte_prsr_mask_copy(params, &idx, &eth_mask->type,
				       sizeof(eth_mask->type));
	}
	/* Add number of vlan header elements */
	params->field_idx += BNXT_ULP_PROTO_HDR_ETH_NUM;
	params->vlan_idx = params->field_idx;
	params->field_idx += BNXT_ULP_PROTO_HDR_VLAN_NUM;

	/* Update the protocol hdr bitmap */
	if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_ETH) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_IPV4) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_IPV6) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_UDP) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_TCP)) {
		ULP_BITMAP_SET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_I_ETH);
		inner_flag = 1;
	} else {
		ULP_BITMAP_SET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_O_ETH);
	}
	/* Update the field protocol hdr bitmap */
	ulp_rte_l2_proto_type_update(params, eth_type, inner_flag);

	return BNXT_TF_RC_SUCCESS;
}
/* Function to handle the parsing of RTE Flow item Ethernet Header. */
Function to handle the parsing of RTE Flow item Ethernet Header.
Function to handle the parsing of RTE Flow item Ethernet Header .
int32_t
ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
			struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_eth *eth_spec = item->spec;
	const struct rte_flow_item_eth *eth_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	uint32_t idx = params->field_idx;
	uint32_t size;
	uint16_t eth_type = 0;
	uint32_t inner_flag = 0;
	if (eth_spec) {
		size = sizeof(eth_spec->dst.addr_bytes);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						eth_spec->dst.addr_bytes,
						size);
		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->dst))
			return BNXT_TF_RC_PARSE_ERR;
		size = sizeof(eth_spec->src.addr_bytes);
		field = ulp_rte_parser_fld_copy(field,
						eth_spec->src.addr_bytes,
						size);
		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->src))
			return BNXT_TF_RC_PARSE_ERR;
		field = ulp_rte_parser_fld_copy(field,
						&eth_spec->type,
						sizeof(eth_spec->type));
		eth_type = eth_spec->type;
	}
	if (eth_mask) {
		ulp_rte_prsr_mask_copy(params, &idx, eth_mask->dst.addr_bytes,
				       sizeof(eth_mask->dst.addr_bytes));
		ulp_rte_prsr_mask_copy(params, &idx, eth_mask->src.addr_bytes,
				       sizeof(eth_mask->src.addr_bytes));
		ulp_rte_prsr_mask_copy(params, &idx, &eth_mask->type,
				       sizeof(eth_mask->type));
	}
	params->field_idx += BNXT_ULP_PROTO_HDR_ETH_NUM;
	params->vlan_idx = params->field_idx;
	params->field_idx += BNXT_ULP_PROTO_HDR_VLAN_NUM;
	if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_ETH) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_IPV4) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_IPV6) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_UDP) ||
	    ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
			     BNXT_ULP_HDR_BIT_O_TCP)) {
		ULP_BITMAP_SET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_I_ETH);
		inner_flag = 1;
	} else {
		ULP_BITMAP_SET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_O_ETH);
	}
	ulp_rte_l2_proto_type_update(params, eth_type, inner_flag);
	return BNXT_TF_RC_SUCCESS;
}
int32_t ulp_rte_eth_hdr_handler ( const struct rte_flow_item * item , struct ulp_rte_parser_params * params ) { const struct rte_flow_item_eth * eth_spec = item -> spec ; const struct rte_flow_item_eth * eth_mask = item -> mask ; struct ulp_rte_hdr_field * field ; uint32_t idx = params -> field_idx ; uint32_t size ; uint16_t eth_type = 0 ; uint32_t inner_flag = 0 ; if ( eth_spec ) { size = sizeof ( eth_spec -> dst . addr_bytes ) ; field = ulp_rte_parser_fld_copy ( & params -> hdr_field [ idx ] , eth_spec -> dst . addr_bytes , size ) ; if ( ulp_rte_parser_is_bcmc_addr ( & eth_spec -> dst ) ) return BNXT_TF_RC_PARSE_ERR ; size = sizeof ( eth_spec -> src . addr_bytes ) ; field = ulp_rte_parser_fld_copy ( field , eth_spec -> src . addr_bytes , size ) ; if ( ulp_rte_parser_is_bcmc_addr ( & eth_spec -> src ) ) return BNXT_TF_RC_PARSE_ERR ; field = ulp_rte_parser_fld_copy ( field , & eth_spec -> type , sizeof ( eth_spec -> type ) ) ; eth_type = eth_spec -> type ; } if ( eth_mask ) { ulp_rte_prsr_mask_copy ( params , & idx , eth_mask -> dst . addr_bytes , sizeof ( eth_mask -> dst . addr_bytes ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , eth_mask -> src . addr_bytes , sizeof ( eth_mask -> src . addr_bytes ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & eth_mask -> type , sizeof ( eth_mask -> type ) ) ; } params -> field_idx += BNXT_ULP_PROTO_HDR_ETH_NUM ; params -> vlan_idx = params -> field_idx ; params -> field_idx += BNXT_ULP_PROTO_HDR_VLAN_NUM ; if ( ULP_BITMAP_ISSET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_ETH ) || ULP_BITMAP_ISSET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_IPV4 ) || ULP_BITMAP_ISSET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_IPV6 ) || ULP_BITMAP_ISSET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_UDP ) || ULP_BITMAP_ISSET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_TCP ) ) { ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_I_ETH ) ; inner_flag = 1 ; } else { ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_O_ETH ) ; } ulp_rte_l2_proto_type_update ( params , eth_type , inner_flag ) ; return BNXT_TF_RC_SUCCESS ; }
Function to handle the parsing of RTE Flow item Ethernet Header.
Function to handle the parsing of RTE Flow item Ethernet Header .
/*
	 * Copy the rte_flow_item for eth into hdr_field using ethernet
	 * header fields
	 */ /* Todo: work around to avoid multicast and broadcast addr */ /* Todo: work around to avoid multicast and broadcast addr */ /* Add number of vlan header elements */ /* Update the protocol hdr bitmap */ /* Update the field protocol hdr bitmap */