replace zero-length arrays with flexible ones
[dpdk.git] / lib / vhost / vhost_user.h
index 16fe03f..c4d091e 100644 (file)
@@ -50,6 +50,8 @@ typedef enum VhostUserRequest {
        VHOST_USER_NET_SET_MTU = 20,
        VHOST_USER_SET_SLAVE_REQ_FD = 21,
        VHOST_USER_IOTLB_MSG = 22,
+       VHOST_USER_GET_CONFIG = 24,
+       VHOST_USER_SET_CONFIG = 25,
        VHOST_USER_CRYPTO_CREATE_SESS = 26,
        VHOST_USER_CRYPTO_CLOSE_SESS = 27,
        VHOST_USER_POSTCOPY_ADVISE = 28,
@@ -59,7 +61,6 @@ typedef enum VhostUserRequest {
        VHOST_USER_SET_INFLIGHT_FD = 32,
        VHOST_USER_SET_STATUS = 39,
        VHOST_USER_GET_STATUS = 40,
-       VHOST_USER_MAX = 41
 } VhostUserRequest;
 
 typedef enum VhostUserSlaveRequest {
@@ -67,7 +68,6 @@ typedef enum VhostUserSlaveRequest {
        VHOST_USER_SLAVE_IOTLB_MSG = 1,
        VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2,
        VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
-       VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
 
 typedef struct VhostUserMemoryRegion {
@@ -125,6 +125,16 @@ typedef struct VhostUserInflight {
        uint16_t queue_size;
 } VhostUserInflight;
 
+#define VHOST_USER_MAX_CONFIG_SIZE             256
+
+/** Get/set config msg payload */
+struct vhost_user_config {
+       uint32_t offset;
+       uint32_t size;
+       uint32_t flags;
+       uint8_t region[VHOST_USER_MAX_CONFIG_SIZE];
+};
+
 typedef struct VhostUserMsg {
        union {
                uint32_t master; /* a VhostUserRequest value */
@@ -148,10 +158,19 @@ typedef struct VhostUserMsg {
                VhostUserCryptoSessionParam crypto_session;
                VhostUserVringArea area;
                VhostUserInflight inflight;
+               struct vhost_user_config cfg;
        } payload;
+       /* Nothing should be added after the payload */
+} __rte_packed VhostUserMsg;
+
+/* Note: this structure and VhostUserMsg can't be changed carelessly as
+ * external message handlers rely on them.
+ */
+struct __rte_packed vhu_msg_context {
+       VhostUserMsg msg;
        int fds[VHOST_MEMORY_MAX_NREGIONS];
        int fd_num;
-} __rte_packed VhostUserMsg;
+};
 
 #define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)
 
@@ -164,8 +183,8 @@ int vhost_user_msg_handler(int vid, int fd);
 int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
 
 /* socket.c */
-int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
+int read_fd_message(char *ifname, int sockfd, char *buf, int buflen, int *fds, int max_fds,
                int *fd_num);
-int send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num);
+int send_fd_message(char *ifname, int sockfd, char *buf, int buflen, int *fds, int fd_num);
 
 #endif