From 9dbd28df2d0bb0b4280d0c84771895c867454c25 Mon Sep 17 00:00:00 2001 From: Igor Romanov Date: Thu, 7 Feb 2019 16:29:14 +0000 Subject: [PATCH] net/sfc: use NIC min number of Tx descs instead of define Min limit is not common for all NIC families. Use the variable from NIC configuration instead of deprecated define. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- 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(-) diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 83001cb68f..2e29bfaf45 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 725dd5ee62..3acb3fe480 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 fd492f21f2..9cb2198e21 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 ff6d5b486d..0711c1136d 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 286550863f..57b8b7e496 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 acdbf1602b..aa0538fe88 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) -- 2.20.1