1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020-2021 Xilinx, Inc.
5 #include <rte_malloc.h>
9 #include <vdpa_driver.h>
11 #include "sfc_vdpa_ops.h"
14 /* Dummy functions for mandatory vDPA ops to pass vDPA device registration.
15 * In subsequent patches these ops would be implemented.
18 sfc_vdpa_get_queue_num(struct rte_vdpa_device *vdpa_dev, uint32_t *queue_num)
20 RTE_SET_USED(vdpa_dev);
21 RTE_SET_USED(queue_num);
27 sfc_vdpa_get_features(struct rte_vdpa_device *vdpa_dev, uint64_t *features)
29 RTE_SET_USED(vdpa_dev);
30 RTE_SET_USED(features);
36 sfc_vdpa_get_protocol_features(struct rte_vdpa_device *vdpa_dev,
39 RTE_SET_USED(vdpa_dev);
40 RTE_SET_USED(features);
46 sfc_vdpa_dev_config(int vid)
54 sfc_vdpa_dev_close(int vid)
62 sfc_vdpa_set_vring_state(int vid, int vring, int state)
72 sfc_vdpa_set_features(int vid)
79 static struct rte_vdpa_dev_ops sfc_vdpa_ops = {
80 .get_queue_num = sfc_vdpa_get_queue_num,
81 .get_features = sfc_vdpa_get_features,
82 .get_protocol_features = sfc_vdpa_get_protocol_features,
83 .dev_conf = sfc_vdpa_dev_config,
84 .dev_close = sfc_vdpa_dev_close,
85 .set_vring_state = sfc_vdpa_set_vring_state,
86 .set_features = sfc_vdpa_set_features,
89 struct sfc_vdpa_ops_data *
90 sfc_vdpa_device_init(void *dev_handle, enum sfc_vdpa_context context)
92 struct sfc_vdpa_ops_data *ops_data;
93 struct rte_pci_device *pci_dev;
95 /* Create vDPA ops context */
96 ops_data = rte_zmalloc("vdpa", sizeof(struct sfc_vdpa_ops_data), 0);
100 ops_data->vdpa_context = context;
101 ops_data->dev_handle = dev_handle;
103 pci_dev = sfc_vdpa_adapter_by_dev_handle(dev_handle)->pdev;
105 /* Register vDPA Device */
106 sfc_vdpa_log_init(dev_handle, "register vDPA device");
108 rte_vdpa_register_device(&pci_dev->device, &sfc_vdpa_ops);
109 if (ops_data->vdpa_dev == NULL) {
110 sfc_vdpa_err(dev_handle, "vDPA device registration failed");
111 goto fail_register_device;
114 ops_data->state = SFC_VDPA_STATE_INITIALIZED;
118 fail_register_device:
124 sfc_vdpa_device_fini(struct sfc_vdpa_ops_data *ops_data)
126 rte_vdpa_unregister_device(ops_data->vdpa_dev);