From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id C01731B2C4 for ; Thu, 12 Oct 2017 14:20:17 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id b189so12574472wmd.4 for ; Thu, 12 Oct 2017 05:20:17 -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; bh=qjldaOUHSXAuJSSlTt4tja6TiFH4Tj7CKr6axkAXPyE=; b=xq0JDrelHJHVFqohfUGviJGqfeKYUuFqjgZh57sezr5ZBMglPLaLktknv2Ig1RKrvm iqaFozeqIhrKoNoZPkWv8pZ+MhyPWv25V8NpKndgUMyvbWZIS1VyzdSSSTPl6+pqHU5C W2CpBCC5qhHW0+GWt04C47TA23U7P5oUC0sv28mQ7Z4/O9JBShhzUK9fv6WZyajdfVsX 5Yr5WiIdChTk1jaHjDAnST+9rjA3pRulTC0KVLRytyylyxE/tDansNn+eq6zDdn1JNnK jmO07hH2FYc7WZgpS/9JIwxvh2GWT8WITcgqT8GHSyEHyUVcfd7kqfTUEGfg/aXXUoF+ uMiw== 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; bh=qjldaOUHSXAuJSSlTt4tja6TiFH4Tj7CKr6axkAXPyE=; b=cyr8UcNIlVtBPfH7ytj8zLr4QgjggrxTg5zR21U3EntJvI5OWdkSAGnFChI7t44Bn4 gMbUZNtxnvR+zto/u8bpnGUZGsRH2+ZxrzIN+8YGR+VV+0Nrn1fSCJ7YXUYtWuMBETcI WZWgcIg/5eKk73ReGhhQj8nlAzlQvpnGZBD6cFEfEn9Hu63GUmfmlxdLYPPKK6hHR7OC eKKMy/BQxK1QEYHtfC5Z6ShgsaYLV903dmrbBklj5VtKUy/LVeeOc63bNVjwnjIXDxeB oPUC3fDpUXv1lcYwyzjJM7BTFiu4qyCXR7BGz5ulbcTc/46C+wDYt4Hl7jB/psKc6teu ECIQ== X-Gm-Message-State: AMCzsaXQ8WeefPWpcNxzj6tXTAdt7DXn3LBZRdG4JBod/P3kodNFeBiC QbOuHbPpdN1g1K88AvAuenYAQg== X-Google-Smtp-Source: AOwi7QBRpgEKCo+mF1C09hi6w74PT5yDNbAOh2aZzIJ0SQbaErRi8nHwPDXmCzqQvaM4xQrVLR7o/A== X-Received: by 10.28.208.129 with SMTP id h123mr2015317wmg.25.1507810817556; Thu, 12 Oct 2017 05:20:17 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id d195sm142404wmd.0.2017.10.12.05.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 05:20:16 -0700 (PDT) From: Adrien Mazarguil To: Ferruh Yigit Cc: Nelio Laranjeiro , dev@dpdk.org Date: Thu, 12 Oct 2017 14:19:22 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 08/29] net/mlx4: compact flow rule error reporting 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: Thu, 12 Oct 2017 12:20:17 -0000 Relying on rte_errno is not necessary where the return value of rte_flow_error_set() can be used directly. A related minor change is switching from RTE_FLOW_ERROR_TYPE_HANDLE to RTE_FLOW_ERROR_TYPE_UNSPECIFIED when no rte_flow handle is involved in the error, specifically when none is allocated yet. This commit does not cause any functional change. Signed-off-by: Adrien Mazarguil Acked-by: Nelio Laranjeiro --- drivers/net/mlx4/mlx4_flow.c | 102 ++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 60 deletions(-) diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index fa56419..000f17f 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -579,45 +579,30 @@ mlx4_flow_prepare(struct priv *priv, }; uint32_t priority_override = 0; - if (attr->group) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_GROUP, - NULL, - "groups are not supported"); - return -rte_errno; - } - if (priv->isolated) { + if (attr->group) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, + NULL, "groups are not supported"); + if (priv->isolated) priority_override = attr->priority; - } else if (attr->priority) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, - NULL, - "priorities are not supported outside" - " isolated mode"); - return -rte_errno; - } - if (attr->priority > MLX4_FLOW_PRIORITY_LAST) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, - NULL, - "maximum priority level is " - MLX4_STR_EXPAND(MLX4_FLOW_PRIORITY_LAST)); - return -rte_errno; - } - if (attr->egress) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, - NULL, - "egress is not supported"); - return -rte_errno; - } - if (!attr->ingress) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, - NULL, - "only ingress is supported"); - return -rte_errno; - } + else if (attr->priority) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, + NULL, + "priorities are not supported outside isolated mode"); + if (attr->priority > MLX4_FLOW_PRIORITY_LAST) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, + NULL, "maximum priority level is " + MLX4_STR_EXPAND(MLX4_FLOW_PRIORITY_LAST)); + if (attr->egress) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, + NULL, "egress is not supported"); + if (!attr->ingress) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, + NULL, "only ingress is supported"); /* Go over pattern. */ for (item = pattern; item->type; ++item) { const struct mlx4_flow_proc_item *next = NULL; @@ -633,14 +618,11 @@ mlx4_flow_prepare(struct priv *priv, if (!item->spec && item->type == RTE_FLOW_ITEM_TYPE_ETH) { const struct rte_flow_item *next = item + 1; - if (next->type) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "the rule requires" - " an Ethernet spec"); - return -rte_errno; - } + if (next->type) + return rte_flow_error_set + (error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "the rule requires an Ethernet spec"); } for (i = 0; proc->next_item && proc->next_item[i]; ++i) { if (proc->next_item[i] == item->type) { @@ -688,20 +670,17 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!target.queue && !target.drop) { - rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "no valid action"); - return -rte_errno; - } + if (!target.queue && !target.drop) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "no valid action"); return 0; exit_item_not_supported: - rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, - item, "item not supported"); - return -rte_errno; + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, + item, "item not supported"); exit_action_not_supported: - rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, - action, "action not supported"); - return -rte_errno; + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + action, "action not supported"); } /** @@ -824,7 +803,8 @@ mlx4_flow_create_target_queue(struct priv *priv, assert(priv->ctx); rte_flow = rte_calloc(__func__, 1, sizeof(*rte_flow), 0); if (!rte_flow) { - rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate flow memory"); return NULL; } @@ -841,7 +821,8 @@ mlx4_flow_create_target_queue(struct priv *priv, return rte_flow; rte_flow->ibv_flow = ibv_create_flow(qp, rte_flow->ibv_attr); if (!rte_flow->ibv_flow) { - rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "flow rule creation failure"); goto error; } @@ -876,7 +857,8 @@ mlx4_flow_create(struct rte_eth_dev *dev, return NULL; flow.ibv_attr = rte_malloc(__func__, flow.offset, 0); if (!flow.ibv_attr) { - rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate ibv_attr memory"); return NULL; } -- 2.1.4