1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 #ifndef _LINUX_MODULEPARAM_H_ 32 #define _LINUX_MODULEPARAM_H_ 33 34 #include <sys/types.h> 35 #include <sys/sysctl.h> 36 37 #include <linux/types.h> 38 39 #ifndef LINUXKPI_PARAM_PARENT 40 #define LINUXKPI_PARAM_PARENT _compat_linuxkpi 41 #endif 42 43 #ifndef LINUXKPI_PARAM_PREFIX 44 #define LINUXKPI_PARAM_PREFIX /* empty prefix is the default */ 45 #endif 46 47 #ifndef LINUXKPI_PARAM_PERM 48 #define LINUXKPI_PARAM_PERM(perm) (((perm) & 0222) ? CTLFLAG_RWTUN : CTLFLAG_RDTUN) 49 #endif 50 51 #define LINUXKPI_PARAM_CONCAT_SUB(a,b,c,d) a##b##c##d 52 #define LINUXKPI_PARAM_CONCAT(...) LINUXKPI_PARAM_CONCAT_SUB(__VA_ARGS__) 53 #define LINUXKPI_PARAM_PASS(...) __VA_ARGS__ 54 #define LINUXKPI_PARAM_DESC(name) LINUXKPI_PARAM_CONCAT(linuxkpi_,LINUXKPI_PARAM_PREFIX,name,_desc) 55 #define LINUXKPI_PARAM_NAME(name) LINUXKPI_PARAM_CONCAT(LINUXKPI_PARAM_PREFIX,name,,) 56 57 #define LINUXKPI_PARAM_bool(name, var, perm) \ 58 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 59 LINUXKPI_PARAM_PASS(SYSCTL_BOOL(LINUXKPI_PARAM_PARENT, OID_AUTO,\ 60 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 61 LINUXKPI_PARAM_DESC(name))) 62 63 #define LINUXKPI_PARAM_byte(name, var, perm) \ 64 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 65 LINUXKPI_PARAM_PASS(SYSCTL_U8(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 66 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 67 LINUXKPI_PARAM_DESC(name))) 68 69 #define LINUXKPI_PARAM_short(name, var, perm) \ 70 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 71 LINUXKPI_PARAM_PASS(SYSCTL_S16(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 72 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 73 LINUXKPI_PARAM_DESC(name))) 74 75 #define LINUXKPI_PARAM_ushort(name, var, perm) \ 76 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 77 LINUXKPI_PARAM_PASS(SYSCTL_U16(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 78 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 79 LINUXKPI_PARAM_DESC(name))) 80 81 #define LINUXKPI_PARAM_int(name, var, perm) \ 82 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 83 LINUXKPI_PARAM_PASS(SYSCTL_INT(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 84 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0,\ 85 LINUXKPI_PARAM_DESC(name))) 86 87 #define LINUXKPI_PARAM_uint(name, var, perm) \ 88 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 89 LINUXKPI_PARAM_PASS(SYSCTL_UINT(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 90 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 91 LINUXKPI_PARAM_DESC(name))) 92 93 #define LINUXKPI_PARAM_long(name, var, perm) \ 94 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 95 LINUXKPI_PARAM_PASS(SYSCTL_LONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 96 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 97 LINUXKPI_PARAM_DESC(name))) 98 99 #define LINUXKPI_PARAM_ulong(name, var, perm) \ 100 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 101 LINUXKPI_PARAM_PASS(SYSCTL_ULONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 102 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \ 103 LINUXKPI_PARAM_DESC(name))) 104 105 #define module_param_string(name, str, len, perm) \ 106 extern const char LINUXKPI_PARAM_DESC(name)[]; \ 107 LINUXKPI_PARAM_PASS(SYSCTL_STRING(LINUXKPI_PARAM_PARENT, OID_AUTO, \ 108 LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), (str), (len), \ 109 LINUXKPI_PARAM_DESC(name))) 110 111 #define module_param_named(name, var, type, mode) \ 112 LINUXKPI_PARAM_##type(name, var, mode) 113 114 #define module_param(var, type, mode) \ 115 LINUXKPI_PARAM_##type(var, var, mode) 116 117 #define module_param_named_unsafe(name, var, type, mode) \ 118 LINUXKPI_PARAM_##type(name, var, mode) 119 120 #define module_param_unsafe(var, type, mode) \ 121 LINUXKPI_PARAM_##type(var, var, mode) 122 123 #define module_param_array(var, type, addr_argc, mode) 124 125 #define MODULE_PARM_DESC(name, desc) \ 126 const char LINUXKPI_PARAM_DESC(name)[] = { desc } 127 128 SYSCTL_DECL(_compat_linuxkpi); 129 130 #endif /* _LINUX_MODULEPARAM_H_ */ 131