src/dpdk/drivers/net/hns3/hns3_flow.c
static int
hns3_parse_fdir_filter(struct rte_eth_dev *dev,
		       const struct rte_flow_item pattern[],
		       const struct rte_flow_action actions[],
		       struct hns3_fdir_rule *rule,
		       struct rte_flow_error *error)
{
	struct hns3_adapter *hns = dev->data->dev_private;
	const struct rte_flow_item *item;
	struct items_step_mngr step_mngr;
	int ret;

	/* FDIR is available only in PF driver */
	if (hns->is_vf)
		return rte_flow_error_set(error, ENOTSUP,
					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
					  "Fdir not supported in VF");

	step_mngr.items = first_items;
	step_mngr.count = ARRAY_SIZE(first_items);
	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
		if (item->type == RTE_FLOW_ITEM_TYPE_VOID)
			continue;

		ret = hns3_validate_item(item, step_mngr, error);
		if (ret)
			return ret;

		if (is_tunnel_packet(item->type)) {
			ret = hns3_parse_tunnel(item, rule, error);
			if (ret)
				return ret;
			step_mngr.items = tunnel_next_items;
			step_mngr.count = ARRAY_SIZE(tunnel_next_items);
		} else {
			ret = hns3_parse_normal(item, rule, &step_mngr, error);
			if (ret)
				return ret;
		}
	}

	return hns3_handle_actions(dev, actions, rule, error);
}
/*
 * Parse the rule to see if it is a IP or MAC VLAN flow director rule.
 * And get the flow director filter info BTW.
 * UDP/TCP/SCTP PATTERN:
 * The first not void item can be ETH or IPV4 or IPV6
 * The second not void item must be IPV4 or IPV6 if the first one is ETH.
 * The next not void item could be UDP or TCP or SCTP (optional)
 * The next not void item could be RAW (for flexbyte, optional)
 * The next not void item must be END.
 * A Fuzzy Match pattern can appear at any place before END.
 * Fuzzy Match is optional for IPV4 but is required for IPV6
 * MAC VLAN PATTERN:
 * The first not void item must be ETH.
 * The second not void item must be MAC VLAN.
 * The next not void item must be END.
 * ACTION:
 * The first not void action should be QUEUE or DROP.
 * The second not void optional action should be MARK,
 * mark_id is a uint32_t number.
 * The next not void action should be END.
 * UDP/TCP/SCTP pattern example:
 * ITEM		Spec			Mask
 * ETH		NULL			NULL
 * IPV4		src_addr 192.168.1.20	0xFFFFFFFF
 *		dst_addr 192.167.3.50	0xFFFFFFFF
 * UDP/TCP/SCTP	src_port	80	0xFFFF
 *		dst_port	80	0xFFFF
 * END
 * MAC VLAN pattern example:
 * ITEM		Spec			Mask
 * ETH		dst_addr
		{0xAC, 0x7B, 0xA1,	{0xFF, 0xFF, 0xFF,
		0x2C, 0x6D, 0x36}	0xFF, 0xFF, 0xFF}
 * MAC VLAN	tci	0x2016		0xEFFF
 * END
 * Other members in mask and spec should set to 0x00.
 * Item->last should be NULL.
 */
