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