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