src/dpdk/drivers/net/enic/enic_flow.c
static int
enic_copy_filter(const struct rte_flow_item pattern[],
		 const struct enic_filter_cap *cap,
		 struct enic *enic,
		 struct filter_v2 *enic_filter,
		 struct rte_flow_error *error)
{
	int ret;
	const struct rte_flow_item *item = pattern;
	uint8_t inner_ofst = 0; /* If encapsulated, ofst into L5 */
	enum rte_flow_item_type prev_item;
	const struct enic_items *item_info;
	struct copy_item_args args;
	enic_copy_item_fn *copy_fn;
	uint8_t is_first_item = 1;

	ENICPMD_FUNC_TRACE();

	prev_item = 0;

	args.filter = enic_filter;
	args.inner_ofst = &inner_ofst;
	args.enic = enic;
	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
		/* Get info about how to validate and copy the item. If NULL
		 * is returned the nic does not support the item.
		 */
		if (item->type == RTE_FLOW_ITEM_TYPE_VOID)
			continue;

		item_info = &cap->item_info[item->type];
		if (item->type > cap->max_item_type ||
		    item_info->copy_item == NULL ||
		    (inner_ofst > 0 && item_info->inner_copy_item == NULL)) {
			rte_flow_error_set(error, ENOTSUP,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "Unsupported item.");
			return -rte_errno;
		}

		/* check to see if item stacking is valid */
		if (!item_stacking_valid(prev_item, item_info, is_first_item))
			goto stacking_error;

		args.item = item;
		copy_fn = inner_ofst > 0 ? item_info->inner_copy_item :
			item_info->copy_item;
		ret = copy_fn(&args);
		if (ret)
			goto item_not_supported;
		prev_item = item->type;
		is_first_item = 0;
	}
	fixup_l5_layer(enic, &enic_filter->u.generic_1, inner_ofst);

	return 0;

item_not_supported:
	rte_flow_error_set(error, ret, RTE_FLOW_ERROR_TYPE_ITEM,
			   NULL, "enic type error");
	return -rte_errno;

stacking_error:
	rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
			   item, "stacking error");
	return -rte_errno;
}
/**
 * Build the intenal enic filter structure from the provided pattern. The
 * pattern is validated as the items are copied.
 *
 * @param pattern[in]
 * @param items_info[in]
 *   Info about this NICs item support, like valid previous items.
 * @param enic_filter[out]
 *   NIC specfilc filters derived from the pattern.
 * @param error[out]
 */
Build the intenal enic filter structure from the provided pattern. The
pattern is validated as the items are copied.

@param pattern[in]
@param items_info[in]
Info about this NICs item support, like valid previous items.
@param enic_filter[out]
NIC specfilc filters derived from the pattern.
@param error[out]
Build the intenal enic filter structure from the provided pattern . The pattern is validated as the items are copied . @param pattern [ in ] @param items_info [ in ] Info about this NICs item support like valid previous items . @param enic_filter [ out ] NIC specfilc filters derived from the pattern . @param error [ out ]
static int
enic_copy_filter(const struct rte_flow_item pattern[],
		 const struct enic_filter_cap *cap,
		 struct enic *enic,
		 struct filter_v2 *enic_filter,
		 struct rte_flow_error *error)
{
	int ret;
	const struct rte_flow_item *item = pattern;
	uint8_t inner_ofst = 0; 
	enum rte_flow_item_type prev_item;
	const struct enic_items *item_info;
	struct copy_item_args args;
	enic_copy_item_fn *copy_fn;
	uint8_t is_first_item = 1;
	ENICPMD_FUNC_TRACE();
	prev_item = 0;
	args.filter = enic_filter;
	args.inner_ofst = &inner_ofst;
	args.enic = enic;
	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
		if (item->type == RTE_FLOW_ITEM_TYPE_VOID)
			continue;
		item_info = &cap->item_info[item->type];
		if (item->type > cap->max_item_type ||
		    item_info->copy_item == NULL ||
		    (inner_ofst > 0 && item_info->inner_copy_item == NULL)) {
			rte_flow_error_set(error, ENOTSUP,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "Unsupported item.");
			return -rte_errno;
		}
		if (!item_stacking_valid(prev_item, item_info, is_first_item))
			goto stacking_error;
		args.item = item;
		copy_fn = inner_ofst > 0 ? item_info->inner_copy_item :
			item_info->copy_item;
		ret = copy_fn(&args);
		if (ret)
			goto item_not_supported;
		prev_item = item->type;
		is_first_item = 0;
	}
	fixup_l5_layer(enic, &enic_filter->u.generic_1, inner_ofst);
	return 0;
item_not_supported:
	rte_flow_error_set(error, ret, RTE_FLOW_ERROR_TYPE_ITEM,
			   NULL, "enic type error");
	return -rte_errno;
stacking_error:
	rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
			   item, "stacking error");
	return -rte_errno;
}
static int enic_copy_filter ( const struct rte_flow_item pattern [ ] , const struct enic_filter_cap * cap , struct enic * enic , struct filter_v2 * enic_filter , struct rte_flow_error * error ) { int ret ; const struct rte_flow_item * item = pattern ; uint8_t inner_ofst = 0 ; enum rte_flow_item_type prev_item ; const struct enic_items * item_info ; struct copy_item_args args ; enic_copy_item_fn * copy_fn ; uint8_t is_first_item = 1 ; ENICPMD_FUNC_TRACE ( ) ; prev_item = 0 ; args . filter = enic_filter ; args . inner_ofst = & inner_ofst ; args . enic = enic ; for ( ; item -> type != RTE_FLOW_ITEM_TYPE_END ; item ++ ) { if ( item -> type == RTE_FLOW_ITEM_TYPE_VOID ) continue ; item_info = & cap -> item_info [ item -> type ] ; if ( item -> type > cap -> max_item_type || item_info -> copy_item == NULL || ( inner_ofst > 0 && item_info -> inner_copy_item == NULL ) ) { rte_flow_error_set ( error , ENOTSUP , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " ) ; return - rte_errno ; } if ( ! item_stacking_valid ( prev_item , item_info , is_first_item ) ) goto stacking_error ; args . item = item ; copy_fn = inner_ofst > 0 ? item_info -> inner_copy_item : item_info -> copy_item ; ret = copy_fn ( & args ) ; if ( ret ) goto item_not_supported ; prev_item = item -> type ; is_first_item = 0 ; } fixup_l5_layer ( enic , & enic_filter -> u . generic_1 , inner_ofst ) ; return 0 ; item_not_supported : rte_flow_error_set ( error , ret , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " ) ; return - rte_errno ; stacking_error : rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " " ) ; return - rte_errno ; }
Build the intenal enic filter structure from the provided pattern.
Build the intenal enic filter structure from the provided pattern .
/* If encapsulated, ofst into L5 */ /* Get info about how to validate and copy the item. If NULL
		 * is returned the nic does not support the item.
		 */ /* check to see if item stacking is valid */