From patchwork Fri Sep 1 08:06:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 28220 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 0B90E996D; Fri, 1 Sep 2017 10:08:06 +0200 (CEST) Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 6485E7D9A for ; Fri, 1 Sep 2017 10:08:02 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id z91so4527766wrc.1 for ; Fri, 01 Sep 2017 01:08:02 -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=OmMJMBNXKkZIKMt4KSt5pWnozaH5rIsMfjGUPIAhxc8=; b=TLsw9YGeVYVqI9Sq3IX4F9E7ne+ZmM5hGkyzBYxgWdk5Et8FnAZiRmm2Xhiqh5Ho1h GT4prC1xARRlqEJUTpsW9NzncFHq0fV4IggVhbDSjRcshne/Mij0WyOLRZFHDy82eNLW +OXFkvmNUUZ7i0ZLf7gDXxZgeuvSsJjJyjrJWBR9U07/nJ7pMV0201SAOHmE6hTxnLUx auspwqHtXnjhendgRz0A3FRAknmPdJGAjnPyyC6wKAvj0Lt/w2KyqzJnE2Oe/BxUIIVh GcciWmG05PStMrI+Nx2u0/pbyV7VUU2+3AH+nYY2oGPQH7GKlSc1CGjFbi2nePp6d7K2 +JmA== 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=OmMJMBNXKkZIKMt4KSt5pWnozaH5rIsMfjGUPIAhxc8=; b=RrA7hmOsgk9w/d+FmbzoubUA/1+fPVh+NPjjbdhh0gyxlpMkKA9vwBgXLR6O25VqEc kY23gXvcsi0KAPHBm2SNx4vtBZz39DdzWPN33+EROPfMZyNv9Ox8isJKSR8vGGhAsk9r iXsX4GE3Nc8z5TSSlm9D3ZGvjex3F3HyYO7ierVMxY4IFX03eMCTBoOGgQuTg5hqd3sT 6gPm2qBo5vbT12zJ9e4n4ZDgv6BiWw6fpc9irTyDFobxfihlL+4nbSUWLMPZZpzB/xmQ ofW7ODeGgJnSxJ604hGTOQ+pf03+osd9v/wh/Vo2FbbWSxkuT5AKnJlBqzFHz9mW5CYZ XttA== X-Gm-Message-State: AHPjjUipc14bFHpqyxkQV+6IsEKAyYuWEqVZJvAE4AWggkDSUXSTk+3v /Ihi/BytgvG8TV6QCRY= X-Google-Smtp-Source: ADKCNb7kYP1VXCCcjr64+YTwxSRl2Umy6Yaicm7NyErlrD4MFjwNk10F3bWQZXR0a7T6BeTfR6RcTg== X-Received: by 10.223.178.230 with SMTP id g93mr611413wrd.20.1504253281596; Fri, 01 Sep 2017 01:08:01 -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 l143sm2806679wmb.8.2017.09.01.01.08.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Sep 2017 01:08:00 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 1 Sep 2017 10:06:46 +0200 Message-Id: <675a3b20d608322af3caf11fb551c2c456151c6e.1504252977.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 31/51] 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 dc8a96f..e1efb8c 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -417,10 +417,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. * @@ -428,8 +428,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); @@ -438,8 +439,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; } @@ -491,7 +494,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. * @@ -502,7 +505,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; @@ -523,21 +526,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); @@ -2457,37 +2445,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; }