06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER START
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The contents of this file are subject to the terms of the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Common Development and Distribution License (the "License").
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You may not use this file except in compliance with the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * or http://www.opensolaris.org/os/licensing.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * See the License for the specific language governing permissions
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * and limitations under the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * When distributing Covered Code, include this CDDL HEADER in each
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If applicable, add the following below this CDDL HEADER, with the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * fields enclosed by brackets "[]" replaced with your own identifying
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * information: Portions Copyright [yyyy] [name of copyright owner]
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER END
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
0e26330710421d79f1fbb73c4f5f75086785b207WENTAO YANG * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * This header file contains the basic data structures which the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * virtual switch (vsw) uses to communicate with vnet clients.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The virtual switch reads the machine description (MD) to
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * determine how many port_t structures to create (each port_t
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * can support communications to a single network device). The
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * port_t's are maintained in a linked list.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Each port in turn contains a number of logical domain channels
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * (ldc's) which are inter domain communications channels which
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * are used for passing small messages between the domains. There
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * may be any number of channels associated with each port, though
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * currently most devices only have a single channel. The current
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * implementation provides support for only one channel per port.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The ldc is a bi-directional channel, which is divided up into
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * two directional 'lanes', one outbound from the switch to the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * virtual network device, the other inbound to the switch.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Depending on the type of device each lane may have seperate
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * communication paramaters (such as mtu etc).
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * For those network clients which use descriptor rings the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * rings are associated with the appropriate lane. I.e. rings
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * which the switch exports are associated with the outbound lanes
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * while those which the network clients are exporting to the switch
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * are associated with the inbound lane.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * In diagram form the data structures look as follows:
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * vsw instance
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * |
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * +----->port_t----->port_t----->port_t----->
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * |
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * +--->ldc_t
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * |
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * +--->lane_t (inbound)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * | |
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * | +--->dring
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * |
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * +--->lane_t (outbound)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * |
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * +--->dring
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#ifndef _VSW_LDC_H
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define _VSW_LDC_H
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#ifdef __cplusplus
06db247c678f0e3956535e8a6dec31d6c2108827raghuramextern "C" {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#endif
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna/*
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna * LDC pkt tranfer MTU - largest msg size used
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define VSW_LDC_MTU 64
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define VSW_DEF_MSG_WORDS \
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna (VNET_DRING_REG_EXT_MSG_SIZE_MAX / sizeof (uint64_t))
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Default message type.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct def_msg {
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint64_t data[VSW_DEF_MSG_WORDS];
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} def_msg_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Currently only support one major/minor pair.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_NUM_VER 1
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct ver_sup {
f2b610cf6e03184d9538e3aaec99bcaf65124714wentaoy uint16_t ver_major; /* major version number */
f2b610cf6e03184d9538e3aaec99bcaf65124714wentaoy uint16_t ver_minor; /* minor version number */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} ver_sup_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Lane states.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_LANE_INACTIV 0x0 /* No params set for lane */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_INFO_SENT 0x1 /* Version # sent to peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_INFO_RECV 0x2 /* Version # recv from peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_ACK_RECV 0x4
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_ACK_SENT 0x8
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_NACK_RECV 0x10
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_VER_NACK_SENT 0x20
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_INFO_SENT 0x40 /* Attributes sent to peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_INFO_RECV 0x80 /* Peer attributes received */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_ACK_SENT 0x100
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_ACK_RECV 0x200
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_NACK_SENT 0x400
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_ATTR_NACK_RECV 0x800
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_INFO_SENT 0x1000 /* Dring info sent to peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_INFO_RECV 0x2000 /* Dring info received */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_ACK_SENT 0x4000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_ACK_RECV 0x8000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_NACK_SENT 0x10000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_DRING_NACK_RECV 0x20000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_INFO_SENT 0x40000 /* RDX sent to peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_INFO_RECV 0x80000 /* RDX received from peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_ACK_SENT 0x100000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_ACK_RECV 0x200000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_NACK_SENT 0x400000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RDX_NACK_RECV 0x800000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_INFO_SENT 0x1000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_INFO_RECV 0x2000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_ACK_SENT 0x4000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_ACK_RECV 0x8000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_NACK_SENT 0x10000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MCST_NACK_RECV 0x20000000
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_LANE_ACTIVE 0x40000000 /* Lane open to xmit data */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* Handshake milestones */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MILESTONE0 0x1 /* ver info exchanged */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MILESTONE1 0x2 /* attribute exchanged */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MILESTONE2 0x4 /* dring info exchanged */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MILESTONE3 0x8 /* rdx exchanged */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MILESTONE4 0x10 /* handshake complete */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Lane direction (relative to ourselves).
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define INBOUND 0x1
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define OUTBOUND 0x2
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* Peer session id received */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PEER_SESSION 0x1
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Maximum number of consecutive reads of data from channel
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MAX_CHAN_READ 50
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Currently only support one ldc per port.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_MAX_LDCS 1 /* max # of ldcs per port */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Used for port add/deletion.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_UPDATED 0x1
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define LDC_TX_SUCCESS 0 /* ldc transmit success */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define LDC_TX_FAILURE 1 /* ldc transmit failure */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define LDC_TX_NORESOURCES 2 /* out of descriptors */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Descriptor ring info
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Each descriptor element has a pre-allocated data buffer
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * associated with it, into which data being transmitted is
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * copied. By pre-allocating we speed up the copying process.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The buffer is re-used once the peer has indicated that it is
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * finished with the descriptor.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_RING_EL_DATA_SZ 2048 /* Size of data section (bytes) */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PRIV_SIZE sizeof (vnet_private_desc_t)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MAX_COOKIES ((ETHERMTU >> MMU_PAGESHIFT) + 2)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Size of the mblk in each mblk pool.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MBLK_SZ_128 128
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MBLK_SZ_256 256
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_MBLK_SZ_2048 2048
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Number of mblks in each mblk pool.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_NUM_MBLKS 1024
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
34f94fbc7a730740933e4776ade5f74009afe4ceWENTAO YANG/*
34f94fbc7a730740933e4776ade5f74009afe4ceWENTAO YANG * Number of rcv buffers in RxDringData mode
34f94fbc7a730740933e4776ade5f74009afe4ceWENTAO YANG */
34f94fbc7a730740933e4776ade5f74009afe4ceWENTAO YANG#define VSW_RXDRING_NRBUFS (vsw_num_descriptors * vsw_nrbufs_factor)
34f94fbc7a730740933e4776ade5f74009afe4ceWENTAO YANG
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna/* increment recv index */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define INCR_DESC_INDEX(dp, i) \
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ((i) = (((i) + 1) & ((dp)->num_descriptors - 1)))
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna/* decrement recv index */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define DECR_DESC_INDEX(dp, i) \
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ((i) = (((i) - 1) & ((dp)->num_descriptors - 1)))
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define INCR_TXI INCR_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define DECR_TXI DECR_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define INCR_RXI INCR_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define DECR_RXI DECR_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna/* bounds check rx index */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define CHECK_DESC_INDEX(dp, i) \
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna (((i) >= 0) && ((i) < (dp)->num_descriptors))
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define CHECK_RXI CHECK_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna#define CHECK_TXI CHECK_DESC_INDEX
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Private descriptor
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_private_desc {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Below lock must be held when accessing the state of
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * a descriptor on either the private or public sections
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * of the ring.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t dstate_lock;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t dstate;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vnet_public_desc_t *descp;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldc_mem_handle_t memhandle;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram void *datap;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t datalen;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t ncookies;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldc_mem_cookie_t memcookie[VSW_MAX_COOKIES];
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int bound;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_private_desc_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Descriptor ring structure
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct dring_info {
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kmutex_t dlock; /* sync access */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t num_descriptors; /* # of descriptors */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t descriptor_size; /* size of descriptor */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t options; /* dring options (mode) */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ldc_dring_handle_t dring_handle; /* dring LDC handle */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t dring_ncookies; /* # of dring cookies */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ldc_mem_cookie_t dring_cookie[1]; /* LDC cookie of dring */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ldc_mem_handle_t data_handle; /* data area LDC handle */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t data_ncookies; /* # of data area cookies */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna ldc_mem_cookie_t *data_cookie; /* data area LDC cookies */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint64_t ident; /* identifier sent to peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t end_idx; /* last idx processed */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna int64_t last_ack_recv; /* last ack received */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kmutex_t txlock; /* protect tx desc alloc */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t next_txi; /* next tx descriptor index */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t next_rxi; /* next expected recv index */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kmutex_t restart_lock; /* protect restart_reqd */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram boolean_t restart_reqd; /* send restart msg */
0e26330710421d79f1fbb73c4f5f75086785b207WENTAO YANG uint32_t restart_peer_txi; /* index to restart peer */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram void *pub_addr; /* base of public section */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram void *priv_addr; /* base of private section */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram void *data_addr; /* base of data section */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram size_t data_sz; /* size of data section */
c1c61f44e88f4c8c155272ee56d868043146096asb size_t desc_data_sz; /* size of descr data blk */
bbfa0259e68b6b625e9e085053d41d620f185eeeha uint8_t dring_mtype; /* dring mem map type */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t num_bufs; /* # of buffers */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna vio_mblk_pool_t *rx_vmp; /* rx mblk pool */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna vio_mblk_t **rxdp_to_vmp; /* descr to buf map tbl */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} dring_info_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Each ldc connection is comprised of two lanes, incoming
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * from a peer, and outgoing to that peer. Each lane shares
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * common ldc parameters and also has private lane-specific
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * parameters.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct lane {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t lstate; /* Lane state */
f2b610cf6e03184d9538e3aaec99bcaf65124714wentaoy uint16_t ver_major; /* Version major number */
f2b610cf6e03184d9538e3aaec99bcaf65124714wentaoy uint16_t ver_minor; /* Version minor number */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t seq_num; /* Sequence number */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t mtu; /* ETHERMTU */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t addr; /* Unique physical address */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t addr_type; /* Only MAC address at moment */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t xfer_mode; /* Dring or Pkt based */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t ack_freq; /* Only non zero for Pkt based xfer */
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna uint32_t physlink_update; /* physlink updates */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint8_t dring_mode; /* Descriptor ring mode */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram dring_info_t *dringp; /* List of drings for this lane */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} lane_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* channel drain states */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_LDC_INIT 0x1 /* Initial non-drain state */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_LDC_DRAINING 0x2 /* Channel draining */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
f0ca1d9a12d54d304791bc74525e2010ca924726sb/*
f0ca1d9a12d54d304791bc74525e2010ca924726sb * vnet-protocol-version dependent function prototypes.
f0ca1d9a12d54d304791bc74525e2010ca924726sb */
f0ca1d9a12d54d304791bc74525e2010ca924726sbtypedef int (*vsw_ldctx_t) (void *, mblk_t *, mblk_t *, uint32_t);
f0ca1d9a12d54d304791bc74525e2010ca924726sbtypedef void (*vsw_ldcrx_pktdata_t) (void *, void *, uint32_t);
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatnatypedef void (*vsw_ldcrx_dringdata_t) (void *, void *);
f0ca1d9a12d54d304791bc74525e2010ca924726sb
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* ldc information associated with a vsw-port */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_ldc {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct vsw_ldc *ldc_next; /* next ldc in the list */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct vsw_port *ldc_port; /* associated port */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct vsw *ldc_vswp; /* associated vsw */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t ldc_cblock; /* sync callback processing */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t ldc_txlock; /* sync transmits */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t ldc_rxlock; /* sync rx */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t ldc_id; /* channel number */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldc_handle_t ldc_handle; /* channel handle */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t drain_cv_lock;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kcondvar_t drain_cv; /* channel draining */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int drain_state;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint32_t hphase; /* handshake phase */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int hcnt; /* # handshake attempts */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t status_lock;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldc_status_t ldc_status; /* channel status */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t reset_active; /* reset flag */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t local_session; /* Our session id */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t peer_session; /* Our peers session id */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t session_status; /* Session recv'd, sent */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint32_t hss_id; /* Handshake session id */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t next_ident; /* Next dring ident # to use */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram lane_t lane_in; /* Inbound lane */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram lane_t lane_out; /* Outbound lane */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint8_t dev_class; /* Peer device class */
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna boolean_t pls_negotiated; /* phys link state update ? */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vio_multi_pool_t vmp; /* Receive mblk pools */
7b1f684a14f99a2b9b1b2561f484ff648eff6d9bSriharsha Basavapatna uint32_t max_rxpool_size; /* max size of rxpool in use */
f0ca1d9a12d54d304791bc74525e2010ca924726sb uint64_t *ldcmsg; /* msg buffer for ldc_read() */
f0ca1d9a12d54d304791bc74525e2010ca924726sb uint64_t msglen; /* size of ldcmsg */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t dringdata_msgid; /* msgid in RxDringData mode */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* tx thread fields */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kthread_t *tx_thread; /* tx thread */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint32_t tx_thr_flags; /* tx thread flags */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t tx_thr_lock; /* lock for tx thread */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kcondvar_t tx_thr_cv; /* cond.var for tx thread */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mblk_t *tx_mhead; /* tx mblks head */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mblk_t *tx_mtail; /* tx mblks tail */
f0ca1d9a12d54d304791bc74525e2010ca924726sb uint32_t tx_cnt; /* # of pkts queued for tx */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna /* message thread fields */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kthread_t *msg_thread; /* message thread */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t msg_thr_flags; /* message thread flags */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kmutex_t msg_thr_lock; /* lock for message thread */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kcondvar_t msg_thr_cv; /* cond.var for msg thread */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* receive thread fields */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kthread_t *rcv_thread; /* receive thread */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna uint32_t rcv_thr_flags; /* receive thread flags */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kmutex_t rcv_thr_lock; /* lock for receive thread */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna kcondvar_t rcv_thr_cv; /* cond.var for recv thread */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
f0ca1d9a12d54d304791bc74525e2010ca924726sb vsw_ldctx_t tx; /* transmit function */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna vsw_ldcrx_pktdata_t rx_pktdata; /* process raw data msg */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna vsw_ldcrx_dringdata_t rx_dringdata; /* process dring data msg */
f0ca1d9a12d54d304791bc74525e2010ca924726sb
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* channel statistics */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vgen_stats_t ldc_stats; /* channel statistics */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_t *ksp; /* channel kstats */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_ldc_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* worker thread flags */
6f09f0fef8e4582cfa771d87fe2a1f777bfb5cf0WENTAO YANG#define VSW_WTHR_DATARCVD 0x01 /* data received */
6f09f0fef8e4582cfa771d87fe2a1f777bfb5cf0WENTAO YANG#define VSW_WTHR_STOP 0x02 /* stop worker thread request */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* multicast addresses port is interested in */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct mcst_addr {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct mcst_addr *nextp;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct ether_addr mca; /* multicast address */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint64_t addr; /* mcast addr converted to hash key */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram boolean_t mac_added; /* added into physical device */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} mcst_addr_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* Port detach states */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_INIT 0x1 /* Initial non-detach state */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_DETACHING 0x2 /* In process of being detached */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_DETACHABLE 0x4 /* Safe to detach */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* port information associated with a vsw */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_port {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int p_instance; /* port instance */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct vsw_port *p_next; /* next port in the list */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct vsw *p_vswp; /* associated vsw */
c1c61f44e88f4c8c155272ee56d868043146096asb int num_ldcs; /* # of ldcs in the port */
c1c61f44e88f4c8c155272ee56d868043146096asb uint64_t *ldc_ids; /* ldc ids */
7bd3a2e26cc8569257b88c1691d559138e1d32d0Sriharsha Basavapatna vsw_ldc_t *ldcp; /* ldc for this port */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t tx_lock; /* transmit lock */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int (*transmit)(vsw_ldc_t *, mblk_t *);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int state; /* port state */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t state_lock;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kcondvar_t state_cv;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng krwlock_t maccl_rwlock; /* protect fields below */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_client_handle_t p_mch; /* mac client handle */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_unicast_handle_t p_muh; /* mac unicast handle */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmutex_t mca_lock; /* multicast lock */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mcst_addr_t *mcap; /* list of multicast addrs */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng boolean_t addr_set; /* Addr set where */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * mac address of the port & connected device
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram struct ether_addr p_macaddr;
c1c61f44e88f4c8c155272ee56d868043146096asb uint16_t pvid; /* port vlan id (untagged) */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng struct vsw_vlanid *vids; /* vlan ids (tagged) */
c1c61f44e88f4c8c155272ee56d868043146096asb uint16_t nvids; /* # of vids */
c1c61f44e88f4c8c155272ee56d868043146096asb mod_hash_t *vlan_hashp; /* vlan hash table */
c1c61f44e88f4c8c155272ee56d868043146096asb uint32_t vlan_nchains; /* # of vlan hash chains */
678453a8ed49104d8adad58f3ba591bdc39883e8speer
678453a8ed49104d8adad58f3ba591bdc39883e8speer /* HybridIO related info */
678453a8ed49104d8adad58f3ba591bdc39883e8speer uint32_t p_hio_enabled; /* Hybrid mode enabled? */
678453a8ed49104d8adad58f3ba591bdc39883e8speer uint32_t p_hio_capable; /* Port capable of HIO */
bce0a86e5d4d65341c5aca6da2595c848297b2aaWENTAO YANG
bce0a86e5d4d65341c5aca6da2595c848297b2aaWENTAO YANG /* bandwidth limit */
bce0a86e5d4d65341c5aca6da2595c848297b2aaWENTAO YANG uint64_t p_bandwidth; /* bandwidth limit */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_port_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* list of ports per vsw */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_port_list {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vsw_port_t *head; /* head of the list */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram krwlock_t lockrw; /* sync access(rw) to the list */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram int num_ports; /* number of ports in the list */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_port_list_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Taskq control message
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_ctrl_task {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vsw_ldc_t *ldcp;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram def_msg_t pktp;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint32_t hss_id;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_ctrl_task_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * State of connection to peer. Some of these states
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * can be mapped to LDC events as follows:
06db247c678f0e3956535e8a6dec31d6c2108827raghuram *
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * VSW_CONN_RESET -> LDC_RESET_EVT
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * VSW_CONN_UP -> LDC_UP_EVT
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_CONN_UP 0x1 /* Connection come up */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_CONN_RESET 0x2 /* Connection reset */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_CONN_RESTART 0x4 /* Restarting handshake on connection */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuramtypedef struct vsw_conn_evt {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram uint16_t evt; /* Connection event */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vsw_ldc_t *ldcp;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram} vsw_conn_evt_t;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/*
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Ethernet broadcast address definition.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic struct ether_addr etherbroadcastaddr = {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
06db247c678f0e3956535e8a6dec31d6c2108827raghuram};
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define IS_BROADCAST(ehp) \
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (bcmp(&ehp->ether_dhost, &etherbroadcastaddr, ETHERADDRL) == 0)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define IS_MULTICAST(ehp) \
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ((ehp->ether_dhost.ether_addr_octet[0] & 01) == 1)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define READ_ENTER(x) rw_enter(x, RW_READER)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define WRITE_ENTER(x) rw_enter(x, RW_WRITER)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define RW_EXIT(x) rw_exit(x)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_REFHOLD(portp) atomic_inc_32(&((portp)->ref_cnt))
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#define VSW_PORT_REFRELE(portp) atomic_dec_32(&((portp)->ref_cnt))
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#ifdef __cplusplus
06db247c678f0e3956535e8a6dec31d6c2108827raghuram}
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#endif
06db247c678f0e3956535e8a6dec31d6c2108827raghuram
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#endif /* _VSW_LDC_H */