[dpdk-dev] [PATCH v2 31/51] net/mlx4: remove unnecessary wrapper functions

Adrien Mazarguil adrien.mazarguil at 6wind.com
Fri Sep 1 10:06:46 CEST 2017


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 <adrien.mazarguil at 6wind.com>
---
 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;
 }
 
-- 
2.1.4



More information about the dev mailing list