src/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
int32_t
ulp_rte_udp_hdr_handler(const struct rte_flow_item *item,
			struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_udp *udp_spec = item->spec;
	const struct rte_flow_item_udp *udp_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;
	uint16_t dst_port = 0;
	uint32_t cnt;

	cnt = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_L4_HDR_CNT);
	if (cnt == 2) {
		BNXT_TF_DBG(ERR, "Parse Err:Third L4 header not supported\n");
		return BNXT_TF_RC_ERROR;
	}

	/*
	 * Copy the rte_flow_item for ipv4 into hdr_field using ipv4
	 * header fields
	 */
	if (udp_spec) {
		size = sizeof(udp_spec->hdr.src_port);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&udp_spec->hdr.src_port,
						size);

		size = sizeof(udp_spec->hdr.dst_port);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dst_port,
						size);
		dst_port = udp_spec->hdr.dst_port;
		size = sizeof(udp_spec->hdr.dgram_len);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dgram_len,
						size);
		size = sizeof(udp_spec->hdr.dgram_cksum);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dgram_cksum,
						size);
	}
	if (udp_mask) {
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.src_port,
				       sizeof(udp_mask->hdr.src_port));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dst_port,
				       sizeof(udp_mask->hdr.dst_port));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dgram_len,
				       sizeof(udp_mask->hdr.dgram_len));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dgram_cksum,
				       sizeof(udp_mask->hdr.dgram_cksum));
	}

	/* Add number of UDP header elements */
	params->field_idx += BNXT_ULP_PROTO_HDR_UDP_NUM;

	/* Set the udp header bitmap and computed l4 header bitmaps */
	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP) ||
	    ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_TCP)) {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_UDP);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L4, 1);
	} else {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L4, 1);
		/* Update the field protocol hdr bitmap */
		ulp_rte_l4_proto_type_update(params, dst_port);
	}
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L4_HDR_CNT, ++cnt);
	return BNXT_TF_RC_SUCCESS;
}
/* Function to handle the parsing of RTE Flow item UDP Header. */
Function to handle the parsing of RTE Flow item UDP Header.
Function to handle the parsing of RTE Flow item UDP Header .
int32_t
ulp_rte_udp_hdr_handler(const struct rte_flow_item *item,
			struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_udp *udp_spec = item->spec;
	const struct rte_flow_item_udp *udp_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;
	uint16_t dst_port = 0;
	uint32_t cnt;
	cnt = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_L4_HDR_CNT);
	if (cnt == 2) {
		BNXT_TF_DBG(ERR, "Parse Err:Third L4 header not supported\n");
		return BNXT_TF_RC_ERROR;
	}
	if (udp_spec) {
		size = sizeof(udp_spec->hdr.src_port);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&udp_spec->hdr.src_port,
						size);
		size = sizeof(udp_spec->hdr.dst_port);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dst_port,
						size);
		dst_port = udp_spec->hdr.dst_port;
		size = sizeof(udp_spec->hdr.dgram_len);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dgram_len,
						size);
		size = sizeof(udp_spec->hdr.dgram_cksum);
		field = ulp_rte_parser_fld_copy(field,
						&udp_spec->hdr.dgram_cksum,
						size);
	}
	if (udp_mask) {
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.src_port,
				       sizeof(udp_mask->hdr.src_port));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dst_port,
				       sizeof(udp_mask->hdr.dst_port));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dgram_len,
				       sizeof(udp_mask->hdr.dgram_len));
		ulp_rte_prsr_mask_copy(params, &idx,
				       &udp_mask->hdr.dgram_cksum,
				       sizeof(udp_mask->hdr.dgram_cksum));
	}
	params->field_idx += BNXT_ULP_PROTO_HDR_UDP_NUM;
	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP) ||
	    ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_TCP)) {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_UDP);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_L4, 1);
	} else {
		ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_UDP);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L4, 1);
		ulp_rte_l4_proto_type_update(params, dst_port);
	}
	ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L4_HDR_CNT, ++cnt);
	return BNXT_TF_RC_SUCCESS;
}
int32_t ulp_rte_udp_hdr_handler ( const struct rte_flow_item * item , struct ulp_rte_parser_params * params ) { const struct rte_flow_item_udp * udp_spec = item -> spec ; const struct rte_flow_item_udp * udp_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 ; uint16_t dst_port = 0 ; uint32_t cnt ; cnt = ULP_COMP_FLD_IDX_RD ( params , BNXT_ULP_CF_IDX_L4_HDR_CNT ) ; if ( cnt == 2 ) { BNXT_TF_DBG ( ERR , " \n " ) ; return BNXT_TF_RC_ERROR ; } if ( udp_spec ) { size = sizeof ( udp_spec -> hdr . src_port ) ; field = ulp_rte_parser_fld_copy ( & params -> hdr_field [ idx ] , & udp_spec -> hdr . src_port , size ) ; size = sizeof ( udp_spec -> hdr . dst_port ) ; field = ulp_rte_parser_fld_copy ( field , & udp_spec -> hdr . dst_port , size ) ; dst_port = udp_spec -> hdr . dst_port ; size = sizeof ( udp_spec -> hdr . dgram_len ) ; field = ulp_rte_parser_fld_copy ( field , & udp_spec -> hdr . dgram_len , size ) ; size = sizeof ( udp_spec -> hdr . dgram_cksum ) ; field = ulp_rte_parser_fld_copy ( field , & udp_spec -> hdr . dgram_cksum , size ) ; } if ( udp_mask ) { ulp_rte_prsr_mask_copy ( params , & idx , & udp_mask -> hdr . src_port , sizeof ( udp_mask -> hdr . src_port ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & udp_mask -> hdr . dst_port , sizeof ( udp_mask -> hdr . dst_port ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & udp_mask -> hdr . dgram_len , sizeof ( udp_mask -> hdr . dgram_len ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & udp_mask -> hdr . dgram_cksum , sizeof ( udp_mask -> hdr . dgram_cksum ) ) ; } params -> field_idx += BNXT_ULP_PROTO_HDR_UDP_NUM ; if ( ULP_BITMAP_ISSET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_UDP ) || ULP_BITMAP_ISSET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_TCP ) ) { ULP_BITMAP_SET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_I_UDP ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_L4 , 1 ) ; } else { ULP_BITMAP_SET ( hdr_bitmap -> bits , BNXT_ULP_HDR_BIT_O_UDP ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_L4 , 1 ) ; ulp_rte_l4_proto_type_update ( params , dst_port ) ; } ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_L4_HDR_CNT , ++ cnt ) ; return BNXT_TF_RC_SUCCESS ; }
Function to handle the parsing of RTE Flow item UDP Header.
Function to handle the parsing of RTE Flow item UDP Header .
/*
	 * Copy the rte_flow_item for ipv4 into hdr_field using ipv4
	 * header fields
	 */ /* Add number of UDP header elements */ /* Set the udp header bitmap and computed l4 header bitmaps */ /* Update the field protocol hdr bitmap */