summaryrefslogtreecommitdiff
path: root/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
diff options
context:
space:
mode:
authorSatha Rao <skoteshwar@marvell.com>2019-07-05 14:08:01 +0530
committerThomas Monjalon <thomas@monjalon.net>2019-07-05 12:43:46 +0200
commitf613c52f7fb7386ede6d5e88b8c5fcdbbeb8de4d (patch)
tree6f03b1eabc80c953808c4ca95a9fc032191d5323 /drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
parent04b7dde74c3c72c08f2d9eef40da0f885a64da70 (diff)
downloaddpdk-f613c52f7fb7386ede6d5e88b8c5fcdbbeb8de4d.zip
dpdk-f613c52f7fb7386ede6d5e88b8c5fcdbbeb8de4d.tar.gz
dpdk-f613c52f7fb7386ede6d5e88b8c5fcdbbeb8de4d.tar.xz
raw/octeontx2_dma: add device close operation
Send message to PF to stop DMA queue when device close is called from application. Defined the required data structures to support enqueue and dequeue APIs. Signed-off-by: Satha Rao <skoteshwar@marvell.com> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Diffstat (limited to 'drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c')
-rw-r--r--drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c b/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
index 224c5e5..f9c330d 100644
--- a/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
+++ b/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
@@ -41,6 +41,34 @@ dma_engine_enb_dis(struct dpi_vf_s *dpivf, const bool enb)
return DPI_DMA_QUEUE_SUCCESS;
}
+/* Free DMA Queue instruction buffers, and send close notification to PF */
+static inline int
+dma_queue_finish(struct dpi_vf_s *dpivf)
+{
+ uint32_t timeout = 0, sleep = 1;
+ uint64_t reg = 0ULL;
+
+ /* Wait for SADDR to become idle */
+ reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+ while (!(reg & BIT_ULL(DPI_VDMA_SADDR_REQ_IDLE))) {
+ rte_delay_ms(sleep);
+ timeout++;
+ if (timeout >= DPI_QFINISH_TIMEOUT) {
+ otx2_dpi_dbg("Timeout!!! Closing Forcibly");
+ break;
+ }
+ reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+ }
+
+ if (otx2_dpi_queue_close(dpivf->vf_id) < 0)
+ return -EACCES;
+
+ rte_mempool_put(dpivf->chunk_pool, dpivf->base_ptr);
+ dpivf->vf_bar0 = (uintptr_t)NULL;
+
+ return DPI_DMA_QUEUE_SUCCESS;
+}
+
static int
otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
{
@@ -140,6 +168,7 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
{
char name[RTE_RAWDEV_NAME_MAX_LEN];
struct rte_rawdev *rawdev;
+ struct dpi_vf_s *dpivf;
if (pci_dev == NULL) {
otx2_dpi_dbg("Invalid pci_dev of the device!");
@@ -157,6 +186,10 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
return -EINVAL;
}
+ dpivf = (struct dpi_vf_s *)rawdev->dev_private;
+ dma_engine_enb_dis(dpivf, false);
+ dma_queue_finish(dpivf);
+
/* rte_rawdev_close is called by pmd_release */
return rte_rawdev_pmd_release(rawdev);
}