Thursday, May 10, 2018 5:22 PM, Ophir Munk: > Subject: [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions > > Functions mlx4_ibv_to_rss_types() and mlx4_conv_rss_types() contain > constant arrays variables which are recreated with every call to the > functions. > By changing the arrays definitions from "const" to "static const" > these recreations can be saved. > > Signed-off-by: Ophir Munk <ophi...@mellanox.com> > --- > drivers/net/mlx4/mlx4_flow.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c > index baad299..6e9b81e 100644 > --- a/drivers/net/mlx4/mlx4_flow.c > +++ b/drivers/net/mlx4/mlx4_flow.c > @@ -91,7 +91,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 | > @@ -112,7 +112,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)] = {
Since there is another version, it is better to have this patch first with the above fixes. > [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, @@ -153,7 +153,7 @@ > mlx4_ibv_to_rss_types(uint64_t types) { > enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP}; > > - const uint64_t in[] = { > + static const uint64_t in[] = { And this one can be done as part of the "advertise supported RSS ..." commit. It is better to have the fix/clean patch first, and then to introduce the new code. > [IPV4] = IPV4_IBV_HF, > [IPV6] = IPV6_IBV_HF, > [IPV4_TCP] = IPV4_IBV_HF | TCP_IBV_HF, @@ -161,7 +161,7 > @@ mlx4_ibv_to_rss_types(uint64_t types) > [IPV4_UDP] = IPV4_IBV_HF | UDP_IBV_HF, > [IPV6_UDP] = IPV6_IBV_HF | UDP_IBV_HF, > }; > - const uint64_t out[RTE_DIM(in)] = { > + static const uint64_t out[RTE_DIM(in)] = { > [IPV4] = IPV4_RSS_HF, > [IPV6] = IPV6_RSS_HF, > [IPV4_TCP] = IPV4_RSS_HF | IPV4_TCP_RSS_HF, > -- > 2.7.4