net/hns3: remove unnecessary parentheses
[dpdk.git] / drivers / net / hns3 / hns3_flow.c
index 4fb129e..e9d0a0b 100644 (file)
@@ -2,8 +2,6 @@
  * Copyright(c) 2018-2019 Hisilicon Limited.
  */
 
-#include <stdbool.h>
-#include <sys/queue.h>
 #include <rte_flow_driver.h>
 #include <rte_io.h>
 #include <rte_malloc.h>
@@ -93,9 +91,9 @@ net_addr_to_host(uint32_t *dst, const rte_be32_t *src, size_t len)
 /*
  * This function is used to find rss general action.
  * 1. As we know RSS is used to spread packets among several queues, the flow
- *    API provide the struct rte_flow_action_rss, user could config it's field
+ *    API provide the struct rte_flow_action_rss, user could config its field
  *    sush as: func/level/types/key/queue to control RSS function.
- * 2. The flow API also support queue region configuration for hns3. It was
+ * 2. The flow API also supports queue region configuration for hns3. It was
  *    implemented by FDIR + RSS in hns3 hardware, user can create one FDIR rule
  *    which action is RSS queues region.
  * 3. When action is RSS, we use the following rule to distinguish:
@@ -130,11 +128,11 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[],
        rss = act->conf;
        if (have_eth && rss->conf.queue_num) {
                /*
-                * Patter have ETH and action's queue_num > 0, indicate this is
+                * Pattern have ETH and action's queue_num > 0, indicate this is
                 * queue region configuration.
                 * Because queue region is implemented by FDIR + RSS in hns3
-                * hardware, it need enter FDIR process, so here return NULL to
-                * avoid enter RSS process.
+                * hardware, it needs to enter FDIR process, so here return NULL
+                * to avoid enter RSS process.
                 */
                return NULL;
        }
@@ -211,8 +209,7 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow,
 
        ret = hns3_get_count(&hns->hw, flow->counter_id, &value);
        if (ret) {
-               rte_flow_error_set(error, -ret,
-                                  RTE_FLOW_ERROR_TYPE_HANDLE,
+               rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE,
                                   NULL, "Read counter fail.");
                return ret;
        }
