diff options
author | Peter Tiedemann <ptiedem@de.ibm.com> | 2008-02-07 18:03:49 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-03-17 07:49:26 -0400 |
commit | 293d984f0e3604c04dcdbf00117ddc1e5d4b1909 (patch) | |
tree | 753698fc17e33a9ce98f957eadd894d3f1d9f739 /drivers/s390/net/ctcm_main.h | |
parent | f423f73506ba8e837b5fdcd8c8be50078deb123d (diff) |
ctcm: infrastructure for replaced ctc driver
ctcm driver supports the channel-to-channel connections of the
old ctc driver plus an additional MPC protocol to provide SNA
connectivity.
This new ctcm driver replaces the existing ctc driver.
Signed-off-by: Peter Tiedemann <ptiedem@de.ibm.com>
Signed-off-by: Ursula Braun <braunu@de.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/s390/net/ctcm_main.h')
-rw-r--r-- | drivers/s390/net/ctcm_main.h | 287 |
1 files changed, 287 insertions, 0 deletions
diff --git a/drivers/s390/net/ctcm_main.h b/drivers/s390/net/ctcm_main.h new file mode 100644 index 000000000000..95b0c0b6ebc6 --- /dev/null +++ b/drivers/s390/net/ctcm_main.h | |||
@@ -0,0 +1,287 @@ | |||
1 | /* | ||
2 | * drivers/s390/net/ctcm_main.h | ||
3 | * | ||
4 | * Copyright IBM Corp. 2001, 2007 | ||
5 | * Authors: Fritz Elfert (felfert@millenux.com) | ||
6 | * Peter Tiedemann (ptiedem@de.ibm.com) | ||
7 | */ | ||
8 | |||
9 | #ifndef _CTCM_MAIN_H_ | ||
10 | #define _CTCM_MAIN_H_ | ||
11 | |||
12 | #include <asm/ccwdev.h> | ||
13 | #include <asm/ccwgroup.h> | ||
14 | |||
15 | #include <linux/skbuff.h> | ||
16 | #include <linux/netdevice.h> | ||
17 | |||
18 | #include "fsm.h" | ||
19 | #include "cu3088.h" | ||
20 | #include "ctcm_dbug.h" | ||
21 | #include "ctcm_mpc.h" | ||
22 | |||
23 | #define CTC_DRIVER_NAME "ctcm" | ||
24 | #define CTC_DEVICE_NAME "ctc" | ||
25 | #define CTC_DEVICE_GENE "ctc%d" | ||
26 | #define MPC_DEVICE_NAME "mpc" | ||
27 | #define MPC_DEVICE_GENE "mpc%d" | ||
28 | |||
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) | ||
37 | |||
38 | #define LOG_FLAG_ILLEGALPKT 1 | ||
39 | #define LOG_FLAG_ILLEGALSIZE 2 | ||
40 | #define LOG_FLAG_OVERRUN 4 | ||
41 | #define LOG_FLAG_NOMEM 8 | ||
42 | |||
43 | #define ctcm_pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg) | ||
44 | #define ctcm_pr_info(fmt, arg...) printk(KERN_INFO fmt, ##arg) | ||
45 | #define ctcm_pr_notice(fmt, arg...) printk(KERN_NOTICE fmt, ##arg) | ||
46 | #define ctcm_pr_warn(fmt, arg...) printk(KERN_WARNING fmt, ##arg) | ||
47 | #define ctcm_pr_emerg(fmt, arg...) printk(KERN_EMERG fmt, ##arg) | ||
48 | #define ctcm_pr_err(fmt, arg...) printk(KERN_ERR fmt, ##arg) | ||
49 | #define ctcm_pr_crit(fmt, arg...) printk(KERN_CRIT fmt, ##arg) | ||
50 | |||
51 | /* | ||
52 | * CCW commands, used in this driver. | ||
53 | */ | ||
54 | #define CCW_CMD_WRITE 0x01 | ||
55 | #define CCW_CMD_READ 0x02 | ||
56 | #define CCW_CMD_NOOP 0x03 | ||
57 | #define CCW_CMD_TIC 0x08 | ||
58 | #define CCW_CMD_SENSE_CMD 0x14 | ||
59 | #define CCW_CMD_WRITE_CTL 0x17 | ||
60 | #define CCW_CMD_SET_EXTENDED 0xc3 | ||
61 | #define CCW_CMD_PREPARE 0xe3 | ||
62 | |||
63 | #define CTCM_PROTO_S390 0 | ||
64 | #define CTCM_PROTO_LINUX 1 | ||
65 | #define CTCM_PROTO_LINUX_TTY 2 | ||
66 | #define CTCM_PROTO_OS390 3 | ||
67 | #define CTCM_PROTO_MPC 4 | ||
68 | #define CTCM_PROTO_MAX 4 | ||
69 | |||
70 | #define CTCM_BUFSIZE_LIMIT 65535 | ||
71 | #define CTCM_BUFSIZE_DEFAULT 32768 | ||
72 | #define MPC_BUFSIZE_DEFAULT CTCM_BUFSIZE_LIMIT | ||
73 | |||
74 | #define CTCM_TIME_1_SEC 1000 | ||
75 | #define CTCM_TIME_5_SEC 5000 | ||
76 | #define CTCM_TIME_10_SEC 10000 | ||
77 | |||
78 | #define CTCM_INITIAL_BLOCKLEN 2 | ||
79 | |||
80 | #define READ 0 | ||
81 | #define WRITE 1 | ||
82 | |||
83 | #define CTCM_ID_SIZE BUS_ID_SIZE+3 | ||
84 | |||
85 | struct ctcm_profile { | ||
86 | unsigned long maxmulti; | ||
87 | unsigned long maxcqueue; | ||
88 | unsigned long doios_single; | ||
89 | unsigned long doios_multi; | ||
90 | unsigned long txlen; | ||
91 | unsigned long tx_time; | ||
92 | struct timespec send_stamp; | ||
93 | }; | ||
94 | |||
95 | /* | ||
96 | * Definition of one channel | ||
97 | */ | ||
98 | struct channel { | ||
99 | struct channel *next; | ||
100 | char id[CTCM_ID_SIZE]; | ||
101 | struct ccw_device *cdev; | ||
102 | /* | ||
103 | * Type of this channel. | ||
104 | * CTC/A or Escon for valid channels. | ||
105 | */ | ||
106 | enum channel_types type; | ||
107 | /* | ||
108 | * Misc. flags. See CHANNEL_FLAGS_... below | ||
109 | */ | ||
110 | __u32 flags; | ||
111 | __u16 protocol; /* protocol of this channel (4 = MPC) */ | ||
112 | /* | ||
113 | * I/O and irq related stuff | ||
114 | */ | ||
115 | struct ccw1 *ccw; | ||
116 | struct irb *irb; | ||
117 | /* | ||
118 | * RX/TX buffer size | ||
119 | */ | ||
120 | int max_bufsize; | ||
121 | struct sk_buff *trans_skb; /* transmit/receive buffer */ | ||
122 | struct sk_buff_head io_queue; /* universal I/O queue */ | ||
123 | struct tasklet_struct ch_tasklet; /* MPC ONLY */ | ||
124 | /* | ||
125 | * TX queue for collecting skb's during busy. | ||
126 | */ | ||
127 | struct sk_buff_head collect_queue; | ||
128 | /* | ||
129 | * Amount of data in collect_queue. | ||
130 | */ | ||
131 | int collect_len; | ||
132 | /* | ||
133 | * spinlock for collect_queue and collect_len | ||
134 | */ | ||
135 | spinlock_t collect_lock; | ||
136 | /* | ||
137 | * Timer for detecting unresposive | ||
138 | * I/O operations. | ||
139 | */ | ||
140 | fsm_timer timer; | ||
141 | /* MPC ONLY section begin */ | ||
142 | __u32 th_seq_num; /* SNA TH seq number */ | ||
143 | __u8 th_seg; | ||
144 | __u32 pdu_seq; | ||
145 | struct sk_buff *xid_skb; | ||
146 | char *xid_skb_data; | ||
147 | struct th_header *xid_th; | ||
148 | struct xid2 *xid; | ||
149 | char *xid_id; | ||
150 | struct th_header *rcvd_xid_th; | ||
151 | struct xid2 *rcvd_xid; | ||
152 | char *rcvd_xid_id; | ||
153 | __u8 in_mpcgroup; | ||
154 | fsm_timer sweep_timer; | ||
155 | struct sk_buff_head sweep_queue; | ||
156 | struct th_header *discontact_th; | ||
157 | struct tasklet_struct ch_disc_tasklet; | ||
158 | /* MPC ONLY section end */ | ||
159 | |||
160 | int retry; /* retry counter for misc. operations */ | ||
161 | fsm_instance *fsm; /* finite state machine of this channel */ | ||
162 | struct net_device *netdev; /* corresponding net_device */ | ||
163 | struct ctcm_profile prof; | ||
164 | unsigned char *trans_skb_data; | ||
165 | __u16 logflags; | ||
166 | }; | ||
167 | |||
168 | struct ctcm_priv { | ||
169 | struct net_device_stats stats; | ||
170 | unsigned long tbusy; | ||
171 | |||
172 | /* The MPC group struct of this interface */ | ||
173 | struct mpc_group *mpcg; /* MPC only */ | ||
174 | struct xid2 *xid; /* MPC only */ | ||
175 | |||
176 | /* The finite state machine of this interface */ | ||
177 | fsm_instance *fsm; | ||
178 | |||
179 | /* The protocol of this device */ | ||
180 | __u16 protocol; | ||
181 | |||
182 | /* Timer for restarting after I/O Errors */ | ||
183 | fsm_timer restart_timer; | ||
184 | |||
185 | int buffer_size; /* ctc only */ | ||
186 | |||
187 | struct channel *channel[2]; | ||
188 | }; | ||
189 | |||
190 | int ctcm_open(struct net_device *dev); | ||
191 | int ctcm_close(struct net_device *dev); | ||
192 | |||
193 | /* | ||
194 | * prototypes for non-static sysfs functions | ||
195 | */ | ||
196 | int ctcm_add_attributes(struct device *dev); | ||
197 | void ctcm_remove_attributes(struct device *dev); | ||
198 | int ctcm_add_files(struct device *dev); | ||
199 | void ctcm_remove_files(struct device *dev); | ||
200 | |||
201 | /* | ||
202 | * Compatibility macros for busy handling | ||
203 | * of network devices. | ||
204 | */ | ||
205 | static inline void ctcm_clear_busy_do(struct net_device *dev) | ||
206 | { | ||
207 | clear_bit(0, &(((struct ctcm_priv *)dev->priv)->tbusy)); | ||
208 | netif_wake_queue(dev); | ||
209 | } | ||
210 | |||
211 | static inline void ctcm_clear_busy(struct net_device *dev) | ||
212 | { | ||
213 | struct mpc_group *grp; | ||
214 | grp = ((struct ctcm_priv *)dev->priv)->mpcg; | ||
215 | |||
216 | if (!(grp && grp->in_sweep)) | ||
217 | ctcm_clear_busy_do(dev); | ||
218 | } | ||
219 | |||
220 | |||
221 | static inline int ctcm_test_and_set_busy(struct net_device *dev) | ||
222 | { | ||
223 | netif_stop_queue(dev); | ||
224 | return test_and_set_bit(0, &(((struct ctcm_priv *)dev->priv)->tbusy)); | ||
225 | } | ||
226 | |||
227 | extern int loglevel; | ||
228 | extern struct channel *channels; | ||
229 | |||
230 | void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb); | ||
231 | |||
232 | /* | ||
233 | * Functions related to setup and device detection. | ||
234 | */ | ||
235 | |||
236 | static inline int ctcm_less_than(char *id1, char *id2) | ||
237 | { | ||
238 | unsigned long dev1, dev2; | ||
239 | |||
240 | id1 = id1 + 5; | ||
241 | id2 = id2 + 5; | ||
242 | |||
243 | dev1 = simple_strtoul(id1, &id1, 16); | ||
244 | dev2 = simple_strtoul(id2, &id2, 16); | ||
245 | |||
246 | return (dev1 < dev2); | ||
247 | } | ||
248 | |||
249 | int ctcm_ch_alloc_buffer(struct channel *ch); | ||
250 | |||
251 | static inline int ctcm_checkalloc_buffer(struct channel *ch) | ||
252 | { | ||
253 | if (ch->trans_skb == NULL) | ||
254 | return ctcm_ch_alloc_buffer(ch); | ||
255 | if (ch->flags & CHANNEL_FLAGS_BUFSIZE_CHANGED) { | ||
256 | dev_kfree_skb(ch->trans_skb); | ||
257 | return ctcm_ch_alloc_buffer(ch); | ||
258 | } | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv); | ||
263 | |||
264 | /* test if protocol attribute (of struct ctcm_priv or struct channel) | ||
265 | * has MPC protocol setting. Type is not checked | ||
266 | */ | ||
267 | #define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC) | ||
268 | |||
269 | /* test if struct ctcm_priv of struct net_device has MPC protocol setting */ | ||
270 | #define IS_MPCDEV(d) IS_MPC((struct ctcm_priv *)d->priv) | ||
271 | |||
272 | static inline gfp_t gfp_type(void) | ||
273 | { | ||
274 | return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | * Definition of our link level header. | ||
279 | */ | ||
280 | struct ll_header { | ||
281 | __u16 length; | ||
282 | __u16 type; | ||
283 | __u16 unused; | ||
284 | }; | ||
285 | #define LL_HEADER_LENGTH (sizeof(struct ll_header)) | ||
286 | |||
287 | #endif | ||