diff options
Diffstat (limited to 'drivers/s390/net/ctcmain.h')
| -rw-r--r-- | drivers/s390/net/ctcmain.h | 276 |
1 files changed, 276 insertions, 0 deletions
diff --git a/drivers/s390/net/ctcmain.h b/drivers/s390/net/ctcmain.h new file mode 100644 index 000000000000..ba3605f16335 --- /dev/null +++ b/drivers/s390/net/ctcmain.h | |||
| @@ -0,0 +1,276 @@ | |||
| 1 | /* | ||
| 2 | * $Id: ctcmain.h,v 1.4 2005/03/24 09:04:17 mschwide Exp $ | ||
| 3 | * | ||
| 4 | * CTC / ESCON network driver | ||
| 5 | * | ||
| 6 | * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation | ||
| 7 | * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com) | ||
| 8 | Peter Tiedemann (ptiedem@de.ibm.com) | ||
| 9 | * | ||
| 10 | * | ||
| 11 | * Documentation used: | ||
| 12 | * - Principles of Operation (IBM doc#: SA22-7201-06) | ||
| 13 | * - Common IO/-Device Commands and Self Description (IBM doc#: SA22-7204-02) | ||
| 14 | * - Common IO/-Device Commands and Self Description (IBM doc#: SN22-5535) | ||
| 15 | * - ESCON Channel-to-Channel Adapter (IBM doc#: SA22-7203-00) | ||
| 16 | * - ESCON I/O Interface (IBM doc#: SA22-7202-029 | ||
| 17 | * | ||
| 18 | * This program is free software; you can redistribute it and/or modify | ||
| 19 | * it under the terms of the GNU General Public License as published by | ||
| 20 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 21 | * any later version. | ||
| 22 | * | ||
| 23 | * This program is distributed in the hope that it will be useful, | ||
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 26 | * GNU General Public License for more details. | ||
| 27 | * | ||
| 28 | * You should have received a copy of the GNU General Public License | ||
| 29 | * along with this program; if not, write to the Free Software | ||
| 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 31 | * | ||
| 32 | * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.4 $ | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | #ifndef _CTCMAIN_H_ | ||
| 37 | #define _CTCMAIN_H_ | ||
| 38 | |||
| 39 | #include <asm/ccwdev.h> | ||
| 40 | #include <asm/ccwgroup.h> | ||
| 41 | |||
| 42 | #include "ctctty.h" | ||
| 43 | #include "fsm.h" | ||
| 44 | #include "cu3088.h" | ||
| 45 | |||
| 46 | |||
| 47 | /** | ||
| 48 | * CCW commands, used in this driver. | ||
| 49 | */ | ||
| 50 | #define CCW_CMD_WRITE 0x01 | ||
| 51 | #define CCW_CMD_READ 0x02 | ||
| 52 | #define CCW_CMD_SET_EXTENDED 0xc3 | ||
| 53 | #define CCW_CMD_PREPARE 0xe3 | ||
| 54 | |||
| 55 | #define CTC_PROTO_S390 0 | ||
| 56 | #define CTC_PROTO_LINUX 1 | ||
| 57 | #define CTC_PROTO_LINUX_TTY 2 | ||
| 58 | #define CTC_PROTO_OS390 3 | ||
| 59 | #define CTC_PROTO_MAX 3 | ||
| 60 | |||
| 61 | #define CTC_BUFSIZE_LIMIT 65535 | ||
| 62 | #define CTC_BUFSIZE_DEFAULT 32768 | ||
| 63 | |||
| 64 | #define CTC_TIMEOUT_5SEC 5000 | ||
| 65 | |||
| 66 | #define CTC_INITIAL_BLOCKLEN 2 | ||
| 67 | |||
| 68 | #define READ 0 | ||
| 69 | #define WRITE 1 | ||
| 70 | |||
| 71 | #define CTC_ID_SIZE BUS_ID_SIZE+3 | ||
| 72 | |||
| 73 | |||
| 74 | struct ctc_profile { | ||
| 75 | unsigned long maxmulti; | ||
| 76 | unsigned long maxcqueue; | ||
| 77 | unsigned long doios_single; | ||
| 78 | unsigned long doios_multi; | ||
| 79 | unsigned long txlen; | ||
| 80 | unsigned long tx_time; | ||
| 81 | struct timespec send_stamp; | ||
| 82 | }; | ||
| 83 | |||
| 84 | /** | ||
| 85 | * Definition of one channel | ||
| 86 | */ | ||
| 87 | struct channel { | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Pointer to next channel in list. | ||
| 91 | */ | ||
| 92 | struct channel *next; | ||
| 93 | char id[CTC_ID_SIZE]; | ||
| 94 | struct ccw_device *cdev; | ||
| 95 | |||
| 96 | /** | ||
| 97 | * Type of this channel. | ||
| 98 | * CTC/A or Escon for valid channels. | ||
| 99 | */ | ||
| 100 | enum channel_types type; | ||
| 101 | |||
| 102 | /** | ||
| 103 | * Misc. flags. See CHANNEL_FLAGS_... below | ||
| 104 | */ | ||
| 105 | __u32 flags; | ||
| 106 | |||
| 107 | /** | ||
| 108 | * The protocol of this channel | ||
| 109 | */ | ||
| 110 | __u16 protocol; | ||
| 111 | |||
| 112 | /** | ||
| 113 | * I/O and irq related stuff | ||
| 114 | */ | ||
| 115 | struct ccw1 *ccw; | ||
| 116 | struct irb *irb; | ||
| 117 | |||
| 118 | /** | ||
| 119 | * RX/TX buffer size | ||
| 120 | */ | ||
| 121 | int max_bufsize; | ||
| 122 | |||
| 123 | /** | ||
| 124 | * Transmit/Receive buffer. | ||
| 125 | */ | ||
| 126 | struct sk_buff *trans_skb; | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Universal I/O queue. | ||
| 130 | */ | ||
| 131 | struct sk_buff_head io_queue; | ||
| 132 | |||
| 133 | /** | ||
| 134 | * TX queue for collecting skb's during busy. | ||
| 135 | */ | ||
| 136 | struct sk_buff_head collect_queue; | ||
| 137 | |||
| 138 | /** | ||
| 139 | * Amount of data in collect_queue. | ||
| 140 | */ | ||
| 141 | int collect_len; | ||
| 142 | |||
| 143 | /** | ||
| 144 | * spinlock for collect_queue and collect_len | ||
| 145 | */ | ||
| 146 | spinlock_t collect_lock; | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Timer for detecting unresposive | ||
| 150 | * I/O operations. | ||
| 151 | */ | ||
| 152 | fsm_timer timer; | ||
| 153 | |||
| 154 | /** | ||
| 155 | * Retry counter for misc. operations. | ||
| 156 | */ | ||
| 157 | int retry; | ||
| 158 | |||
| 159 | /** | ||
| 160 | * The finite state machine of this channel | ||
| 161 | */ | ||
| 162 | fsm_instance *fsm; | ||
| 163 | |||
| 164 | /** | ||
| 165 | * The corresponding net_device this channel | ||
| 166 | * belongs to. | ||
| 167 | */ | ||
| 168 | struct net_device *netdev; | ||
| 169 | |||
| 170 | struct ctc_profile prof; | ||
| 171 | |||
| 172 | unsigned char *trans_skb_data; | ||
| 173 | |||
| 174 | __u16 logflags; | ||
| 175 | }; | ||
| 176 | |||
| 177 | #define CHANNEL_FLAGS_READ 0 | ||
| 178 | #define CHANNEL_FLAGS_WRITE 1 | ||
| 179 | #define CHANNEL_FLAGS_INUSE 2 | ||
| 180 | #define CHANNEL_FLAGS_BUFSIZE_CHANGED 4 | ||
| 181 | #define CHANNEL_FLAGS_FAILED 8 | ||
| 182 | #define CHANNEL_FLAGS_WAITIRQ 16 | ||
| 183 | #define CHANNEL_FLAGS_RWMASK 1 | ||
| 184 | #define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK) | ||
| 185 | |||
| 186 | #define LOG_FLAG_ILLEGALPKT 1 | ||
| 187 | #define LOG_FLAG_ILLEGALSIZE 2 | ||
| 188 | #define LOG_FLAG_OVERRUN 4 | ||
| 189 | #define LOG_FLAG_NOMEM 8 | ||
| 190 | |||
| 191 | #define CTC_LOGLEVEL_INFO 1 | ||
| 192 | #define CTC_LOGLEVEL_NOTICE 2 | ||
| 193 | #define CTC_LOGLEVEL_WARN 4 | ||
| 194 | #define CTC_LOGLEVEL_EMERG 8 | ||
| 195 | #define CTC_LOGLEVEL_ERR 16 | ||
| 196 | #define CTC_LOGLEVEL_DEBUG 32 | ||
| 197 | #define CTC_LOGLEVEL_CRIT 64 | ||
| 198 | |||
| 199 | #define CTC_LOGLEVEL_DEFAULT \ | ||
| 200 | (CTC_LOGLEVEL_INFO | CTC_LOGLEVEL_NOTICE | CTC_LOGLEVEL_WARN | CTC_LOGLEVEL_CRIT) | ||
| 201 | |||
| 202 | #define CTC_LOGLEVEL_MAX ((CTC_LOGLEVEL_CRIT<<1)-1) | ||
| 203 | |||
| 204 | #define ctc_pr_debug(fmt, arg...) \ | ||
| 205 | do { if (loglevel & CTC_LOGLEVEL_DEBUG) printk(KERN_DEBUG fmt,##arg); } while (0) | ||
| 206 | |||
| 207 | #define ctc_pr_info(fmt, arg...) \ | ||
| 208 | do { if (loglevel & CTC_LOGLEVEL_INFO) printk(KERN_INFO fmt,##arg); } while (0) | ||
| 209 | |||
| 210 | #define ctc_pr_notice(fmt, arg...) \ | ||
| 211 | do { if (loglevel & CTC_LOGLEVEL_NOTICE) printk(KERN_NOTICE fmt,##arg); } while (0) | ||
| 212 | |||
| 213 | #define ctc_pr_warn(fmt, arg...) \ | ||
| 214 | do { if (loglevel & CTC_LOGLEVEL_WARN) printk(KERN_WARNING fmt,##arg); } while (0) | ||
| 215 | |||
| 216 | #define ctc_pr_emerg(fmt, arg...) \ | ||
| 217 | do { if (loglevel & CTC_LOGLEVEL_EMERG) printk(KERN_EMERG fmt,##arg); } while (0) | ||
| 218 | |||
| 219 | #define ctc_pr_err(fmt, arg...) \ | ||
| 220 | do { if (loglevel & CTC_LOGLEVEL_ERR) printk(KERN_ERR fmt,##arg); } while (0) | ||
| 221 | |||
| 222 | #define ctc_pr_crit(fmt, arg...) \ | ||
| 223 | do { if (loglevel & CTC_LOGLEVEL_CRIT) printk(KERN_CRIT fmt,##arg); } while (0) | ||
| 224 | |||
| 225 | struct ctc_priv { | ||
| 226 | struct net_device_stats stats; | ||
| 227 | unsigned long tbusy; | ||
| 228 | /** | ||
| 229 | * The finite state machine of this interface. | ||
| 230 | */ | ||
| 231 | fsm_instance *fsm; | ||
| 232 | /** | ||
| 233 | * The protocol of this device | ||
| 234 | */ | ||
| 235 | __u16 protocol; | ||
| 236 | /** | ||
| 237 | * Timer for restarting after I/O Errors | ||
| 238 | */ | ||
| 239 | fsm_timer restart_timer; | ||
| 240 | |||
| 241 | int buffer_size; | ||
| 242 | |||
| 243 | struct channel *channel[2]; | ||
| 244 | }; | ||
| 245 | |||
| 246 | /** | ||
| 247 | * Definition of our link level header. | ||
| 248 | */ | ||
| 249 | struct ll_header { | ||
| 250 | __u16 length; | ||
| 251 | __u16 type; | ||
| 252 | __u16 unused; | ||
| 253 | }; | ||
| 254 | #define LL_HEADER_LENGTH (sizeof(struct ll_header)) | ||
| 255 | |||
| 256 | /** | ||
| 257 | * Compatibility macros for busy handling | ||
| 258 | * of network devices. | ||
| 259 | */ | ||
| 260 | static __inline__ void | ||
| 261 | ctc_clear_busy(struct net_device * dev) | ||
| 262 | { | ||
| 263 | clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy)); | ||
| 264 | if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) | ||
| 265 | netif_wake_queue(dev); | ||
| 266 | } | ||
| 267 | |||
| 268 | static __inline__ int | ||
| 269 | ctc_test_and_set_busy(struct net_device * dev) | ||
| 270 | { | ||
| 271 | if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) | ||
| 272 | netif_stop_queue(dev); | ||
| 273 | return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy); | ||
| 274 | } | ||
| 275 | |||
| 276 | #endif | ||