@@ -269,8 +266,8 @@ hns3_handle_action_queue(struct rte_eth_dev *dev,
 
        queue = (const struct rte_flow_action_queue *)action->conf;
        if (queue->index >= hw->used_rx_queues) {
-               hns3_err(hw, "queue ID(%d) is greater than number of "
-                         "available queue (%d) in driver.",
+               hns3_err(hw, "queue ID(%u) is greater than number of "
+                         "available queue (%u) in driver.",
                          queue->index, hw->used_rx_queues);
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
@@ -408,7 +405,6 @@ hns3_handle_actions(struct rte_eth_dev *dev,
        return 0;
 }
 
-/* Parse to get the attr and action info of flow director rule. */
 static int
 hns3_check_attr(const struct rte_flow_attr *attr, struct rte_flow_error *error)
 {
@@ -436,17 +432,12 @@ hns3_check_attr(const struct rte_flow_attr *attr, struct rte_flow_error *error)
 }
 
 static int
-hns3_parse_eth(const struct rte_flow_item *item,
-                  struct hns3_fdir_rule *rule, struct rte_flow_error *error)
+hns3_parse_eth(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
+              struct rte_flow_error *error __rte_unused)
 {
        const struct rte_flow_item_eth *eth_spec;
        const struct rte_flow_item_eth *eth_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        /* Only used to describe the protocol stack. */
        if (item->spec == NULL && item->mask == NULL)
                return 0;
@@ -486,11 +477,6 @@ hns3_parse_vlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_vlan *vlan_spec;
        const struct rte_flow_item_vlan *vlan_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        rule->key_conf.vlan_num++;
        if (rule->key_conf.vlan_num > VLAN_TAG_NUM_MAX)
                return rte_flow_error_set(error, EINVAL,
@@ -528,6 +514,17 @@ hns3_parse_vlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        return 0;
 }
 
+static bool
+hns3_check_ipv4_mask_supported(const struct rte_flow_item_ipv4 *ipv4_mask)
+{
+       if (ipv4_mask->hdr.total_length || ipv4_mask->hdr.packet_id ||
+           ipv4_mask->hdr.fragment_offset || ipv4_mask->hdr.time_to_live ||
+           ipv4_mask->hdr.hdr_checksum)
+               return false;
+
+       return true;
+}
+
 static int
 hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
                struct rte_flow_error *error)
@@ -535,26 +532,17 @@ hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_ipv4 *ipv4_spec;
        const struct rte_flow_item_ipv4 *ipv4_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 1);
        rule->key_conf.spec.ether_type = RTE_ETHER_TYPE_IPV4;
        rule->key_conf.mask.ether_type = ETHER_TYPE_MASK;
+
        /* Only used to describe the protocol stack. */
        if (item->spec == NULL && item->mask == NULL)
                return 0;
 
        if (item->mask) {
                ipv4_mask = item->mask;
-
-               if (ipv4_mask->hdr.total_length ||
-                   ipv4_mask->hdr.packet_id ||
-                   ipv4_mask->hdr.fragment_offset ||
-                   ipv4_mask->hdr.time_to_live ||
-                   ipv4_mask->hdr.hdr_checksum) {
+               if (!hns3_check_ipv4_mask_supported(ipv4_mask)) {
                        return rte_flow_error_set(error, EINVAL,
                                                  RTE_FLOW_ERROR_TYPE_ITEM_MASK,
                                                  item,
@@ -603,11 +591,6 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_ipv6 *ipv6_spec;
        const struct rte_flow_item_ipv6 *ipv6_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 1);
        rule->key_conf.spec.ether_type = RTE_ETHER_TYPE_IPV6;
        rule->key_conf.mask.ether_type = ETHER_TYPE_MASK;
@@ -618,8 +601,8 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
        if (item->mask) {
                ipv6_mask = item->mask;
-               if (ipv6_mask->hdr.vtc_flow ||
-                   ipv6_mask->hdr.payload_len || ipv6_mask->hdr.hop_limits) {
+               if (ipv6_mask->hdr.vtc_flow || ipv6_mask->hdr.payload_len ||
+                   ipv6_mask->hdr.hop_limits) {
                        return rte_flow_error_set(error, EINVAL,
                                                  RTE_FLOW_ERROR_TYPE_ITEM_MASK,
                                                  item,
@@ -652,6 +635,18 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        return 0;
 }
 
+static bool
+hns3_check_tcp_mask_supported(const struct rte_flow_item_tcp *tcp_mask)
+{
+       if (tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack ||
+           tcp_mask->hdr.data_off || tcp_mask->hdr.tcp_flags ||
+           tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum ||
+           tcp_mask->hdr.tcp_urp)
+               return false;
+
+       return true;
+}
+
 static int
 hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
               struct rte_flow_error *error)
@@ -659,11 +654,6 @@ hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_tcp *tcp_spec;
        const struct rte_flow_item_tcp *tcp_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1);
        rule->key_conf.spec.ip_proto = IPPROTO_TCP;
        rule->key_conf.mask.ip_proto = IPPROTO_MASK;
@@ -674,12 +664,7 @@ hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
        if (item->mask) {
                tcp_mask = item->mask;
-               if (tcp_mask->hdr.sent_seq ||
-                   tcp_mask->hdr.recv_ack ||
-                   tcp_mask->hdr.data_off ||
-                   tcp_mask->hdr.tcp_flags ||
-                   tcp_mask->hdr.rx_win ||
-                   tcp_mask->hdr.cksum || tcp_mask->hdr.tcp_urp) {
+               if (!hns3_check_tcp_mask_supported(tcp_mask)) {
                        return rte_flow_error_set(error, EINVAL,
                                                  RTE_FLOW_ERROR_TYPE_ITEM_MASK,
                                                  item,
@@ -712,14 +697,10 @@ hns3_parse_udp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_udp *udp_spec;
        const struct rte_flow_item_udp *udp_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1);
        rule->key_conf.spec.ip_proto = IPPROTO_UDP;
        rule->key_conf.mask.ip_proto = IPPROTO_MASK;
+
        /* Only used to describe the protocol stack. */
        if (item->spec == NULL && item->mask == NULL)
                return 0;
@@ -758,11 +739,6 @@ hns3_parse_sctp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_sctp *sctp_spec;
        const struct rte_flow_item_sctp *sctp_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-
        hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1);
        rule->key_conf.spec.ip_proto = IPPROTO_SCTP;
        rule->key_conf.mask.ip_proto = IPPROTO_MASK;
@@ -778,7 +754,6 @@ hns3_parse_sctp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
                                                  RTE_FLOW_ERROR_TYPE_ITEM_MASK,
                                                  item,
                                                  "Only support src & dst port in SCTP");
-
                if (sctp_mask->hdr.src_port) {
                        hns3_set_bit(rule->input_set, INNER_SRC_PORT, 1);
                        rule->key_conf.mask.src_port =
@@ -807,7 +782,7 @@ hns3_parse_sctp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 }
 
 /*
- * Check items before tunnel, save inner configs to outer configs,and clear
+ * 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
@@ -895,15 +870,6 @@ hns3_parse_vxlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_vxlan *vxlan_spec;
        const struct rte_flow_item_vxlan *vxlan_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-       else if (item->spec && (item->mask == NULL))
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Tunnel packets must configure with mask");
-
        hns3_set_bit(rule->input_set, OUTER_DST_PORT, 1);
        rule->key_conf.mask.tunnel_type = TUNNEL_TYPE_MASK;
        if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN)
@@ -946,15 +912,6 @@ hns3_parse_nvgre(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_nvgre *nvgre_spec;
        const struct rte_flow_item_nvgre *nvgre_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-       else if (item->spec && (item->mask == NULL))
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Tunnel packets must configure with mask");
-
        hns3_set_bit(rule->input_set, OUTER_IP_PROTO, 1);
        rule->key_conf.spec.outer_proto = IPPROTO_GRE;
        rule->key_conf.mask.outer_proto = IPPROTO_MASK;
@@ -1004,15 +961,6 @@ hns3_parse_geneve(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
        const struct rte_flow_item_geneve *geneve_spec;
        const struct rte_flow_item_geneve *geneve_mask;
 
-       if (item->spec == NULL && item->mask)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Can't configure FDIR with mask but without spec");
-       else if (item->spec && (item->mask == NULL))
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "Tunnel packets must configure with mask");
-
        hns3_set_bit(rule->input_set, OUTER_DST_PORT, 1);
        rule->key_conf.spec.tunnel_type = HNS3_TUNNEL_TYPE_GENEVE;
        rule->key_conf.mask.tunnel_type = TUNNEL_TYPE_MASK;
@@ -1049,6 +997,17 @@ hns3_parse_tunnel(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 {
        int ret;
 
+       if (item->spec == NULL && item->mask)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
+                                         "Can't configure FDIR with mask "
+                                         "but without spec");
+       else if (item->spec && (item->mask == NULL))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
+                                         "Tunnel packets must configure "
+                                         "with mask");
+
        switch (item->type) {
        case RTE_FLOW_ITEM_TYPE_VXLAN:
        case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
@@ -1071,13 +1030,18 @@ hns3_parse_tunnel(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 }
 
 static int
-hns3_parse_normal(const struct rte_flow_item *item,
-                 struct hns3_fdir_rule *rule,
+hns3_parse_normal(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
                  struct items_step_mngr *step_mngr,
                  struct rte_flow_error *error)
 {
        int ret;
 
+       if (item->spec == NULL && item->mask)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
+                                         "Can't configure FDIR with mask "
+                                         "but without spec");
+
        switch (item->type) {
        case RTE_FLOW_ITEM_TYPE_ETH:
                ret = hns3_parse_eth(item, rule, error);
@@ -1216,11 +1180,6 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
                                          "Fdir not supported in VF");
 
-       if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT)
-               return rte_flow_error_set(error, ENOTSUP,
-                                         RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-                                         "fdir_conf.mode isn't perfect");
-
        step_mngr.items = first_items;
        step_mngr.count = ARRAY_SIZE(first_items);
        for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
@@ -1306,7 +1265,7 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp,
        if (comp->func == RTE_ETH_HASH_FUNCTION_MAX)
                func_is_same = false;
        else
-               func_is_same = (with->func ? (comp->func == with->func) : true);
+               func_is_same = with->func ? (comp->func == with->func) : true;
 
        return (func_is_same &&
                comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) &&
@@ -1333,15 +1292,36 @@ hns3_rss_conf_copy(struct hns3_rss_conf *out,
                .key_len = in->key_len,
                .queue_num = in->queue_num,
        };
-       out->conf.queue =
-               memcpy(out->queue, in->queue,
-                      sizeof(*in->queue) * in->queue_num);
+       out->conf.queue = memcpy(out->queue, in->queue,
+                               sizeof(*in->queue) * in->queue_num);
        if (in->key)
                out->conf.key = memcpy(out->key, in->key, in->key_len);
 
        return 0;
 }
 
+static bool
+hns3_rss_input_tuple_supported(struct hns3_hw *hw,
+                              const struct rte_flow_action_rss *rss)
+{
+       /*
+        * For IP packet, it is not supported to use src/dst port fields to RSS
+        * hash for the following packet types.
+        * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG
+        * Besides, for Kunpeng920, the NIC HW is not supported to use src/dst
+        * port fields to RSS hash for IPV6 SCTP packet type. However, the
+        * Kunpeng930 and future kunpeng series support to use src/dst port
+        * fields to RSS hash for IPv6 SCTP packet type.
+        */
+       if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) &&
+           (rss->types & ETH_RSS_IP ||
+           (!hw->rss_info.ipv6_sctp_offload_supported &&
+           rss->types & ETH_RSS_NONFRAG_IPV6_SCTP)))
+               return false;
+
+       return true;
+}
+
 /*
  * This function is used to parse rss action validatation.
  */
@@ -1367,13 +1347,18 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev,
                                          act, "no valid queues");
        }
 
+       if (rss->queue_num > RTE_DIM(rss_conf->queue))
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
+                                         "queue number configured exceeds "
+                                         "queue buffer size driver supported");
+
        for (n = 0; n < rss->queue_num; n++) {
-               if (rss->queue[n] < dev->data->nb_rx_queues)
+               if (rss->queue[n] < hw->alloc_rss_size)
                        continue;
                return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION_CONF,
-                                         act,
-                                         "queue id > max number of queues");
+                                         RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
+                                         "queue id must be less than queue number allocated to a TC");
        }
 
        if (!(rss->types & HNS3_ETH_RSS_SUPPORT) && rss->types)
