369N/A/*
4659N/A * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
369N/A *
369N/A * This software is available to you under a choice of one of two
369N/A * licenses. You may choose to be licensed under the terms of the GNU
369N/A * General Public License (GPL) Version 2, available from the file
369N/A * COPYING in the main directory of this source tree, or the
369N/A * OpenIB.org BSD license below:
369N/A *
369N/A * Redistribution and use in source and binary forms, with or
369N/A * without modification, are permitted provided that the following
369N/A * conditions are met:
369N/A *
369N/A * - Redistributions of source code must retain the above
369N/A * copyright notice, this list of conditions and the following
369N/A * disclaimer.
369N/A *
369N/A * - Redistributions in binary form must reproduce the above
369N/A * copyright notice, this list of conditions and the following
369N/A * disclaimer in the documentation and/or other materials
369N/A * provided with the distribution.
369N/A *
369N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
369N/A * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
369N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
369N/A * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
369N/A * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
369N/A * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
369N/A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
369N/A * SOFTWARE.
369N/A */
369N/A
369N/A/*
369N/A * NAME: ofa_solaris.h
369N/A * DESC: OFED Solaris wrapper
369N/A */
369N/A#ifndef _OFA_SOLARIS_H
736N/A#define _OFA_SOLARIS_H
369N/A
369N/A#include <sys/types.h>
369N/A#include <sys/socket.h>
369N/A#include <sys/byteorder.h>
369N/A#include <sys/sockio.h>
369N/A#include <sys/mman.h>
369N/A#include <stdio.h>
369N/A#include <inttypes.h>
369N/A#include <alloca.h>
4659N/A#include <string.h>
369N/A
369N/A#ifdef __cplusplus
369N/Aextern "C" {
369N/A#endif
369N/A
369N/Atypedef uint8_t __u8;
369N/Atypedef uint16_t __u16;
369N/Atypedef uint32_t __u32;
369N/Atypedef uint64_t __u64;
369N/Atypedef int32_t __s32;
369N/Atypedef int64_t __s64;
369N/A
369N/Atypedef uint8_t u8;
369N/Atypedef uint16_t u16;
369N/Atypedef uint32_t u32;
369N/Atypedef uint64_t u64;
369N/Atypedef int32_t s32;
369N/A
369N/Atypedef __u8 u_int8_t;
369N/Atypedef __u16 u_int16_t;
369N/Atypedef __u32 u_int32_t;
369N/A
369N/A#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
369N/Atypedef __u64 u_int64_t;
369N/Atypedef __s64 int64_t;
369N/A#endif
369N/A
736N/Atypedef uint8_t __be8;
736N/Atypedef uint16_t __be16;
736N/Atypedef uint32_t __be32;
736N/Atypedef uint64_t __be64;
369N/A
369N/A/* Size of a pointer */
369N/A#if defined(_LP64) || defined(_I32LPx)
736N/A#define __WORDSIZE 64
369N/A#else
736N/A#define __WORDSIZE 32
369N/A#endif
369N/A
369N/A
369N/A/*
369N/A * Endian definitions
369N/A */
736N/A#define __LITTLE_ENDIAN 1234
736N/A#define __BIG_ENDIAN 4321
369N/A
369N/A#ifdef _BIG_ENDIAN
736N/A#define __BYTE_ORDER __BIG_ENDIAN
369N/A#elif defined _LITTLE_ENDIAN
736N/A#define __BYTE_ORDER __LITTLE_ENDIAN
369N/A#else
369N/A#error unknown endianness
369N/A#endif
369N/A
369N/A/*
369N/A * byteswap functions.
369N/A */
369N/A#define bswap_8(x) ((x) & 0xff)
369N/A
369N/A#if !defined(__i386) && !defined(__amd64)
736N/A#define bswap_16(x) ((bswap_8(x) << 8) | bswap_8((x) >> 8))
736N/A#define bswap_32(x) (((uint32_t)(x) << 24) | \
736N/A (((uint32_t)(x) << 8) & 0xff0000) | \
736N/A (((uint32_t)(x) >> 8) & 0xff00) | \
736N/A ((uint32_t)(x) >> 24))
369N/A#else /* x86 */
736N/A#define bswap_16(x) htons(x)
736N/A#define bswap_32(x) htonl(x)
369N/A#endif /* !__i386 && !__amd64 */
369N/A
369N/A#if defined(_LP64) || defined(_LONGLONG_TYPE)
369N/A#if (!defined(__i386) && !defined(__amd64))
736N/A#define bswap_64(x) (((uint64_t)(x) << 56) | \
736N/A (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \
736N/A (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \
736N/A (((uint64_t)(x) << 8) & 0xff00000000ULL) | \
736N/A (((uint64_t)(x) >> 8) & 0xff000000ULL) | \
736N/A (((uint64_t)(x) >> 24) & 0xff0000ULL) | \
736N/A (((uint64_t)(x) >> 40) & 0xff00ULL) | \
736N/A ((uint64_t)(x) >> 56))
369N/A#else /* x86 */
736N/A#define bswap_64(x) htonll(x)
369N/A#endif /* !__i386 && !__amd64 */
736N/A#else /* no uint64_t */
736N/A#define bswap_64(x) ((bswap_32(x) << 32) | bswap_32((x) >> 32))
369N/A#endif
369N/A
369N/Atypedef struct sol_cpu_info_s {
369N/A char cpu_name[64];
369N/A uint_t cpu_mhz;
736N/A uint_t cpu_number;
369N/A} sol_cpu_info_t;
369N/A
736N/Aint sol_get_cpu_info(sol_cpu_info_t **);
736N/A
736N/Atypedef struct sol_cpu_stats_s {
736N/A uint64_t t_user;
736N/A uint64_t t_kernel;
736N/A uint64_t t_idle;
736N/A uint64_t t_iowait;
736N/A uint64_t t_intr;
736N/A} sol_cpu_stats_t;
736N/A
736N/Aint sol_get_cpu_stats(sol_cpu_stats_t *);
736N/A
736N/Avoid solaris_init(void);
736N/Avoid solaris_fini(void);
369N/A
369N/A#ifdef __cplusplus
369N/A}
369N/A#endif
369N/A
369N/A#endif /* _OFA_SOLARIS_H */