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_VDP_IMPL_H
2N/A#define _SYS_VDP_IMPL_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <errno.h>
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <stdarg.h>
2N/A#include <unistd.h>
2N/A#include <sys/types.h>
2N/A#include <stddef.h>
2N/A#include <door.h>
2N/A#include <sys/stat.h>
2N/A#include <fcntl.h>
2N/A#include <paths.h>
2N/A#include <sys/param.h>
2N/A#include <sys/list.h>
2N/A#include <libdllink.h>
2N/A#include <libdlpi.h>
2N/A#include <pthread.h>
2N/A#include <string.h>
2N/A#include <strings.h>
2N/A#include <sys/socket_impl.h>
2N/A#include <sys/socket.h>
2N/A#include <assert.h>
2N/A#include <ecp.h>
2N/A#include <vdp.h>
2N/A#include <libinetutil.h>
2N/A
2N/A#define D_ALL 0xffff
2N/A
2N/A/*
2N/A * VDP Timers
2N/A */
2N/A#define VDP_RESP_WAIT_DELAY_MSEC 11600
2N/A#define VDP_REINIT_KEEP_ALIVE_TIME_MSEC 10500
2N/A
2N/A#define VDP_KEEP_ALIVE_EXPONENT 20
2N/A#define VDP_RESOURCE_WAIT_DELAY_EXPONENT 20
2N/A
2N/Atypedef enum vdp_state {
2N/A VDP_REC_INIT,
2N/A VDP_REC_ACTIVE,
2N/A VDP_REC_DELETED,
2N/A VDP_REC_TIMEDOUT
2N/A} vdp_state_t;
2N/A
2N/Atypedef enum vdp_prof_proc_state_s {
2N/A VDP_PROF_INIT = 0,
2N/A VDP_PROF_PROCESSING,
2N/A VDP_PROF_WAIT_SYS_CMD,
2N/A VDP_PROF_TX_KEEP_ALIVE,
2N/A VDP_PROF_TIMEDOUT,
2N/A VDP_PROF_TX_DEASSOC,
2N/A VDP_PROF_DELETED,
2N/A} vdp_prof_proc_state_t;
2N/A
2N/A#define VDP_TLV_TYPE_MASK 0xFE
2N/A#define VDP_TLV_LEN_MASK 0x1FF
2N/A
2N/A#define VDP_TLV_REASON_OFFSET 0x02
2N/A#define VDP_TLV_REASON_MASK 0xF
2N/A
2N/A#define VDP_TLV_TYPE_SHIFT 9
2N/A#define VDP_TLV_LEN_SHIFT 0
2N/A
2N/A#define VDP_TLV_VSIID_OFFSET 0x08
2N/A
2N/A#pragma pack(1)
2N/Atypedef struct vdp_tlv_s {
2N/A uint16_t vdp_tlv_type_len;
2N/A uint8_t vdp_tlv_reason;
2N/A uint8_t vdp_tlv_vsi_type[3];
2N/A uint8_t vdp_tlv_vsi_type_ver;
2N/A uint8_t vdp_tlv_vsiid_format;
2N/A uint8_t vdp_tlv_vsiid[16];
2N/A uint8_t vdp_tlv_fltr_format;
2N/A uint16_t vdp_tlv_fltr_entries;
2N/A} vdp_tlv_t;
2N/A
2N/Atypedef struct vdp_tlv_mgr_s {
2N/A uint16_t vdp_mgr_tlv_type_len;
2N/A uint8_t vdp_mgr_tlv_id[16];
2N/A} vdp_tlv_mgr_t;
2N/A
2N/A/* Org specific TLV that follows the VSI Manager TLV. */
2N/Atypedef struct vdp_tlv_mgrenc_s {
2N/A uint16_t vtme_type_len;
2N/A uint8_t vtme_ouistype[VDP_ORG_HSIZE];
2N/A uint8_t vtme_encid;
2N/A} vdp_tlv_mgrenc_t;
2N/A
2N/A/*
2N/A * VDP Filters
2N/A */
2N/A
2N/A#define VTF_PS_MASK 0x1
2N/A#define VTF_PCP_MASK 0x7
2N/A#define VTF_VID_MASK 0xFFF
2N/A
2N/A#define VTF_PS_SHIFT 15
2N/A#define VTF_PCP_SHIFT 12
2N/A
2N/Atypedef short vtf_ps_pcp_vid_t;
2N/A
2N/Atypedef struct vdp_tlv_fltr_vid_s {
2N/A vtf_ps_pcp_vid_t vtf_vid_ps_pcp_vid;
2N/A}vtf_vid_t;
2N/A
2N/Atypedef struct vtf_mac_s {
2N/A uint8_t vtf_mac_addr[6];
2N/A vtf_ps_pcp_vid_t vtf_mac_ps_pcp_vid;
2N/A} vtf_mac_t;
2N/A
2N/Atypedef struct vtf_group_s {
2N/A char vtf_group_id[4];
2N/A vtf_ps_pcp_vid_t vtf_group_ps_pcp_vid;
2N/A} vtf_group_t;
2N/A
2N/Atypedef struct vtf_group_mac_s {
2N/A char vtf_group_mac_id[4];
2N/A uint8_t vtf_group_mac_addr[6];
2N/A vtf_ps_pcp_vid_t vtf_group_mac_ps_pcp_vid;
2N/A} vtf_group_mac_t;
2N/A
2N/A#pragma pack()
2N/A
2N/A/* VDP profile for each VSI/VNIC */
2N/Atypedef struct vdp_profile_s {
2N/A char vdp_prof_vnic_name[MAXLINKNAMELEN];
2N/A datalink_id_t vdp_prof_vnic_id;
2N/A uint8_t vdp_prof_vsiid_format;
2N/A uint8_t vdp_prof_vsiid[16];
2N/A uint_t vdp_prof_id_type;
2N/A uint_t vdp_prof_id_vers;
2N/A vdp_prof_proc_state_t vdp_prof_proc_state;
2N/A vdp_tlv_type_t vdp_prof_vsi_state; /* same as TLV type */
2N/A vdp_tlv_type_t vdp_prof_cmd_pending; /* same as TLV type */
2N/A vdp_tlv_t vdp_prof_tlv;
2N/A char vdp_prof_wire_tlv[ETHERMTU];
2N/A int vdp_prof_tlv_len;
2N/A int vdp_prof_timer_id;
2N/A struct vdp_inst_struct_s *vdp_prof_instp;
2N/A boolean_t vdp_prof_deleted;
2N/A
2N/A int vdp_prof_fltr_entries;
2N/A vdp_tlv_fltr_fmt_t vdp_prof_fltr_info_format;
2N/A vtf_mac_t vdp_prof_tlv_fltr_mac;
2N/A list_node_t vdp_profile_node;
2N/A vdp_tlv_mgr_t vdp_prof_mgr_tlv;
2N/A vdp_tlv_mgrenc_t vdp_prof_mgr_enc_tlv;
2N/A /* per-vsi Statistics */
2N/A uint64_t vdp_prof_ipkts;
2N/A uint64_t vdp_prof_opkts;
2N/A uint64_t vdp_prof_kas;
2N/A} vdp_profile_t;
2N/A
2N/A#define VDP_PROF_STAT_UPDATE(v, s, c) { \
2N/A vdp_profile_t *vp = (vdp_profile_t *)(v); \
2N/A vdp_inst_t *vi = (vdp_inst_t *)vp->vdp_prof_instp; \
2N/A vp->vdp_prof_##s += ((uint64_t)(c)); \
2N/A vi->vdp_inst_##s += ((uint64_t)(c)); \
2N/A}
2N/A
2N/A/* VDP instance for each physical port */
2N/Atypedef struct vdp_inst_struct_s {
2N/A char vdp_inst_phy_link_name[MAXLINKNAMELEN];
2N/A datalink_id_t vdp_inst_phy_id;
2N/A vdp_state_t vdp_inst_state;
2N/A void *vdp_inst_ecp_handle;
2N/A size_t vdp_inst_ecp_offset; /* offset for ECP header */
2N/A pthread_cond_t vdp_inst_cv;
2N/A pthread_mutex_t vdp_inst_lock;
2N/A uint8_t vdp_inst_lphysaddr[DLPI_PHYSADDR_MAX];
2N/A size_t vdp_inst_lphysaddr_len;
2N/A int vdp_inst_sockfd;
2N/A pthread_t vdp_inst_timeout_process_thread;
2N/A list_t vdp_inst_profiles; /* list of profiles */
2N/A list_node_t vdp_inst_node; /* link in Global instance list */
2N/A iu_tq_t *vdp_inst_tq;
2N/A /* Statistics */
2N/A uint64_t vdp_inst_ipkts;
2N/A uint64_t vdp_inst_opkts;
2N/A uint64_t vdp_inst_kas;
2N/A} vdp_inst_t;
2N/A
2N/Aextern void vdp_logmsg(int, const char *, ...);
2N/A
2N/A#define logerr(...) vdp_logmsg(LOG_ERR, __VA_ARGS__)
2N/A#define logtrace(...) vdp_logmsg(LOG_INFO, __VA_ARGS__)
2N/A#define logdebug(...) vdp_logmsg(LOG_DEBUG, __VA_ARGS__)
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SYS_VDP_IMPL_H */