[ARM] pxa: Gumstix Verdex PCMCIA support
[linux-2.6/verdex.git] / drivers / s390 / net / ctcm_main.h
blobd925e732b7d8f69fbf46785e2d4ee24cb3db8f34
1 /*
2 * drivers/s390/net/ctcm_main.h
4 * Copyright IBM Corp. 2001, 2007
5 * Authors: Fritz Elfert (felfert@millenux.com)
6 * Peter Tiedemann (ptiedem@de.ibm.com)
7 */
9 #ifndef _CTCM_MAIN_H_
10 #define _CTCM_MAIN_H_
12 #include <asm/ccwdev.h>
13 #include <asm/ccwgroup.h>
15 #include <linux/skbuff.h>
16 #include <linux/netdevice.h>
18 #include "fsm.h"
19 #include "cu3088.h"
20 #include "ctcm_dbug.h"
21 #include "ctcm_mpc.h"
23 #define CTC_DRIVER_NAME "ctcm"
24 #define CTC_DEVICE_NAME "ctc"
25 #define MPC_DEVICE_NAME "mpc"
26 #define CTC_DEVICE_GENE CTC_DEVICE_NAME "%d"
27 #define MPC_DEVICE_GENE MPC_DEVICE_NAME "%d"
29 #define CHANNEL_FLAGS_READ 0
30 #define CHANNEL_FLAGS_WRITE 1
31 #define CHANNEL_FLAGS_INUSE 2
32 #define CHANNEL_FLAGS_BUFSIZE_CHANGED 4
33 #define CHANNEL_FLAGS_FAILED 8
34 #define CHANNEL_FLAGS_WAITIRQ 16
35 #define CHANNEL_FLAGS_RWMASK 1
36 #define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
38 #define LOG_FLAG_ILLEGALPKT 1
39 #define LOG_FLAG_ILLEGALSIZE 2
40 #define LOG_FLAG_OVERRUN 4
41 #define LOG_FLAG_NOMEM 8
43 #define ctcm_pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
45 #define CTCM_PR_DEBUG(fmt, arg...) \
46 do { \
47 if (do_debug) \
48 printk(KERN_DEBUG fmt, ##arg); \
49 } while (0)
51 #define CTCM_PR_DBGDATA(fmt, arg...) \
52 do { \
53 if (do_debug_data) \
54 printk(KERN_DEBUG fmt, ##arg); \
55 } while (0)
57 #define CTCM_D3_DUMP(buf, len) \
58 do { \
59 if (do_debug_data) \
60 ctcmpc_dumpit(buf, len); \
61 } while (0)
63 #define CTCM_CCW_DUMP(buf, len) \
64 do { \
65 if (do_debug_ccw) \
66 ctcmpc_dumpit(buf, len); \
67 } while (0)
70 * CCW commands, used in this driver.
72 #define CCW_CMD_WRITE 0x01
73 #define CCW_CMD_READ 0x02
74 #define CCW_CMD_NOOP 0x03
75 #define CCW_CMD_TIC 0x08
76 #define CCW_CMD_SENSE_CMD 0x14
77 #define CCW_CMD_WRITE_CTL 0x17
78 #define CCW_CMD_SET_EXTENDED 0xc3
79 #define CCW_CMD_PREPARE 0xe3
81 #define CTCM_PROTO_S390 0
82 #define CTCM_PROTO_LINUX 1
83 #define CTCM_PROTO_LINUX_TTY 2
84 #define CTCM_PROTO_OS390 3
85 #define CTCM_PROTO_MPC 4
86 #define CTCM_PROTO_MAX 4
88 #define CTCM_BUFSIZE_LIMIT 65535
89 #define CTCM_BUFSIZE_DEFAULT 32768
90 #define MPC_BUFSIZE_DEFAULT CTCM_BUFSIZE_LIMIT
92 #define CTCM_TIME_1_SEC 1000
93 #define CTCM_TIME_5_SEC 5000
94 #define CTCM_TIME_10_SEC 10000
96 #define CTCM_INITIAL_BLOCKLEN 2
98 #define READ 0
99 #define WRITE 1
101 #define CTCM_ID_SIZE 20+3
103 struct ctcm_profile {
104 unsigned long maxmulti;
105 unsigned long maxcqueue;
106 unsigned long doios_single;
107 unsigned long doios_multi;
108 unsigned long txlen;
109 unsigned long tx_time;
110 struct timespec send_stamp;
114 * Definition of one channel
116 struct channel {
117 struct channel *next;
118 char id[CTCM_ID_SIZE];
119 struct ccw_device *cdev;
121 * Type of this channel.
122 * CTC/A or Escon for valid channels.
124 enum channel_types type;
126 * Misc. flags. See CHANNEL_FLAGS_... below
128 __u32 flags;
129 __u16 protocol; /* protocol of this channel (4 = MPC) */
131 * I/O and irq related stuff
133 struct ccw1 *ccw;
134 struct irb *irb;
136 * RX/TX buffer size
138 int max_bufsize;
139 struct sk_buff *trans_skb; /* transmit/receive buffer */
140 struct sk_buff_head io_queue; /* universal I/O queue */
141 struct tasklet_struct ch_tasklet; /* MPC ONLY */
143 * TX queue for collecting skb's during busy.
145 struct sk_buff_head collect_queue;
147 * Amount of data in collect_queue.
149 int collect_len;
151 * spinlock for collect_queue and collect_len
153 spinlock_t collect_lock;
155 * Timer for detecting unresposive
156 * I/O operations.
158 fsm_timer timer;
159 /* MPC ONLY section begin */
160 __u32 th_seq_num; /* SNA TH seq number */
161 __u8 th_seg;
162 __u32 pdu_seq;
163 struct sk_buff *xid_skb;
164 char *xid_skb_data;
165 struct th_header *xid_th;
166 struct xid2 *xid;
167 char *xid_id;
168 struct th_header *rcvd_xid_th;
169 struct xid2 *rcvd_xid;
170 char *rcvd_xid_id;
171 __u8 in_mpcgroup;
172 fsm_timer sweep_timer;
173 struct sk_buff_head sweep_queue;
174 struct th_header *discontact_th;
175 struct tasklet_struct ch_disc_tasklet;
176 /* MPC ONLY section end */
178 int retry; /* retry counter for misc. operations */
179 fsm_instance *fsm; /* finite state machine of this channel */
180 struct net_device *netdev; /* corresponding net_device */
181 struct ctcm_profile prof;
182 __u8 *trans_skb_data;
183 __u16 logflags;
184 __u8 sense_rc; /* last unit check sense code report control */
187 struct ctcm_priv {
188 struct net_device_stats stats;
189 unsigned long tbusy;
191 /* The MPC group struct of this interface */
192 struct mpc_group *mpcg; /* MPC only */
193 struct xid2 *xid; /* MPC only */
195 /* The finite state machine of this interface */
196 fsm_instance *fsm;
198 /* The protocol of this device */
199 __u16 protocol;
201 /* Timer for restarting after I/O Errors */
202 fsm_timer restart_timer;
204 int buffer_size; /* ctc only */
206 struct channel *channel[2];
209 int ctcm_open(struct net_device *dev);
210 int ctcm_close(struct net_device *dev);
213 * prototypes for non-static sysfs functions
215 int ctcm_add_attributes(struct device *dev);
216 void ctcm_remove_attributes(struct device *dev);
217 int ctcm_add_files(struct device *dev);
218 void ctcm_remove_files(struct device *dev);
221 * Compatibility macros for busy handling
222 * of network devices.
224 static inline void ctcm_clear_busy_do(struct net_device *dev)
226 clear_bit(0, &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
227 netif_wake_queue(dev);
230 static inline void ctcm_clear_busy(struct net_device *dev)
232 struct mpc_group *grp;
233 grp = ((struct ctcm_priv *)dev->ml_priv)->mpcg;
235 if (!(grp && grp->in_sweep))
236 ctcm_clear_busy_do(dev);
240 static inline int ctcm_test_and_set_busy(struct net_device *dev)
242 netif_stop_queue(dev);
243 return test_and_set_bit(0,
244 &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
247 extern int loglevel;
248 extern struct channel *channels;
250 void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb);
253 * Functions related to setup and device detection.
256 static inline int ctcm_less_than(char *id1, char *id2)
258 unsigned long dev1, dev2;
260 id1 = id1 + 5;
261 id2 = id2 + 5;
263 dev1 = simple_strtoul(id1, &id1, 16);
264 dev2 = simple_strtoul(id2, &id2, 16);
266 return (dev1 < dev2);
269 int ctcm_ch_alloc_buffer(struct channel *ch);
271 static inline int ctcm_checkalloc_buffer(struct channel *ch)
273 if (ch->trans_skb == NULL)
274 return ctcm_ch_alloc_buffer(ch);
275 if (ch->flags & CHANNEL_FLAGS_BUFSIZE_CHANGED) {
276 dev_kfree_skb(ch->trans_skb);
277 return ctcm_ch_alloc_buffer(ch);
279 return 0;
282 struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv);
284 /* test if protocol attribute (of struct ctcm_priv or struct channel)
285 * has MPC protocol setting. Type is not checked
287 #define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC)
289 /* test if struct ctcm_priv of struct net_device has MPC protocol setting */
290 #define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv)
292 static inline gfp_t gfp_type(void)
294 return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
298 * Definition of our link level header.
300 struct ll_header {
301 __u16 length;
302 __u16 type;
303 __u16 unused;
305 #define LL_HEADER_LENGTH (sizeof(struct ll_header))
307 #endif