DPDK patches and discussions
 help / color / mirror / Atom feed
From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>,
	"Kiran Kumar K" <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>,
	Harman Kalra <hkalra@marvell.com>,
	"Pavan Nikhilesh" <pbhagavatula@marvell.com>,
	Shijith Thotton <sthotton@marvell.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 19/20] common/cnxk: update timer base code
Date: Thu, 3 Oct 2024 18:52:36 +0530	[thread overview]
Message-ID: <20241003132237.20193-19-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20241003132237.20193-1-pbhagavatula@marvell.com>

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Update event timer base code to support configuring
HW accelerated timer arm and cancel.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 drivers/common/cnxk/hw/tim.h        |  5 ++
 drivers/common/cnxk/roc_mbox.h      | 38 ++++++++++++-
 drivers/common/cnxk/roc_tim.c       | 84 ++++++++++++++++++++++++++---
 drivers/common/cnxk/roc_tim.h       | 20 +++++--
 drivers/common/cnxk/version.map     |  1 +
 drivers/event/cnxk/cnxk_tim_evdev.h |  5 --
 6 files changed, 135 insertions(+), 18 deletions(-)

diff --git a/drivers/common/cnxk/hw/tim.h b/drivers/common/cnxk/hw/tim.h
index 82b094e3dc..75700a11b8 100644
--- a/drivers/common/cnxk/hw/tim.h
+++ b/drivers/common/cnxk/hw/tim.h
@@ -47,10 +47,15 @@
 #define TIM_LF_RAS_INT_ENA_W1S	   (0x310)
 #define TIM_LF_RAS_INT_ENA_W1C	   (0x318)
 #define TIM_LF_RING_REL		   (0x400)
+#define TIM_LF_SCHED_TIMER0	   (0x480)
+#define TIM_LF_RING_FIRST_EXPIRY   (0x558)
 
 #define TIM_MAX_INTERVAL_TICKS ((1ULL << 32) - 1)
+#define TIM_MAX_INTERVAL_EXT_TICKS ((1ULL << 34) - 1)
 #define TIM_MAX_BUCKET_SIZE    ((1ULL << 20) - 2)
 #define TIM_MIN_BUCKET_SIZE    1
 #define TIM_BUCKET_WRAP_SIZE   3
+#define TIM_BUCKET_MIN_GAP     1
+#define TIM_NPA_TMO            0xFFFF
 
 #endif /* __TIM_HW_H__ */
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index db6e8f07b3..8c0e274684 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -164,6 +164,9 @@ struct mbox_msghdr {
 	  tim_intvl_rsp)                                                       \
 	M(TIM_CAPTURE_COUNTERS, 0x806, tim_capture_counters, msg_req,          \
 	  tim_capture_rsp)                                                     \
+	M(TIM_CONFIG_HWWQE,    0x807, tim_config_hwwqe, tim_cfg_hwwqe_req,     \
+	  msg_rsp)                                                             \
+	M(TIM_GET_HW_INFO,     0x808, tim_get_hw_info, msg_req, tim_hw_info)   \
 	/* CPT mbox IDs (range 0xA00 - 0xBFF) */                               \
 	M(CPT_LF_ALLOC, 0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg, msg_rsp)    \
 	M(CPT_LF_FREE, 0xA01, cpt_lf_free, msg_req, msg_rsp)                   \
