Skip to contentSkip to conversation

raw/cnxk_bphy: sync with upstream

PATCH In review Tomasz Duszynski 2 participants 4 messages Oct 1, 2021 – Oct 7, 2021

lore
Share & tools
lore
#0 lore raw

cover raw/cnxk_bphy: sync with upstream

This series add some wrappers that simplify using
existing BPHY APIs.

Jakub Palider (1):
raw/cnxk_bphy: use roc calls for max irq

Tomasz Duszynski (1):
raw/cnxk_bphy: add wrappers for available message types

 drivers/common/cnxk/roc_bphy_irq.c         |   6 +
 drivers/common/cnxk/roc_bphy_irq.h         |   1 +
 drivers/common/cnxk/version.map            |   1 +
 drivers/raw/cnxk_bphy/cnxk_bphy.c          |  62 ++++--
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 125 ++---------
 drivers/raw/cnxk_bphy/cnxk_bphy_irq.c      |   2 +-
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h       | 245 +++++++++++++++------
 7 files changed, 245 insertions(+), 197 deletions(-)

--
2.25.1

#1 lore raw

PATCH 1/2 raw/cnxk_bphy: add wrappers for available message types

One sends commands and receive responses by enqueuing or dequeuing custom messages. In order to simplify this scheme simple wrappers were added which take care of all the heavy lifting.

---
 drivers/raw/cnxk_bphy/cnxk_bphy.c          |  62 ++++--
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 125 ++---------
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h       | 245 +++++++++++++++------
 3 files changed, 236 insertions(+), 196 deletions(-)
drivers/raw/cnxk_bphy/cnxk_bphy.c +49 -13
index 4b7669b3e6..6bfda71761 100644
@@ -45,6 +45,7 @@ static int
 bphy_rawdev_selftest(uint16_t dev_id)
 {
 	unsigned int i, queues, descs;
+	uint16_t pf_func;
 	uint64_t max_irq;
 	int ret;
 
@@ -68,12 +69,12 @@ bphy_rawdev_selftest(uint16_t dev_id)
 		goto err_desc;
 	}
 
-	ret = rte_pmd_bphy_npa_pf_func_get(dev_id);
-	if (ret == 0)
+	ret = rte_pmd_bphy_npa_pf_func_get(dev_id, &pf_func);
+	if (ret || pf_func == 0)
 		plt_warn("NPA pf_func is invalid");
 
-	ret = rte_pmd_bphy_sso_pf_func_get(dev_id);
-	if (ret == 0)
+	ret = rte_pmd_bphy_sso_pf_func_get(dev_id, &pf_func);
+	if (ret || pf_func == 0)
 		plt_warn("SSO pf_func is invalid");
 
 	ret = rte_pmd_bphy_intr_init(dev_id);
@@ -169,9 +170,13 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
 {
 	struct bphy_device *bphy_dev = (struct bphy_device *)dev->dev_private;
 	struct cnxk_bphy_irq_msg *msg = buffers[0]->buf_addr;
+	struct bphy_irq_queue *qp = &bphy_dev->queues[0];
 	unsigned int queue = (size_t)context;
 	struct cnxk_bphy_irq_info *info;
-	int ret = 0;
+	struct cnxk_bphy_mem *mem;
+	uint16_t *pf_func;
+	void *rsp = NULL;
+	int ret;
 
 	if (queue >= RTE_DIM(bphy_dev->queues))
 		return -EINVAL;
@@ -182,6 +187,8 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
 	switch (msg->type) {
 	case CNXK_BPHY_IRQ_MSG_TYPE_INIT:
 		ret = cnxk_bphy_intr_init(dev->dev_id);
+		if (ret)
+			return ret;
 		break;
 	case CNXK_BPHY_IRQ_MSG_TYPE_FINI:
 		cnxk_bphy_intr_fini(dev->dev_id);
@@ -191,27 +198,49 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
 		ret = cnxk_bphy_intr_register(dev->dev_id, info->irq_num,
 					      info->handler, info->data,
 					      info->cpu);
+		if (ret)
+			return ret;
 		break;
 	case CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER:
 		info = (struct cnxk_bphy_irq_info *)msg->data;
 		cnxk_bphy_intr_unregister(dev->dev_id, info->irq_num);
 		break;
 	case CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET:
-		bphy_dev->queues[queue].rsp = &bphy_dev->mem;
+		mem = rte_zmalloc(NULL, sizeof(*mem), 0);
+		if (!mem)
+			return -ENOMEM;
+
+		*mem = bphy_dev->mem;
+		rsp = mem;
 		break;
 	case CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC:
-		bphy_dev->queues[queue].rsp =
-			(void *)(size_t)roc_bphy_npa_pf_func_get();
+		pf_func = rte_malloc(NULL, sizeof(*pf_func), 0);
+		if (!pf_func)
+			return -ENOMEM;
+
+		*pf_func = roc_bphy_npa_pf_func_get();
+		rsp = pf_func;
 		break;
 	case CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC:
-		bphy_dev->queues[queue].rsp =
-			(void *)(size_t)roc_bphy_sso_pf_func_get();
+		pf_func = rte_malloc(NULL, sizeof(*pf_func), 0);
+		if (!pf_func)
+			return -ENOMEM;
+
+		*pf_func = roc_bphy_sso_pf_func_get();
+		rsp = pf_func;
 		break;
 	default:
-		ret = -EINVAL;
+		return -EINVAL;
 	}
 
-	return ret;
+	/* get rid of last response if any */
+	if (qp->rsp) {
+		RTE_LOG(WARNING, PMD, "Previous response got overwritten\n");
+		rte_free(qp->rsp);
+	}
+	qp->rsp = rsp;
+
+	return 1;
 }
 
 static int
