[PATCH 19/23] net/nfp: add support of ring pop and push
Chaoyong He
chaoyong.he at corigine.com
Wed Jun 19 11:58:26 CEST 2024
From: Peng Zhang <peng.zhang at corigine.com>
Add support of ring pop and push, the ring memory is in firmware
side, we add this support to make it is possible to share resource
between PFs.
Signed-off-by: Peng Zhang <peng.zhang at corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Long Wu <long.wu at corigine.com>
---
drivers/net/nfp/nfpcore/nfp_rtsym.c | 103 +++++++++++++++++++++++++++
drivers/net/nfp/nfpcore/nfp_rtsym.h | 4 ++
drivers/net/nfp/nfpcore/nfp_target.c | 2 +
3 files changed, 109 insertions(+)
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c
index 2fedd4d9af..7d9cfb0d42 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.c
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c
@@ -706,3 +706,106 @@ nfp_rtsym_map(struct nfp_rtsym_table *rtbl,
{
return nfp_rtsym_map_offset(rtbl, name, 0, min_size, area);
}
+
+/**
+ * Pop a simple unsigned scalar value from ring
+ *
+ * Lookup the symbol table for ring base and address, then pop value base on
+ * the ring with cpp read and write operation.
+ *
+ * @param rtbl
+ * NFP run-time symbol table
+ * @param aux_name
+ * The auxiliary rtsym table name which can ensure ring base and address
+ * @param name
+ * The rtsym table name which can handle the ring
+ * @param value
+ * Pop this value from ring
+ *
+ * @return
+ * 0 on success, negative errno otherwise.
+ */
+int
+nfp_rtsym_readl_indirect(struct nfp_rtsym_table *rtbl,
+ const char *aux_name,
+ const char *name,
+ uint32_t *value)
+{
+ int ret;
+ uint32_t cpp_id;
+ const struct nfp_rtsym *sym;
+ const struct nfp_rtsym *aux_sym;
+
+ if (value == NULL)
+ return -EINVAL;
+
+ aux_sym = nfp_rtsym_lookup(rtbl, aux_name);
+ if (aux_sym == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to find symbol %s", aux_name);
+ return -ENOENT;
+ }
+
+ sym = nfp_rtsym_lookup(rtbl, name);
+ if (sym == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to find symbol %s", name);
+ return -ENOENT;
+ }
+
+ /* Ring Pop */
+ cpp_id = NFP_CPP_ISLAND_ID(aux_sym->target, 22, 0, aux_sym->domain);
+ ret = nfp_cpp_readl(rtbl->cpp, cpp_id, sym->addr, value);
+ if (ret != 0)
+ return -EIO;
+
+ return 0;
+}
+
+/**
+ * Push a simple unsigned scalar value to ring
+ *
+ * Lookup the symbol table for ring base and address, then Push value base on
+ * the ring with cpp read and write operation.
+ *
+ * @param rtbl
+ * NFP run-time symbol table
+ * @param aux_name
+ * The auxiliary rtsym table name which can ensure ring base and address
+ * @param name
+ * The rtsym table name which can handle the ring
+ * @param value
+ * Push this value to ring
+ *
+ * @return
+ * 0 on success, negative errno otherwise.
+ */
+int
+nfp_rtsym_writel_indirect(struct nfp_rtsym_table *rtbl,
+ const char *aux_name,
+ const char *name,
+ uint32_t value)
+{
+ int ret;
+ uint32_t cpp_id;
+ const struct nfp_rtsym *sym;
+ const struct nfp_rtsym *aux_sym;
+
+ aux_sym = nfp_rtsym_lookup(rtbl, aux_name);
+ if (aux_sym == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to find symbol %s", aux_name);
+ return -ENOENT;
+ }
+
+ sym = nfp_rtsym_lookup(rtbl, name);
+ if (sym == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to find symbol %s", name);
+ return -ENOENT;
+ }
+
+ /* Ring Put */
+ cpp_id = NFP_CPP_ISLAND_ID(aux_sym->target, 20, 0, aux_sym->domain);
+ ret = nfp_cpp_writel(rtbl->cpp, cpp_id, sym->addr, value);
+ if (ret != 0)
+ return -EIO;
+
+ return 0;
+}
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.h b/drivers/net/nfp/nfpcore/nfp_rtsym.h
index 3e8acdd38e..5b1ea53bea 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.h
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.h
@@ -42,5 +42,9 @@ uint8_t *nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name,
uint32_t min_size, struct nfp_cpp_area **area);
uint8_t *nfp_rtsym_map_offset(struct nfp_rtsym_table *rtbl, const char *name,
uint32_t offset, uint32_t min_size, struct nfp_cpp_area **area);
+int nfp_rtsym_readl_indirect(struct nfp_rtsym_table *rtbl, const char *aux_name,
+ const char *name, uint32_t *value);
+int nfp_rtsym_writel_indirect(struct nfp_rtsym_table *rtbl, const char *aux_name,
+ const char *name, uint32_t value);
#endif /* __NFP_RTSYM_H__ */
diff --git a/drivers/net/nfp/nfpcore/nfp_target.c b/drivers/net/nfp/nfpcore/nfp_target.c
index ea5b39a4b9..0e7a5cbb05 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.c
+++ b/drivers/net/nfp/nfpcore/nfp_target.c
@@ -264,6 +264,8 @@ nfp6000_mu_emu(uint32_t cpp_id)
return PUSHPULL(P32, 0);
case NFP_CPP_ID(0, 18, 3): /* write_queue_ring */
return PUSHPULL(P32, 0);
+ case NFP_CPP_ID(0, 20, 0): /* put */
+ return PUSHPULL(P32, 0);
case NFP_CPP_ID(0, 20, 2): /* journal */
return PUSHPULL(P32, 0);
case NFP_CPP_ID(0, 21, 0): /* get */
--
2.39.1
More information about the dev
mailing list