@@ -2803,6 +2806,7 @@ enum tim_af_status {
 	TIM_AF_INVALID_ENABLE_DONTFREE = -815,
 	TIM_AF_ENA_DONTFRE_NSET_PERIODIC = -816,
 	TIM_AF_RING_ALREADY_DISABLED = -817,
+	TIM_AF_LF_START_SYNC_FAIL = -818,
 };
 
 enum tim_clk_srcs {
@@ -2895,13 +2899,43 @@ struct tim_config_req {
 	uint8_t __io enabledontfreebuffer;
 	uint32_t __io bucketsize;
 	uint32_t __io chunksize;
-	uint32_t __io interval;
+	uint32_t __io interval_lo;
 	uint8_t __io gpioedge;
-	uint8_t __io rsvd[7];
+	uint8_t __io rsvd[3];
+	uint32_t __io interval_hi;
 	uint64_t __io intervalns;
 	uint64_t __io clockfreq;
 };
 
+struct tim_cfg_hwwqe_req {
+	struct mbox_msghdr hdr;
+	uint16_t __io ring;
+	uint8_t __io grp_ena;
+	uint8_t __io hwwqe_ena;
+	uint8_t __io ins_min_gap;
+	uint8_t __io flw_ctrl_ena;
+	uint8_t __io wqe_rd_clr_ena;
+	uint16_t __io grp_tmo_cntr;
+	uint16_t __io npa_tmo_cntr;
+	uint16_t __io result_offset;
+	uint16_t __io event_count_offset;
+	uint64_t __io rsvd[2];
+};
+
+struct tim_feat_info {
+	uint16_t __io rings;
+	uint8_t __io engines;
+	uint8_t __io hwwqe : 1;
+	uint8_t __io intvl_ext : 1;
+	uint8_t __io rsvd8[4];
+	uint64_t __io rsvd[2];
+};
+
+struct tim_hw_info {
+	struct mbox_msghdr hdr;
+	struct tim_feat_info feat;
+};
+
 struct tim_lf_alloc_rsp {
 	struct mbox_msghdr hdr;
 	uint64_t __io tenns_clk;
diff --git a/drivers/common/cnxk/roc_tim.c b/drivers/common/cnxk/roc_tim.c
index 095afbb9e6..db1c129806 100644
--- a/drivers/common/cnxk/roc_tim.c
+++ b/drivers/common/cnxk/roc_tim.c
@@ -5,6 +5,8 @@
 #include "roc_api.h"
 #include "roc_priv.h"
 
+#define LF_ENABLE_RETRY_CNT 8
+
 static int
 tim_fill_msix(struct roc_tim *roc_tim, uint16_t nb_ring)
 {
@@ -86,8 +88,11 @@ tim_err_desc(int rc)
 	case TIM_AF_RING_ALREADY_DISABLED:
 		plt_err("Ring already stopped");
 		break;
+	case TIM_AF_LF_START_SYNC_FAIL:
+		plt_err("Ring start sync failed.");
+		break;
 	default:
-		plt_err("Unknown Error.");
+		plt_err("Unknown Error: %d", rc);
 	}
 }
 
@@ -123,10 +128,12 @@ roc_tim_lf_enable(struct roc_tim *roc_tim, uint8_t ring_id, uint64_t *start_tsc,
 	struct sso *sso = roc_sso_to_sso_priv(roc_tim->roc_sso);
 	struct dev *dev = &sso->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
+	uint8_t retry_cnt = LF_ENABLE_RETRY_CNT;
 	struct tim_enable_rsp *rsp;
 	struct tim_ring_req *req;
 	int rc = -ENOSPC;
 
+retry:
 	req = mbox_alloc_msg_tim_enable_ring(mbox);
 	if (req == NULL)
 		goto fail;
@@ -134,6 +141,9 @@ roc_tim_lf_enable(struct roc_tim *roc_tim, uint8_t ring_id, uint64_t *start_tsc,
 
 	rc = mbox_process_msg(dev->mbox, (void **)&rsp);
 	if (rc) {
+		if (rc == TIM_AF_LF_START_SYNC_FAIL && retry_cnt--)
+			goto retry;
+
 		tim_err_desc(rc);
 		rc = -EIO;
 		goto fail;
@@ -183,10 +193,9 @@ roc_tim_lf_base_get(struct roc_tim *roc_tim, uint8_t ring_id)
 }
 
 int
-roc_tim_lf_config(struct roc_tim *roc_tim, uint8_t ring_id,
-		  enum roc_tim_clk_src clk_src, uint8_t ena_periodic,
-		  uint8_t ena_dfb, uint32_t bucket_sz, uint32_t chunk_sz,
-		  uint32_t interval, uint64_t intervalns, uint64_t clockfreq)
+roc_tim_lf_config(struct roc_tim *roc_tim, uint8_t ring_id, enum roc_tim_clk_src clk_src,
+		  uint8_t ena_periodic, uint8_t ena_dfb, uint32_t bucket_sz, uint32_t chunk_sz,
+		  uint64_t interval, uint64_t intervalns, uint64_t clockfreq)
 {
 	struct sso *sso = roc_sso_to_sso_priv(roc_tim->roc_sso);
 	struct dev *dev = &sso->dev;
@@ -204,7 +213,8 @@ roc_tim_lf_config(struct roc_tim *roc_tim, uint8_t ring_id,
 	req->clocksource = clk_src;
 	req->enableperiodic = ena_periodic;
 	req->enabledontfreebuffer = ena_dfb;
-	req->interval = interval;
+	req->interval_lo = interval;
+	req->interval_hi = interval >> 32;
 	req->intervalns = intervalns;
 	req->clockfreq = clockfreq;
 	req->gpioedge = TIM_GPIO_LTOH_TRANS;
@@ -220,6 +230,41 @@ roc_tim_lf_config(struct roc_tim *roc_tim, uint8_t ring_id,
 	return rc;
 }
 
+int
+roc_tim_lf_config_hwwqe(struct roc_tim *roc_tim, uint8_t ring_id, struct roc_tim_hwwqe_cfg *cfg)
+{
+	struct sso *sso = roc_sso_to_sso_priv(roc_tim->roc_sso);
+	struct dev *dev = &sso->dev;
+	struct mbox *mbox = mbox_get(dev->mbox);
+	struct tim_cfg_hwwqe_req *req;
+	int rc = -ENOSPC;
+
+	req = mbox_alloc_msg_tim_config_hwwqe(mbox);
+	if (req == NULL)
+		goto fail;
+	req->ring = ring_id;
+	req->hwwqe_ena = cfg->hwwqe_ena;
+	req->grp_ena = cfg->grp_ena;
+	req->grp_tmo_cntr = cfg->grp_tmo_cyc;
+	req->flw_ctrl_ena = cfg->flw_ctrl_ena;
+	req->result_offset = cfg->result_offset;
+	req->event_count_offset = cfg->event_count_offset;
+
+	req->wqe_rd_clr_ena = 1;
+	req->npa_tmo_cntr = TIM_NPA_TMO;
+	req->ins_min_gap = TIM_BUCKET_MIN_GAP;
+
+	rc = mbox_process(mbox);
+	if (rc) {
+		tim_err_desc(rc);
+		rc = -EIO;
+	}
+
+fail:
+	mbox_put(mbox);
+	return rc;
+}
+
 int
 roc_tim_lf_interval(struct roc_tim *roc_tim, enum roc_tim_clk_src clk_src,
 		    uint64_t clockfreq, uint64_t *intervalns,
@@ -353,6 +398,31 @@ tim_free_lf_count_get(struct dev *dev, uint16_t *nb_lfs)
 	return 0;
 }
 
+static int
+tim_hw_info_get(struct roc_tim *roc_tim)
+{
+	struct dev *dev = &roc_sso_to_sso_priv(roc_tim->roc_sso)->dev;
+	struct mbox *mbox = mbox_get(dev->mbox);
+	struct tim_hw_info *rsp;
+	int rc;
+
+	mbox_alloc_msg_tim_get_hw_info(mbox);
+	rc = mbox_process_msg(mbox, (void **)&rsp);
+	if (rc && rc != MBOX_MSG_INVALID) {
+		plt_err("Failed to get SSO HW info\n");
+		rc = -EIO;
+		goto exit;
+	}
+
+	if (rc != MBOX_MSG_INVALID)
+		mbox_memcpy(&roc_tim->feat, &rsp->feat, sizeof(roc_tim->feat));
+
+	rc = 0;
+exit:
+	mbox_put(mbox);
+	return rc;
+}
+
 int
 roc_tim_init(struct roc_tim *roc_tim)
 {
@@ -372,6 +442,8 @@ roc_tim_init(struct roc_tim *roc_tim)
 	PLT_STATIC_ASSERT(sizeof(struct tim) <= TIM_MEM_SZ);
 	nb_lfs = roc_tim->nb_lfs;
 
+	rc = tim_hw_info_get(roc_tim);
+
 	rc = tim_free_lf_count_get(dev, &nb_free_lfs);
 	if (rc) {
 		plt_tim_dbg("Failed to get TIM resource count");
diff --git a/drivers/common/cnxk/roc_tim.h b/drivers/common/cnxk/roc_tim.h
index f9a9ad1887..2eb6e6962b 100644
--- a/drivers/common/cnxk/roc_tim.h
+++ b/drivers/common/cnxk/roc_tim.h
@@ -19,10 +19,20 @@ enum roc_tim_clk_src {
 	ROC_TIM_CLK_SRC_INVALID,
 };
 
+struct roc_tim_hwwqe_cfg {
+	uint8_t grp_ena;
+	uint8_t hwwqe_ena;
+	uint8_t flw_ctrl_ena;
+	uint16_t grp_tmo_cyc;
+	uint16_t result_offset;
+	uint16_t event_count_offset;
+};
+
 struct roc_tim {
 	struct roc_sso *roc_sso;
 	/* Public data. */
 	uint16_t nb_lfs;
+	struct tim_feat_info feat;
 	/* Private data. */
 #define TIM_MEM_SZ (1 * 1024)
 	uint8_t reserved[TIM_MEM_SZ] __plt_cache_aligned;
@@ -36,11 +46,11 @@ int __roc_api roc_tim_lf_enable(struct roc_tim *roc_tim, uint8_t ring_id,
 				uint64_t *start_tsc, uint32_t *cur_bkt);
 int __roc_api roc_tim_lf_disable(struct roc_tim *roc_tim, uint8_t ring_id);
 int __roc_api roc_tim_lf_config(struct roc_tim *roc_tim, uint8_t ring_id,
-				enum roc_tim_clk_src clk_src,
-				uint8_t ena_periodic, uint8_t ena_dfb,
-				uint32_t bucket_sz, uint32_t chunk_sz,
-				uint32_t interval, uint64_t intervalns,
-				uint64_t clockfreq);
+				enum roc_tim_clk_src clk_src, uint8_t ena_periodic, uint8_t ena_dfb,
+				uint32_t bucket_sz, uint32_t chunk_sz, uint64_t interval,
+				uint64_t intervalns, uint64_t clockfreq);
+int __roc_api roc_tim_lf_config_hwwqe(struct roc_tim *roc_tim, uint8_t ring_id,
+				      struct roc_tim_hwwqe_cfg *cfg);
 int __roc_api roc_tim_lf_interval(struct roc_tim *roc_tim,
 				  enum roc_tim_clk_src clk_src,
 				  uint64_t clockfreq, uint64_t *intervalns,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index d0e9436e9b..55e645e383 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -527,6 +527,7 @@ INTERNAL {
 	roc_tim_lf_alloc;
 	roc_tim_lf_base_get;
 	roc_tim_lf_config;
+	roc_tim_lf_config_hwwqe;
 	roc_tim_lf_disable;
 	roc_tim_lf_enable;
 	roc_tim_lf_free;
diff --git a/drivers/event/cnxk/cnxk_tim_evdev.h b/drivers/event/cnxk/cnxk_tim_evdev.h
index 6cf10dbf4d..9bd36158d8 100644
--- a/drivers/event/cnxk/cnxk_tim_evdev.h
+++ b/drivers/event/cnxk/cnxk_tim_evdev.h
@@ -16,11 +16,6 @@
 #include <rte_memzone.h>
 #include <rte_reciprocal.h>
 
-#include "hw/tim.h"
-
-#include "roc_model.h"
-#include "roc_tim.h"
-
 #define NSECPERSEC		 1E9
 #define USECPERSEC		 1E6
 #define TICK2NSEC(__tck, __freq) (((__tck)*NSECPERSEC) / (__freq))
-- 
2.25.1


  parent reply	other threads:[~2024-10-03 13:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 13:22 [PATCH 01/20] common/cnxk: implement SSO HW info pbhagavatula
2024-10-03 13:22 ` [PATCH 02/20] event/cnxk: add CN20K specific device probe pbhagavatula
2024-10-03 13:22 ` [PATCH 03/20] event/cnxk: add CN20K device config pbhagavatula
2024-10-03 13:22 ` [PATCH 04/20] event/cnxk: add CN20k event queue config pbhagavatula
2024-10-03 13:22 ` [PATCH 05/20] event/cnxk: add CN20K event port configuration pbhagavatula
2024-10-03 13:22 ` [PATCH 06/20] event/cnxk: add CN20K SSO enqueue fast path pbhagavatula
2024-10-03 13:22 ` [PATCH 07/20] event/cnxk: add CN20K SSO dequeue " pbhagavatula
2024-10-03 13:22 ` [PATCH 08/20] event/cnxk: add CN20K event port quiesce pbhagavatula
2024-10-03 13:22 ` [PATCH 09/20] event/cnxk: add CN20K event port profile switch pbhagavatula
2024-10-03 13:22 ` [PATCH 10/20] event/cnxk: add CN20K device start pbhagavatula
2024-10-03 13:22 ` [PATCH 11/20] event/cnxk: add CN20K device stop and close pbhagavatula
2024-10-03 13:22 ` [PATCH 12/20] event/cnxk: add CN20K xstats, selftest and dump pbhagavatula
2024-10-03 13:22 ` [PATCH 13/20] event/cnxk: support CN20K Rx adapter pbhagavatula
2024-10-03 13:22 ` [PATCH 14/20] event/cnxk: support CN20K Rx adapter fast path pbhagavatula
2024-10-03 13:22 ` [PATCH 15/20] event/cnxk: support CN20K Tx adapter pbhagavatula
2024-10-03 13:22 ` [PATCH 16/20] event/cnxk: support CN20K Tx adapter fast path pbhagavatula
2024-10-03 13:22 ` [PATCH 17/20] common/cnxk: add SSO event aggregator pbhagavatula
2024-10-03 13:22 ` [PATCH 18/20] event/cnxk: add Rx/Tx event vector support pbhagavatula
2024-10-03 13:22 ` pbhagavatula [this message]
2024-10-03 13:22 ` [PATCH 20/20] event/cnxk: add CN20K timer adapter pbhagavatula

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=20241003132237.20193-19-pbhagavatula@marvell.com \
    --to=pbhagavatula@marvell.com \
    --cc=dev@dpdk.org \
    --cc=hkalra@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=sthotton@marvell.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).