@@ -1394,13 +1379,8 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev,
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
                                          "RSS hash key must be exactly 40 bytes");
-       if (rss->queue_num > RTE_DIM(rss_conf->queue))
-               return rte_flow_error_set(error, ENOTSUP,
-                                         RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
-                                         "too many queues for RSS context");
 
-       if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) &&
-           (rss->types & ETH_RSS_IP))
+       if (!hns3_rss_input_tuple_supported(hw, rss))
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
                                          &rss->types,
@@ -1440,9 +1420,8 @@ hns3_disable_rss(struct hns3_hw *hw)
 static void
 hns3_parse_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf)
 {
-       if (rss_conf->key == NULL ||
-           rss_conf->key_len < HNS3_RSS_KEY_SIZE) {
-               hns3_info(hw, "Default RSS hash key to be set");
+       if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) {
+               hns3_warn(hw, "Default RSS hash key to be set");
                rss_conf->key = hns3_hash_key;
                rss_conf->key_len = HNS3_RSS_KEY_SIZE;
        }
@@ -1483,23 +1462,19 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
        struct hns3_rss_tuple_cfg *tuple;
        int ret;
 
-       /* Parse hash key */
        hns3_parse_rss_key(hw, rss_config);
 
-       /* Parse hash algorithm */
        ret = hns3_parse_rss_algorithm(hw, &rss_config->func,
                                       &hw->rss_info.hash_algo);
        if (ret)
                return ret;
 
-       ret = hns3_set_rss_algo_key(hw, rss_config->key);
+       ret = hns3_rss_set_algo_key(hw, rss_config->key);
        if (ret)
                return ret;
 
-       /* Update algorithm of hw */
        hw->rss_info.conf.func = rss_config->func;
 
-       /* Set flow type supported */
        tuple = &hw->rss_info.rss_tuple_sets;
        ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types);
        if (ret)
