1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
32 * Copyright (C) 2006 Myricom, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
38 * lnet/klnds/mxlnd/mxlnd.h
40 * Author: Eric Barton <eric@bartonsoftware.com>
41 * Author: Scott Atchley <atchley at myri.com>
47 #ifndef AUTOCONF_INCLUDED
48 #include <linux/config.h>
50 #include <linux/module.h> /* module */
51 #include <linux/kernel.h> /* module */
53 #include <linux/string.h>
54 #include <linux/stat.h>
55 #include <linux/errno.h>
56 #include <linux/smp_lock.h>
57 #include <linux/unistd.h>
58 #include <linux/uio.h>
61 #include <asm/system.h>
62 #include <asm/uaccess.h>
65 #include <linux/init.h> /* module */
67 #include <linux/file.h>
68 #include <linux/stat.h>
69 #include <linux/list.h>
70 #include <linux/kmod.h>
71 #include <linux/sysctl.h>
72 #include <linux/random.h>
73 #include <linux/utsname.h>
74 #include <linux/jiffies.h> /* msecs_to_jiffies */
75 #include <asm/semaphore.h>
80 #include <asm/byteorder.h> /* __LITTLE_ENDIAN */
81 #include <net/arp.h> /* arp table */
82 #include <linux/netdevice.h> /* get_device_by_name */
83 #include <linux/inetdevice.h> /* neigh_lookup, etc. */
84 #include <linux/net.h> /* sock_create_kern, kernel_connect, sock_release */
86 #define DEBUG_SUBSYSTEM S_LND
88 #include "libcfs/libcfs.h"
89 #include "lnet/lnet.h"
90 #include "lnet/lib-lnet.h"
91 //#include <lnet/lnet-sysctl.h>
94 #include "mx_extensions.h"
95 #include "myriexpress.h"
97 #if LNET_MAX_IOV > MX_MAX_SEGMENTS
98 #error LNET_MAX_IOV is greater then MX_MAX_SEGMENTS
101 #define MXLND_MSG_MAGIC 0x4d583130 /* unique magic 'MX10' */
102 #define MXLND_MSG_VERSION 0x03
104 /* Using MX's 64 match bits
105 * We are using the match bits to specify message type and the cookie. The
106 * highest four bits (60-63) are reserved for message type. Below we specify
107 * the types. We reserve the remaining combinations for future use. The next 8
108 * bits (52-59) are reserved for returning a status code for failed GET_DATA
109 * (payload) messages. The last 52 bits are used for cookies. That should allow
110 * unique cookies for 4 KB messages at 10 Gbps line rate without rollover for
111 * about 8 years. That should be enough. */
113 #define MXLND_MSG_OFFSET 60 /* msg type offset */
114 #define MXLND_MSG_BITS (64 - MXLND_MSG_OFFSET)
115 #define MXLND_MSG_MASK (((1ULL<<MXLND_MSG_BITS) - 1) << MXLND_MSG_OFFSET)
116 #define MXLND_MSG_TYPE(x) (((x) & MXLND_MSG_MASK) >> MXLND_MSG_OFFSET)
118 #define MXLND_ERROR_OFFSET 52 /* error value offset */
119 #define MXLND_ERROR_BITS (MXLND_MSG_OFFSET - MXLND_ERROR_OFFSET)
120 #define MXLND_ERROR_MASK (((1ULL<<MXLND_ERROR_BITS) - 1) << MXLND_ERROR_OFFSET)
121 #define MXLND_ERROR_VAL(x) (((x) & MXLND_ERROR_MASK) >> MXLND_ERROR_OFFSET)
124 #define MXLND_MSG_ICON_REQ 0xb /* mx_iconnect() before CONN_REQ */
125 #define MXLND_MSG_CONN_REQ 0xc /* connection request */
126 #define MXLND_MSG_ICON_ACK 0x9 /* mx_iconnect() before CONN_ACK */
127 #define MXLND_MSG_CONN_ACK 0xa /* connection request response */
128 #define MXLND_MSG_BYE 0xd /* disconnect msg */
129 #define MXLND_MSG_EAGER 0xe /* eager message */
130 #define MXLND_MSG_NOOP 0x1 /* no msg, return credits */
131 #define MXLND_MSG_PUT_REQ 0x2 /* put request src->sink */
132 #define MXLND_MSG_PUT_ACK 0x3 /* put ack src<-sink */
133 #define MXLND_MSG_PUT_DATA 0x4 /* put payload src->sink */
134 #define MXLND_MSG_GET_REQ 0x5 /* get request sink->src */
135 #define MXLND_MSG_GET_DATA 0x6 /* get payload sink<-src */
137 /* when to roll-over the cookie value */
138 #define MXLND_MAX_COOKIE ((1ULL << MXLND_ERROR_OFFSET) - 1)
140 /* defaults for configurable parameters */
141 #define MXLND_N_SCHED 1 /* # schedulers (mx_wait_any() threads) */
142 #define MXLND_NDAEMONS 3 /* connd, timeoutd, tx_queued */
143 #define MXLND_MX_BOARD 0 /* Use the first MX NIC if more than 1 avail */
144 #define MXLND_MX_EP_ID 0 /* MX endpoint ID */
145 #define MXLND_COMM_TIMEOUT (20 * HZ) /* timeout for send/recv (jiffies) */
146 #define MXLND_WAIT_TIMEOUT HZ /* timeout for wait (jiffies) */
147 #define MXLND_CONNECT_TIMEOUT (5 * HZ) /* timeout for connections (jiffies) */
148 #define MXLND_POLLING 1000 /* poll iterations before blocking */
149 #define MXLND_LOOKUP_COUNT 5 /* how many times to try to resolve MAC */
150 #define MXLND_MAX_PEERS 1024 /* number of nodes talking to me */
152 #define MXLND_MSG_SIZE (4<<10) /* pre-posted eager message size */
153 #define MXLND_MSG_QUEUE_DEPTH 8 /* default msg queue depth */
154 #define MXLND_NTX 256 /* default # of tx msg descriptors */
156 #define MXLND_HASH_BITS 6 /* the number of bits to hash over */
157 #define MXLND_HASH_SIZE (1<<MXLND_HASH_BITS)
158 /* number of peer lists for lookup.
159 we hash over the last N bits of
160 the IP address converted to an int. */
161 #define MXLND_HASH_MASK (MXLND_HASH_SIZE - 1)
162 /* ensure we use only the last N bits */
164 /* derived constants... */
165 /* TX messages (shared by all connections) */
166 #define MXLND_TX_MSGS() (*kmxlnd_tunables.kmx_ntx)
167 #define MXLND_TX_MSG_BYTES() (MXLND_TX_MSGS() * MXLND_MSG_SIZE)
168 #define MXLND_TX_MSG_PAGES() ((MXLND_TX_MSG_BYTES() + PAGE_SIZE - 1)/PAGE_SIZE)
170 /* RX messages (per connection) */
171 #define MXLND_RX_MSGS() (*kmxlnd_tunables.kmx_peercredits)
172 #define MXLND_RX_MSG_BYTES() (MXLND_RX_MSGS() * MXLND_MSG_SIZE)
173 #define MXLND_RX_MSG_PAGES() ((MXLND_RX_MSG_BYTES() + PAGE_SIZE - 1)/PAGE_SIZE)
174 #define MXLND_CREDIT_HIGHWATER() (*kmxlnd_tunables.kmx_peercredits - 2)
175 /* when to send a noop to return credits */
177 /* debugging features */
178 #define MXLND_CKSUM 0 /* checksum kmx_msg_t */
179 #define MXLND_DEBUG 0 /* additional CDEBUG messages */
181 /* provide wrappers around LIBCFS_ALLOC/FREE to keep MXLND specific
182 * memory usage stats that include pages */
184 #define MXLND_ALLOC(x, size) \
186 spin_lock(&kmxlnd_data.kmx_mem_lock); \
187 kmxlnd_data.kmx_mem_used += size; \
188 spin_unlock(&kmxlnd_data.kmx_mem_lock); \
189 LIBCFS_ALLOC(x, size); \
190 if (unlikely(x == NULL)) { \
191 spin_lock(&kmxlnd_data.kmx_mem_lock); \
192 kmxlnd_data.kmx_mem_used -= size; \
193 spin_unlock(&kmxlnd_data.kmx_mem_lock); \
197 #define MXLND_FREE(x, size) \
199 spin_lock(&kmxlnd_data.kmx_mem_lock); \
200 kmxlnd_data.kmx_mem_used -= size; \
201 spin_unlock(&kmxlnd_data.kmx_mem_lock); \
202 LIBCFS_FREE(x, size); \
206 typedef struct kmx_tunables
208 int *kmx_n_waitd; /* # completion threads */
209 int *kmx_max_peers; /* max # of potential peers */
210 int *kmx_cksum; /* checksum small msgs? */
211 int *kmx_ntx; /* total # of tx */
212 int *kmx_credits; /* concurrent sends to all peers */
213 int *kmx_peercredits; /* concurrent sends to 1 peer */
214 int *kmx_board; /* MX board (NIC) number */
215 int *kmx_ep_id; /* MX endpoint number */
216 char **kmx_default_ipif; /* IPoMX interface name */
217 int *kmx_polling; /* if 0, block. if > 0, poll this many
218 iterations before blocking */
223 int mxg_npages; /* # pages */
224 struct page *mxg_pages[0];
227 /* global interface state */
228 typedef struct kmx_data
230 int kmx_init; /* initialization state */
231 atomic_t kmx_shutdown; /* shutting down? */
232 atomic_t kmx_nthreads; /* number of threads */
233 struct completion *kmx_completions; /* array of completion structs */
234 lnet_ni_t *kmx_ni; /* the LND instance */
235 u64 kmx_incarnation; /* my incarnation value */
236 long kmx_mem_used; /* memory used */
237 mx_endpoint_t kmx_endpt; /* the MX endpoint */
238 mx_endpoint_addr_t kmx_epa; /* the MX endpoint address */
240 rwlock_t kmx_global_lock; /* global lock */
241 spinlock_t kmx_mem_lock; /* memory accounting lock */
243 struct list_head kmx_conn_reqs; /* list of connection requests */
244 spinlock_t kmx_conn_lock; /* connection list lock */
245 struct semaphore kmx_conn_sem; /* semaphore for connection request list */
246 struct list_head kmx_conn_zombies; /* list of zombie connections */
247 struct list_head kmx_orphan_msgs; /* list of txs to cancel */
249 /* list of all known peers */
250 struct list_head kmx_peers[MXLND_HASH_SIZE];
251 atomic_t kmx_npeers; /* number of peers */
253 kmx_pages_t *kmx_tx_pages; /* tx msg pages */
255 struct kmx_ctx *kmx_txs; /* all tx descriptors */
256 struct list_head kmx_tx_idle; /* list of idle tx */
257 spinlock_t kmx_tx_idle_lock; /* lock for idle tx list */
258 s32 kmx_tx_used; /* txs in use */
259 u64 kmx_tx_next_cookie; /* unique id for tx */
260 struct list_head kmx_tx_queue; /* generic send queue */
261 spinlock_t kmx_tx_queue_lock; /* lock for generic sends */
262 struct semaphore kmx_tx_queue_sem; /* semaphore for tx queue */
265 #define MXLND_INIT_NOTHING 0 /* in the beginning, there was nothing... */
266 #define MXLND_INIT_DATA 1 /* main data structures created */
267 #define MXLND_INIT_TXS 2 /* tx descriptors created */
268 #define MXLND_INIT_MX 3 /* initiate MX library, open endpoint, get NIC id */
269 #define MXLND_INIT_THREADS 4 /* waitd, timeoutd, tx_queued threads */
270 #define MXLND_INIT_ALL 5 /* startup completed */
272 /************************************************************************
273 * MXLND Wire message format.
274 * These are sent in sender's byte order (i.e. receiver flips).
277 typedef struct kmx_connreq_msg
279 u32 mxcrm_queue_depth; /* per peer max messages in flight */
280 u32 mxcrm_eager_size; /* size of preposted eager messages */
281 } WIRE_ATTR kmx_connreq_msg_t;
283 typedef struct kmx_eager_msg
285 lnet_hdr_t mxem_hdr; /* lnet header */
286 char mxem_payload[0]; /* piggy-backed payload */
287 } WIRE_ATTR kmx_eager_msg_t;
289 typedef struct kmx_putreq_msg
291 lnet_hdr_t mxprm_hdr; /* lnet header */
292 u64 mxprm_cookie; /* opaque completion cookie */
293 } WIRE_ATTR kmx_putreq_msg_t;
295 typedef struct kmx_putack_msg
297 u64 mxpam_src_cookie; /* reflected completion cookie */
298 u64 mxpam_dst_cookie; /* opaque completion cookie */
299 } WIRE_ATTR kmx_putack_msg_t;
301 typedef struct kmx_getreq_msg
303 lnet_hdr_t mxgrm_hdr; /* lnet header */
304 u64 mxgrm_cookie; /* opaque completion cookie */
305 } WIRE_ATTR kmx_getreq_msg_t;
307 typedef struct kmx_msg
309 /* First two fields fixed for all time */
310 u32 mxm_magic; /* MXLND message */
311 u16 mxm_version; /* version number */
313 u8 mxm_type; /* message type */
314 u8 mxm_credits; /* returned credits */
315 u32 mxm_nob; /* # of bytes in whole message */
316 u32 mxm_cksum; /* checksum (0 == no checksum) */
317 u64 mxm_srcnid; /* sender's NID */
318 u64 mxm_srcstamp; /* sender's incarnation */
319 u64 mxm_dstnid; /* destination's NID */
320 u64 mxm_dststamp; /* destination's incarnation */
323 kmx_connreq_msg_t conn_req;
324 kmx_eager_msg_t eager;
325 kmx_putreq_msg_t put_req;
326 kmx_putack_msg_t put_ack;
327 kmx_getreq_msg_t get_req;
329 } WIRE_ATTR kmx_msg_t;
331 /***********************************************************************/
338 /* The life cycle of a request */
340 MXLND_CTX_INIT = 0, /* just created */
341 MXLND_CTX_IDLE = 1, /* available for use */
342 MXLND_CTX_PREP = 2, /* getting ready for send/recv */
343 MXLND_CTX_PENDING = 3, /* mx_isend() or mx_irecv() called */
344 MXLND_CTX_COMPLETED = 4, /* cleaning up after completion or timeout */
345 MXLND_CTX_CANCELED = 5, /* timed out but still in ctx list */
348 /* Context Structure - generic tx/rx descriptor
349 * It represents the context (or state) of each send or receive request.
350 * In other LNDs, they have separate TX and RX descriptors and this replaces both.
352 * The txs live on the global kmx_txs array for cleanup. The rxs are managed
353 * per struct kmx_conn. We will move them between the rx/tx idle lists and the
354 * pending list which is monitored by mxlnd_timeoutd().
356 typedef struct kmx_ctx
358 enum kmx_req_type mxc_type; /* TX or RX */
359 u64 mxc_incarnation; /* store the peer's incarnation here
360 to verify before changing flow
361 control credits after completion */
362 unsigned long mxc_deadline; /* request time out in absolute jiffies */
363 enum kmx_req_state mxc_state; /* what is the state of the request? */
364 struct list_head mxc_list; /* place on rx/tx idle list, tx q, peer tx */
365 struct list_head mxc_rx_list; /* place on mxp_rx_posted list */
367 lnet_nid_t mxc_nid; /* dst's NID if peer is not known */
368 struct kmx_peer *mxc_peer; /* owning peer */
369 struct kmx_conn *mxc_conn; /* owning conn */
370 kmx_msg_t *mxc_msg; /* msg hdr mapped to mxc_page */
371 lnet_msg_t *mxc_lntmsg[2]; /* lnet msgs to finalize */
373 u8 mxc_msg_type; /* what type of message is this? */
374 u64 mxc_cookie; /* completion cookie */
375 u64 mxc_match; /* MX match info */
376 mx_ksegment_t mxc_seg; /* local MX ksegment for non-DATA */
377 mx_ksegment_t *mxc_seg_list; /* MX ksegment array for DATA */
378 int mxc_nseg; /* number of segments */
379 unsigned long mxc_pin_type; /* MX_PIN_PHYSICAL [| MX_PIN_FULLPAGES] */
380 u32 mxc_nob; /* number of bytes sent/received */
381 mx_request_t mxc_mxreq; /* MX request */
382 mx_status_t mxc_status; /* MX status */
383 u32 mxc_errno; /* errno for LNET */
384 u64 mxc_get; /* # of times returned from idle list */
385 u64 mxc_put; /* # of times returned from idle list */
388 #define MXLND_CONN_DISCONNECT -2 /* conn is being destroyed - do not add txs */
389 #define MXLND_CONN_FAIL -1 /* connect failed (bad handshake, unavail, etc.) */
390 #define MXLND_CONN_INIT 0 /* in the beginning, there was nothing... */
391 #define MXLND_CONN_REQ 1 /* a connection request message is needed */
392 #define MXLND_CONN_ACK 2 /* a connection ack is needed */
393 #define MXLND_CONN_WAIT 3 /* waiting for req or ack to complete */
394 #define MXLND_CONN_READY 4 /* ready to send */
396 /* store all data from an unexpected CONN_[REQ|ACK] receive */
397 typedef struct kmx_connparams
399 struct list_head mxr_list; /* list to hang on kmx_conn_reqs */
400 void *mxr_context; /* context - unused - will hold net */
401 mx_endpoint_addr_t mxr_epa; /* the peer's epa */
402 u64 mxr_match; /* the CONN_REQ's match bits */
403 u32 mxr_nob; /* length of CONN_REQ message */
404 struct kmx_peer *mxr_peer; /* peer if known */
405 struct kmx_conn *mxr_conn; /* conn if known */
406 kmx_msg_t mxr_msg; /* the msg header & connreq_msg_t */
409 /* connection state - queues for queued and pending msgs */
410 typedef struct kmx_conn
412 struct kmx_peer *mxk_peer; /* owning peer */
413 struct list_head mxk_list; /* for placing on mxp_conns */
414 struct list_head mxk_zombie; /* for placing on zombies list */
415 u64 mxk_incarnation; /* connections's incarnation value */
416 u32 mxk_sid; /* peer's MX session id */
417 atomic_t mxk_refcount; /* reference counting */
418 int mxk_status; /* can we send messages? MXLND_CONN_* */
420 mx_endpoint_addr_t mxk_epa; /* peer's endpoint address */
422 spinlock_t mxk_lock; /* lock */
423 unsigned long mxk_timeout; /* expiration of oldest pending tx/rx */
424 unsigned long mxk_last_tx; /* when last tx completed with success */
425 unsigned long mxk_last_rx; /* when last rx completed */
427 kmx_pages_t *mxk_rx_pages; /* rx msg pages */
428 kmx_ctx_t *mxk_rxs; /* the rx descriptors */
429 struct list_head mxk_rx_idle; /* list of idle rx */
431 int mxk_credits; /* # of my credits for sending to peer */
432 int mxk_outstanding; /* # of credits to return */
434 struct list_head mxk_tx_credit_queue; /* send queue for peer */
435 struct list_head mxk_tx_free_queue; /* send queue for peer */
436 int mxk_ntx_msgs; /* # of msgs on tx queues */
437 int mxk_ntx_data ; /* # of DATA on tx queues */
438 int mxk_ntx_posted; /* # of tx msgs in flight */
439 int mxk_data_posted; /* # of tx data payloads in flight */
441 struct list_head mxk_pending; /* in flight rxs and txs */
445 typedef struct kmx_peer
447 struct list_head mxp_list; /* for placing on kmx_peers */
448 lnet_nid_t mxp_nid; /* peer's LNET NID */
449 lnet_ni_t *mxp_ni; /* LNET interface */
450 atomic_t mxp_refcount; /* reference counts */
452 struct list_head mxp_conns; /* list of connections */
453 kmx_conn_t *mxp_conn; /* current connection */
454 struct list_head mxp_tx_queue; /* msgs waiting for a conn */
456 u32 mxp_board; /* peer's board rank */
457 u32 mxp_ep_id; /* peer's MX endpoint ID */
458 u64 mxp_nic_id; /* remote's MX nic_id for mx_connect() */
460 unsigned long mxp_reconnect_time; /* when to retry connect */
461 int mxp_incompatible; /* incorrect conn_req values */
464 extern kmx_data_t kmxlnd_data;
465 extern kmx_tunables_t kmxlnd_tunables;
467 /* required for the LNET API */
468 int mxlnd_startup(lnet_ni_t *ni);
469 void mxlnd_shutdown(lnet_ni_t *ni);
470 int mxlnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
471 int mxlnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
472 int mxlnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
473 unsigned int niov, struct iovec *iov, lnet_kiov_t *kiov,
474 unsigned int offset, unsigned int mlen, unsigned int rlen);
477 extern void mxlnd_thread_stop(long id);
478 extern void mxlnd_ctx_init(kmx_ctx_t *ctx);
479 extern int mxlnd_peer_alloc(kmx_peer_t **peerp, lnet_nid_t nid,
480 u32 board, u32 ep_id, u64 nic_id);
481 extern int mxlnd_alloc_pages(kmx_pages_t **pp, int npages);
482 extern void mxlnd_free_pages(kmx_pages_t *p);
485 void mxlnd_eager_recv(void *context, uint64_t match_value, uint32_t length);
486 extern mx_unexp_handler_action_t mxlnd_unexpected_recv(void *context,
487 mx_endpoint_addr_t source, uint64_t match_value, uint32_t length,
488 void *data_if_available);
489 extern void mxlnd_peer_free(kmx_peer_t *peer);
490 extern void mxlnd_conn_free_locked(kmx_conn_t *conn);
491 extern void mxlnd_conn_disconnect(kmx_conn_t *conn, int mx_dis, int send_bye);
492 extern int mxlnd_close_matching_conns(lnet_nid_t nid);
493 extern void mxlnd_sleep(unsigned long timeout);
494 extern int mxlnd_tx_queued(void *arg);
495 extern void mxlnd_handle_rx_completion(kmx_ctx_t *rx);
496 extern int mxlnd_check_sends(kmx_peer_t *peer);
497 extern int mxlnd_tx_peer_queued(void *arg);
498 extern int mxlnd_request_waitd(void *arg);
499 extern int mxlnd_unex_recvd(void *arg);
500 extern int mxlnd_timeoutd(void *arg);
501 extern int mxlnd_free_conn_zombies(void);
502 extern int mxlnd_connd(void *arg);
503 extern int mxlnd_del_peer(lnet_nid_t nid);
507 * mxlnd_nid_to_hash - hash the nid
510 * Takes the u64 nid and XORs the lowest N bits by the next lowest N bits.
513 mxlnd_nid_to_hash(lnet_nid_t nid)
515 return (nid & MXLND_HASH_MASK) ^
516 ((nid & (MXLND_HASH_MASK << MXLND_HASH_BITS)) >> MXLND_HASH_BITS);
520 #define mxlnd_peer_addref(peer) \
522 LASSERT(peer != NULL); \
523 LASSERT(atomic_read(&(peer)->mxp_refcount) > 0); \
524 atomic_inc(&(peer)->mxp_refcount); \
528 #define mxlnd_peer_decref(peer) \
530 LASSERT(atomic_read(&(peer)->mxp_refcount) > 0); \
531 if (atomic_dec_and_test(&(peer)->mxp_refcount)) \
532 mxlnd_peer_free(peer); \
535 #define mxlnd_conn_addref(conn) \
537 LASSERT(conn != NULL); \
538 LASSERT(atomic_read(&(conn)->mxk_refcount) > 0); \
539 atomic_inc(&(conn)->mxk_refcount); \
543 #define mxlnd_conn_decref(conn) \
545 LASSERT(conn != NULL); \
546 LASSERT(atomic_read(&(conn)->mxk_refcount) > 0); \
547 if (atomic_dec_and_test(&(conn)->mxk_refcount)) { \
548 spin_lock(&kmxlnd_data.kmx_conn_lock); \
549 LASSERT((conn)->mxk_status == MXLND_CONN_DISCONNECT); \
550 CDEBUG(D_NET, "adding conn %p to zombies\n", (conn)); \
551 list_add_tail(&(conn)->mxk_zombie, \
552 &kmxlnd_data.kmx_conn_zombies); \
553 spin_unlock(&kmxlnd_data.kmx_conn_lock); \
554 up(&kmxlnd_data.kmx_conn_sem); \
558 #define mxlnd_valid_msg_type(type) \
560 LASSERT((type) == MXLND_MSG_EAGER || \
561 (type) == MXLND_MSG_ICON_REQ || \
562 (type) == MXLND_MSG_CONN_REQ || \
563 (type) == MXLND_MSG_ICON_ACK || \
564 (type) == MXLND_MSG_CONN_ACK || \
565 (type) == MXLND_MSG_BYE || \
566 (type) == MXLND_MSG_NOOP || \
567 (type) == MXLND_MSG_PUT_REQ || \
568 (type) == MXLND_MSG_PUT_ACK || \
569 (type) == MXLND_MSG_PUT_DATA || \
570 (type) == MXLND_MSG_GET_REQ || \
571 (type) == MXLND_MSG_GET_DATA); \