/*****************************************************************************
 * Copyright (c) 1988-95 Digi International Inc., All Rights Reserved
 * 
 * This  software  contains  proprietary  and  confidential   information   of
 * Digi International  Inc.   By  accepting  transfer  of this copy, Recipient
 * agrees to retain this software in  confidence,  to  prevent  disclosure  to
 * others,  and  to make no  use of this software other than that for which it
 * was delivered.  This is an unpublished copyright work  Digi   International
 * Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is
 * strictly prohibited.
 * 
 * Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc.
 * Confidential  when   combined   with   the   aggregated  modules  for  this
 * product) OBJECT CODE ONLY SOURCE MATERIALS
 * 
 * (C) COPYRIGHT Digi International Inc. 1995
 * 
 * All Rights Reserved
 * 
 * US   Government   Users   Restricted   Rights   -   Use,   duplication   or
 * disclosure  restricted by GSA ADP Schedule Contract with Digi International
 * Inc.
 * 
 *****************************************************************************/

/*
 * $Id: fastfr.h,v 1.3 1996/10/24 20:24:36 gary Exp $
 */

/******************************************************************
 *
 *	ISO 3309 module definitions
 *
 ******************************************************************/

#define	ACCM_LENGTH	32

struct fast_frame_stats {
	uint32 frames_sent;
	uint32 frames_received;
	uint32 frames_invalid;
	uint32 frames_encap_errors;
	uint32 bytes_encoded;
	uint32 bytes_transmitted;
	uint32 bytes_decoded;
	uint32 bytes_extracted;
};

typedef struct fast_frame_stats ffrstats_t;

struct fast_frame_info {
	queue_t *read_q;		/* read queue which points to entry */
	queue_t *write_q;		/* write queue which points to entry */
	uint8 ACCM[ACCM_LENGTH];	/* ACCM flags */
	mblk_t *first_buffer;		/* first read-side buffer on hold */
	mblk_t *last_buffer;		/* last read-side buffer on hold */
	uint16 FCS;			/* Saved FCS state for read-side */
	uint16 SBDPTCount;		/* Saved SBDPT state for read-side */
	uint8 read_state;		/* Read state */
	uint8 state;			/* Module's current state */
	uint8 options;			/* Currently selected options */
	ffrstats_t stats;		/* Statistics */
};

typedef struct fast_frame_info ffr_t;

/* Possible module states */
#define	FSTFS_UNUSED		0x00
#define	FSTFS_INACTIVE		0x01
#define	FSTFS_PAUSED		0x02
#define	FSTFS_ACTIVE		0x03

/* Possible read-side states */
#define	FSTFRS_WAITING		0x00	/* Waiting for start of frame */
#define	FSTFRS_READY		0x01	/* In middle of frame */
#define	FSTFRS_ESCAPED		0x02	/* Last byte of data was 0x7D */

/* Possible options */
#define	FSTFO_SBDPT		0x01	/* Seven-Bit Data Path Transparency */

/* Possible M_PROTO commands */
#define	FSTFP_FRAME		180
#define	FSTFP_ACTIVATE		181
#define	FSTFP_DEACTIVATE	182
#define	FSTFP_PAUSE		183
#define	FSTFP_UNPAUSE		184

/* Possible M_IOCTL commands */
#define	FSTFI_BASE		(0xEE << 8)
#define	FSTFI_GETSTATS		(FSTFI_BASE|1)
#define	FSTFI_CLEARSTATS	(FSTFI_BASE|2)

struct ffr_frame_struct {
	uint8 command;			/* should be FSTFP_FRAME */
	uint8 address;			/* Address byte */
	uint8 control;			/* Control byte */
	uint8 pad;			/* padding */
};

struct ffr_activate_struct {
	uint8 command;			/* should be FSTFP_ACTIVATE */
	uint8 options;			/* encap/decap options */
	uint8 pad[2];			/* padding */
	uint32 ACCM;			/* ACCM flag list */
};

typedef struct ffr_frame_struct ffr_frame_t;
typedef struct ffr_activate_struct ffr_activate_t;

union ffr_miscmsg_struct {
	uint8 command;
	ffr_frame_t ffr_frame;
	ffr_activate_t ffr_activate;
};

typedef union ffr_miscmsg_struct ffr_miscmsg_t;

