From patchwork Tue Aug 1 16:54:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 27346 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id DBB74A226; Tue, 1 Aug 2017 18:56:02 +0200 (CEST) Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 9E2F5A14E for ; Tue, 1 Aug 2017 18:55:34 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id 33so9242211wrz.4 for ; Tue, 01 Aug 2017 09:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=K22HwpTLustuOZqWpzVekHT+OAvwq4yrSzwErnGiK0s=; b=ILSnke2J6z0NNqQR/C/AFBElZccydOkofMnIUB4K6wSgs13FIZRJiqOgDyYqbm0ZLo LJg54GHizsFWyH+GaLegZvq7wXxUm37JZ2VcDcYCyIlKLm3WC2sYe+VML5WUN+noFnw0 O2KLhqwFSBPswLdnwy/EeyTPrpJVFLSOJrJmPD0G4swUdy4T90hMiT92y1BSMMEewzPw up+I5R5GtFsCmaT7wHc0WhmeAwPID9W8n0V9qM5BEqY4Ux9EETxJSsyUoRgO+I8H3orv qrlYY769H9zt3i7SPJAo9+XhMxcf6QcSzgaOylr8WfJuUBhKWmhDRWqSvgokD0quYZc1 Ba2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=K22HwpTLustuOZqWpzVekHT+OAvwq4yrSzwErnGiK0s=; b=k8IC9yCC/i+dd+8Ko2VgRV6ciGl/3N7HMDs8Iyy9Sbep582FdooYhCQ9jMif7g1qBG ejUPYVx4xrmx4H6R32UHd0B1jajyC9AuM+kDNcy7sZWNU2koqvofxCKKnZTocrBj7yv3 ZZIN7fvz8k5roLnWCDgP/JLRpirp7TT4Wii0lkE2NBukSpbS51Xg3CQ12+AOeP88J4bF MG6wPCsMfZt7YY47bHWtzRRu+CCEcktaeWH10XvMGkGYC6BzxDc8VBBRqT0OPIWBHfbR Qe5iXWbVzU2D+bSQEWBowIYNf9IZhVOGopjsP2WPNUYm+QiAf+o0Bto6XW+z+SjUcp7B jkYQ== X-Gm-Message-State: AIVw113j16MKntE3E0gXuVjbDluJjx1C54THzWpUm9tuja3g0xrmid88 LDj82GvBnXnxtnUeVqI= X-Received: by 10.223.188.82 with SMTP id a18mr14480162wrh.1.1501606534089; Tue, 01 Aug 2017 09:55:34 -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 e76sm1807908wmd.36.2017.08.01.09.55.33 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Aug 2017 09:55:33 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 1 Aug 2017 18:54:17 +0200 Message-Id: <328f0b7998b833dfe16eea7d19557d59371eb29d.1501598384.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 30/48] net/mlx4: remove unnecessary wrapper functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Wrapper functions whose main purpose was to take a lock on the private structure are no longer needed since this lock does not exist anymore. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 61 ++++------------------ drivers/net/mlx4/mlx4_flow.c | 106 +++++++++----------------------------- 2 files changed, 32 insertions(+), 135 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 71ee016..d831729 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -428,10 +428,10 @@ priv_get_mtu(struct priv *priv, uint16_t *mtu) } /** - * Set device MTU. + * DPDK callback to change the MTU. * * @param priv - * Pointer to private structure. + * Pointer to Ethernet device structure. * @param mtu * MTU value to set. * @@ -439,8 +439,9 @@ priv_get_mtu(struct priv *priv, uint16_t *mtu) * 0 on success, negative errno value otherwise and rte_errno is set. */ static int -priv_set_mtu(struct priv *priv, uint16_t mtu) +mlx4_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) { + struct priv *priv = dev->data->dev_private; uint16_t new_mtu; int ret = priv_set_sysfs_ulong(priv, "mtu", mtu); @@ -449,8 +450,10 @@ priv_set_mtu(struct priv *priv, uint16_t mtu) ret = priv_get_mtu(priv, &new_mtu); if (ret) return ret; - if (new_mtu == mtu) + if (new_mtu == mtu) { + priv->mtu = mtu; return 0; + } rte_errno = EINVAL; return -rte_errno; } @@ -502,7 +505,7 @@ static void priv_mac_addr_del(struct priv *priv); /** - * Ethernet device configuration. + * DPDK callback for Ethernet device configuration. * * Prepare the driver for a given number of TX and RX queues. * @@ -513,7 +516,7 @@ priv_mac_addr_del(struct priv *priv); * 0 on success, negative errno value otherwise and rte_errno is set. */ static int -dev_configure(struct rte_eth_dev *dev) +mlx4_dev_configure(struct rte_eth_dev *dev) { struct priv *priv = dev->data->dev_private; unsigned int rxqs_n = dev->data->nb_rx_queues; @@ -534,21 +537,6 @@ dev_configure(struct rte_eth_dev *dev) return 0; } -/** - * DPDK callback for Ethernet device configuration. - * - * @param dev - * Pointer to Ethernet device structure. - * - * @return - * 0 on success, negative errno value otherwise and rte_errno is set. - */ -static int -mlx4_dev_configure(struct rte_eth_dev *dev) -{ - return dev_configure(dev); -} - static uint16_t mlx4_tx_burst(void *, struct rte_mbuf **, uint16_t); static uint16_t removed_rx_burst(void *, struct rte_mbuf **, uint16_t); @@ -2528,37 +2516,6 @@ mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) } /** - * DPDK callback to change the MTU. - * - * @param dev - * Pointer to Ethernet device structure. - * @param in_mtu - * New MTU. - * - * @return - * 0 on success, negative errno value otherwise and rte_errno is set. - */ -static int -mlx4_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) -{ - struct priv *priv = dev->data->dev_private; - int ret = 0; - - /* Set kernel interface MTU first. */ - if (priv_set_mtu(priv, mtu)) { - ret = rte_errno; - WARN("cannot set port %u MTU to %u: %s", priv->port, mtu, - strerror(rte_errno)); - goto out; - } else - DEBUG("adapter port %u MTU set to %u", priv->port, mtu); - priv->mtu = mtu; -out: - assert(ret >= 0); - return -ret; -} - -/** * DPDK callback to get flow control status. * * @param dev diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 07305f1..3463713 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -837,29 +837,19 @@ priv_flow_create_action_queue(struct priv *priv, } /** - * Convert a flow. - * - * @param priv - * Pointer to private structure. - * @param[in] attr - * Flow rule attributes. - * @param[in] items - * Pattern specification (list terminated by the END pattern item). - * @param[in] actions - * Associated actions (list terminated by the END action). - * @param[out] error - * Perform verbose error reporting if not NULL. + * Create a flow. * - * @return - * A flow on success, NULL otherwise. + * @see rte_flow_create() + * @see rte_flow_ops */ -static struct rte_flow * -priv_flow_create(struct priv *priv, +struct rte_flow * +mlx4_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error) { + struct priv *priv = dev->data->dev_private; struct rte_flow *rte_flow; struct mlx4_flow_action action; struct mlx4_flow flow = { .offset = sizeof(struct ibv_flow_attr), }; @@ -909,38 +899,17 @@ priv_flow_create(struct priv *priv, } rte_flow = priv_flow_create_action_queue(priv, flow.ibv_attr, &action, error); - if (rte_flow) + if (rte_flow) { + LIST_INSERT_HEAD(&priv->flows, rte_flow, next); + DEBUG("Flow created %p", (void *)rte_flow); return rte_flow; + } exit: rte_free(flow.ibv_attr); return NULL; } /** - * Create a flow. - * - * @see rte_flow_create() - * @see rte_flow_ops - */ -struct rte_flow * -mlx4_flow_create(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_item items[], - const struct rte_flow_action actions[], - struct rte_flow_error *error) -{ - struct priv *priv = dev->data->dev_private; - struct rte_flow *flow; - - flow = priv_flow_create(priv, attr, items, actions, error); - if (flow) { - LIST_INSERT_HEAD(&priv->flows, flow, next); - DEBUG("Flow created %p", (void *)flow); - } - return flow; -} - -/** * @see rte_flow_isolate() * * Must be done before calling dev_configure(). @@ -977,26 +946,6 @@ mlx4_flow_isolate(struct rte_eth_dev *dev, /** * Destroy a flow. * - * @param priv - * Pointer to private structure. - * @param[in] flow - * Flow to destroy. - */ -static void -priv_flow_destroy(struct priv *priv, struct rte_flow *flow) -{ - (void)priv; - LIST_REMOVE(flow, next); - if (flow->ibv_flow) - claim_zero(ibv_destroy_flow(flow->ibv_flow)); - rte_free(flow->ibv_attr); - DEBUG("Flow destroyed %p", (void *)flow); - rte_free(flow); -} - -/** - * Destroy a flow. - * * @see rte_flow_destroy() * @see rte_flow_ops */ @@ -1005,33 +954,20 @@ mlx4_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) { - struct priv *priv = dev->data->dev_private; - + (void)dev; (void)error; - priv_flow_destroy(priv, flow); + LIST_REMOVE(flow, next); + if (flow->ibv_flow) + claim_zero(ibv_destroy_flow(flow->ibv_flow)); + rte_free(flow->ibv_attr); + DEBUG("Flow destroyed %p", (void *)flow); + rte_free(flow); return 0; } /** * Destroy all flows. * - * @param priv - * Pointer to private structure. - */ -static void -priv_flow_flush(struct priv *priv) -{ - while (!LIST_EMPTY(&priv->flows)) { - struct rte_flow *flow; - - flow = LIST_FIRST(&priv->flows); - priv_flow_destroy(priv, flow); - } -} - -/** - * Destroy all flows. - * * @see rte_flow_flush() * @see rte_flow_ops */ @@ -1041,8 +977,12 @@ mlx4_flow_flush(struct rte_eth_dev *dev, { struct priv *priv = dev->data->dev_private; - (void)error; - priv_flow_flush(priv); + while (!LIST_EMPTY(&priv->flows)) { + struct rte_flow *flow; + + flow = LIST_FIRST(&priv->flows); + mlx4_flow_destroy(dev, flow, error); + } return 0; }