/*****************************************************************************

 @(#) sdli_ioctl.h,v 0.7 2000/11/25 07:22:11 brian Exp

 -----------------------------------------------------------------------------

     Copyright (C) 2000  Brian Bidulock.  All Rights Reserved.


                                  PUBLIC LICENSE

     This license is provided without fee, provided that the above copy-
     right notice and this public license must be retained on all copies,
     extracts, compilations and derivative works.  Use or distribution of
     this work in a manner that restricts its use except as provided here
     will render this license void.

     The author(s) hereby waive any and all other restrictions in respect
     of their copyright in this software and its associated documentation.
     The authors(s) of this software place in the public domain any novel
     methods or processes which are embodied in this software.

     The author(s) undertook to write it for the sake of the advancement
     of the Arts and Sciences, but it is provided as is, and the author(s)
     will not take any responsibility in it.

 -----------------------------------------------------------------------------

 Last Modified 2000/11/25 07:22:11 by brian

 sdli_ioctl.h,v
 Revision 0.7  2000/11/25 07:22:11  brian
 Added SDLI interface below SDTI.

 *****************************************************************************/

#ident @(#) sdli_ioctl.h,v 0.7 2000/11/25 07:22:11 brian Exp

#ifndef __SDLI_IOCTL_H__
#define __SDLI_IOCTL_H__

#include <linux/ioctl.h>

#define SDL_IOC_MAGIC 'd'

/*
 *  CONFIGURATION
 */

typedef struct sdl_config {
    sdl_ulong   pvar;   /* protocol variant */
    sdl_ulong   popt;   /* protocol options */
    sdl_ulong   N;      /* octets per su    */
} sdl_config_t;

#define SDL_POPT_HSL    0x01    /* high speed link              */
#define SDL_POPT_XSN    0x02    /* exitended sequence numbers   */

#define SDL_IOCTCONFIG  _IOWR( SDL_IOC_MAGIC,  0, sdl_config_t )
#define SDL_IOCCCONFIG  _IOR(  SDL_IOC_MAGIC,  1, sdl_config_t )
#define SDL_IOCSCONFIG  _IOWR( SDL_IOC_MAGIC,  2, sdl_config_t )
#define SDL_IOCGCONFIG  _IOR(  SDL_IOC_MAGIC,  3, sdl_config_t )

/*
 *  STATE
 */

typedef struct sdl_statem {
    sdl_ulong   daedt_state;
    sdl_ulong   daedr_state;
    sdl_ulong   octet_counting_mode;
} sdl_statem_t;

#define SDL_STATE_IDLE          0x00
#define SDL_STATE_IN_SERVICE    0x01

#define SDL_IOCCMRESET  _IOR(  SDL_IOC_MAGIC,  4, sdl_statem_t )
#define SDL_IOCGSTATEM  _IOR(  SDL_IOC_MAGIC,  5, sdl_statem_t )

/*
 *  STATISTICS
 */

typedef struct sdl_stats {
    sdl_ulong   rx_bytes;
    sdl_ulong   tx_bytes;
    sdl_ulong   rx_sus;
    sdl_ulong   tx_sus;
    sdl_ulong   rx_overruns;
    sdl_ulong   tx_underruns;
    sdl_ulong   rx_aborts;
    sdl_ulong   tx_aborts;
    sdl_ulong   rx_buffer_overflows;
    sdl_ulong   tx_buffer_overflows;
    sdl_ulong   rx_sus_in_error;
    sdl_ulong   rx_sync_transitions;
    sdl_ulong   rx_bits_octet_counted;
    sdl_ulong   rx_crc_errors;
    sdl_ulong   rx_frame_errors;
    sdl_ulong   rx_frame_overflows;
    sdl_ulong   rx_frame_too_long;
    sdl_ulong   rx_frame_too_short;
    sdl_ulong   rx_residue_errors;
    sdl_ulong   lead_cts_lost;
    sdl_ulong   lead_dcd_lost;
} sdl_stats_t;

#define SDL_IOCSSTATSP  _IOWR( SDL_IOC_MAGIC,  6, sdl_stats_t  )
#define SDL_IOCGSTATSP  _IOR(  SDL_IOC_MAGIC,  7, sdl_stats_t  )
#define SDL_IOCCSTATS   _IOW(  SDL_IOC_MAGIC,  8, sdl_stats_t  )
#define SDL_IOCGSTATS   _IOR(  SDL_IOC_MAGIC,  9, sdl_stats_t  )

/*
 *  EVENTS
 */
typedef struct sdl_events {
    sdl_ulong   sdl_mask;
} sdl_events_t;

#define SDL_EVT_LOST_SYNC   0x0000001
#define SDL_EVT_SU_ERROR    0x0000002
#define SDL_EVT_TX_FAIL     0x0000004
#define SDL_EVT_RX_FAIL     0x0000008

#define SDL_IOCSNOTIFY  _IOW(  SDL_IOC_MAGIC, 10, sdl_events_t )
#define SDL_IOCCNOTIFY  _IOW(  SDL_IOC_MAGIC, 11, sdl_events_t )
#define SDL_IOCGNOTIFY  _IOR(  SDL_IOC_MAGIC, 12, sdl_events_t )

/*
 *  Device config
 */

