From: <jerinj@marvell.com>
To: <dev@dpdk.org>
Cc: <skoteshwar@marvell.com>, Vamsi Attunuru <vattunuru@marvell.com>
Subject: [dpdk-dev] [PATCH v1 4/9] raw/octeontx2_dma: add device close operation
Date: Sat, 1 Jun 2019 23:50:25 +0530 [thread overview]
Message-ID: <20190601182030.8282-5-jerinj@marvell.com> (raw)
In-Reply-To: <20190601182030.8282-1-jerinj@marvell.com>
From: Satha Rao <skoteshwar@marvell.com>
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>
---
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 33 +++++
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h | 133 ++++++++++++++++++++
2 files changed, 166 insertions(+)
diff --git a/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c b/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
index b418dc5bb..e7e30825f 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);
}
diff --git a/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h b/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
index 918ae725a..f59bab97f 100644
--- a/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
+++ b/drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
@@ -31,6 +31,32 @@
#define DPI_QUEUE_STOP 0x0
#define DPI_QUEUE_START 0x1
+#define DPI_VDMA_SADDR_REQ_IDLE 63
+#define DPI_MAX_POINTER 15
+#define STRM_INC(s) ((s)->tail = ((s)->tail + 1) % (s)->max_cnt)
+#define DPI_QFINISH_TIMEOUT (10 * 1000)
+
+/* DPI Transfer Type, pointer type in DPI_DMA_INSTR_HDR_S[XTYPE] */
+#define DPI_XTYPE_OUTBOUND (0)
+#define DPI_XTYPE_INBOUND (1)
+#define DPI_XTYPE_INTERNAL_ONLY (2)
+#define DPI_XTYPE_EXTERNAL_ONLY (3)
+#define DPI_XTYPE_MASK 0x3
+#define DPI_HDR_PT_ZBW_CA 0x0
+#define DPI_HDR_PT_ZBW_NC 0x1
+#define DPI_HDR_PT_WQP 0x2
+#define DPI_HDR_PT_WQP_NOSTATUS 0x0
+#define DPI_HDR_PT_WQP_STATUSCA 0x1
+#define DPI_HDR_PT_WQP_STATUSNC 0x3
+#define DPI_HDR_PT_CNT 0x3
+#define DPI_HDR_PT_MASK 0x3
+#define DPI_W0_TT_MASK 0x3
+#define DPI_W0_GRP_MASK 0x3FF
+/* Set Completion data to 0xFF when request submitted,
+ * upon successful request completion engine reset to completion status
+ */
+#define DPI_REQ_CDATA 0xFF
+
struct dpi_vf_s {
struct rte_pci_device *dev;
uint8_t state;
@@ -56,6 +82,113 @@ enum dpi_dma_queue_result_e {
DPI_DMA_QUEUE_INVALID_PARAM = -2,
};
+struct dpi_dma_req_compl_s {
+ uint64_t cdata;
+ void (*compl_cb)(void *dev, void *arg);
+ void *cb_data;
+};
+
+union dpi_dma_ptr_u {
+ uint64_t u[2];
+ struct dpi_dma_s {
+ uint64_t length:16;
+ uint64_t reserved:44;
+ uint64_t bed:1; /* Big-Endian */
+ uint64_t alloc_l2:1;
+ uint64_t full_write:1;
+ uint64_t invert:1;
+ uint64_t ptr;
+ } s;
+};
+
+struct dpi_dma_buf_ptr_s {
+ union dpi_dma_ptr_u *rptr[DPI_MAX_POINTER]; /* Read From pointer list */
+ union dpi_dma_ptr_u *wptr[DPI_MAX_POINTER]; /* Write to pointer list */
+ uint8_t rptr_cnt;
+ uint8_t wptr_cnt;
+ struct dpi_dma_req_compl_s *comp_ptr;
+};
+
+struct dpi_cring_data_s {
+ struct dpi_dma_req_compl_s **compl_data;
+ uint16_t max_cnt;
+ uint16_t head;
+ uint16_t tail;
+};
+
+struct dpi_dma_queue_ctx_s {
+ uint16_t xtype:2;
+
+ /* Completion pointer type */
+ uint16_t pt:2;
+
+ /* Completion updated using WQE */
+ uint16_t tt:2;
+ uint16_t grp:10;
+ uint32_t tag;
+
+ /* Valid only for Outbound only mode */
+ uint16_t aura:12;
+ uint16_t csel:1;
+ uint16_t ca:1;
+ uint16_t fi:1;
+ uint16_t ii:1;
+ uint16_t fl:1;
+
+ uint16_t pvfe:1;
+ uint16_t dealloce:1;
+ uint16_t req_type:2;
+ uint16_t use_lock:1;
+ uint16_t deallocv;
+
+ struct dpi_cring_data_s *c_ring;
+};
+
+/* DPI DMA Instruction Header Format */
+union dpi_dma_instr_hdr_u {
+ uint64_t u[4];
+
+ struct dpi_dma_instr_hdr_s_s {
+ uint64_t tag:32;
+ uint64_t tt:2;
+ uint64_t grp:10;
+ uint64_t reserved_44_47:4;
+ uint64_t nfst:4;
+ uint64_t reserved_52_53:2;
+ uint64_t nlst:4;
+ uint64_t reserved_58_63:6;
+ /* Word 0 - End */
+
+ uint64_t aura:12;
+ uint64_t reserved_76_79:4;
+ uint64_t deallocv:16;
+ uint64_t dealloce:1;
+ uint64_t pvfe:1;
+ uint64_t reserved_98_99:2;
+ uint64_t pt:2;
+ uint64_t reserved_102_103:2;
+ uint64_t fl:1;
+ uint64_t ii:1;
+ uint64_t fi:1;
+ uint64_t ca:1;
+ uint64_t csel:1;
+ uint64_t reserved_109_111:3;
+ uint64_t xtype:2;
+ uint64_t reserved_114_119:6;
+ uint64_t fport:2;
+ uint64_t reserved_122_123:2;
+ uint64_t lport:2;
+ uint64_t reserved_126_127:2;
+ /* Word 1 - End */
+
+ uint64_t ptr:64;
+ /* Word 2 - End */
+
+ uint64_t reserved_192_255:64;
+ /* Word 3 - End */
+ } s;
+};
+
int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
int otx2_dpi_queue_close(uint16_t vf_id);
--
2.21.0
next prev parent reply other threads:[~2019-06-01 18:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-01 18:20 [dpdk-dev] [PATCH v1 0/9] OCTEON TX2 DMA driver jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra and device probe jerinj
2019-06-03 11:17 ` Luca Boccassi
2019-06-06 8:32 ` Jerin Jacob Kollanukkaran
2019-06-06 8:49 ` Luca Boccassi
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 2/9] raw/octeontx2_dma: update probe function jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 3/9] raw/octeontx2_dma: add device configuration jerinj
2019-06-01 18:20 ` jerinj [this message]
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 5/9] raw/octeontx2_dma: add enqueue operation jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 6/9] raw/octeontx2_dma: add dequeue and device control operations jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 7/9] raw/octeontx2_dma: add driver self test jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 8/9] usertools: add octeontx2 DMA device jerinj
2019-06-01 18:20 ` [dpdk-dev] [PATCH v1 9/9] raw/octeontx2_dma: add documentation jerinj
2019-07-05 8:37 ` [dpdk-dev] [PATCH v2 0/8] OCTEON TX2 DMA driver jerinj
2019-07-05 8:37 ` [dpdk-dev] [PATCH v2 1/8] raw/octeontx2_dma: add build infra and device probe jerinj
2019-07-05 8:37 ` [dpdk-dev] [PATCH v2 2/8] raw/octeontx2_dma: update probe function jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 3/8] raw/octeontx2_dma: add device configuration jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 4/8] raw/octeontx2_dma: add device close operation jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 5/8] raw/octeontx2_dma: add enqueue operation jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 6/8] raw/octeontx2_dma: add dequeue and device control operations jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 7/8] raw/octeontx2_dma: add driver self test jerinj
2019-07-05 8:38 ` [dpdk-dev] [PATCH v2 8/8] usertools: add octeontx2 DMA device binding jerinj
2019-07-05 10:45 ` [dpdk-dev] [PATCH v2 0/8] OCTEON TX2 DMA driver Thomas Monjalon
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=20190601182030.8282-5-jerinj@marvell.com \
--to=jerinj@marvell.com \
--cc=dev@dpdk.org \
--cc=skoteshwar@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).