2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _DAT_PLATFORM_SPECIFIC_H_
2N/A#define _DAT_PLATFORM_SPECIFIC_H_
2N/A
2N/A/*
2N/A *
2N/A * HEADER: dat_platform_specific.h
2N/A *
2N/A * PURPOSE: defines Platform specific types.
2N/A *
2N/A * Description: Header file for "uDAPL: User Direct Access Programming
2N/A * Library, Version: 1.2"
2N/A *
2N/A * Mapping rules:
2N/A *
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/* OS, processor, compiler type definitions. Add OS's as needed. */
2N/A
2N/A/*
2N/A * This captures the alignment for the bus transfer from the HCA/IB chip
2N/A * to the main memory.
2N/A */
2N/A#ifndef DAT_OPTIMAL_ALIGNMENT
2N/A#define DAT_OPTIMAL_ALIGNMENT 256 /* Performance optimal alignment */
2N/A#endif /* DAT_OPTIMAL_ALIGNMENT */
2N/A
2N/A/*
2N/A * Assume all O/Ss use sockaddr, for address family: IPv4 == AF_INET,
2N/A * IPv6 == AF_INET6. Use of "namelen" field indicated.
2N/A *
2N/A * The Interface Adaptor Address names an Interface Adaptor local or
2N/A * remote, that is used for connection management and Name
2N/A * Service. The format of the dat_ia_address_ptr follows the normal
2N/A * socket programming practice of struct sockaddr *. DAT supports both
2N/A * IPv4 and IPv6 address families. Allocation and initialization of
2N/A * DAT IA address structures must follow normal Sockets programming
2N/A * procedures. The underlying type of the DAT IA address is the native
2N/A * struct sockaddr for each target operating system. In all cases,
2N/A * storage appropriate for the address family in use by the target
2N/A * Provider must be allocated. For instance, when IPv6 addressing is
2N/A * in use, this should be allocated as struct sockaddr_net6. The
2N/A * sockaddr sa_family and, if present, sa_len fields must be
2N/A * initialized appropriately, as well as the address information.
2N/A * When passed across the DAPL API this storage is cast to the
2N/A * DAT_IA_ADDRESS_PTR type. It is the responsibility of the callee to
2N/A * verify that the sockaddr contains valid data for the requested
2N/A * operation. It is always the responsibility of the caller to manage
2N/A * the storage.
2N/A *
2N/A * Code example for Linux:
2N/A *
2N/A * #include <stdio.h>
2N/A * #include <sys/socket.h>
2N/A * #include <netinet/in.h>
2N/A * #include <dat/udat.h>
2N/A *
2N/A * struct sockaddr_in6 addr;
2N/A * DAT_IA_ADDRESS_PTR ia_addr;
2N/A *
2N/A * // Note: linux pton requires explicit encoding of IPv4 in IPv6
2N/A *
2N/A * addr.sin6_family = AF_INET6;
2N/A * if (inet_pton(AF_INET6, "0:0:0:0:0:FFFF:192.168.0.1",
2N/A * &addr.sin6_addr) <= 0)
2N/A * return(-1); // Bad address or no address family support
2N/A *
2N/A * // initialize other necessary fields such as port, flow, etc
2N/A *
2N/A * ia_addr = (DAT_IA_ADDRESS_PTR) &addr;
2N/A * dat_ep_connect(ep_handle, ia_addr, conn_qual, timeout, 0, NULL,
2N/A * qos, DAT_CONNECT_DEFAULT_FLAG);
2N/A *
2N/A */
2N/A
2N/A#if defined(sun) || defined(__sun) || defined(_sun_) || defined(__solaris__)
2N/A/* Solaris begins */
2N/A
2N/A#include <sys/types.h>
2N/A#include <inttypes.h> /* needed for UINT64_C() macro */
2N/A
2N/Atypedef uint32_t DAT_UINT32; /* Unsigned host order, 32 bits */
2N/Atypedef uint64_t DAT_UINT64; /* Unsigned host order, 64 bits */
2N/Atypedef unsigned long long DAT_UVERYLONG; /* Unsigned longest native */
2N/A /* to compiler */
2N/A
2N/Atypedef void *DAT_PVOID;
2N/Atypedef int DAT_COUNT;
2N/A
2N/A#include <sys/socket.h>
2N/A#include <netinet/in.h>
2N/Atypedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */
2N/A /* native to OS */
2N/Atypedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */
2N/A /* native to OS */
2N/A
2N/A#define DAT_AF_INET AF_INET
2N/A#define DAT_AF_INET6 AF_INET6
2N/A
2N/Atypedef DAT_UINT64 DAT_PADDR;
2N/A
2N/A/* Solaris ends */
2N/A
2N/A#elif defined(__linux__) /* Linux */
2N/A/* Linux begins */
2N/A
2N/A#include <sys/types.h>
2N/A
2N/Atypedef u_int32_t DAT_UINT32; /* unsigned host order, 32 bits */
2N/Atypedef u_int64_t DAT_UINT64; /* unsigned host order, 64 bits */
2N/Atypedef unsigned long long DAT_UVERYLONG; /* unsigned longest native */
2N/A /* to compiler */
2N/A
2N/Atypedef void *DAT_PVOID;
2N/Atypedef int DAT_COUNT;
2N/Atypedef DAT_UINT64 DAT_PADDR;
2N/A
2N/A#ifndef UINT64_C
2N/A#define UINT64_C(c) c ## ULL
2N/A#endif /* UINT64_C */
2N/A
2N/A#include <sys/socket.h>
2N/Atypedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */
2N/A /* native to OS */
2N/Atypedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */
2N/A /* native to OS */
2N/A
2N/A#define DAT_AF_INET AF_INET
2N/A#define DAT_AF_INET6 AF_INET6
2N/A
2N/A/* Linux ends */
2N/A
2N/A#elif defined(_MSC_VER) || defined(_WIN32)
2N/A/* NT. MSC compiler, Win32 platform */
2N/A/* Win32 begins */
2N/A
2N/Atypedef unsigned __int32 DAT_UINT32; /* Unsigned host order, 32 bits */
2N/Atypedef unsigned __int64 DAT_UINT64; /* Unsigned host order, 64 bits */
2N/Atypedef unsigned long DAT_UVERYLONG; /* Unsigned longest native to */
2N/A /* compiler */
2N/A
2N/Atypedef void *DAT_PVOID;
2N/Atypedef long DAT_COUNT;
2N/A
2N/Atypedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */
2N/A /* native to OS */
2N/Atypedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */
2N/A /* native to OS */
2N/A#ifndef UINT64_C
2N/A#define UINT64_C(c) c ## i64
2N/A#endif /* UINT64_C */
2N/A
2N/A#define DAT_AF_INET AF_INET
2N/A#define DAT_AF_INET6 AF_INET6
2N/A
2N/A/* Win32 ends */
2N/A
2N/A#else
2N/A#error dat_platform_specific.h : OS type not defined
2N/A#endif
2N/A
2N/A#ifndef IN
2N/A#define IN
2N/A#endif
2N/A#ifndef OUT
2N/A#define OUT
2N/A#endif
2N/A#ifndef INOUT
2N/A#define INOUT
2N/A#endif
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DAT_PLATFORM_SPECIFIC_H_ */