net/mlx5: add translation of connection tracking action
[dpdk.git] / drivers / raw / octeontx2_dma / otx2_dpi_rawdev.c
index a1d679f..8c01f25 100644 (file)
@@ -60,7 +60,7 @@ dma_queue_finish(struct dpi_vf_s *dpivf)
                reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
        }
 
-       if (otx2_dpi_queue_close(dpivf->vf_id) < 0)
+       if (otx2_dpi_queue_close(dpivf) < 0)
                return -EACCES;
 
        rte_mempool_put(dpivf->chunk_pool, dpivf->base_ptr);
@@ -201,6 +201,8 @@ otx2_dpi_rawdev_enqueue_bufs(struct rte_rawdev *dev,
                index += 4;
                hdr->s.fport = 0;
                hdr->s.lport = 0;
+               if (ctx->xtype !=  DPI_XTYPE_INTERNAL_ONLY)
+                       hdr->s.lport = ctx->pem_id;
 
                /* For inbound case, src pointers are last pointers.
                 * For all other cases, src pointers are first pointers.
@@ -234,8 +236,68 @@ otx2_dpi_rawdev_enqueue_bufs(struct rte_rawdev *dev,
        return c;
 }
 
+/* Check for command completion, returns number of commands completed */
 static int
-otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
+otx2_dpi_rawdev_dequeue_bufs(struct rte_rawdev *dev __rte_unused,
+                            struct rte_rawdev_buf **buffers,
+                            unsigned int count, rte_rawdev_obj_t context)
+{
+       struct dpi_dma_queue_ctx_s *ctx = (struct dpi_dma_queue_ctx_s *)context;
+       unsigned int i = 0, headp;
+
+       /* No completion ring to poll */
+       if (ctx->c_ring == NULL)
+               return 0;
+
+       headp = ctx->c_ring->head;
+       for (i = 0; i < count && (headp != ctx->c_ring->tail); i++) {
+               struct dpi_dma_req_compl_s *comp_ptr =
+                                        ctx->c_ring->compl_data[headp];
+
+               if (comp_ptr->cdata)
+                       break;
+
+               /* Request Completed */
+               buffers[i] = (void *)comp_ptr;
+               headp = (headp + 1) % ctx->c_ring->max_cnt;
+       }
+       ctx->c_ring->head = headp;
+
+       return i;
+}
+
+static int
+otx2_dpi_rawdev_start(struct rte_rawdev *dev)
+{
+       dev->started = DPI_QUEUE_START;
+
+       return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static void
+otx2_dpi_rawdev_stop(struct rte_rawdev *dev)
+{
+       dev->started = DPI_QUEUE_STOP;
+}
+
+static int
+otx2_dpi_rawdev_close(struct rte_rawdev *dev)
+{
+       dma_engine_enb_dis(dev->dev_private, false);
+       dma_queue_finish(dev->dev_private);
+
+       return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static int
+otx2_dpi_rawdev_reset(struct rte_rawdev *dev)
+{
+       return dev ? DPI_QUEUE_STOP : DPI_QUEUE_START;
+}
+
+static int
+otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config,
+               size_t config_size)
 {
        struct dpi_rawdev_conf_s *conf = config;
        struct dpi_vf_s *dpivf = NULL;
@@ -243,8 +305,8 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
        uintptr_t pool;
        uint32_t gaura;
 
-       if (conf == NULL) {
-               otx2_dpi_dbg("NULL configuration");
+       if (conf == NULL || config_size != sizeof(*conf)) {
+               otx2_dpi_dbg("NULL or invalid configuration");
                return -EINVAL;
        }
        dpivf = (struct dpi_vf_s *)dev->dev_private;
@@ -261,7 +323,7 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
        otx2_write64(0, dpivf->vf_bar0 + DPI_VDMA_REQQ_CTL);
        otx2_write64(((uint64_t)buf >> 7) << 7,
                     dpivf->vf_bar0 + DPI_VDMA_SADDR);
-       if (otx2_dpi_queue_open(dpivf->vf_id, DPI_CHUNK_SIZE, gaura) < 0) {
+       if (otx2_dpi_queue_open(dpivf, DPI_CHUNK_SIZE, gaura) < 0) {
                otx2_err("Unable to open DPI VF %d", dpivf->vf_id);
                rte_mempool_put(conf->chunk_pool, buf);
                return -EACCES;
@@ -273,7 +335,13 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 
 static const struct rte_rawdev_ops dpi_rawdev_ops = {
        .dev_configure = otx2_dpi_rawdev_configure,
+       .dev_start = otx2_dpi_rawdev_start,
+       .dev_stop = otx2_dpi_rawdev_stop,
+       .dev_close = otx2_dpi_rawdev_close,
+       .dev_reset = otx2_dpi_rawdev_reset,
        .enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
+       .dequeue_bufs = otx2_dpi_rawdev_dequeue_bufs,
+       .dev_selftest = test_otx2_dma_rawdev,
 };
 
 static int
@@ -321,6 +389,7 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
        vf_id = ((pci_dev->addr.devid & 0x1F) << 3) |
                 (pci_dev->addr.function & 0x7);
        vf_id -= 1;
+       dpivf->dev = pci_dev;
        dpivf->state = DPI_QUEUE_START;
        dpivf->vf_id = vf_id;
        dpivf->vf_bar0 = (uintptr_t)pci_dev->mem_resource[0].addr;
@@ -362,7 +431,7 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_dpi_rawdev_pmd = {
        .id_table  = pci_dma_map,
-       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
        .probe     = otx2_dpi_rawdev_probe,
        .remove    = otx2_dpi_rawdev_remove,
 };