diff mbox series

[v3,10/27] common/cnxk: support RoC API to connect bandwidth profiles

Message ID 20210930090844.1059326-10-skori@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers show
Series [v3,01/27] common/cnxk: update policer MBOX APIs and HW definitions | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sunil Kumar Kori Sept. 30, 2021, 9:08 a.m. UTC
From: Sunil Kumar Kori <skori@marvell.com>

To maintain chain of bandwidth profiles, they needs to be
connected. Implement RoC API to connect two bandwidth profiles
at different levels.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v3:
 - Rebase support on latest DPDK
 - Handled multilevel chaining for tree hierarchy
 - Fix naming convention
v2:
 - Rebase support on latest DPDK
 - Handled multilevel chaining for linear hierarchy
 - Review comments incorporated

 drivers/common/cnxk/roc_nix.h     |  6 ++++++
 drivers/common/cnxk/roc_nix_bpf.c | 36 +++++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map   |  1 +
 3 files changed, 43 insertions(+)
diff mbox series

Patch

diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index 6d17d46388..af76068030 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -7,6 +7,7 @@ 
 
 /* Constants */
 #define ROC_NIX_BPF_PER_PFFUNC	      64
+#define ROC_NIX_BPF_ID_INVALID	      0xFFFF
 #define ROC_NIX_BPF_LEVEL_IDX_INVALID 0xFF
 #define ROC_NIX_BPF_LEVEL_MAX	      3
 
@@ -586,6 +587,11 @@  int __roc_api roc_nix_bpf_pre_color_tbl_setup(
 	struct roc_nix *roc_nix, uint16_t id,
 	enum roc_nix_bpf_level_flag lvl_flag, struct roc_nix_bpf_precolor *tbl);
 
+/* Use ROC_NIX_BPF_ID_INVALID as dst_id to disconnect */
+int __roc_api roc_nix_bpf_connect(struct roc_nix *roc_nix,
+				  enum roc_nix_bpf_level_flag lvl_flag,
+				  uint16_t src_id, uint16_t dst_id);
+
 uint8_t __roc_api
 roc_nix_bpf_level_to_idx(enum roc_nix_bpf_level_flag lvl_flag);
 
diff --git a/drivers/common/cnxk/roc_nix_bpf.c b/drivers/common/cnxk/roc_nix_bpf.c
index b5a1c484a9..f5822136d1 100644
--- a/drivers/common/cnxk/roc_nix_bpf.c
+++ b/drivers/common/cnxk/roc_nix_bpf.c
@@ -761,3 +761,39 @@  roc_nix_bpf_pre_color_tbl_setup(struct roc_nix *roc_nix, uint16_t id,
 exit:
 	return rc;
 }
+
+int
+roc_nix_bpf_connect(struct roc_nix *roc_nix,
+		    enum roc_nix_bpf_level_flag lvl_flag, uint16_t src_id,
+		    uint16_t dst_id)
+{
+	struct mbox *mbox = get_mbox(roc_nix);
+	struct nix_cn10k_aq_enq_req *aq;
+	uint8_t level_idx;
+
+	if (roc_model_is_cn9k())
+		return NIX_ERR_HW_NOTSUP;
+
+	level_idx = roc_nix_bpf_level_to_idx(lvl_flag);
+	if (level_idx == ROC_NIX_BPF_LEVEL_IDX_INVALID)
+		return NIX_ERR_PARAM;
+
+	aq = mbox_alloc_msg_nix_cn10k_aq_enq(mbox);
+	if (aq == NULL)
+		return -ENOSPC;
+	aq->qidx = (sw_to_hw_lvl_map[level_idx] << 14) | src_id;
+	aq->ctype = NIX_AQ_CTYPE_BAND_PROF;
+	aq->op = NIX_AQ_INSTOP_WRITE;
+
+	if (dst_id == ROC_NIX_BPF_ID_INVALID) {
+		aq->prof.hl_en = false;
+		aq->prof_mask.hl_en = ~(aq->prof_mask.hl_en);
+	} else {
+		aq->prof.hl_en = true;
+		aq->prof.band_prof_id = dst_id;
+		aq->prof_mask.hl_en = ~(aq->prof_mask.hl_en);
+		aq->prof_mask.band_prof_id = ~(aq->prof_mask.band_prof_id);
+	}
+
+	return mbox_process(mbox);
+}
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index a08fbe6013..c04a8ca9da 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -79,6 +79,7 @@  INTERNAL {
 	roc_se_ciph_key_set;
 	roc_nix_bpf_alloc;
 	roc_nix_bpf_config;
+	roc_nix_bpf_connect;
 	roc_nix_bpf_count_get;
 	roc_nix_bpf_dump;
 	roc_nix_bpf_ena_dis;