Patchwork [dpdk-dev,09/38] net/sfc: use NIC min number of Tx descs instead of define

login
register
mail settings
Submitter Andrew Rybchenko
Date Feb. 7, 2019, 4:29 p.m.
Message ID <1549556983-10896-10-git-send-email-arybchenko@solarflare.com>
Download mbox | patch
Permalink /patch/720837/
State New
Headers show

Comments

Andrew Rybchenko - Feb. 7, 2019, 4:29 p.m.
From: Igor Romanov <igor.romanov@oktetlabs.ru>

Min limit is not common for all NIC families. Use the variable from
NIC configuration instead of deprecated define.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc.c         |  3 +++
 drivers/net/sfc/sfc.h         |  1 +
 drivers/net/sfc/sfc_dp_tx.h   |  7 +++++++
 drivers/net/sfc/sfc_ef10_tx.c |  5 +++--
 drivers/net/sfc/sfc_ethdev.c  |  4 ++--
 drivers/net/sfc/sfc_tx.c      | 13 ++++++++++---
 6 files changed, 26 insertions(+), 7 deletions(-)

Patch

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 83001cb68..2e29bfaf4 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -759,6 +759,9 @@  sfc_attach(struct sfc_adapter *sa)
 	sa->txq_max_entries = encp->enc_txq_max_ndescs;
 	SFC_ASSERT(rte_is_power_of_2(sa->txq_max_entries));
 
+	sa->txq_min_entries = encp->enc_txq_min_ndescs;
+	SFC_ASSERT(rte_is_power_of_2(sa->txq_min_entries));
+
 	rc = sfc_intr_attach(sa);
 	if (rc != 0)
 		goto fail_intr_attach;
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 725dd5ee6..3acb3fe48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -245,6 +245,7 @@  struct sfc_adapter {
 	unsigned int			txq_max;
 
 	unsigned int			txq_max_entries;
+	unsigned int			txq_min_entries;
 
 	uint32_t			evq_flags;
 	unsigned int			evq_count;
diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index fd492f21f..9cb2198e2 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -27,6 +27,12 @@  struct sfc_dp_txq {
 	struct sfc_dp_queue	dpq;
 };
 
+/** Datapath transmit queue descriptor number limitations */
+struct sfc_dp_tx_hw_limits {
+	unsigned int txq_max_entries;
+	unsigned int txq_min_entries;
+};
+
 /**
  * Datapath transmit queue creation information.
  *
@@ -83,6 +89,7 @@  typedef void (sfc_dp_tx_get_dev_info_t)(struct rte_eth_dev_info *dev_info);
  * @return 0 or positive errno.
  */
 typedef int (sfc_dp_tx_qsize_up_rings_t)(uint16_t nb_tx_desc,
+					 struct sfc_dp_tx_hw_limits *limits,
 					 unsigned int *txq_entries,
 					 unsigned int *evq_entries,
 					 unsigned int *txq_max_fill_level);
diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c
index ff6d5b486..0711c1136 100644
--- a/drivers/net/sfc/sfc_ef10_tx.c
+++ b/drivers/net/sfc/sfc_ef10_tx.c
@@ -782,6 +782,7 @@  sfc_ef10_get_dev_info(struct rte_eth_dev_info *dev_info)
 static sfc_dp_tx_qsize_up_rings_t sfc_ef10_tx_qsize_up_rings;
 static int
 sfc_ef10_tx_qsize_up_rings(uint16_t nb_tx_desc,
+			   struct sfc_dp_tx_hw_limits *limits,
 			   unsigned int *txq_entries,
 			   unsigned int *evq_entries,
 			   unsigned int *txq_max_fill_level)
@@ -790,8 +791,8 @@  sfc_ef10_tx_qsize_up_rings(uint16_t nb_tx_desc,
 	 * rte_ethdev API guarantees that the number meets min, max and
 	 * alignment requirements.
 	 */
-	if (nb_tx_desc <= EFX_TXQ_MINNDESCS)
-		*txq_entries = EFX_TXQ_MINNDESCS;
+	if (nb_tx_desc <= limits->txq_min_entries)
+		*txq_entries = limits->txq_min_entries;
 	else
 		*txq_entries = rte_align32pow2(nb_tx_desc);
 
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 286550863..57b8b7e49 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -162,12 +162,12 @@  sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	/* Initialize to hardware limits */
 	dev_info->tx_desc_lim.nb_max = sa->txq_max_entries;
-	dev_info->tx_desc_lim.nb_min = EFX_TXQ_MINNDESCS;
+	dev_info->tx_desc_lim.nb_min = sa->txq_min_entries;
 	/*
 	 * The TXQ hardware requires that the descriptor count is a power
 	 * of 2, but tx_desc_lim cannot properly describe that constraint
 	 */
-	dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS;
+	dev_info->tx_desc_lim.nb_align = sa->txq_min_entries;
 
 	if (sap->dp_rx->get_dev_info != NULL)
 		sap->dp_rx->get_dev_info(dev_info);
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index acdbf1602..aa0538fe8 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -131,14 +131,20 @@  sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	int rc = 0;
 	struct sfc_dp_tx_qcreate_info info;
 	uint64_t offloads;
+	struct sfc_dp_tx_hw_limits hw_limits;
 
 	sfc_log_init(sa, "TxQ = %u", sw_index);
 
-	rc = sa->priv.dp_tx->qsize_up_rings(nb_tx_desc, &txq_entries,
-					    &evq_entries, &txq_max_fill_level);
+	memset(&hw_limits, 0, sizeof(hw_limits));
+	hw_limits.txq_max_entries = sa->txq_max_entries;
+	hw_limits.txq_min_entries = sa->txq_min_entries;
+
+	rc = sa->priv.dp_tx->qsize_up_rings(nb_tx_desc, &hw_limits,
+					    &txq_entries, &evq_entries,
+					    &txq_max_fill_level);
 	if (rc != 0)
 		goto fail_size_up_rings;
-	SFC_ASSERT(txq_entries >= EFX_TXQ_MINNDESCS);
+	SFC_ASSERT(txq_entries >= sa->txq_min_entries);
 	SFC_ASSERT(txq_entries <= sa->txq_max_entries);
 	SFC_ASSERT(txq_entries >= nb_tx_desc);
 	SFC_ASSERT(txq_max_fill_level <= nb_tx_desc);
@@ -920,6 +926,7 @@  sfc_txq_by_dp_txq(const struct sfc_dp_txq *dp_txq)
 static sfc_dp_tx_qsize_up_rings_t sfc_efx_tx_qsize_up_rings;
 static int
 sfc_efx_tx_qsize_up_rings(uint16_t nb_tx_desc,
+			  __rte_unused struct sfc_dp_tx_hw_limits *limits,
 			  unsigned int *txq_entries,
 			  unsigned int *evq_entries,
 			  unsigned int *txq_max_fill_level)