src/dpdk/drivers/net/hns3/hns3_flow.c
static int
hns3_handle_tunnel(const struct rte_flow_item *item,
		   struct hns3_fdir_rule *rule, struct rte_flow_error *error)
{
	/* check eth config */
	if (rule->input_set & (BIT(INNER_SRC_MAC) | BIT(INNER_DST_MAC)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item, "Outer eth mac is unsupported");
	if (rule->input_set & BIT(INNER_ETH_TYPE)) {
		hns3_set_bit(rule->input_set, OUTER_ETH_TYPE, 1);
		rule->key_conf.spec.outer_ether_type =
		    rule->key_conf.spec.ether_type;
		rule->key_conf.mask.outer_ether_type =
		    rule->key_conf.mask.ether_type;
		hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 0);
		rule->key_conf.spec.ether_type = 0;
		rule->key_conf.mask.ether_type = 0;
	}

	/* check vlan config */
	if (rule->input_set & (BIT(INNER_VLAN_TAG1) | BIT(INNER_VLAN_TAG2)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item,
					  "Outer vlan tags is unsupported");

	/* clear vlan_num for inner vlan select */
	rule->key_conf.outer_vlan_num = rule->key_conf.vlan_num;
	rule->key_conf.vlan_num = 0;

	/* check L3 config */
	if (rule->input_set &
	    (BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) | BIT(INNER_IP_TOS)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item, "Outer ip is unsupported");
	if (rule->input_set & BIT(INNER_IP_PROTO)) {
		hns3_set_bit(rule->input_set, OUTER_IP_PROTO, 1);
		rule->key_conf.spec.outer_proto = rule->key_conf.spec.ip_proto;
		rule->key_conf.mask.outer_proto = rule->key_conf.mask.ip_proto;
		hns3_set_bit(rule->input_set, INNER_IP_PROTO, 0);
		rule->key_conf.spec.ip_proto = 0;
		rule->key_conf.mask.ip_proto = 0;
	}

	/* check L4 config */
	if (rule->input_set & BIT(INNER_SCTP_TAG))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM, item,
					  "Outer sctp tag is unsupported");

	if (rule->input_set & BIT(INNER_SRC_PORT)) {
		hns3_set_bit(rule->input_set, OUTER_SRC_PORT, 1);
		rule->key_conf.spec.outer_src_port =
		    rule->key_conf.spec.src_port;
		rule->key_conf.mask.outer_src_port =
		    rule->key_conf.mask.src_port;
		hns3_set_bit(rule->input_set, INNER_SRC_PORT, 0);
		rule->key_conf.spec.src_port = 0;
		rule->key_conf.mask.src_port = 0;
	}
	if (rule->input_set & BIT(INNER_DST_PORT)) {
		hns3_set_bit(rule->input_set, INNER_DST_PORT, 0);
		rule->key_conf.spec.dst_port = 0;
		rule->key_conf.mask.dst_port = 0;
	}
	return 0;
}
/*
 * Check items before tunnel, save inner configs to outer configs, and clear
 * inner configs.
 * The key consists of two parts: meta_data and tuple keys.
 * Meta data uses 15 bits, including vlan_num(2bit), des_port(12bit) and tunnel
 * packet(1bit).
 * Tuple keys uses 384bit, including ot_dst-mac(48bit), ot_dst-port(16bit),
 * ot_tun_vni(24bit), ot_flow_id(8bit), src-mac(48bit), dst-mac(48bit),
 * src-ip(32/128bit), dst-ip(32/128bit), src-port(16bit), dst-port(16bit),
 * tos(8bit), ether-proto(16bit), ip-proto(8bit), vlantag1(16bit),
 * Vlantag2(16bit) and sctp-tag(32bit).
 */