@@ -221,6 +250,7 @@ cnxk_bphy_irq_dequeue_bufs(struct rte_rawdev *dev,
 {
 	struct bphy_device *bphy_dev = (struct bphy_device *)dev->dev_private;
 	unsigned int queue = (size_t)context;
+	struct bphy_irq_queue *qp;
 
 	if (queue >= RTE_DIM(bphy_dev->queues))
 		return -EINVAL;
@@ -228,7 +258,13 @@ cnxk_bphy_irq_dequeue_bufs(struct rte_rawdev *dev,
 	if (count == 0)
 		return 0;
 
-	buffers[0]->buf_addr = bphy_dev->queues[queue].rsp;
+	qp = &bphy_dev->queues[queue];
+	if (qp->rsp) {
+		buffers[0]->buf_addr = qp->rsp;
+		qp->rsp = NULL;
+
+		return 1;
+	}
 
 	return 0;
 }
drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c +14 -111

216 lines not on this page · raw message

drivers/raw/cnxk_bphy/rte_pmd_bphy.h +173 -72

313 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 raw/cnxk_bphy: use roc calls for max irq

In reply to Tomasz Duszynski

From: Jakub Palider <[email protected]>

Maximum interrupt number function used direct access to structure field while ROC helper exists and serves the same purpose.

---
 drivers/common/cnxk/roc_bphy_irq.c    | 6 ++++++
 drivers/common/cnxk/roc_bphy_irq.h    | 1 +
 drivers/common/cnxk/version.map       | 1 +
 drivers/raw/cnxk_bphy/cnxk_bphy_irq.c | 2 +-
 4 files changed, 9 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_bphy_irq.c +6 -0
index 53eb89c2f1..f4e9b341af 100644
@@ -318,6 +318,12 @@ roc_bphy_intr_available(struct roc_bphy_irq_chip *irq_chip, int irq_num)
 	return irq_chip->avail_irq_bmask & BIT(irq_num);
 }
 
+uint64_t
+roc_bphy_intr_max_get(struct roc_bphy_irq_chip *irq_chip)
+{
+	return irq_chip->max_irq;
+}
+
 int
 roc_bphy_intr_clear(struct roc_bphy_irq_chip *chip, int irq_num)
 {
drivers/common/cnxk/roc_bphy_irq.h +1 -0
index 185b6354a5..93335e0d6d 100644
@@ -36,6 +36,7 @@ __roc_api void roc_bphy_intr_handler(unsigned int irq_num);
 __roc_api bool roc_bphy_intr_available(struct roc_bphy_irq_chip *irq_chip,
 				       int irq_num);
 __roc_api int roc_bphy_intr_clear(struct roc_bphy_irq_chip *chip, int irq_num);
+__roc_api uint64_t roc_bphy_intr_max_get(struct roc_bphy_irq_chip *irq_chip);
 __roc_api int roc_bphy_intr_register(struct roc_bphy_irq_chip *irq_chip,
 				     struct roc_bphy_intr *intr);
 
drivers/common/cnxk/version.map +1 -0
index fff7902b25..ebc2ffeb85 100644
@@ -42,6 +42,7 @@ INTERNAL {
 	roc_bphy_intr_fini;
 	roc_bphy_intr_handler;
 	roc_bphy_intr_init;
+	roc_bphy_intr_max_get;
 	roc_bphy_intr_register;
 	roc_bphy_npa_pf_func_get;
 	roc_bphy_sso_pf_func_get;
drivers/raw/cnxk_bphy/cnxk_bphy_irq.c +1 -1
index 1fb3bf786b..a328029aad 100644
@@ -32,7 +32,7 @@ cnxk_bphy_irq_max_get(uint16_t dev_id)
 	bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
 	irq_chip = bphy_dev->irq_chip;
 
-	return irq_chip->max_irq;
+	return roc_bphy_intr_max_get(irq_chip);
 }
 
 int
Signature · 1 line
2.25.1
#3 lore raw
In reply to Tomasz Duszynski
Quoted 9 lines · Tomasz Duszynski

This series add some wrappers that simplify using
existing BPHY APIs.

Jakub Palider (1):
raw/cnxk_bphy: use roc calls for max irq

Tomasz Duszynski (1):
raw/cnxk_bphy: add wrappers for available message types

Series Acked-by: Jerin Jacob <[email protected]> Series applied to dpdk-next-net-mrvl/for-next-net. Thanks.

Quoted 13 lines
 drivers/common/cnxk/roc_bphy_irq.c         |   6 +
 drivers/common/cnxk/roc_bphy_irq.h         |   1 +
 drivers/common/cnxk/version.map            |   1 +
 drivers/raw/cnxk_bphy/cnxk_bphy.c          |  62 ++++--
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 125 ++---------
 drivers/raw/cnxk_bphy/cnxk_bphy_irq.c      |   2 +-
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h       | 245 +++++++++++++++------
 7 files changed, 245 insertions(+), 197 deletions(-)

--
2.25.1