]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/infiniband/ulp/ipoib/ipoib.h
[IPoIB] remove unneeded initializations to 0
[mirror_ubuntu-bionic-kernel.git] / drivers / infiniband / ulp / ipoib / ipoib.h
CommitLineData
1da177e4
LT
1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
2a1d9b7f
RD
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
1da177e4
LT
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 *
34 * $Id: ipoib.h 1358 2004-12-17 22:00:11Z roland $
35 */
36
37#ifndef _IPOIB_H
38#define _IPOIB_H
39
40#include <linux/list.h>
41#include <linux/skbuff.h>
42#include <linux/netdevice.h>
43#include <linux/workqueue.h>
44#include <linux/pci.h>
45#include <linux/config.h>
46#include <linux/kref.h>
47#include <linux/if_infiniband.h>
48
49#include <net/neighbour.h>
50
51#include <asm/atomic.h>
52#include <asm/semaphore.h>
53
a4d61e84
RD
54#include <rdma/ib_verbs.h>
55#include <rdma/ib_pack.h>
56#include <rdma/ib_sa.h>
1da177e4
LT
57
58/* constants */
59
60enum {
61 IPOIB_PACKET_SIZE = 2048,
62 IPOIB_BUF_SIZE = IPOIB_PACKET_SIZE + IB_GRH_BYTES,
63
64 IPOIB_ENCAP_LEN = 4,
65
66 IPOIB_RX_RING_SIZE = 128,
67 IPOIB_TX_RING_SIZE = 64,
68
69 IPOIB_NUM_WC = 4,
70
71 IPOIB_MAX_PATH_REC_QUEUE = 3,
72 IPOIB_MAX_MCAST_QUEUE = 3,
73
74 IPOIB_FLAG_OPER_UP = 0,
75 IPOIB_FLAG_ADMIN_UP = 1,
76 IPOIB_PKEY_ASSIGNED = 2,
77 IPOIB_PKEY_STOP = 3,
78 IPOIB_FLAG_SUBINTERFACE = 4,
79 IPOIB_MCAST_RUN = 5,
80 IPOIB_STOP_REAPER = 6,
81
82 IPOIB_MAX_BACKOFF_SECONDS = 16,
83
84 IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */
85 IPOIB_MCAST_FLAG_SENDONLY = 1,
86 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
87 IPOIB_MCAST_FLAG_ATTACHED = 3,
88};
89
90/* structs */
91
92struct ipoib_header {
97f52eb4
SH
93 __be16 proto;
94 u16 reserved;
1da177e4
LT
95};
96
97struct ipoib_pseudoheader {
98 u8 hwaddr[INFINIBAND_ALEN];
99};
100
101struct ipoib_mcast;
102
1993d683
RD
103struct ipoib_rx_buf {
104 struct sk_buff *skb;
105 dma_addr_t mapping;
106};
107
108struct ipoib_tx_buf {
1da177e4
LT
109 struct sk_buff *skb;
110 DECLARE_PCI_UNMAP_ADDR(mapping)
111};
112
113/*
114 * Device private locking: tx_lock protects members used in TX fast
115 * path (and we use LLTX so upper layers don't do extra locking).
116 * lock protects everything else. lock nests inside of tx_lock (ie
117 * tx_lock must be acquired first if needed).
118 */
119struct ipoib_dev_priv {
120 spinlock_t lock;
121
122 struct net_device *dev;
123
124 unsigned long flags;
125
126 struct semaphore mcast_mutex;
127 struct semaphore vlan_mutex;
128
129 struct rb_root path_tree;
130 struct list_head path_list;
131
132 struct ipoib_mcast *broadcast;
133 struct list_head multicast_list;
134 struct rb_root multicast_tree;
135
136 struct work_struct pkey_task;
137 struct work_struct mcast_task;
138 struct work_struct flush_task;
139 struct work_struct restart_task;
140 struct work_struct ah_reap_task;
141
142 struct ib_device *ca;
143 u8 port;
144 u16 pkey;
145 struct ib_pd *pd;
146 struct ib_mr *mr;
147 struct ib_cq *cq;
148 struct ib_qp *qp;
149 u32 qkey;
150
151 union ib_gid local_gid;
152 u16 local_lid;
153 u8 local_rate;
154
155 unsigned int admin_mtu;
156 unsigned int mcast_mtu;
157
1993d683 158 struct ipoib_rx_buf *rx_ring;
1da177e4 159
1993d683
RD
160 spinlock_t tx_lock;
161 struct ipoib_tx_buf *tx_ring;
162 unsigned tx_head;
163 unsigned tx_tail;
164 struct ib_sge tx_sge;
165 struct ib_send_wr tx_wr;
1da177e4
LT
166
167 struct ib_wc ibwc[IPOIB_NUM_WC];
168
169 struct list_head dead_ahs;
170
171 struct ib_event_handler event_handler;
172
173 struct net_device_stats stats;
174
175 struct net_device *parent;
176 struct list_head child_intfs;
177 struct list_head list;
178
179#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
180 struct list_head fs_list;
181 struct dentry *mcg_dentry;
182#endif
183};
184
185struct ipoib_ah {
186 struct net_device *dev;
187 struct ib_ah *ah;
188 struct list_head list;
189 struct kref ref;
190 unsigned last_send;
191};
192
193struct ipoib_path {
194 struct net_device *dev;
195 struct ib_sa_path_rec pathrec;
196 struct ipoib_ah *ah;
197 struct sk_buff_head queue;
198
199 struct list_head neigh_list;
200
201 int query_id;
202 struct ib_sa_query *query;
203 struct completion done;
204
205 struct rb_node rb_node;
206 struct list_head list;
207};
208
209struct ipoib_neigh {
210 struct ipoib_ah *ah;
211 struct sk_buff_head queue;
212
213 struct neighbour *neighbour;
214
215 struct list_head list;
216};
217
218static inline struct ipoib_neigh **to_ipoib_neigh(struct neighbour *neigh)
219{
220 return (struct ipoib_neigh **) (neigh->ha + 24 -
221 (offsetof(struct neighbour, ha) & 4));
222}
223
224extern struct workqueue_struct *ipoib_workqueue;
225
226/* functions */
227
228void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
229
230struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
231 struct ib_pd *pd, struct ib_ah_attr *attr);
232void ipoib_free_ah(struct kref *kref);
233static inline void ipoib_put_ah(struct ipoib_ah *ah)
234{
235 kref_put(&ah->ref, ipoib_free_ah);
236}
237
238int ipoib_add_pkey_attr(struct net_device *dev);
239
240void ipoib_send(struct net_device *dev, struct sk_buff *skb,
241 struct ipoib_ah *address, u32 qpn);
242void ipoib_reap_ah(void *dev_ptr);
243
244void ipoib_flush_paths(struct net_device *dev);
245struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
246
247int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
248void ipoib_ib_dev_flush(void *dev);
249void ipoib_ib_dev_cleanup(struct net_device *dev);
250
251int ipoib_ib_dev_open(struct net_device *dev);
252int ipoib_ib_dev_up(struct net_device *dev);
253int ipoib_ib_dev_down(struct net_device *dev);
254int ipoib_ib_dev_stop(struct net_device *dev);
255
256int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
257void ipoib_dev_cleanup(struct net_device *dev);
258
259void ipoib_mcast_join_task(void *dev_ptr);
260void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
261 struct sk_buff *skb);
262
263void ipoib_mcast_restart_task(void *dev_ptr);
264int ipoib_mcast_start_thread(struct net_device *dev);
8d2cae06 265int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
1da177e4
LT
266
267void ipoib_mcast_dev_down(struct net_device *dev);
268void ipoib_mcast_dev_flush(struct net_device *dev);
269
270struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev);
271void ipoib_mcast_iter_free(struct ipoib_mcast_iter *iter);
272int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
273void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
274 union ib_gid *gid,
275 unsigned long *created,
276 unsigned int *queuelen,
277 unsigned int *complete,
278 unsigned int *send_only);
279
280int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
281 union ib_gid *mgid);
282int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
283 union ib_gid *mgid);
284
5b6810e0 285int ipoib_init_qp(struct net_device *dev);
1da177e4
LT
286int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
287void ipoib_transport_dev_cleanup(struct net_device *dev);
288
289void ipoib_event(struct ib_event_handler *handler,
290 struct ib_event *record);
291
292int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
293int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
294
295void ipoib_pkey_poll(void *dev);
296int ipoib_pkey_dev_delay_open(struct net_device *dev);
297
298#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
299int ipoib_create_debug_file(struct net_device *dev);
300void ipoib_delete_debug_file(struct net_device *dev);
301int ipoib_register_debugfs(void);
302void ipoib_unregister_debugfs(void);
303#else
304static inline int ipoib_create_debug_file(struct net_device *dev) { return 0; }
305static inline void ipoib_delete_debug_file(struct net_device *dev) { }
306static inline int ipoib_register_debugfs(void) { return 0; }
307static inline void ipoib_unregister_debugfs(void) { }
308#endif
309
310
311#define ipoib_printk(level, priv, format, arg...) \
312 printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg)
313#define ipoib_warn(priv, format, arg...) \
314 ipoib_printk(KERN_WARNING, priv, format , ## arg)
315
316
317#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
318extern int ipoib_debug_level;
319
320#define ipoib_dbg(priv, format, arg...) \
321 do { \
322 if (ipoib_debug_level > 0) \
323 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
324 } while (0)
325#define ipoib_dbg_mcast(priv, format, arg...) \
326 do { \
327 if (mcast_debug_level > 0) \
328 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
329 } while (0)
330#else /* CONFIG_INFINIBAND_IPOIB_DEBUG */
331#define ipoib_dbg(priv, format, arg...) \
332 do { (void) (priv); } while (0)
333#define ipoib_dbg_mcast(priv, format, arg...) \
334 do { (void) (priv); } while (0)
335#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
336
337#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
338#define ipoib_dbg_data(priv, format, arg...) \
339 do { \
340 if (data_debug_level > 0) \
341 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
342 } while (0)
343#else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
344#define ipoib_dbg_data(priv, format, arg...) \
345 do { (void) (priv); } while (0)
346#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
347
348
349#define IPOIB_GID_FMT "%x:%x:%x:%x:%x:%x:%x:%x"
350
351#define IPOIB_GID_ARG(gid) be16_to_cpup((__be16 *) ((gid).raw + 0)), \
352 be16_to_cpup((__be16 *) ((gid).raw + 2)), \
353 be16_to_cpup((__be16 *) ((gid).raw + 4)), \
354 be16_to_cpup((__be16 *) ((gid).raw + 6)), \
355 be16_to_cpup((__be16 *) ((gid).raw + 8)), \
356 be16_to_cpup((__be16 *) ((gid).raw + 10)), \
357 be16_to_cpup((__be16 *) ((gid).raw + 12)), \
358 be16_to_cpup((__be16 *) ((gid).raw + 14))
359
360#endif /* _IPOIB_H */