1 /* 2 * General definitions for the COMX driver 3 * 4 * Original authors: Arpad Bakay <bakay.arpad@synergon.hu>, 5 * Peter Bajan <bajan.peter@synergon.hu>, 6 * Previous maintainer: Tivadar Szemethy <tiv@itc.hu> 7 * Currently maintained by: Gergely Madarasz <gorgo@itc.hu> 8 * 9 * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu> 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 14 * 2 of the License, or (at your option) any later version. 15 * 16 * 17 * net_device_stats: 18 * rx_length_errors rec_len < 4 || rec_len > 2000 19 * rx_over_errors receive overrun (OVR) 20 * rx_crc_errors rx crc error 21 * rx_frame_errors aborts rec'd (ABO) 22 * rx_fifo_errors status fifo overrun (PBUFOVR) 23 * rx_missed_errors receive buffer overrun (BUFOVR) 24 * tx_aborted_errors ? 25 * tx_carrier_errors modem line status changes 26 * tx_fifo_errors tx underrun (locomx) 27 */ 28 #include <linux/config.h> 29 30 struct comx_protocol { 31 char *name; 32 char *version; 33 unsigned short encap_type; 34 int (*line_init)(struct net_device *dev); 35 int (*line_exit)(struct net_device *dev); 36 struct comx_protocol *next; 37 }; 38 39 struct comx_hardware { 40 char *name; 41 char *version; 42 int (*hw_init)(struct net_device *dev); 43 int (*hw_exit)(struct net_device *dev); 44 int (*hw_dump)(struct net_device *dev); 45 struct comx_hardware *next; 46 }; 47 48 struct comx_channel { 49 void *if_ptr; // General purpose pointer 50 struct net_device *dev; // Where we belong to 51 struct net_device *twin; // On dual-port cards 52 struct proc_dir_entry *procdir; // the directory 53 54 unsigned char init_status; 55 unsigned char line_status; 56 57 struct timer_list lineup_timer; // against line jitter 58 long int lineup_pending; 59 unsigned char lineup_delay; 60 61 #if 0 62 struct timer_list reset_timer; // for board resetting 63 long reset_pending; 64 int reset_timeout; 65 #endif 66 67 struct net_device_stats stats; 68 struct net_device_stats *current_stats; 69 #if 0 70 unsigned long board_resets; 71 #endif 72 unsigned long *avg_bytes; 73 int loadavg_counter, loadavg_size; 74 int loadavg[3]; 75 struct timer_list loadavg_timer; 76 int debug_flags; 77 char *debug_area; 78 int debug_start, debug_end, debug_size; 79 struct proc_dir_entry *debug_file; 80 #ifdef CONFIG_COMX_DEBUG_RAW 81 char *raw; 82 int raw_len; 83 #endif 84 // LINE specific 85 struct comx_protocol *protocol; 86 void (*LINE_rx)(struct net_device *dev, struct sk_buff *skb); 87 int (*LINE_tx)(struct net_device *dev); 88 void (*LINE_status)(struct net_device *dev, u_short status); 89 int (*LINE_open)(struct net_device *dev); 90 int (*LINE_close)(struct net_device *dev); 91 int (*LINE_xmit)(struct sk_buff *skb, struct net_device *dev); 92 int (*LINE_header)(struct sk_buff *skb, struct net_device *dev, 93 u_short type,void *daddr, void *saddr, 94 unsigned len); 95 int (*LINE_rebuild_header)(struct sk_buff *skb); 96 int (*LINE_statistics)(struct net_device *dev, char *page); 97 int (*LINE_parameter_check)(struct net_device *dev); 98 int (*LINE_ioctl)(struct net_device *dev, struct ifreq *ifr, 99 int cmd); 100 void (*LINE_mod_use)(int); 101 void * LINE_privdata; 102 103 // HW specific 104 105 struct comx_hardware *hardware; 106 void (*HW_board_on)(struct net_device *dev); 107 void (*HW_board_off)(struct net_device *dev); 108 struct net_device *(*HW_access_board)(struct net_device *dev); 109 void (*HW_release_board)(struct net_device *dev, struct net_device *savep); 110 int (*HW_txe)(struct net_device *dev); 111 int (*HW_open)(struct net_device *dev); 112 int (*HW_close)(struct net_device *dev); 113 int (*HW_send_packet)(struct net_device *dev,struct sk_buff *skb); 114 int (*HW_statistics)(struct net_device *dev, char *page); 115 #if 0 116 int (*HW_reset)(struct net_device *dev, char *page); 117 #endif 118 int (*HW_load_board)(struct net_device *dev); 119 void (*HW_set_clock)(struct net_device *dev); 120 void *HW_privdata; 121 }; 122 123 struct comx_debugflags_struct { 124 char *name; 125 int value; 126 }; 127 128 #define COMX_ROOT_DIR_NAME "comx" 129 130 #define FILENAME_HARDWARE "boardtype" 131 #define FILENAME_HARDWARELIST "boardtypes" 132 #define FILENAME_PROTOCOL "protocol" 133 #define FILENAME_PROTOCOLLIST "protocols" 134 #define FILENAME_DEBUG "debug" 135 #define FILENAME_CLOCK "clock" 136 #define FILENAME_STATUS "status" 137 #define FILENAME_IO "io" 138 #define FILENAME_IRQ "irq" 139 #define FILENAME_KEEPALIVE "keepalive" 140 #define FILENAME_LINEUPDELAY "lineup_delay" 141 #define FILENAME_CHANNEL "channel" 142 #define FILENAME_FIRMWARE "firmware" 143 #define FILENAME_MEMADDR "memaddr" 144 #define FILENAME_TWIN "twin" 145 #define FILENAME_T1 "t1" 146 #define FILENAME_T2 "t2" 147 #define FILENAME_N2 "n2" 148 #define FILENAME_WINDOW "window" 149 #define FILENAME_MODE "mode" 150 #define FILENAME_DLCI "dlci" 151 #define FILENAME_MASTER "master" 152 #ifdef CONFIG_COMX_DEBUG_RAW 153 #define FILENAME_RAW "raw" 154 #endif 155 156 #define PROTONAME_NONE "none" 157 #define HWNAME_NONE "none" 158 #define KEEPALIVE_OFF "off" 159 160 #define FRAME_ACCEPTED 0 /* sending and xmitter busy */ 161 #define FRAME_DROPPED 1 162 #define FRAME_ERROR 2 /* xmitter error */ 163 #define FRAME_QUEUED 3 /* sending but more can come */ 164 165 #define LINE_UP 1 /* Modem UP */ 166 #define PROTO_UP 2 167 #define PROTO_LOOP 4 168 169 #define HW_OPEN 1 170 #define LINE_OPEN 2 171 #define FW_LOADED 4 172 #define IRQ_ALLOCATED 8 173 174 #define DEBUG_COMX_RX 2 175 #define DEBUG_COMX_TX 4 176 #define DEBUG_HW_TX 16 177 #define DEBUG_HW_RX 32 178 #define DEBUG_HDLC_KEEPALIVE 64 179 #define DEBUG_COMX_PPP 128 180 #define DEBUG_COMX_LAPB 256 181 #define DEBUG_COMX_DLCI 512 182 183 #define DEBUG_PAGESIZE 3072 184 #define DEFAULT_DEBUG_SIZE 4096 185 #define DEFAULT_LINEUP_DELAY 1 186 #define FILE_PAGESIZE 3072 187 188 #ifndef COMX_PPP_MAJOR 189 #define COMX_PPP_MAJOR 88 190 #endif 191 192 193 #define COMX_CHANNEL(dev) ((struct comx_channel*)dev->priv) 194 195 #define TWIN(dev) (COMX_CHANNEL(dev)->twin) 196 197 198 #ifndef byte 199 typedef u8 byte; 200 #endif 201 #ifndef word 202 typedef u16 word; 203 #endif 204 205 #ifndef SEEK_SET 206 #define SEEK_SET 0 207 #endif 208 #ifndef SEEK_CUR 209 #define SEEK_CUR 1 210 #endif 211 #ifndef SEEK_END 212 #define SEEK_END 2 213 #endif 214 215 extern int comx_register_hardware(struct comx_hardware *comx_hw); 216 extern int comx_unregister_hardware(char *name); 217 extern int comx_register_protocol(struct comx_protocol *comx_line); 218 extern int comx_unregister_protocol(char *name); 219 220 extern int comx_rx(struct net_device *dev, struct sk_buff *skb); 221 extern void comx_status(struct net_device *dev, int status); 222 extern void comx_lineup_func(unsigned long d); 223 224 extern int comx_debug(struct net_device *dev, char *fmt, ...); 225 extern int comx_debug_skb(struct net_device *dev, struct sk_buff *skb, char *msg); 226 extern int comx_debug_bytes(struct net_device *dev, unsigned char *bytes, int len, 227 char *msg); 228 extern int comx_strcasecmp(const char *cs, const char *ct); 229 230 extern struct inode_operations comx_normal_inode_ops; 231