Blame iscsiuio/src/unix/options.h

Packit eace71
/*
Packit eace71
 * Copyright (c) 2009-2011, Broadcom Corporation
Packit eace71
 * Copyright (c) 2014, QLogic Corporation
Packit eace71
 *
Packit eace71
 * Written by:  Benjamin Li  (benli@broadcom.com)
Packit eace71
 *
Packit eace71
 * All rights reserved.
Packit eace71
 *
Packit eace71
 * Redistribution and use in source and binary forms, with or without
Packit eace71
 * modification, are permitted provided that the following conditions
Packit eace71
 * are met:
Packit eace71
 * 1. Redistributions of source code must retain the above copyright
Packit eace71
 *    notice, this list of conditions and the following disclaimer.
Packit eace71
 * 2. Redistributions in binary form must reproduce the above copyright
Packit eace71
 *    notice, this list of conditions and the following disclaimer in the
Packit eace71
 *    documentation and/or other materials provided with the distribution.
Packit eace71
 * 3. All advertising materials mentioning features or use of this software
Packit eace71
 *    must display the following acknowledgement:
Packit eace71
 *      This product includes software developed by Adam Dunkels.
Packit eace71
 * 4. The name of the author may not be used to endorse or promote
Packit eace71
 *    products derived from this software without specific prior
Packit eace71
 *    written permission.
Packit eace71
 *
Packit eace71
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
Packit eace71
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Packit eace71
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit eace71
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
Packit eace71
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit eace71
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit eace71
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit eace71
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit eace71
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit eace71
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit eace71
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit eace71
 *
Packit eace71
 * options.h - CNIC UIO uIP user space stack
Packit eace71
 *
Packit eace71
 */
Packit eace71
#ifndef __OPTIONS_H__
Packit eace71
#define __OPTIONS_H__
Packit eace71
Packit eace71
#include <byteswap.h>
Packit eace71
#include <time.h>
Packit eace71
#include <sys/types.h>
Packit eace71
Packit eace71
/******************************************************************************
Packit eace71
 * Constants which are tuned at compile time by the user
Packit eace71
 *****************************************************************************/
Packit eace71
Packit eace71
/**
Packit eace71
 * MAX_COUNT_NIC_NL_RESP - This is the maximum number of polls uIP will
Packit eace71
 *                         try for a kernel response after a PATH_REQ
Packit eace71
 */
Packit eace71
#define MAX_COUNT_NIC_NL_RESP 128
Packit eace71
Packit eace71
/**
Packit eace71
 * NLM_BUF_DEFAULT_MAX - This is the buffer size allocated for the send/receive
Packit eace71
 *                       buffers used by the uIP Netlink subsystem.  This
Packit eace71
 *                       value is in bytes.
Packit eace71
 */
Packit eace71
#define NLM_BUF_DEFAULT_MAX	8192	/* bytes */
Packit eace71
Packit eace71
/******************************************************************************
Packit eace71
 * Non adjustable constants
Packit eace71
 *****************************************************************************/
Packit eace71
#ifndef ETHERTYPE_IP
Packit eace71
#define ETHERTYPE_IP                    0x0800	/* IP */
Packit eace71
#endif /* ETHERTYPE_IP */
Packit eace71
Packit eace71
#ifndef ETHERTYPE_IPV6
Packit eace71
#define ETHERTYPE_IPV6                  0x86dd	/* IP protocol version 6 */
Packit eace71
#endif /* ETHERTYPE_IPV6 */
Packit eace71
Packit eace71
#ifndef ETHERTYPE_ARP
Packit eace71
#define ETHERTYPE_ARP                   0x0806	/* Address resolution */
Packit eace71
#endif /* ETHERTYPE_ARP */
Packit eace71
Packit eace71
#ifndef ETHERTYPE_VLAN
Packit eace71
#define ETHERTYPE_VLAN                  0x8100	/* IEEE 802.1Q VLAN tagging */
Packit eace71
#endif /* ETHERTYPE_VLAN */
Packit eace71
Packit eace71
#define APP_NAME "iscsiuio"
Packit eace71
/* BUILD_DATE is automatically generated from the Makefile */
Packit eace71
Packit eace71
#define DEBUG_OFF	0x1
Packit eace71
#define DEBUG_ON	0x2
Packit eace71
Packit eace71
#define INVALID_FD	-1
Packit eace71
#define INVALID_THREAD	-1
Packit eace71
#define INVALID_HOST_NO	-1
Packit eace71
Packit eace71
struct options {
Packit eace71
	char debug;
Packit eace71
Packit eace71
	/*  Time the userspace daemon was started */
Packit eace71
	time_t start_time;
Packit eace71
};
Packit eace71
Packit eace71
extern int event_loop_stop;
Packit eace71
extern struct options opt;
Packit eace71
Packit eace71
#ifdef WORDS_BIGENDIAN
Packit eace71
#define ntohll(x)  (x)
Packit eace71
#define htonll(x)  (x)
Packit eace71
#else
Packit eace71
#define ntohll(x)  bswap_64(x)
Packit eace71
#define htonll(x)  bswap_64(x)
Packit eace71
#endif
Packit eace71
Packit eace71
# define likely(x)      __builtin_expect(!!(x), 1)
Packit eace71
# define unlikely(x)    __builtin_expect(!!(x), 0)
Packit eace71
Packit eace71
/*  taken from Linux kernel, include/linux/compiler-gcc.h */
Packit eace71
/* Optimization barrier */
Packit eace71
/* The "volatile" is due to gcc bugs */
Packit eace71
#define barrier() __asm__ __volatile__("": : :"memory")
Packit eace71
Packit eace71
#endif