[PATCH 6/6] VSOCK: header and config files.
VSOCK header files, Makefiles and Kconfig systems for Linux VSocket module. Signed-off-by: George Zhang georgezh...@vmware.com Acked-by: Andy king ack...@vmware.com Acked-by: Dmitry Torokhov d...@vmware.com --- Documentation/ioctl/ioctl-number.txt |1 include/linux/socket.h |4 net/Kconfig |1 net/Makefile |1 net/vmw_vsock/Kconfig| 14 + net/vmw_vsock/Makefile |4 net/vmw_vsock/notify_qstate.c| 408 ++ net/vmw_vsock/vmci_sockets.h | 270 +++ net/vmw_vsock/vmci_sockets_packet.h | 79 +++ net/vmw_vsock/vsock_common.h | 103 + net/vmw_vsock/vsock_packet.h | 92 net/vmw_vsock/vsock_version.h| 22 ++ 12 files changed, 998 insertions(+), 1 deletions(-) create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/notify_qstate.c create mode 100644 net/vmw_vsock/vmci_sockets.h create mode 100644 net/vmw_vsock/vmci_sockets_packet.h create mode 100644 net/vmw_vsock/vsock_common.h create mode 100644 net/vmw_vsock/vsock_packet.h create mode 100644 net/vmw_vsock/vsock_version.h diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 2152b0e..df2b341 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt @@ -70,6 +70,7 @@ Code Seq#(hex) Include FileComments 0x03 all linux/hdreg.h 0x04 D2-DC linux/umsdos_fs.h Dead since 2.6.11, but don't reuse these. 0x06 all linux/lp.h +0x07 9F-D0 linux/vmw_vmci_defs.h mailto:georgezh...@vmware.com 0x09 all linux/raid/md_u.h 0x10 00-0F drivers/char/s390/vmcp.h 0x12 all linux/fs.h diff --git a/include/linux/socket.h b/include/linux/socket.h index 9a546ff..2c57d63 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -178,7 +178,8 @@ struct ucred { #define AF_CAIF37 /* CAIF sockets */ #define AF_ALG 38 /* Algorithm sockets*/ #define AF_NFC 39 /* NFC sockets */ -#define AF_MAX 40 /* For now.. */ +#define AF_VSOCK 40 /* VMCI sockets */ +#define AF_MAX 41 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -221,6 +222,7 @@ struct ucred { #define PF_CAIFAF_CAIF #define PF_ALG AF_ALG #define PF_NFC AF_NFC +#define PF_VSOCK AF_VSOCK #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/net/Kconfig b/net/Kconfig index 30b48f5..f143ac3 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -218,6 +218,7 @@ source net/dcb/Kconfig source net/dns_resolver/Kconfig source net/batman-adv/Kconfig source net/openvswitch/Kconfig +source net/vmw_vsock/Kconfig config RPS boolean diff --git a/net/Makefile b/net/Makefile index 4f4ee08..cae59f4 100644 --- a/net/Makefile +++ b/net/Makefile @@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB)+= ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_NFC) += nfc/ obj-$(CONFIG_OPENVSWITCH) += openvswitch/ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock/ diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig new file mode 100644 index 000..95e2568 --- /dev/null +++ b/net/vmw_vsock/Kconfig @@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate Virtual Socket protocol + depends on VMWARE_VMCI + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N. diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile new file mode 100644 index 000..4e940fe --- /dev/null +++ b/net/vmw_vsock/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o + +vmw_vsock-y += af_vsock.o notify.o notify_qstate.o stats.o util.o \ + vsock_addr.o diff --git a/net/vmw_vsock/notify_qstate.c b/net/vmw_vsock/notify_qstate.c new file mode 100644 index 000..1132ae4 --- /dev/null +++ b/net/vmw_vsock/notify_qstate.c @@ -0,0 +1,408 @@ +/* + * VMware vSockets Driver + * + * Copyright (C) 2009-2012 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A
[PATCH 6/6] VSOCK: header and config files.
VSOCK header files, Makefiles and Kconfig systems for Linux VSocket module. Signed-off-by: George Zhang georgezh...@vmware.com --- include/linux/socket.h |4 net/Kconfig |1 net/Makefile|1 net/vmw_vsock/Kconfig | 14 + net/vmw_vsock/Makefile |4 net/vmw_vsock/notify_qstate.c | 627 +++ net/vmw_vsock/vmci_sockets.h| 517 + net/vmw_vsock/vmci_sockets_packet.h | 106 ++ net/vmw_vsock/vsock_common.h| 130 +++ net/vmw_vsock/vsock_packet.h| 131 +++ net/vmw_vsock/vsock_version.h | 29 ++ 11 files changed, 1563 insertions(+), 1 deletions(-) create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/notify_qstate.c create mode 100644 net/vmw_vsock/vmci_sockets.h create mode 100644 net/vmw_vsock/vmci_sockets_packet.h create mode 100644 net/vmw_vsock/vsock_common.h create mode 100644 net/vmw_vsock/vsock_packet.h create mode 100644 net/vmw_vsock/vsock_version.h diff --git a/include/linux/socket.h b/include/linux/socket.h index 25d6322..57bc85e 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -195,7 +195,8 @@ struct ucred { #define AF_CAIF37 /* CAIF sockets */ #define AF_ALG 38 /* Algorithm sockets*/ #define AF_NFC 39 /* NFC sockets */ -#define AF_MAX 40 /* For now.. */ +#define AF_VSOCK 40 /* VMCI sockets */ +#define AF_MAX 41 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -238,6 +239,7 @@ struct ucred { #define PF_CAIFAF_CAIF #define PF_ALG AF_ALG #define PF_NFC AF_NFC +#define PF_VSOCK AF_VSOCK #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/net/Kconfig b/net/Kconfig index 245831b..75b8d5e 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -216,6 +216,7 @@ source net/dcb/Kconfig source net/dns_resolver/Kconfig source net/batman-adv/Kconfig source net/openvswitch/Kconfig +source net/vmw_vsock/Kconfig config RPS boolean diff --git a/net/Makefile b/net/Makefile index 4f4ee08..cae59f4 100644 --- a/net/Makefile +++ b/net/Makefile @@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB)+= ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_NFC) += nfc/ obj-$(CONFIG_OPENVSWITCH) += openvswitch/ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock/ diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig new file mode 100644 index 000..95e2568 --- /dev/null +++ b/net/vmw_vsock/Kconfig @@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate Virtual Socket protocol + depends on VMWARE_VMCI + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N. diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile new file mode 100644 index 000..4e940fe --- /dev/null +++ b/net/vmw_vsock/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o + +vmw_vsock-y += af_vsock.o notify.o notify_qstate.o stats.o util.o \ + vsock_addr.o diff --git a/net/vmw_vsock/notify_qstate.c b/net/vmw_vsock/notify_qstate.c new file mode 100644 index 000..9cc4b58 --- /dev/null +++ b/net/vmw_vsock/notify_qstate.c @@ -0,0 +1,627 @@ +/* + * VMware vSockets Driver + * + * Copyright (C) 2009-2012 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +/* + * notifyQState.c -- + * + * Linux control notifications based on Queuepair state for the VMCI Stream + * Sockets protocol. + */ + +#include linux/types.h + +#include linux/socket.h + +#include linux/stddef.h /* for NULL */ +#include net/sock.h + +#include notify.h +#include af_vsock.h + +#define PKT_FIELD(vsk, field_name) \ + (vsk)-notify.pkt_q_state.field_name + +/* + * + * vsock_vmci_notify_waiting_write -- + * + * Determines if the conditions have been met to notify a waiting writer. + * + * Results: true if a notification should be sent, false otherwise. + * + * Side effects: None. + */ + +static bool
[PATCH 6/6] VSOCK: header and config files.
VSOCK header files, Makefiles and Kconfig systems for Linux VSocket module. Signed-off-by: George Zhang georgezh...@vmware.com --- include/linux/socket.h |4 net/Kconfig |1 net/Makefile|1 net/vmw_vsock/Kconfig | 14 + net/vmw_vsock/Makefile |4 net/vmw_vsock/notify_qstate.c | 627 +++ net/vmw_vsock/vmci_sockets.h| 517 + net/vmw_vsock/vmci_sockets_packet.h | 106 ++ net/vmw_vsock/vsock_common.h| 130 +++ net/vmw_vsock/vsock_packet.h| 131 +++ net/vmw_vsock/vsock_version.h | 29 ++ 11 files changed, 1563 insertions(+), 1 deletions(-) create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/notify_qstate.c create mode 100644 net/vmw_vsock/vmci_sockets.h create mode 100644 net/vmw_vsock/vmci_sockets_packet.h create mode 100644 net/vmw_vsock/vsock_common.h create mode 100644 net/vmw_vsock/vsock_packet.h create mode 100644 net/vmw_vsock/vsock_version.h diff --git a/include/linux/socket.h b/include/linux/socket.h index 25d6322..57bc85e 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -195,7 +195,8 @@ struct ucred { #define AF_CAIF37 /* CAIF sockets */ #define AF_ALG 38 /* Algorithm sockets*/ #define AF_NFC 39 /* NFC sockets */ -#define AF_MAX 40 /* For now.. */ +#define AF_VSOCK 40 /* VMCI sockets */ +#define AF_MAX 41 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -238,6 +239,7 @@ struct ucred { #define PF_CAIFAF_CAIF #define PF_ALG AF_ALG #define PF_NFC AF_NFC +#define PF_VSOCK AF_VSOCK #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/net/Kconfig b/net/Kconfig index 245831b..75b8d5e 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -216,6 +216,7 @@ source net/dcb/Kconfig source net/dns_resolver/Kconfig source net/batman-adv/Kconfig source net/openvswitch/Kconfig +source net/vmw_vsock/Kconfig config RPS boolean diff --git a/net/Makefile b/net/Makefile index 4f4ee08..cae59f4 100644 --- a/net/Makefile +++ b/net/Makefile @@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB)+= ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_NFC) += nfc/ obj-$(CONFIG_OPENVSWITCH) += openvswitch/ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock/ diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig new file mode 100644 index 000..95e2568 --- /dev/null +++ b/net/vmw_vsock/Kconfig @@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate Virtual Socket protocol + depends on VMWARE_VMCI + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N. diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile new file mode 100644 index 000..4e940fe --- /dev/null +++ b/net/vmw_vsock/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o + +vmw_vsock-y += af_vsock.o notify.o notify_qstate.o stats.o util.o \ + vsock_addr.o diff --git a/net/vmw_vsock/notify_qstate.c b/net/vmw_vsock/notify_qstate.c new file mode 100644 index 000..9cc4b58 --- /dev/null +++ b/net/vmw_vsock/notify_qstate.c @@ -0,0 +1,627 @@ +/* + * VMware vSockets Driver + * + * Copyright (C) 2009-2012 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +/* + * notifyQState.c -- + * + * Linux control notifications based on Queuepair state for the VMCI Stream + * Sockets protocol. + */ + +#include linux/types.h + +#include linux/socket.h + +#include linux/stddef.h /* for NULL */ +#include net/sock.h + +#include notify.h +#include af_vsock.h + +#define PKT_FIELD(vsk, field_name) \ + (vsk)-notify.pkt_q_state.field_name + +/* + * + * vsock_vmci_notify_waiting_write -- + * + * Determines if the conditions have been met to notify a waiting writer. + * + * Results: true if a notification should be sent, false otherwise. + * + * Side effects: None. + */ + +static bool
[PATCH 6/6] VSOCK: header and config files.
VSOCK header files, Makefiles and Kconfig systems for Linux VSocket module. Signed-off-by: George Zhang georgezh...@vmware.com --- net/Kconfig |1 net/Makefile|1 net/vmw_vsock/Kconfig | 14 + net/vmw_vsock/Makefile |8 net/vmw_vsock/notify_qstate.c | 670 +++ net/vmw_vsock/vmci_sockets.h| 517 +++ net/vmw_vsock/vmci_sockets_packet.h | 107 ++ net/vmw_vsock/vsock_common.h| 130 +++ net/vmw_vsock/vsock_packet.h| 131 +++ net/vmw_vsock/vsock_version.h | 29 ++ 10 files changed, 1608 insertions(+), 0 deletions(-) create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/notify_qstate.c create mode 100644 net/vmw_vsock/vmci_sockets.h create mode 100644 net/vmw_vsock/vmci_sockets_packet.h create mode 100644 net/vmw_vsock/vsock_common.h create mode 100644 net/vmw_vsock/vsock_packet.h create mode 100644 net/vmw_vsock/vsock_version.h diff --git a/net/Kconfig b/net/Kconfig index 245831b..75b8d5e 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -216,6 +216,7 @@ source net/dcb/Kconfig source net/dns_resolver/Kconfig source net/batman-adv/Kconfig source net/openvswitch/Kconfig +source net/vmw_vsock/Kconfig config RPS boolean diff --git a/net/Makefile b/net/Makefile index 4f4ee08..cae59f4 100644 --- a/net/Makefile +++ b/net/Makefile @@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB)+= ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_NFC) += nfc/ obj-$(CONFIG_OPENVSWITCH) += openvswitch/ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock/ diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig new file mode 100644 index 000..95e2568 --- /dev/null +++ b/net/vmw_vsock/Kconfig @@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate Virtual Socket protocol + depends on VMWARE_VMCI + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N. diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile new file mode 100644 index 000..8cb1e1c --- /dev/null +++ b/net/vmw_vsock/Makefile @@ -0,0 +1,8 @@ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o +ccflags-y += -I$(src)/shared +vmw_vsock-y += af_vsock.o +vmw_vsock-y += notify.o +vmw_vsock-y += notify_qstate.o +vmw_vsock-y += stats.o +vmw_vsock-y += util.o +vmw_vsock-y += vsock_addr.o diff --git a/net/vmw_vsock/notify_qstate.c b/net/vmw_vsock/notify_qstate.c new file mode 100644 index 000..fafb76c --- /dev/null +++ b/net/vmw_vsock/notify_qstate.c @@ -0,0 +1,670 @@ +/* + * VMware vSockets Driver + * + * Copyright (C) 2009-2012 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +/* + * notifyQState.c -- + * + * Linux control notifications based on Queuepair state for the VMCI Stream + * Sockets protocol. + */ + +#include linux/types.h + +#include linux/socket.h + +#include linux/stddef.h /* for NULL */ +#include net/sock.h + +#include notify.h +#include af_vsock.h + +#define PKT_FIELD(vsk, field_name) \ + (vsk)-notify.pkt_q_state.field_name + +/* + * + * vsock_vmci_notify_waiting_write -- + * + * Determines if the conditions have been met to notify a waiting writer. + * + * Results: true if a notification should be sent, false otherwise. + * + * Side effects: None. + */ + +static bool vsock_vmci_notify_waiting_write(vsock_vmci_sock *vsk) +{ + bool retval; + u64 notify_limit; + + if (!PKT_FIELD(vsk, peer_waiting_write)) + return false; + + /* +* When the sender blocks, we take that as a sign that the sender is +* faster than the receiver. To reduce the transmit rate of the sender, +* we delay the sending of the read notification by decreasing the +* write_notify_window. The notification is delayed until the number of +* bytes used in the queue drops below the write_notify_window. +*/ + + if (!PKT_FIELD(vsk, peer_waiting_write_detected)) { + PKT_FIELD(vsk, peer_waiting_write_detected) = true; + if (PKT_FIELD(vsk, write_notify_window) PAGE_SIZE) { + PKT_FIELD(vsk,