#include <lnet/lnet.h>
#include <lnet/lib-types.h>
-extern lnet_t the_lnet; /* THE network */
+extern lnet_t the_lnet; /* THE network */
#if (BITS_PER_LONG == 32)
/* 2 CPTs, allowing more CPTs might make us under memory pressure */
#endif /* BITS_PER_LONG == 32 */
/* max allowed CPT number */
-#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
+#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
-#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
-#define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
-#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
+#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
+#define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
+#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
/** exclusive lock */
-#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
+#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
static inline int lnet_is_route_alive(lnet_route_t *route)
{
static inline int lnet_is_wire_handle_none (lnet_handle_wire_t *wh)
{
- return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE &&
- wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE);
+ return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE &&
+ wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE);
}
static inline int lnet_md_exhausted (lnet_libmd_t *md)
{
- return (md->md_threshold == 0 ||
- ((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
- md->md_offset + md->md_max_size > md->md_length));
+ return (md->md_threshold == 0 ||
+ ((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
+ md->md_offset + md->md_max_size > md->md_length));
}
static inline int lnet_md_unlinkable (lnet_libmd_t *md)
{
- /* Should unlink md when its refcount is 0 and either:
- * - md has been flagged for deletion (by auto unlink or LNetM[DE]Unlink,
- * in the latter case md may not be exhausted).
- * - auto unlink is on and md is exhausted.
- */
- if (md->md_refcount != 0)
- return 0;
+ /* Should unlink md when its refcount is 0 and either:
+ * - md has been flagged for deletion (by auto unlink or LNetM[DE]Unlink,
+ * in the latter case md may not be exhausted).
+ * - auto unlink is on and md is exhausted.
+ */
+ if (md->md_refcount != 0)
+ return 0;
- if ((md->md_flags & LNET_MD_FLAG_ZOMBIE) != 0)
- return 1;
+ if ((md->md_flags & LNET_MD_FLAG_ZOMBIE) != 0)
+ return 1;
- return ((md->md_flags & LNET_MD_FLAG_AUTO_UNLINK) != 0 &&
- lnet_md_exhausted(md));
+ return ((md->md_flags & LNET_MD_FLAG_AUTO_UNLINK) != 0 &&
+ lnet_md_exhausted(md));
}
#define lnet_cpt_table() (the_lnet.ln_cpt_table)
#define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock)
#define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock)
-#define MAX_PORTALS 64
+#define MAX_PORTALS 64
#define LNET_SMALL_MD_SIZE offsetof(lnet_libmd_t, md_iov.iov[1])
extern struct kmem_cache *lnet_mes_cachep; /* MEs kmem_cache */
static inline lnet_eq_t *
lnet_eq_alloc (void)
{
- lnet_eq_t *eq;
+ lnet_eq_t *eq;
- LIBCFS_ALLOC(eq, sizeof(*eq));
- return (eq);
+ LIBCFS_ALLOC(eq, sizeof(*eq));
+ return (eq);
}
static inline void
static inline lnet_libmd_t *
lnet_md_alloc (lnet_md_t *umd)
{
- lnet_libmd_t *md;
- unsigned int size;
- unsigned int niov;
+ lnet_libmd_t *md;
+ unsigned int size;
+ unsigned int niov;
- if ((umd->options & LNET_MD_KIOV) != 0) {
- niov = umd->length;
- size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
- } else {
- niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
- umd->length : 1;
- size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
- }
+ if ((umd->options & LNET_MD_KIOV) != 0) {
+ niov = umd->length;
+ size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
+ } else {
+ niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
+ umd->length : 1;
+ size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
+ }
if (size <= LNET_SMALL_MD_SIZE) {
md = kmem_cache_alloc(lnet_small_mds_cachep,
static inline lnet_msg_t *
lnet_msg_alloc(void)
{
- lnet_msg_t *msg;
+ lnet_msg_t *msg;
- LIBCFS_ALLOC(msg, sizeof(*msg));
+ LIBCFS_ALLOC(msg, sizeof(*msg));
- /* no need to zero, LIBCFS_ALLOC does for us */
- return (msg);
+ /* no need to zero, LIBCFS_ALLOC does for us */
+ return (msg);
}
static inline void
static inline void
lnet_eq2handle (lnet_handle_eq_t *handle, lnet_eq_t *eq)
{
- if (eq == NULL) {
- LNetInvalidateHandle(handle);
- return;
- }
+ if (eq == NULL) {
+ LNetInvalidateHandle(handle);
+ return;
+ }
- handle->cookie = eq->eq_lh.lh_cookie;
+ handle->cookie = eq->eq_lh.lh_cookie;
}
static inline lnet_eq_t *
static inline void
lnet_md2handle (lnet_handle_md_t *handle, lnet_libmd_t *md)
{
- handle->cookie = md->md_lh.lh_cookie;
+ handle->cookie = md->md_lh.lh_cookie;
}
static inline lnet_libmd_t *
static inline void
lnet_me2handle (lnet_handle_me_t *handle, lnet_me_t *me)
{
- handle->cookie = me->me_lh.lh_cookie;
+ handle->cookie = me->me_lh.lh_cookie;
}
static inline lnet_me_t *
static inline void
lnet_peer_addref_locked(lnet_peer_t *lp)
{
- LASSERT (lp->lp_refcount > 0);
- lp->lp_refcount++;
+ LASSERT(lp->lp_refcount > 0);
+ lp->lp_refcount++;
}
extern void lnet_destroy_peer_locked(lnet_peer_t *lp);
static inline void
lnet_peer_decref_locked(lnet_peer_t *lp)
{
- LASSERT (lp->lp_refcount > 0);
- lp->lp_refcount--;
- if (lp->lp_refcount == 0)
- lnet_destroy_peer_locked(lp);
+ LASSERT(lp->lp_refcount > 0);
+ lp->lp_refcount--;
+ if (lp->lp_refcount == 0)
+ lnet_destroy_peer_locked(lp);
}
static inline int
lnet_isrouter(lnet_peer_t *lp)
{
- return lp->lp_rtr_refcount != 0;
+ return lp->lp_rtr_refcount != 0;
}
static inline void
int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
};
-#define DECLARE_IOCTL_HANDLER(ident, func) \
- static struct libcfs_ioctl_handler ident = { \
- /* .item = */ LIST_HEAD_INIT(ident.item), \
- /* .handle_ioctl = */ func \
+#define DECLARE_IOCTL_HANDLER(ident, func) \
+ static struct libcfs_ioctl_handler ident = { \
+ /* .item = */ LIST_HEAD_INIT(ident.item), \
+ /* .handle_ioctl = */ func \
}
extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev);
void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
- unsigned int offset, unsigned int len);
+ unsigned int offset, unsigned int len);
int lnet_send(lnet_nid_t nid, lnet_msg_t *msg, lnet_nid_t rtr_nid);
void lnet_return_tx_credits_locked(lnet_msg_t *msg);
void lnet_return_rx_credits_locked(lnet_msg_t *msg);
/* message functions */
int lnet_parse (lnet_ni_t *ni, lnet_hdr_t *hdr,
- lnet_nid_t fromnid, void *private, int rdma_req);
+ lnet_nid_t fromnid, void *private, int rdma_req);
int lnet_parse_local(lnet_ni_t *ni, lnet_msg_t *msg);
int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg);
void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
- unsigned int offset, unsigned int mlen, unsigned int rlen);
+ unsigned int offset, unsigned int mlen, unsigned int rlen);
void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
int delayed, unsigned int offset,
unsigned int mlen, unsigned int rlen);
unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
int lnet_extract_iov(int dst_niov, struct kvec *dst,
int src_niov, struct kvec *src,
- unsigned int offset, unsigned int len);
+ unsigned int offset, unsigned int len);
unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
int lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
static inline void
lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
unsigned int nsiov, struct kvec *siov, unsigned int soffset,
- unsigned int nob)
+ unsigned int nob)
{
struct kvec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
- lnet_copy_iov2iov(1, &diov, doffset,
- nsiov, siov, soffset, nob);
+ lnet_copy_iov2iov(1, &diov, doffset,
+ nsiov, siov, soffset, nob);
}
static inline void
{
struct kvec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
- lnet_copy_kiov2iov(1, &diov, doffset,
- nsiov, skiov, soffset, nob);
+ lnet_copy_kiov2iov(1, &diov, doffset,
+ nsiov, skiov, soffset, nob);
}
static inline void
unsigned int nob)
{
struct kvec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
- lnet_copy_iov2iov(ndiov, diov, doffset,
- 1, &siov, soffset, nob);
+ lnet_copy_iov2iov(ndiov, diov, doffset,
+ 1, &siov, soffset, nob);
}
static inline void
unsigned int soffset, unsigned int nob)
{
struct kvec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
- lnet_copy_iov2kiov(ndiov, dkiov, doffset,
- 1, &siov, soffset, nob);
+ lnet_copy_iov2kiov(ndiov, dkiov, doffset,
+ 1, &siov, soffset, nob);
}
void lnet_me_unlink(lnet_me_t *me);
void lnet_unregister_lnd(lnd_t *lnd);
int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
- __u32 local_ip, __u32 peer_ip, int peer_port);
+ __u32 local_ip, __u32 peer_ip, int peer_port);
void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
- __u32 peer_ip, int port);
+ __u32 peer_ip, int port);
int lnet_count_acceptor_nis(void);
int lnet_acceptor_timeout(void);
int lnet_acceptor_port(void);