@@ -1515,20 +1490,18 @@ hns3_update_indir_table(struct rte_eth_dev *dev,
        struct hns3_adapter *hns = dev->data->dev_private;
        struct hns3_hw *hw = &hns->hw;
        uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE];
-       uint16_t j, allow_rss_queues;
+       uint16_t j;
        uint32_t i;
 
-       allow_rss_queues = RTE_MIN(dev->data->nb_rx_queues, hw->rss_size_max);
        /* Fill in redirection table */
        memcpy(indir_tbl, hw->rss_info.rss_indirection_tbl,
               sizeof(hw->rss_info.rss_indirection_tbl));
        for (i = 0, j = 0; i < HNS3_RSS_IND_TBL_SIZE; i++, j++) {
                j %= num;
-               if (conf->queue[j] >= allow_rss_queues) {
-                       hns3_err(hw, "Invalid queue id(%u) to be set in "
-                                    "redirection table, max number of rss "
-                                    "queues: %u", conf->queue[j],
-                                allow_rss_queues);
+               if (conf->queue[j] >= hw->alloc_rss_size) {
+                       hns3_err(hw, "queue id(%u) set to redirection table "
+                                "exceeds queue number(%u) allocated to a TC.",
+                                conf->queue[j], hw->alloc_rss_size);
                        return -EINVAL;
                }
                indir_tbl[i] = conf->queue[j];
@@ -1586,7 +1559,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
                if (rss_flow_conf.queue_num) {
                        /*
                         * Due the content of queue pointer have been reset to
-                        * 0, the rss_info->conf.queue should be set NULL
+                        * 0, the rss_info->conf.queue should be set to NULL
                         */
                        rss_info->conf.queue = NULL;
                        rss_info->conf.queue_num = 0;
@@ -1597,11 +1570,8 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
                return 0;
        }
 
-       /* Get rx queues num */
-       num = dev->data->nb_rx_queues;
-
        /* Set rx queues to use */
-       num = RTE_MIN(num, rss_flow_conf.queue_num);
+       num = RTE_MIN(dev->data->nb_rx_queues, rss_flow_conf.queue_num);
        if (rss_flow_conf.queue_num > num)
                hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
                          rss_flow_conf.queue_num);
@@ -1638,7 +1608,6 @@ rss_config_err:
        return ret;
 }
 
