DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ankur Dwivedi <adwivedi@marvell.com>
To: <dev@dpdk.org>
Cc: <gakhil@marvell.com>, <vattunuru@marvell.com>,
	<jerinj@marvell.com>, "Ankur Dwivedi" <adwivedi@marvell.com>
Subject: [PATCH v1 1/2] common/cnxk: add sa to port mapping
Date: Wed, 23 Aug 2023 11:19:59 +0530	[thread overview]
Message-ID: <20230823055000.2692083-2-adwivedi@marvell.com> (raw)
In-Reply-To: <20230823055000.2692083-1-adwivedi@marvell.com>

Adds sa to port mapping in roc mcs. This helps to propagate the tx and
rx pn threshold events to the correct ethernet device.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 drivers/common/cnxk/roc_mcs.c         | 22 +++++++++++++++++++---
 drivers/common/cnxk/roc_mcs.h         |  8 ++++++--
 drivers/common/cnxk/roc_mcs_sec_cfg.c |  6 ++++++
 drivers/common/cnxk/version.map       |  1 +
 4 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/common/cnxk/roc_mcs.c b/drivers/common/cnxk/roc_mcs.c
index 1f269ddae5..f823f7f478 100644
--- a/drivers/common/cnxk/roc_mcs.c
+++ b/drivers/common/cnxk/roc_mcs.c
@@ -10,6 +10,7 @@ struct mcs_event_cb {
 	enum roc_mcs_event_type event;
 	roc_mcs_dev_cb_fn cb_fn;
 	void *cb_arg;
+	void *userdata;
 	void *ret_param;
 	uint32_t active;
 };
@@ -320,12 +321,16 @@ roc_mcs_intr_configure(struct roc_mcs *mcs, struct roc_mcs_intr_cfg *config)
 {
 	struct mcs_intr_cfg *req;
 	struct msg_rsp *rsp;
+	int rc;
 
 	if (config == NULL)
 		return -EINVAL;
 
 	MCS_SUPPORT_CHECK;
 
+	if (mcs->intr_cfg_once)
+		return 0;
+
 	req = mbox_alloc_msg_mcs_intr_cfg(mcs->mbox);
 	if (req == NULL)
 		return -ENOMEM;
@@ -333,7 +338,11 @@ roc_mcs_intr_configure(struct roc_mcs *mcs, struct roc_mcs_intr_cfg *config)
 	req->intr_mask = config->intr_mask;
 	req->mcs_id = mcs->idx;
 
-	return mbox_process_msg(mcs->mbox, (void *)&rsp);
+	rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
+	if (rc == 0)
+		mcs->intr_cfg_once = true;
+
+	return rc;
 }
 
 int
@@ -630,7 +639,7 @@ roc_mcs_event_cb_register(struct roc_mcs *mcs, enum roc_mcs_event_type event,
 		cb->cb_fn = cb_fn;
 		cb->cb_arg = cb_arg;
 		cb->event = event;
-		mcs->userdata = userdata;
+		cb->userdata = userdata;
 		TAILQ_INSERT_TAIL(cb_list, cb, next);
 	}
 
@@ -678,7 +687,8 @@ mcs_event_cb_process(struct roc_mcs *mcs, struct roc_mcs_event_desc *desc)
 		cb->active = 1;
 		mcs_cb.ret_param = desc;
 
-		rc = mcs_cb.cb_fn(mcs->userdata, mcs_cb.ret_param, mcs_cb.cb_arg);
+		rc = mcs_cb.cb_fn(mcs_cb.userdata, mcs_cb.ret_param, mcs_cb.cb_arg,
+				  mcs->sa_port_map[desc->metadata.sa_idx]);
 		cb->active = 0;
 	}
 
@@ -788,6 +798,10 @@ mcs_alloc_rsrc_bmap(struct roc_mcs *mcs)
 		}
 	}
 
+	mcs->sa_port_map = plt_zmalloc(sizeof(uint8_t) * hw->sa_entries, 0);
+	if (mcs->sa_port_map == NULL)
+		goto exit;
+
 	return rc;
 
 exit:
@@ -865,6 +879,8 @@ roc_mcs_dev_fini(struct roc_mcs *mcs)
 
 	plt_free(priv->port_rsrc);
 