typedef struct sdl_device {
    sdl_ulong   iftype;     /* interface type   */
    sdl_ulong   grptype;    /* group type       */
    sdl_ulong   ifmode;     /* interface mode   */
    sdl_ulong   ifrate;     /* interface rate   */
    sdl_ulong   ifclock;    /* interface clock  */
    sdl_ulong   ifcoding;   /* interface coding */
    sdl_ulong   ifleads;    /* interface leads  */
    sdl_ulong   ifindex;    /* interface index  */
    sdl_ulong   irq;        /* interrupt        */
    sdl_ulong   iobase;     /* i/o base address */
    sdl_ulong   dma_rx;     /* dma receive      */
    sdl_ulong   dma_tx;     /* dma transmit     */
} sdl_device_t;

#define SDL_IOCSIFTYPE    _IOW( SDL_IOC_MAGIC, 64 +  1, sdl_ulong )
#define SDL_IOCGIFTYPE    _IOR( SDL_IOC_MAGIC, 64 +  2, sdl_ulong )

enum {
    SDL_TYPE_NONE,
    SDL_TYPE_V35,
    SDL_TYPE_DS0,
    SDL_TYPE_DS0A,
    SDL_TYPE_E1,
    SDL_TYPE_T1,
    SDL_TYPE_J1,
    SDL_TYPE_ATM,
    SDL_TYPE_PACKET
};

#define SDL_IOCSGRPTYPE   _IOW( SDL_IOC_MAGIC, 64 +  3, sdl_ulong )
#define SDL_IOCGGRPTYPE   _IOR( SDL_IOC_MAGIC, 64 +  4, sdl_ulong )

enum {
    SDL_GTYPE_NONE,
    SDL_GTYPE_T1,
    SDL_GTYPE_E1,
    SDL_GTYPE_J1,
    SDL_GTYPE_ATM
};

#define SDL_IOCSIFMODE    _IOW( SDL_IOC_MAGIC, 64 +  5, sdl_ulong )
#define SDL_IOCGIFMODE    _IOR( SDL_IOC_MAGIC, 64 +  6, sdl_ulong )

enum {
    SDL_MODE_NONE,
    SDL_MODE_DSU,
    SDL_MODE_CSU,
    SDL_MODE_DTE,
    SDL_MODE_DCE,
    SDL_MODE_CLIENT,
    SDL_MODE_SERVER,
    SDL_MODE_PEER,
    SDL_MODE_ECHO,
    SDL_MODE_REM_LB,
    SDL_MODE_LOC_LB,
    SDL_MODE_LB_ECHO,
    SDL_MODE_TEST
};

#define SDL_IOCSIFRATE    _IOW( SDL_IOC_MAGIC, 64 +  7, sdl_ulong )
#define SDL_IOCGIFRATE    _IOR( SDL_IOC_MAGIC, 64 +  8, sdl_ulong )

#define SDL_IOCSIFCLOCK   _IOW( SDL_IOC_MAGIC, 64 +  9, sdl_ulong )
#define SDL_IOCGIFCLOCK   _IOR( SDL_IOC_MAGIC, 64 + 10, sdl_ulong )

enum {
    SDL_CLOCK_NONE,
    SDL_CLOCK_INT,
    SDL_CLOCK_EXT,
    SDL_CLOCK_LOOP,
    SDL_CLOCK_MASTER,
    SDL_CLOCK_SLAVE,
    SDL_CLOCK_DPLL
};

#define SDL_IOCSIFCODING  _IOW( SDL_IOC_MAGIC, 64 + 11, sdl_ulong )
#define SDL_IOCGIFCODING  _IOR( SDL_IOC_MAGIC, 64 + 12, sdl_ulong )

enum {
    SDL_CODING_NONE,
    SDL_CODING_NRZ,
    SDL_CODING_NRZI,
    SDL_CODING_AMI,
    SDL_CODING_B6ZS,
    SDL_CODING_B8ZS,
    SDL_CODING_ESF,
    SDL_CODING_AAL1,
    SDL_CODING_AAL2,
    SDL_CODING_AAL5
};

#define SDL_IOCSIFLEADS   _IOW( SDL_IOC_MAGIC, 64 + 13, sdl_ulong )
#define SDL_IOCCIFLEADS   _IOW( SDL_IOC_MAGIC, 64 + 14, sdl_ulong )
#define SDL_IOCGIFLEADS   _IOR( SDL_IOC_MAGIC, 64 + 15, sdl_ulong )

enum {
    SDL_LEAD_DTR = 0x01,    /* for V.35 DTR lead set or clr */
    SDL_LEAD_RTS = 0x02,    /* for V.35 RTS lead set or clr */
    SDL_LEAD_DCD = 0x04,    /* for V.35 DCD lead get */
    SDL_LEAD_CTS = 0x08,    /* for V.35 CTS lead get */
    SDL_LEAD_DSR = 0x10     /* for V.35 DSR lead get */
};

#define SDL_IOCCDISCTX    _IO(  SDL_IOC_MAGIC, 64 + 16 )
#define SDL_IOCCCONNTX    _IO(  SDL_IOC_MAGIC, 64 + 17 )

#define SDL_IOCDEVPRIVATE 128


#endif  __SDLI_IOCTL_H__
