ipoib.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
  3. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  4. * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
  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. #ifndef _IPOIB_H
  37. #define _IPOIB_H
  38. #include <linux/list.h>
  39. #include <linux/skbuff.h>
  40. #include <linux/netdevice.h>
  41. #include <linux/workqueue.h>
  42. #include <linux/kref.h>
  43. #include <linux/if_infiniband.h>
  44. #include <linux/mutex.h>
  45. #include <net/neighbour.h>
  46. #include <asm/atomic.h>
  47. #include <rdma/ib_verbs.h>
  48. #include <rdma/ib_pack.h>
  49. #include <rdma/ib_sa.h>
  50. /* constants */
  51. enum {
  52. IPOIB_PACKET_SIZE = 2048,
  53. IPOIB_BUF_SIZE = IPOIB_PACKET_SIZE + IB_GRH_BYTES,
  54. IPOIB_ENCAP_LEN = 4,
  55. IPOIB_CM_MTU = 0x10000 - 0x10, /* padding to align header to 16 */
  56. IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN,
  57. IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE,
  58. IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE,
  59. IPOIB_RX_RING_SIZE = 128,
  60. IPOIB_TX_RING_SIZE = 64,
  61. IPOIB_MAX_QUEUE_SIZE = 8192,
  62. IPOIB_MIN_QUEUE_SIZE = 2,
  63. IPOIB_NUM_WC = 4,
  64. IPOIB_MAX_PATH_REC_QUEUE = 3,
  65. IPOIB_MAX_MCAST_QUEUE = 3,
  66. IPOIB_FLAG_OPER_UP = 0,
  67. IPOIB_FLAG_INITIALIZED = 1,
  68. IPOIB_FLAG_ADMIN_UP = 2,
  69. IPOIB_PKEY_ASSIGNED = 3,
  70. IPOIB_PKEY_STOP = 4,
  71. IPOIB_FLAG_SUBINTERFACE = 5,
  72. IPOIB_MCAST_RUN = 6,
  73. IPOIB_STOP_REAPER = 7,
  74. IPOIB_MCAST_STARTED = 8,
  75. IPOIB_FLAG_NETIF_STOPPED = 9,
  76. IPOIB_FLAG_ADMIN_CM = 10,
  77. IPOIB_MAX_BACKOFF_SECONDS = 16,
  78. IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */
  79. IPOIB_MCAST_FLAG_SENDONLY = 1,
  80. IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
  81. IPOIB_MCAST_FLAG_ATTACHED = 3,
  82. };
  83. #define IPOIB_OP_RECV (1ul << 31)
  84. #ifdef CONFIG_INFINIBAND_IPOIB_CM
  85. #define IPOIB_CM_OP_SRQ (1ul << 30)
  86. #else
  87. #define IPOIB_CM_OP_SRQ (0)
  88. #endif
  89. /* structs */
  90. struct ipoib_header {
  91. __be16 proto;
  92. u16 reserved;
  93. };
  94. struct ipoib_pseudoheader {
  95. u8 hwaddr[INFINIBAND_ALEN];
  96. };
  97. struct ipoib_mcast;
  98. struct ipoib_rx_buf {
  99. struct sk_buff *skb;
  100. u64 mapping;
  101. };
  102. struct ipoib_tx_buf {
  103. struct sk_buff *skb;
  104. u64 mapping;
  105. };
  106. struct ib_cm_id;
  107. struct ipoib_cm_data {
  108. __be32 qpn; /* High byte MUST be ignored on receive */
  109. __be32 mtu;
  110. };
  111. /*
  112. * Quoting 10.3.1 Queue Pair and EE Context States:
  113. *
  114. * Note, for QPs that are associated with an SRQ, the Consumer should take the
  115. * QP through the Error State before invoking a Destroy QP or a Modify QP to the
  116. * Reset State. The Consumer may invoke the Destroy QP without first performing
  117. * a Modify QP to the Error State and waiting for the Affiliated Asynchronous
  118. * Last WQE Reached Event. However, if the Consumer does not wait for the
  119. * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment
  120. * leakage may occur. Therefore, it is good programming practice to tear down a
  121. * QP that is associated with an SRQ by using the following process:
  122. *
  123. * - Put the QP in the Error State
  124. * - Wait for the Affiliated Asynchronous Last WQE Reached Event;
  125. * - either:
  126. * drain the CQ by invoking the Poll CQ verb and either wait for CQ
  127. * to be empty or the number of Poll CQ operations has exceeded
  128. * CQ capacity size;
  129. * - or
  130. * post another WR that completes on the same CQ and wait for this
  131. * WR to return as a WC;
  132. * - and then invoke a Destroy QP or Reset QP.
  133. *
  134. * We use the second option and wait for a completion on the
  135. * same CQ before destroying QPs attached to our SRQ.
  136. */
  137. enum ipoib_cm_state {
  138. IPOIB_CM_RX_LIVE,
  139. IPOIB_CM_RX_ERROR, /* Ignored by stale task */
  140. IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */
  141. };
  142. struct ipoib_cm_rx {
  143. struct ib_cm_id *id;
  144. struct ib_qp *qp;
  145. struct list_head list;
  146. struct net_device *dev;
  147. unsigned long jiffies;
  148. enum ipoib_cm_state state;
  149. };
  150. struct ipoib_cm_tx {
  151. struct ib_cm_id *id;
  152. struct ib_cq *cq;
  153. struct ib_qp *qp;
  154. struct list_head list;
  155. struct net_device *dev;
  156. struct ipoib_neigh *neigh;
  157. struct ipoib_path *path;
  158. struct ipoib_tx_buf *tx_ring;
  159. unsigned tx_head;
  160. unsigned tx_tail;
  161. unsigned long flags;
  162. u32 mtu;
  163. struct ib_wc ibwc[IPOIB_NUM_WC];
  164. };
  165. struct ipoib_cm_rx_buf {
  166. struct sk_buff *skb;
  167. u64 mapping[IPOIB_CM_RX_SG];
  168. };
  169. struct ipoib_cm_dev_priv {
  170. struct ib_srq *srq;
  171. struct ipoib_cm_rx_buf *srq_ring;
  172. struct ib_cm_id *id;
  173. struct list_head passive_ids; /* state: LIVE */
  174. struct list_head rx_error_list; /* state: ERROR */
  175. struct list_head rx_flush_list; /* state: FLUSH, drain not started */
  176. struct list_head rx_drain_list; /* state: FLUSH, drain started */
  177. struct list_head rx_reap_list; /* state: FLUSH, drain done */
  178. struct work_struct start_task;
  179. struct work_struct reap_task;
  180. struct work_struct skb_task;
  181. struct work_struct rx_reap_task;
  182. struct delayed_work stale_task;
  183. struct sk_buff_head skb_queue;
  184. struct list_head start_list;
  185. struct list_head reap_list;
  186. struct ib_wc ibwc[IPOIB_NUM_WC];
  187. struct ib_sge rx_sge[IPOIB_CM_RX_SG];
  188. struct ib_recv_wr rx_wr;
  189. };
  190. /*
  191. * Device private locking: tx_lock protects members used in TX fast
  192. * path (and we use LLTX so upper layers don't do extra locking).
  193. * lock protects everything else. lock nests inside of tx_lock (ie
  194. * tx_lock must be acquired first if needed).
  195. */
  196. struct ipoib_dev_priv {
  197. spinlock_t lock;
  198. struct net_device *dev;
  199. unsigned long flags;
  200. struct mutex mcast_mutex;
  201. struct mutex vlan_mutex;
  202. struct rb_root path_tree;
  203. struct list_head path_list;
  204. struct ipoib_mcast *broadcast;
  205. struct list_head multicast_list;
  206. struct rb_root multicast_tree;
  207. struct delayed_work pkey_poll_task;
  208. struct delayed_work mcast_task;
  209. struct work_struct flush_task;
  210. struct work_struct restart_task;
  211. struct delayed_work ah_reap_task;
  212. struct work_struct pkey_event_task;
  213. struct ib_device *ca;
  214. u8 port;
  215. u16 pkey;
  216. u16 pkey_index;
  217. struct ib_pd *pd;
  218. struct ib_mr *mr;
  219. struct ib_cq *cq;
  220. struct ib_qp *qp;
  221. u32 qkey;
  222. union ib_gid local_gid;
  223. u16 local_lid;
  224. unsigned int admin_mtu;
  225. unsigned int mcast_mtu;
  226. struct ipoib_rx_buf *rx_ring;
  227. spinlock_t tx_lock;
  228. struct ipoib_tx_buf *tx_ring;
  229. unsigned tx_head;
  230. unsigned tx_tail;
  231. struct ib_sge tx_sge;
  232. struct ib_send_wr tx_wr;
  233. struct ib_wc ibwc[IPOIB_NUM_WC];
  234. struct list_head dead_ahs;
  235. struct ib_event_handler event_handler;
  236. struct net_device_stats stats;
  237. struct net_device *parent;
  238. struct list_head child_intfs;
  239. struct list_head list;
  240. #ifdef CONFIG_INFINIBAND_IPOIB_CM
  241. struct ipoib_cm_dev_priv cm;
  242. #endif
  243. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  244. struct list_head fs_list;
  245. struct dentry *mcg_dentry;
  246. struct dentry *path_dentry;
  247. #endif
  248. };
  249. struct ipoib_ah {
  250. struct net_device *dev;
  251. struct ib_ah *ah;
  252. struct list_head list;
  253. struct kref ref;
  254. unsigned last_send;
  255. };
  256. struct ipoib_path {
  257. struct net_device *dev;
  258. struct ib_sa_path_rec pathrec;
  259. struct ipoib_ah *ah;
  260. struct sk_buff_head queue;
  261. struct list_head neigh_list;
  262. int query_id;
  263. struct ib_sa_query *query;
  264. struct completion done;
  265. struct rb_node rb_node;
  266. struct list_head list;
  267. };
  268. struct ipoib_neigh {
  269. struct ipoib_ah *ah;
  270. #ifdef CONFIG_INFINIBAND_IPOIB_CM
  271. struct ipoib_cm_tx *cm;
  272. #endif
  273. union ib_gid dgid;
  274. struct sk_buff_head queue;
  275. struct neighbour *neighbour;
  276. struct list_head list;
  277. };
  278. /*
  279. * We stash a pointer to our private neighbour information after our
  280. * hardware address in neigh->ha. The ALIGN() expression here makes
  281. * sure that this pointer is stored aligned so that an unaligned
  282. * load is not needed to dereference it.
  283. */
  284. static inline struct ipoib_neigh **to_ipoib_neigh(struct neighbour *neigh)
  285. {
  286. return (void*) neigh + ALIGN(offsetof(struct neighbour, ha) +
  287. INFINIBAND_ALEN, sizeof(void *));
  288. }
  289. struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh);
  290. void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh);
  291. extern struct workqueue_struct *ipoib_workqueue;
  292. /* functions */
  293. int ipoib_poll(struct net_device *dev, int *budget);
  294. void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
  295. struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
  296. struct ib_pd *pd, struct ib_ah_attr *attr);
  297. void ipoib_free_ah(struct kref *kref);
  298. static inline void ipoib_put_ah(struct ipoib_ah *ah)
  299. {
  300. kref_put(&ah->ref, ipoib_free_ah);
  301. }
  302. int ipoib_open(struct net_device *dev);
  303. int ipoib_add_pkey_attr(struct net_device *dev);
  304. void ipoib_send(struct net_device *dev, struct sk_buff *skb,
  305. struct ipoib_ah *address, u32 qpn);
  306. void ipoib_reap_ah(struct work_struct *work);
  307. void ipoib_flush_paths(struct net_device *dev);
  308. struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
  309. int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
  310. void ipoib_ib_dev_flush(struct work_struct *work);
  311. void ipoib_pkey_event(struct work_struct *work);
  312. void ipoib_ib_dev_cleanup(struct net_device *dev);
  313. int ipoib_ib_dev_open(struct net_device *dev);
  314. int ipoib_ib_dev_up(struct net_device *dev);
  315. int ipoib_ib_dev_down(struct net_device *dev, int flush);
  316. int ipoib_ib_dev_stop(struct net_device *dev, int flush);
  317. int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
  318. void ipoib_dev_cleanup(struct net_device *dev);
  319. void ipoib_mcast_join_task(struct work_struct *work);
  320. void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
  321. void ipoib_mcast_restart_task(struct work_struct *work);
  322. int ipoib_mcast_start_thread(struct net_device *dev);
  323. int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
  324. void ipoib_mcast_dev_down(struct net_device *dev);
  325. void ipoib_mcast_dev_flush(struct net_device *dev);
  326. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  327. struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev);
  328. int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
  329. void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
  330. union ib_gid *gid,
  331. unsigned long *created,
  332. unsigned int *queuelen,
  333. unsigned int *complete,
  334. unsigned int *send_only);
  335. struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev);
  336. int ipoib_path_iter_next(struct ipoib_path_iter *iter);
  337. void ipoib_path_iter_read(struct ipoib_path_iter *iter,
  338. struct ipoib_path *path);
  339. #endif
  340. int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
  341. union ib_gid *mgid);
  342. int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
  343. union ib_gid *mgid);
  344. int ipoib_init_qp(struct net_device *dev);
  345. int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
  346. void ipoib_transport_dev_cleanup(struct net_device *dev);
  347. void ipoib_event(struct ib_event_handler *handler,
  348. struct ib_event *record);
  349. int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
  350. int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
  351. void ipoib_pkey_poll(struct work_struct *work);
  352. int ipoib_pkey_dev_delay_open(struct net_device *dev);
  353. void ipoib_drain_cq(struct net_device *dev);
  354. #ifdef CONFIG_INFINIBAND_IPOIB_CM
  355. #define IPOIB_FLAGS_RC 0x80
  356. #define IPOIB_FLAGS_UC 0x40
  357. /* We don't support UC connections at the moment */
  358. #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC))
  359. static inline int ipoib_cm_admin_enabled(struct net_device *dev)
  360. {
  361. struct ipoib_dev_priv *priv = netdev_priv(dev);
  362. return IPOIB_CM_SUPPORTED(dev->dev_addr) &&
  363. test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
  364. }
  365. static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n)
  366. {
  367. struct ipoib_dev_priv *priv = netdev_priv(dev);
  368. return IPOIB_CM_SUPPORTED(n->ha) &&
  369. test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
  370. }
  371. static inline int ipoib_cm_up(struct ipoib_neigh *neigh)
  372. {
  373. return test_bit(IPOIB_FLAG_OPER_UP, &neigh->cm->flags);
  374. }
  375. static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh)
  376. {
  377. return neigh->cm;
  378. }
  379. static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx)
  380. {
  381. neigh->cm = tx;
  382. }
  383. void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx);
  384. int ipoib_cm_dev_open(struct net_device *dev);
  385. void ipoib_cm_dev_stop(struct net_device *dev);
  386. int ipoib_cm_dev_init(struct net_device *dev);
  387. int ipoib_cm_add_mode_attr(struct net_device *dev);
  388. void ipoib_cm_dev_cleanup(struct net_device *dev);
  389. struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path,
  390. struct ipoib_neigh *neigh);
  391. void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx);
  392. void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb,
  393. unsigned int mtu);
  394. void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc);
  395. #else
  396. struct ipoib_cm_tx;
  397. static inline int ipoib_cm_admin_enabled(struct net_device *dev)
  398. {
  399. return 0;
  400. }
  401. static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n)
  402. {
  403. return 0;
  404. }
  405. static inline int ipoib_cm_up(struct ipoib_neigh *neigh)
  406. {
  407. return 0;
  408. }
  409. static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh)
  410. {
  411. return NULL;
  412. }
  413. static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx)
  414. {
  415. }
  416. static inline
  417. void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx)
  418. {
  419. return;
  420. }
  421. static inline
  422. int ipoib_cm_dev_open(struct net_device *dev)
  423. {
  424. return 0;
  425. }
  426. static inline
  427. void ipoib_cm_dev_stop(struct net_device *dev)
  428. {
  429. return;
  430. }
  431. static inline
  432. int ipoib_cm_dev_init(struct net_device *dev)
  433. {
  434. return -ENOSYS;
  435. }
  436. static inline
  437. void ipoib_cm_dev_cleanup(struct net_device *dev)
  438. {
  439. return;
  440. }
  441. static inline
  442. struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path,
  443. struct ipoib_neigh *neigh)
  444. {
  445. return NULL;
  446. }
  447. static inline
  448. void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
  449. {
  450. return;
  451. }
  452. static inline
  453. int ipoib_cm_add_mode_attr(struct net_device *dev)
  454. {
  455. return 0;
  456. }
  457. static inline void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb,
  458. unsigned int mtu)
  459. {
  460. dev_kfree_skb_any(skb);
  461. }
  462. static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
  463. {
  464. }
  465. #endif
  466. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  467. void ipoib_create_debug_files(struct net_device *dev);
  468. void ipoib_delete_debug_files(struct net_device *dev);
  469. int ipoib_register_debugfs(void);
  470. void ipoib_unregister_debugfs(void);
  471. #else
  472. static inline void ipoib_create_debug_files(struct net_device *dev) { }
  473. static inline void ipoib_delete_debug_files(struct net_device *dev) { }
  474. static inline int ipoib_register_debugfs(void) { return 0; }
  475. static inline void ipoib_unregister_debugfs(void) { }
  476. #endif
  477. #define ipoib_printk(level, priv, format, arg...) \
  478. printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg)
  479. #define ipoib_warn(priv, format, arg...) \
  480. ipoib_printk(KERN_WARNING, priv, format , ## arg)
  481. extern int ipoib_sendq_size;
  482. extern int ipoib_recvq_size;
  483. extern struct ib_sa_client ipoib_sa_client;
  484. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  485. extern int ipoib_debug_level;
  486. #define ipoib_dbg(priv, format, arg...) \
  487. do { \
  488. if (ipoib_debug_level > 0) \
  489. ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
  490. } while (0)
  491. #define ipoib_dbg_mcast(priv, format, arg...) \
  492. do { \
  493. if (mcast_debug_level > 0) \
  494. ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
  495. } while (0)
  496. #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */
  497. #define ipoib_dbg(priv, format, arg...) \
  498. do { (void) (priv); } while (0)
  499. #define ipoib_dbg_mcast(priv, format, arg...) \
  500. do { (void) (priv); } while (0)
  501. #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
  502. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
  503. #define ipoib_dbg_data(priv, format, arg...) \
  504. do { \
  505. if (data_debug_level > 0) \
  506. ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
  507. } while (0)
  508. #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
  509. #define ipoib_dbg_data(priv, format, arg...) \
  510. do { (void) (priv); } while (0)
  511. #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
  512. #define IPOIB_GID_FMT "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:" \
  513. "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x"
  514. #define IPOIB_GID_RAW_ARG(gid) ((u8 *)(gid))[0], \
  515. ((u8 *)(gid))[1], \
  516. ((u8 *)(gid))[2], \
  517. ((u8 *)(gid))[3], \
  518. ((u8 *)(gid))[4], \
  519. ((u8 *)(gid))[5], \
  520. ((u8 *)(gid))[6], \
  521. ((u8 *)(gid))[7], \
  522. ((u8 *)(gid))[8], \
  523. ((u8 *)(gid))[9], \
  524. ((u8 *)(gid))[10],\
  525. ((u8 *)(gid))[11],\
  526. ((u8 *)(gid))[12],\
  527. ((u8 *)(gid))[13],\
  528. ((u8 *)(gid))[14],\
  529. ((u8 *)(gid))[15]
  530. #define IPOIB_GID_ARG(gid) IPOIB_GID_RAW_ARG((gid).raw)
  531. #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
  532. #endif /* _IPOIB_H */