src/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
int32_t
ulp_rte_vlan_hdr_handler(const struct rte_flow_item *item,
			 struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_vlan *vlan_spec = item->spec;
	const struct rte_flow_item_vlan *vlan_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	struct ulp_rte_hdr_bitmap	*hdr_bit;
	uint32_t idx = params->vlan_idx;
	uint16_t vlan_tag, priority;
	uint32_t outer_vtag_num;
	uint32_t inner_vtag_num;
	uint16_t eth_type = 0;
	uint32_t inner_flag = 0;

	/*
	 * Copy the rte_flow_item for vlan into hdr_field using Vlan
	 * header fields
	 */
	if (vlan_spec) {
		vlan_tag = ntohs(vlan_spec->tci);
		priority = htons(vlan_tag >> ULP_VLAN_PRIORITY_SHIFT);
		vlan_tag &= ULP_VLAN_TAG_MASK;
		vlan_tag = htons(vlan_tag);

		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&priority,
						sizeof(priority));
		field = ulp_rte_parser_fld_copy(field,
						&vlan_tag,
						sizeof(vlan_tag));
		field = ulp_rte_parser_fld_copy(field,
						&vlan_spec->inner_type,
						sizeof(vlan_spec->inner_type));
		eth_type = vlan_spec->inner_type;
	}

	if (vlan_mask) {
		vlan_tag = ntohs(vlan_mask->tci);
		priority = htons(vlan_tag >> ULP_VLAN_PRIORITY_SHIFT);
		vlan_tag &= 0xfff;

		/*
		 * the storage for priority and vlan tag is 2 bytes
		 * The mask of priority which is 3 bits if it is all 1's
		 * then make the rest bits 13 bits as 1's
		 * so that it is matched as exact match.
		 */
		if (priority == ULP_VLAN_PRIORITY_MASK)
			priority |= ~ULP_VLAN_PRIORITY_MASK;
		if (vlan_tag == ULP_VLAN_TAG_MASK)
			vlan_tag |= ~ULP_VLAN_TAG_MASK;
		vlan_tag = htons(vlan_tag);

		/*
		 * The priority 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, &priority,
					 sizeof(priority));

		ulp_rte_prsr_mask_copy(params, &idx, &vlan_tag,
				       sizeof(vlan_tag));
		ulp_rte_prsr_mask_copy(params, &idx, &vlan_mask->inner_type,
				       sizeof(vlan_mask->inner_type));
	}
	/* Set the vlan index to new incremented value */
	params->vlan_idx += BNXT_ULP_PROTO_HDR_S_VLAN_NUM;

	/* Get the outer tag and inner tag counts */
	outer_vtag_num = ULP_COMP_FLD_IDX_RD(params,
					     BNXT_ULP_CF_IDX_O_VTAG_NUM);
	inner_vtag_num = ULP_COMP_FLD_IDX_RD(params,
					     BNXT_ULP_CF_IDX_I_VTAG_NUM);

	/* Update the hdr_bitmap of the vlans */
	hdr_bit = &params->hdr_bitmap;
	if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
	    !ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
	    !outer_vtag_num) {
		/* Update the vlan tag num */
		outer_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
				    outer_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_NO_VTAG, 0);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 1);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_OO_VLAN);
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   !ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   outer_vtag_num == 1) {
		/* update the vlan tag num */
		outer_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
				    outer_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_TWO_VTAGS, 1);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 0);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_OI_VLAN);
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   !inner_vtag_num) {
		/* update the vlan tag num */
		inner_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
				    inner_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_NO_VTAG, 0);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 1);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_IO_VLAN);
		inner_flag = 1;
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   inner_vtag_num == 1) {
		/* update the vlan tag num */
		inner_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
				    inner_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_TWO_VTAGS, 1);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 0);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_II_VLAN);
		inner_flag = 1;
	} else {
		BNXT_TF_DBG(ERR, "Error Parsing:Vlan hdr found withtout eth\n");
		return BNXT_TF_RC_ERROR;
	}
	/* 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 Vlan Header. */