Check items before tunnel, save inner configs to outer configs, and clear
inner configs.
The key consists of two parts: meta_data and tuple keys.
Check items before tunnel save inner configs to outer configs and clear inner configs . The key consists of two parts : meta_data and tuple keys .
static int
hns3_handle_tunnel(const struct rte_flow_item *item,
		   struct hns3_fdir_rule *rule, struct rte_flow_error *error)
{
	if (rule->input_set & (BIT(INNER_SRC_MAC) | BIT(INNER_DST_MAC)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item, "Outer eth mac is unsupported");
	if (rule->input_set & BIT(INNER_ETH_TYPE)) {
		hns3_set_bit(rule->input_set, OUTER_ETH_TYPE, 1);
		rule->key_conf.spec.outer_ether_type =
		    rule->key_conf.spec.ether_type;
		rule->key_conf.mask.outer_ether_type =
		    rule->key_conf.mask.ether_type;
		hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 0);
		rule->key_conf.spec.ether_type = 0;
		rule->key_conf.mask.ether_type = 0;
	}
	if (rule->input_set & (BIT(INNER_VLAN_TAG1) | BIT(INNER_VLAN_TAG2)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item,
					  "Outer vlan tags is unsupported");
	rule->key_conf.outer_vlan_num = rule->key_conf.vlan_num;
	rule->key_conf.vlan_num = 0;
	if (rule->input_set &
	    (BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) | BIT(INNER_IP_TOS)))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM,
					  item, "Outer ip is unsupported");
	if (rule->input_set & BIT(INNER_IP_PROTO)) {
		hns3_set_bit(rule->input_set, OUTER_IP_PROTO, 1);
		rule->key_conf.spec.outer_proto = rule->key_conf.spec.ip_proto;
		rule->key_conf.mask.outer_proto = rule->key_conf.mask.ip_proto;
		hns3_set_bit(rule->input_set, INNER_IP_PROTO, 0);
		rule->key_conf.spec.ip_proto = 0;
		rule->key_conf.mask.ip_proto = 0;
	}
	if (rule->input_set & BIT(INNER_SCTP_TAG))
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_ITEM, item,
					  "Outer sctp tag is unsupported");
	if (rule->input_set & BIT(INNER_SRC_PORT)) {
		hns3_set_bit(rule->input_set, OUTER_SRC_PORT, 1);
		rule->key_conf.spec.outer_src_port =
		    rule->key_conf.spec.src_port;
		rule->key_conf.mask.outer_src_port =
		    rule->key_conf.mask.src_port;
		hns3_set_bit(rule->input_set, INNER_SRC_PORT, 0);
		rule->key_conf.spec.src_port = 0;
		rule->key_conf.mask.src_port = 0;
	}
	if (rule->input_set & BIT(INNER_DST_PORT)) {
		hns3_set_bit(rule->input_set, INNER_DST_PORT, 0);
		rule->key_conf.spec.dst_port = 0;
		rule->key_conf.mask.dst_port = 0;
	}
	return 0;
}
static int hns3_handle_tunnel ( const struct rte_flow_item * item , struct hns3_fdir_rule * rule , struct rte_flow_error * error ) { if ( rule -> input_set & ( BIT ( INNER_SRC_MAC ) | BIT ( INNER_DST_MAC ) ) ) return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " " ) ; if ( rule -> input_set & BIT ( INNER_ETH_TYPE ) ) { hns3_set_bit ( rule -> input_set , OUTER_ETH_TYPE , 1 ) ; rule -> key_conf . spec . outer_ether_type = rule -> key_conf . spec . ether_type ; rule -> key_conf . mask . outer_ether_type = rule -> key_conf . mask . ether_type ; hns3_set_bit ( rule -> input_set , INNER_ETH_TYPE , 0 ) ; rule -> key_conf . spec . ether_type = 0 ; rule -> key_conf . mask . ether_type = 0 ; } if ( rule -> input_set & ( BIT ( INNER_VLAN_TAG1 ) | BIT ( INNER_VLAN_TAG2 ) ) ) return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " " ) ; rule -> key_conf . outer_vlan_num = rule -> key_conf . vlan_num ; rule -> key_conf . vlan_num = 0 ; if ( rule -> input_set & ( BIT ( INNER_SRC_IP ) | BIT ( INNER_DST_IP ) | BIT ( INNER_IP_TOS ) ) ) return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " " ) ; if ( rule -> input_set & BIT ( INNER_IP_PROTO ) ) { hns3_set_bit ( rule -> input_set , OUTER_IP_PROTO , 1 ) ; rule -> key_conf . spec . outer_proto = rule -> key_conf . spec . ip_proto ; rule -> key_conf . mask . outer_proto = rule -> key_conf . mask . ip_proto ; hns3_set_bit ( rule -> input_set , INNER_IP_PROTO , 0 ) ; rule -> key_conf . spec . ip_proto = 0 ; rule -> key_conf . mask . ip_proto = 0 ; } if ( rule -> input_set & BIT ( INNER_SCTP_TAG ) ) return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_ITEM , item , " " ) ; if ( rule -> input_set & BIT ( INNER_SRC_PORT ) ) { hns3_set_bit ( rule -> input_set , OUTER_SRC_PORT , 1 ) ; rule -> key_conf . spec . outer_src_port = rule -> key_conf . spec . src_port ; rule -> key_conf . mask . outer_src_port = rule -> key_conf . mask . src_port ; hns3_set_bit ( rule -> input_set , INNER_SRC_PORT , 0 ) ; rule -> key_conf . spec . src_port = 0 ; rule -> key_conf . mask . src_port = 0 ; } if ( rule -> input_set & BIT ( INNER_DST_PORT ) ) { hns3_set_bit ( rule -> input_set , INNER_DST_PORT , 0 ) ; rule -> key_conf . spec . dst_port = 0 ; rule -> key_conf . mask . dst_port = 0 ; } return 0 ; }
Check items before tunnel, save inner configs to outer configs, and clear
 inner configs.
Check items before tunnel save inner configs to outer configs and clear inner configs .
/* check eth config */ /* check vlan config */ /* clear vlan_num for inner vlan select */ /* check L3 config */ /* check L4 config */