6d790fd8befd71db22e03a11cca1903fb7c7dda4
[dpdk.git] / drivers / vdpa / sfc / sfc_vdpa_ops.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020-2021 Xilinx, Inc.
3  */
4
5 #ifndef _SFC_VDPA_OPS_H
6 #define _SFC_VDPA_OPS_H
7
8 #include <rte_vdpa.h>
9
10 #define SFC_VDPA_MAX_QUEUE_PAIRS                1
11
12 enum sfc_vdpa_context {
13         SFC_VDPA_AS_VF
14 };
15
16 enum sfc_vdpa_state {
17         SFC_VDPA_STATE_UNINITIALIZED = 0,
18         SFC_VDPA_STATE_INITIALIZED,
19         SFC_VDPA_STATE_CONFIGURING,
20         SFC_VDPA_STATE_CONFIGURED,
21         SFC_VDPA_STATE_CLOSING,
22         SFC_VDPA_STATE_CLOSED,
23         SFC_VDPA_STATE_STARTING,
24         SFC_VDPA_STATE_STARTED,
25         SFC_VDPA_STATE_STOPPING,
26 };
27
28 struct sfc_vdpa_vring_info {
29         uint64_t        desc;
30         uint64_t        avail;
31         uint64_t        used;
32         uint64_t        size;
33         uint16_t        last_avail_idx;
34         uint16_t        last_used_idx;
35 };
36
37 typedef struct sfc_vdpa_vq_context_s {
38         uint8_t                         enable;
39         uint32_t                        pidx;
40         uint32_t                        cidx;
41         efx_virtio_vq_t                 *vq;
42 } sfc_vdpa_vq_context_t;
43
44 struct sfc_vdpa_ops_data {
45         void                            *dev_handle;
46         int                             vid;
47         struct rte_vdpa_device          *vdpa_dev;
48         enum sfc_vdpa_context           vdpa_context;
49         enum sfc_vdpa_state             state;
50         pthread_t                       notify_tid;
51         bool                            is_notify_thread_started;
52
53         uint64_t                        dev_features;
54         uint64_t                        drv_features;
55         uint64_t                        req_features;
56
57         uint16_t                        vq_count;
58         struct sfc_vdpa_vq_context_s    vq_cxt[SFC_VDPA_MAX_QUEUE_PAIRS * 2];
59 };
60
61 struct sfc_vdpa_ops_data *
62 sfc_vdpa_device_init(void *adapter, enum sfc_vdpa_context context);
63 void
64 sfc_vdpa_device_fini(struct sfc_vdpa_ops_data *ops_data);
65
66 #endif /* _SFC_VDPA_OPS_H */