]> git.proxmox.com Git - ceph.git/blame - ceph/src/seastar/dpdk/drivers/net/virtio/virtio_user/virtio_user_dev.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / virtio / virtio_user / virtio_user_dev.h
CommitLineData
9f95a23c
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
7c673cae
FG
3 */
4
5#ifndef _VIRTIO_USER_DEV_H
6#define _VIRTIO_USER_DEV_H
7
8#include <limits.h>
9f95a23c 9#include <stdbool.h>
7c673cae
FG
10#include "../virtio_pci.h"
11#include "../virtio_ring.h"
11fdf7f2 12#include "vhost.h"
7c673cae 13
9f95a23c
TL
14struct virtio_user_queue {
15 uint16_t used_idx;
16 bool avail_wrap_counter;
17 bool used_wrap_counter;
18};
19
7c673cae 20struct virtio_user_dev {
11fdf7f2 21 /* for vhost_user backend */
7c673cae 22 int vhostfd;
9f95a23c
TL
23 int listenfd; /* listening fd */
24 bool is_server; /* server or client mode */
11fdf7f2
TL
25
26 /* for vhost_kernel backend */
27 char *ifname;
28 int *vhostfds;
29 int *tapfds;
30
31 /* for both vhost_user and vhost_kernel */
32 int callfds[VIRTIO_MAX_VIRTQUEUES];
33 int kickfds[VIRTIO_MAX_VIRTQUEUES];
7c673cae
FG
34 int mac_specified;
35 uint32_t max_queue_pairs;
36 uint32_t queue_pairs;
37 uint32_t queue_size;
11fdf7f2
TL
38 uint64_t features; /* the negotiated features with driver,
39 * and will be sync with device
40 */
41 uint64_t device_features; /* supported features by device */
9f95a23c
TL
42 uint64_t frontend_features; /* enabled frontend features */
43 uint64_t unsupported_features; /* unsupported features mask */
7c673cae 44 uint8_t status;
9f95a23c 45 uint16_t port_id;
7c673cae
FG
46 uint8_t mac_addr[ETHER_ADDR_LEN];
47 char path[PATH_MAX];
9f95a23c
TL
48 union {
49 struct vring vrings[VIRTIO_MAX_VIRTQUEUES];
50 struct vring_packed packed_vrings[VIRTIO_MAX_VIRTQUEUES];
51 };
52 struct virtio_user_queue packed_queues[VIRTIO_MAX_VIRTQUEUES];
53
11fdf7f2 54 struct virtio_user_backend_ops *ops;
9f95a23c
TL
55 pthread_mutex_t mutex;
56 bool started;
7c673cae
FG
57};
58
11fdf7f2 59int is_vhost_user_by_type(const char *path);
7c673cae
FG
60int virtio_user_start_device(struct virtio_user_dev *dev);
61int virtio_user_stop_device(struct virtio_user_dev *dev);
62int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
9f95a23c
TL
63 int cq, int queue_size, const char *mac, char **ifname,
64 int server, int mrg_rxbuf, int in_order,
65 int packed_vq);
7c673cae
FG
66void virtio_user_dev_uninit(struct virtio_user_dev *dev);
67void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
9f95a23c
TL
68void virtio_user_handle_cq_packed(struct virtio_user_dev *dev,
69 uint16_t queue_idx);
70uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
7c673cae 71#endif