]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: hns3: improve the unused_tuple parameter setting
authorJijie Shao <shaojijie@huawei.com>
Wed, 10 Jun 2026 06:06:14 +0000 (14:06 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 14 Jun 2026 00:56:18 +0000 (17:56 -0700)
Currently, when the tc tool is used to set flow table rules, the IP address
and MAC address can be configured separately, for example, src_xx or dst_xx
can be configured separately.

Therefore, the driver needs to check whether the mask is all zero in
keys, such as FLOW_DISSECTOR_KEY_IPV4_ADDRS, FLOW_DISSECTOR_KEY_IPV6_ADDRS,
and FLOW_DISSECTOR_KEY_ETH_ADDRS.
If the mask is all zero, the tuple is not configured.
In this case, the driver adds the tuple to unused_tuple.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Link: https://patch.msgid.link/20260610060618.834987-3-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 77bd23e2c11eb5038eb56e8eff41f456b24fa0d8..176ea5aac8aa4247cfd399e3182677d7e2a54c4e 100644 (file)
@@ -7242,6 +7242,10 @@ static void hclge_get_cls_key_mac(const struct flow_rule *flow,
                ether_addr_copy(rule->tuples_mask.dst_mac, match.mask->dst);
                ether_addr_copy(rule->tuples.src_mac, match.key->src);
                ether_addr_copy(rule->tuples_mask.src_mac, match.mask->src);
+               if (is_zero_ether_addr(match.mask->dst))
+                       rule->unused_tuple |= BIT(INNER_DST_MAC);
+               if (is_zero_ether_addr(match.mask->src))
+                       rule->unused_tuple |= BIT(INNER_SRC_MAC);
        } else {
                rule->unused_tuple |= BIT(INNER_DST_MAC);
                rule->unused_tuple |= BIT(INNER_SRC_MAC);
@@ -7290,6 +7294,10 @@ static int hclge_get_cls_key_ip(const struct flow_rule *flow,
                rule->tuples.dst_ip[IPV4_INDEX] = be32_to_cpu(match.key->dst);
                rule->tuples_mask.dst_ip[IPV4_INDEX] =
                                                be32_to_cpu(match.mask->dst);
+               if (!match.mask->src)
+                       rule->unused_tuple |= BIT(INNER_SRC_IP);
+               if (!match.mask->dst)
+                       rule->unused_tuple |= BIT(INNER_DST_IP);
        } else if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
                struct flow_match_ipv6_addrs match;
 
@@ -7302,6 +7310,10 @@ static int hclge_get_cls_key_ip(const struct flow_rule *flow,
                                      match.key->dst.s6_addr32);
                ipv6_addr_be32_to_cpu(rule->tuples_mask.dst_ip,
                                      match.mask->dst.s6_addr32);
+               if (ipv6_addr_any(&match.mask->src))
+                       rule->unused_tuple |= BIT(INNER_SRC_IP);
+               if (ipv6_addr_any(&match.mask->dst))
+                       rule->unused_tuple |= BIT(INNER_DST_IP);
        } else {
                rule->unused_tuple |= BIT(INNER_SRC_IP);
                rule->unused_tuple |= BIT(INNER_DST_IP);