[dpdk-dev,v6,1/2] net/mlx4: avoid constant recreations in function

Message ID 1526292452-30482-1-git-send-email-ophirmu@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ophir Munk May 14, 2018, 10:07 a.m. UTC
  Function mlx4_conv_rss_types() contains constant arrays variables
which are recreated with every call to the function. By changing the
arrays definitions from "const" to "static const" these recreations
can be saved.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
v1:
Initial release
v2:
Update based on reviews (split into 2 commits)
v3, v4, v5
More updates based on reviews
v6
Following review comments: prefix with MLX4_ all constants

 drivers/net/mlx4/mlx4_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Shahaf Shuler May 14, 2018, 10:14 a.m. UTC | #1
Monday, May 14, 2018 1:08 PM, Ophir Munk:
> Subject: [PATCH v6 1/2] net/mlx4: avoid constant recreations in function
> 
> Function mlx4_conv_rss_types() contains constant arrays variables which are
> recreated with every call to the function. By changing the arrays definitions
> from "const" to "static const" these recreations can be saved.
> 
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>

Series applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 37463b8..f117e2e 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -94,7 +94,7 @@  uint64_t
 mlx4_conv_rss_types(struct priv *priv, uint64_t types)
 {
 	enum { IPV4, IPV6, TCP, UDP, };
-	const uint64_t in[] = {
+	static const uint64_t in[] = {
 		[IPV4] = (ETH_RSS_IPV4 |
 			  ETH_RSS_FRAG_IPV4 |
 			  ETH_RSS_NONFRAG_IPV4_TCP |
@@ -115,7 +115,7 @@  mlx4_conv_rss_types(struct priv *priv, uint64_t types)
 			 ETH_RSS_NONFRAG_IPV6_UDP |
 			 ETH_RSS_IPV6_UDP_EX),
 	};
-	const uint64_t out[RTE_DIM(in)] = {
+	static const uint64_t out[RTE_DIM(in)] = {
 		[IPV4] = IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4,
 		[IPV6] = IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6,
 		[TCP] = IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP,