Wire the mlx5 PMD to the new rte_eth_get_queue_rate_limit()
ethdev callback. The implementation reads the per-queue
rate_mbps tracking field from the txq_ctrl structure.

Signed-off-by: Vincent Jardin <[email protected]>
---
 drivers/net/mlx5/mlx5.c     |  2 ++
 drivers/net/mlx5/mlx5_tx.h  |  2 ++
 drivers/net/mlx5/mlx5_txq.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 7d08d7886b..f5784761f9 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2652,6 +2652,7 @@ const struct eth_dev_ops mlx5_dev_ops = {
        .rx_metadata_negotiate = mlx5_flow_rx_metadata_negotiate,
        .get_restore_flags = mlx5_get_restore_flags,
        .set_queue_rate_limit = mlx5_set_queue_rate_limit,
+       .get_queue_rate_limit = mlx5_get_queue_rate_limit,
 };
 
 /* Available operations from secondary process. */
@@ -2746,6 +2747,7 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = {
        .map_aggr_tx_affinity = mlx5_map_aggr_tx_affinity,
        .get_restore_flags = mlx5_get_restore_flags,
        .set_queue_rate_limit = mlx5_set_queue_rate_limit,
+       .get_queue_rate_limit = mlx5_get_queue_rate_limit,
 };
 
 /**
diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h
index 975ff57acd..02feb9e6fd 100644
--- a/drivers/net/mlx5/mlx5_tx.h
+++ b/drivers/net/mlx5/mlx5_tx.h
@@ -224,6 +224,8 @@ int mlx5_txq_releasable(struct rte_eth_dev *dev, uint16_t 
idx);
 int mlx5_txq_verify(struct rte_eth_dev *dev);
 int mlx5_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
                              uint32_t tx_rate);
+int mlx5_get_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
+                             uint32_t *tx_rate);
 int mlx5_txq_get_sqn(struct mlx5_txq_ctrl *txq);
 void mlx5_txq_alloc_elts(struct mlx5_txq_ctrl *txq_ctrl);
 void mlx5_txq_free_elts(struct mlx5_txq_ctrl *txq_ctrl);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index ce08363ca9..867ea4b994 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1481,6 +1481,36 @@ mlx5_set_queue_rate_limit(struct rte_eth_dev *dev, 
uint16_t queue_idx,
        return 0;
 }
 
+/**
+ * Get per-queue packet pacing rate limit.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queue_idx
+ *   TX queue index.
+ * @param[out] tx_rate
+ *   Pointer to store the TX rate in Mbps, 0 if rate limiting is disabled.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
+                         uint32_t *tx_rate)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+       struct mlx5_txq_ctrl *txq_ctrl;
+
+       if (priv->txqs == NULL || (*priv->txqs)[queue_idx] == NULL) {
+               rte_errno = EINVAL;
+               return -rte_errno;
+       }
+       txq_ctrl = container_of((*priv->txqs)[queue_idx],
+                               struct mlx5_txq_ctrl, txq);
+       *tx_rate = txq_ctrl->rate_limit.rate_mbps;
+       return 0;
+}
+
 /**
  * Verify if the queue can be released.
  *
-- 
2.43.0

Reply via email to