src/dpdk/drivers/net/txgbe/txgbe_flow.c
static int
txgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
			  const struct rte_flow_action actions[],
			  struct txgbe_fdir_rule *rule,
			  struct rte_flow_error *error)
{
	const struct rte_flow_action *act;
	const struct rte_flow_action_queue *act_q;
	const struct rte_flow_action_mark *mark;

	/* parse attr */
	/* must be input direction */
	if (!attr->ingress) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
			attr, "Only support ingress.");
		return -rte_errno;
	}

	/* not supported */
	if (attr->egress) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
			attr, "Not support egress.");
		return -rte_errno;
	}

	/* not supported */
	if (attr->transfer) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
			attr, "No support for transfer.");
		return -rte_errno;
	}

	/* not supported */
	if (attr->priority) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
			attr, "Not support priority.");
		return -rte_errno;
	}

	/* check if the first not void action is QUEUE or DROP. */
	act = next_no_void_action(actions, NULL);
	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
	    act->type != RTE_FLOW_ACTION_TYPE_DROP) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}

	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
		act_q = (const struct rte_flow_action_queue *)act->conf;
		rule->queue = act_q->index;
	} else { /* drop */
		/* signature mode does not support drop action. */
		if (rule->mode == RTE_FDIR_MODE_SIGNATURE) {
			memset(rule, 0, sizeof(struct txgbe_fdir_rule));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ACTION,
				act, "Not supported action.");
			return -rte_errno;
		}
		rule->fdirflags = TXGBE_FDIRPICMD_DROP;
	}

	/* check if the next not void item is MARK */
	act = next_no_void_action(actions, act);
	if (act->type != RTE_FLOW_ACTION_TYPE_MARK &&
		act->type != RTE_FLOW_ACTION_TYPE_END) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}

	rule->soft_id = 0;

	if (act->type == RTE_FLOW_ACTION_TYPE_MARK) {
		mark = (const struct rte_flow_action_mark *)act->conf;
		rule->soft_id = mark->id;
		act = next_no_void_action(actions, act);
	}

	/* check if the next not void item is END */
	if (act->type != RTE_FLOW_ACTION_TYPE_END) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}

	return 0;
}
/* Parse to get the attr and action info of flow director rule. */
Parse to get the attr and action info of flow director rule.
Parse to get the attr and action info of flow director rule .
static int
txgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
			  const struct rte_flow_action actions[],
			  struct txgbe_fdir_rule *rule,
			  struct rte_flow_error *error)
{
	const struct rte_flow_action *act;
	const struct rte_flow_action_queue *act_q;
	const struct rte_flow_action_mark *mark;
	if (!attr->ingress) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
			attr, "Only support ingress.");
		return -rte_errno;
	}
	if (attr->egress) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
			attr, "Not support egress.");
		return -rte_errno;
	}
	if (attr->transfer) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
			attr, "No support for transfer.");
		return -rte_errno;
	}
	if (attr->priority) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
			attr, "Not support priority.");
		return -rte_errno;
	}
	act = next_no_void_action(actions, NULL);
	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
	    act->type != RTE_FLOW_ACTION_TYPE_DROP) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}
	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
		act_q = (const struct rte_flow_action_queue *)act->conf;
		rule->queue = act_q->index;
	} else { 
		if (rule->mode == RTE_FDIR_MODE_SIGNATURE) {
			memset(rule, 0, sizeof(struct txgbe_fdir_rule));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ACTION,
				act, "Not supported action.");
			return -rte_errno;
		}
		rule->fdirflags = TXGBE_FDIRPICMD_DROP;
	}
	act = next_no_void_action(actions, act);
	if (act->type != RTE_FLOW_ACTION_TYPE_MARK &&
		act->type != RTE_FLOW_ACTION_TYPE_END) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}
	rule->soft_id = 0;
	if (act->type == RTE_FLOW_ACTION_TYPE_MARK) {
		mark = (const struct rte_flow_action_mark *)act->conf;
		rule->soft_id = mark->id;
		act = next_no_void_action(actions, act);
	}
	if (act->type != RTE_FLOW_ACTION_TYPE_END) {
		memset(rule, 0, sizeof(struct txgbe_fdir_rule));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ACTION,
			act, "Not supported action.");
		return -rte_errno;
	}
	return 0;
}
static int txgbe_parse_fdir_act_attr ( const struct rte_flow_attr * attr , const struct rte_flow_action actions [ ] , struct txgbe_fdir_rule * rule , struct rte_flow_error * error ) { const struct rte_flow_action * act ; const struct rte_flow_action_queue * act_q ; const struct rte_flow_action_mark * mark ; if ( ! attr -> ingress ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , attr , " " ) ; return - rte_errno ; } if ( attr -> egress ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , attr , " " ) ; return - rte_errno ; } if ( attr -> transfer ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , attr , " " ) ; return - rte_errno ; } if ( attr -> priority ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr , " " ) ; return - rte_errno ; } act = next_no_void_action ( actions , NULL ) ; if ( act -> type != RTE_FLOW_ACTION_TYPE_QUEUE && act -> type != RTE_FLOW_ACTION_TYPE_DROP ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ACTION , act , " " ) ; return - rte_errno ; } if ( act -> type == RTE_FLOW_ACTION_TYPE_QUEUE ) { act_q = ( const struct rte_flow_action_queue * ) act -> conf ; rule -> queue = act_q -> index ; } else { if ( rule -> mode == RTE_FDIR_MODE_SIGNATURE ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ACTION , act , " " ) ; return - rte_errno ; } rule -> fdirflags = TXGBE_FDIRPICMD_DROP ; } act = next_no_void_action ( actions , act ) ; if ( act -> type != RTE_FLOW_ACTION_TYPE_MARK && act -> type != RTE_FLOW_ACTION_TYPE_END ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ACTION , act , " " ) ; return - rte_errno ; } rule -> soft_id = 0 ; if ( act -> type == RTE_FLOW_ACTION_TYPE_MARK ) { mark = ( const struct rte_flow_action_mark * ) act -> conf ; rule -> soft_id = mark -> id ; act = next_no_void_action ( actions , act ) ; } if ( act -> type != RTE_FLOW_ACTION_TYPE_END ) { memset ( rule , 0 , sizeof ( struct txgbe_fdir_rule ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ACTION , act , " " ) ; return - rte_errno ; } return 0 ; }
Parse to get the attr and action info of flow director rule.
Parse to get the attr and action info of flow director rule .
/* parse attr */ /* must be input direction */ /* not supported */ /* not supported */ /* not supported */ /* check if the first not void action is QUEUE or DROP. */ /* drop */ /* signature mode does not support drop action. */ /* check if the next not void item is MARK */ /* check if the next not void item is END */