~ubuntu-branches/ubuntu/trusty/drbd8/trusty

« back to all changes in this revision

Viewing changes to drbd/linux/connector.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-07-05 15:40:13 UTC
  • mfrom: (1.4.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110705154013-f9l32owj6mi9e1p0
Tags: 2:8.3.11-0ubuntu1
* New upstream release
* debian/patches/01_ubuntu_cn_idx.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *      connector.h
3
 
 * 
4
 
 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5
 
 * All rights reserved.
6
 
 * 
7
 
 * Modified by Philipp Reiser to work on older 2.6.x kernels.
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; either version 2 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with this program; if not, write to the Free Software
21
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 
 */
23
 
 
24
 
#ifndef __CONNECTOR_H
25
 
#define __CONNECTOR_H
26
 
#define DRBD_CONNECTOR_BACKPORT_HEADER
27
 
 
28
 
#include <asm/types.h>
29
 
 
30
 
#define NETLINK_CONNECTOR       11
31
 
 
32
 
#define CN_IDX_CONNECTOR                0xffffffff
33
 
#define CN_VAL_CONNECTOR                0xffffffff
34
 
 
35
 
/*
36
 
 * Process Events connector unique ids -- used for message routing
37
 
 */
38
 
#define CN_IDX_PROC                     0x1
39
 
#define CN_VAL_PROC                     0x1
40
 
#define CN_IDX_CIFS                     0x2
41
 
#define CN_VAL_CIFS                     0x1
42
 
 
43
 
#define CN_NETLINK_USERS                1
44
 
 
45
 
/*
46
 
 * Maximum connector's message size.
47
 
 */
48
 
#define CONNECTOR_MAX_MSG_SIZE  1024
49
 
 
50
 
/*
51
 
 * idx and val are unique identifiers which 
52
 
 * are used for message routing and 
53
 
 * must be registered in connector.h for in-kernel usage.
54
 
 */
55
 
 
56
 
struct cb_id {
57
 
        __u32 idx;
58
 
        __u32 val;
59
 
};
60
 
 
61
 
struct cn_msg {
62
 
        struct cb_id id;
63
 
 
64
 
        __u32 seq;
65
 
        __u32 ack;
66
 
 
67
 
        __u16 len;              /* Length of the following data */
68
 
        __u16 flags;
69
 
        __u8 data[0];
70
 
};
71
 
 
72
 
/*
73
 
 * Notify structure - requests notification about
74
 
 * registering/unregistering idx/val in range [first, first+range].
75
 
 */
76
 
struct cn_notify_req {
77
 
        __u32 first;
78
 
        __u32 range;
79
 
};
80
 
 
81
 
/*
82
 
 * Main notification control message
83
 
 * *_notify_num         - number of appropriate cn_notify_req structures after 
84
 
 *                              this struct.
85
 
 * group                - notification receiver's idx.
86
 
 * len                  - total length of the attached data.
87
 
 */
88
 
struct cn_ctl_msg {
89
 
        __u32 idx_notify_num;
90
 
        __u32 val_notify_num;
91
 
        __u32 group;
92
 
        __u32 len;
93
 
        __u8 data[0];
94
 
};
95
 
 
96
 
#ifdef __KERNEL__
97
 
#include <linux/drbd_config.h>
98
 
 
99
 
#ifndef KERNEL_HAS_GFP_T
100
 
#define KERNEL_HAS_GFP_T
101
 
typedef unsigned gfp_t;
102
 
#endif
103
 
 
104
 
#include <asm/atomic.h>
105
 
 
106
 
#include <linux/list.h>
107
 
#include <linux/workqueue.h>
108
 
 
109
 
#include <net/sock.h>
110
 
 
111
 
#define CN_CBQ_NAMELEN          32
112
 
 
113
 
struct cn_queue_dev {
114
 
        atomic_t refcnt;
115
 
        unsigned char name[CN_CBQ_NAMELEN];
116
 
 
117
 
        struct workqueue_struct *cn_queue;
118
 
 
119
 
        struct list_head queue_list;
120
 
        spinlock_t queue_lock;
121
 
 
122
 
        int netlink_groups;
123
 
        struct sock *nls;
124
 
};
125
 
 
126
 
struct cn_callback_id {
127
 
        unsigned char name[CN_CBQ_NAMELEN];
128
 
        struct cb_id id;
129
 
};
130
 
 
131
 
struct cn_callback_data {
132
 
        void (*destruct_data) (void *);
133
 
        void *ddata;
134
 
        
135
 
        void *callback_priv;
136
 
        void (*callback) (void *);
137
 
 
138
 
        void *free;
139
 
};
140
 
 
141
 
struct cn_callback_entry {
142
 
        struct list_head callback_entry;
143
 
        struct cn_callback *cb;
144
 
        struct work_struct work;
145
 
        struct cn_queue_dev *pdev;
146
 
 
147
 
        struct cn_callback_id id;
148
 
        struct cn_callback_data data;
149
 
 
150
 
        int seq, group;
151
 
        struct sock *nls;
152
 
};
153
 
 
154
 
struct cn_ctl_entry {
155
 
        struct list_head notify_entry;
156
 
        struct cn_ctl_msg *msg;
157
 
};
158
 
 
159
 
struct cn_dev {
160
 
        struct cb_id id;
161
 
 
162
 
        u32 seq, groups;
163
 
        struct sock *nls;
164
 
        void (*input) (struct sock * sk, int len);
165
 
 
166
 
        struct cn_queue_dev *cbdev;
167
 
};
168
 
 
169
 
int cn_add_callback(struct cb_id *, char *, void (*callback) (void *));
170
 
void cn_del_callback(struct cb_id *);
171
 
int cn_netlink_send(struct cn_msg *, u32, gfp_t);
172
 
 
173
 
int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *));
174
 
void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
175
 
 
176
 
struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *);
177
 
void cn_queue_free_dev(struct cn_queue_dev *dev);
178
 
 
179
 
int cn_cb_equal(struct cb_id *, struct cb_id *);
180
 
 
181
 
void cn_queue_wrapper(void *data);
182
 
 
183
 
extern int cn_already_initialized;
184
 
 
185
 
#endif                          /* __KERNEL__ */
186
 
#endif                          /* __CONNECTOR_H */