-/* Remove the rss filter */
 static int
 hns3_clear_rss_filter(struct rte_eth_dev *dev)
 {
@@ -1674,7 +1643,6 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
        return ret;
 }
 
-/* Restore the rss filter */
 int
 hns3_restore_rss_filter(struct rte_eth_dev *dev)
 {
@@ -1696,7 +1664,6 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev,
        struct hns3_hw *hw = &hns->hw;
        bool ret;
 
-       /* Action rss same */
        ret = hns3_action_rss_same(&hw->rss_info.conf, &conf->conf);
        if (ret) {
                hns3_err(hw, "Enter duplicate RSS configuration : %d", ret);
@@ -1758,7 +1725,7 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 /*
  * Create or destroy a flow rule.
  * Theorically one rule can match more than one filters.
- * We will let it use the filter which it hitt first.
+ * We will let it use the filter which it hit first.
  * So, the sequence matters.
  */
 static struct rte_flow *
@@ -1785,17 +1752,15 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 
        flow = rte_zmalloc("hns3 flow", sizeof(struct rte_flow), 0);
        if (flow == NULL) {
-               rte_flow_error_set(error, ENOMEM,
-                                  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-                                  "Failed to allocate flow memory");
+               rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
+                                  NULL, "Failed to allocate flow memory");
                return NULL;
        }
        flow_node = rte_zmalloc("hns3 flow node",
                                sizeof(struct hns3_flow_mem), 0);
        if (flow_node == NULL) {
-               rte_flow_error_set(error, ENOMEM,
-                                  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-                                  "Failed to allocate flow list memory");
+               rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
+                                  NULL, "Failed to allocate flow list memory");
                rte_free(flow);
                return NULL;
        }
@@ -1854,6 +1819,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                        ret = -ENOMEM;
                        goto err_fdir;
                }
+
                memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule,
                        sizeof(struct hns3_fdir_rule));
                TAILQ_INSERT_TAIL(&process_list->fdir_list,
@@ -1896,6 +1862,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_HANDLE,
                                          flow, "Flow is NULL");
+
        filter_type = flow->filter_type;
        switch (filter_type) {
        case RTE_ETH_FILTER_FDIR: