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