rdsv3_impl.h revision 1a5e258f5471356ca102c7176637cdce45bac147
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _RDSV3_IMPL_H
#define _RDSV3_IMPL_H
/*
* This file is only present in Solaris
*/
#ifdef __cplusplus
extern "C" {
#endif
extern dev_info_t *rdsv3_dev_info;
#define uint16_be_t uint16_t
#define uint32_be_t uint32_t
#define uint64_be_t uint64_t
/*
* RDS Well known service id
* Format: 0x1h00144Fhhhhhhhh
* "00144F" is the Sun OUI
* 'h' can be any hex-decimal digit.
*/
#define RDS_SERVICE_ID 0x1000144F00000001ULL
/*
* Atomic operations
*/
typedef unsigned int atomic_t;
#define ATOMIC_INIT(a) a
#define atomic_get(p) (*(p))
#define atomic_cmpset_long(p, c, n) \
((c == atomic_cas_uint(p, c, n)) ? c : -1)
#define atomic_dec_and_test(a) \
(atomic_dec_uint_nv((a)) == 0)
#define atomic_cmpxchg(a, o, n) \
atomic_cas_uint(a, o, n)
#ifdef _LP64
#define set_bit(b, p) \
1ul << ((b) & 0x3f))
#define clear_bit(b, p) \
~(1ul << ((b) & 0x3f)))
#define test_bit(b, p) \
#define test_and_set_bit(b, p) \
atomic_set_long_excl(((ulong_t *)(void *)(p)) + \
((b) >> 6), ((b) & 0x3f))
#define test_and_clear_bit(b, p) \
((b) & 0x3f))
#else
#define set_bit(b, p) \
1ul << (b & 0x1f))
#define clear_bit(b, p) \
~(1ul << (b & 0x1f)))
#define test_bit(b, p) \
#define test_and_set_bit(b, p) \
#define test_and_clear_bit(b, p) \
#endif
/*
* generic_{test,__{clear,set}}_le_bit().
*/
#if defined(sparc)
#else
#define LE_BIT_XOR 0
#endif
#define jiffies 100
/* setting this to PAGESIZE throws build errors */
#define BITS_PER_LONG (sizeof (unsigned long) * 8)
/* debug */
/* ERR */
#define MAX_ERRNO 4095
/* list */
/* copied and modified list_remove_node */
#define list_remove_node(node) \
}
}
objp; \
/* simulate wait_queue_head_t */
typedef struct rdsv3_wait_queue_s {
#define rdsv3_init_waitqueue(waitqp) \
(waitqp)->waitq_waiters = 0
#define rdsv3_exit_waitqueue(waitqp) \
#define rdsv3_wake_up(waitqp) { \
if ((waitqp)->waitq_waiters) \
}
#define rdsv3_wake_up_all(waitqp) { \
if ((waitqp)->waitq_waiters) \
}
/* analogous to cv_wait */
{ \
(waitq)->waitq_waiters++; \
while (!(condition)) { \
} \
(waitq)->waitq_waiters--; \
}
/* analogous to cv_wait_sig */
( \
{ \
int cv_return = 1; \
(waitqp)->waitq_waiters++; \
while (!(condition)) { \
&(waitqp)->waitq_mutex); \
if (cv_return == 0) { \
break; \
} \
} \
(waitqp)->waitq_waiters--; \
cv_return; \
} \
)
#define SOCK_DEAD 1ul
/* socket */
typedef struct rsock {
int sk_sndbuf;
int sk_rcvbuf;
struct rdsv3_sock *sk_protinfo;
} rsock_t;
typedef struct rdsv3_conn_info_s {
/* WQ */
typedef struct rdsv3_workqueue_struct_s {
int wq_pending;
struct rdsv3_work_s;
typedef void (*rdsv3_work_func_t)(struct rdsv3_work_s *);
typedef struct rdsv3_work_s {
} rdsv3_work_t;
/* simulate delayed_work */
typedef struct rdsv3_delayed_work_s {
#define RDSV3_INIT_DELAYED_WORK(dwp, f) \
/* simulate scatterlist */
struct rdsv3_scatterlist {
};
#if defined(__sparc)
/* To maintain backward compatibility, alignment needs to be 8 on sparc. */
#define _CMSG_HDR_ALIGNMENT 8
#else
/* for __i386 (and other future architectures) */
#define _CMSG_HDR_ALIGNMENT 4
#endif /* defined(__sparc) */
/*
* The cmsg headers (and macros dealing with them) were made available as
* part of UNIX95 and hence need to be protected with a _XPG4_2 define.
*/
#define _CMSG_DATA_ALIGNMENT (sizeof (int))
~(_CMSG_HDR_ALIGNMENT - 1))
~(_CMSG_DATA_ALIGNMENT - 1))
#define CMSG_DATA(c) \
#define CMSG_FIRSTHDR(m) \
(((m)->msg_controllen < sizeof (struct cmsghdr)) ? \
#define CMSG_NXTHDR(m, c) \
(((c) == 0) ? CMSG_FIRSTHDR(m) : \
((((uintptr_t)_CMSG_HDR_ALIGN((char *)(c) + \
((struct cmsghdr *)0) : \
((struct cmsghdr *)_CMSG_HDR_ALIGN((char *)(c) + \
/* Amount of space + padding needed for a message of length l */
#define CMSG_SPACE(l) \
((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
/* Value to be used in cmsg_len, does not include trailing padding */
#define CMSG_LEN(l) \
((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
/* OFUV -> IB */
struct rdsv3_hdrs_mr {
};
/* rdsv3_impl.c */
void rdsv3_trans_init();
struct rsock *rdsv3_sk_alloc();
void rdsv3_loop_init();
void *payload);
static inline void
{
}
static inline void
{
}
static inline int
{
}
static inline void
{
}
void rdsv3_ib_free_conn(void *arg);
#ifdef __cplusplus
}
#endif
#endif /* _RDSV3_IMPL_H */