ipoib.h 20 KB

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