1fe267a55SPedro F. Giffuni /*-
2fe267a55SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3fe267a55SPedro F. Giffuni *
4aa0a1e58SJeff Roberson * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
5aa0a1e58SJeff Roberson * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6aa0a1e58SJeff Roberson * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
7aa0a1e58SJeff Roberson *
8aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two
9aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU
10aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file
11aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the
12aa0a1e58SJeff Roberson * OpenIB.org BSD license below:
13aa0a1e58SJeff Roberson *
14aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or
15aa0a1e58SJeff Roberson * without modification, are permitted provided that the following
16aa0a1e58SJeff Roberson * conditions are met:
17aa0a1e58SJeff Roberson *
18aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above
19aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following
20aa0a1e58SJeff Roberson * disclaimer.
21aa0a1e58SJeff Roberson *
22aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above
23aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following
24aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials
25aa0a1e58SJeff Roberson * provided with the distribution.
26aa0a1e58SJeff Roberson *
27aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34aa0a1e58SJeff Roberson * SOFTWARE.
35aa0a1e58SJeff Roberson */
36aa0a1e58SJeff Roberson
37aa0a1e58SJeff Roberson #ifndef _IPOIB_H
38aa0a1e58SJeff Roberson #define _IPOIB_H
39aa0a1e58SJeff Roberson
40fa201e28SHans Petter Selasky #define LINUXKPI_PARAM_PREFIX ipoib_
41fa201e28SHans Petter Selasky
42aa0a1e58SJeff Roberson #include "opt_inet.h"
43aa0a1e58SJeff Roberson #include "opt_inet6.h"
44aa0a1e58SJeff Roberson #include "opt_ofed.h"
45aa0a1e58SJeff Roberson
46aa0a1e58SJeff Roberson #include <sys/param.h>
47aa0a1e58SJeff Roberson #include <sys/systm.h>
48aa0a1e58SJeff Roberson #include <sys/kernel.h>
49aa0a1e58SJeff Roberson #include <sys/lock.h>
50aa0a1e58SJeff Roberson #include <sys/malloc.h>
51aa0a1e58SJeff Roberson #include <sys/mbuf.h>
52aa0a1e58SJeff Roberson #include <sys/random.h>
53aa0a1e58SJeff Roberson #include <sys/rwlock.h>
54aa0a1e58SJeff Roberson #include <sys/socket.h>
55aa0a1e58SJeff Roberson #include <sys/sockio.h>
56aa0a1e58SJeff Roberson #include <sys/sysctl.h>
57aa0a1e58SJeff Roberson
58aa0a1e58SJeff Roberson #include <net/if.h>
5976039bc8SGleb Smirnoff #include <net/if_var.h>
60aa0a1e58SJeff Roberson #include <net/if_arp.h>
61aa0a1e58SJeff Roberson #include <net/netisr.h>
62aa0a1e58SJeff Roberson #include <net/route.h>
63aa0a1e58SJeff Roberson #include <net/if_llc.h>
64aa0a1e58SJeff Roberson #include <net/if_dl.h>
65aa0a1e58SJeff Roberson #include <net/if_types.h>
66aa0a1e58SJeff Roberson #include <net/bpf.h>
67aa0a1e58SJeff Roberson #include <net/if_llatbl.h>
68aa0a1e58SJeff Roberson #include <net/vnet.h>
69aa0a1e58SJeff Roberson
70aa0a1e58SJeff Roberson #if defined(INET) || defined(INET6)
71aa0a1e58SJeff Roberson #include <netinet/in.h>
72aa0a1e58SJeff Roberson #include <netinet/in_var.h>
73aa0a1e58SJeff Roberson #include <netinet/if_ether.h>
74aa0a1e58SJeff Roberson #include <netinet/ip_var.h>
75aa0a1e58SJeff Roberson #endif
76aa0a1e58SJeff Roberson #ifdef INET6
77aa0a1e58SJeff Roberson #include <netinet6/nd6.h>
78aa0a1e58SJeff Roberson #endif
79aa0a1e58SJeff Roberson
80aa0a1e58SJeff Roberson #include <security/mac/mac_framework.h>
81aa0a1e58SJeff Roberson
82aa0a1e58SJeff Roberson #include <linux/list.h>
83aa0a1e58SJeff Roberson
84aa0a1e58SJeff Roberson #include <linux/workqueue.h>
85aa0a1e58SJeff Roberson #include <linux/kref.h>
86aa0a1e58SJeff Roberson #include <linux/mutex.h>
87b5c1e0cbSHans Petter Selasky #include <linux/rbtree.h>
88aa0a1e58SJeff Roberson
89aa0a1e58SJeff Roberson #include <asm/atomic.h>
90aa0a1e58SJeff Roberson
91aa0a1e58SJeff Roberson #include <rdma/ib_verbs.h>
92aa0a1e58SJeff Roberson #include <rdma/ib_pack.h>
93aa0a1e58SJeff Roberson #include <rdma/ib_sa.h>
94aa0a1e58SJeff Roberson
95aa0a1e58SJeff Roberson /* constants */
96aa0a1e58SJeff Roberson
97aa0a1e58SJeff Roberson #define INFINIBAND_ALEN 20 /* Octets in IPoIB HW addr */
98aa0a1e58SJeff Roberson
99aa0a1e58SJeff Roberson #ifdef IPOIB_CM
100aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_CM
101aa0a1e58SJeff Roberson #endif
102aa0a1e58SJeff Roberson
103aa0a1e58SJeff Roberson #ifdef IPOIB_DEBUG
104aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_DEBUG
105aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
106aa0a1e58SJeff Roberson #endif
107aa0a1e58SJeff Roberson
108aa0a1e58SJeff Roberson enum ipoib_flush_level {
109aa0a1e58SJeff Roberson IPOIB_FLUSH_LIGHT,
110aa0a1e58SJeff Roberson IPOIB_FLUSH_NORMAL,
111aa0a1e58SJeff Roberson IPOIB_FLUSH_HEAVY
112aa0a1e58SJeff Roberson };
113aa0a1e58SJeff Roberson
114aa0a1e58SJeff Roberson enum {
115aa0a1e58SJeff Roberson IPOIB_ENCAP_LEN = 4,
116aa0a1e58SJeff Roberson IPOIB_HEADER_LEN = IPOIB_ENCAP_LEN + INFINIBAND_ALEN,
117aa0a1e58SJeff Roberson IPOIB_UD_MAX_MTU = 4 * 1024,
1184e38478cSHans Petter Selasky IPOIB_UD_RX_SG = 2, /* packet header and one cluster */
119aa0a1e58SJeff Roberson IPOIB_UD_TX_SG = (IPOIB_UD_MAX_MTU / MCLBYTES) + 2,
120aa0a1e58SJeff Roberson IPOIB_CM_MAX_MTU = (64 * 1024),
121aa0a1e58SJeff Roberson IPOIB_CM_TX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2,
1224e38478cSHans Petter Selasky IPOIB_CM_RX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2,
123aa0a1e58SJeff Roberson IPOIB_RX_RING_SIZE = 256,
124aa0a1e58SJeff Roberson IPOIB_TX_RING_SIZE = 128,
125aa0a1e58SJeff Roberson IPOIB_MAX_RX_SG = MAX(IPOIB_CM_RX_SG, IPOIB_UD_RX_SG),
126aa0a1e58SJeff Roberson IPOIB_MAX_TX_SG = MAX(IPOIB_CM_TX_SG, IPOIB_UD_TX_SG),
127aa0a1e58SJeff Roberson IPOIB_MAX_QUEUE_SIZE = 8192,
128aa0a1e58SJeff Roberson IPOIB_MIN_QUEUE_SIZE = 2,
129aa0a1e58SJeff Roberson IPOIB_CM_MAX_CONN_QP = 4096,
130aa0a1e58SJeff Roberson
131aa0a1e58SJeff Roberson IPOIB_NUM_WC = 4,
132aa0a1e58SJeff Roberson
133a061f0ebSSlava Shwartsman IPOIB_MAX_PATH_REC_QUEUE = 16,
134a061f0ebSSlava Shwartsman IPOIB_MAX_MCAST_QUEUE = 16,
135aa0a1e58SJeff Roberson
136aa0a1e58SJeff Roberson IPOIB_FLAG_OPER_UP = 0,
137aa0a1e58SJeff Roberson IPOIB_FLAG_INITIALIZED = 1,
138aa0a1e58SJeff Roberson IPOIB_FLAG_ADMIN_UP = 2,
139aa0a1e58SJeff Roberson IPOIB_PKEY_ASSIGNED = 3,
140aa0a1e58SJeff Roberson IPOIB_PKEY_STOP = 4,
141aa0a1e58SJeff Roberson IPOIB_FLAG_SUBINTERFACE = 5,
142aa0a1e58SJeff Roberson IPOIB_MCAST_RUN = 6,
143aa0a1e58SJeff Roberson IPOIB_STOP_REAPER = 7,
144aa0a1e58SJeff Roberson IPOIB_FLAG_UMCAST = 10,
145aa0a1e58SJeff Roberson IPOIB_FLAG_CSUM = 11,
146aa0a1e58SJeff Roberson
147aa0a1e58SJeff Roberson IPOIB_MAX_BACKOFF_SECONDS = 16,
148aa0a1e58SJeff Roberson
149aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */
150aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_SENDONLY = 1,
151aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
152aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_ATTACHED = 3,
153aa0a1e58SJeff Roberson
154aa0a1e58SJeff Roberson IPOIB_MAX_LRO_DESCRIPTORS = 8,
155aa0a1e58SJeff Roberson IPOIB_LRO_MAX_AGGR = 64,
156aa0a1e58SJeff Roberson
157aa0a1e58SJeff Roberson MAX_SEND_CQE = 16,
158aa0a1e58SJeff Roberson IPOIB_CM_COPYBREAK = 256,
159aa0a1e58SJeff Roberson };
160aa0a1e58SJeff Roberson
161aa0a1e58SJeff Roberson #define IPOIB_OP_RECV (1ul << 31)
162aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM
163aa0a1e58SJeff Roberson #define IPOIB_OP_CM (1ul << 30)
164aa0a1e58SJeff Roberson #else
165aa0a1e58SJeff Roberson #define IPOIB_OP_CM (0)
166aa0a1e58SJeff Roberson #endif
167aa0a1e58SJeff Roberson
168aa0a1e58SJeff Roberson /* structs */
169aa0a1e58SJeff Roberson
170aa0a1e58SJeff Roberson struct ipoib_header {
171aa0a1e58SJeff Roberson u8 hwaddr[INFINIBAND_ALEN];
172aa0a1e58SJeff Roberson __be16 proto;
173aa0a1e58SJeff Roberson u16 reserved;
174aa0a1e58SJeff Roberson };
175aa0a1e58SJeff Roberson
176aa0a1e58SJeff Roberson struct ipoib_pseudoheader {
177aa0a1e58SJeff Roberson u8 hwaddr[INFINIBAND_ALEN];
178aa0a1e58SJeff Roberson };
179aa0a1e58SJeff Roberson
180aa0a1e58SJeff Roberson /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
181aa0a1e58SJeff Roberson struct ipoib_mcast {
182aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec mcmember;
183aa0a1e58SJeff Roberson struct ib_sa_multicast *mc;
184aa0a1e58SJeff Roberson struct ipoib_ah *ah;
185aa0a1e58SJeff Roberson
186aa0a1e58SJeff Roberson struct rb_node rb_node;
187aa0a1e58SJeff Roberson struct list_head list;
188aa0a1e58SJeff Roberson
189aa0a1e58SJeff Roberson unsigned long created;
190aa0a1e58SJeff Roberson unsigned long backoff;
191aa0a1e58SJeff Roberson
192aa0a1e58SJeff Roberson unsigned long flags;
193aa0a1e58SJeff Roberson unsigned char logcount;
194aa0a1e58SJeff Roberson
195aa0a1e58SJeff Roberson struct ifqueue pkt_queue;
196aa0a1e58SJeff Roberson
197aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv;
198aa0a1e58SJeff Roberson };
199aa0a1e58SJeff Roberson
200aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf {
201aa0a1e58SJeff Roberson struct mbuf *mb;
202aa0a1e58SJeff Roberson u64 mapping[IPOIB_CM_RX_SG];
203aa0a1e58SJeff Roberson };
204aa0a1e58SJeff Roberson
205aa0a1e58SJeff Roberson struct ipoib_cm_tx_buf {
206aa0a1e58SJeff Roberson struct mbuf *mb;
207aa0a1e58SJeff Roberson u64 mapping[IPOIB_CM_TX_SG];
208aa0a1e58SJeff Roberson };
209aa0a1e58SJeff Roberson
210aa0a1e58SJeff Roberson struct ipoib_rx_buf {
211aa0a1e58SJeff Roberson struct mbuf *mb;
212aa0a1e58SJeff Roberson u64 mapping[IPOIB_UD_RX_SG];
213aa0a1e58SJeff Roberson };
214aa0a1e58SJeff Roberson
215aa0a1e58SJeff Roberson struct ipoib_tx_buf {
216aa0a1e58SJeff Roberson struct mbuf *mb;
217aa0a1e58SJeff Roberson u64 mapping[IPOIB_UD_TX_SG];
218aa0a1e58SJeff Roberson };
219aa0a1e58SJeff Roberson
220aa0a1e58SJeff Roberson struct ib_cm_id;
221aa0a1e58SJeff Roberson
222aa0a1e58SJeff Roberson struct ipoib_cm_data {
223aa0a1e58SJeff Roberson __be32 qpn; /* High byte MUST be ignored on receive */
224aa0a1e58SJeff Roberson __be32 mtu;
225aa0a1e58SJeff Roberson };
226aa0a1e58SJeff Roberson
227aa0a1e58SJeff Roberson /*
228aa0a1e58SJeff Roberson * Quoting 10.3.1 Queue Pair and EE Context States:
229aa0a1e58SJeff Roberson *
230aa0a1e58SJeff Roberson * Note, for QPs that are associated with an SRQ, the Consumer should take the
231aa0a1e58SJeff Roberson * QP through the Error State before invoking a Destroy QP or a Modify QP to the
232aa0a1e58SJeff Roberson * Reset State. The Consumer may invoke the Destroy QP without first performing
233aa0a1e58SJeff Roberson * a Modify QP to the Error State and waiting for the Affiliated Asynchronous
234aa0a1e58SJeff Roberson * Last WQE Reached Event. However, if the Consumer does not wait for the
235aa0a1e58SJeff Roberson * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment
236aa0a1e58SJeff Roberson * leakage may occur. Therefore, it is good programming practice to tear down a
237aa0a1e58SJeff Roberson * QP that is associated with an SRQ by using the following process:
238aa0a1e58SJeff Roberson *
239aa0a1e58SJeff Roberson * - Put the QP in the Error State
240aa0a1e58SJeff Roberson * - Wait for the Affiliated Asynchronous Last WQE Reached Event;
241aa0a1e58SJeff Roberson * - either:
242aa0a1e58SJeff Roberson * drain the CQ by invoking the Poll CQ verb and either wait for CQ
243aa0a1e58SJeff Roberson * to be empty or the number of Poll CQ operations has exceeded
244aa0a1e58SJeff Roberson * CQ capacity size;
245aa0a1e58SJeff Roberson * - or
246aa0a1e58SJeff Roberson * post another WR that completes on the same CQ and wait for this
247aa0a1e58SJeff Roberson * WR to return as a WC;
248aa0a1e58SJeff Roberson * - and then invoke a Destroy QP or Reset QP.
249aa0a1e58SJeff Roberson *
250aa0a1e58SJeff Roberson * We use the second option and wait for a completion on the
251aa0a1e58SJeff Roberson * same CQ before destroying QPs attached to our SRQ.
252aa0a1e58SJeff Roberson */
253aa0a1e58SJeff Roberson
254aa0a1e58SJeff Roberson enum ipoib_cm_state {
255aa0a1e58SJeff Roberson IPOIB_CM_RX_LIVE,
256aa0a1e58SJeff Roberson IPOIB_CM_RX_ERROR, /* Ignored by stale task */
257aa0a1e58SJeff Roberson IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */
258aa0a1e58SJeff Roberson };
259aa0a1e58SJeff Roberson
260aa0a1e58SJeff Roberson struct ipoib_cm_rx {
261aa0a1e58SJeff Roberson struct ib_cm_id *id;
262aa0a1e58SJeff Roberson struct ib_qp *qp;
263aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf *rx_ring;
264aa0a1e58SJeff Roberson struct list_head list;
265aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv;
266aa0a1e58SJeff Roberson unsigned long jiffies;
267aa0a1e58SJeff Roberson enum ipoib_cm_state state;
268aa0a1e58SJeff Roberson int recv_count;
269aa0a1e58SJeff Roberson };
270aa0a1e58SJeff Roberson
271aa0a1e58SJeff Roberson struct ipoib_cm_tx {
272aa0a1e58SJeff Roberson struct ib_cm_id *id;
273aa0a1e58SJeff Roberson struct ib_qp *qp;
274aa0a1e58SJeff Roberson struct list_head list;
275aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv;
276aa0a1e58SJeff Roberson struct ipoib_path *path;
277aa0a1e58SJeff Roberson struct ipoib_cm_tx_buf *tx_ring;
278aa0a1e58SJeff Roberson unsigned tx_head;
279aa0a1e58SJeff Roberson unsigned tx_tail;
280aa0a1e58SJeff Roberson unsigned long flags;
281aa0a1e58SJeff Roberson u32 mtu; /* remote specified mtu, with grh. */
282aa0a1e58SJeff Roberson };
283aa0a1e58SJeff Roberson
284aa0a1e58SJeff Roberson struct ipoib_cm_dev_priv {
285aa0a1e58SJeff Roberson struct ib_srq *srq;
286aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf *srq_ring;
287aa0a1e58SJeff Roberson struct ib_cm_id *id;
288aa0a1e58SJeff Roberson struct list_head passive_ids; /* state: LIVE */
289aa0a1e58SJeff Roberson struct list_head rx_error_list; /* state: ERROR */
290aa0a1e58SJeff Roberson struct list_head rx_flush_list; /* state: FLUSH, drain not started */
291aa0a1e58SJeff Roberson struct list_head rx_drain_list; /* state: FLUSH, drain started */
292aa0a1e58SJeff Roberson struct list_head rx_reap_list; /* state: FLUSH, drain done */
293aa0a1e58SJeff Roberson struct work_struct start_task;
294aa0a1e58SJeff Roberson struct work_struct reap_task;
295aa0a1e58SJeff Roberson struct work_struct mb_task;
296aa0a1e58SJeff Roberson struct work_struct rx_reap_task;
297aa0a1e58SJeff Roberson struct delayed_work stale_task;
298aa0a1e58SJeff Roberson struct ifqueue mb_queue;
299aa0a1e58SJeff Roberson struct list_head start_list;
300aa0a1e58SJeff Roberson struct list_head reap_list;
301aa0a1e58SJeff Roberson struct ib_sge rx_sge[IPOIB_CM_RX_SG];
302aa0a1e58SJeff Roberson struct ib_recv_wr rx_wr;
303aa0a1e58SJeff Roberson int nonsrq_conn_qp;
304aa0a1e58SJeff Roberson int max_cm_mtu; /* Actual buf size. */
305aa0a1e58SJeff Roberson int num_frags;
306aa0a1e58SJeff Roberson };
307aa0a1e58SJeff Roberson
308aa0a1e58SJeff Roberson struct ipoib_ethtool_st {
309aa0a1e58SJeff Roberson u16 coalesce_usecs;
310aa0a1e58SJeff Roberson u16 max_coalesced_frames;
311aa0a1e58SJeff Roberson };
312aa0a1e58SJeff Roberson
313aa0a1e58SJeff Roberson /*
314aa0a1e58SJeff Roberson * Device private locking: network stack tx_lock protects members used
315aa0a1e58SJeff Roberson * in TX fast path, lock protects everything else. lock nests inside
316aa0a1e58SJeff Roberson * of tx_lock (ie tx_lock must be acquired first if needed).
317aa0a1e58SJeff Roberson */
318aa0a1e58SJeff Roberson struct ipoib_dev_priv {
319aa0a1e58SJeff Roberson spinlock_t lock;
320b5c1e0cbSHans Petter Selasky spinlock_t drain_lock;
321aa0a1e58SJeff Roberson
3223e142e07SJustin Hibbits if_t dev;
323aa0a1e58SJeff Roberson
324aa0a1e58SJeff Roberson u8 broadcastaddr[INFINIBAND_ALEN];
325aa0a1e58SJeff Roberson
326aa0a1e58SJeff Roberson unsigned long flags;
327aa0a1e58SJeff Roberson
3289319562bSHans Petter Selasky int gone;
329478d3005SHans Petter Selasky int unit;
3309319562bSHans Petter Selasky
331aa0a1e58SJeff Roberson struct mutex vlan_mutex;
332aa0a1e58SJeff Roberson
333aa0a1e58SJeff Roberson struct rb_root path_tree;
334aa0a1e58SJeff Roberson struct list_head path_list;
335aa0a1e58SJeff Roberson
336aa0a1e58SJeff Roberson struct ipoib_mcast *broadcast;
337aa0a1e58SJeff Roberson struct list_head multicast_list;
338aa0a1e58SJeff Roberson struct rb_root multicast_tree;
339aa0a1e58SJeff Roberson
340aa0a1e58SJeff Roberson struct delayed_work pkey_poll_task;
341aa0a1e58SJeff Roberson struct delayed_work mcast_task;
342aa0a1e58SJeff Roberson struct work_struct carrier_on_task;
343aa0a1e58SJeff Roberson struct work_struct flush_light;
344aa0a1e58SJeff Roberson struct work_struct flush_normal;
345aa0a1e58SJeff Roberson struct work_struct flush_heavy;
346aa0a1e58SJeff Roberson struct work_struct restart_task;
347aa0a1e58SJeff Roberson struct delayed_work ah_reap_task;
348aa0a1e58SJeff Roberson
349aa0a1e58SJeff Roberson struct ib_device *ca;
350aa0a1e58SJeff Roberson u8 port;
351aa0a1e58SJeff Roberson u16 pkey;
352aa0a1e58SJeff Roberson u16 pkey_index;
353aa0a1e58SJeff Roberson struct ib_pd *pd;
354aa0a1e58SJeff Roberson struct ib_cq *recv_cq;
355aa0a1e58SJeff Roberson struct ib_cq *send_cq;
356aa0a1e58SJeff Roberson struct ib_qp *qp;
357aa0a1e58SJeff Roberson u32 qkey;
358aa0a1e58SJeff Roberson
359aa0a1e58SJeff Roberson union ib_gid local_gid;
360aa0a1e58SJeff Roberson u16 local_lid;
361aa0a1e58SJeff Roberson
362aa0a1e58SJeff Roberson unsigned int admin_mtu; /* User selected MTU, no GRH. */
363aa0a1e58SJeff Roberson unsigned int mcast_mtu; /* Minus GRH bytes, from mcast group. */
364aa0a1e58SJeff Roberson unsigned int max_ib_mtu; /* Without header, actual buf size. */
365aa0a1e58SJeff Roberson
366aa0a1e58SJeff Roberson struct ipoib_rx_buf *rx_ring;
367aa0a1e58SJeff Roberson
368aa0a1e58SJeff Roberson struct ipoib_tx_buf *tx_ring;
369aa0a1e58SJeff Roberson unsigned tx_head;
370aa0a1e58SJeff Roberson unsigned tx_tail;
371aa0a1e58SJeff Roberson struct ib_sge tx_sge[IPOIB_MAX_TX_SG];
372478d3005SHans Petter Selasky struct ib_ud_wr tx_wr;
373aa0a1e58SJeff Roberson unsigned tx_outstanding;
374aa0a1e58SJeff Roberson struct ib_wc send_wc[MAX_SEND_CQE];
375aa0a1e58SJeff Roberson
376aa0a1e58SJeff Roberson struct ib_recv_wr rx_wr;
377aa0a1e58SJeff Roberson struct ib_sge rx_sge[IPOIB_MAX_RX_SG];
378aa0a1e58SJeff Roberson
379aa0a1e58SJeff Roberson struct ib_wc ibwc[IPOIB_NUM_WC];
380aa0a1e58SJeff Roberson
381aa0a1e58SJeff Roberson struct list_head dead_ahs;
382aa0a1e58SJeff Roberson
383aa0a1e58SJeff Roberson struct ib_event_handler event_handler;
384aa0a1e58SJeff Roberson
3853e142e07SJustin Hibbits if_t parent;
386aa0a1e58SJeff Roberson struct list_head child_intfs;
387aa0a1e58SJeff Roberson struct list_head list;
388aa0a1e58SJeff Roberson
389aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM
390aa0a1e58SJeff Roberson struct ipoib_cm_dev_priv cm;
391aa0a1e58SJeff Roberson #endif
392aa0a1e58SJeff Roberson
393aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
394aa0a1e58SJeff Roberson struct list_head fs_list;
395aa0a1e58SJeff Roberson struct dentry *mcg_dentry;
396aa0a1e58SJeff Roberson struct dentry *path_dentry;
397aa0a1e58SJeff Roberson #endif
398aa0a1e58SJeff Roberson int hca_caps;
399aa0a1e58SJeff Roberson struct ipoib_ethtool_st ethtool;
400aa0a1e58SJeff Roberson struct timer_list poll_timer;
401aa0a1e58SJeff Roberson };
402aa0a1e58SJeff Roberson
403aa0a1e58SJeff Roberson struct ipoib_ah {
404aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv;
405aa0a1e58SJeff Roberson struct ib_ah *ah;
406aa0a1e58SJeff Roberson struct list_head list;
407aa0a1e58SJeff Roberson struct kref ref;
408aa0a1e58SJeff Roberson unsigned last_send;
409aa0a1e58SJeff Roberson };
410aa0a1e58SJeff Roberson
411aa0a1e58SJeff Roberson struct ipoib_path {
412aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv;
413aa0a1e58SJeff Roberson struct rb_node rb_node;
414aa0a1e58SJeff Roberson struct list_head list;
415aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM
416aa0a1e58SJeff Roberson uint8_t hwaddr[INFINIBAND_ALEN];
417aa0a1e58SJeff Roberson struct ipoib_cm_tx *cm;
418aa0a1e58SJeff Roberson #endif
419aa0a1e58SJeff Roberson struct ipoib_ah *ah;
420aa0a1e58SJeff Roberson struct ib_sa_path_rec pathrec;
421aa0a1e58SJeff Roberson struct ifqueue queue;
422aa0a1e58SJeff Roberson
423aa0a1e58SJeff Roberson int query_id;
424aa0a1e58SJeff Roberson struct ib_sa_query *query;
425aa0a1e58SJeff Roberson struct completion done;
426aa0a1e58SJeff Roberson
427aa0a1e58SJeff Roberson int valid;
428aa0a1e58SJeff Roberson };
429aa0a1e58SJeff Roberson
430aa0a1e58SJeff Roberson /* UD Only transmits encap len but we want the two sizes to be symmetrical. */
431aa0a1e58SJeff Roberson #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN)
432aa0a1e58SJeff Roberson #define IPOIB_CM_MTU(ib_mtu) (ib_mtu - 0x10)
433aa0a1e58SJeff Roberson
434aa0a1e58SJeff Roberson #define IPOIB_IS_MULTICAST(addr) ((addr)[4] == 0xff)
435aa0a1e58SJeff Roberson
436aa0a1e58SJeff Roberson extern struct workqueue_struct *ipoib_workqueue;
437aa0a1e58SJeff Roberson
438aa0a1e58SJeff Roberson /* functions */
439aa0a1e58SJeff Roberson void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
440aa0a1e58SJeff Roberson void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr);
441aa0a1e58SJeff Roberson
442aa0a1e58SJeff Roberson struct ipoib_ah *ipoib_create_ah(struct ipoib_dev_priv *,
443aa0a1e58SJeff Roberson struct ib_pd *pd, struct ib_ah_attr *attr);
444aa0a1e58SJeff Roberson void ipoib_free_ah(struct kref *kref);
ipoib_put_ah(struct ipoib_ah * ah)445aa0a1e58SJeff Roberson static inline void ipoib_put_ah(struct ipoib_ah *ah)
446aa0a1e58SJeff Roberson {
447aa0a1e58SJeff Roberson kref_put(&ah->ref, ipoib_free_ah);
448aa0a1e58SJeff Roberson }
449aa0a1e58SJeff Roberson
450aa0a1e58SJeff Roberson int ipoib_open(struct ipoib_dev_priv *priv);
451aa0a1e58SJeff Roberson int ipoib_add_pkey_attr(struct ipoib_dev_priv *priv);
452aa0a1e58SJeff Roberson int ipoib_add_umcast_attr(struct ipoib_dev_priv *priv);
453aa0a1e58SJeff Roberson
454aa0a1e58SJeff Roberson void ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb,
455aa0a1e58SJeff Roberson struct ipoib_ah *address, u32 qpn);
456aa0a1e58SJeff Roberson void ipoib_reap_ah(struct work_struct *work);
457aa0a1e58SJeff Roberson
458aa0a1e58SJeff Roberson void ipoib_mark_paths_invalid(struct ipoib_dev_priv *priv);
459aa0a1e58SJeff Roberson void ipoib_flush_paths(struct ipoib_dev_priv *priv);
460*fc6c93b6SZhenlei Huang struct ipoib_dev_priv *ipoib_intf_alloc(const char *format, struct ib_device *ca);
461aa0a1e58SJeff Roberson
462aa0a1e58SJeff Roberson int ipoib_ib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca,
463aa0a1e58SJeff Roberson int port);
464aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_light(struct work_struct *work);
465aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_normal(struct work_struct *work);
466aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_heavy(struct work_struct *work);
467aa0a1e58SJeff Roberson void ipoib_pkey_event(struct work_struct *work);
468aa0a1e58SJeff Roberson void ipoib_ib_dev_cleanup(struct ipoib_dev_priv *priv);
469aa0a1e58SJeff Roberson
470aa0a1e58SJeff Roberson int ipoib_ib_dev_open(struct ipoib_dev_priv *priv);
471aa0a1e58SJeff Roberson int ipoib_ib_dev_up(struct ipoib_dev_priv *priv);
472aa0a1e58SJeff Roberson int ipoib_ib_dev_down(struct ipoib_dev_priv *priv, int flush);
473aa0a1e58SJeff Roberson int ipoib_ib_dev_stop(struct ipoib_dev_priv *priv, int flush);
474aa0a1e58SJeff Roberson
475aa0a1e58SJeff Roberson int ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port);
476aa0a1e58SJeff Roberson void ipoib_dev_cleanup(struct ipoib_dev_priv *priv);
477aa0a1e58SJeff Roberson
478aa0a1e58SJeff Roberson void ipoib_mcast_join_task(struct work_struct *work);
479aa0a1e58SJeff Roberson void ipoib_mcast_carrier_on_task(struct work_struct *work);
480aa0a1e58SJeff Roberson void ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb);
481aa0a1e58SJeff Roberson
482aa0a1e58SJeff Roberson void ipoib_mcast_restart_task(struct work_struct *work);
483aa0a1e58SJeff Roberson void ipoib_mcast_restart(struct ipoib_dev_priv *);
484aa0a1e58SJeff Roberson int ipoib_mcast_start_thread(struct ipoib_dev_priv *priv);
485aa0a1e58SJeff Roberson int ipoib_mcast_stop_thread(struct ipoib_dev_priv *priv, int flush);
486aa0a1e58SJeff Roberson
487aa0a1e58SJeff Roberson void ipoib_mcast_dev_down(struct ipoib_dev_priv *priv);
488aa0a1e58SJeff Roberson void ipoib_mcast_dev_flush(struct ipoib_dev_priv *priv);
489aa0a1e58SJeff Roberson
490aa0a1e58SJeff Roberson void ipoib_path_free(struct ipoib_dev_priv *priv, struct ipoib_path *path);
491aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
492aa0a1e58SJeff Roberson struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct ipoib_dev_priv *priv);
493aa0a1e58SJeff Roberson int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
494aa0a1e58SJeff Roberson void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
495aa0a1e58SJeff Roberson union ib_gid *gid,
496aa0a1e58SJeff Roberson unsigned long *created,
497aa0a1e58SJeff Roberson unsigned int *queuelen,
498aa0a1e58SJeff Roberson unsigned int *complete,
499aa0a1e58SJeff Roberson unsigned int *send_only);
500aa0a1e58SJeff Roberson
501aa0a1e58SJeff Roberson struct ipoib_path_iter *ipoib_path_iter_init(struct ipoib_dev_priv *priv);
502aa0a1e58SJeff Roberson int ipoib_path_iter_next(struct ipoib_path_iter *iter);
503aa0a1e58SJeff Roberson void ipoib_path_iter_read(struct ipoib_path_iter *iter,
504aa0a1e58SJeff Roberson struct ipoib_path *path);
505aa0a1e58SJeff Roberson #endif
506aa0a1e58SJeff Roberson
507099ad46eSSlava Shwartsman int ipoib_change_mtu(struct ipoib_dev_priv *priv, int new_mtu, bool propagate);
508aa0a1e58SJeff Roberson
509aa0a1e58SJeff Roberson int ipoib_mcast_attach(struct ipoib_dev_priv *priv, u16 mlid,
510aa0a1e58SJeff Roberson union ib_gid *mgid, int set_qkey);
511aa0a1e58SJeff Roberson
512aa0a1e58SJeff Roberson int ipoib_init_qp(struct ipoib_dev_priv *priv);
513aa0a1e58SJeff Roberson int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca);
514aa0a1e58SJeff Roberson void ipoib_transport_dev_cleanup(struct ipoib_dev_priv *priv);
515aa0a1e58SJeff Roberson
516aa0a1e58SJeff Roberson void ipoib_event(struct ib_event_handler *handler,
517aa0a1e58SJeff Roberson struct ib_event *record);
518aa0a1e58SJeff Roberson
519aa0a1e58SJeff Roberson void ipoib_pkey_poll(struct work_struct *work);
520aa0a1e58SJeff Roberson int ipoib_pkey_dev_delay_open(struct ipoib_dev_priv *priv);
521aa0a1e58SJeff Roberson void ipoib_drain_cq(struct ipoib_dev_priv *priv);
522aa0a1e58SJeff Roberson
523aa0a1e58SJeff Roberson int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req, int max);
524aa0a1e58SJeff Roberson void ipoib_dma_unmap_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req);
5256fe20cefSHans Petter Selasky int ipoib_poll_tx(struct ipoib_dev_priv *priv, bool do_start);
526aa0a1e58SJeff Roberson
527aa0a1e58SJeff Roberson void ipoib_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req);
528aa0a1e58SJeff Roberson void ipoib_dma_mb(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int length);
5294e38478cSHans Petter Selasky struct mbuf *ipoib_alloc_map_mb(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req, int align, int size, int max_frags);
530aa0a1e58SJeff Roberson
531aa0a1e58SJeff Roberson
5323e142e07SJustin Hibbits void ipoib_set_ethtool_ops(if_t dev);
533aa0a1e58SJeff Roberson int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca);
534aa0a1e58SJeff Roberson
535aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM
536aa0a1e58SJeff Roberson
537aa0a1e58SJeff Roberson #define IPOIB_FLAGS_RC 0x80
538aa0a1e58SJeff Roberson #define IPOIB_FLAGS_UC 0x40
539aa0a1e58SJeff Roberson
540aa0a1e58SJeff Roberson /* We don't support UC connections at the moment */
541aa0a1e58SJeff Roberson #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC))
542aa0a1e58SJeff Roberson
543aa0a1e58SJeff Roberson extern int ipoib_max_conn_qp;
544aa0a1e58SJeff Roberson
ipoib_cm_admin_enabled(struct ipoib_dev_priv * priv)545aa0a1e58SJeff Roberson static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)
546aa0a1e58SJeff Roberson {
5473e142e07SJustin Hibbits return IPOIB_CM_SUPPORTED(if_getlladdr(priv->dev));
548aa0a1e58SJeff Roberson }
549aa0a1e58SJeff Roberson
ipoib_cm_enabled(struct ipoib_dev_priv * priv,uint8_t * hwaddr)550aa0a1e58SJeff Roberson static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)
551aa0a1e58SJeff Roberson {
552aa0a1e58SJeff Roberson return IPOIB_CM_SUPPORTED(hwaddr);
553aa0a1e58SJeff Roberson }
554aa0a1e58SJeff Roberson
ipoib_cm_up(struct ipoib_path * path)555aa0a1e58SJeff Roberson static inline int ipoib_cm_up(struct ipoib_path *path)
556aa0a1e58SJeff Roberson
557aa0a1e58SJeff Roberson {
558aa0a1e58SJeff Roberson return test_bit(IPOIB_FLAG_OPER_UP, &path->cm->flags);
559aa0a1e58SJeff Roberson }
560aa0a1e58SJeff Roberson
ipoib_cm_get(struct ipoib_path * path)561aa0a1e58SJeff Roberson static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
562aa0a1e58SJeff Roberson {
563aa0a1e58SJeff Roberson return path->cm;
564aa0a1e58SJeff Roberson }
565aa0a1e58SJeff Roberson
ipoib_cm_set(struct ipoib_path * path,struct ipoib_cm_tx * tx)566aa0a1e58SJeff Roberson static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
567aa0a1e58SJeff Roberson {
568aa0a1e58SJeff Roberson path->cm = tx;
569aa0a1e58SJeff Roberson }
570aa0a1e58SJeff Roberson
ipoib_cm_has_srq(struct ipoib_dev_priv * priv)571aa0a1e58SJeff Roberson static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)
572aa0a1e58SJeff Roberson {
573aa0a1e58SJeff Roberson return !!priv->cm.srq;
574aa0a1e58SJeff Roberson }
575aa0a1e58SJeff Roberson
ipoib_cm_max_mtu(struct ipoib_dev_priv * priv)576aa0a1e58SJeff Roberson static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)
577aa0a1e58SJeff Roberson {
578aa0a1e58SJeff Roberson return priv->cm.max_cm_mtu;
579aa0a1e58SJeff Roberson }
580aa0a1e58SJeff Roberson
581aa0a1e58SJeff Roberson void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx);
582aa0a1e58SJeff Roberson int ipoib_cm_dev_open(struct ipoib_dev_priv *priv);
583aa0a1e58SJeff Roberson void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv);
584aa0a1e58SJeff Roberson int ipoib_cm_dev_init(struct ipoib_dev_priv *priv);
585aa0a1e58SJeff Roberson int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv);
586aa0a1e58SJeff Roberson void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv);
587aa0a1e58SJeff Roberson struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv,
588aa0a1e58SJeff Roberson struct ipoib_path *path);
589aa0a1e58SJeff Roberson void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx);
590aa0a1e58SJeff Roberson void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,
591aa0a1e58SJeff Roberson unsigned int mtu);
592aa0a1e58SJeff Roberson void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);
593aa0a1e58SJeff Roberson void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);
594aa0a1e58SJeff Roberson #else
595aa0a1e58SJeff Roberson
596aa0a1e58SJeff Roberson struct ipoib_cm_tx;
597aa0a1e58SJeff Roberson
598aa0a1e58SJeff Roberson #define ipoib_max_conn_qp 0
599aa0a1e58SJeff Roberson
ipoib_cm_admin_enabled(struct ipoib_dev_priv * priv)600aa0a1e58SJeff Roberson static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)
601aa0a1e58SJeff Roberson {
602aa0a1e58SJeff Roberson return 0;
603aa0a1e58SJeff Roberson }
ipoib_cm_enabled(struct ipoib_dev_priv * priv,uint8_t * hwaddr)604aa0a1e58SJeff Roberson static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)
605aa0a1e58SJeff Roberson
606aa0a1e58SJeff Roberson {
607aa0a1e58SJeff Roberson return 0;
608aa0a1e58SJeff Roberson }
609aa0a1e58SJeff Roberson
ipoib_cm_up(struct ipoib_path * path)610aa0a1e58SJeff Roberson static inline int ipoib_cm_up(struct ipoib_path *path)
611aa0a1e58SJeff Roberson
612aa0a1e58SJeff Roberson {
613aa0a1e58SJeff Roberson return 0;
614aa0a1e58SJeff Roberson }
615aa0a1e58SJeff Roberson
ipoib_cm_get(struct ipoib_path * path)616aa0a1e58SJeff Roberson static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
617aa0a1e58SJeff Roberson {
618aa0a1e58SJeff Roberson return NULL;
619aa0a1e58SJeff Roberson }
620aa0a1e58SJeff Roberson
ipoib_cm_set(struct ipoib_path * path,struct ipoib_cm_tx * tx)621aa0a1e58SJeff Roberson static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
622aa0a1e58SJeff Roberson {
623aa0a1e58SJeff Roberson }
624aa0a1e58SJeff Roberson
ipoib_cm_has_srq(struct ipoib_dev_priv * priv)625aa0a1e58SJeff Roberson static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)
626aa0a1e58SJeff Roberson {
627aa0a1e58SJeff Roberson return 0;
628aa0a1e58SJeff Roberson }
629aa0a1e58SJeff Roberson
ipoib_cm_max_mtu(struct ipoib_dev_priv * priv)630aa0a1e58SJeff Roberson static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)
631aa0a1e58SJeff Roberson {
632aa0a1e58SJeff Roberson return 0;
633aa0a1e58SJeff Roberson }
634aa0a1e58SJeff Roberson
635aa0a1e58SJeff Roberson static inline
ipoib_cm_send(struct ipoib_dev_priv * priv,struct mbuf * mb,struct ipoib_cm_tx * tx)636aa0a1e58SJeff Roberson void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx)
637aa0a1e58SJeff Roberson {
638aa0a1e58SJeff Roberson return;
639aa0a1e58SJeff Roberson }
640aa0a1e58SJeff Roberson
641aa0a1e58SJeff Roberson static inline
ipoib_cm_dev_open(struct ipoib_dev_priv * priv)642aa0a1e58SJeff Roberson int ipoib_cm_dev_open(struct ipoib_dev_priv *priv)
643aa0a1e58SJeff Roberson {
644aa0a1e58SJeff Roberson return 0;
645aa0a1e58SJeff Roberson }
646aa0a1e58SJeff Roberson
647aa0a1e58SJeff Roberson static inline
ipoib_cm_dev_stop(struct ipoib_dev_priv * priv)648aa0a1e58SJeff Roberson void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv)
649aa0a1e58SJeff Roberson {
650aa0a1e58SJeff Roberson return;
651aa0a1e58SJeff Roberson }
652aa0a1e58SJeff Roberson
653aa0a1e58SJeff Roberson static inline
ipoib_cm_dev_init(struct ipoib_dev_priv * priv)654aa0a1e58SJeff Roberson int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)
655aa0a1e58SJeff Roberson {
656aa0a1e58SJeff Roberson return -ENOSYS;
657aa0a1e58SJeff Roberson }
658aa0a1e58SJeff Roberson
659aa0a1e58SJeff Roberson static inline
ipoib_cm_dev_cleanup(struct ipoib_dev_priv * priv)660aa0a1e58SJeff Roberson void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv)
661aa0a1e58SJeff Roberson {
662aa0a1e58SJeff Roberson return;
663aa0a1e58SJeff Roberson }
664aa0a1e58SJeff Roberson
665aa0a1e58SJeff Roberson static inline
ipoib_cm_create_tx(struct ipoib_dev_priv * priv,struct ipoib_path * path)666aa0a1e58SJeff Roberson struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv, struct ipoib_path *path)
667aa0a1e58SJeff Roberson {
668aa0a1e58SJeff Roberson return NULL;
669aa0a1e58SJeff Roberson }
670aa0a1e58SJeff Roberson
671aa0a1e58SJeff Roberson static inline
ipoib_cm_destroy_tx(struct ipoib_cm_tx * tx)672aa0a1e58SJeff Roberson void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
673aa0a1e58SJeff Roberson {
674aa0a1e58SJeff Roberson return;
675aa0a1e58SJeff Roberson }
676aa0a1e58SJeff Roberson
677aa0a1e58SJeff Roberson static inline
ipoib_cm_add_mode_attr(struct ipoib_dev_priv * priv)678aa0a1e58SJeff Roberson int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv)
679aa0a1e58SJeff Roberson {
680aa0a1e58SJeff Roberson return 0;
681aa0a1e58SJeff Roberson }
682aa0a1e58SJeff Roberson
ipoib_cm_mb_too_long(struct ipoib_dev_priv * priv,struct mbuf * mb,unsigned int mtu)683aa0a1e58SJeff Roberson static inline void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,
684aa0a1e58SJeff Roberson unsigned int mtu)
685aa0a1e58SJeff Roberson {
686aa0a1e58SJeff Roberson m_freem(mb);
687aa0a1e58SJeff Roberson }
688aa0a1e58SJeff Roberson
ipoib_cm_handle_rx_wc(struct ipoib_dev_priv * priv,struct ib_wc * wc)689aa0a1e58SJeff Roberson static inline void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
690aa0a1e58SJeff Roberson {
691aa0a1e58SJeff Roberson }
692aa0a1e58SJeff Roberson
ipoib_cm_handle_tx_wc(struct ipoib_dev_priv * priv,struct ib_wc * wc)693aa0a1e58SJeff Roberson static inline void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
694aa0a1e58SJeff Roberson {
695aa0a1e58SJeff Roberson }
696aa0a1e58SJeff Roberson #endif
697aa0a1e58SJeff Roberson
698aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
699aa0a1e58SJeff Roberson void ipoib_create_debug_files(struct ipoib_dev_priv *priv);
700aa0a1e58SJeff Roberson void ipoib_delete_debug_files(struct ipoib_dev_priv *priv);
701aa0a1e58SJeff Roberson int ipoib_register_debugfs(void);
702aa0a1e58SJeff Roberson void ipoib_unregister_debugfs(void);
703aa0a1e58SJeff Roberson #else
ipoib_create_debug_files(struct ipoib_dev_priv * priv)704aa0a1e58SJeff Roberson static inline void ipoib_create_debug_files(struct ipoib_dev_priv *priv) { }
ipoib_delete_debug_files(struct ipoib_dev_priv * priv)705aa0a1e58SJeff Roberson static inline void ipoib_delete_debug_files(struct ipoib_dev_priv *priv) { }
ipoib_register_debugfs(void)706aa0a1e58SJeff Roberson static inline int ipoib_register_debugfs(void) { return 0; }
ipoib_unregister_debugfs(void)707aa0a1e58SJeff Roberson static inline void ipoib_unregister_debugfs(void) { }
708aa0a1e58SJeff Roberson #endif
709aa0a1e58SJeff Roberson
710aa0a1e58SJeff Roberson #define ipoib_printk(level, priv, format, arg...) \
711aa0a1e58SJeff Roberson printk(level "%s: " format, if_name(((struct ipoib_dev_priv *) priv)->dev), ## arg)
712aa0a1e58SJeff Roberson #define ipoib_warn(priv, format, arg...) \
713aa0a1e58SJeff Roberson ipoib_printk(KERN_WARNING, priv, format , ## arg)
714aa0a1e58SJeff Roberson
715aa0a1e58SJeff Roberson extern int ipoib_sendq_size;
716aa0a1e58SJeff Roberson extern int ipoib_recvq_size;
717aa0a1e58SJeff Roberson
718aa0a1e58SJeff Roberson extern struct ib_sa_client ipoib_sa_client;
719aa0a1e58SJeff Roberson
720aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
721aa0a1e58SJeff Roberson extern int ipoib_debug_level;
722aa0a1e58SJeff Roberson
723aa0a1e58SJeff Roberson #define ipoib_dbg(priv, format, arg...) \
724aa0a1e58SJeff Roberson do { \
725aa0a1e58SJeff Roberson if (ipoib_debug_level > 0) \
726aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
727aa0a1e58SJeff Roberson } while (0)
728aa0a1e58SJeff Roberson #define ipoib_dbg_mcast(priv, format, arg...) \
729aa0a1e58SJeff Roberson do { \
730aa0a1e58SJeff Roberson if (mcast_debug_level > 0) \
731aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
732aa0a1e58SJeff Roberson } while (0)
733aa0a1e58SJeff Roberson #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */
734aa0a1e58SJeff Roberson #define ipoib_dbg(priv, format, arg...) \
735aa0a1e58SJeff Roberson do { (void) (priv); } while (0)
736aa0a1e58SJeff Roberson #define ipoib_dbg_mcast(priv, format, arg...) \
737aa0a1e58SJeff Roberson do { (void) (priv); } while (0)
738aa0a1e58SJeff Roberson #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
739aa0a1e58SJeff Roberson
740aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
741aa0a1e58SJeff Roberson #define ipoib_dbg_data(priv, format, arg...) \
742aa0a1e58SJeff Roberson do { \
743aa0a1e58SJeff Roberson if (data_debug_level > 0) \
744aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
745aa0a1e58SJeff Roberson } while (0)
746aa0a1e58SJeff Roberson #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
747aa0a1e58SJeff Roberson #define ipoib_dbg_data(priv, format, arg...) \
748aa0a1e58SJeff Roberson do { (void) (priv); } while (0)
749aa0a1e58SJeff Roberson #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
750aa0a1e58SJeff Roberson
751aa0a1e58SJeff Roberson #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
752aa0a1e58SJeff Roberson
7533e142e07SJustin Hibbits void ipoib_start_locked(if_t, struct ipoib_dev_priv *);
7546fe20cefSHans Petter Selasky
755aa0a1e58SJeff Roberson #endif /* _IPOIB_H */
756