Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 1999 Digi International (www.digi.com) |
| 4 | * Gene Olson <gene at digi dot com> |
| 5 | * James Puzzo <jamesp at digi dot com> |
| 6 | * Scott Kilau <scottk at digi dot com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the |
| 15 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | /************************************************************************ |
| 21 | * Master include file for Linux Realport Driver. |
| 22 | ************************************************************************/ |
| 23 | |
| 24 | #ifndef __DRP_H |
| 25 | #define __DRP_H |
| 26 | |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/wait.h> |
| 29 | #include <linux/semaphore.h> |
| 30 | #include <linux/tty.h> |
| 31 | |
| 32 | |
| 33 | #include "digirp.h" |
| 34 | |
| 35 | /************************************************************************ |
| 36 | * Tuning parameters. |
| 37 | ************************************************************************/ |
| 38 | |
| 39 | #define CHAN_MAX 64 /* Max # ports per server */ |
| 40 | |
| 41 | #define SEQ_MAX 128 /* Max # transmit sequences (2^n) */ |
| 42 | #define SEQ_MASK (SEQ_MAX-1) /* Sequence buffer modulus mask */ |
| 43 | |
| 44 | #define TBUF_MAX 4096 /* Size of transmit buffer (2^n) */ |
| 45 | #define RBUF_MAX 4096 /* Size of receive buffer (2^n) */ |
| 46 | |
| 47 | #define TBUF_MASK (TBUF_MAX-1) /* Transmit buffer modulus mask */ |
| 48 | #define RBUF_MASK (RBUF_MAX-1) /* Receive buffer modulus mask */ |
| 49 | |
| 50 | #define TBUF_LOW 1000 /* Transmit low water mark */ |
| 51 | |
| 52 | #define UIO_BASE 1000 /* Base for write operations */ |
| 53 | #define UIO_MIN 2000 /* Minimum size application buffer */ |
| 54 | #define UIO_MAX 8100 /* Unix I/O buffer size */ |
| 55 | |
| 56 | #define MON_MAX 65536 /* Monitor buffer size (2^n) */ |
| 57 | #define MON_MASK (MON_MAX-1) /* Monitor wrap mask */ |
| 58 | |
| 59 | #define DPA_MAX 65536 /* DPA buffer size (2^n) */ |
| 60 | #define DPA_MASK (DPA_MAX-1) /* DPA wrap mask */ |
| 61 | #define DPA_HIGH_WATER 58000 /* Enforce flow control when |
| 62 | * over this amount |
| 63 | */ |
| 64 | |
| 65 | #define IDLE_MAX (20 * HZ) /* Max TCP link idle time */ |
| 66 | |
| 67 | #define MAX_DESC_LEN 100 /* Maximum length of stored PS |
| 68 | * description |
| 69 | */ |
| 70 | |
| 71 | #define WRITEBUFLEN ((4096) + 4) /* 4 extra for alignment play space */ |
| 72 | |
| 73 | #define VPDSIZE 512 |
| 74 | |
| 75 | /************************************************************************ |
| 76 | * Minor device decoding conventions. |
| 77 | ************************************************************************ |
| 78 | * |
| 79 | * For Linux, the net and mon devices are handled via "proc", so we |
| 80 | * only have to mux the "tty" devices. Since every PortServer will |
| 81 | * have an individual major number, the PortServer number does not |
| 82 | * need to be encoded, and in fact, does not need to exist. |
| 83 | * |
| 84 | */ |
| 85 | |
| 86 | /* |
| 87 | * Port device decoding conventions: |
| 88 | * |
| 89 | * Device 00 - 3f 64 dial-in modem devices. (tty) |
| 90 | * Device 40 - 7f 64 dial-out tty devices. (cu) |
| 91 | * Device 80 - bf 64 dial-out printer devices. |
| 92 | * |
| 93 | * IS_PRINT(dev) This is a printer device. |
| 94 | * |
| 95 | * OPEN_CATEGORY(dev) Specifies the device category. No two |
| 96 | * devices of different categories may be open |
| 97 | * at the same time. |
| 98 | * |
| 99 | * The following require the category returned by OPEN_CATEGORY(). |
| 100 | * |
| 101 | * OPEN_WAIT_AVAIL(cat) Waits on open until the device becomes |
| 102 | * available. Fails if NDELAY specified. |
| 103 | * |
| 104 | * OPEN_WAIT_CARRIER(cat) Waits on open if carrier is not present. |
| 105 | * Succeeds if NDELAY is given. |
| 106 | * |
| 107 | * OPEN_FORCES_CARRIER(cat) Carrier is forced high on open. |
| 108 | * |
| 109 | */ |
| 110 | |
| 111 | #define PORT_NUM(dev) ((dev) & 0x3f) |
| 112 | |
| 113 | #define OPEN_CATEGORY(dev) ((((dev) & 0x80) & 0x40)) |
| 114 | #define IS_PRINT(dev) (((dev) & 0xff) >= 0x80) |
| 115 | |
| 116 | #define OPEN_WAIT_AVAIL(cat) (((cat) & 0x40) == 0x000) |
| 117 | #define OPEN_WAIT_CARRIER(cat) (((cat) & 0x40) == 0x000) |
| 118 | #define OPEN_FORCES_CARRIER(cat) (((cat) & 0x40) != 0x000) |
| 119 | |
| 120 | |
| 121 | /************************************************************************ |
| 122 | * Modem signal defines for 16450/16550 compatible FEP. |
| 123 | * set in ch_mout, ch_mflow, ch_mlast etc |
| 124 | ************************************************************************/ |
| 125 | |
| 126 | /* TODO : Re-verify that these modem signal definitions are correct */ |
| 127 | |
| 128 | #define DM_DTR 0x01 |
| 129 | #define DM_RTS 0x02 |
| 130 | #define DM_RTS_TOGGLE 0x04 |
| 131 | |
| 132 | #define DM_OUT1 0x04 |
| 133 | #define DM_OUT2 0x08 |
| 134 | |
| 135 | #define DM_CTS 0x10 |
| 136 | #define DM_DSR 0x20 |
| 137 | #define DM_RI 0x40 |
| 138 | #define DM_CD 0x80 /* This is the DCD flag */ |
| 139 | |
| 140 | |
| 141 | /************************************************************************ |
| 142 | * Realport Event Flags. |
| 143 | ************************************************************************/ |
| 144 | |
| 145 | #define EV_OPU 0x0001 /* Ouput paused by client */ |
| 146 | #define EV_OPS 0x0002 /* Output paused by XOFF */ |
| 147 | #define EV_OPX 0x0004 /* Output paused by XXOFF */ |
| 148 | #define EV_OPH 0x0008 /* Output paused by MFLOW */ |
| 149 | #define EV_IPU 0x0010 /* Input paused by client */ |
| 150 | #define EV_IPS 0x0020 /* Input paused by hi/low water */ |
| 151 | #define EV_TXB 0x0040 /* Transmit break pending */ |
| 152 | #define EV_TXI 0x0080 /* Transmit immediate pending */ |
| 153 | #define EV_TXF 0x0100 /* Transmit flow control pending */ |
| 154 | #define EV_RXB 0x0200 /* Break received */ |
| 155 | |
| 156 | |
| 157 | /************************************************************************ |
| 158 | * Realport CFLAGS. |
| 159 | ************************************************************************/ |
| 160 | |
| 161 | #define CF_CS5 0x0000 /* 5 bit characters */ |
| 162 | #define CF_CS6 0x0010 /* 6 bit characters */ |
| 163 | #define CF_CS7 0x0020 /* 7 bit characters */ |
| 164 | #define CF_CS8 0x0030 /* 8 bit characters */ |
| 165 | #define CF_CSIZE 0x0030 /* Character size */ |
| 166 | #define CF_CSTOPB 0x0040 /* Two stop bits */ |
| 167 | #define CF_CREAD 0x0080 /* Enable receiver */ |
| 168 | #define CF_PARENB 0x0100 /* Enable parity */ |
| 169 | #define CF_PARODD 0x0200 /* Odd parity */ |
| 170 | #define CF_HUPCL 0x0400 /* Drop DTR on close */ |
| 171 | |
| 172 | |
| 173 | /************************************************************************ |
| 174 | * Realport XFLAGS. |
| 175 | ************************************************************************/ |
| 176 | |
| 177 | #define XF_XPAR 0x0001 /* Enable Mark/Space Parity */ |
| 178 | #define XF_XMODEM 0x0002 /* Enable in-band modem signalling */ |
| 179 | #define XF_XCASE 0x0004 /* Convert special characters */ |
| 180 | #define XF_XEDATA 0x0008 /* Error data in stream */ |
| 181 | #define XF_XTOSS 0x0010 /* Toss IXANY characters */ |
| 182 | #define XF_XIXON 0x0020 /* xxon/xxoff enable */ |
| 183 | |
| 184 | |
| 185 | /************************************************************************ |
| 186 | * Realport IFLAGS. |
| 187 | ************************************************************************/ |
| 188 | |
| 189 | #define IF_IGNBRK 0x0001 /* Ignore input break */ |
| 190 | #define IF_BRKINT 0x0002 /* Break interrupt */ |
| 191 | #define IF_IGNPAR 0x0004 /* Ignore error characters */ |
| 192 | #define IF_PARMRK 0x0008 /* Error chars marked with 0xff */ |
| 193 | #define IF_INPCK 0x0010 /* Input parity checking enabled */ |
| 194 | #define IF_ISTRIP 0x0020 /* Input chars masked with 0x7F */ |
| 195 | #define IF_IXON 0x0400 /* Output software flow control */ |
| 196 | #define IF_IXANY 0x0800 /* Restart output on any char */ |
| 197 | #define IF_IXOFF 0x1000 /* Input software flow control */ |
| 198 | #define IF_DOSMODE 0x8000 /* 16450-compatible errors */ |
| 199 | |
| 200 | |
| 201 | /************************************************************************ |
| 202 | * Realport OFLAGS. |
| 203 | ************************************************************************/ |
| 204 | |
| 205 | #define OF_OLCUC 0x0002 /* Map lower to upper case */ |
| 206 | #define OF_ONLCR 0x0004 /* Map NL to CR-NL */ |
| 207 | #define OF_OCRNL 0x0008 /* Map CR to NL */ |
| 208 | #define OF_ONOCR 0x0010 /* No CR output at column 0 */ |
| 209 | #define OF_ONLRET 0x0020 /* Assume NL does NL/CR */ |
| 210 | #define OF_TAB3 0x1800 /* Tabs expand to 8 spaces */ |
| 211 | #define OF_TABDLY 0x1800 /* Tab delay */ |
| 212 | |
| 213 | /************************************************************************ |
| 214 | * Unit flag definitions for un_flag. |
| 215 | ************************************************************************/ |
| 216 | |
| 217 | /* These are the DIGI unit flags */ |
| 218 | #define UN_EXCL 0x00010000 /* Exclusive open */ |
| 219 | #define UN_STICKY 0x00020000 /* TTY Settings are now sticky */ |
| 220 | #define UN_BUSY 0x00040000 /* Some work this channel */ |
| 221 | #define UN_PWAIT 0x00080000 /* Printer waiting for terminal */ |
| 222 | #define UN_TIME 0x00100000 /* Waiting on time */ |
| 223 | #define UN_EMPTY 0x00200000 /* Waiting output queue empty */ |
| 224 | #define UN_LOW 0x00400000 /* Waiting output low water */ |
| 225 | #define UN_DIGI_MASK 0x00FF0000 /* Waiting output low water */ |
| 226 | |
| 227 | /* |
| 228 | * Definitions for async_struct (and serial_struct) flags field |
| 229 | * |
| 230 | * these are the ASYNC flags copied from serial.h |
| 231 | * |
| 232 | */ |
| 233 | #define UN_HUP_NOTIFY 0x0001 /* Notify getty on hangups and |
| 234 | * closes on the callout port |
| 235 | */ |
| 236 | #define UN_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ |
| 237 | #define UN_SAK 0x0004 /* Secure Attention Key (Orange book) */ |
| 238 | #define UN_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ |
| 239 | |
| 240 | #define UN_SPD_MASK 0x0030 |
| 241 | #define UN_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ |
| 242 | #define UN_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ |
| 243 | #define UN_SPD_CUST 0x0030 /* Use user-specified divisor */ |
| 244 | |
| 245 | #define UN_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ |
| 246 | #define UN_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ |
| 247 | |
| 248 | #define UN_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ |
| 249 | #define UN_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ |
| 250 | #define UN_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ |
| 251 | |
| 252 | #define UN_FLAGS 0x0FFF /* Possible legal async flags */ |
| 253 | #define UN_USR_MASK 0x0430 /* Legal flags that non-privileged |
| 254 | * users can set or reset |
| 255 | */ |
| 256 | |
| 257 | #define UN_INITIALIZED 0x80000000 /* Serial port was initialized */ |
| 258 | #define UN_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */ |
| 259 | #define UN_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ |
| 260 | #define UN_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ |
| 261 | #define UN_CLOSING 0x08000000 /* Serial port is closing */ |
| 262 | #define UN_CTS_FLOW 0x04000000 /* Do CTS flow control */ |
| 263 | #define UN_CHECK_CD 0x02000000 /* i.e., CLOCAL */ |
| 264 | #define UN_SHARE_IRQ 0x01000000 /* for multifunction cards */ |
| 265 | |
| 266 | |
| 267 | /************************************************************************ |
| 268 | * Structure for terminal or printer unit. struct un_struct |
| 269 | * |
| 270 | * Note that in some places the code assumes the "tty_t" is placed |
| 271 | * first in the structure. |
| 272 | ************************************************************************/ |
| 273 | |
| 274 | struct un_struct { |
| 275 | struct tty_struct *un_tty; /* System TTY struct */ |
| 276 | struct ch_struct *un_ch; /* Associated channel */ |
| 277 | |
| 278 | ushort un_open_count; /* Successful open count */ |
| 279 | int un_flag; /* Unit flags */ |
| 280 | ushort un_tbusy; /* Busy transmit count */ |
| 281 | |
| 282 | wait_queue_head_t un_open_wait; |
| 283 | wait_queue_head_t un_close_wait; |
| 284 | ushort un_type; |
| 285 | struct device *un_sysfs; |
| 286 | }; |
| 287 | |
| 288 | |
| 289 | /************************************************************************ |
| 290 | * Channel State Numbers for ch_state. |
| 291 | ************************************************************************/ |
| 292 | |
| 293 | /* |
| 294 | * The ordering is important. |
| 295 | * |
| 296 | * state <= CS_WAIT_CANCEL implies the channel is definitely closed. |
| 297 | * |
| 298 | * state >= CS_WAIT_FAIL implies the channel is definitely open. |
| 299 | * |
| 300 | * state >= CS_READY implies data is allowed on the channel. |
| 301 | */ |
| 302 | |
| 303 | enum dgrp_ch_state_t { |
| 304 | CS_IDLE = 0, /* Channel is idle */ |
| 305 | CS_WAIT_OPEN = 1, /* Waiting for Immediate Open Resp */ |
| 306 | CS_WAIT_CANCEL = 2, /* Waiting for Per/Incom Cancel Resp */ |
| 307 | CS_WAIT_FAIL = 3, /* Waiting for Immed Open Failure */ |
| 308 | CS_SEND_QUERY = 4, /* Ready to send Port Query */ |
| 309 | CS_WAIT_QUERY = 5, /* Waiting for Port Query Response */ |
| 310 | CS_READY = 6, /* Ready to accept commands and data */ |
| 311 | CS_SEND_CLOSE = 7, /* Ready to send Close Request */ |
| 312 | CS_WAIT_CLOSE = 8 /* Waiting for Close Response */ |
| 313 | }; |
| 314 | |
| 315 | /************************************************************************ |
| 316 | * Device flag definitions for ch_flag. |
| 317 | ************************************************************************/ |
| 318 | |
| 319 | /* |
| 320 | * Note that the state of the two carrier based flags is key. When |
| 321 | * we check for carrier state transitions, we look at the current |
| 322 | * physical state of the DCD line and compare it with PHYS_CD (which |
| 323 | * was the state the last time we checked), and we also determine |
| 324 | * a new virtual state (composite of the physical state, FORCEDCD, |
| 325 | * CLOCAL, etc.) and compare it with VIRT_CD. |
| 326 | * |
| 327 | * VIRTUAL transitions high will have the side effect of waking blocked |
| 328 | * opens. |
| 329 | * |
| 330 | * PHYSICAL transitions low will cause hangups to occur _IF_ the virtual |
| 331 | * state is also low. We DON'T want to hangup on a PURE virtual drop. |
| 332 | */ |
| 333 | |
| 334 | #define CH_HANGUP 0x00002 /* Server port ready to close */ |
| 335 | |
| 336 | #define CH_VIRT_CD 0x00004 /* Carrier was virtually present */ |
| 337 | #define CH_PHYS_CD 0x00008 /* Carrier was physically present */ |
| 338 | |
| 339 | #define CH_CLOCAL 0x00010 /* CLOCAL set in cflags */ |
| 340 | #define CH_BAUD0 0x00020 /* Baud rate zero hangup */ |
| 341 | |
| 342 | #define CH_FAST_READ 0x00040 /* Fast reads are enabled */ |
| 343 | #define CH_FAST_WRITE 0x00080 /* Fast writes are enabled */ |
| 344 | |
| 345 | #define CH_PRON 0x00100 /* Printer on string active */ |
| 346 | #define CH_RX_FLUSH 0x00200 /* Flushing receive data */ |
| 347 | #define CH_LOW 0x00400 /* Thread waiting for LOW water */ |
| 348 | #define CH_EMPTY 0x00800 /* Thread waiting for EMPTY */ |
| 349 | #define CH_DRAIN 0x01000 /* Close is waiting to drain */ |
| 350 | #define CH_INPUT 0x02000 /* Thread waiting for INPUT */ |
| 351 | #define CH_RXSTOP 0x04000 /* Stop output to ldisc */ |
| 352 | #define CH_PARAM 0x08000 /* A parameter was updated */ |
| 353 | #define CH_WAITING_SYNC 0x10000 /* A pending sync was assigned |
| 354 | * to this port. |
| 355 | */ |
| 356 | #define CH_PORT_GONE 0x20000 /* Port has disappeared */ |
| 357 | #define CH_TX_BREAK 0x40000 /* TX Break to be sent, |
| 358 | * but has not yet. |
| 359 | */ |
| 360 | |
| 361 | /************************************************************************ |
| 362 | * Types of Open Requests for ch_otype. |
| 363 | ************************************************************************/ |
| 364 | |
| 365 | #define OTYPE_IMMEDIATE 0 /* Immediate Open */ |
| 366 | #define OTYPE_PERSISTENT 1 /* Persistent Open */ |
| 367 | #define OTYPE_INCOMING 2 /* Incoming Open */ |
| 368 | |
| 369 | |
| 370 | /************************************************************************ |
| 371 | * Request/Response flags. |
| 372 | ************************************************************************/ |
| 373 | |
| 374 | #define RR_SEQUENCE 0x0001 /* Get server RLAST, TIN */ |
| 375 | #define RR_STATUS 0x0002 /* Get server MINT, EINT */ |
| 376 | #define RR_BUFFER 0x0004 /* Get server RSIZE, TSIZE */ |
| 377 | #define RR_CAPABILITY 0x0008 /* Get server port capabilities */ |
| 378 | |
| 379 | #define RR_TX_FLUSH 0x0040 /* Flush output buffers */ |
| 380 | #define RR_RX_FLUSH 0x0080 /* Flush input buffers */ |
| 381 | |
| 382 | #define RR_TX_STOP 0x0100 /* Pause output */ |
| 383 | #define RR_RX_STOP 0x0200 /* Pause input */ |
| 384 | #define RR_TX_START 0x0400 /* Start output */ |
| 385 | #define RR_RX_START 0x0800 /* Start input */ |
| 386 | |
| 387 | #define RR_TX_BREAK 0x1000 /* Send BREAK */ |
| 388 | #define RR_TX_ICHAR 0x2000 /* Send character immediate */ |
| 389 | |
| 390 | |
| 391 | /************************************************************************ |
| 392 | * Channel information structure. struct ch_struct |
| 393 | ************************************************************************/ |
| 394 | |
| 395 | struct ch_struct { |
| 396 | struct digi_struct ch_digi; /* Digi variables */ |
| 397 | int ch_edelay; /* Digi edelay */ |
| 398 | |
| 399 | struct tty_port port; |
| 400 | struct un_struct ch_tun; /* Terminal unit info */ |
| 401 | struct un_struct ch_pun; /* Printer unit info */ |
| 402 | |
| 403 | struct nd_struct *ch_nd; /* Node pointer */ |
| 404 | u8 *ch_tbuf; /* Local Transmit Buffer */ |
| 405 | u8 *ch_rbuf; /* Local Receive Buffer */ |
| 406 | ulong ch_cpstime; /* Printer CPS time */ |
| 407 | ulong ch_waketime; /* Printer wake time */ |
| 408 | |
| 409 | ulong ch_flag; /* CH_* flags */ |
| 410 | |
| 411 | enum dgrp_ch_state_t ch_state; /* CS_* Protocol state */ |
| 412 | ushort ch_send; /* Bit vector of RR_* requests */ |
| 413 | ushort ch_expect; /* Bit vector of RR_* responses */ |
| 414 | ushort ch_wait_carrier; /* Thread count waiting for carrier */ |
| 415 | ushort ch_wait_count[3]; /* Thread count waiting by otype */ |
| 416 | |
| 417 | ushort ch_portnum; /* Port number */ |
| 418 | ushort ch_open_count; /* Successful open count */ |
| 419 | ushort ch_category; /* Device category */ |
| 420 | ushort ch_open_error; /* Last open error number */ |
| 421 | ushort ch_break_time; /* Pending break request time */ |
| 422 | ushort ch_cpsrem; /* Printer CPS remainder */ |
| 423 | ushort ch_ocook; /* Realport fastcook oflags */ |
| 424 | ushort ch_inwait; /* Thread count in CLIST input */ |
| 425 | |
| 426 | ushort ch_tin; /* Local transmit buffer in ptr */ |
| 427 | ushort ch_tout; /* Local transmit buffer out ptr */ |
| 428 | ushort ch_s_tin; /* Realport TIN */ |
| 429 | ushort ch_s_tpos; /* Realport TPOS */ |
| 430 | ushort ch_s_tsize; /* Realport TSIZE */ |
| 431 | ushort ch_s_treq; /* Realport TREQ */ |
| 432 | ushort ch_s_elast; /* Realport ELAST */ |
| 433 | |
| 434 | ushort ch_rin; /* Local receive buffer in ptr */ |
| 435 | ushort ch_rout; /* Local receive buffer out ptr */ |
| 436 | ushort ch_s_rin; /* Realport RIN */ |
| 437 | /* David Fries 7-13-2001, ch_s_rin should be renamed ch_s_rout because |
| 438 | * the variable we want to represent is the PortServer's ROUT, which is |
| 439 | * the sequence number for the next byte the PortServer will send us. |
| 440 | * RIN is the sequence number for the next byte the PortServer will |
| 441 | * receive from the uart. The port server will send data as long as |
| 442 | * ROUT is less than RWIN. What would happen is the port is opened, it |
| 443 | * receives data, it gives the value of RIN, we set the RWIN to |
| 444 | * RIN+RBUF_MAX-1, it sends us RWIN-ROUT bytes which overflows. ROUT |
| 445 | * is set to zero when the port is opened, so we start at zero and |
| 446 | * count up as data is received. |
| 447 | */ |
| 448 | ushort ch_s_rwin; /* Realport RWIN */ |
| 449 | ushort ch_s_rsize; /* Realport RSIZE */ |
| 450 | |
| 451 | ushort ch_tmax; /* Local TMAX */ |
| 452 | ushort ch_ttime; /* Local TTIME */ |
| 453 | ushort ch_rmax; /* Local RMAX */ |
| 454 | ushort ch_rtime; /* Local RTIME */ |
| 455 | ushort ch_rlow; /* Local RLOW */ |
| 456 | ushort ch_rhigh; /* Local RHIGH */ |
| 457 | |
| 458 | ushort ch_s_tmax; /* Realport TMAX */ |
| 459 | ushort ch_s_ttime; /* Realport TTIME */ |
| 460 | ushort ch_s_rmax; /* Realport RMAX */ |
| 461 | ushort ch_s_rtime; /* Realport RTIME */ |
| 462 | ushort ch_s_rlow; /* Realport RLOW */ |
| 463 | ushort ch_s_rhigh; /* Realport RHIGH */ |
| 464 | |
| 465 | ushort ch_brate; /* Local baud rate */ |
| 466 | ushort ch_cflag; /* Local tty cflags */ |
| 467 | ushort ch_iflag; /* Local tty iflags */ |
| 468 | ushort ch_oflag; /* Local tty oflags */ |
| 469 | ushort ch_xflag; /* Local tty xflags */ |
| 470 | |
| 471 | ushort ch_s_brate; /* Realport BRATE */ |
| 472 | ushort ch_s_cflag; /* Realport CFLAG */ |
| 473 | ushort ch_s_iflag; /* Realport IFLAG */ |
| 474 | ushort ch_s_oflag; /* Realport OFLAG */ |
| 475 | ushort ch_s_xflag; /* Realport XFLAG */ |
| 476 | |
| 477 | u8 ch_otype; /* Open request type */ |
| 478 | u8 ch_pscan_savechar; /* Last character read by parity scan */ |
| 479 | u8 ch_pscan_state; /* PScan State based on last 2 chars */ |
| 480 | u8 ch_otype_waiting; /* Type of open pending in server */ |
| 481 | u8 ch_flush_seq; /* Receive flush end sequence */ |
| 482 | u8 ch_s_mlast; /* Realport MLAST */ |
| 483 | |
| 484 | u8 ch_mout; /* Local MOUT */ |
| 485 | u8 ch_mflow; /* Local MFLOW */ |
| 486 | u8 ch_mctrl; /* Local MCTRL */ |
| 487 | u8 ch_xon; /* Local XON */ |
| 488 | u8 ch_xoff; /* Local XOFF */ |
| 489 | u8 ch_lnext; /* Local LNEXT */ |
| 490 | u8 ch_xxon; /* Local XXON */ |
| 491 | u8 ch_xxoff; /* Local XXOFF */ |
| 492 | |
| 493 | u8 ch_s_mout; /* Realport MOUT */ |
| 494 | u8 ch_s_mflow; /* Realport MFLOW */ |
| 495 | u8 ch_s_mctrl; /* Realport MCTRL */ |
| 496 | u8 ch_s_xon; /* Realport XON */ |
| 497 | u8 ch_s_xoff; /* Realport XOFF */ |
| 498 | u8 ch_s_lnext; /* Realport LNEXT */ |
| 499 | u8 ch_s_xxon; /* Realport XXON */ |
| 500 | u8 ch_s_xxoff; /* Realport XXOFF */ |
| 501 | |
| 502 | wait_queue_head_t ch_flag_wait; /* Wait queue for ch_flag changes */ |
| 503 | wait_queue_head_t ch_sleep; /* Wait queue for my_sleep() */ |
| 504 | |
| 505 | int ch_custom_speed; /* Realport custom speed */ |
| 506 | int ch_txcount; /* Running TX count */ |
| 507 | int ch_rxcount; /* Running RX count */ |
| 508 | }; |
| 509 | |
| 510 | |
| 511 | /************************************************************************ |
| 512 | * Node State definitions. |
| 513 | ************************************************************************/ |
| 514 | |
| 515 | enum dgrp_nd_state_t { |
| 516 | NS_CLOSED = 0, /* Network device is closed */ |
| 517 | NS_IDLE = 1, /* Network connection inactive */ |
| 518 | NS_SEND_QUERY = 2, /* Send server query */ |
| 519 | NS_WAIT_QUERY = 3, /* Wait for query response */ |
| 520 | NS_READY = 4, /* Network ready */ |
| 521 | NS_SEND_ERROR = 5 /* Must send error hangup */ |
| 522 | }; |
| 523 | |
| 524 | #define ND_STATE_STR(x) \ |
| 525 | ((x) == NS_CLOSED ? "CLOSED" : \ |
| 526 | ((x) == NS_IDLE ? "IDLE" : \ |
| 527 | ((x) == NS_SEND_QUERY ? "SEND_QUERY" : \ |
| 528 | ((x) == NS_WAIT_QUERY ? "WAIT_QUERY" : \ |
| 529 | ((x) == NS_READY ? "READY" : \ |
| 530 | ((x) == NS_SEND_ERROR ? "SEND_ERROR" : "UNKNOWN")))))) |
| 531 | |
| 532 | /************************************************************************ |
| 533 | * Node Flag definitions. |
| 534 | ************************************************************************/ |
| 535 | |
| 536 | #define ND_SELECT 0x0001 /* Multiple net read selects */ |
| 537 | #define ND_DEB_WAIT 0x0002 /* Debug Device waiting */ |
| 538 | |
| 539 | |
| 540 | /************************************************************************ |
| 541 | * Monitoring flag definitions. |
| 542 | ************************************************************************/ |
| 543 | |
| 544 | #define MON_WAIT_DATA 0x0001 /* Waiting for buffer data */ |
| 545 | #define MON_WAIT_SPACE 0x0002 /* Waiting for buffer space */ |
| 546 | |
| 547 | /************************************************************************ |
| 548 | * DPA flag definitions. |
| 549 | ************************************************************************/ |
| 550 | |
| 551 | #define DPA_WAIT_DATA 0x0001 /* Waiting for buffer data */ |
| 552 | #define DPA_WAIT_SPACE 0x0002 /* Waiting for buffer space */ |
| 553 | |
| 554 | |
| 555 | /************************************************************************ |
| 556 | * Definitions taken from Realport Dump. |
| 557 | ************************************************************************/ |
| 558 | |
| 559 | #define RPDUMP_MAGIC "Digi-RealPort-1.0" |
| 560 | |
| 561 | #define RPDUMP_MESSAGE 0xE2 /* Descriptive message */ |
| 562 | #define RPDUMP_RESET 0xE7 /* Connection reset */ |
| 563 | #define RPDUMP_CLIENT 0xE8 /* Client data */ |
| 564 | #define RPDUMP_SERVER 0xE9 /* Server data */ |
| 565 | |
| 566 | |
| 567 | /************************************************************************ |
| 568 | * Node request/response definitions. |
| 569 | ************************************************************************/ |
| 570 | |
| 571 | #define NR_ECHO 0x0001 /* Server echo packet */ |
| 572 | #define NR_IDENT 0x0002 /* Server Product ID */ |
| 573 | #define NR_CAPABILITY 0x0004 /* Server Capabilties */ |
| 574 | #define NR_VPD 0x0008 /* Server VPD, if any */ |
| 575 | #define NR_PASSWORD 0x0010 /* Server Password */ |
| 576 | |
| 577 | /************************************************************************ |
| 578 | * Registration status of the node's Linux struct tty_driver structures. |
| 579 | ************************************************************************/ |
| 580 | #define SERIAL_TTDRV_REG 0x0001 /* nd_serial_ttdriver registered */ |
| 581 | #define CALLOUT_TTDRV_REG 0x0002 /* nd_callout_ttdriver registered */ |
| 582 | #define XPRINT_TTDRV_REG 0x0004 /* nd_xprint_ttdriver registered */ |
| 583 | |
| 584 | |
| 585 | /************************************************************************ |
| 586 | * Node structure. There exists one of these for each associated |
| 587 | * realport server. |
| 588 | ************************************************************************/ |
| 589 | |
| 590 | struct nd_struct { |
| 591 | struct list_head list; |
| 592 | long nd_major; /* Node's major number */ |
| 593 | long nd_ID; /* Node's ID code */ |
| 594 | |
| 595 | char nd_serial_name[50]; /* "tty_dgrp_<id>_" + null */ |
| 596 | char nd_callout_name[50]; /* "cu_dgrp_<id>_" + null */ |
| 597 | char nd_xprint_name[50]; /* "pr_dgrp_<id>_" + null */ |
| 598 | |
| 599 | char password[16]; /* Password for server, if needed */ |
| 600 | int nd_tty_ref_cnt; /* Linux tty reference count */ |
| 601 | |
| 602 | struct proc_dir_entry *nd_net_de; /* Dir entry for /proc/dgrp/net */ |
| 603 | struct proc_dir_entry *nd_mon_de; /* Dir entry for /proc/dgrp/mon */ |
| 604 | struct proc_dir_entry *nd_ports_de; /* Dir entry for /proc/dgrp/ports*/ |
| 605 | struct proc_dir_entry *nd_dpa_de; /* Dir entry for /proc/dgrp/dpa */ |
| 606 | |
| 607 | spinlock_t nd_lock; /* General node lock */ |
| 608 | |
| 609 | struct semaphore nd_net_semaphore; /* Net read/write lock */ |
| 610 | struct semaphore nd_mon_semaphore; /* Monitor buffer lock */ |
| 611 | spinlock_t nd_dpa_lock; /* DPA buffer lock */ |
| 612 | |
| 613 | enum dgrp_nd_state_t nd_state; /* NS_* network state */ |
| 614 | int nd_chan_count; /* # active channels */ |
| 615 | int nd_flag; /* Node flags */ |
| 616 | int nd_send; /* Responses to send */ |
| 617 | int nd_expect; /* Responses we expect */ |
| 618 | |
| 619 | u8 *nd_iobuf; /* Network R/W Buffer */ |
| 620 | wait_queue_head_t nd_tx_waitq; /* Network select wait queue */ |
| 621 | |
| 622 | u8 *nd_inputbuf; /* Input Buffer */ |
| 623 | u8 *nd_inputflagbuf; /* Input Flags Buffer */ |
| 624 | |
| 625 | int nd_tx_deposit; /* Accumulated transmit deposits */ |
| 626 | int nd_tx_charge; /* Accumulated transmit charges */ |
| 627 | int nd_tx_credit; /* Current TX credit */ |
| 628 | int nd_tx_ready; /* Ready to transmit */ |
| 629 | int nd_tx_work; /* TX work waiting */ |
| 630 | ulong nd_tx_time; /* Last transmit time */ |
| 631 | ulong nd_poll_time; /* Next scheduled poll time */ |
| 632 | |
| 633 | int nd_delay; /* Current TX delay */ |
| 634 | int nd_rate; /* Current TX rate */ |
| 635 | struct link_struct nd_link; /* Link speed params. */ |
| 636 | |
| 637 | int nd_seq_in; /* TX seq in ptr */ |
| 638 | int nd_seq_out; /* TX seq out ptr */ |
| 639 | int nd_unack; /* Unacknowledged byte count */ |
| 640 | int nd_remain; /* Remaining receive bytes */ |
| 641 | int nd_tx_module; /* Current TX module # */ |
| 642 | int nd_rx_module; /* Current RX module # */ |
| 643 | char *nd_error; /* Protocol error message */ |
| 644 | |
| 645 | int nd_write_count; /* drp_write() call count */ |
| 646 | int nd_read_count; /* drp_read() count */ |
| 647 | int nd_send_count; /* TCP message sent */ |
| 648 | int nd_tx_byte; /* Transmit byte count */ |
| 649 | int nd_rx_byte; /* Receive byte count */ |
| 650 | |
| 651 | ulong nd_mon_lbolt; /* Monitor start time */ |
| 652 | int nd_mon_flag; /* Monitor flags */ |
| 653 | int nd_mon_in; /* Monitor in pointer */ |
| 654 | int nd_mon_out; /* Monitor out pointer */ |
| 655 | wait_queue_head_t nd_mon_wqueue; /* Monitor wait queue (on flags) */ |
| 656 | u8 *nd_mon_buf; /* Monitor buffer */ |
| 657 | |
| 658 | ulong nd_dpa_lbolt; /* DPA start time */ |
| 659 | int nd_dpa_flag; /* DPA flags */ |
| 660 | int nd_dpa_in; /* DPA in pointer */ |
| 661 | int nd_dpa_out; /* DPA out pointer */ |
| 662 | wait_queue_head_t nd_dpa_wqueue; /* DPA wait queue (on flags) */ |
| 663 | u8 *nd_dpa_buf; /* DPA buffer */ |
| 664 | |
| 665 | uint nd_dpa_debug; |
| 666 | uint nd_dpa_port; |
| 667 | |
| 668 | wait_queue_head_t nd_seq_wque[SEQ_MAX]; /* TX thread wait queues */ |
| 669 | u8 nd_seq_wait[SEQ_MAX]; /* Transmit thread wait count */ |
| 670 | |
| 671 | ushort nd_seq_size[SEQ_MAX]; /* Transmit seq packet size */ |
| 672 | ulong nd_seq_time[SEQ_MAX]; /* Transmit seq packet time */ |
| 673 | |
| 674 | ushort nd_hw_ver; /* HW version returned from PS */ |
| 675 | ushort nd_sw_ver; /* SW version returned from PS */ |
| 676 | uint nd_hw_id; /* HW ID returned from PS */ |
| 677 | u8 nd_ps_desc[MAX_DESC_LEN+1]; /* Description from PS */ |
| 678 | uint nd_vpd_len; /* VPD len, if any */ |
| 679 | u8 nd_vpd[VPDSIZE]; /* VPD, if any */ |
| 680 | |
| 681 | ulong nd_ttdriver_flags; /* Registration status */ |
| 682 | struct tty_driver *nd_serial_ttdriver; /* Linux TTYDRIVER structure */ |
| 683 | struct tty_driver *nd_callout_ttdriver; /* Linux TTYDRIVER structure */ |
| 684 | struct tty_driver *nd_xprint_ttdriver; /* Linux TTYDRIVER structure */ |
| 685 | |
| 686 | u8 *nd_writebuf; /* Used to cache data read |
| 687 | * from user |
| 688 | */ |
| 689 | struct ch_struct nd_chan[CHAN_MAX]; /* Channel array */ |
| 690 | struct device *nd_class_dev; /* Hang our sysfs stuff off of here */ |
| 691 | }; |
| 692 | |
| 693 | #endif /* __DRP_H */ |