* [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions
@ 2018-05-08 15:43 Ophir Munk
2018-05-09 9:38 ` Shahaf Shuler
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
0 siblings, 2 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-08 15:43 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Report on mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 51 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..2a1533c 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS dpdk types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format
+ *
+ * @return
+ * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
+ */
+static uint64_t
+mlx4_ibv_to_dpdk_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, TCP, UDP, };
+ const uint64_t 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,
+ [UDP] = IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP,
+ };
+ const uint64_t out[RTE_DIM(in)] = {
+ [IPV4] = (ETH_RSS_IPV4 |
+ ETH_RSS_FRAG_IPV4 |
+ ETH_RSS_NONFRAG_IPV4_OTHER),
+ [IPV6] = (ETH_RSS_IPV6 |
+ ETH_RSS_FRAG_IPV6 |
+ ETH_RSS_NONFRAG_IPV6_OTHER |
+ ETH_RSS_IPV6_EX),
+ [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
+ ETH_RSS_NONFRAG_IPV6_TCP |
+ ETH_RSS_IPV6_TCP_EX),
+ [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
+ ETH_RSS_NONFRAG_IPV6_UDP |
+ ETH_RSS_IPV6_UDP_EX),
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* DPDK callback to get information about the device.
*
* @param dev
@@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
ETH_LINK_SPEED_20G |
ETH_LINK_SPEED_40G |
ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
+ priv->hw_rss_sup);
}
/**
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions
2018-05-08 15:43 [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions Ophir Munk
@ 2018-05-09 9:38 ` Shahaf Shuler
2018-05-09 11:54 ` Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
1 sibling, 1 reply; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-09 9:38 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Hi Ophir,
Tuesday, May 8, 2018 6:43 PM, Ophir Munk:
> Subject: [PATCH v1] net/mlx4: report on supported RSS hash functions
>
> Report on mlx4 supported RSS functions as part of dev_infos_get callback.
> Previous to this commit RSS support was reported as none. Since the
> introduction of [1] it is required that all RSS configurations will be verified.
>
> [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
>
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
> drivers/net/mlx4/mlx4_ethdev.c | 51
> ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..2a1533c 100644
> --- a/drivers/net/mlx4/mlx4_ethdev.c
> +++ b/drivers/net/mlx4/mlx4_ethdev.c
> @@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, struct
> ether_addr *mac_addr) }
>
> /**
> + * Convert verbs RSS types to their DPDK equivalents.
> + *
> + * This function returns a group of RSS dpdk types given their
> +equivalent group
> + * of verbs types.
> + * For example both source IPv4 and destination IPv4 verbs types are
> +converted
> + * into their equivalent RSS group types. If each of these verbs types
> +existed
> + * exclusively - no conversion would take place.
> + *
> + * @param types
> + * RSS hash types in verbs format
> + *
> + * @return
> + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
> + */
> +static uint64_t
> +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> + enum { IPV4, IPV6, TCP, UDP, };
> + const uint64_t 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,
> + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> IBV_RX_HASH_DST_PORT_UDP,
> + };
> + const uint64_t out[RTE_DIM(in)] = {
> + [IPV4] = (ETH_RSS_IPV4 |
> + ETH_RSS_FRAG_IPV4 |
> + ETH_RSS_NONFRAG_IPV4_OTHER),
> + [IPV6] = (ETH_RSS_IPV6 |
> + ETH_RSS_FRAG_IPV6 |
> + ETH_RSS_NONFRAG_IPV6_OTHER |
> + ETH_RSS_IPV6_EX),
> + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> + ETH_RSS_NONFRAG_IPV6_TCP |
> + ETH_RSS_IPV6_TCP_EX),
> + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> + ETH_RSS_NONFRAG_IPV6_UDP |
> + ETH_RSS_IPV6_UDP_EX),
> + };
Since above are constants, why not defining a global array of structs containing the ibv_hash and the equivalent dpdk_hash, instead of recreating it for each call?
There is a similar concept on mlx5_flow.c:
/* Initialization data for hash RX queues. */
const struct hash_rxq_init hash_rxq_init[] = {
[HASH_RXQ_TCPV4] = {
.hash_fields = (IBV_RX_HASH_SRC_IPV4 |
IBV_RX_HASH_DST_IPV4 |
IBV_RX_HASH_SRC_PORT_TCP |
IBV_RX_HASH_DST_PORT_TCP),
.dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP,
.flow_priority = 0,
.ip_version = MLX5_IPV4,
},
> + uint64_t conv = 0;
> + unsigned int i;
> +
> + for (i = 0; i != RTE_DIM(in); ++i)
> + if ((types & in[i]) == in[i])
> + conv |= out[i];
> + return conv;
> +}
> +
> +/**
> * DPDK callback to get information about the device.
> *
> * @param dev
> @@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *info)
> ETH_LINK_SPEED_20G |
> ETH_LINK_SPEED_40G |
> ETH_LINK_SPEED_56G;
> + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
> + priv->hw_rss_sup);
> }
>
> /**
> --
> 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions
2018-05-09 9:38 ` Shahaf Shuler
@ 2018-05-09 11:54 ` Ophir Munk
2018-05-09 14:01 ` Shahaf Shuler
0 siblings, 1 reply; 25+ messages in thread
From: Ophir Munk @ 2018-05-09 11:54 UTC (permalink / raw)
To: Shahaf Shuler, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Hi Shahaf,
> -----Original Message-----
> From: Shahaf Shuler
> Sent: Wednesday, May 09, 2018 12:39 PM
> To: Ophir Munk <ophirmu@mellanox.com>; dev@dpdk.org; Adrien
> Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; Olga Shern
> <olgas@mellanox.com>
> Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash functions
>
> Hi Ophir,
>
> Tuesday, May 8, 2018 6:43 PM, Ophir Munk:
> > Subject: [PATCH v1] net/mlx4: report on supported RSS hash functions
> >
> > Report on mlx4 supported RSS functions as part of dev_infos_get callback.
> > Previous to this commit RSS support was reported as none. Since the
> > introduction of [1] it is required that all RSS configurations will be verified.
> >
> > [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> > drivers/net/mlx4/mlx4_ethdev.c | 51
> > ++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 51 insertions(+)
> >
> > diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> > b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..2a1533c 100644
> > --- a/drivers/net/mlx4/mlx4_ethdev.c
> > +++ b/drivers/net/mlx4/mlx4_ethdev.c
> > @@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev,
> struct
> > ether_addr *mac_addr) }
> >
> > /**
> > + * Convert verbs RSS types to their DPDK equivalents.
> > + *
> > + * This function returns a group of RSS dpdk types given their
> > +equivalent group
> > + * of verbs types.
> > + * For example both source IPv4 and destination IPv4 verbs types are
> > +converted
> > + * into their equivalent RSS group types. If each of these verbs
> > +types existed
> > + * exclusively - no conversion would take place.
> > + *
> > + * @param types
> > + * RSS hash types in verbs format
> > + *
> > + * @return
> > + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
> > + */
> > +static uint64_t
> > +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> > + enum { IPV4, IPV6, TCP, UDP, };
> > + const uint64_t 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,
> > + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> > IBV_RX_HASH_DST_PORT_UDP,
> > + };
> > + const uint64_t out[RTE_DIM(in)] = {
> > + [IPV4] = (ETH_RSS_IPV4 |
> > + ETH_RSS_FRAG_IPV4 |
> > + ETH_RSS_NONFRAG_IPV4_OTHER),
> > + [IPV6] = (ETH_RSS_IPV6 |
> > + ETH_RSS_FRAG_IPV6 |
> > + ETH_RSS_NONFRAG_IPV6_OTHER |
> > + ETH_RSS_IPV6_EX),
> > + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> > + ETH_RSS_NONFRAG_IPV6_TCP |
> > + ETH_RSS_IPV6_TCP_EX),
> > + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> > + ETH_RSS_NONFRAG_IPV6_UDP |
> > + ETH_RSS_IPV6_UDP_EX),
> > + };
>
> Since above are constants, why not defining a global array of structs
> containing the ibv_hash and the equivalent dpdk_hash, instead of recreating
> it for each call?
The array is recreated because it should have been declared as "static const" rather than just "const". I prefer this fix.
Alternatively it could have been defined globally outside of the function as suggested which would have avoided recreation as well.
All of those claims are confirmed by inspecting the assembly code of the above alternatives.
> There is a similar concept on mlx5_flow.c:
>
> /* Initialization data for hash RX queues. */
> const struct hash_rxq_init hash_rxq_init[] = {
> [HASH_RXQ_TCPV4] = {
> .hash_fields = (IBV_RX_HASH_SRC_IPV4 |
> IBV_RX_HASH_DST_IPV4 |
> IBV_RX_HASH_SRC_PORT_TCP |
> IBV_RX_HASH_DST_PORT_TCP),
> .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP,
> .flow_priority = 0,
> .ip_version = MLX5_IPV4,
> },
>
I was inspired from "the reversed" function in mlx4_flow.c which defines constants inside the function as well, see [1].
To fix the constants recreation both functions should be handled together.
I suggest:
1. Moving mlx4_ibv_to_dpdk_rss_types() function as is from mlx4_ether.c to mlx4_flow.c so it will be adjacent to mlx4_conv_rss_types() function.
2. Sending a new patch that avoids constants recreation in the 2 functions.
[1]
uint64_t
mlx4_conv_rss_types(struct priv *priv, uint64_t types)
{
enum { IPV4, IPV6, TCP, UDP, };
const uint64_t in[] = {
[IPV4] = (ETH_RSS_IPV4 |
ETH_RSS_FRAG_IPV4 |
ETH_RSS_NONFRAG_IPV4_TCP |
ETH_RSS_NONFRAG_IPV4_UDP |
ETH_RSS_NONFRAG_IPV4_OTHER),
[IPV6] = (ETH_RSS_IPV6 |
ETH_RSS_FRAG_IPV6 |
ETH_RSS_NONFRAG_IPV6_TCP |
ETH_RSS_NONFRAG_IPV6_UDP |
ETH_RSS_NONFRAG_IPV6_OTHER |
ETH_RSS_IPV6_EX |
ETH_RSS_IPV6_TCP_EX |
ETH_RSS_IPV6_UDP_EX),
[TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
ETH_RSS_NONFRAG_IPV6_TCP |
ETH_RSS_IPV6_TCP_EX),
[UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
ETH_RSS_NONFRAG_IPV6_UDP |
ETH_RSS_IPV6_UDP_EX),
};
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,
[UDP] = IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP,
};
uint64_t seen = 0;
uint64_t conv = 0;
unsigned int i;
if (types == (uint64_t)-1)
return priv->hw_rss_sup;
for (i = 0; i != RTE_DIM(in); ++i)
if (types & in[i]) {
seen |= types & in[i];
conv |= out[i];
}
if ((conv & priv->hw_rss_sup) == conv && !(types & ~seen))
return conv;
rte_errno = ENOTSUP;
return (uint64_t)-1;
}
> > + uint64_t conv = 0;
> > + unsigned int i;
> > +
> > + for (i = 0; i != RTE_DIM(in); ++i)
> > + if ((types & in[i]) == in[i])
> > + conv |= out[i];
> > + return conv;
> > +}
> > +
> > +/**
> > * DPDK callback to get information about the device.
> > *
> > * @param dev
> > @@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev,
> struct
> > rte_eth_dev_info *info)
> > ETH_LINK_SPEED_20G |
> > ETH_LINK_SPEED_40G |
> > ETH_LINK_SPEED_56G;
> > + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
> > + priv->hw_rss_sup);
> > }
> >
> > /**
> > --
> > 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions
2018-05-09 11:54 ` Ophir Munk
@ 2018-05-09 14:01 ` Shahaf Shuler
2018-05-09 22:42 ` Ophir Munk
0 siblings, 1 reply; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-09 14:01 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Wednesday, May 9, 2018 2:54 PM, Ophir Munk:
> Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash functions
>
> Hi Shahaf,
>
> > -----Original Message-----
> > From: Shahaf Shuler
> > Sent: Wednesday, May 09, 2018 12:39 PM
> > To: Ophir Munk <ophirmu@mellanox.com>; dev@dpdk.org; Adrien
> Mazarguil
> > <adrien.mazarguil@6wind.com>
> > Cc: Thomas Monjalon <thomas@monjalon.net>; Olga Shern
> > <olgas@mellanox.com>
> > Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash
> > functions
> >
> > Hi Ophir,
> >
> > Tuesday, May 8, 2018 6:43 PM, Ophir Munk:
> > > Subject: [PATCH v1] net/mlx4: report on supported RSS hash functions
> > >
> > > Report on mlx4 supported RSS functions as part of dev_infos_get
> callback.
> > > Previous to this commit RSS support was reported as none. Since the
> > > introduction of [1] it is required that all RSS configurations will be verified.
> > >
> > > [1] commit 8863a1fbfc66 ("ethdev: add supported hash function
> > > check")
> > >
> > > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > > ---
> > > drivers/net/mlx4/mlx4_ethdev.c | 51
> > > ++++++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 51 insertions(+)
> > >
> > > diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> > > b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..2a1533c 100644
> > > --- a/drivers/net/mlx4/mlx4_ethdev.c
> > > +++ b/drivers/net/mlx4/mlx4_ethdev.c
> > > @@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev,
> > struct
> > > ether_addr *mac_addr) }
> > >
> > > /**
> > > + * Convert verbs RSS types to their DPDK equivalents.
> > > + *
> > > + * This function returns a group of RSS dpdk types given their
> > > +equivalent group
> > > + * of verbs types.
> > > + * For example both source IPv4 and destination IPv4 verbs types
> > > +are converted
> > > + * into their equivalent RSS group types. If each of these verbs
> > > +types existed
> > > + * exclusively - no conversion would take place.
> > > + *
> > > + * @param types
> > > + * RSS hash types in verbs format
> > > + *
> > > + * @return
> > > + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
> > > + */
> > > +static uint64_t
> > > +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> > > + enum { IPV4, IPV6, TCP, UDP, };
> > > + const uint64_t 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,
> > > + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> > > IBV_RX_HASH_DST_PORT_UDP,
> > > + };
> > > + const uint64_t out[RTE_DIM(in)] = {
> > > + [IPV4] = (ETH_RSS_IPV4 |
> > > + ETH_RSS_FRAG_IPV4 |
> > > + ETH_RSS_NONFRAG_IPV4_OTHER),
> > > + [IPV6] = (ETH_RSS_IPV6 |
> > > + ETH_RSS_FRAG_IPV6 |
> > > + ETH_RSS_NONFRAG_IPV6_OTHER |
> > > + ETH_RSS_IPV6_EX),
> > > + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> > > + ETH_RSS_NONFRAG_IPV6_TCP |
> > > + ETH_RSS_IPV6_TCP_EX),
> > > + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> > > + ETH_RSS_NONFRAG_IPV6_UDP |
> > > + ETH_RSS_IPV6_UDP_EX),
> > > + };
> >
> > Since above are constants, why not defining a global array of structs
> > containing the ibv_hash and the equivalent dpdk_hash, instead of
> > recreating it for each call?
>
> The array is recreated because it should have been declared as "static const"
> rather than just "const". I prefer this fix.
> Alternatively it could have been defined globally outside of the function as
> suggested which would have avoided recreation as well.
> All of those claims are confirmed by inspecting the assembly code of the
> above alternatives.
>
> > There is a similar concept on mlx5_flow.c:
> >
> > /* Initialization data for hash RX queues. */ const struct
> > hash_rxq_init hash_rxq_init[] = {
> > [HASH_RXQ_TCPV4] = {
> > .hash_fields = (IBV_RX_HASH_SRC_IPV4 |
> > IBV_RX_HASH_DST_IPV4 |
> > IBV_RX_HASH_SRC_PORT_TCP |
> > IBV_RX_HASH_DST_PORT_TCP),
> > .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP,
> > .flow_priority = 0,
> > .ip_version = MLX5_IPV4,
> > },
> >
>
> I was inspired from "the reversed" function in mlx4_flow.c which defines
> constants inside the function as well, see [1].
> To fix the constants recreation both functions should be handled together.
>
> I suggest:
> 1. Moving mlx4_ibv_to_dpdk_rss_types() function as is from mlx4_ether.c to
> mlx4_flow.c so it will be adjacent to mlx4_conv_rss_types() function.
> 2. Sending a new patch that avoids constants recreation in the 2 functions.
OK. Those can be 2 patches from the same series.
>
> [1]
> uint64_t
> mlx4_conv_rss_types(struct priv *priv, uint64_t types) {
> enum { IPV4, IPV6, TCP, UDP, };
> const uint64_t in[] = {
> [IPV4] = (ETH_RSS_IPV4 |
> ETH_RSS_FRAG_IPV4 |
> ETH_RSS_NONFRAG_IPV4_TCP |
> ETH_RSS_NONFRAG_IPV4_UDP |
> ETH_RSS_NONFRAG_IPV4_OTHER),
> [IPV6] = (ETH_RSS_IPV6 |
> ETH_RSS_FRAG_IPV6 |
> ETH_RSS_NONFRAG_IPV6_TCP |
> ETH_RSS_NONFRAG_IPV6_UDP |
> ETH_RSS_NONFRAG_IPV6_OTHER |
> ETH_RSS_IPV6_EX |
> ETH_RSS_IPV6_TCP_EX |
> ETH_RSS_IPV6_UDP_EX),
> [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> ETH_RSS_NONFRAG_IPV6_TCP |
> ETH_RSS_IPV6_TCP_EX),
> [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> ETH_RSS_NONFRAG_IPV6_UDP |
> ETH_RSS_IPV6_UDP_EX),
> };
> 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,
> [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> IBV_RX_HASH_DST_PORT_UDP,
> };
> uint64_t seen = 0;
> uint64_t conv = 0;
> unsigned int i;
>
> if (types == (uint64_t)-1)
> return priv->hw_rss_sup;
> for (i = 0; i != RTE_DIM(in); ++i)
> if (types & in[i]) {
> seen |= types & in[i];
> conv |= out[i];
> }
> if ((conv & priv->hw_rss_sup) == conv && !(types & ~seen))
> return conv;
> rte_errno = ENOTSUP;
> return (uint64_t)-1;
> }
>
> > > + uint64_t conv = 0;
> > > + unsigned int i;
> > > +
> > > + for (i = 0; i != RTE_DIM(in); ++i)
> > > + if ((types & in[i]) == in[i])
> > > + conv |= out[i];
> > > + return conv;
> > > +}
> > > +
> > > +/**
> > > * DPDK callback to get information about the device.
> > > *
> > > * @param dev
> > > @@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev,
> > struct
> > > rte_eth_dev_info *info)
> > > ETH_LINK_SPEED_20G |
> > > ETH_LINK_SPEED_40G |
> > > ETH_LINK_SPEED_56G;
> > > + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
> > > + priv->hw_rss_sup);
> > > }
> > >
> > > /**
> > > --
> > > 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions
2018-05-08 15:43 [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions Ophir Munk
2018-05-09 9:38 ` Shahaf Shuler
@ 2018-05-09 22:27 ` Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
` (2 more replies)
1 sibling, 3 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-09 22:27 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
v1:
Initial release
v2:
Split into 2 commits following reviews
drivers/net/mlx4/mlx4_ethdev.c | 3 +++
drivers/net/mlx4/mlx4_flow.c | 49 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 1 +
3 files changed, 53 insertions(+)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..8fbb781 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -544,6 +544,7 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
return mlx4_mac_addr_add(dev, mac_addr, 0, 0);
}
+
/**
* DPDK callback to get information about the device.
*
@@ -587,6 +588,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
ETH_LINK_SPEED_20G |
ETH_LINK_SPEED_40G |
ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
+ priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 397a150..41dac16 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -134,6 +134,55 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS dpdk types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format
+ *
+ * @return
+ * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
+ */
+uint64_t
+mlx4_ibv_to_dpdk_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, TCP, UDP, };
+ const uint64_t 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,
+ [UDP] = IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP,
+ };
+ const uint64_t out[RTE_DIM(in)] = {
+ [IPV4] = (ETH_RSS_IPV4 |
+ ETH_RSS_FRAG_IPV4 |
+ ETH_RSS_NONFRAG_IPV4_OTHER),
+ [IPV6] = (ETH_RSS_IPV6 |
+ ETH_RSS_FRAG_IPV6 |
+ ETH_RSS_NONFRAG_IPV6_OTHER |
+ ETH_RSS_IPV6_EX),
+ [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
+ ETH_RSS_NONFRAG_IPV6_TCP |
+ ETH_RSS_IPV6_TCP_EX),
+ [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
+ ETH_RSS_NONFRAG_IPV6_UDP |
+ ETH_RSS_IPV6_UDP_EX),
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..ec990df 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -49,6 +49,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_dpdk_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] net/mlx4: avoid constant recreations in functions
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
@ 2018-05-09 22:27 ` Ophir Munk
2018-05-10 5:20 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
2 siblings, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-09 22:27 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Functions mlx4_ibv_to_dpdk_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 <ophirmu@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 41dac16..47d0403 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)] = {
[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,
@@ -152,13 +152,13 @@ uint64_t
mlx4_ibv_to_dpdk_rss_types(uint64_t types)
{
enum { IPV4, IPV6, TCP, UDP, };
- const uint64_t in[] = {
+ static const uint64_t 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,
[UDP] = IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP,
};
- const uint64_t out[RTE_DIM(in)] = {
+ static const uint64_t out[RTE_DIM(in)] = {
[IPV4] = (ETH_RSS_IPV4 |
ETH_RSS_FRAG_IPV4 |
ETH_RSS_NONFRAG_IPV4_OTHER),
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions
2018-05-09 14:01 ` Shahaf Shuler
@ 2018-05-09 22:42 ` Ophir Munk
0 siblings, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-09 22:42 UTC (permalink / raw)
To: Shahaf Shuler, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Hi,
PATCH v2 was sent
> -----Original Message-----
> From: Shahaf Shuler
> Sent: Wednesday, May 09, 2018 5:01 PM
> To: Ophir Munk <ophirmu@mellanox.com>; dev@dpdk.org; Adrien
> Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; Olga Shern
> <olgas@mellanox.com>
> Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash functions
>
> Wednesday, May 9, 2018 2:54 PM, Ophir Munk:
> > Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash
> > functions
> >
> > Hi Shahaf,
> >
> > > -----Original Message-----
> > > From: Shahaf Shuler
> > > Sent: Wednesday, May 09, 2018 12:39 PM
> > > To: Ophir Munk <ophirmu@mellanox.com>; dev@dpdk.org; Adrien
> > Mazarguil
> > > <adrien.mazarguil@6wind.com>
> > > Cc: Thomas Monjalon <thomas@monjalon.net>; Olga Shern
> > > <olgas@mellanox.com>
> > > Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash
> > > functions
> > >
> > > Hi Ophir,
> > >
> > > Tuesday, May 8, 2018 6:43 PM, Ophir Munk:
> > > > Subject: [PATCH v1] net/mlx4: report on supported RSS hash
> > > > functions
> > > >
> > > > Report on mlx4 supported RSS functions as part of dev_infos_get
> > callback.
> > > > Previous to this commit RSS support was reported as none. Since
> > > > the introduction of [1] it is required that all RSS configurations will be
> verified.
> > > >
> > > > [1] commit 8863a1fbfc66 ("ethdev: add supported hash function
> > > > check")
> > > >
> > > > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > > > ---
> > > > drivers/net/mlx4/mlx4_ethdev.c | 51
> > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 51 insertions(+)
> > > >
> > > > diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> > > > b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..2a1533c 100644
> > > > --- a/drivers/net/mlx4/mlx4_ethdev.c
> > > > +++ b/drivers/net/mlx4/mlx4_ethdev.c
> > > > @@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev,
> > > struct
> > > > ether_addr *mac_addr) }
> > > >
> > > > /**
> > > > + * Convert verbs RSS types to their DPDK equivalents.
> > > > + *
> > > > + * This function returns a group of RSS dpdk types given their
> > > > +equivalent group
> > > > + * of verbs types.
> > > > + * For example both source IPv4 and destination IPv4 verbs types
> > > > +are converted
> > > > + * into their equivalent RSS group types. If each of these verbs
> > > > +types existed
> > > > + * exclusively - no conversion would take place.
> > > > + *
> > > > + * @param types
> > > > + * RSS hash types in verbs format
> > > > + *
> > > > + * @return
> > > > + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
> > > > + */
> > > > +static uint64_t
> > > > +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> > > > + enum { IPV4, IPV6, TCP, UDP, };
> > > > + const uint64_t 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,
> > > > + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> > > > IBV_RX_HASH_DST_PORT_UDP,
> > > > + };
> > > > + const uint64_t out[RTE_DIM(in)] = {
> > > > + [IPV4] = (ETH_RSS_IPV4 |
> > > > + ETH_RSS_FRAG_IPV4 |
> > > > + ETH_RSS_NONFRAG_IPV4_OTHER),
> > > > + [IPV6] = (ETH_RSS_IPV6 |
> > > > + ETH_RSS_FRAG_IPV6 |
> > > > + ETH_RSS_NONFRAG_IPV6_OTHER |
> > > > + ETH_RSS_IPV6_EX),
> > > > + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> > > > + ETH_RSS_NONFRAG_IPV6_TCP |
> > > > + ETH_RSS_IPV6_TCP_EX),
> > > > + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> > > > + ETH_RSS_NONFRAG_IPV6_UDP |
> > > > + ETH_RSS_IPV6_UDP_EX),
> > > > + };
> > >
> > > Since above are constants, why not defining a global array of
> > > structs containing the ibv_hash and the equivalent dpdk_hash,
> > > instead of recreating it for each call?
> >
> > The array is recreated because it should have been declared as "static
> const"
> > rather than just "const". I prefer this fix.
> > Alternatively it could have been defined globally outside of the
> > function as suggested which would have avoided recreation as well.
> > All of those claims are confirmed by inspecting the assembly code of
> > the above alternatives.
> >
> > > There is a similar concept on mlx5_flow.c:
> > >
> > > /* Initialization data for hash RX queues. */ const struct
> > > hash_rxq_init hash_rxq_init[] = {
> > > [HASH_RXQ_TCPV4] = {
> > > .hash_fields = (IBV_RX_HASH_SRC_IPV4 |
> > > IBV_RX_HASH_DST_IPV4 |
> > > IBV_RX_HASH_SRC_PORT_TCP |
> > > IBV_RX_HASH_DST_PORT_TCP),
> > > .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP,
> > > .flow_priority = 0,
> > > .ip_version = MLX5_IPV4,
> > > },
> > >
> >
> > I was inspired from "the reversed" function in mlx4_flow.c which
> > defines constants inside the function as well, see [1].
> > To fix the constants recreation both functions should be handled together.
> >
> > I suggest:
> > 1. Moving mlx4_ibv_to_dpdk_rss_types() function as is from
> > mlx4_ether.c to mlx4_flow.c so it will be adjacent to
> mlx4_conv_rss_types() function.
> > 2. Sending a new patch that avoids constants recreation in the 2 functions.
>
> OK. Those can be 2 patches from the same series.
>
> >
> > [1]
> > uint64_t
> > mlx4_conv_rss_types(struct priv *priv, uint64_t types) {
> > enum { IPV4, IPV6, TCP, UDP, };
> > const uint64_t in[] = {
> > [IPV4] = (ETH_RSS_IPV4 |
> > ETH_RSS_FRAG_IPV4 |
> > ETH_RSS_NONFRAG_IPV4_TCP |
> > ETH_RSS_NONFRAG_IPV4_UDP |
> > ETH_RSS_NONFRAG_IPV4_OTHER),
> > [IPV6] = (ETH_RSS_IPV6 |
> > ETH_RSS_FRAG_IPV6 |
> > ETH_RSS_NONFRAG_IPV6_TCP |
> > ETH_RSS_NONFRAG_IPV6_UDP |
> > ETH_RSS_NONFRAG_IPV6_OTHER |
> > ETH_RSS_IPV6_EX |
> > ETH_RSS_IPV6_TCP_EX |
> > ETH_RSS_IPV6_UDP_EX),
> > [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> > ETH_RSS_NONFRAG_IPV6_TCP |
> > ETH_RSS_IPV6_TCP_EX),
> > [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> > ETH_RSS_NONFRAG_IPV6_UDP |
> > ETH_RSS_IPV6_UDP_EX),
> > };
> > 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,
> > [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> > IBV_RX_HASH_DST_PORT_UDP,
> > };
> > uint64_t seen = 0;
> > uint64_t conv = 0;
> > unsigned int i;
> >
> > if (types == (uint64_t)-1)
> > return priv->hw_rss_sup;
> > for (i = 0; i != RTE_DIM(in); ++i)
> > if (types & in[i]) {
> > seen |= types & in[i];
> > conv |= out[i];
> > }
> > if ((conv & priv->hw_rss_sup) == conv && !(types & ~seen))
> > return conv;
> > rte_errno = ENOTSUP;
> > return (uint64_t)-1;
> > }
> >
> > > > + uint64_t conv = 0;
> > > > + unsigned int i;
> > > > +
> > > > + for (i = 0; i != RTE_DIM(in); ++i)
> > > > + if ((types & in[i]) == in[i])
> > > > + conv |= out[i];
> > > > + return conv;
> > > > +}
> > > > +
> > > > +/**
> > > > * DPDK callback to get information about the device.
> > > > *
> > > > * @param dev
> > > > @@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev,
> > > struct
> > > > rte_eth_dev_info *info)
> > > > ETH_LINK_SPEED_20G |
> > > > ETH_LINK_SPEED_40G |
> > > > ETH_LINK_SPEED_56G;
> > > > + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
> > > > + priv->hw_rss_sup);
> > > > }
> > > >
> > > > /**
> > > > --
> > > > 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
@ 2018-05-10 5:20 ` Shahaf Shuler
2018-05-10 14:25 ` Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
2 siblings, 1 reply; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-10 5:20 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Hi Ophir,
Thursday, May 10, 2018 1:27 AM, Ophir Munk:
> Subject: [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions
>
> Advertise mlx4 supported RSS functions as part of dev_infos_get callback.
> Previous to this commit RSS support was reported as none. Since the
> introduction of [1] it is required that all RSS configurations will be verified.
>
> [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
>
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
> v1:
> Initial release
> v2:
> Split into 2 commits following reviews
>
> drivers/net/mlx4/mlx4_ethdev.c | 3 +++
> drivers/net/mlx4/mlx4_flow.c | 49
> ++++++++++++++++++++++++++++++++++++++++++
> drivers/net/mlx4/mlx4_flow.h | 1 +
> 3 files changed, 53 insertions(+)
>
> diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..8fbb781 100644
> --- a/drivers/net/mlx4/mlx4_ethdev.c
> +++ b/drivers/net/mlx4/mlx4_ethdev.c
> @@ -544,6 +544,7 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, struct
> ether_addr *mac_addr)
> return mlx4_mac_addr_add(dev, mac_addr, 0, 0); }
>
> +
Remove this extra line.
> /**
> * DPDK callback to get information about the device.
> *
> @@ -587,6 +588,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *info)
> ETH_LINK_SPEED_20G |
> ETH_LINK_SPEED_40G |
> ETH_LINK_SPEED_56G;
> + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
I think better to ident mlx4_ibv_to_dpdk_rss_types to the line below along with hw_rss_sup
> + priv->hw_rss_sup);
> }
>
> /**
> diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
> index 397a150..41dac16 100644
> --- a/drivers/net/mlx4/mlx4_flow.c
> +++ b/drivers/net/mlx4/mlx4_flow.c
> @@ -134,6 +134,55 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t
> types) }
>
> /**
> + * Convert verbs RSS types to their DPDK equivalents.
> + *
> + * This function returns a group of RSS dpdk types given their
> +equivalent group
> + * of verbs types.
> + * For example both source IPv4 and destination IPv4 verbs types are
> +converted
> + * into their equivalent RSS group types. If each of these verbs types
> +existed
> + * exclusively - no conversion would take place.
> + *
> + * @param types
> + * RSS hash types in verbs format
Missing period
> + *
> + * @return
> + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
DPDK RSS hash fields supported by mlx4. is enough.
> + */
> +uint64_t
> +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> + enum { IPV4, IPV6, TCP, UDP, };
> + const uint64_t 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,
> + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> IBV_RX_HASH_DST_PORT_UDP,
> + };
> + const uint64_t out[RTE_DIM(in)] = {
> + [IPV4] = (ETH_RSS_IPV4 |
> + ETH_RSS_FRAG_IPV4 |
> + ETH_RSS_NONFRAG_IPV4_OTHER),
> + [IPV6] = (ETH_RSS_IPV6 |
> + ETH_RSS_FRAG_IPV6 |
> + ETH_RSS_NONFRAG_IPV6_OTHER |
> + ETH_RSS_IPV6_EX),
> + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> + ETH_RSS_NONFRAG_IPV6_TCP |
> + ETH_RSS_IPV6_TCP_EX),
> + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> + ETH_RSS_NONFRAG_IPV6_UDP |
> + ETH_RSS_IPV6_UDP_EX),
> + };
> + uint64_t conv = 0;
> + unsigned int i;
> +
> + for (i = 0; i != RTE_DIM(in); ++i)
> + if ((types & in[i]) == in[i])
There is an issue with this logic. Sorry for not noticing in the previous version.
Let's say the caps report support for only UDP, no IP. On the logic above it will report both
ETH_RSS_NONFRAG_IPV4_UDP
ETH_RSS_NONFRAG_IPV6_UDP
It looks like for the L4 to be valid RSS hash it needs the l3 to be valid.
> + conv |= out[i];
> + return conv;
> +}
> +
> +/**
> * Merge Ethernet pattern item into flow rule handle.
> *
> * Additional mlx4-specific constraints on supported fields:
> diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
> index 2c8dff3..ec990df 100644
> --- a/drivers/net/mlx4/mlx4_flow.h
> +++ b/drivers/net/mlx4/mlx4_flow.h
> @@ -49,6 +49,7 @@ struct rte_flow {
> /* mlx4_flow.c */
>
> uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
> +uint64_t mlx4_ibv_to_dpdk_rss_types(uint64_t ibv_rss_types);
> int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void
> mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev
> *dev,
> --
> 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
2018-05-10 5:20 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
@ 2018-05-10 14:21 ` Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
` (3 more replies)
2 siblings, 4 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-10 14:21 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
v1:
Initial release
v2:
Update based on reviews (split into 2 commits)
v3:
More updates based on reviews
drivers/net/mlx4/mlx4_ethdev.c | 12 ++++++-----
drivers/net/mlx4/mlx4_flow.c | 45 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 35 ++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..ef559a3 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -582,11 +582,13 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
info->if_index = if_nametoindex(ifname);
info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE;
info->speed_capa =
- ETH_LINK_SPEED_1G |
- ETH_LINK_SPEED_10G |
- ETH_LINK_SPEED_20G |
- ETH_LINK_SPEED_40G |
- ETH_LINK_SPEED_56G;
+ ETH_LINK_SPEED_1G |
+ ETH_LINK_SPEED_10G |
+ ETH_LINK_SPEED_20G |
+ ETH_LINK_SPEED_40G |
+ ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads =
+ mlx4_ibv_to_rss_types(priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 397a150..baad299 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -134,6 +134,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS dpdk types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format.
+ *
+ * @return
+ * DPDK RSS hash fields supported by mlx4.
+ */
+uint64_t
+mlx4_ibv_to_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
+
+ const uint64_t in[] = {
+ [IPV4] = IPV4_IBV_HF,
+ [IPV6] = IPV6_IBV_HF,
+ [IPV4_TCP] = IPV4_IBV_HF | TCP_IBV_HF,
+ [IPV6_TCP] = IPV6_IBV_HF | TCP_IBV_HF,
+ [IPV4_UDP] = IPV4_IBV_HF | UDP_IBV_HF,
+ [IPV6_UDP] = IPV6_IBV_HF | UDP_IBV_HF,
+ };
+ const uint64_t out[RTE_DIM(in)] = {
+ [IPV4] = IPV4_RSS_HF,
+ [IPV6] = IPV6_RSS_HF,
+ [IPV4_TCP] = IPV4_RSS_HF | IPV4_TCP_RSS_HF,
+ [IPV6_TCP] = IPV6_RSS_HF | IPV6_TCP_RSS_HF,
+ [IPV4_UDP] = IPV4_RSS_HF | IPV4_UDP_RSS_HF,
+ [IPV6_UDP] = IPV6_RSS_HF | IPV6_UDP_RSS_HF,
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..e47982c 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -30,6 +30,40 @@
/** Meta pattern item used to distinguish internal rules. */
#define MLX4_FLOW_ITEM_TYPE_INTERNAL ((enum rte_flow_item_type)-1)
+/** IBV supported RSS hash functions combinations */
+#define IPV4_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV4 | \
+ IBV_RX_HASH_DST_IPV4)
+#define IPV6_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV6 | \
+ IBV_RX_HASH_DST_IPV6)
+#define TCP_IBV_HF ( \
+ IBV_RX_HASH_SRC_PORT_TCP | \
+ IBV_RX_HASH_DST_PORT_TCP)
+#define UDP_IBV_HF (IBV_RX_HASH_SRC_PORT_UDP | \
+ IBV_RX_HASH_DST_PORT_UDP)
+
+/** Supported RSS hash functions combinations */
+#define IPV4_RSS_HF ( \
+ ETH_RSS_IPV4 | \
+ ETH_RSS_FRAG_IPV4 | \
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+#define IPV6_RSS_HF ( \
+ ETH_RSS_IPV6 | \
+ ETH_RSS_FRAG_IPV6 | \
+ ETH_RSS_NONFRAG_IPV6_OTHER | \
+ ETH_RSS_IPV6_EX)
+#define IPV4_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_TCP)
+#define IPV6_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_TCP | \
+ ETH_RSS_IPV6_TCP_EX)
+#define IPV4_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_UDP)
+#define IPV6_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_UDP | \
+ ETH_RSS_IPV6_UDP_EX)
+
/** PMD-specific (mlx4) definition of a flow rule handle. */
struct rte_flow {
LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
@@ -49,6 +83,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
@ 2018-05-10 14:21 ` Ophir Munk
2018-05-13 6:05 ` Shahaf Shuler
2018-05-13 6:05 ` [dpdk-dev] [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
` (2 subsequent siblings)
3 siblings, 1 reply; 25+ messages in thread
From: Ophir Munk @ 2018-05-10 14:21 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
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 <ophirmu@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)] = {
[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[] = {
[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
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions
2018-05-10 5:20 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
@ 2018-05-10 14:25 ` Ophir Munk
0 siblings, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-10 14:25 UTC (permalink / raw)
To: Shahaf Shuler, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Hi,
PATCH v3 was sent
> -----Original Message-----
> From: Shahaf Shuler
> Sent: Thursday, May 10, 2018 8:20 AM
> To: Ophir Munk <ophirmu@mellanox.com>; dev@dpdk.org; Adrien
> Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; Olga Shern
> <olgas@mellanox.com>
> Subject: RE: [PATCH v2 1/2] net/mlx4: advertise supported RSS hash
> functions
>
> Hi Ophir,
>
> Thursday, May 10, 2018 1:27 AM, Ophir Munk:
> > Subject: [PATCH v2 1/2] net/mlx4: advertise supported RSS hash
> > functions
> >
> > Advertise mlx4 supported RSS functions as part of dev_infos_get callback.
> > Previous to this commit RSS support was reported as none. Since the
> > introduction of [1] it is required that all RSS configurations will be verified.
> >
> > [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> > v1:
> > Initial release
> > v2:
> > Split into 2 commits following reviews
> >
> > drivers/net/mlx4/mlx4_ethdev.c | 3 +++
> > drivers/net/mlx4/mlx4_flow.c | 49
> > ++++++++++++++++++++++++++++++++++++++++++
> > drivers/net/mlx4/mlx4_flow.h | 1 +
> > 3 files changed, 53 insertions(+)
> >
> > diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> > b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..8fbb781 100644
> > --- a/drivers/net/mlx4/mlx4_ethdev.c
> > +++ b/drivers/net/mlx4/mlx4_ethdev.c
> > @@ -544,6 +544,7 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev,
> struct
> > ether_addr *mac_addr)
> > return mlx4_mac_addr_add(dev, mac_addr, 0, 0); }
> >
> > +
>
> Remove this extra line.
>
> > /**
> > * DPDK callback to get information about the device.
> > *
> > @@ -587,6 +588,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev,
> struct
> > rte_eth_dev_info *info)
> > ETH_LINK_SPEED_20G |
> > ETH_LINK_SPEED_40G |
> > ETH_LINK_SPEED_56G;
> > + info->flow_type_rss_offloads = mlx4_ibv_to_dpdk_rss_types(
>
> I think better to ident mlx4_ibv_to_dpdk_rss_types to the line below along
> with hw_rss_sup
>
> > + priv->hw_rss_sup);
>
>
> > }
> >
> > /**
> > diff --git a/drivers/net/mlx4/mlx4_flow.c
> > b/drivers/net/mlx4/mlx4_flow.c index 397a150..41dac16 100644
> > --- a/drivers/net/mlx4/mlx4_flow.c
> > +++ b/drivers/net/mlx4/mlx4_flow.c
> > @@ -134,6 +134,55 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t
> > types) }
> >
> > /**
> > + * Convert verbs RSS types to their DPDK equivalents.
> > + *
> > + * This function returns a group of RSS dpdk types given their
> > +equivalent group
> > + * of verbs types.
> > + * For example both source IPv4 and destination IPv4 verbs types are
> > +converted
> > + * into their equivalent RSS group types. If each of these verbs
> > +types existed
> > + * exclusively - no conversion would take place.
> > + *
> > + * @param types
> > + * RSS hash types in verbs format
>
> Missing period
>
> > + *
> > + * @return
> > + * A valid dpdk RSS hash fields supported by mlx4 (may return 0)
>
> DPDK RSS hash fields supported by mlx4. is enough.
>
> > + */
> > +uint64_t
> > +mlx4_ibv_to_dpdk_rss_types(uint64_t types) {
> > + enum { IPV4, IPV6, TCP, UDP, };
> > + const uint64_t 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,
> > + [UDP] = IBV_RX_HASH_SRC_PORT_UDP |
> > IBV_RX_HASH_DST_PORT_UDP,
> > + };
> > + const uint64_t out[RTE_DIM(in)] = {
> > + [IPV4] = (ETH_RSS_IPV4 |
> > + ETH_RSS_FRAG_IPV4 |
> > + ETH_RSS_NONFRAG_IPV4_OTHER),
> > + [IPV6] = (ETH_RSS_IPV6 |
> > + ETH_RSS_FRAG_IPV6 |
> > + ETH_RSS_NONFRAG_IPV6_OTHER |
> > + ETH_RSS_IPV6_EX),
> > + [TCP] = (ETH_RSS_NONFRAG_IPV4_TCP |
> > + ETH_RSS_NONFRAG_IPV6_TCP |
> > + ETH_RSS_IPV6_TCP_EX),
> > + [UDP] = (ETH_RSS_NONFRAG_IPV4_UDP |
> > + ETH_RSS_NONFRAG_IPV6_UDP |
> > + ETH_RSS_IPV6_UDP_EX),
> > + };
> > + uint64_t conv = 0;
> > + unsigned int i;
> > +
> > + for (i = 0; i != RTE_DIM(in); ++i)
> > + if ((types & in[i]) == in[i])
>
> There is an issue with this logic. Sorry for not noticing in the previous version.
>
> Let's say the caps report support for only UDP, no IP. On the logic above it
> will report both ETH_RSS_NONFRAG_IPV4_UDP
> ETH_RSS_NONFRAG_IPV6_UDP
>
> It looks like for the L4 to be valid RSS hash it needs the l3 to be valid.
>
> > + conv |= out[i];
> > + return conv;
> > +}
> > +
> > +/**
> > * Merge Ethernet pattern item into flow rule handle.
> > *
> > * Additional mlx4-specific constraints on supported fields:
> > diff --git a/drivers/net/mlx4/mlx4_flow.h
> > b/drivers/net/mlx4/mlx4_flow.h index 2c8dff3..ec990df 100644
> > --- a/drivers/net/mlx4/mlx4_flow.h
> > +++ b/drivers/net/mlx4/mlx4_flow.h
> > @@ -49,6 +49,7 @@ struct rte_flow {
> > /* mlx4_flow.c */
> >
> > uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
> > +uint64_t mlx4_ibv_to_dpdk_rss_types(uint64_t ibv_rss_types);
> > int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
> > void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct
> > rte_eth_dev *dev,
> > --
> > 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
@ 2018-05-13 6:05 ` Shahaf Shuler
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
3 siblings, 0 replies; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-13 6:05 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
Thursday, May 10, 2018 5:22 PM, Ophir Munk:
@mellanox.com>; Shahaf
> Shuler <shahafs@mellanox.com>
> Subject: [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions
>
> Advertise mlx4 supported RSS functions as part of dev_infos_get callback.
> Previous to this commit RSS support was reported as none. Since the
> introduction of [1] it is required that all RSS configurations will be verified.
>
> [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
>
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
> v1:
> Initial release
> v2:
> Update based on reviews (split into 2 commits)
> v3:
> More updates based on reviews
>
> drivers/net/mlx4/mlx4_ethdev.c | 12 ++++++-----
> drivers/net/mlx4/mlx4_flow.c | 45
> ++++++++++++++++++++++++++++++++++++++++++
> drivers/net/mlx4/mlx4_flow.h | 35
> ++++++++++++++++++++++++++++++++
> 3 files changed, 87 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..ef559a3 100644
> --- a/drivers/net/mlx4/mlx4_ethdev.c
> +++ b/drivers/net/mlx4/mlx4_ethdev.c
> @@ -582,11 +582,13 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev,
> struct rte_eth_dev_info *info)
> info->if_index = if_nametoindex(ifname);
> info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE;
> info->speed_capa =
> - ETH_LINK_SPEED_1G |
> - ETH_LINK_SPEED_10G |
> - ETH_LINK_SPEED_20G |
> - ETH_LINK_SPEED_40G |
> - ETH_LINK_SPEED_56G;
> + ETH_LINK_SPEED_1G |
> + ETH_LINK_SPEED_10G |
> + ETH_LINK_SPEED_20G |
> + ETH_LINK_SPEED_40G |
> + ETH_LINK_SPEED_56G;
> + info->flow_type_rss_offloads =
> + mlx4_ibv_to_rss_types(priv->hw_rss_sup);
> }
>
> /**
> diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
> index 397a150..baad299 100644
> --- a/drivers/net/mlx4/mlx4_flow.c
> +++ b/drivers/net/mlx4/mlx4_flow.c
> @@ -134,6 +134,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t
> types) }
>
> /**
> + * Convert verbs RSS types to their DPDK equivalents.
> + *
> + * This function returns a group of RSS dpdk types given their
dpdk -> DPDK
> +equivalent group
> + * of verbs types.
> + * For example both source IPv4 and destination IPv4 verbs types are
> +converted
> + * into their equivalent RSS group types. If each of these verbs types
> +existed
> + * exclusively - no conversion would take place.
> + *
> + * @param types
> + * RSS hash types in verbs format.
> + *
> + * @return
> + * DPDK RSS hash fields supported by mlx4.
> + */
> +uint64_t
> +mlx4_ibv_to_rss_types(uint64_t types)
> +{
> + enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
> +
> + const uint64_t in[] = {
> + [IPV4] = IPV4_IBV_HF,
> + [IPV6] = IPV6_IBV_HF,
> + [IPV4_TCP] = IPV4_IBV_HF | TCP_IBV_HF,
> + [IPV6_TCP] = IPV6_IBV_HF | TCP_IBV_HF,
> + [IPV4_UDP] = IPV4_IBV_HF | UDP_IBV_HF,
> + [IPV6_UDP] = IPV6_IBV_HF | UDP_IBV_HF,
> + };
> + const uint64_t out[RTE_DIM(in)] = {
> + [IPV4] = IPV4_RSS_HF,
> + [IPV6] = IPV6_RSS_HF,
> + [IPV4_TCP] = IPV4_RSS_HF | IPV4_TCP_RSS_HF,
> + [IPV6_TCP] = IPV6_RSS_HF | IPV6_TCP_RSS_HF,
> + [IPV4_UDP] = IPV4_RSS_HF | IPV4_UDP_RSS_HF,
> + [IPV6_UDP] = IPV6_RSS_HF | IPV6_UDP_RSS_HF,
> + };
> + uint64_t conv = 0;
> + unsigned int i;
> +
> + for (i = 0; i != RTE_DIM(in); ++i)
> + if ((types & in[i]) == in[i])
> + conv |= out[i];
> + return conv;
> +}
> +
> +/**
> * Merge Ethernet pattern item into flow rule handle.
> *
> * Additional mlx4-specific constraints on supported fields:
> diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
> index 2c8dff3..e47982c 100644
> --- a/drivers/net/mlx4/mlx4_flow.h
> +++ b/drivers/net/mlx4/mlx4_flow.h
> @@ -30,6 +30,40 @@
> /** Meta pattern item used to distinguish internal rules. */ #define
> MLX4_FLOW_ITEM_TYPE_INTERNAL ((enum rte_flow_item_type)-1)
>
Any specific reason below MACRO are part of the .h file and not the .c file?
Also all mlx4 related macros should be prefixed with MLX4_
> +/** IBV supported RSS hash functions combinations */ #define
> +IPV4_IBV_HF ( \
> + IBV_RX_HASH_SRC_IPV4 | \
> + IBV_RX_HASH_DST_IPV4)
> +#define IPV6_IBV_HF ( \
> + IBV_RX_HASH_SRC_IPV6 | \
> + IBV_RX_HASH_DST_IPV6)
> +#define TCP_IBV_HF ( \
> + IBV_RX_HASH_SRC_PORT_TCP | \
> + IBV_RX_HASH_DST_PORT_TCP)
> +#define UDP_IBV_HF (IBV_RX_HASH_SRC_PORT_UDP | \
> + IBV_RX_HASH_DST_PORT_UDP)
> +
> +/** Supported RSS hash functions combinations */ #define IPV4_RSS_HF (
> +\
> + ETH_RSS_IPV4 | \
> + ETH_RSS_FRAG_IPV4 | \
> + ETH_RSS_NONFRAG_IPV4_OTHER)
> +#define IPV6_RSS_HF ( \
> + ETH_RSS_IPV6 | \
> + ETH_RSS_FRAG_IPV6 | \
> + ETH_RSS_NONFRAG_IPV6_OTHER | \
> + ETH_RSS_IPV6_EX)
> +#define IPV4_TCP_RSS_HF ( \
> + ETH_RSS_NONFRAG_IPV4_TCP)
> +#define IPV6_TCP_RSS_HF ( \
> + ETH_RSS_NONFRAG_IPV6_TCP | \
> + ETH_RSS_IPV6_TCP_EX)
> +#define IPV4_UDP_RSS_HF ( \
> + ETH_RSS_NONFRAG_IPV4_UDP)
> +#define IPV6_UDP_RSS_HF ( \
> + ETH_RSS_NONFRAG_IPV6_UDP | \
> + ETH_RSS_IPV6_UDP_EX)
> +
> /** PMD-specific (mlx4) definition of a flow rule handle. */ struct rte_flow {
> LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure.
> */ @@ -49,6 +83,7 @@ struct rte_flow {
> /* mlx4_flow.c */
>
> uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
> +uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
> int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void
> mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev
> *dev,
> --
> 2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
@ 2018-05-13 6:05 ` Shahaf Shuler
0 siblings, 0 replies; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-13 6:05 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
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 <ophirmu@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
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
2018-05-13 6:05 ` [dpdk-dev] [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
@ 2018-05-13 15:36 ` Ophir Munk
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
3 siblings, 1 reply; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 15:36 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
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
More updates based on reviews
drivers/net/mlx4/mlx4_flow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
@ 2018-05-13 15:36 ` Ophir Munk
0 siblings, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 15:36 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 12 ++++++-----
drivers/net/mlx4/mlx4_flow.c | 45 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 35 ++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..ef559a3 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -582,11 +582,13 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
info->if_index = if_nametoindex(ifname);
info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE;
info->speed_capa =
- ETH_LINK_SPEED_1G |
- ETH_LINK_SPEED_10G |
- ETH_LINK_SPEED_20G |
- ETH_LINK_SPEED_40G |
- ETH_LINK_SPEED_56G;
+ ETH_LINK_SPEED_1G |
+ ETH_LINK_SPEED_10G |
+ ETH_LINK_SPEED_20G |
+ ETH_LINK_SPEED_40G |
+ ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads =
+ mlx4_ibv_to_rss_types(priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f117e2e..b234623 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -139,6 +139,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS dpdk types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format.
+ *
+ * @return
+ * DPDK RSS hash fields supported by mlx4.
+ */
+uint64_t
+mlx4_ibv_to_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
+
+ static const uint64_t in[] = {
+ [IPV4] = IPV4_IBV_HF,
+ [IPV6] = IPV6_IBV_HF,
+ [IPV4_TCP] = IPV4_IBV_HF | TCP_IBV_HF,
+ [IPV6_TCP] = IPV6_IBV_HF | TCP_IBV_HF,
+ [IPV4_UDP] = IPV4_IBV_HF | UDP_IBV_HF,
+ [IPV6_UDP] = IPV6_IBV_HF | UDP_IBV_HF,
+ };
+ 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,
+ [IPV6_TCP] = IPV6_RSS_HF | IPV6_TCP_RSS_HF,
+ [IPV4_UDP] = IPV4_RSS_HF | IPV4_UDP_RSS_HF,
+ [IPV6_UDP] = IPV6_RSS_HF | IPV6_UDP_RSS_HF,
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..e47982c 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -30,6 +30,40 @@
/** Meta pattern item used to distinguish internal rules. */
#define MLX4_FLOW_ITEM_TYPE_INTERNAL ((enum rte_flow_item_type)-1)
+/** IBV supported RSS hash functions combinations */
+#define IPV4_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV4 | \
+ IBV_RX_HASH_DST_IPV4)
+#define IPV6_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV6 | \
+ IBV_RX_HASH_DST_IPV6)
+#define TCP_IBV_HF ( \
+ IBV_RX_HASH_SRC_PORT_TCP | \
+ IBV_RX_HASH_DST_PORT_TCP)
+#define UDP_IBV_HF (IBV_RX_HASH_SRC_PORT_UDP | \
+ IBV_RX_HASH_DST_PORT_UDP)
+
+/** Supported RSS hash functions combinations */
+#define IPV4_RSS_HF ( \
+ ETH_RSS_IPV4 | \
+ ETH_RSS_FRAG_IPV4 | \
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+#define IPV6_RSS_HF ( \
+ ETH_RSS_IPV6 | \
+ ETH_RSS_FRAG_IPV6 | \
+ ETH_RSS_NONFRAG_IPV6_OTHER | \
+ ETH_RSS_IPV6_EX)
+#define IPV4_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_TCP)
+#define IPV6_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_TCP | \
+ ETH_RSS_IPV6_TCP_EX)
+#define IPV4_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_UDP)
+#define IPV6_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_UDP | \
+ ETH_RSS_IPV6_UDP_EX)
+
/** PMD-specific (mlx4) definition of a flow rule handle. */
struct rte_flow {
LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
@@ -49,6 +83,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
` (2 preceding siblings ...)
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
@ 2018-05-13 15:39 ` Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
3 siblings, 2 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 15:39 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
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
More updates based on reviews
drivers/net/mlx4/mlx4_flow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
@ 2018-05-13 15:39 ` Ophir Munk
2018-05-13 16:12 ` Thomas Monjalon
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
1 sibling, 1 reply; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 15:39 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 12 ++++++-----
drivers/net/mlx4/mlx4_flow.c | 45 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 35 ++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..ef559a3 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -582,11 +582,13 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
info->if_index = if_nametoindex(ifname);
info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE;
info->speed_capa =
- ETH_LINK_SPEED_1G |
- ETH_LINK_SPEED_10G |
- ETH_LINK_SPEED_20G |
- ETH_LINK_SPEED_40G |
- ETH_LINK_SPEED_56G;
+ ETH_LINK_SPEED_1G |
+ ETH_LINK_SPEED_10G |
+ ETH_LINK_SPEED_20G |
+ ETH_LINK_SPEED_40G |
+ ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads =
+ mlx4_ibv_to_rss_types(priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f117e2e..b234623 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -139,6 +139,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS DPDK types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format.
+ *
+ * @return
+ * DPDK RSS hash fields supported by mlx4.
+ */
+uint64_t
+mlx4_ibv_to_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
+
+ static const uint64_t in[] = {
+ [IPV4] = IPV4_IBV_HF,
+ [IPV6] = IPV6_IBV_HF,
+ [IPV4_TCP] = IPV4_IBV_HF | TCP_IBV_HF,
+ [IPV6_TCP] = IPV6_IBV_HF | TCP_IBV_HF,
+ [IPV4_UDP] = IPV4_IBV_HF | UDP_IBV_HF,
+ [IPV6_UDP] = IPV6_IBV_HF | UDP_IBV_HF,
+ };
+ 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,
+ [IPV6_TCP] = IPV6_RSS_HF | IPV6_TCP_RSS_HF,
+ [IPV4_UDP] = IPV4_RSS_HF | IPV4_UDP_RSS_HF,
+ [IPV6_UDP] = IPV6_RSS_HF | IPV6_UDP_RSS_HF,
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..e47982c 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -30,6 +30,40 @@
/** Meta pattern item used to distinguish internal rules. */
#define MLX4_FLOW_ITEM_TYPE_INTERNAL ((enum rte_flow_item_type)-1)
+/** IBV supported RSS hash functions combinations */
+#define IPV4_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV4 | \
+ IBV_RX_HASH_DST_IPV4)
+#define IPV6_IBV_HF ( \
+ IBV_RX_HASH_SRC_IPV6 | \
+ IBV_RX_HASH_DST_IPV6)
+#define TCP_IBV_HF ( \
+ IBV_RX_HASH_SRC_PORT_TCP | \
+ IBV_RX_HASH_DST_PORT_TCP)
+#define UDP_IBV_HF (IBV_RX_HASH_SRC_PORT_UDP | \
+ IBV_RX_HASH_DST_PORT_UDP)
+
+/** Supported RSS hash functions combinations */
+#define IPV4_RSS_HF ( \
+ ETH_RSS_IPV4 | \
+ ETH_RSS_FRAG_IPV4 | \
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+#define IPV6_RSS_HF ( \
+ ETH_RSS_IPV6 | \
+ ETH_RSS_FRAG_IPV6 | \
+ ETH_RSS_NONFRAG_IPV6_OTHER | \
+ ETH_RSS_IPV6_EX)
+#define IPV4_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_TCP)
+#define IPV6_TCP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_TCP | \
+ ETH_RSS_IPV6_TCP_EX)
+#define IPV4_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV4_UDP)
+#define IPV6_UDP_RSS_HF ( \
+ ETH_RSS_NONFRAG_IPV6_UDP | \
+ ETH_RSS_IPV6_UDP_EX)
+
/** PMD-specific (mlx4) definition of a flow rule handle. */
struct rte_flow {
LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
@@ -49,6 +83,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
@ 2018-05-13 16:12 ` Thomas Monjalon
2018-05-13 16:13 ` Ophir Munk
0 siblings, 1 reply; 25+ messages in thread
From: Thomas Monjalon @ 2018-05-13 16:12 UTC (permalink / raw)
To: Ophir Munk; +Cc: dev, Adrien Mazarguil, Olga Shern, Shahaf Shuler
13/05/2018 17:39, Ophir Munk:
> info->speed_capa =
> - ETH_LINK_SPEED_1G |
> - ETH_LINK_SPEED_10G |
> - ETH_LINK_SPEED_20G |
> - ETH_LINK_SPEED_40G |
> - ETH_LINK_SPEED_56G;
> + ETH_LINK_SPEED_1G |
> + ETH_LINK_SPEED_10G |
> + ETH_LINK_SPEED_20G |
> + ETH_LINK_SPEED_40G |
> + ETH_LINK_SPEED_56G;
Not sure why you re-indent.
For info, line continuation in control statements must be done with 2 tabs:
http://dpdk.org/doc/guides/contributing/coding_style.html#general
In this case, it is not a control statement, so I guess 1 or 2 tabs
can be accepted.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 16:12 ` Thomas Monjalon
@ 2018-05-13 16:13 ` Ophir Munk
2018-05-13 16:23 ` Ophir Munk
0 siblings, 1 reply; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 16:13 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, Adrien Mazarguil, Olga Shern, Shahaf Shuler
Shahaf asked for it in his review
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Sunday, May 13, 2018 7:13 PM
> To: Ophir Munk <ophirmu@mellanox.com>
> Cc: dev@dpdk.org; Adrien Mazarguil <adrien.mazarguil@6wind.com>; Olga
> Shern <olgas@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Subject: Re: [PATCH v4 2/2] net/mlx4: advertise supported RSS hash
> functions
>
> 13/05/2018 17:39, Ophir Munk:
> > info->speed_capa =
> > - ETH_LINK_SPEED_1G |
> > - ETH_LINK_SPEED_10G |
> > - ETH_LINK_SPEED_20G |
> > - ETH_LINK_SPEED_40G |
> > - ETH_LINK_SPEED_56G;
> > + ETH_LINK_SPEED_1G |
> > + ETH_LINK_SPEED_10G |
> > + ETH_LINK_SPEED_20G |
> > + ETH_LINK_SPEED_40G |
> > + ETH_LINK_SPEED_56G;
>
> Not sure why you re-indent.
> For info, line continuation in control statements must be done with 2 tabs:
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F
> %2Fdpdk.org%2Fdoc%2Fguides%2Fcontributing%2Fcoding_style.html%23ge
> neral&data=02%7C01%7Cophirmu%40mellanox.com%7C521136e06b61475a
> 99c308d5b8ec58fa%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7
> C636618247609249241&sdata=GkEBudFg9ukUbGM9Wi%2F84vT%2FQRv3qX
> KuT%2BiFN0ziVjc%3D&reserved=0
> In this case, it is not a control statement, so I guess 1 or 2 tabs can be
> accepted.
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 16:13 ` Ophir Munk
@ 2018-05-13 16:23 ` Ophir Munk
0 siblings, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 16:23 UTC (permalink / raw)
To: Thomas Monjalon
Cc: 'dev@dpdk.org', Adrien Mazarguil, Olga Shern, Shahaf Shuler
Anyway will update in v5 to be sent now
> -----Original Message-----
> From: Ophir Munk
> Sent: Sunday, May 13, 2018 7:14 PM
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: dev@dpdk.org; Adrien Mazarguil <adrien.mazarguil@6wind.com>; Olga
> Shern <olgas@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Subject: RE: [PATCH v4 2/2] net/mlx4: advertise supported RSS hash
> functions
>
> Shahaf asked for it in his review
>
> > -----Original Message-----
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > Sent: Sunday, May 13, 2018 7:13 PM
> > To: Ophir Munk <ophirmu@mellanox.com>
> > Cc: dev@dpdk.org; Adrien Mazarguil <adrien.mazarguil@6wind.com>; Olga
> > Shern <olgas@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> > Subject: Re: [PATCH v4 2/2] net/mlx4: advertise supported RSS hash
> > functions
> >
> > 13/05/2018 17:39, Ophir Munk:
> > > info->speed_capa =
> > > - ETH_LINK_SPEED_1G |
> > > - ETH_LINK_SPEED_10G |
> > > - ETH_LINK_SPEED_20G |
> > > - ETH_LINK_SPEED_40G |
> > > - ETH_LINK_SPEED_56G;
> > > + ETH_LINK_SPEED_1G |
> > > + ETH_LINK_SPEED_10G |
> > > + ETH_LINK_SPEED_20G |
> > > + ETH_LINK_SPEED_40G |
> > > + ETH_LINK_SPEED_56G;
> >
> > Not sure why you re-indent.
> > For info, line continuation in control statements must be done with 2 tabs:
> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F
> >
> %2Fdpdk.org%2Fdoc%2Fguides%2Fcontributing%2Fcoding_style.html%23ge
> >
> neral&data=02%7C01%7Cophirmu%40mellanox.com%7C521136e06b61475a
> >
> 99c308d5b8ec58fa%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7
> >
> C636618247609249241&sdata=GkEBudFg9ukUbGM9Wi%2F84vT%2FQRv3qX
> > KuT%2BiFN0ziVjc%3D&reserved=0
> > In this case, it is not a control statement, so I guess 1 or 2 tabs
> > can be accepted.
> >
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
@ 2018-05-13 16:50 ` Ophir Munk
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
1 sibling, 2 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 16:50 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
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
v3, v4, v5
More updates based on reviews
drivers/net/mlx4/mlx4_flow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v5 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
@ 2018-05-13 16:50 ` Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
1 sibling, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-13 16:50 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 2 ++
drivers/net/mlx4/mlx4_flow.c | 79 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 1 +
3 files changed, 82 insertions(+)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..0a9c2e2 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -587,6 +587,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
ETH_LINK_SPEED_20G |
ETH_LINK_SPEED_40G |
ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads =
+ mlx4_ibv_to_rss_types(priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f117e2e..8d90e06 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -42,6 +42,40 @@
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"
+/** IBV supported RSS hash functions combinations */
+#define MLX4_IPV4_HF ( \
+ IBV_RX_HASH_SRC_IPV4 | \
+ IBV_RX_HASH_DST_IPV4)
+#define MLX4_IPV6_HF ( \
+ IBV_RX_HASH_SRC_IPV6 | \
+ IBV_RX_HASH_DST_IPV6)
+#define MLX4_TCP_HF ( \
+ IBV_RX_HASH_SRC_PORT_TCP | \
+ IBV_RX_HASH_DST_PORT_TCP)
+#define MLX4_UDP_HF (IBV_RX_HASH_SRC_PORT_UDP | \
+ IBV_RX_HASH_DST_PORT_UDP)
+
+/** Supported RSS hash functions combinations */
+#define ETH_RSS_IPV4_HF ( \
+ ETH_RSS_IPV4 | \
+ ETH_RSS_FRAG_IPV4 | \
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+#define ETH_RSS_IPV6_HF ( \
+ ETH_RSS_IPV6 | \
+ ETH_RSS_FRAG_IPV6 | \
+ ETH_RSS_NONFRAG_IPV6_OTHER | \
+ ETH_RSS_IPV6_EX)
+#define ETH_RSS_IPV4_TCP_HF ( \
+ ETH_RSS_NONFRAG_IPV4_TCP)
+#define ETH_RSS_IPV6_TCP_HF ( \
+ ETH_RSS_NONFRAG_IPV6_TCP | \
+ ETH_RSS_IPV6_TCP_EX)
+#define ETH_RSS_IPV4_UDP_HF ( \
+ ETH_RSS_NONFRAG_IPV4_UDP)
+#define ETH_RSS_IPV6_UDP_HF ( \
+ ETH_RSS_NONFRAG_IPV6_UDP | \
+ ETH_RSS_IPV6_UDP_EX)
+
/** Static initializer for a list of subsequent item types. */
#define NEXT_ITEM(...) \
(const enum rte_flow_item_type []){ \
@@ -139,6 +173,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS DPDK types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format.
+ *
+ * @return
+ * DPDK RSS hash fields supported by mlx4.
+ */
+uint64_t
+mlx4_ibv_to_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
+
+ static const uint64_t in[] = {
+ [IPV4] = MLX4_IPV4_HF,
+ [IPV6] = MLX4_IPV6_HF,
+ [IPV4_TCP] = MLX4_IPV4_HF | MLX4_TCP_HF,
+ [IPV6_TCP] = MLX4_IPV6_HF | MLX4_TCP_HF,
+ [IPV4_UDP] = MLX4_IPV4_HF | MLX4_UDP_HF,
+ [IPV6_UDP] = MLX4_IPV6_HF | MLX4_UDP_HF,
+ };
+ static const uint64_t out[RTE_DIM(in)] = {
+ [IPV4] = ETH_RSS_IPV4_HF,
+ [IPV6] = ETH_RSS_IPV6_HF,
+ [IPV4_TCP] = ETH_RSS_IPV4_HF | ETH_RSS_IPV4_TCP_HF,
+ [IPV6_TCP] = ETH_RSS_IPV6_HF | ETH_RSS_IPV6_TCP_HF,
+ [IPV4_UDP] = ETH_RSS_IPV4_HF | ETH_RSS_IPV4_UDP_HF,
+ [IPV6_UDP] = ETH_RSS_IPV6_HF | ETH_RSS_IPV6_UDP_HF,
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..d1f1611 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -49,6 +49,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
@ 2018-05-14 10:07 ` Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-14 10:14 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Shahaf Shuler
1 sibling, 2 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-14 10:07 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
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(-)
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,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-dev] [PATCH v6 2/2] net/mlx4: advertise supported RSS hash functions
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
@ 2018-05-14 10:07 ` Ophir Munk
2018-05-14 10:14 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Shahaf Shuler
1 sibling, 0 replies; 25+ messages in thread
From: Ophir Munk @ 2018-05-14 10:07 UTC (permalink / raw)
To: dev, Adrien Mazarguil
Cc: Thomas Monjalon, Olga Shern, Ophir Munk, Shahaf Shuler
Advertise mlx4 supported RSS functions as part of dev_infos_get
callback.
Previous to this commit RSS support was reported as none. Since the
introduction of [1] it is required that all RSS configurations will be
verified.
[1] commit 8863a1fbfc66 ("ethdev: add supported hash function check")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 2 ++
drivers/net/mlx4/mlx4_flow.c | 80 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/mlx4/mlx4_flow.h | 1 +
3 files changed, 83 insertions(+)
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 9a76670..0a9c2e2 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -587,6 +587,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
ETH_LINK_SPEED_20G |
ETH_LINK_SPEED_40G |
ETH_LINK_SPEED_56G;
+ info->flow_type_rss_offloads =
+ mlx4_ibv_to_rss_types(priv->hw_rss_sup);
}
/**
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f117e2e..3085829 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -42,6 +42,41 @@
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"
+/** IBV supported RSS hash functions combinations */
+#define MLX4_IBV_IPV4_HF ( \
+ IBV_RX_HASH_SRC_IPV4 | \
+ IBV_RX_HASH_DST_IPV4)
+#define MLX4_IBV_IPV6_HF ( \
+ IBV_RX_HASH_SRC_IPV6 | \
+ IBV_RX_HASH_DST_IPV6)
+#define MLX4_IBV_TCP_HF ( \
+ IBV_RX_HASH_SRC_PORT_TCP | \
+ IBV_RX_HASH_DST_PORT_TCP)
+#define MLX4_IBV_UDP_HF ( \
+ IBV_RX_HASH_SRC_PORT_UDP | \
+ IBV_RX_HASH_DST_PORT_UDP)
+
+/** Supported RSS hash functions combinations */
+#define MLX4_RSS_IPV4_HF ( \
+ ETH_RSS_IPV4 | \
+ ETH_RSS_FRAG_IPV4 | \
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+#define MLX4_RSS_IPV6_HF ( \
+ ETH_RSS_IPV6 | \
+ ETH_RSS_FRAG_IPV6 | \
+ ETH_RSS_NONFRAG_IPV6_OTHER | \
+ ETH_RSS_IPV6_EX)
+#define MLX4_RSS_IPV4_TCP_HF ( \
+ ETH_RSS_NONFRAG_IPV4_TCP)
+#define MLX4_RSS_IPV6_TCP_HF ( \
+ ETH_RSS_NONFRAG_IPV6_TCP | \
+ ETH_RSS_IPV6_TCP_EX)
+#define MLX4_RSS_IPV4_UDP_HF ( \
+ ETH_RSS_NONFRAG_IPV4_UDP)
+#define MLX4_RSS_IPV6_UDP_HF ( \
+ ETH_RSS_NONFRAG_IPV6_UDP | \
+ ETH_RSS_IPV6_UDP_EX)
+
/** Static initializer for a list of subsequent item types. */
#define NEXT_ITEM(...) \
(const enum rte_flow_item_type []){ \
@@ -139,6 +174,51 @@ mlx4_conv_rss_types(struct priv *priv, uint64_t types)
}
/**
+ * Convert verbs RSS types to their DPDK equivalents.
+ *
+ * This function returns a group of RSS DPDK types given their equivalent group
+ * of verbs types.
+ * For example both source IPv4 and destination IPv4 verbs types are converted
+ * into their equivalent RSS group types. If each of these verbs types existed
+ * exclusively - no conversion would take place.
+ *
+ * @param types
+ * RSS hash types in verbs format.
+ *
+ * @return
+ * DPDK RSS hash fields supported by mlx4.
+ */
+uint64_t
+mlx4_ibv_to_rss_types(uint64_t types)
+{
+ enum { IPV4, IPV6, IPV4_TCP, IPV6_TCP, IPV4_UDP, IPV6_UDP};
+
+ static const uint64_t in[] = {
+ [IPV4] = MLX4_IBV_IPV4_HF,
+ [IPV6] = MLX4_IBV_IPV6_HF,
+ [IPV4_TCP] = MLX4_IBV_IPV4_HF | MLX4_IBV_TCP_HF,
+ [IPV6_TCP] = MLX4_IBV_IPV6_HF | MLX4_IBV_TCP_HF,
+ [IPV4_UDP] = MLX4_IBV_IPV4_HF | MLX4_IBV_UDP_HF,
+ [IPV6_UDP] = MLX4_IBV_IPV6_HF | MLX4_IBV_UDP_HF,
+ };
+ static const uint64_t out[RTE_DIM(in)] = {
+ [IPV4] = MLX4_RSS_IPV4_HF,
+ [IPV6] = MLX4_RSS_IPV6_HF,
+ [IPV4_TCP] = MLX4_RSS_IPV4_HF | MLX4_RSS_IPV4_TCP_HF,
+ [IPV6_TCP] = MLX4_RSS_IPV6_HF | MLX4_RSS_IPV6_TCP_HF,
+ [IPV4_UDP] = MLX4_RSS_IPV4_HF | MLX4_RSS_IPV4_UDP_HF,
+ [IPV6_UDP] = MLX4_RSS_IPV6_HF | MLX4_RSS_IPV6_UDP_HF,
+ };
+ uint64_t conv = 0;
+ unsigned int i;
+
+ for (i = 0; i != RTE_DIM(in); ++i)
+ if ((types & in[i]) == in[i])
+ conv |= out[i];
+ return conv;
+}
+
+/**
* Merge Ethernet pattern item into flow rule handle.
*
* Additional mlx4-specific constraints on supported fields:
diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h
index 2c8dff3..d1f1611 100644
--- a/drivers/net/mlx4/mlx4_flow.h
+++ b/drivers/net/mlx4/mlx4_flow.h
@@ -49,6 +49,7 @@ struct rte_flow {
/* mlx4_flow.c */
uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf);
+uint64_t mlx4_ibv_to_rss_types(uint64_t ibv_rss_types);
int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error);
void mlx4_flow_clean(struct priv *priv);
int mlx4_filter_ctrl(struct rte_eth_dev *dev,
--
2.7.4
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
@ 2018-05-14 10:14 ` Shahaf Shuler
1 sibling, 0 replies; 25+ messages in thread
From: Shahaf Shuler @ 2018-05-14 10:14 UTC (permalink / raw)
To: Ophir Munk, dev, Adrien Mazarguil; +Cc: Thomas Monjalon, Olga Shern
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.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2018-05-14 10:14 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 15:43 [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions Ophir Munk
2018-05-09 9:38 ` Shahaf Shuler
2018-05-09 11:54 ` Ophir Munk
2018-05-09 14:01 ` Shahaf Shuler
2018-05-09 22:42 ` Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise " Ophir Munk
2018-05-09 22:27 ` [dpdk-dev] [PATCH v2 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
2018-05-10 5:20 ` [dpdk-dev] [PATCH v2 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
2018-05-10 14:25 ` Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 " Ophir Munk
2018-05-10 14:21 ` [dpdk-dev] [PATCH v3 2/2] net/mlx4: avoid constant recreations in functions Ophir Munk
2018-05-13 6:05 ` Shahaf Shuler
2018-05-13 6:05 ` [dpdk-dev] [PATCH v3 1/2] net/mlx4: advertise supported RSS hash functions Shahaf Shuler
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 15:36 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 15:39 ` [dpdk-dev] [PATCH v4 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-13 16:12 ` Thomas Monjalon
2018-05-13 16:13 ` Ophir Munk
2018-05-13 16:23 ` Ophir Munk
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-13 16:50 ` [dpdk-dev] [PATCH v5 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Ophir Munk
2018-05-14 10:07 ` [dpdk-dev] [PATCH v6 2/2] net/mlx4: advertise supported RSS hash functions Ophir Munk
2018-05-14 10:14 ` [dpdk-dev] [PATCH v6 1/2] net/mlx4: avoid constant recreations in function Shahaf Shuler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).