net/mlx5: use a macro for the RSS key size
authorNelio Laranjeiro <nelio.laranjeiro@6wind.com>
Thu, 12 Jul 2018 09:30:59 +0000 (11:30 +0200)
committerShahaf Shuler <shahafs@mellanox.com>
Thu, 12 Jul 2018 10:10:03 +0000 (12:10 +0200)
ConnectX 4-5 support only 40 bytes of RSS key, using a compiled size
hash key is not necessary.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/mlx5/mlx5_flow.c
drivers/net/mlx5/mlx5_prm.h
drivers/net/mlx5/mlx5_rss.c
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_rxtx.h

index ea01b39..b8f9136 100644 (file)
@@ -376,15 +376,15 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 
        if (use_app_rss_key &&
            (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
-            rss_hash_default_key_len)) {
-               DRV_LOG(ERR, "port %u RSS key len must be %zu Bytes long",
-                       dev->data->port_id, rss_hash_default_key_len);
+            MLX5_RSS_HASH_KEY_LEN)) {
+               DRV_LOG(ERR, "port %u RSS key len must be %s Bytes long",
+                       dev->data->port_id, RTE_STR(MLX5_RSS_HASH_KEY_LEN));
                rte_errno = EINVAL;
                return -rte_errno;
        }
        priv->rss_conf.rss_key =
                rte_realloc(priv->rss_conf.rss_key,
-                           rss_hash_default_key_len, 0);
+                           MLX5_RSS_HASH_KEY_LEN, 0);
        if (!priv->rss_conf.rss_key) {
                DRV_LOG(ERR, "port %u cannot allocate RSS hash key memory (%u)",
                        dev->data->port_id, rxqs_n);
@@ -395,8 +395,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
               use_app_rss_key ?
               dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key :
               rss_hash_default_key,
-              rss_hash_default_key_len);
-       priv->rss_conf.rss_key_len = rss_hash_default_key_len;
+              MLX5_RSS_HASH_KEY_LEN);
+       priv->rss_conf.rss_key_len = MLX5_RSS_HASH_KEY_LEN;
        priv->rss_conf.rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
        priv->rxqs = (void *)dev->data->rx_queues;
        priv->txqs = (void *)dev->data->tx_queues;
@@ -514,7 +514,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
                info->if_index = if_nametoindex(ifname);
        info->reta_size = priv->reta_idx_n ?
                priv->reta_idx_n : config->ind_table_max_size;
-       info->hash_key_size = rss_hash_default_key_len;
+       info->hash_key_size = MLX5_RSS_HASH_KEY_LEN;
        info->speed_capa = priv->link_speed_capa;
        info->flow_type_rss_offloads = ~MLX5_RSS_HF_MASK;
        mlx5_set_default_params(dev, info);
index 1280db4..77483bd 100644 (file)
@@ -1493,11 +1493,11 @@ mlx5_flow_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
                struct mlx5_hrxq *hrxq;
 
                hrxq = mlx5_hrxq_get(dev, rss_hash_default_key,
-                                    rss_hash_default_key_len, 0,
+                                    MLX5_RSS_HASH_KEY_LEN, 0,
                                     &flow->queue, 1, 0, 0);
                if (!hrxq)
                        hrxq = mlx5_hrxq_new(dev, rss_hash_default_key,
-                                            rss_hash_default_key_len, 0,
+                                            MLX5_RSS_HASH_KEY_LEN, 0,
                                             &flow->queue, 1, 0, 0);
                if (!hrxq)
                        return rte_flow_error_set(error, rte_errno,
index f9fae1e..0870d32 100644 (file)
@@ -21,6 +21,9 @@
 #include <rte_vect.h>
 #include "mlx5_autoconf.h"
 
+/* RSS hash key size. */
+#define MLX5_RSS_HASH_KEY_LEN 40
+
 /* Get CQE owner bit. */
 #define MLX5_CQE_OWNER(op_own) ((op_own) & MLX5_CQE_OWNER_MASK)
 
index d69b4c0..b95778a 100644 (file)
@@ -50,10 +50,11 @@ mlx5_rss_hash_update(struct rte_eth_dev *dev,
                return -rte_errno;
        }
        if (rss_conf->rss_key && rss_conf->rss_key_len) {
-               if (rss_conf->rss_key_len != rss_hash_default_key_len) {
+               if (rss_conf->rss_key_len != MLX5_RSS_HASH_KEY_LEN) {
                        DRV_LOG(ERR,
-                               "port %u RSS key len must be %zu Bytes long",
-                               dev->data->port_id, rss_hash_default_key_len);
+                               "port %u RSS key len must be %s Bytes long",
+                               dev->data->port_id,
+                               RTE_STR(MLX5_RSS_HASH_KEY_LEN));
                        rte_errno = EINVAL;
                        return -rte_errno;
                }
index d960daa..d50b82c 100644 (file)
@@ -52,7 +52,9 @@ uint8_t rss_hash_default_key[] = {
 };
 
 /* Length of the default RSS hash key. */
-const size_t rss_hash_default_key_len = sizeof(rss_hash_default_key);
+static_assert(MLX5_RSS_HASH_KEY_LEN ==
+             (unsigned int)sizeof(rss_hash_default_key),
+             "wrong RSS default key size.");
 
 /**
  * Check whether Multi-Packet RQ can be enabled for the device.
@@ -1771,7 +1773,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev,
                return NULL;
        }
        if (!rss_key_len) {
-               rss_key_len = rss_hash_default_key_len;
+               rss_key_len = MLX5_RSS_HASH_KEY_LEN;
                rss_key = rss_hash_default_key;
        }
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
@@ -1791,7 +1793,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev,
                        .rx_hash_conf = (struct ibv_rx_hash_conf){
                                .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ,
                                .rx_hash_key_len = rss_key_len ? rss_key_len :
-                                                  rss_hash_default_key_len,
+                                                  MLX5_RSS_HASH_KEY_LEN,
                                .rx_hash_key = rss_key ?
                                               (void *)(uintptr_t)rss_key :
                                               rss_hash_default_key,
@@ -1815,7 +1817,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev,
                        .rx_hash_conf = (struct ibv_rx_hash_conf){
                                .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ,
                                .rx_hash_key_len = rss_key_len ? rss_key_len :
-                                                  rss_hash_default_key_len,
+                                                  MLX5_RSS_HASH_KEY_LEN,
                                .rx_hash_key = rss_key ?
                                               (void *)(uintptr_t)rss_key :
                                               rss_hash_default_key,
@@ -2138,7 +2140,7 @@ mlx5_hrxq_drop_new(struct rte_eth_dev *dev)
                        .rx_hash_conf = (struct ibv_rx_hash_conf){
                                .rx_hash_function =
                                        IBV_RX_HASH_FUNC_TOEPLITZ,
-                               .rx_hash_key_len = rss_hash_default_key_len,
+                               .rx_hash_key_len = MLX5_RSS_HASH_KEY_LEN,
                                .rx_hash_key = rss_hash_default_key,
                                .rx_hash_fields_mask = 0,
                                },
index 99b769d..59e374d 100644 (file)
@@ -225,7 +225,6 @@ struct mlx5_txq_ctrl {
 /* mlx5_rxq.c */
 
 extern uint8_t rss_hash_default_key[];
-extern const size_t rss_hash_default_key_len;
 
 int mlx5_check_mprq_support(struct rte_eth_dev *dev);
 int mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq);