ceddk.h revision 154899
1/* 2 * Middle-level code for Cronyx Tau32-PCI adapters. 3 * 4 * Copyright (C) 2004 Cronyx Engineering 5 * Copyright (C) 2004 Roman Kurakin <rik@FreeBSD.org> 6 * 7 * This software is distributed with NO WARRANTIES, not even the implied 8 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * 10 * Authors grant any other persons or organisations a permission to use, 11 * modify and redistribute this software in source and binary forms, 12 * as long as this message is kept with the software, all derivative 13 * works or modified versions. 14 * 15 * $Cronyx: ceddk.h,v 1.2.6.1 2005/11/09 13:01:39 rik Exp $ 16 * $FreeBSD: head/sys/dev/ce/ceddk.h 154899 2006-01-27 09:02:09Z rik $ 17 */ 18 19#define TAU32_UserContext_Add void *sys; 20#define TAU32_UserRequest_Add void *sys; TAU32_UserRequest *next; 21 22#include <dev/ce/tau32-ddk.h> 23 24#define NCHAN TAU32_CHANNELS 25#ifndef NBRD 26# define NBRD 6 27#endif 28#if NBRD != 6 29# error "NBRD != 6" 30#endif 31 32#define BUFSZ 1664 33 34typedef struct _ce_buf_item_t { 35 TAU32_UserRequest req; 36 unsigned char buf [BUFSZ+4]; 37 unsigned long phys; 38} ce_buf_item_t; 39 40typedef struct _ce_buf_t { 41 ce_buf_item_t tx_item[TAU32_IO_QUEUE]; 42 ce_buf_item_t rx_item[TAU32_IO_QUEUE]; 43} ce_buf_t; 44 45typedef struct { 46 unsigned long bpv; /* bipolar violations */ 47 unsigned long fse; /* frame sync errors */ 48 unsigned long crce; /* CRC errors */ 49 unsigned long rcrce; /* remote CRC errors (E-bit) */ 50 unsigned long uas; /* unavailable seconds */ 51 unsigned long les; /* line errored seconds */ 52 unsigned long es; /* errored seconds */ 53 unsigned long bes; /* bursty errored seconds */ 54 unsigned long ses; /* severely errored seconds */ 55 unsigned long oofs; /* out of frame seconds */ 56 unsigned long css; /* controlled slip seconds */ 57 unsigned long dm; /* degraded minutes */ 58} ce_gstat_t; 59 60typedef struct _ce_chan_t { 61 unsigned char num; 62 unsigned char type; 63#define T_NONE 0 /* no channel */ 64#define T_E1 3 /* E1 */ 65#define T_DATA 6 /* no physical interface */ 66 67 struct _ce_board_t *board; 68 unsigned char dtr; 69 unsigned char rts; 70 ce_buf_item_t *tx_item; 71 ce_buf_item_t *rx_item; 72 TAU32_UserRequest *rx_queue; 73 TAU32_UserRequest *tx_queue; 74 unsigned char debug; 75 void (*transmit) (struct _ce_chan_t*, void*, int); 76 void (*receive) (struct _ce_chan_t*, unsigned char*, int); 77 void (*error) (struct _ce_chan_t*, int); 78#define CE_FRAME 1 79#define CE_CRC 2 80#define CE_UNDERRUN 3 81#define CE_OVERRUN 4 82#define CE_OVERFLOW 5 83 int tx_pending; 84 int rx_pending; 85 unsigned long rintr; 86 unsigned long tintr; 87 ulong64 ibytes; 88 ulong64 obytes; 89 unsigned long ipkts; 90 unsigned long opkts; 91 unsigned long underrun; 92 unsigned long overrun; 93 unsigned long frame; 94 unsigned long crc; 95 96 unsigned short status; /* E1/G.703 line status bit mask */ 97#define ESTS_NOALARM 0x0001 /* no alarm present */ 98#define ESTS_FARLOF 0x0002 /* receiving far loss of framing */ 99#define ESTS_AIS 0x0008 /* receiving all ones */ 100#define ESTS_LOF 0x0020 /* loss of framing */ 101#define ESTS_LOS 0x0040 /* loss of signal */ 102#define ESTS_AIS16 0x0100 /* receiving all ones in timeslot 16 */ 103#define ESTS_FARLOMF 0x0200 /* receiving alarm in timeslot 16 */ 104#define ESTS_LOMF 0x0400 /* loss of multiframe sync */ 105#define ESTS_TSTREQ 0x0800 /* test code detected */ 106#define ESTS_TSTERR 0x1000 /* test error */ 107 108 unsigned long totsec; /* total seconds elapsed */ 109 unsigned long cursec; /* current seconds elapsed */ 110 unsigned long degsec; /* degraded seconds */ 111 unsigned long degerr; /* errors during degraded seconds */ 112 ce_gstat_t currnt; /* current 15-min interval data */ 113 ce_gstat_t total; /* total statistics data */ 114 ce_gstat_t interval [48]; /* 12 hour period data */ 115 116 unsigned int acc_status; 117 unsigned long config; 118 unsigned long baud; 119 unsigned long ts; 120 unsigned long ts_mask; 121 unsigned char dir; 122 unsigned char lloop; 123 unsigned char rloop; 124 unsigned char higain; 125 unsigned char phony; 126 unsigned char scrambler; 127 unsigned char unfram; 128 unsigned char monitor; 129 unsigned char crc4; 130 unsigned char use16; 131 unsigned char gsyn; /* G.703 clock mode */ 132#define GSYN_INT 0 /* internal transmit clock source */ 133#define GSYN_RCV 1 /* transmit clock source = receive */ 134#define GSYN_RCV0 2 /* tclk = rclk from channel 0 */ 135#define GSYN_RCV1 3 /* ...from channel 1 */ 136 unsigned long mtu; 137 void *sys; 138} ce_chan_t; 139 140#define CONFREQSZ 128 141typedef struct _ce_conf_req { 142 TAU32_UserRequest req[CONFREQSZ+10]; 143 TAU32_UserRequest *queue; 144 int pending; 145} ce_conf_req; 146 147typedef struct _ce_board_t { 148 TAU32_UserContext ddk; 149 ce_chan_t chan[NCHAN]; 150 int num; 151 int mux; 152#define TAU32_BASE_NAME "Tau-PCI-32" 153#define TAU32_LITE_NAME "Tau-PCI-32/Lite" 154#define TAU32_ADPCM_NAME "Tau-PCI-32/ADPCM" 155#define TAU32_UNKNOWN_NAME "Unknown Tau-PCI-32" 156 char name [32]; 157 ce_conf_req cr; 158 TAU32_CrossMatrix dxc; 159 unsigned long pmask; 160 void *sys; 161} ce_board_t; 162 163void ce_set_dtr (ce_chan_t *c, int on); 164void ce_set_rts (ce_chan_t *c, int on); 165int ce_get_cd (ce_chan_t *c); 166int ce_get_cts (ce_chan_t *c); 167int ce_get_dsr (ce_chan_t *c); 168 169int ce_transmit_space (ce_chan_t *c); 170int ce_send_packet (ce_chan_t *c, unsigned char *buf, int len, void *tag); 171void ce_start_chan (ce_chan_t *c, int tx, int rx, ce_buf_t *cb, unsigned long phys); 172void ce_stop_chan (ce_chan_t *c); 173void ce_register_transmit (ce_chan_t *c, void (*func) (ce_chan_t*, void*, int)); 174void ce_register_receive (ce_chan_t *c, void (*func) (ce_chan_t*, 175 unsigned char*, int)); 176void ce_register_error (ce_chan_t *c, void (*func) (ce_chan_t*, int)); 177 178void TAU32_CALLBACK_TYPE 179 ce_error_callback(TAU32_UserContext *pContext, int Item, 180 unsigned NotifyBits); 181void TAU32_CALLBACK_TYPE 182 ce_status_callback(TAU32_UserContext *pContext, int Item, 183 unsigned NotifyBits); 184 185void ce_set_baud (ce_chan_t *c, unsigned long baud); 186void ce_set_lloop (ce_chan_t *c, unsigned char on); 187void ce_set_rloop (ce_chan_t *c, unsigned char on); 188void ce_set_higain (ce_chan_t *c, unsigned char on); 189void ce_set_unfram (ce_chan_t *c, unsigned char on); 190void ce_set_ts (ce_chan_t *c, unsigned long ts); 191void ce_set_phony (ce_chan_t *c, unsigned char on); 192void ce_set_scrambler (ce_chan_t *c, unsigned char on); 193void ce_set_monitor (ce_chan_t *c, unsigned char on); 194void ce_set_use16 (ce_chan_t *c, unsigned char on); 195void ce_set_crc4 (ce_chan_t *c, unsigned char on); 196void ce_set_gsyn (ce_chan_t *c, int syn); 197#define CABLE_TP 11 198int ce_get_cable (ce_chan_t *c); 199void ce_set_dir (ce_chan_t *c, int dir); 200void ce_e1_timer (ce_chan_t *c); 201void ce_init_board (ce_board_t *b); 202