2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
8 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU
10 * General Public License (GPL) Version 2, available from the file
11 * COPYING in the main directory of this source tree, or the
12 * OpenIB.org BSD license below:
14 * Redistribution and use in source and binary forms, with or
15 * without modification, are permitted provided that the following
18 * - Redistributions of source code must retain the above
19 * copyright notice, this list of conditions and the following
22 * - Redistributions in binary form must reproduce the above
23 * copyright notice, this list of conditions and the following
24 * disclaimer in the documentation and/or other materials
25 * provided with the distribution.
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40 #define LINUXKPI_PARAM_PREFIX ipoib_
43 #include "opt_inet6.h"
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
50 #include <sys/malloc.h>
52 #include <sys/random.h>
53 #include <sys/rwlock.h>
54 #include <sys/socket.h>
55 #include <sys/sockio.h>
56 #include <sys/sysctl.h>
59 #include <net/if_var.h>
60 #include <net/if_arp.h>
61 #include <net/netisr.h>
62 #include <net/route.h>
63 #include <net/if_llc.h>
64 #include <net/if_dl.h>
65 #include <net/if_types.h>
67 #include <net/if_llatbl.h>
70 #if defined(INET) || defined(INET6)
71 #include <netinet/in.h>
72 #include <netinet/in_var.h>
73 #include <netinet/if_ether.h>
74 #include <netinet/ip_var.h>
77 #include <netinet6/nd6.h>
80 #include <security/mac/mac_framework.h>
82 #include <linux/list.h>
84 #include <linux/workqueue.h>
85 #include <linux/kref.h>
86 #include <linux/mutex.h>
87 #include <linux/rbtree.h>
89 #include <asm/atomic.h>
91 #include <rdma/ib_verbs.h>
92 #include <rdma/ib_pack.h>
93 #include <rdma/ib_sa.h>
97 #define INFINIBAND_ALEN 20 /* Octets in IPoIB HW addr */
100 #define CONFIG_INFINIBAND_IPOIB_CM
104 #define CONFIG_INFINIBAND_IPOIB_DEBUG
105 #define CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
108 enum ipoib_flush_level {
116 IPOIB_HEADER_LEN = IPOIB_ENCAP_LEN + INFINIBAND_ALEN,
117 IPOIB_UD_MAX_MTU = 4 * 1024,
118 // IPOIB_UD_RX_SG = (IPOIB_UD_MAX_MTU / MJUMPAGESIZE),
120 IPOIB_UD_TX_SG = (IPOIB_UD_MAX_MTU / MCLBYTES) + 2,
121 IPOIB_CM_MAX_MTU = (64 * 1024),
122 IPOIB_CM_TX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2,
123 IPOIB_CM_RX_SG = (IPOIB_CM_MAX_MTU / MJUMPAGESIZE),
124 IPOIB_RX_RING_SIZE = 256,
125 IPOIB_TX_RING_SIZE = 128,
126 IPOIB_MAX_RX_SG = MAX(IPOIB_CM_RX_SG, IPOIB_UD_RX_SG),
127 IPOIB_MAX_TX_SG = MAX(IPOIB_CM_TX_SG, IPOIB_UD_TX_SG),
128 IPOIB_MAX_QUEUE_SIZE = 8192,
129 IPOIB_MIN_QUEUE_SIZE = 2,
130 IPOIB_CM_MAX_CONN_QP = 4096,
134 IPOIB_MAX_PATH_REC_QUEUE = 3,
135 IPOIB_MAX_MCAST_QUEUE = 3,
137 IPOIB_FLAG_OPER_UP = 0,
138 IPOIB_FLAG_INITIALIZED = 1,
139 IPOIB_FLAG_ADMIN_UP = 2,
140 IPOIB_PKEY_ASSIGNED = 3,
142 IPOIB_FLAG_SUBINTERFACE = 5,
144 IPOIB_STOP_REAPER = 7,
145 IPOIB_FLAG_UMCAST = 10,
146 IPOIB_FLAG_CSUM = 11,
148 IPOIB_MAX_BACKOFF_SECONDS = 16,
150 IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */
151 IPOIB_MCAST_FLAG_SENDONLY = 1,
152 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
153 IPOIB_MCAST_FLAG_ATTACHED = 3,
155 IPOIB_MAX_LRO_DESCRIPTORS = 8,
156 IPOIB_LRO_MAX_AGGR = 64,
159 IPOIB_CM_COPYBREAK = 256,
162 #define IPOIB_OP_RECV (1ul << 31)
163 #ifdef CONFIG_INFINIBAND_IPOIB_CM
164 #define IPOIB_OP_CM (1ul << 30)
166 #define IPOIB_OP_CM (0)
171 struct ipoib_header {
172 u8 hwaddr[INFINIBAND_ALEN];
177 struct ipoib_pseudoheader {
178 u8 hwaddr[INFINIBAND_ALEN];
181 /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
183 struct ib_sa_mcmember_rec mcmember;
184 struct ib_sa_multicast *mc;
187 struct rb_node rb_node;
188 struct list_head list;
190 unsigned long created;
191 unsigned long backoff;
194 unsigned char logcount;
196 struct ifqueue pkt_queue;
198 struct ipoib_dev_priv *priv;
201 struct ipoib_cm_rx_buf {
203 u64 mapping[IPOIB_CM_RX_SG];
206 struct ipoib_cm_tx_buf {
208 u64 mapping[IPOIB_CM_TX_SG];
211 struct ipoib_rx_buf {
213 u64 mapping[IPOIB_UD_RX_SG];
216 struct ipoib_tx_buf {
218 u64 mapping[IPOIB_UD_TX_SG];
223 struct ipoib_cm_data {
224 __be32 qpn; /* High byte MUST be ignored on receive */
229 * Quoting 10.3.1 Queue Pair and EE Context States:
231 * Note, for QPs that are associated with an SRQ, the Consumer should take the
232 * QP through the Error State before invoking a Destroy QP or a Modify QP to the
233 * Reset State. The Consumer may invoke the Destroy QP without first performing
234 * a Modify QP to the Error State and waiting for the Affiliated Asynchronous
235 * Last WQE Reached Event. However, if the Consumer does not wait for the
236 * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment
237 * leakage may occur. Therefore, it is good programming practice to tear down a
238 * QP that is associated with an SRQ by using the following process:
240 * - Put the QP in the Error State
241 * - Wait for the Affiliated Asynchronous Last WQE Reached Event;
243 * drain the CQ by invoking the Poll CQ verb and either wait for CQ
244 * to be empty or the number of Poll CQ operations has exceeded
247 * post another WR that completes on the same CQ and wait for this
248 * WR to return as a WC;
249 * - and then invoke a Destroy QP or Reset QP.
251 * We use the second option and wait for a completion on the
252 * same CQ before destroying QPs attached to our SRQ.
255 enum ipoib_cm_state {
257 IPOIB_CM_RX_ERROR, /* Ignored by stale task */
258 IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */
264 struct ipoib_cm_rx_buf *rx_ring;
265 struct list_head list;
266 struct ipoib_dev_priv *priv;
267 unsigned long jiffies;
268 enum ipoib_cm_state state;
275 struct list_head list;
276 struct ipoib_dev_priv *priv;
277 struct ipoib_path *path;
278 struct ipoib_cm_tx_buf *tx_ring;
282 u32 mtu; /* remote specified mtu, with grh. */
285 struct ipoib_cm_dev_priv {
287 struct ipoib_cm_rx_buf *srq_ring;
289 struct list_head passive_ids; /* state: LIVE */
290 struct list_head rx_error_list; /* state: ERROR */
291 struct list_head rx_flush_list; /* state: FLUSH, drain not started */
292 struct list_head rx_drain_list; /* state: FLUSH, drain started */
293 struct list_head rx_reap_list; /* state: FLUSH, drain done */
294 struct work_struct start_task;
295 struct work_struct reap_task;
296 struct work_struct mb_task;
297 struct work_struct rx_reap_task;
298 struct delayed_work stale_task;
299 struct ifqueue mb_queue;
300 struct list_head start_list;
301 struct list_head reap_list;
302 struct ib_sge rx_sge[IPOIB_CM_RX_SG];
303 struct ib_recv_wr rx_wr;
305 int max_cm_mtu; /* Actual buf size. */
309 struct ipoib_ethtool_st {
311 u16 max_coalesced_frames;
315 * Device private locking: network stack tx_lock protects members used
316 * in TX fast path, lock protects everything else. lock nests inside
317 * of tx_lock (ie tx_lock must be acquired first if needed).
319 struct ipoib_dev_priv {
321 spinlock_t drain_lock;
325 u8 broadcastaddr[INFINIBAND_ALEN];
332 struct mutex vlan_mutex;
334 struct rb_root path_tree;
335 struct list_head path_list;
337 struct ipoib_mcast *broadcast;
338 struct list_head multicast_list;
339 struct rb_root multicast_tree;
341 struct delayed_work pkey_poll_task;
342 struct delayed_work mcast_task;
343 struct work_struct carrier_on_task;
344 struct work_struct flush_light;
345 struct work_struct flush_normal;
346 struct work_struct flush_heavy;
347 struct work_struct restart_task;
348 struct delayed_work ah_reap_task;
350 struct ib_device *ca;
355 struct ib_cq *recv_cq;
356 struct ib_cq *send_cq;
360 union ib_gid local_gid;
363 unsigned int admin_mtu; /* User selected MTU, no GRH. */
364 unsigned int mcast_mtu; /* Minus GRH bytes, from mcast group. */
365 unsigned int max_ib_mtu; /* Without header, actual buf size. */
367 struct ipoib_rx_buf *rx_ring;
369 struct ipoib_tx_buf *tx_ring;
372 struct ib_sge tx_sge[IPOIB_MAX_TX_SG];
373 struct ib_ud_wr tx_wr;
374 unsigned tx_outstanding;
375 struct ib_wc send_wc[MAX_SEND_CQE];
377 struct ib_recv_wr rx_wr;
378 struct ib_sge rx_sge[IPOIB_MAX_RX_SG];
380 struct ib_wc ibwc[IPOIB_NUM_WC];
382 struct list_head dead_ahs;
384 struct ib_event_handler event_handler;
386 struct ifnet *parent;
387 struct list_head child_intfs;
388 struct list_head list;
390 #ifdef CONFIG_INFINIBAND_IPOIB_CM
391 struct ipoib_cm_dev_priv cm;
394 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
395 struct list_head fs_list;
396 struct dentry *mcg_dentry;
397 struct dentry *path_dentry;
400 struct ipoib_ethtool_st ethtool;
401 struct timer_list poll_timer;
405 struct ipoib_dev_priv *priv;
407 struct list_head list;
413 struct ipoib_dev_priv *priv;
414 struct rb_node rb_node;
415 struct list_head list;
416 #ifdef CONFIG_INFINIBAND_IPOIB_CM
417 uint8_t hwaddr[INFINIBAND_ALEN];
418 struct ipoib_cm_tx *cm;
421 struct ib_sa_path_rec pathrec;
422 struct ifqueue queue;
425 struct ib_sa_query *query;
426 struct completion done;
431 /* UD Only transmits encap len but we want the two sizes to be symmetrical. */
432 #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN)
433 #define IPOIB_CM_MTU(ib_mtu) (ib_mtu - 0x10)
435 #define IPOIB_IS_MULTICAST(addr) ((addr)[4] == 0xff)
437 extern struct workqueue_struct *ipoib_workqueue;
439 #define IPOIB_MTAP_PROTO(_ifp, _m, _proto) \
441 if (bpf_peers_present((_ifp)->if_bpf)) { \
443 ipoib_mtap_proto((_ifp), (_m), (_proto)); \
448 void ipoib_mtap_proto(struct ifnet *ifp, struct mbuf *mb, uint16_t proto);
449 void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
450 void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr);
452 struct ipoib_ah *ipoib_create_ah(struct ipoib_dev_priv *,
453 struct ib_pd *pd, struct ib_ah_attr *attr);
454 void ipoib_free_ah(struct kref *kref);
455 static inline void ipoib_put_ah(struct ipoib_ah *ah)
457 kref_put(&ah->ref, ipoib_free_ah);
460 int ipoib_open(struct ipoib_dev_priv *priv);
461 int ipoib_add_pkey_attr(struct ipoib_dev_priv *priv);
462 int ipoib_add_umcast_attr(struct ipoib_dev_priv *priv);
464 void ipoib_demux(struct ifnet *ifp, struct mbuf *m, u_short proto);
466 void ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb,
467 struct ipoib_ah *address, u32 qpn);
468 void ipoib_reap_ah(struct work_struct *work);
470 void ipoib_mark_paths_invalid(struct ipoib_dev_priv *priv);
471 void ipoib_flush_paths(struct ipoib_dev_priv *priv);
472 struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
474 int ipoib_ib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca,
476 void ipoib_ib_dev_flush_light(struct work_struct *work);
477 void ipoib_ib_dev_flush_normal(struct work_struct *work);
478 void ipoib_ib_dev_flush_heavy(struct work_struct *work);
479 void ipoib_pkey_event(struct work_struct *work);
480 void ipoib_ib_dev_cleanup(struct ipoib_dev_priv *priv);
482 int ipoib_ib_dev_open(struct ipoib_dev_priv *priv);
483 int ipoib_ib_dev_up(struct ipoib_dev_priv *priv);
484 int ipoib_ib_dev_down(struct ipoib_dev_priv *priv, int flush);
485 int ipoib_ib_dev_stop(struct ipoib_dev_priv *priv, int flush);
487 int ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port);
488 void ipoib_dev_cleanup(struct ipoib_dev_priv *priv);
490 void ipoib_mcast_join_task(struct work_struct *work);
491 void ipoib_mcast_carrier_on_task(struct work_struct *work);
492 void ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb);
494 void ipoib_mcast_restart_task(struct work_struct *work);
495 void ipoib_mcast_restart(struct ipoib_dev_priv *);
496 int ipoib_mcast_start_thread(struct ipoib_dev_priv *priv);
497 int ipoib_mcast_stop_thread(struct ipoib_dev_priv *priv, int flush);
499 void ipoib_mcast_dev_down(struct ipoib_dev_priv *priv);
500 void ipoib_mcast_dev_flush(struct ipoib_dev_priv *priv);
502 void ipoib_path_free(struct ipoib_dev_priv *priv, struct ipoib_path *path);
503 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
504 struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct ipoib_dev_priv *priv);
505 int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
506 void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
508 unsigned long *created,
509 unsigned int *queuelen,
510 unsigned int *complete,
511 unsigned int *send_only);
513 struct ipoib_path_iter *ipoib_path_iter_init(struct ipoib_dev_priv *priv);
514 int ipoib_path_iter_next(struct ipoib_path_iter *iter);
515 void ipoib_path_iter_read(struct ipoib_path_iter *iter,
516 struct ipoib_path *path);
519 int ipoib_change_mtu(struct ipoib_dev_priv *priv, int new_mtu);
521 int ipoib_mcast_attach(struct ipoib_dev_priv *priv, u16 mlid,
522 union ib_gid *mgid, int set_qkey);
524 int ipoib_init_qp(struct ipoib_dev_priv *priv);
525 int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca);
526 void ipoib_transport_dev_cleanup(struct ipoib_dev_priv *priv);
528 void ipoib_event(struct ib_event_handler *handler,
529 struct ib_event *record);
531 void ipoib_pkey_poll(struct work_struct *work);
532 int ipoib_pkey_dev_delay_open(struct ipoib_dev_priv *priv);
533 void ipoib_drain_cq(struct ipoib_dev_priv *priv);
535 int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req, int max);
536 void ipoib_dma_unmap_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req);
537 int ipoib_poll_tx(struct ipoib_dev_priv *priv);
539 void ipoib_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req);
540 void ipoib_dma_mb(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int length);
541 struct mbuf *ipoib_alloc_map_mb(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req, int size);
544 void ipoib_set_ethtool_ops(struct ifnet *dev);
545 int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca);
547 #ifdef CONFIG_INFINIBAND_IPOIB_CM
549 #define IPOIB_FLAGS_RC 0x80
550 #define IPOIB_FLAGS_UC 0x40
552 /* We don't support UC connections at the moment */
553 #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC))
555 extern int ipoib_max_conn_qp;
557 static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)
559 return IPOIB_CM_SUPPORTED(IF_LLADDR(priv->dev));
562 static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)
564 return IPOIB_CM_SUPPORTED(hwaddr);
567 static inline int ipoib_cm_up(struct ipoib_path *path)
570 return test_bit(IPOIB_FLAG_OPER_UP, &path->cm->flags);
573 static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
578 static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
583 static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)
585 return !!priv->cm.srq;
588 static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)
590 return priv->cm.max_cm_mtu;
593 void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx);
594 int ipoib_cm_dev_open(struct ipoib_dev_priv *priv);
595 void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv);
596 int ipoib_cm_dev_init(struct ipoib_dev_priv *priv);
597 int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv);
598 void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv);
599 struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv,
600 struct ipoib_path *path);
601 void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx);
602 void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,
604 void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);
605 void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);
610 #define ipoib_max_conn_qp 0
612 static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)
616 static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)
622 static inline int ipoib_cm_up(struct ipoib_path *path)
628 static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
633 static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
637 static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)
642 static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)
648 void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx)
654 int ipoib_cm_dev_open(struct ipoib_dev_priv *priv)
660 void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv)
666 int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)
672 void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv)
678 struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv, struct ipoib_path *path)
684 void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
690 int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv)
695 static inline void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,
701 static inline void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
705 static inline void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
710 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
711 void ipoib_create_debug_files(struct ipoib_dev_priv *priv);
712 void ipoib_delete_debug_files(struct ipoib_dev_priv *priv);
713 int ipoib_register_debugfs(void);
714 void ipoib_unregister_debugfs(void);
716 static inline void ipoib_create_debug_files(struct ipoib_dev_priv *priv) { }
717 static inline void ipoib_delete_debug_files(struct ipoib_dev_priv *priv) { }
718 static inline int ipoib_register_debugfs(void) { return 0; }
719 static inline void ipoib_unregister_debugfs(void) { }
722 #define ipoib_printk(level, priv, format, arg...) \
723 printk(level "%s: " format, if_name(((struct ipoib_dev_priv *) priv)->dev), ## arg)
724 #define ipoib_warn(priv, format, arg...) \
725 ipoib_printk(KERN_WARNING, priv, format , ## arg)
727 extern int ipoib_sendq_size;
728 extern int ipoib_recvq_size;
730 extern struct ib_sa_client ipoib_sa_client;
732 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
733 extern int ipoib_debug_level;
735 #define ipoib_dbg(priv, format, arg...) \
737 if (ipoib_debug_level > 0) \
738 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
740 #define ipoib_dbg_mcast(priv, format, arg...) \
742 if (mcast_debug_level > 0) \
743 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
745 #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */
746 #define ipoib_dbg(priv, format, arg...) \
747 do { (void) (priv); } while (0)
748 #define ipoib_dbg_mcast(priv, format, arg...) \
749 do { (void) (priv); } while (0)
750 #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
752 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
753 #define ipoib_dbg_data(priv, format, arg...) \
755 if (data_debug_level > 0) \
756 ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
758 #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
759 #define ipoib_dbg_data(priv, format, arg...) \
760 do { (void) (priv); } while (0)
761 #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
763 #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
765 #endif /* _IPOIB_H */