DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shahaf Shuler <shahafs@mellanox.com>
To: nelio.laranjeiro@6wind.com, adrien.mazarguil@6wind.com,
	yskoh@mellanox.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 1/7] net/mlx5: change pkt burst select function prototype
Date: Wed, 10 Jan 2018 11:16:57 +0200	[thread overview]
Message-ID: <556561708a2d3d0631b899d117e00979891cb6c2.1515575671.git.shahafs@mellanox.com> (raw)
In-Reply-To: <cover.1515575671.git.shahafs@mellanox.com>

Change the function prototype to return the function pointer of the
selected Tx/Rx burst function instead of assigning it directly to the
device context.

Such change will enable to use those select functions to query the burst
function that will be selected according to the device configuration.

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5.c         | 11 ++++++++--
 drivers/net/mlx5/mlx5.h         |  4 ++--
 drivers/net/mlx5/mlx5_ethdev.c  | 41 +++++++++++++++++++++---------------
 drivers/net/mlx5/mlx5_trigger.c |  4 ++--
 4 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cd66fe162..0192815f2 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -712,8 +712,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 				err = -err;
 				goto error;
 			}
-			priv_dev_select_rx_function(priv, eth_dev);
-			priv_dev_select_tx_function(priv, eth_dev);
+			/*
+			 * Ethdev pointer is still required as input since
+			 * the primary device is not accessible from the
+			 * secondary process.
+			 */
+			eth_dev->rx_pkt_burst =
+				priv_select_rx_function(priv, eth_dev);
+			eth_dev->tx_pkt_burst =
+				priv_select_tx_function(priv, eth_dev);
 			continue;
 		}
 
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e6a69b823..3e3259b55 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -206,8 +206,8 @@ void priv_dev_interrupt_handler_uninstall(struct priv *, struct rte_eth_dev *);
 void priv_dev_interrupt_handler_install(struct priv *, struct rte_eth_dev *);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
-void priv_dev_select_tx_function(struct priv *priv, struct rte_eth_dev *dev);
-void priv_dev_select_rx_function(struct priv *priv, struct rte_eth_dev *dev);
+eth_tx_burst_t priv_select_tx_function(struct priv *, struct rte_eth_dev *);
+eth_rx_burst_t priv_select_rx_function(struct priv *, struct rte_eth_dev *);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 282ef241e..28183534a 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1325,8 +1325,8 @@ priv_dev_set_link(struct priv *priv, struct rte_eth_dev *dev, int up)
 		err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
 		if (err)
 			return err;
-		priv_dev_select_tx_function(priv, dev);
-		priv_dev_select_rx_function(priv, dev);
+		dev->tx_pkt_burst = priv_select_tx_function(priv, dev);
+		dev->rx_pkt_burst = priv_select_rx_function(priv, dev);
 	} else {
 		err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP);
 		if (err)
@@ -1386,32 +1386,36 @@ mlx5_set_link_up(struct rte_eth_dev *dev)
  *   Pointer to private data structure.
  * @param dev
  *   Pointer to rte_eth_dev structure.
+ *
+ * @return
+ *   Pointer to selected Tx burst function.
  */
-void
-priv_dev_select_tx_function(struct priv *priv, struct rte_eth_dev *dev)
+eth_tx_burst_t
+priv_select_tx_function(struct priv *priv, __rte_unused struct rte_eth_dev *dev)
 {
+	eth_tx_burst_t tx_pkt_burst = mlx5_tx_burst;
+
 	assert(priv != NULL);
-	assert(dev != NULL);
-	dev->tx_pkt_burst = mlx5_tx_burst;
 	/* Select appropriate TX function. */
 	if (priv->mps == MLX5_MPW_ENHANCED) {
 		if (priv_check_vec_tx_support(priv) > 0) {
 			if (priv_check_raw_vec_tx_support(priv) > 0)
-				dev->tx_pkt_burst = mlx5_tx_burst_raw_vec;
+				tx_pkt_burst = mlx5_tx_burst_raw_vec;
 			else
-				dev->tx_pkt_burst = mlx5_tx_burst_vec;
+				tx_pkt_burst = mlx5_tx_burst_vec;
 			DEBUG("selected Enhanced MPW TX vectorized function");
 		} else {
-			dev->tx_pkt_burst = mlx5_tx_burst_empw;
+			tx_pkt_burst = mlx5_tx_burst_empw;
 			DEBUG("selected Enhanced MPW TX function");
 		}
 	} else if (priv->mps && priv->txq_inline) {
-		dev->tx_pkt_burst = mlx5_tx_burst_mpw_inline;
+		tx_pkt_burst = mlx5_tx_burst_mpw_inline;
 		DEBUG("selected MPW inline TX function");
 	} else if (priv->mps) {
-		dev->tx_pkt_burst = mlx5_tx_burst_mpw;
+		tx_pkt_burst = mlx5_tx_burst_mpw;
 		DEBUG("selected MPW TX function");
 	}
+	return tx_pkt_burst;
 }
 
 /**
@@ -1421,16 +1425,19 @@ priv_dev_select_tx_function(struct priv *priv, struct rte_eth_dev *dev)
  *   Pointer to private data structure.
  * @param dev
  *   Pointer to rte_eth_dev structure.
+ *
+ * @return
+ *   Pointer to selected Rx burst function.
  */