Parse the rule to see if it is a IP or MAC VLAN flow director rule.
And get the flow director filter info BTW.
UDP/TCP/SCTP PATTERN:
The first not void item can be ETH or IPV4 or IPV6
The second not void item must be IPV4 or IPV6 if the first one is ETH.
The next not void item could be UDP or TCP or SCTP (optional)
The next not void item could be RAW (for flexbyte, optional)
The next not void item must be END.
A Fuzzy Match pattern can appear at any place before END.
Fuzzy Match is optional for IPV4 but is required for IPV6
MAC VLAN PATTERN:
The first not void item must be ETH.
The second not void item must be MAC VLAN.
The next not void item must be END.
ACTION:
The first not void action should be QUEUE or DROP.
The second not void optional action should be MARK,
mark_id is a uint32_t number.
The next not void action should be END.
UDP/TCP/SCTP pattern example:
ITEM         Spec                    Mask
ETH          NULL                    NULL
IPV4         src_addr 192.168.1.20   0xFFFFFFFF
dst_addr 192.167.3.50   0xFFFFFFFF
UDP/TCP/SCTP src_port        80      0xFFFF
dst_port        80      0xFFFF
END
MAC VLAN pattern example:
ITEM         Spec                    Mask
ETH          dst_addr
{0xAC, 0x7B, 0xA1,      {0xFF, 0xFF, 0xFF,
0x2C, 0x6D, 0x36}       0xFF, 0xFF, 0xFF}
MAC VLAN     tci     0x2016          0xEFFF
END
Other members in mask and spec should set to 0x00.
Item->last should be NULL.
Parse the rule to see if it is a IP or MAC VLAN flow director rule . And get the flow director filter info BTW . UDP / TCP / SCTP PATTERN : The first not void item can be ETH or IPV4 or IPV6 The second not void item must be IPV4 or IPV6 if the first one is ETH . The next not void item could be UDP or TCP or SCTP ( optional ) The next not void item could be RAW ( for flexbyte optional ) The next not void item must be END . A Fuzzy Match pattern can appear at any place before END . Fuzzy Match is optional for IPV4 but is required for IPV6 MAC VLAN PATTERN : The first not void item must be ETH . The second not void item must be MAC VLAN . The next not void item must be END . ACTION : The first not void action should be QUEUE or DROP . The second not void optional action should be MARK mark_id is a uint32_t number . The next not void action should be END . UDP / TCP / SCTP pattern example : ITEM Spec Mask ETH NULL NULL IPV4 src_addr 192 . 168 . 1 . 20 0xFFFFFFFF dst_addr 192 . 167 . 3 . 50 0xFFFFFFFF UDP / TCP / SCTP src_port 80 0xFFFF dst_port 80 0xFFFF END MAC VLAN pattern example : ITEM Spec Mask ETH dst_addr { 0xAC 0x7B 0xA1 { 0xFF 0xFF 0xFF 0x2C 0x6D 0x36 } 0xFF 0xFF 0xFF } MAC VLAN tci 0x2016 0xEFFF END Other members in mask and spec should set to 0x00 . Item - > last should be NULL .
static int
hns3_parse_fdir_filter(struct rte_eth_dev *dev,
		       const struct rte_flow_item pattern[],
		       const struct rte_flow_action actions[],
		       struct hns3_fdir_rule *rule,
		       struct rte_flow_error *error)
{
	struct hns3_adapter *hns = dev->data->dev_private;
	const struct rte_flow_item *item;
	struct items_step_mngr step_mngr;
	int ret;
	if (hns->is_vf)
		return rte_flow_error_set(error, ENOTSUP,
					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
					  "Fdir not supported in VF");
	step_mngr.items = first_items;
	step_mngr.count = ARRAY_SIZE(first_items);
	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
		if (item->type == RTE_FLOW_ITEM_TYPE_VOID)
			continue;
		ret = hns3_validate_item(item, step_mngr, error);
		if (ret)
			return ret;
		if (is_tunnel_packet(item->type)) {
			ret = hns3_parse_tunnel(item, rule, error);
			if (ret)
				return ret;
			step_mngr.items = tunnel_next_items;
			step_mngr.count = ARRAY_SIZE(tunnel_next_items);
		} else {
			ret = hns3_parse_normal(item, rule, &step_mngr, error);
			if (ret)
				return ret;
		}
	}
	return hns3_handle_actions(dev, actions, rule, error);
}
static int hns3_parse_fdir_filter ( struct rte_eth_dev * dev , const struct rte_flow_item pattern [ ] , const struct rte_flow_action actions [ ] , struct hns3_fdir_rule * rule , struct rte_flow_error * error ) { struct hns3_adapter * hns = dev -> data -> dev_private ; const struct rte_flow_item * item ; struct items_step_mngr step_mngr ; int ret ; if ( hns -> is_vf ) return rte_flow_error_set ( error , ENOTSUP , RTE_FLOW_ERROR_TYPE_HANDLE , NULL , " " ) ; step_mngr . items = first_items ; step_mngr . count = ARRAY_SIZE ( first_items ) ; for ( item = pattern ; item -> type != RTE_FLOW_ITEM_TYPE_END ; item ++ ) { if ( item -> type == RTE_FLOW_ITEM_TYPE_VOID ) continue ; ret = hns3_validate_item ( item , step_mngr , error ) ; if ( ret ) return ret ; if ( is_tunnel_packet ( item -> type ) ) { ret = hns3_parse_tunnel ( item , rule , error ) ; if ( ret ) return ret ; step_mngr . items = tunnel_next_items ; step_mngr . count = ARRAY_SIZE ( tunnel_next_items ) ; } else { ret = hns3_parse_normal ( item , rule , & step_mngr , error ) ; if ( ret ) return ret ; } } return hns3_handle_actions ( dev , actions , rule , error ) ; }
Parse the rule to see if it is a IP or MAC VLAN flow director rule.
Parse the rule to see if it is a IP or MAC VLAN flow director rule .
/* FDIR is available only in PF driver */