Function to handle the parsing of RTE Flow item Vlan Header.
Function to handle the parsing of RTE Flow item Vlan Header .
int32_t
ulp_rte_vlan_hdr_handler(const struct rte_flow_item *item,
			 struct ulp_rte_parser_params *params)
{
	const struct rte_flow_item_vlan *vlan_spec = item->spec;
	const struct rte_flow_item_vlan *vlan_mask = item->mask;
	struct ulp_rte_hdr_field *field;
	struct ulp_rte_hdr_bitmap	*hdr_bit;
	uint32_t idx = params->vlan_idx;
	uint16_t vlan_tag, priority;
	uint32_t outer_vtag_num;
	uint32_t inner_vtag_num;
	uint16_t eth_type = 0;
	uint32_t inner_flag = 0;
	if (vlan_spec) {
		vlan_tag = ntohs(vlan_spec->tci);
		priority = htons(vlan_tag >> ULP_VLAN_PRIORITY_SHIFT);
		vlan_tag &= ULP_VLAN_TAG_MASK;
		vlan_tag = htons(vlan_tag);
		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
						&priority,
						sizeof(priority));
		field = ulp_rte_parser_fld_copy(field,
						&vlan_tag,
						sizeof(vlan_tag));
		field = ulp_rte_parser_fld_copy(field,
						&vlan_spec->inner_type,
						sizeof(vlan_spec->inner_type));
		eth_type = vlan_spec->inner_type;
	}
	if (vlan_mask) {
		vlan_tag = ntohs(vlan_mask->tci);
		priority = htons(vlan_tag >> ULP_VLAN_PRIORITY_SHIFT);
		vlan_tag &= 0xfff;
		if (priority == ULP_VLAN_PRIORITY_MASK)
			priority |= ~ULP_VLAN_PRIORITY_MASK;
		if (vlan_tag == ULP_VLAN_TAG_MASK)
			vlan_tag |= ~ULP_VLAN_TAG_MASK;
		vlan_tag = htons(vlan_tag);
		ulp_rte_prsr_mask_ignore(params, &idx, &priority,
					 sizeof(priority));
		ulp_rte_prsr_mask_copy(params, &idx, &vlan_tag,
				       sizeof(vlan_tag));
		ulp_rte_prsr_mask_copy(params, &idx, &vlan_mask->inner_type,
				       sizeof(vlan_mask->inner_type));
	}
	params->vlan_idx += BNXT_ULP_PROTO_HDR_S_VLAN_NUM;
	outer_vtag_num = ULP_COMP_FLD_IDX_RD(params,
					     BNXT_ULP_CF_IDX_O_VTAG_NUM);
	inner_vtag_num = ULP_COMP_FLD_IDX_RD(params,
					     BNXT_ULP_CF_IDX_I_VTAG_NUM);
	hdr_bit = &params->hdr_bitmap;
	if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
	    !ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
	    !outer_vtag_num) {
		outer_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
				    outer_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_NO_VTAG, 0);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 1);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_OO_VLAN);
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   !ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   outer_vtag_num == 1) {
		outer_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_VTAG_NUM,
				    outer_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_TWO_VTAGS, 1);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_ONE_VTAG, 0);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_OI_VLAN);
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   !inner_vtag_num) {
		inner_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
				    inner_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_NO_VTAG, 0);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 1);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_IO_VLAN);
		inner_flag = 1;
	} else if (ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_O_ETH) &&
		   ULP_BITMAP_ISSET(hdr_bit->bits, BNXT_ULP_HDR_BIT_I_ETH) &&
		   inner_vtag_num == 1) {
		inner_vtag_num++;
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_VTAG_NUM,
				    inner_vtag_num);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_TWO_VTAGS, 1);
		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_I_ONE_VTAG, 0);
		ULP_BITMAP_SET(params->hdr_bitmap.bits,
			       BNXT_ULP_HDR_BIT_II_VLAN);
		inner_flag = 1;
	} else {
		BNXT_TF_DBG(ERR, "Error Parsing:Vlan hdr found withtout eth\n");
		return BNXT_TF_RC_ERROR;
	}
	ulp_rte_l2_proto_type_update(params, eth_type, inner_flag);
	return BNXT_TF_RC_SUCCESS;
}
int32_t ulp_rte_vlan_hdr_handler ( const struct rte_flow_item * item , struct ulp_rte_parser_params * params ) { const struct rte_flow_item_vlan * vlan_spec = item -> spec ; const struct rte_flow_item_vlan * vlan_mask = item -> mask ; struct ulp_rte_hdr_field * field ; struct ulp_rte_hdr_bitmap * hdr_bit ; uint32_t idx = params -> vlan_idx ; uint16_t vlan_tag , priority ; uint32_t outer_vtag_num ; uint32_t inner_vtag_num ; uint16_t eth_type = 0 ; uint32_t inner_flag = 0 ; if ( vlan_spec ) { vlan_tag = ntohs ( vlan_spec -> tci ) ; priority = htons ( vlan_tag >> ULP_VLAN_PRIORITY_SHIFT ) ; vlan_tag &= ULP_VLAN_TAG_MASK ; vlan_tag = htons ( vlan_tag ) ; field = ulp_rte_parser_fld_copy ( & params -> hdr_field [ idx ] , & priority , sizeof ( priority ) ) ; field = ulp_rte_parser_fld_copy ( field , & vlan_tag , sizeof ( vlan_tag ) ) ; field = ulp_rte_parser_fld_copy ( field , & vlan_spec -> inner_type , sizeof ( vlan_spec -> inner_type ) ) ; eth_type = vlan_spec -> inner_type ; } if ( vlan_mask ) { vlan_tag = ntohs ( vlan_mask -> tci ) ; priority = htons ( vlan_tag >> ULP_VLAN_PRIORITY_SHIFT ) ; vlan_tag &= 0xfff ; if ( priority == ULP_VLAN_PRIORITY_MASK ) priority |= ~ ULP_VLAN_PRIORITY_MASK ; if ( vlan_tag == ULP_VLAN_TAG_MASK ) vlan_tag |= ~ ULP_VLAN_TAG_MASK ; vlan_tag = htons ( vlan_tag ) ; ulp_rte_prsr_mask_ignore ( params , & idx , & priority , sizeof ( priority ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & vlan_tag , sizeof ( vlan_tag ) ) ; ulp_rte_prsr_mask_copy ( params , & idx , & vlan_mask -> inner_type , sizeof ( vlan_mask -> inner_type ) ) ; } params -> vlan_idx += BNXT_ULP_PROTO_HDR_S_VLAN_NUM ; outer_vtag_num = ULP_COMP_FLD_IDX_RD ( params , BNXT_ULP_CF_IDX_O_VTAG_NUM ) ; inner_vtag_num = ULP_COMP_FLD_IDX_RD ( params , BNXT_ULP_CF_IDX_I_VTAG_NUM ) ; hdr_bit = & params -> hdr_bitmap ; if ( ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_O_ETH ) && ! ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_I_ETH ) && ! outer_vtag_num ) { outer_vtag_num ++ ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_VTAG_NUM , outer_vtag_num ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_NO_VTAG , 0 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_ONE_VTAG , 1 ) ; ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_OO_VLAN ) ; } else if ( ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_O_ETH ) && ! ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_I_ETH ) && outer_vtag_num == 1 ) { outer_vtag_num ++ ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_VTAG_NUM , outer_vtag_num ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_TWO_VTAGS , 1 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_O_ONE_VTAG , 0 ) ; ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_OI_VLAN ) ; } else if ( ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_O_ETH ) && ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_I_ETH ) && ! inner_vtag_num ) { inner_vtag_num ++ ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_VTAG_NUM , inner_vtag_num ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_NO_VTAG , 0 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_ONE_VTAG , 1 ) ; ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_IO_VLAN ) ; inner_flag = 1 ; } else if ( ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_O_ETH ) && ULP_BITMAP_ISSET ( hdr_bit -> bits , BNXT_ULP_HDR_BIT_I_ETH ) && inner_vtag_num == 1 ) { inner_vtag_num ++ ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_VTAG_NUM , inner_vtag_num ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_TWO_VTAGS , 1 ) ; ULP_COMP_FLD_IDX_WR ( params , BNXT_ULP_CF_IDX_I_ONE_VTAG , 0 ) ; ULP_BITMAP_SET ( params -> hdr_bitmap . bits , BNXT_ULP_HDR_BIT_II_VLAN ) ; inner_flag = 1 ; } else { BNXT_TF_DBG ( ERR , " \n " ) ; return BNXT_TF_RC_ERROR ; } 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 Vlan Header.
Function to handle the parsing of RTE Flow item Vlan Header .
/*
	 * Copy the rte_flow_item for vlan into hdr_field using Vlan
	 * header fields
	 */ /*
		 * the storage for priority and vlan tag is 2 bytes
		 * The mask of priority which is 3 bits if it is all 1's
		 * then make the rest bits 13 bits as 1's
		 * so that it is matched as exact match.
		 */ /*
		 * The priority 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.
		 */ /* Set the vlan index to new incremented value */ /* Get the outer tag and inner tag counts */ /* Update the hdr_bitmap of the vlans */ /* Update the vlan tag num */ /* update the vlan tag num */ /* update the vlan tag num */ /* update the vlan tag num */ /* Update the field protocol hdr bitmap */