1 /* 2 * GPL HEADER START 3 * 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 only, 8 * as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License version 2 for more details (a copy is included 14 * in the LICENSE file that accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License 17 * version 2 along with this program; If not, see 18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf 19 * 20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21 * CA 95054 USA or visit www.sun.com if you need additional information or 22 * have any questions. 23 * 24 * GPL HEADER END 25 */ 26 /* 27 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 /* 31 * This file is part of Lustre, http://www.lustre.org/ 32 * Lustre is a trademark of Sun Microsystems, Inc. 33 * 34 * Author: Nathan Rutman <nathan.rutman@sun.com> 35 * 36 * libcfs/include/libcfs/libcfs_kernelcomm.h 37 * 38 * Kernel <-> userspace communication routines. 39 * The definitions below are used in the kernel and userspace. 40 * 41 */ 42 43 #ifndef __LIBCFS_KERNELCOMM_H__ 44 #define __LIBCFS_KERNELCOMM_H__ 45 46 #ifndef __LIBCFS_LIBCFS_H__ 47 #error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead 48 #endif 49 50 /* KUC message header. 51 * All current and future KUC messages should use this header. 52 * To avoid having to include Lustre headers from libcfs, define this here. 53 */ 54 struct kuc_hdr { 55 __u16 kuc_magic; 56 __u8 kuc_transport; /* Each new Lustre feature should use a different 57 transport */ 58 __u8 kuc_flags; 59 __u16 kuc_msgtype; /* Message type or opcode, transport-specific */ 60 __u16 kuc_msglen; /* Including header */ 61 } __aligned(sizeof(__u64)); 62 63 #define KUC_CHANGELOG_MSG_MAXSIZE (sizeof(struct kuc_hdr)+CR_MAXSIZE) 64 65 #define KUC_MAGIC 0x191C /*Lustre9etLinC */ 66 #define KUC_FL_BLOCK 0x01 /* Wait for send */ 67 68 /* kuc_msgtype values are defined in each transport */ 69 enum kuc_transport_type { 70 KUC_TRANSPORT_GENERIC = 1, 71 KUC_TRANSPORT_HSM = 2, 72 KUC_TRANSPORT_CHANGELOG = 3, 73 }; 74 75 enum kuc_generic_message_type { 76 KUC_MSG_SHUTDOWN = 1, 77 }; 78 79 /* prototype for callback function on kuc groups */ 80 typedef int (*libcfs_kkuc_cb_t)(__u32 data, void *cb_arg); 81 82 /* KUC Broadcast Groups. This determines which userspace process hears which 83 * messages. Mutliple transports may be used within a group, or multiple 84 * groups may use the same transport. Broadcast 85 * groups need not be used if e.g. a UID is specified instead; 86 * use group 0 to signify unicast. 87 */ 88 #define KUC_GRP_HSM 0x02 89 #define KUC_GRP_MAX KUC_GRP_HSM 90 91 /* Kernel methods */ 92 int libcfs_kkuc_msg_put(struct file *fp, void *payload); 93 int libcfs_kkuc_group_put(int group, void *payload); 94 int libcfs_kkuc_group_add(struct file *fp, int uid, int group, 95 __u32 data); 96 int libcfs_kkuc_group_rem(int uid, int group); 97 int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, 98 void *cb_arg); 99 100 #define LK_FLG_STOP 0x01 101 102 /* kernelcomm control structure, passed from userspace to kernel */ 103 typedef struct lustre_kernelcomm { 104 __u32 lk_wfd; 105 __u32 lk_rfd; 106 __u32 lk_uid; 107 __u32 lk_group; 108 __u32 lk_data; 109 __u32 lk_flags; 110 } __packed lustre_kernelcomm; 111 112 /* Userspace methods */ 113 int libcfs_ukuc_start(lustre_kernelcomm *l, int groups); 114 int libcfs_ukuc_stop(lustre_kernelcomm *l); 115 int libcfs_ukuc_msg_get(lustre_kernelcomm *l, char *buf, int maxsize, 116 int transport); 117 118 #endif /* __LIBCFS_KERNELCOMM_H__ */ 119