On Tue, Apr 10, 2018 at 09:34:06PM +0800, Xueming Li wrote: > This patch split out flow RSS hash field handling logic to dedicate > function. > > Signed-off-by: Xueming Li <xuemi...@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranje...@6wind.com> > --- > drivers/net/mlx5/mlx5_flow.c | 94 > +++++++++++++++++++++++++------------------- > 1 file changed, 53 insertions(+), 41 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index b3ad6dc85..64658bc0e 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -992,13 +992,6 @@ mlx5_flow_update_priority(struct rte_eth_dev *dev, > static void > mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) > { > - const unsigned int ipv4 = > - hash_rxq_init[parser->layer].ip_version == MLX5_IPV4; > - const enum hash_rxq_type hmin = ipv4 ? HASH_RXQ_TCPV4 : HASH_RXQ_TCPV6; > - const enum hash_rxq_type hmax = ipv4 ? HASH_RXQ_IPV4 : HASH_RXQ_IPV6; > - const enum hash_rxq_type ohmin = ipv4 ? HASH_RXQ_TCPV6 : HASH_RXQ_TCPV4; > - const enum hash_rxq_type ohmax = ipv4 ? HASH_RXQ_IPV6 : HASH_RXQ_IPV4; > - const enum hash_rxq_type ip = ipv4 ? HASH_RXQ_IPV4 : HASH_RXQ_IPV6; > unsigned int i; > > /* Remove any other flow not matching the pattern. */ > @@ -1011,40 +1004,6 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > return; > } > - if (parser->layer == HASH_RXQ_ETH) { > - goto fill; > - } else { > - /* > - * This layer becomes useless as the pattern define under > - * layers. > - */ > - rte_free(parser->queue[HASH_RXQ_ETH].ibv_attr); > - parser->queue[HASH_RXQ_ETH].ibv_attr = NULL; > - } > - /* Remove opposite kind of layer e.g. IPv6 if the pattern is IPv4. */ > - for (i = ohmin; i != (ohmax + 1); ++i) { > - if (!parser->queue[i].ibv_attr) > - continue; > - rte_free(parser->queue[i].ibv_attr); > - parser->queue[i].ibv_attr = NULL; > - } > - /* Remove impossible flow according to the RSS configuration. */ > - if (hash_rxq_init[parser->layer].dpdk_rss_hf & > - parser->rss_conf.types) { > - /* Remove any other flow. */ > - for (i = hmin; i != (hmax + 1); ++i) { > - if ((i == parser->layer) || > - (!parser->queue[i].ibv_attr)) > - continue; > - rte_free(parser->queue[i].ibv_attr); > - parser->queue[i].ibv_attr = NULL; > - } > - } else if (!parser->queue[ip].ibv_attr) { > - /* no RSS possible with the current configuration. */ > - parser->rss_conf.queue_num = 1; > - return; > - } > -fill: > /* > * Fill missing layers in verbs specifications, or compute the correct > * offset to allocate the memory space for the attributes and > @@ -1107,6 +1066,56 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > > /** > + * Update flows according to pattern and RSS hash fields. > + * > + * @param[in, out] parser > + * Internal parser structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set. > + */ > +static int > +mlx5_flow_convert_rss(struct mlx5_flow_parse *parser) > +{ > + const unsigned int ipv4 = > + hash_rxq_init[parser->layer].ip_version == MLX5_IPV4; > + const enum hash_rxq_type hmin = ipv4 ? HASH_RXQ_TCPV4 : HASH_RXQ_TCPV6; > + const enum hash_rxq_type hmax = ipv4 ? HASH_RXQ_IPV4 : HASH_RXQ_IPV6; > + const enum hash_rxq_type ohmin = ipv4 ? HASH_RXQ_TCPV6 : HASH_RXQ_TCPV4; > + const enum hash_rxq_type ohmax = ipv4 ? HASH_RXQ_IPV6 : HASH_RXQ_IPV4; > + const enum hash_rxq_type ip = ipv4 ? HASH_RXQ_IPV4 : HASH_RXQ_IPV6; > + unsigned int i; > + > + if (parser->layer == HASH_RXQ_ETH) > + return 0; > + /* This layer becomes useless as the pattern define under layers. */ > + rte_free(parser->queue[HASH_RXQ_ETH].ibv_attr); > + parser->queue[HASH_RXQ_ETH].ibv_attr = NULL; > + /* Remove opposite kind of layer e.g. IPv6 if the pattern is IPv4. */ > + for (i = ohmin; i != (ohmax + 1); ++i) { > + if (!parser->queue[i].ibv_attr) > + continue; > + rte_free(parser->queue[i].ibv_attr); > + parser->queue[i].ibv_attr = NULL; > + } > + /* Remove impossible flow according to the RSS configuration. */ > + if (hash_rxq_init[parser->layer].dpdk_rss_hf & > + parser->rss_conf.types) { > + /* Remove any other flow. */ > + for (i = hmin; i != (hmax + 1); ++i) { > + if (i == parser->layer || !parser->queue[i].ibv_attr) > + continue; > + rte_free(parser->queue[i].ibv_attr); > + parser->queue[i].ibv_attr = NULL; > + } > + } else if (!parser->queue[ip].ibv_attr) { > + /* no RSS possible with the current configuration. */ > + parser->rss_conf.queue_num = 1; > + } > + return 0; > +} > + > +/** > * Validate and convert a flow supported by the NIC. > * > * @param dev > @@ -1214,6 +1223,9 @@ mlx5_flow_convert(struct rte_eth_dev *dev, > * configuration. > */ > if (!parser->drop) > + ret = mlx5_flow_convert_rss(parser); > + if (ret) > + goto exit_free; > mlx5_flow_convert_finalise(parser); > mlx5_flow_update_priority(dev, parser, attr); > exit_free: > -- > 2.13.3 > -- Nélio Laranjeiro 6WIND