/*
* 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
* or http://www.opensolaris.org/os/licensing.
* 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 (c) 2012, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SYS_ECP_IMPL_H
#define _SYS_ECP_IMPL_H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <strings.h>
#include <signal.h>
#include <unistd.h>
#include <pthread.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <syslog.h>
#include <assert.h>
#include <errno.h>
#include <ecp.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ECP_HEADER_SIZE sizeof (ecp_hdr_t)
#define ECP_TX_TIMEOUT 11600 /* timeout in msecs */
#pragma pack(1)
typedef struct ecp_hdr_s {
struct ether_header ecp_ether_header;
#define ecp_ether_dhost ecp_ether_header.ether_dhost.ether_addr_octet
#define ecp_ether_shost ecp_ether_header.ether_shost.ether_addr_octet
uint16_t ecp_ver_op_stype;
uint16_t ecp_seq;
} ecp_hdr_t;
#pragma pack()
typedef struct ecp_instance_s {
ushort_t ecp_version : 4;
ushort_t ecp_subtype : 10;
ushort_t ecp_notused : 2;
ushort_t ecp_req_seq;
ushort_t ecp_ack_seq;
ushort_t ecp_last_ack_seq;
struct ether_addr ecp_src_addr;
struct ether_addr ecp_dst_addr;
int ecp_sockfd;
int ecp_max_tx_attempts;
ushort_t ecp_ether_type;
boolean_t ecp_init_req_seq;
pthread_t ecp_process_thread;
ecp_ulp_cb_t ecp_ulp_cb;
void *ecp_ulp_cb_arg;
pthread_mutex_t ecp_tx_lock;
pthread_cond_t ecp_tx_cv;
boolean_t ecp_tx_acked;
/* Statistcs */
ecp_stat_t ecp_stat;
} ecp_instance_t;
#define ECP_STAT_UPDATE(e, s, c) \
(((ecp_instance_t *)(e))->ecp_stat.es_##s += ((uint64_t)(c)))
extern void ecp_logmsg(int, const char *, ...);
#define logerr(...) ecp_logmsg(LOG_ERR, __VA_ARGS__)
#define logtrace(...) ecp_logmsg(LOG_INFO, __VA_ARGS__)
#define logdebug(...) ecp_logmsg(LOG_DEBUG, __VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ECP_IMPL_H */