DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <dsosnowski@nvidia.com>,
	<rasland@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Subject: [PATCH v3 10/11] net/mlx5: use non const max number for ASO actions
Date: Mon, 3 Jun 2024 13:48:49 +0300	[thread overview]
Message-ID: <20240603104850.9935-10-mkashani@nvidia.com> (raw)
In-Reply-To: <20240603104850.9935-1-mkashani@nvidia.com>

For ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
---
 drivers/net/mlx5/mlx5.h            | 17 ++++++++++++-----
 drivers/net/mlx5/mlx5_flow_hw.c    | 13 +++++++++----
 drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++----
 3 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 67986a00b4..e635907c52 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -792,12 +792,18 @@ struct mlx5_dev_shared_port {
 /* Only yellow color valid. */
 #define MLX5_MTR_POLICY_MODE_OY 3
 
+/* Max number of meters. */
+#define MLX5_MTR_MAX(priv) (mlx5_flow_mtr_max_get(priv))
 /* Max number of meters allocated in non template mode. */
-#define MLX5_MTR_NT_MAX (1 << 23)
-/* Max number of connection tracking allocated in non template mode */
-#define MLX5_CT_NT_MAX (1 << 23)
-/* Max number of counters allocated in non template mode */
-#define MLX5_CNT_MAX (1 << 23)
+#define MLX5_MTR_NT_MAX(priv) (MLX5_MTR_MAX(priv) >> 1)
+/* Max number of connection tracking. */
+#define MLX5_CT_MAX(priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload)
+/* Max number of connection tracking allocated in non template mode. */
+#define MLX5_CT_NT_MAX(priv) (MLX5_CT_MAX(priv) >> 1)
+/* Max number of counters. */
+#define MLX5_CNT_MAX(priv) ((priv)->sh->hws_max_nb_counters)
+/* Max number of counters allocated in non template mode. */
+#define MLX5_CNT_NT_MAX(priv) (MLX5_CNT_MAX(priv) >> 1)
 
 enum mlx5_meter_domain {
 	MLX5_MTR_DOMAIN_INGRESS,
@@ -2423,6 +2429,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,
 int mlx5_flow_meter_flush(struct rte_eth_dev *dev,
 			  struct rte_mtr_error *error);
 void mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev);
+uint32_t mlx5_flow_mtr_max_get(struct mlx5_priv *priv);
 
 /* mlx5_os.c */
 
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 41f20ed222..3022a86344 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -12522,6 +12522,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,
 	bool actions_end = false;
 	struct mlx5_priv *priv = dev->data->dev_private;
 	int ret;
+	uint obj_num;
 
 	for (; !actions_end; actions++) {
 		switch ((int)actions->type) {
@@ -12530,7 +12531,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,
 			if (!priv->hws_age_req) {
 				/* If no counters were previously allocated. */
 				if (!priv->hws_cpool) {
-					ret = mlx5_hws_cnt_pool_create(dev, MLX5_CNT_MAX,
+					obj_num = MLX5_CNT_NT_MAX(priv);
+					ret = mlx5_hws_cnt_pool_create(dev, obj_num,
 						priv->nb_queue, NULL);
 					if (ret)
 						goto err;
@@ -12548,7 +12550,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			/* If no counters were previously allocated. */
 			if (!priv->hws_cpool) {
-				ret = mlx5_hws_cnt_pool_create(dev, MLX5_CNT_MAX,
+				obj_num = MLX5_CNT_NT_MAX(priv);
+				ret = mlx5_hws_cnt_pool_create(dev, obj_num,
 					priv->nb_queue, NULL);
 				if (ret)
 					goto err;
@@ -12557,7 +12560,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			/* If no CT were previously allocated. */
 			if (!priv->hws_ctpool) {
-				ret = mlx5_flow_ct_init(dev, MLX5_CT_NT_MAX, priv->nb_queue);
+				obj_num = MLX5_CT_NT_MAX(priv);
+				ret = mlx5_flow_ct_init(dev, obj_num, priv->nb_queue);
 				if (ret)
 					goto err;
 			}
@@ -12565,7 +12569,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_METER_MARK:
 			/* If no meters were previously allocated. */
 			if (!priv->hws_mpool) {
-				ret = mlx5_flow_meter_init(dev, MLX5_MTR_NT_MAX, 0, 0,
+				obj_num = MLX5_MTR_NT_MAX(priv);
+				ret = mlx5_flow_meter_init(dev, obj_num, 0, 0,
 								priv->nb_queue);
 				if (ret)
 					goto err;
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index da3289b218..19d8607070 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,
 	return 0;
 }
 
+/**
+ * Callback to get MTR maximum objects number.
+ *
+ * @param[in] priv
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   Max number of meters.
+ */
+uint32_t
+mlx5_flow_mtr_max_get(struct mlx5_priv *priv)
+{
+	struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos;
+
+	/* Max number of meters. */
+	return ((priv->sh->meter_aso_en) ?
+	1 << (qattr->log_max_num_meter_aso + 1) :
+	qattr->log_max_flow_meter);
+}
+
 /**
  * Callback to get MTR capabilities.
  *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,
 					  RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
 					  "Meter is not supported");
 	memset(cap, 0, sizeof(*cap));
+	cap->n_max = mlx5_flow_mtr_max_get(priv);
 	if (priv->sh->meter_aso_en) {
-		/* 2 meters per one ASO cache line. */
-		cap->n_max = 1 << (qattr->log_max_num_meter_aso + 1);
 		cap->srtcm_rfc2697_packet_mode_supported = 1;
 		cap->trtcm_rfc2698_packet_mode_supported = 1;
 		cap->trtcm_rfc4115_packet_mode_supported = 1;
-	} else {
-		cap->n_max = 1 << qattr->log_max_flow_meter;
 	}
 	cap->srtcm_rfc2697_byte_mode_supported = 1;
 	cap->trtcm_rfc2698_byte_mode_supported = 1;
-- 
2.25.1


  parent reply	other threads:[~2024-06-03 10:51 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-02 10:28 [PATCH 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-03  8:04 ` [PATCH v2 05/34] " Maayan Kashani
2024-06-03  8:04   ` [PATCH v2 06/34] net/mlx5: add dummy last action Maayan Kashani
2024-06-03  8:04   ` [PATCH v2 07/34] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-03  8:04   ` [PATCH v2 08/34] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-03  8:04   ` [PATCH v2 09/34] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-03  8:04   ` [PATCH v2 10/34] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-03  8:05   ` [PATCH v2 11/34] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-03  8:05   ` [PATCH v2 12/34] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-03  8:05   ` [PATCH v2 13/34] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-03  8:05   ` [PATCH v2 14/34] net/mlx5: use non const max number for ASO actions Maayan Kashani
2024-06-03  8:05   ` [PATCH v2 15/34] net/mlx5: initial design changes Maayan Kashani
2024-06-03 10:48 ` [PATCH v3 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 02/11] net/mlx5: add dummy last action Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 03/11] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 04/11] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 05/11] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 06/11] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 07/11] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 08/11] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-03 10:48   ` [PATCH v3 09/11] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-03 10:48   ` Maayan Kashani [this message]
2024-06-03 10:48   ` [PATCH v3 11/11] net/mlx5: initial design changes Maayan Kashani
2024-06-06 10:23   ` [PATCH v4 00/11] non-template pmd basic func Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 02/11] net/mlx5: add dummy last action Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 03/11] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 04/11] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 05/11] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 06/11] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 07/11] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 08/11] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 09/11] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 10/11] net/mlx5: use non const max number for ASO actions Maayan Kashani
2024-06-06 10:23     ` [PATCH v4 11/11] net/mlx5: initial design changes Maayan Kashani
2024-06-06 12:32     ` [PATCH v5 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 02/11] net/mlx5: add dummy last action Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 03/11] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 04/11] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 05/11] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 06/11] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 07/11] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 08/11] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 09/11] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 10/11] net/mlx5: use non const max number for ASO actions Maayan Kashani
2024-06-06 12:32       ` [PATCH v5 11/11] net/mlx5: initial design changes Maayan Kashani
2024-06-09  8:55       ` [PATCH v6 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 02/11] net/mlx5: add dummy last action Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 03/11] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 04/11] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 05/11] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 06/11] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 07/11] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 08/11] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 09/11] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-09  8:55         ` [PATCH v6 10/11] net/mlx5: use non const max number for ASO actions Maayan Kashani
2024-06-09  8:56         ` [PATCH v6 11/11] net/mlx5: initial design changes Maayan Kashani
2024-06-09 11:00         ` [PATCH v7 01/11] net/mlx5: initial design of non template to hws Maayan Kashani
2024-06-09 11:00           ` [PATCH v7 02/11] net/mlx5: add dummy last action Maayan Kashani
2024-06-09 11:00           ` [PATCH v7 03/11] net/mlx5: add basic actions support for non-template API Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 04/11] net/mlx5: add default miss action support in nt2hws mode Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 05/11] net/mlx5: add ASO actions support to non-template mode Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 06/11] net/mlx5: fix segfault on counter pool destroy Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 07/11] net/mlx5: abstract action handling and enable reconfigure Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 08/11] common/mlx5: read connection tracking attributes Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 09/11] net/mlx5: support bulk actions in non template mode Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 10/11] net/mlx5: use non const max number for ASO actions Maayan Kashani
2024-06-09 11:01           ` [PATCH v7 11/11] net/mlx5: initial design changes Maayan Kashani
2024-06-10  8:34           ` [PATCH v7 01/11] net/mlx5: initial design of non template to hws Raslan Darawsheh

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=20240603104850.9935-10-mkashani@nvidia.com \
    --to=mkashani@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.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).