+	plt_free(mcs->sa_port_map);
+
 	roc_idev_mcs_free(mcs);
 
 	plt_free(mcs);
diff --git a/drivers/common/cnxk/roc_mcs.h b/drivers/common/cnxk/roc_mcs.h
index afac6c92e2..1b554f79c9 100644
--- a/drivers/common/cnxk/roc_mcs.h
+++ b/drivers/common/cnxk/roc_mcs.h
@@ -477,15 +477,17 @@ struct roc_mcs_fips_result_rsp {
 };
 
 /** User application callback to be registered for any notifications from driver. */
-typedef int (*roc_mcs_dev_cb_fn)(void *userdata, struct roc_mcs_event_desc *desc, void *cb_arg);
+typedef int (*roc_mcs_dev_cb_fn)(void *userdata, struct roc_mcs_event_desc *desc, void *cb_arg,
+				 uint8_t port_id);
 
 struct roc_mcs {
 	TAILQ_ENTRY(roc_mcs) next;
 	struct plt_pci_device *pci_dev;
 	struct mbox *mbox;
-	void *userdata;
 	uint8_t idx;
 	uint8_t refcount;
+	bool intr_cfg_once;
+	uint8_t *sa_port_map;
 
 #define ROC_MCS_MEM_SZ (1 * 1024)
 	uint8_t reserved[ROC_MCS_MEM_SZ] __plt_cache_aligned;
@@ -556,6 +558,8 @@ __roc_api int roc_mcs_tx_sc_sa_map_write(struct roc_mcs *mcs,
 					 struct roc_mcs_tx_sc_sa_map *tx_sc_sa_map);
 __roc_api int roc_mcs_tx_sc_sa_map_read(struct roc_mcs *mcs,
 					struct roc_mcs_tx_sc_sa_map *tx_sc_sa_map);
+/* SA to Port map update */
+__roc_api void roc_mcs_sa_port_map_update(struct roc_mcs *mcs, int sa_id, uint8_t port_id);
 
 /* Flow entry read, write and enable */
 __roc_api int roc_mcs_flowid_entry_write(struct roc_mcs *mcs,
diff --git a/drivers/common/cnxk/roc_mcs_sec_cfg.c b/drivers/common/cnxk/roc_mcs_sec_cfg.c
index 7b3a4c91e8..e2fd3e7b8c 100644
--- a/drivers/common/cnxk/roc_mcs_sec_cfg.c
+++ b/drivers/common/cnxk/roc_mcs_sec_cfg.c
@@ -526,3 +526,9 @@ roc_mcs_flowid_entry_enable(struct roc_mcs *mcs, struct roc_mcs_flowid_ena_dis_e
 
 	return mbox_process_msg(mcs->mbox, (void *)&rsp);
 }
+
+void
+roc_mcs_sa_port_map_update(struct roc_mcs *mcs, int sa_id, uint8_t port_id)
+{
+	mcs->sa_port_map[sa_id] = port_id;
+}
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 8c71497df8..47b219af2b 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -170,6 +170,7 @@ INTERNAL {
 	roc_mcs_rx_sc_sa_map_write;
 	roc_mcs_sa_policy_read;
 	roc_mcs_sa_policy_write;
+	roc_mcs_sa_port_map_update;
 	roc_mcs_sc_stats_get;
 	roc_mcs_secy_policy_read;
 	roc_mcs_secy_policy_write;
-- 
2.25.1


  reply	other threads:[~2023-08-23  5:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23  5:49 [PATCH v1 0/2] support of MACsec PN threshold events on multiple ports Ankur Dwivedi
2023-08-23  5:49 ` Ankur Dwivedi [this message]
2023-08-24 12:20   ` [PATCH v1 1/2] common/cnxk: add sa to port mapping Jerin Jacob
2023-08-23  5:50 ` [PATCH v1 2/2] net/cnxk: update sa to port map Ankur Dwivedi
2023-08-25 10:36 ` [PATCH v2 0/1] support for MACsec PN threshold events on multiple ports Ankur Dwivedi
2023-08-25 10:36   ` [PATCH v2 1/1] net/cnxk: support " Ankur Dwivedi
2023-08-28 13:08     ` Jerin Jacob

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=20230823055000.2692083-2-adwivedi@marvell.com \
    --to=adwivedi@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=vattunuru@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).