Deleted Added
full compact
vnet.h (261650) vnet.h (274225)
1/*-
2 * Copyright (c) 2006-2009 University of Zagreb
3 * Copyright (c) 2006-2009 FreeBSD Foundation
4 * All rights reserved.
5 *
6 * This software was developed by the University of Zagreb and the
7 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
8 * FreeBSD Foundation.

--- 18 unchanged lines hidden (view full) ---

27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
1/*-
2 * Copyright (c) 2006-2009 University of Zagreb
3 * Copyright (c) 2006-2009 FreeBSD Foundation
4 * All rights reserved.
5 *
6 * This software was developed by the University of Zagreb and the
7 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
8 * FreeBSD Foundation.

--- 18 unchanged lines hidden (view full) ---

27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/net/vnet.h 261650 2014-02-09 08:13:17Z trociny $
35 * $FreeBSD: head/sys/net/vnet.h 274225 2014-11-07 09:39:05Z glebius $
36 */
37
38/*-
39 * This header file defines several sets of interfaces supporting virtualized
40 * network stacks:
41 *
42 * - Definition of 'struct vnet' and functions and macros to allocate/free/
43 * manipulate it.

--- 70 unchanged lines hidden (view full) ---

114static void \
115vnet_##name##_uninit(const void *unused) \
116{ \
117 VNET_PCPUSTAT_FREE(name); \
118} \
119VNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_PROTO_IFATTACHDOMAIN, \
120 SI_ORDER_ANY, vnet_ ## name ## _uninit, NULL)
121
36 */
37
38/*-
39 * This header file defines several sets of interfaces supporting virtualized
40 * network stacks:
41 *
42 * - Definition of 'struct vnet' and functions and macros to allocate/free/
43 * manipulate it.

--- 70 unchanged lines hidden (view full) ---

114static void \
115vnet_##name##_uninit(const void *unused) \
116{ \
117 VNET_PCPUSTAT_FREE(name); \
118} \
119VNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_PROTO_IFATTACHDOMAIN, \
120 SI_ORDER_ANY, vnet_ ## name ## _uninit, NULL)
121
122#ifdef SYSCTL_OID
122#define SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc) \
123static int \
124array##_sysctl(SYSCTL_HANDLER_ARGS) \
125{ \
126 type s; \
127 CTASSERT((sizeof(type) / sizeof(uint64_t)) == \
128 (sizeof(VNET(array)) / sizeof(counter_u64_t))); \
129 COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\
130 if (req->newptr) \
131 COUNTER_ARRAY_ZERO(VNET(array), \
132 sizeof(type) / sizeof(uint64_t)); \
133 return (SYSCTL_OUT(req, &s, sizeof(type))); \
134} \
123#define SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc) \
124static int \
125array##_sysctl(SYSCTL_HANDLER_ARGS) \
126{ \
127 type s; \
128 CTASSERT((sizeof(type) / sizeof(uint64_t)) == \
129 (sizeof(VNET(array)) / sizeof(counter_u64_t))); \
130 COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\
131 if (req->newptr) \
132 COUNTER_ARRAY_ZERO(VNET(array), \
133 sizeof(type) / sizeof(uint64_t)); \
134 return (SYSCTL_OUT(req, &s, sizeof(type))); \
135} \
135SYSCTL_VNET_PROC(parent, nbr, name, CTLTYPE_OPAQUE | CTLFLAG_RW, NULL, \
136 0, array ## _sysctl, "I", desc)
136SYSCTL_PROC(parent, nbr, name, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RW, \
137 NULL, 0, array ## _sysctl, "I", desc)
138#endif /* SYSCTL_OID */
137
138#ifdef VIMAGE
139#include <sys/lock.h>
140#include <sys/proc.h> /* for struct thread */
141#include <sys/rwlock.h>
142#include <sys/sx.h>
143
144/*

--- 133 unchanged lines hidden (view full) ---

278/*
279 * Virtual network stack allocator interfaces from the kernel linker.
280 */
281void *vnet_data_alloc(int size);
282void vnet_data_copy(void *start, int size);
283void vnet_data_free(void *start_arg, int size);
284
285/*
139
140#ifdef VIMAGE
141#include <sys/lock.h>
142#include <sys/proc.h> /* for struct thread */
143#include <sys/rwlock.h>
144#include <sys/sx.h>
145
146/*

--- 133 unchanged lines hidden (view full) ---

280/*
281 * Virtual network stack allocator interfaces from the kernel linker.
282 */
283void *vnet_data_alloc(int size);
284void vnet_data_copy(void *start, int size);
285void vnet_data_free(void *start_arg, int size);
286
287/*
286 * Sysctl variants for vnet-virtualized global variables. Include
287 * <sys/sysctl.h> to expose these definitions.
288 *
289 * Note: SYSCTL_PROC() handler functions will need to resolve pointer
290 * arguments themselves, if required.
291 */
292#ifdef SYSCTL_OID
293#define SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr) \
294 SYSCTL_OID(parent, nbr, name, \
295 CTLTYPE_INT|CTLFLAG_MPSAFE|CTLFLAG_VNET|(access), \
296 ptr, val, sysctl_handle_int, "I", descr)
297#define SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler, \
298 fmt, descr) \
299 CTASSERT(((access) & CTLTYPE) != 0); \
300 SYSCTL_OID(parent, nbr, name, CTLFLAG_VNET|(access), ptr, arg, \
301 handler, fmt, descr)
302#define SYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt, \
303 descr) \
304 SYSCTL_OID(parent, nbr, name, \
305 CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, len, \
306 sysctl_handle_opaque, fmt, descr)
307#define SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr) \
308 SYSCTL_OID(parent, nbr, name, \
309 CTLTYPE_STRING|CTLFLAG_VNET|(access), \
310 arg, len, sysctl_handle_string, "A", descr)
311#define SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) \
312 SYSCTL_OID(parent, nbr, name, \
313 CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, \
314 sizeof(struct type), sysctl_handle_opaque, "S," #type, \
315 descr)
316#define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \
317 SYSCTL_OID(parent, nbr, name, \
318 CTLTYPE_UINT|CTLFLAG_MPSAFE|CTLFLAG_VNET|(access), \
319 ptr, val, sysctl_handle_int, "IU", descr)
320#define VNET_SYSCTL_ARG(req, arg1) do { \
321 if (arg1 != NULL) \
322 arg1 = (void *)(TD_TO_VNET((req)->td)->vnet_data_base + \
323 (uintptr_t)(arg1)); \
324} while (0)
325#endif /* SYSCTL_OID */
326
327/*
328 * Virtual sysinit mechanism, allowing network stack components to declare
329 * startup and shutdown methods to be run when virtual network stack
330 * instances are created and destroyed.
331 */
332#include <sys/kernel.h>
333
334/*
335 * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and

--- 106 unchanged lines hidden (view full) ---

442 */
443#define VNET_VNET_PTR(vnet, n) (&(n))
444#define VNET_VNET(vnet, n) (n)
445
446#define VNET_PTR(n) (&(n))
447#define VNET(n) (n)
448
449/*
288 * Virtual sysinit mechanism, allowing network stack components to declare
289 * startup and shutdown methods to be run when virtual network stack
290 * instances are created and destroyed.
291 */
292#include <sys/kernel.h>
293
294/*
295 * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and

--- 106 unchanged lines hidden (view full) ---

402 */
403#define VNET_VNET_PTR(vnet, n) (&(n))
404#define VNET_VNET(vnet, n) (n)
405
406#define VNET_PTR(n) (&(n))
407#define VNET(n) (n)
408
409/*
450 * When VIMAGE isn't compiled into the kernel, virtaulized SYSCTLs simply
451 * become normal SYSCTLs.
452 */
453#ifdef SYSCTL_OID
454#define SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr) \
455 SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)
456#define SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler, \
457 fmt, descr) \
458 SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, \
459 descr)
460#define SYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt, \
461 descr) \
462 SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
463#define SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr) \
464 SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
465#define SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) \
466 SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr)
467#define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \
468 SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr)
469#define VNET_SYSCTL_ARG(req, arg1)
470#endif /* SYSCTL_OID */
471
472/*
473 * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT
474 * map into normal sysinits, which have the same ordering properties.
475 */
476#define VNET_SYSINIT(ident, subsystem, order, func, arg) \
477 SYSINIT(ident, subsystem, order, func, arg)
478#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \
479 SYSUNINIT(ident, subsystem, order, func, arg)
480
481/*
482 * Without VIMAGE revert to the default implementation.
483 */
484#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \
485 (tag) = eventhandler_register(NULL, #name, func, arg, priority)
486#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \
487 eventhandler_register(NULL, #name, func, arg, priority)
488#endif /* VIMAGE */
489#endif /* _KERNEL */
490
491#endif /* !_NET_VNET_H_ */
410 * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT
411 * map into normal sysinits, which have the same ordering properties.
412 */
413#define VNET_SYSINIT(ident, subsystem, order, func, arg) \
414 SYSINIT(ident, subsystem, order, func, arg)
415#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \
416 SYSUNINIT(ident, subsystem, order, func, arg)
417
418/*
419 * Without VIMAGE revert to the default implementation.
420 */
421#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \
422 (tag) = eventhandler_register(NULL, #name, func, arg, priority)
423#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \
424 eventhandler_register(NULL, #name, func, arg, priority)
425#endif /* VIMAGE */
426#endif /* _KERNEL */
427
428#endif /* !_NET_VNET_H_ */