src/dpdk/drivers/net/e1000/igb_flow.c
static int
igb_parse_ntuple_filter(struct rte_eth_dev *dev,
			  const struct rte_flow_attr *attr,
			  const struct rte_flow_item pattern[],
			  const struct rte_flow_action actions[],
			  struct rte_eth_ntuple_filter *filter,
			  struct rte_flow_error *error)
{
	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	int ret;

	MAC_TYPE_FILTER_SUP(hw->mac.type);

	ret = cons_parse_ntuple_filter(attr, pattern, actions, filter, error);

	if (ret)
		return ret;

	/* Igb doesn't support many priorities. */
	if (filter->priority > E1000_2TUPLE_MAX_PRI) {
		memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ITEM,
			NULL, "Priority not supported by ntuple filter");
		return -rte_errno;
	}

	if (hw->mac.type == e1000_82576) {
		if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "queue number not "
				"supported by ntuple filter");
			return -rte_errno;
		}
		filter->flags |= RTE_5TUPLE_FLAGS;
	} else {
		if (filter->src_ip_mask || filter->dst_ip_mask ||
			filter->src_port_mask) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "only two tuple are "
				"supported by this filter");
			return -rte_errno;
		}
		if (filter->queue >= IGB_MAX_RX_QUEUE_NUM) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "queue number not "
				"supported by ntuple filter");
			return -rte_errno;
		}
		filter->flags |= RTE_2TUPLE_FLAGS;
	}

	return 0;
}
/* a specific function for igb because the flags is specific */
a specific function for igb because the flags is specific
a specific function for igb because the flags is specific
static int
igb_parse_ntuple_filter(struct rte_eth_dev *dev,
			  const struct rte_flow_attr *attr,
			  const struct rte_flow_item pattern[],
			  const struct rte_flow_action actions[],
			  struct rte_eth_ntuple_filter *filter,
			  struct rte_flow_error *error)
{
	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	int ret;
	MAC_TYPE_FILTER_SUP(hw->mac.type);
	ret = cons_parse_ntuple_filter(attr, pattern, actions, filter, error);
	if (ret)
		return ret;
	if (filter->priority > E1000_2TUPLE_MAX_PRI) {
		memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
		rte_flow_error_set(error, EINVAL,
			RTE_FLOW_ERROR_TYPE_ITEM,
			NULL, "Priority not supported by ntuple filter");
		return -rte_errno;
	}
	if (hw->mac.type == e1000_82576) {
		if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "queue number not "
				"supported by ntuple filter");
			return -rte_errno;
		}
		filter->flags |= RTE_5TUPLE_FLAGS;
	} else {
		if (filter->src_ip_mask || filter->dst_ip_mask ||
			filter->src_port_mask) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "only two tuple are "
				"supported by this filter");
			return -rte_errno;
		}
		if (filter->queue >= IGB_MAX_RX_QUEUE_NUM) {
			memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
			rte_flow_error_set(error, EINVAL,
				RTE_FLOW_ERROR_TYPE_ITEM,
				NULL, "queue number not "
				"supported by ntuple filter");
			return -rte_errno;
		}
		filter->flags |= RTE_2TUPLE_FLAGS;
	}
	return 0;
}
static int igb_parse_ntuple_filter ( struct rte_eth_dev * dev , const struct rte_flow_attr * attr , const struct rte_flow_item pattern [ ] , const struct rte_flow_action actions [ ] , struct rte_eth_ntuple_filter * filter , struct rte_flow_error * error ) { struct e1000_hw * hw = E1000_DEV_PRIVATE_TO_HW ( dev -> data -> dev_private ) ; int ret ; MAC_TYPE_FILTER_SUP ( hw -> mac . type ) ; ret = cons_parse_ntuple_filter ( attr , pattern , actions , filter , error ) ; if ( ret ) return ret ; if ( filter -> priority > E1000_2TUPLE_MAX_PRI ) { memset ( filter , 0 , sizeof ( struct rte_eth_ntuple_filter ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " ) ; return - rte_errno ; } if ( hw -> mac . type == e1000_82576 ) { if ( filter -> queue >= IGB_MAX_RX_QUEUE_NUM_82576 ) { memset ( filter , 0 , sizeof ( struct rte_eth_ntuple_filter ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " " " ) ; return - rte_errno ; } filter -> flags |= RTE_5TUPLE_FLAGS ; } else { if ( filter -> src_ip_mask || filter -> dst_ip_mask || filter -> src_port_mask ) { memset ( filter , 0 , sizeof ( struct rte_eth_ntuple_filter ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " " " ) ; return - rte_errno ; } if ( filter -> queue >= IGB_MAX_RX_QUEUE_NUM ) { memset ( filter , 0 , sizeof ( struct rte_eth_ntuple_filter ) ) ; rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , NULL , " " " " ) ; return - rte_errno ; } filter -> flags |= RTE_2TUPLE_FLAGS ; } return 0 ; }
a specific function for igb because the flags is specific
a specific function for igb because the flags is specific
/* Igb doesn't support many priorities. */