From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id A1876A49B for ; Tue, 13 Mar 2018 15:18:58 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id f14so23198836wre.8 for ; Tue, 13 Mar 2018 07:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/94/RUSviUriUlRP/AukF6Zn8TcUSQQa4cP6HTK6DAM=; b=T9WyRBbJwYyNN0dwm0Eraz87QnKPPHBeebPUy5/HBY4ACgmupSThXvkeL3j9Fj1NEx kb7/0a+ph7VT0VG8gzWM3fXt9nKMCuhr5QnqaRcR+CVKid9exjRUt+ZBEEk5civUEg2y UHVamrhcEEAibiDfRwj0OoYWGgpyvLDyTdq9r8DVAw622hS2H6fTbw0uox7eD04ZPtdQ unngGhzuLjaTZ4efCC9Rpu6WAl+IFk8c76hWY5as6k8cQofL3g+NDdY/1dMd+ZA2aAa8 e8rDkwej5i1hnFLTsppMAuKKQUULrC28aVVUlT1X7lOJSrcn0sV5yHQTHFoaHTXyy//Z ECaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/94/RUSviUriUlRP/AukF6Zn8TcUSQQa4cP6HTK6DAM=; b=EXsykYv6eHMppUGngQ3PKeTKnszrk5scecKPrAvqQrvL4hffCavAcnFyy7ZF559Rg0 HH8wlcaIAcUODovLWZwAcO89YMHgs/KE5T86mgteZ2Egl4ErcR7ul6RjrXb0N4STJKUl kdwRU7ZDClKzlkFfN6S/U2zZsX8UIH02d+76SE3pv8mnrvdlqVfHCu3Z5cVydYPNYrpv 5ALO+qrz+NRg6KKUZePqdQCL17H2WNO6DTPtYZZeKx9Hw+bMt7kgDjZ9wKobMdJY1h9G SS6K7r/eYnBDVtAOMNDewtgFaSOAArWakcUUszdssrwDhk39wVAUW5oy6xExPRY5D/8y 2GGA== X-Gm-Message-State: AElRT7EBSQ8uAiMrJdiouMmKnpbk9xaUPImM/NJNeA8S2VHB9bV5mcvl 1Lok5warpdTLf2jHxEZUQ4YY X-Google-Smtp-Source: AG47ELt9GZMdwGmOshTKOlTFJohYvsiEn0IWI5w8dsNAXuEj752+Mfeq3YjO+Po1NQR+RuupKsd2hg== X-Received: by 10.28.249.21 with SMTP id x21mr981775wmh.114.1520950738333; Tue, 13 Mar 2018 07:18:58 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x78sm466302wmd.2.2018.03.13.07.18.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 07:18:57 -0700 (PDT) From: Nelio Laranjeiro To: Adrien Mazarguil , Yongseok Koh Cc: dev@dpdk.org Date: Tue, 13 Mar 2018 15:17:38 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: <7aeb54018d1a8dd06638632076f25fbc88945afd.1518686582.git.nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH 3/4] net/mlx5: improve flow error explanation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 14:18:58 -0000 Fill the error context in conversion function to provide a better reason on why it cannot be done to the user. Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 72 ++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index e7040daad..5c096ca9c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -44,40 +44,46 @@ struct ibv_flow_spec_counter_action { extern const struct eth_dev_ops mlx5_dev_ops; extern const struct eth_dev_ops mlx5_dev_ops_isolate; +/** Structure give to the conversion functions. */ +struct mlx5_flow_data { + struct mlx5_flow_parse *parser; /** Parser context. */ + struct rte_flow_error *error; /** Error context. */ +}; + static int mlx5_flow_create_eth(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_vlan(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_ipv4(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_ipv6(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_udp(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_tcp(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); static int mlx5_flow_create_vxlan(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); struct mlx5_flow_parse; @@ -252,7 +258,7 @@ struct mlx5_flow_items { */ int (*convert)(const struct rte_flow_item *item, const void *default_mask, - void *data); + struct mlx5_flow_data *data); /** Size in bytes of the destination structure. */ const unsigned int dst_sz; /** List of possible following items. */ @@ -1118,6 +1124,11 @@ mlx5_flow_convert(struct rte_eth_dev *dev, /* Third step. Conversion parse, fill the specifications. */ parser->inner = 0; for (; items->type != RTE_FLOW_ITEM_TYPE_END; ++items) { + struct mlx5_flow_data data = { + .parser = parser, + .error = error, + }; + if (items->type == RTE_FLOW_ITEM_TYPE_VOID) continue; cur_item = &mlx5_flow_items[items->type]; @@ -1125,13 +1136,9 @@ mlx5_flow_convert(struct rte_eth_dev *dev, (cur_item->default_mask ? cur_item->default_mask : cur_item->mask), - parser); - if (ret) { - rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_ITEM, - items, "item not supported"); + &data); + if (ret) goto exit_free; - } } if (parser->mark) mlx5_flow_create_flag_mark(parser, parser->mark_id); @@ -1224,11 +1231,11 @@ mlx5_flow_create_copy(struct mlx5_flow_parse *parser, void *src, static int mlx5_flow_create_eth(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_eth *spec = item->spec; const struct rte_flow_item_eth *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); struct ibv_flow_spec_eth eth = { .type = parser->inner | IBV_FLOW_SPEC_ETH, @@ -1276,11 +1283,11 @@ mlx5_flow_create_eth(const struct rte_flow_item *item, static int mlx5_flow_create_vlan(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_vlan *spec = item->spec; const struct rte_flow_item_vlan *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); @@ -1319,11 +1326,11 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, static int mlx5_flow_create_ipv4(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_ipv4 *spec = item->spec; const struct rte_flow_item_ipv4 *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; unsigned int ipv4_size = sizeof(struct ibv_flow_spec_ipv4_ext); struct ibv_flow_spec_ipv4_ext ipv4 = { .type = parser->inner | IBV_FLOW_SPEC_IPV4_EXT, @@ -1374,11 +1381,11 @@ mlx5_flow_create_ipv4(const struct rte_flow_item *item, static int mlx5_flow_create_ipv6(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_ipv6 *spec = item->spec; const struct rte_flow_item_ipv6 *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; unsigned int ipv6_size = sizeof(struct ibv_flow_spec_ipv6); struct ibv_flow_spec_ipv6 ipv6 = { .type = parser->inner | IBV_FLOW_SPEC_IPV6, @@ -1449,11 +1456,11 @@ mlx5_flow_create_ipv6(const struct rte_flow_item *item, static int mlx5_flow_create_udp(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_udp *spec = item->spec; const struct rte_flow_item_udp *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; unsigned int udp_size = sizeof(struct ibv_flow_spec_tcp_udp); struct ibv_flow_spec_tcp_udp udp = { .type = parser->inner | IBV_FLOW_SPEC_UDP, @@ -1498,11 +1505,11 @@ mlx5_flow_create_udp(const struct rte_flow_item *item, static int mlx5_flow_create_tcp(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_tcp *spec = item->spec; const struct rte_flow_item_tcp *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; unsigned int tcp_size = sizeof(struct ibv_flow_spec_tcp_udp); struct ibv_flow_spec_tcp_udp tcp = { .type = parser->inner | IBV_FLOW_SPEC_TCP, @@ -1547,11 +1554,11 @@ mlx5_flow_create_tcp(const struct rte_flow_item *item, static int mlx5_flow_create_vxlan(const struct rte_flow_item *item, const void *default_mask, - void *data) + struct mlx5_flow_data *data) { const struct rte_flow_item_vxlan *spec = item->spec; const struct rte_flow_item_vxlan *mask = item->mask; - struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data; + struct mlx5_flow_parse *parser = data->parser; unsigned int size = sizeof(struct ibv_flow_spec_tunnel); struct ibv_flow_spec_tunnel vxlan = { .type = parser->inner | IBV_FLOW_SPEC_VXLAN_TUNNEL, @@ -1582,10 +1589,11 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item, * before will also match this rule. * To avoid such situation, VNI 0 is currently refused. */ - if (!vxlan.val.tunnel_id) { - rte_errno = EINVAL; - return -rte_errno; - } + if (!vxlan.val.tunnel_id) + return rte_flow_error_set(data->error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VxLAN vni cannot be 0"); mlx5_flow_create_copy(parser, &vxlan, size); return 0; } -- 2.11.0