-void
-priv_dev_select_rx_function(struct priv *priv, struct rte_eth_dev *dev)
+eth_rx_burst_t
+priv_select_rx_function(struct priv *priv, __rte_unused struct rte_eth_dev *dev)
 {
+	eth_rx_burst_t rx_pkt_burst = mlx5_rx_burst;
+
 	assert(priv != NULL);
-	assert(dev != NULL);
 	if (priv_check_vec_rx_support(priv) > 0) {
-		dev->rx_pkt_burst = mlx5_rx_burst_vec;
+		rx_pkt_burst = mlx5_rx_burst_vec;
 		DEBUG("selected RX vectorized function");
-	} else {
-		dev->rx_pkt_burst = mlx5_rx_burst;
 	}
+	return rx_pkt_burst;
 }
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 88f60a01d..1a20967a2 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -152,7 +152,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 	/* Update send callback. */
-	priv_dev_select_tx_function(priv, dev);
+	dev->tx_pkt_burst = priv_select_tx_function(priv, dev);
 	err = priv_rxq_start(priv);
 	if (err) {
 		ERROR("%p: RXQ allocation failed: %s",
@@ -160,7 +160,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 	/* Update receive callback. */
-	priv_dev_select_rx_function(priv, dev);
+	dev->rx_pkt_burst = priv_select_rx_function(priv, dev);
 	err = priv_dev_traffic_enable(priv, dev);
 	if (err) {
 		ERROR("%p: an error occurred while configuring control flows:"
-- 
2.12.0

  reply	other threads:[~2018-01-10  9:17 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 12:02 [dpdk-dev] [PATCH 0/6] convert mlx PMDs to new ethdev offloads API Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 1/6] net/mlx5: store PMD args in private structure Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 2/6] net/mlx5: convert to new Tx offloads API Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 3/6] net/mlx5: convert to new Rx " Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 4/6] net/mlx5: fix VLAN configuration after port stop Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 5/6] net/mlx4: convert to new Tx offloads API Shahaf Shuler
2017-11-23 12:02 ` [dpdk-dev] [PATCH 6/6] net/mlx4: convert to new Rx " Shahaf Shuler
2018-01-03  7:16 ` [dpdk-dev] [PATCH v2 0/7] convert mlx PMDs to new ethdev " Shahaf Shuler
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 1/7] net/mlx5: change pkt burst select function prototype Shahaf Shuler
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 2/7] net/mlx5: add device configuration structure Shahaf Shuler
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 3/7] net/mlx5: rename counter set in configuration Shahaf Shuler
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 4/7] net/mlx5: convert to new Tx offloads API Shahaf Shuler
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 5/7] net/mlx5: convert to new Rx " Shahaf Shuler
2018-01-04 10:12     ` Nelio Laranjeiro
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 6/7] net/mlx4: convert to new Tx " Shahaf Shuler
2018-01-03 17:29     ` Adrien Mazarguil
2018-01-04 11:55       ` Shahaf Shuler
2018-01-09 10:35         ` Nelio Laranjeiro
2018-01-03  7:16   ` [dpdk-dev] [PATCH v2 7/7] net/mlx4: convert to new Rx " Shahaf Shuler
2018-01-03 17:29     ` Adrien Mazarguil
2018-01-10  9:16   ` [dpdk-dev] [PATCH v3 0/7] convert mlx PMDs to new ethdev " Shahaf Shuler
2018-01-10  9:16     ` Shahaf Shuler [this message]
2018-01-10  9:16     ` [dpdk-dev] [PATCH v3 2/7] net/mlx5: add device configuration structure Shahaf Shuler
2018-01-10  9:16     ` [dpdk-dev] [PATCH v3 3/7] net/mlx5: rename counter set in configuration Shahaf Shuler
2018-01-10  9:17     ` [dpdk-dev] [PATCH v3 4/7] net/mlx5: convert to new Tx offloads API Shahaf Shuler
2018-01-10  9:17     ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: convert to new Rx " Shahaf Shuler
2018-01-10  9:17     ` [dpdk-dev] [PATCH v3 6/7] net/mlx4: convert to new Tx " Shahaf Shuler
2018-01-10  9:17     ` [dpdk-dev] [PATCH v3 7/7] net/mlx4: convert to new Rx " Shahaf Shuler
2018-01-10 15:24     ` [dpdk-dev] [PATCH v3 0/7] convert mlx PMDs to new ethdev " Shahaf Shuler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556561708a2d3d0631b899d117e00979891cb6c2.1515575671.git.shahafs@mellanox.com \
    --to=shahafs@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=yskoh@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).