c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER START
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The contents of this file are subject to the terms of the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Common Development and Distribution License (the "License").
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You may not use this file except in compliance with the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * See the License for the specific language governing permissions
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * and limitations under the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * When distributing Covered Code, include this CDDL HEADER in each
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * If applicable, add the following below this CDDL HEADER, with the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * fields enclosed by brackets "[]" replaced with your own identifying
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * information: Portions Copyright [yyyy] [name of copyright owner]
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER END
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
1d99877f5d809f065d76e8ab35d75ce6e4e128a9Alexey Zaytsev * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * This file is only present in Solaris
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern "C" {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * RDS Well known service id
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Format: 0x1h00144Fhhhhhhhh
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * "00144F" is the Sun OUI
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * 'h' can be any hex-decimal digit.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Atomic operations
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota atomic_or_ulong(((volatile ulong_t *)(void *)(p)) + ((b) >> 6), \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota atomic_and_ulong(((volatile ulong_t *)(void *)(p)) + ((b) >> 6), \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((volatile ulong_t *)(void *)(p))[(b) >> 6] & (1ul << ((b) & 0x3f)))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota !atomic_clear_long_excl(((ulong_t *)(void *)(p)) + ((b) >> 6), \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((b) & 0x3f))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota atomic_or_uint(((volatile uint_t *)(void *)p) + (b >> 5), \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota atomic_and_uint(((volatile uint_t *)(void *)p) + (b >> 5), \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((volatile uint_t *)(void *)p)[b >> 5] & (1ul << (b & 0x1f)))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota atomic_set_long_excl(((ulong_t *)(void *)p) + (b >> 5), (b & 0x1f))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota !atomic_clear_long_excl(((ulong_t *)(void *)p) + (b >> 5), (b & 0x1f))
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * These macros and/or constants are used instead of Linux
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * generic_{test,__{clear,set}}_le_bit().
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota#define clear_le_bit(b, p) clear_bit(b ^ LE_BIT_XOR, p)
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota#define test_le_bit(b, p) test_bit(b ^ LE_BIT_XOR, p)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* setting this to PAGESIZE throws build errors */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDSV3_PANIC() cmn_err(CE_PANIC, "Panic forced by RDSV3");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define IS_ERR(ptr) (((uintptr_t)ptr) >= (uintptr_t)-MAX_ERRNO)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* copied and modified list_remove_node */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (node)->list_prev->list_next = (node)->list_next; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (node)->list_next->list_prev = (node)->list_prev; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota list_create(dst, (src)->list_size, (src)->list_offset); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDSV3_FOR_EACH_LIST_NODE(objp, listp, member) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota for (objp = list_head(listp); objp; objp = list_next(listp, objp))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDSV3_FOR_EACH_LIST_NODE_SAFE(objp, tmp, listp, member) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota for (objp = list_head(listp), tmp = (objp != NULL) ? \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* simulate wait_queue_head_t */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota mutex_init(&(waitqp)->waitq_mutex, NULL, MUTEX_DRIVER, NULL); \
6e18d381c642549b8bb1774a803d3510aec6baafagiri cv_init(&(waitqp)->waitq_cv, NULL, CV_DRIVER, NULL); \
6e18d381c642549b8bb1774a803d3510aec6baafagiri/* analogous to cv_wait */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota while (!(condition)) { \
6e18d381c642549b8bb1774a803d3510aec6baafagiri/* analogous to cv_wait_sig */
6e18d381c642549b8bb1774a803d3510aec6baafagiri while (!(condition)) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (cv_return == 0) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* socket */
6e18d381c642549b8bb1774a803d3510aec6baafagiri rdsv3_wait_queue_t *sk_sleep; /* Also protected by rs_recv_lock */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otatypedef void (*rdsv3_work_func_t)(struct rdsv3_work_s *);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* simulate delayed_work */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota mutex_init(&(dwp)->lock, NULL, MUTEX_DRIVER, NULL); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* simulate scatterlist */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define rdsv3_ib_sg_dma_len(dev, scat) rdsv3_sg_len(scat)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* copied from sys/socket.h */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* To maintain backward compatibility, alignment needs to be 8 on sparc. */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* for __i386 (and other future architectures) */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif /* defined(__sparc) */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The cmsg headers (and macros dealing with them) were made available as
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * part of UNIX95 and hence need to be protected with a _XPG4_2 define.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define _CMSG_HDR_ALIGN(x) (((uintptr_t)(x) + _CMSG_HDR_ALIGNMENT - 1) & \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define _CMSG_DATA_ALIGN(x) (((uintptr_t)(x) + _CMSG_DATA_ALIGNMENT - 1) & \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((unsigned char *)_CMSG_DATA_ALIGN((struct cmsghdr *)(c) + 1))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((m)->msg_controllen < sizeof (struct cmsghdr)) ? \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (struct cmsghdr *)0 : (struct cmsghdr *)((m)->msg_control))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((c) == 0) ? CMSG_FIRSTHDR(m) : \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((struct cmsghdr *)(c))->cmsg_len) + sizeof (struct cmsghdr)) > \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((uintptr_t)((struct msghdr *)(m))->msg_control) + \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((uintptr_t)((struct msghdr *)(m))->msg_controllen))) ? \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((struct cmsghdr *)0) : \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* Amount of space + padding needed for a message of length l */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* Value to be used in cmsg_len, does not include trailing padding */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* OFUV -> IB */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDSV3_IBDEV2HCAHDL(device) (device)->hca_hdl
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaboolean_t rdsv3_capable_interface(struct lifreq *lifrp);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_do_ip_ioctl(ksocket_t so4, void **ipaddrs, int *size, int *nifs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_do_ip_ioctl_old(ksocket_t so4, void **ipaddrs, int *size, int *nifs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_cancel_delayed_work(rdsv3_delayed_work_t *dwp);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_flush_workqueue(rdsv3_workqueue_struct_t *wq);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_queue_work(rdsv3_workqueue_struct_t *wq, rdsv3_work_t *wp);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_queue_delayed_work(rdsv3_workqueue_struct_t *wq,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_destroy_task_workqueue(rdsv3_workqueue_struct_t *wq);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_workqueue_struct_t *rdsv3_create_task_workqueue(char *name);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_conn_constructor(void *buf, void *arg, int kmflags);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_conn_compare(const void *conn1, const void *conn2);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_mr_compare(const void *mr1, const void *mr2);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_put_cmsg(struct nmsghdr *msg, int level, int type, size_t size,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint16_t rdsv3_ip_fast_csum(void *buffer, size_t length);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint_t rdsv3_ib_dma_map_sg(struct ib_device *dev, struct rdsv3_scatterlist
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_dma_unmap_sg(ib_device_t *dev, struct rdsv3_scatterlist *scat,
1a561c7696fb9440160a24ca56e8dd264a4cd8abEiji Otastatic inline void
1a561c7696fb9440160a24ca56e8dd264a4cd8abEiji Otastatic inline void
1a561c7696fb9440160a24ca56e8dd264a4cd8abEiji Otastatic inline int
1a561c7696fb9440160a24ca56e8dd264a4cd8abEiji Otastatic inline void
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota#define rdsv3_sndtimeo(a, b) b ? 0 : 3600 /* check this value on linux */
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota#define rdsv3_rcvtimeo(a, b) b ? 0 : 3600 /* check this value on linux */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif /* _RDSV3_IMPL_H */