src/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
int32_t
ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item,
			 struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_ipv4 *ipv4_spec = item->spec;
	const struct rte_flow_item_ipv4 *ipv4_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	struct ulp_rte_hdr_bitmap *hdr_bitmap = &params->hdr_bitmap;
	uint32_t idx = params->field_idx;
	uint32_t size;
	uint8_t proto = 0;
	uint32_t inner_flag = 0;
	uint32_t cnt;

	/* validate there are no 3rd L3 header */
	cnt = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_L3_HDR_CNT);
	if (cnt == 2) {
		BNXT_TF_DBG(ERR, "Parse Err:Third L3 header not supported\n");
		return BNXT_TF_RC_ERROR;
	}

	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_I_ETH)) {
		/* Since F2 flow does not include eth item, when parser detects
		 * IPv4/IPv6 item list and it belongs to the outer header; i.e.,
		 * o_ipv4/o_ipv6, check if O_ETH and I_ETH is set. If not set,
		 * then add offset sizeof(o_eth/oo_vlan/oi_vlan) to the index.
		 * This will allow the parser post processor to update the
		 * t_dmac in hdr_field[o_eth.dmac]
		 */
		idx += (BNXT_ULP_PROTO_HDR_ETH_NUM +
			BNXT_ULP_PROTO_HDR_VLAN_NUM);
		params->field_idx = idx;
	}

	/*
	 * Copy the rte_flow_item for ipv4 into hdr_field using ipv4
	 * header fields
	 */
	if (ipv4_spec) {
		size = sizeof(ipv4_spec->hdr.version_ihl);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&ipv4_spec->hdr.version_ihl,
						size);
		size = sizeof(ipv4_spec->hdr.type_of_service);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.type_of_service,
						size);
		size = sizeof(ipv4_spec->hdr.total_length);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.total_length,
						size);
		size = sizeof(ipv4_spec->hdr.packet_id);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.packet_id,
						size);
		size = sizeof(ipv4_spec->hdr.fragment_offset);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.fragment_offset,
						size);
		size = sizeof(ipv4_spec->hdr.time_to_live);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.time_to_live,
						size);
		size = sizeof(ipv4_spec->hdr.next_proto_id);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.next_proto_id,
						size);
		proto = ipv4_spec->hdr.next_proto_id;
		size = sizeof(ipv4_spec->hdr.hdr_checksum);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.hdr_checksum,
						size);
		size = sizeof(ipv4_spec->hdr.src_addr);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.src_addr,
						size);
		size = sizeof(ipv4_spec->hdr.dst_addr);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.dst_addr,
						size);
	}
	if (ipv4_mask) {
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.version_ihl,
				       sizeof(ipv4_mask->hdr.version_ihl));
		/*
		 * The tos field is ignored since OVS is setting it as wild card
		 * match and it is not supported. This is a work around and
		 * shall be addressed in the future.
		 */
		ulp_rte_prsr_mask_ignore(params, &idx,
					 &ipv4_mask->hdr.type_of_service,
					 sizeof(ipv4_mask->hdr.type_of_service)
					 );

		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.total_length,
				       sizeof(ipv4_mask->hdr.total_length));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.packet_id,
				       sizeof(ipv4_mask->hdr.packet_id));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.fragment_offset,
				       sizeof(ipv4_mask->hdr.fragment_offset));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.time_to_live,
				       sizeof(ipv4_mask->hdr.time_to_live));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.next_proto_id,
				       sizeof(ipv4_mask->hdr.next_proto_id));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.hdr_checksum,
				       sizeof(ipv4_mask->hdr.hdr_checksum));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.src_addr,
				       sizeof(ipv4_mask->hdr.src_addr));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.dst_addr,
				       sizeof(ipv4_mask->hdr.dst_addr));
	}
	/* Add the number of ipv4 header elements */
	params->field_idx += BNXT_ULP_PROTO_HDR_IPV4_NUM;

	/* Set the ipv4 header bitmap and computed l3 header bitmaps */
	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4) ||
	    ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV6)) {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_IPV4);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L3, 1);
		inner_flag = 1;
	} else {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, 1);
	}

	/* Some of the PMD applications may set the protocol field
	 * in the IPv4 spec but don't set the mask. So, consider
	 * the mask in the proto value calculation.
	 */
	if (ipv4_mask)
		proto &= ipv4_mask->hdr.next_proto_id;

	/* Update the field protocol hdr bitmap */
	ulp_rte_l3_proto_type_update(params, proto, inner_flag);
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L3_HDR_CNT, ++cnt);
	return BNXT_TF_RC_SUCCESS;
}
/* Function to handle the parsing of RTE Flow item IPV4 Header. */
Function to handle the parsing of RTE Flow item IPV4 Header.
Function to handle the parsing of RTE Flow item IPV4 Header .
int32_t
ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item,
			 struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_ipv4 *ipv4_spec = item->spec;
	const struct rte_flow_item_ipv4 *ipv4_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	struct ulp_rte_hdr_bitmap *hdr_bitmap = &params->hdr_bitmap;
	uint32_t idx = params->field_idx;
	uint32_t size;
	uint8_t proto = 0;
	uint32_t inner_flag = 0;
	uint32_t cnt;
	cnt = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_L3_HDR_CNT);
	if (cnt == 2) {
		BNXT_TF_DBG(ERR, "Parse Err:Third L3 header not supported\n");
		return BNXT_TF_RC_ERROR;
	}
	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_I_ETH)) {
		idx += (BNXT_ULP_PROTO_HDR_ETH_NUM +
			BNXT_ULP_PROTO_HDR_VLAN_NUM);
		params->field_idx = idx;
	}
	if (ipv4_spec) {
		size = sizeof(ipv4_spec->hdr.version_ihl);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&ipv4_spec->hdr.version_ihl,
						size);
		size = sizeof(ipv4_spec->hdr.type_of_service);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.type_of_service,
						size);
		size = sizeof(ipv4_spec->hdr.total_length);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.total_length,
						size);
		size = sizeof(ipv4_spec->hdr.packet_id);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.packet_id,
						size);
		size = sizeof(ipv4_spec->hdr.fragment_offset);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.fragment_offset,
						size);
		size = sizeof(ipv4_spec->hdr.time_to_live);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.time_to_live,
						size);
		size = sizeof(ipv4_spec->hdr.next_proto_id);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.next_proto_id,
						size);
		proto = ipv4_spec->hdr.next_proto_id;
		size = sizeof(ipv4_spec->hdr.hdr_checksum);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.hdr_checksum,
						size);
		size = sizeof(ipv4_spec->hdr.src_addr);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.src_addr,
						size);
		size = sizeof(ipv4_spec->hdr.dst_addr);
		field = ulp_rte_parser_fld_copy(field,
						&ipv4_spec->hdr.dst_addr,
						size);
	}
	if (ipv4_mask) {
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.version_ihl,
				       sizeof(ipv4_mask->hdr.version_ihl));
		ulp_rte_prsr_mask_ignore(params, &idx,
					 &ipv4_mask->hdr.type_of_service,
					 sizeof(ipv4_mask->hdr.type_of_service)
					 );
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.total_length,
				       sizeof(ipv4_mask->hdr.total_length));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.packet_id,
				       sizeof(ipv4_mask->hdr.packet_id));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.fragment_offset,
				       sizeof(ipv4_mask->hdr.fragment_offset));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.time_to_live,
				       sizeof(ipv4_mask->hdr.time_to_live));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.next_proto_id,
				       sizeof(ipv4_mask->hdr.next_proto_id));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.hdr_checksum,
				       sizeof(ipv4_mask->hdr.hdr_checksum));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.src_addr,
				       sizeof(ipv4_mask->hdr.src_addr));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &ipv4_mask->hdr.dst_addr,
				       sizeof(ipv4_mask->hdr.dst_addr));
	}
	params->field_idx += BNXT_ULP_PROTO_HDR_IPV4_NUM;
	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4) ||
	    ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV6)) {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_IPV4);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L3, 1);
		inner_flag = 1;
	} else {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, 1);
	}
	if (ipv4_mask)
		proto &= ipv4_mask->hdr.next_proto_id;
	ulp_rte_l3_proto_type_update(params, proto, inner_flag);
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L3_HDR_CNT, ++cnt);
	return BNXT_TF_RC_SUCCESS;
}
int32_t ulp_rte_ipv4_hdr_handler ( const struct rte_flow_item * item , struct ulp_rte_parser_params * params ) { const struct rte_flow_item_ipv4 * ipv4_spec = item -> spec ; const struct rte_flow_item_ipv4 * ipv4_mask = item -> mask ; struct ulp_rte_hdr_field * field ; struct ulp_rte_hdr_bitmap * hdr_bitmap = & params -> hdr_bitmap ; uint32_t idx = params -> field_idx ; uint32_t size ; uint8_t proto = 0 ; uint32_t inner_flag = 0 ; uint32_t cnt ; cnt = ULP_COMP_FLD_IDX_RD ( params , BNXT_ULP_CF_IDX_L3_HDR_CNT ) ; if ( cnt == 2 ) { BNXT_TF_DBG ( ERR , " \n " ) ; return BNXT_TF_RC_ERROR ; } 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_I_ETH ) ) { idx += ( BNXT_ULP_PROTO_HDR_ETH_NUM + BNXT_ULP_PROTO_HDR_VLAN_NUM ) ; params -> field_idx = idx ; } if ( ipv4_spec ) { size = sizeof ( ipv4_spec -> hdr . version_ihl ) ; field = ulp_rte_parser_fld_copy ( & params -> hdr_field [ idx ] , & ipv4_spec -> hdr . version_ihl , size ) ; size = sizeof ( ipv4_spec -> hdr . type_of_service ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . type_of_service , size ) ; size = sizeof ( ipv4_spec -> hdr . total_length ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . total_length , size ) ; size = sizeof ( ipv4_spec -> hdr . packet_id ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . packet_id , size ) ; size = sizeof ( ipv4_spec -> hdr . fragment_offset ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . fragment_offset , size ) ; size = sizeof ( ipv4_spec -> hdr . time_to_live ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . time_to_live , size ) ; size = sizeof ( ipv4_spec -> hdr . next_proto_id ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . next_proto_id , size ) ; proto = ipv4_spec -> hdr . next_proto_id ; size = sizeof ( ipv4_spec -> hdr . hdr_checksum ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . hdr_checksum , size ) ; size = sizeof ( ipv4_spec -> hdr . src_addr ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . src_addr , size ) ; size = sizeof ( ipv4_spec -> hdr . dst_addr ) ; field = ulp_rte_parser_fld_copy ( field , & ipv4_spec -> hdr . dst_addr , size ) ; } if ( ipv4_mask ) { ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . version_ihl , sizeof ( ipv4_mask -> hdr . version_ihl ) ) ; ulp_rte_prsr_mask_ignore ( params , & idx , & ipv4_mask -> hdr . type_of_service , sizeof ( ipv4_mask -> hdr . type_of_service ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . total_length , sizeof ( ipv4_mask -> hdr . total_length ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . packet_id , sizeof ( ipv4_mask -> hdr . packet_id ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . fragment_offset , sizeof ( ipv4_mask -> hdr . fragment_offset ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . time_to_live , sizeof ( ipv4_mask -> hdr . time_to_live ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . next_proto_id , sizeof ( ipv4_mask -> hdr . next_proto_id ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . hdr_checksum , sizeof ( ipv4_mask -> hdr . hdr_checksum ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . src_addr , sizeof ( ipv4_mask -> hdr . src_addr ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & ipv4_mask -> hdr . dst_addr , sizeof ( ipv4_mask -> hdr . dst_addr ) ) ; } params -> field_idx += BNXT_ULP_PROTO_HDR_IPV4_NUM ; if ( ULP_BITMAP_ISSET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_IPV4 ) || ULP_BITMAP_ISSET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_IPV6 ) ) { ULP_BITMAP_SET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_I_IPV4 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_L3 , 1 ) ; inner_flag = 1 ; } else { ULP_BITMAP_SET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_IPV4 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_L3 , 1 ) ; } if ( ipv4_mask ) proto &= ipv4_mask -> hdr . next_proto_id ; ulp_rte_l3_proto_type_update ( params , proto , inner_flag ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_L3_HDR_CNT , ++ cnt ) ; return BNXT_TF_RC_SUCCESS ; }
Function to handle the parsing of RTE Flow item IPV4 Header.
Function to handle the parsing of RTE Flow item IPV4 Header .
/* validate there are no 3rd L3 header */ /* Since F2 flow does not include eth item, when parser detects
		 * IPv4/IPv6 item list and it belongs to the outer header; i.e.,
		 * o_ipv4/o_ipv6, check if O_ETH and I_ETH is set. If not set,
		 * then add offset sizeof(o_eth/oo_vlan/oi_vlan) to the index.
		 * This will allow the parser post processor to update the
		 * t_dmac in hdr_field[o_eth.dmac]
		 */ /*
	 * Copy the rte_flow_item for ipv4 into hdr_field using ipv4
	 * header fields
	 */ /*
		 * The tos field is ignored since OVS is setting it as wild card
		 * match and it is not supported. This is a work around and
		 * shall be addressed in the future.
		 */ /* Add the number of ipv4 header elements */ /* Set the ipv4 header bitmap and computed l3 header bitmaps */ /* Some of the PMD applications may set the protocol field
	 * in the IPv4 spec but don't set the mask. So, consider
	 * the mask in the proto value calculation.
	 */ /* Update the field protocol hdr bitmap */