xref: /freebsd/sys/compat/linuxkpi/common/include/linux/moduleparam.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
18d59ecb2SHans Petter Selasky /*-
28d59ecb2SHans Petter Selasky  * Copyright (c) 2010 Isilon Systems, Inc.
38d59ecb2SHans Petter Selasky  * Copyright (c) 2010 iX Systems, Inc.
48d59ecb2SHans Petter Selasky  * Copyright (c) 2010 Panasas, Inc.
51d9b99e5SHans Petter Selasky  * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
68d59ecb2SHans Petter Selasky  * All rights reserved.
78d59ecb2SHans Petter Selasky  *
88d59ecb2SHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
98d59ecb2SHans Petter Selasky  * modification, are permitted provided that the following conditions
108d59ecb2SHans Petter Selasky  * are met:
118d59ecb2SHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
128d59ecb2SHans Petter Selasky  *    notice unmodified, this list of conditions, and the following
138d59ecb2SHans Petter Selasky  *    disclaimer.
148d59ecb2SHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
158d59ecb2SHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
168d59ecb2SHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
178d59ecb2SHans Petter Selasky  *
188d59ecb2SHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
198d59ecb2SHans Petter Selasky  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
208d59ecb2SHans Petter Selasky  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
218d59ecb2SHans Petter Selasky  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
228d59ecb2SHans Petter Selasky  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
238d59ecb2SHans Petter Selasky  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
248d59ecb2SHans Petter Selasky  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
258d59ecb2SHans Petter Selasky  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
268d59ecb2SHans Petter Selasky  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
278d59ecb2SHans Petter Selasky  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
288d59ecb2SHans Petter Selasky  */
29307f78f3SVladimir Kondratyev #ifndef	_LINUXKPI_LINUX_MODULEPARAM_H_
30307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_MODULEPARAM_H_
318d59ecb2SHans Petter Selasky 
321d9b99e5SHans Petter Selasky #include <sys/types.h>
331d9b99e5SHans Petter Selasky #include <sys/sysctl.h>
341d9b99e5SHans Petter Selasky 
358d59ecb2SHans Petter Selasky #include <linux/types.h>
368d59ecb2SHans Petter Selasky 
371d9b99e5SHans Petter Selasky #ifndef LINUXKPI_PARAM_PARENT
381d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_PARENT	_compat_linuxkpi
391d9b99e5SHans Petter Selasky #endif
408d59ecb2SHans Petter Selasky 
411d9b99e5SHans Petter Selasky #ifndef LINUXKPI_PARAM_PREFIX
421d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_PREFIX	/* empty prefix is the default */
431d9b99e5SHans Petter Selasky #endif
448d59ecb2SHans Petter Selasky 
4506ca64ecSHans Petter Selasky #ifndef LINUXKPI_PARAM_PERM
4606ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_PERM(perm) (((perm) & 0222) ? CTLFLAG_RWTUN : CTLFLAG_RDTUN)
4706ca64ecSHans Petter Selasky #endif
4806ca64ecSHans Petter Selasky 
491d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_CONCAT_SUB(a,b,c,d) a##b##c##d
501d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_CONCAT(...) LINUXKPI_PARAM_CONCAT_SUB(__VA_ARGS__)
511d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_PASS(...) __VA_ARGS__
521d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_DESC(name) LINUXKPI_PARAM_CONCAT(linuxkpi_,LINUXKPI_PARAM_PREFIX,name,_desc)
531d9b99e5SHans Petter Selasky #define	LINUXKPI_PARAM_NAME(name) LINUXKPI_PARAM_CONCAT(LINUXKPI_PARAM_PREFIX,name,,)
548d59ecb2SHans Petter Selasky 
5506ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_bool(name, var, perm)				\
560bb3dd30SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
570bb3dd30SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_BOOL(LINUXKPI_PARAM_PARENT, OID_AUTO,\
5806ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
590bb3dd30SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
600bb3dd30SHans Petter Selasky 
6106ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_byte(name, var, perm)				\
621d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
631d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_U8(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
6406ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
651d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
668d59ecb2SHans Petter Selasky 
6706ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_short(name, var, perm)				\
681d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
691d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_S16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
7006ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
711d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
728d59ecb2SHans Petter Selasky 
7306ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_ushort(name, var, perm)				\
741d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
751d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_U16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
7606ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
771d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
788d59ecb2SHans Petter Selasky 
7906ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_int(name, var, perm)				\
801d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
811d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_INT(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
8206ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0,\
831d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
848d59ecb2SHans Petter Selasky 
8506ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_uint(name, var, perm)				\
861d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
871d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_UINT(LINUXKPI_PARAM_PARENT, OID_AUTO, \
8806ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
891d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
908d59ecb2SHans Petter Selasky 
91*e101c1c2SJean-Sébastien Pédron #define	LINUXKPI_PARAM_bint(name, var, perm)				\
92*e101c1c2SJean-Sébastien Pédron 	LINUXKPI_PARAM_int(name, var, perm)
93*e101c1c2SJean-Sébastien Pédron 
940b8a423dSJean-Sébastien Pédron #define	LINUXKPI_PARAM_hexint(name, var, perm)				\
950b8a423dSJean-Sébastien Pédron 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
960b8a423dSJean-Sébastien Pédron 	LINUXKPI_PARAM_PASS(SYSCTL_UINT(LINUXKPI_PARAM_PARENT, OID_AUTO, \
970b8a423dSJean-Sébastien Pédron 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
980b8a423dSJean-Sébastien Pédron 	LINUXKPI_PARAM_DESC(name)))
990b8a423dSJean-Sébastien Pédron 
10006ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_long(name, var, perm)				\
1011d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
1021d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_LONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
10306ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
1041d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
1051d9b99e5SHans Petter Selasky 
10606ca64ecSHans Petter Selasky #define	LINUXKPI_PARAM_ulong(name, var, perm)				\
1071d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
1081d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_ULONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
10906ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
1101d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
1111d9b99e5SHans Petter Selasky 
112c1661d59SBjoern A. Zeeb #define	LINUXKPI_PARAM_charp(name, var, perm)				\
113c1661d59SBjoern A. Zeeb 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
114c1661d59SBjoern A. Zeeb 	LINUXKPI_PARAM_PASS(SYSCTL_STRING(LINUXKPI_PARAM_PARENT, OID_AUTO, \
115c1661d59SBjoern A. Zeeb 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
116c1661d59SBjoern A. Zeeb 	LINUXKPI_PARAM_DESC(name)))
117c1661d59SBjoern A. Zeeb 
1181d9b99e5SHans Petter Selasky #define	module_param_string(name, str, len, perm)			\
1191d9b99e5SHans Petter Selasky 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
1201d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_PASS(SYSCTL_STRING(LINUXKPI_PARAM_PARENT, OID_AUTO, \
12106ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), (str), (len), \
1221d9b99e5SHans Petter Selasky 	LINUXKPI_PARAM_DESC(name)))
1238d59ecb2SHans Petter Selasky 
1248d59ecb2SHans Petter Selasky #define	module_param_named(name, var, type, mode)	\
12506ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_##type(name, var, mode)
1268d59ecb2SHans Petter Selasky 
1278d59ecb2SHans Petter Selasky #define	module_param(var, type, mode)	\
12806ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_##type(var, var, mode)
1298d59ecb2SHans Petter Selasky 
130707324edSHans Petter Selasky #define	module_param_named_unsafe(name, var, type, mode) \
13106ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_##type(name, var, mode)
132707324edSHans Petter Selasky 
133707324edSHans Petter Selasky #define	module_param_unsafe(var, type, mode) \
13406ca64ecSHans Petter Selasky 	LINUXKPI_PARAM_##type(var, var, mode)
135707324edSHans Petter Selasky 
1361d9b99e5SHans Petter Selasky #define	module_param_array(var, type, addr_argc, mode)
1378d59ecb2SHans Petter Selasky 
1381d9b99e5SHans Petter Selasky #define	MODULE_PARM_DESC(name, desc) \
1391d9b99e5SHans Petter Selasky 	const char LINUXKPI_PARAM_DESC(name)[] = { desc }
1408d59ecb2SHans Petter Selasky 
14120789a72SHans Petter Selasky #define	kernel_param_lock(...) do {} while (0)
14220789a72SHans Petter Selasky #define	kernel_param_unlock(...) do {} while (0)
14320789a72SHans Petter Selasky 
1441d9b99e5SHans Petter Selasky SYSCTL_DECL(_compat_linuxkpi);
1458d59ecb2SHans Petter Selasky 
146307f78f3SVladimir Kondratyev #endif					/* _LINUXKPI_LINUX_MODULEPARAM_H_ */
147