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