1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
5 #include <rte_rawdev_pmd.h>
6 #include <rte_memzone.h>
7 #include <rte_common.h>
9 #include "ioat_private.h"
12 idxd_rawdev_close(struct rte_rawdev *dev __rte_unused)
18 idxd_dev_dump(struct rte_rawdev *dev, FILE *f)
20 struct idxd_rawdev *idxd = dev->dev_private;
21 struct rte_idxd_rawdev *rte_idxd = &idxd->public;
24 fprintf(f, "Raw Device #%d\n", dev->dev_id);
25 fprintf(f, "Driver: %s\n\n", dev->driver_name);
27 fprintf(f, "Portal: %p\n", rte_idxd->portal);
28 fprintf(f, "Batch Ring size: %u\n", rte_idxd->batch_ring_sz);
29 fprintf(f, "Comp Handle Ring size: %u\n\n", rte_idxd->hdl_ring_sz);
31 fprintf(f, "Next batch: %u\n", rte_idxd->next_batch);
32 fprintf(f, "Next batch to be completed: %u\n", rte_idxd->next_completed);
33 for (i = 0; i < rte_idxd->batch_ring_sz; i++) {
34 struct rte_idxd_desc_batch *b = &rte_idxd->batch_ring[i];
35 fprintf(f, "Batch %u @%p: submitted=%u, op_count=%u, hdl_end=%u\n",
36 i, b, b->submitted, b->op_count, b->hdl_end);
40 fprintf(f, "Next free hdl: %u\n", rte_idxd->next_free_hdl);
41 fprintf(f, "Last completed hdl: %u\n", rte_idxd->last_completed_hdl);
42 fprintf(f, "Next returned hdl: %u\n", rte_idxd->next_ret_hdl);
48 idxd_rawdev_create(const char *name, struct rte_device *dev,
49 const struct idxd_rawdev *base_idxd,
50 const struct rte_rawdev_ops *ops)
52 struct idxd_rawdev *idxd;
53 struct rte_rawdev *rawdev = NULL;
54 const struct rte_memzone *mz = NULL;
55 char mz_name[RTE_MEMZONE_NAMESIZE];
58 RTE_BUILD_BUG_ON(sizeof(struct rte_idxd_hw_desc) != 64);
59 RTE_BUILD_BUG_ON(offsetof(struct rte_idxd_hw_desc, size) != 32);
60 RTE_BUILD_BUG_ON(sizeof(struct rte_idxd_completion) != 32);
63 IOAT_PMD_ERR("Invalid name of the device!");
68 /* Allocate device structure */
69 rawdev = rte_rawdev_pmd_allocate(name, sizeof(struct idxd_rawdev),
72 IOAT_PMD_ERR("Unable to allocate raw device");
77 snprintf(mz_name, sizeof(mz_name), "rawdev%u_private", rawdev->dev_id);
78 mz = rte_memzone_reserve(mz_name, sizeof(struct idxd_rawdev),
79 dev->numa_node, RTE_MEMZONE_IOVA_CONTIG);
81 IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
85 rawdev->dev_private = mz->addr;
86 rawdev->dev_ops = ops;
88 rawdev->driver_name = IOAT_PMD_RAWDEV_NAME_STR;
90 idxd = rawdev->dev_private;
91 *idxd = *base_idxd; /* copy over the main fields already passed in */
92 idxd->rawdev = rawdev;
99 rte_rawdev_pmd_release(rawdev);