src/dpdk/drivers/net/mvpp2/mrvl_flow.c
static int
mrvl_parse_init(const struct rte_flow_item *item,
		const void **spec_ptr,
		const void **mask_ptr,
		const void *def_mask,
		unsigned int size,
		struct rte_flow_error *error)
{
	const uint8_t *spec;
	const uint8_t *mask;
	const uint8_t *last;
	uint8_t zeros[size];

	memset(zeros, 0, size);

	if (item == NULL) {
		rte_flow_error_set(error, EINVAL,
				   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
				   "NULL item\n");
		return -rte_errno;
	}

	if ((item->last != NULL || item->mask != NULL) && item->spec == NULL) {
		rte_flow_error_set(error, EINVAL,
				   RTE_FLOW_ERROR_TYPE_ITEM, item,
				   "Mask or last is set without spec\n");
		return -rte_errno;
	}

	/*
	 * If "mask" is not set, default mask is used,
	 * but if default mask is NULL, "mask" should be set.
	 */
	if (item->mask == NULL) {
		if (def_mask == NULL) {
			rte_flow_error_set(error, EINVAL,
					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
					   "Mask should be specified\n");
			return -rte_errno;
		}

		mask = (const uint8_t *)def_mask;
	} else {
		mask = (const uint8_t *)item->mask;
	}

	spec = (const uint8_t *)item->spec;
	last = (const uint8_t *)item->last;

	if (spec == NULL) {
		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
				   NULL, "Spec should be specified\n");
		return -rte_errno;
	}

	/*
	 * If field values in "last" are either 0 or equal to the corresponding
	 * values in "spec" then they are ignored.
	 */
	if (last != NULL &&
	    !memcmp(last, zeros, size) &&
	    memcmp(last, spec, size) != 0) {
		rte_flow_error_set(error, ENOTSUP,
				   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
				   "Ranging is not supported\n");
		return -rte_errno;
	}

	*spec_ptr = spec;
	*mask_ptr = mask;

	return 0;
}
/*
 * Initialize rte flow item parsing.
 *
 * @param item Pointer to the flow item.
 * @param spec_ptr Pointer to the specific item pointer.
 * @param mask_ptr Pointer to the specific item's mask pointer.
 * @def_mask Pointer to the default mask.
 * @size Size of the flow item.
 * @error Pointer to the rte flow error.
 * @returns 0 in case of success, negative value otherwise.
 */
Initialize rte flow item parsing.
@param item Pointer to the flow item.
@param spec_ptr Pointer to the specific item pointer.
@param mask_ptr Pointer to the specific item's mask pointer.
@def_mask Pointer to the default mask.
@size Size of the flow item.
@error Pointer to the rte flow error.
@returns 0 in case of success, negative value otherwise.
Initialize rte flow item parsing . @param item Pointer to the flow item . @param spec_ptr Pointer to the specific item pointer . @param mask_ptr Pointer to the specific item ' s mask pointer . @def_mask Pointer to the default mask . @size Size of the flow item . @error Pointer to the rte flow error . @returns 0 in case of success negative value otherwise .
static int
mrvl_parse_init(const struct rte_flow_item *item,
		const void **spec_ptr,
		const void **mask_ptr,
		const void *def_mask,
		unsigned int size,
		struct rte_flow_error *error)
{
	const uint8_t *spec;
	const uint8_t *mask;
	const uint8_t *last;
	uint8_t zeros[size];
	memset(zeros, 0, size);
	if (item == NULL) {
		rte_flow_error_set(error, EINVAL,
				   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
				   "NULL item\n");
		return -rte_errno;
	}
	if ((item->last != NULL || item->mask != NULL) && item->spec == NULL) {
		rte_flow_error_set(error, EINVAL,
				   RTE_FLOW_ERROR_TYPE_ITEM, item,
				   "Mask or last is set without spec\n");
		return -rte_errno;
	}
	if (item->mask == NULL) {
		if (def_mask == NULL) {
			rte_flow_error_set(error, EINVAL,
					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
					   "Mask should be specified\n");
			return -rte_errno;
		}
		mask = (const uint8_t *)def_mask;
	} else {
		mask = (const uint8_t *)item->mask;
	}
	spec = (const uint8_t *)item->spec;
	last = (const uint8_t *)item->last;
	if (spec == NULL) {
		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
				   NULL, "Spec should be specified\n");
		return -rte_errno;
	}
	if (last != NULL &&
	    !memcmp(last, zeros, size) &&
	    memcmp(last, spec, size) != 0) {
		rte_flow_error_set(error, ENOTSUP,
				   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
				   "Ranging is not supported\n");
		return -rte_errno;
	}
	*spec_ptr = spec;
	*mask_ptr = mask;
	return 0;
}
static int mrvl_parse_init ( const struct rte_flow_item * item , const void * * spec_ptr , const void * * mask_ptr , const void * def_mask , unsigned int size , struct rte_flow_error * error ) { const uint8_t * spec ; const uint8_t * mask ; const uint8_t * last ; uint8_t zeros [ size ] ; memset ( zeros , 0 , size ) ; if ( item == NULL ) { rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " \n " ) ; return - rte_errno ; } if ( ( item -> last != NULL || item -> mask != NULL ) && item -> spec == NULL ) { rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " \n " ) ; return - rte_errno ; } if ( item -> mask == NULL ) { if ( def_mask == NULL ) { rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " \n " ) ; return - rte_errno ; } mask = ( const uint8_t * ) def_mask ; } else { mask = ( const uint8_t * ) item -> mask ; } spec = ( const uint8_t * ) item -> spec ; last = ( const uint8_t * ) item -> last ; if ( spec == NULL ) { rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " \n " ) ; return - rte_errno ; } if ( last != NULL && ! memcmp ( last , zeros , size ) && memcmp ( last , spec , size ) != 0 ) { rte_flow_error_set ( error , ENOTSUP , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " \n " ) ; return - rte_errno ; } * spec_ptr = spec ; * mask_ptr = mask ; return 0 ; }
Initialize rte flow item parsing.
Initialize rte flow item parsing .
/*
	 * If "mask" is not set, default mask is used,
	 * but if default mask is NULL, "mask" should be set.
	 */ /*
	 * If field values in "last" are either 0 or equal to the corresponding
	 * values in "spec" then they are ignored.
	 */