Skip to content

Commit

Permalink
driver: vservices: Add the vservices framework and core
Browse files Browse the repository at this point in the history
Adds the Virtual Services framework and core protocol code.

The Virtual Services framework provides a bus for generic inter-vm
communications using a high level abstract model. The vservices
bus provides support for both HLOS and embedded C clients and servers,
allowing VMs to communicate in a common OS independent manner.

The vservices bus and services over it are hot-plug capable and
can support a wide variety of use cases, including device virtualization
using virtual device protocol (classes) and drivers, similar in
concept to USB or virtio.

Change-Id: I7a696354f59730e0ad340fb92dc85661a7376dee
Signed-off-by: Carl van Schaik <carl@cog.systems>
Git-commit: 42814676e8bf5fb34060ee80e05e2175ae146292
Git-repo: https://github.com/CogSystems/linux-msm/commits/msm-4.9-hyp
[mnalajal@codeaurora: Resolve trivial merge conflicts]
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
  • Loading branch information
navlrac authored and Murali Nalajala committed Nov 20, 2018
1 parent f1d9da1 commit 465e06d
Show file tree
Hide file tree
Showing 39 changed files with 11,658 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ source "drivers/hv/Kconfig"

source "drivers/xen/Kconfig"

source "drivers/vservices/Kconfig"

source "drivers/staging/Kconfig"

source "drivers/platform/Kconfig"
Expand Down
2 changes: 2 additions & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ obj-y += bus/

obj-$(CONFIG_GENERIC_PHY) += phy/

obj-$(CONFIG_VSERVICES_SUPPORT) += vservices/

# GPIO must come after pinctrl as gpios may need to mux pins etc
obj-$(CONFIG_PINCTRL) += pinctrl/
obj-$(CONFIG_GPIOLIB) += gpio/
Expand Down
81 changes: 81 additions & 0 deletions drivers/vservices/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# OKL4 Virtual Services framework
#

menuconfig VSERVICES_SUPPORT
tristate "OKL4 Virtual Services support"
default OKL4_GUEST || OKL4_VIRTUALISATION
select HOTPLUG
help
This option adds core support for OKL4 Virtual Services. The Virtual
Services framework is an inter-OS device/service sharing
protocol which is supported on OKL4 Microvisor virtualization
platforms. You will also need drivers from the following menu in
order to make use of it.

if VSERVICES_SUPPORT

config VSERVICES_CHAR_DEV
bool "Virtual Services user-space service API"
default y
help
Select this if you want to use user-space service drivers. You will
also need udev rules that create device nodes, and protocol code
generated by the OK Mill tool.

config VSERVICES_DEBUG
bool "Virtual Services debugging support"
help
Select this if you want to enable Virtual Services core framework
debugging. The debug messages for various components of the Virtual
Services core framework can be toggled at runtime on a per-session
basis via sysfs. When Virtual Services debugging is enabled here,
but disabled at runtime it has a minimal performance impact.

config VSERVICES_LOCK_DEBUG
bool "Debug Virtual Services state locks"
default DEBUG_KERNEL
help
This option enables some runtime checks that Virtual Services
state lock functions are used correctly in service drivers.

config VSERVICES_SERVER
tristate "Virtual Services server support"
depends on SYSFS
default y
help
This option adds support for Virtual Services servers, which allows
exporting of services from this Linux to other environments. Servers
are created at runtime by writing to files in
/sys/bus/vservices-server.

config VSERVICES_CLIENT
tristate "Virtual Services client support"
default y
help
This option adds support for Virtual Services clients, which allows
connecting to services exported from other environments.

config VSERVICES_SKELETON_DRIVER
tristate "Virtual Services skeleton driver"
depends on VSERVICES_SERVER || VSERVICES_CLIENT
default n
help
This option adds support for a skeleton virtual service driver. This
driver can be used for templating or testing of virtual service
drivers. If unsure say N.

config VSERVICES_NAMED_DEVICE
bool "Virtual Services use named device node in /dev"
default n
help
Select this if you want to use a named device name over a numeric
device name in /dev

source "drivers/vservices/transport/Kconfig"

source "drivers/vservices/protocol/Kconfig"

source "drivers/vservices/Kconfig.stacks"

endif # VSERVICES_SUPPORT
7 changes: 7 additions & 0 deletions drivers/vservices/Kconfig.stacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# vServices drivers configuration
#

menu "Client and Server drivers"

endmenu
14 changes: 14 additions & 0 deletions drivers/vservices/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ccflags-y += -Werror
ccflags-$(CONFIG_VSERVICES_DEBUG) += -DDEBUG

obj-$(CONFIG_VSERVICES_SUPPORT) += vservices.o
vservices-objs-$(CONFIG_VSERVICES_CHAR_DEV) += devio.o
vservices-objs = session.o $(vservices-objs-y)

obj-$(CONFIG_VSERVICES_CLIENT) += core_client.o
obj-$(CONFIG_VSERVICES_SERVER) += core_server.o

obj-$(CONFIG_VSERVICES_SKELETON_DRIVER) += vservices_skeleton_driver.o
vservices_skeleton_driver-objs = skeleton_driver.o

obj-$(CONFIG_VSERVICES_SUPPORT) += protocol/
59 changes: 59 additions & 0 deletions drivers/vservices/compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* drivers/vservices/compat.h
*
* Copyright (c) 2012-2018 General Dynamics
* Copyright (c) 2014 Open Kernel Labs, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Wrapper functions/definitions for compatibility between differnet kernel
* versions.
*/

#ifndef _VSERVICES_COMPAT_H
#define _VSERVICES_COMPAT_H

#include <linux/workqueue.h>
#include <linux/version.h>

/* The INIT_WORK_ONSTACK macro has a slightly different name in older kernels */
#ifndef INIT_WORK_ONSTACK
#define INIT_WORK_ONSTACK(_work, _func) INIT_WORK_ON_STACK(_work, _func)
#endif

/*
* We require a workqueue with no concurrency. This is provided by
* create_singlethread_workqueue() in kernel prior to 2.6.36.
* In later versions, create_singlethread_workqueue() enables WQ_MEM_RECLAIM and
* thus WQ_RESCUER, which allows work items to be grabbed by a rescuer thread
* and run concurrently if the queue is running too slowly. We must use
* alloc_ordered_workqueue() instead, to disable the rescuer.
*/
static inline struct workqueue_struct *
vs_create_workqueue(const char *name)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
return create_singlethread_workqueue(name);
#else
return alloc_ordered_workqueue(name, 0);
#endif
}

/*
* The max3 macro has only been present from 2.6.37
* (commit: f27c85c56b32c42bcc54a43189c1e00fdceb23ec)
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
#define max3(x, y, z) ({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
typeof(z) _max3 = (z); \
(void) (&_max1 == &_max2); \
(void) (&_max1 == &_max3); \
_max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
(_max2 > _max3 ? _max2 : _max3); })
#endif

#endif /* _VSERVICES_COMPAT_H */
Loading

0 comments on commit 465e06d

Please sign in to comment.