patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / s390 / net / lcs.h
1 /*lcs.h*/
2
3 #include <linux/interrupt.h>
4 #include <linux/netdevice.h>
5 #include <linux/skbuff.h>
6 #include <linux/workqueue.h>
7 #include <asm/ccwdev.h>
8
9 #define VERSION_LCS_H "$Revision: 1.16 $"
10
11 #define LCS_DBF_TEXT(level, name, text) \
12         do { \
13                 debug_text_event(lcs_dbf_##name, level, text); \
14         } while (0)
15
16 #define LCS_DBF_HEX(level,name,addr,len) \
17 do { \
18         debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
19 } while (0)
20
21 #define LCS_DBF_TEXT_(level,name,text...) \
22 do {                                       \
23         sprintf(debug_buffer, text);  \
24                 debug_text_event(lcs_dbf_##name,level, debug_buffer);\
25 } while (0)
26
27 /**
28  * some more definitions for debug or output stuff
29  */
30 #define PRINTK_HEADER           " lcs: "
31
32 /**
33  *      sysfs related stuff
34  */
35 #define CARD_FROM_DEV(cdev) \
36         (struct lcs_card *) \
37         ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
38 /**
39  * CCW commands used in this driver
40  */
41 #define LCS_CCW_WRITE           0x01
42 #define LCS_CCW_READ            0x02
43 #define LCS_CCW_TRANSFER        0x08
44
45 /**
46  * LCS device status primitives
47  */
48 #define LCS_CMD_STARTLAN        0x01
49 #define LCS_CMD_STOPLAN         0x02
50 #define LCS_CMD_LANSTAT         0x04
51 #define LCS_CMD_STARTUP         0x07
52 #define LCS_CMD_SHUTDOWN        0x08
53 #define LCS_CMD_QIPASSIST       0xb2
54 #define LCS_CMD_SETIPM          0xb4
55 #define LCS_CMD_DELIPM          0xb5
56
57 #define LCS_INITIATOR_TCPIP     0x00
58 #define LCS_INITIATOR_LGW       0x01
59 #define LCS_STD_CMD_SIZE        16
60 #define LCS_MULTICAST_CMD_SIZE  404
61
62 /**
63  * LCS IPASSIST MASKS,only used when multicast is switched on
64  */
65 /* Not supported by LCS */
66 #define LCS_IPASS_ARP_PROCESSING        0x0001
67 #define LCS_IPASS_IN_CHECKSUM_SUPPORT   0x0002
68 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT  0x0004
69 #define LCS_IPASS_IP_FRAG_REASSEMBLY    0x0008
70 #define LCS_IPASS_IP_FILTERING          0x0010
71 /* Supported by lcs 3172 */
72 #define LCS_IPASS_IPV6_SUPPORT          0x0020
73 #define LCS_IPASS_MULTICAST_SUPPORT     0x0040
74
75 /**
76  * LCS sense byte definitions
77  */
78 #define LCS_SENSE_INTERFACE_DISCONNECT  0x01
79 #define LCS_SENSE_EQUIPMENT_CHECK       0x10
80 #define LCS_SENSE_BUS_OUT_CHECK         0x20
81 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
82 #define LCS_SENSE_CMD_REJECT            0x80
83 #define LCS_SENSE_RESETTING_EVENT       0x0080
84 #define LCS_SENSE_DEVICE_ONLINE         0x0020
85
86 /**
87  * LCS packet type definitions
88  */
89 #define LCS_FRAME_TYPE_CONTROL          0
90 #define LCS_FRAME_TYPE_ENET             1
91 #define LCS_FRAME_TYPE_TR               2
92 #define LCS_FRAME_TYPE_FDDI             7
93 #define LCS_FRAME_TYPE_AUTO             -1
94
95 /**
96  * some more definitions,we will sort them later
97  */
98 #define LCS_ILLEGAL_OFFSET              0xffff
99 #define LCS_IOBUFFERSIZE                0x5000
100 #define LCS_NUM_BUFFS                   8       /* needs to be power of 2 */
101 #define LCS_MAC_LENGTH                  6
102 #define LCS_INVALID_PORT_NO             -1
103 #define LCS_LANCMD_TIMEOUT_DEFAULT      5
104
105 /**
106  * Multicast state
107  */
108 #define  LCS_IPM_STATE_SET_REQUIRED     0
109 #define  LCS_IPM_STATE_DEL_REQUIRED     1
110 #define  LCS_IPM_STATE_ON_CARD          2
111
112 /**
113  * LCS IP Assist declarations
114  * seems to be only used for multicast
115  */
116 #define  LCS_IPASS_ARP_PROCESSING       0x0001
117 #define  LCS_IPASS_INBOUND_CSUM_SUPP    0x0002
118 #define  LCS_IPASS_OUTBOUND_CSUM_SUPP   0x0004
119 #define  LCS_IPASS_IP_FRAG_REASSEMBLY   0x0008
120 #define  LCS_IPASS_IP_FILTERING         0x0010
121 #define  LCS_IPASS_IPV6_SUPPORT         0x0020
122 #define  LCS_IPASS_MULTICAST_SUPPORT    0x0040
123
124 /**
125  * LCS Buffer states
126  */
127 enum lcs_buffer_states {
128         BUF_STATE_EMPTY,        /* buffer is empty */
129         BUF_STATE_LOCKED,       /* buffer is locked, don't touch */
130         BUF_STATE_READY,        /* buffer is ready for read/write */
131         BUF_STATE_PROCESSED,
132 };
133
134 /**
135  * LCS Channel State Machine declarations
136  */
137 enum lcs_channel_states {
138         CH_STATE_INIT,
139         CH_STATE_HALTED,
140         CH_STATE_STOPPED,
141         CH_STATE_RUNNING,
142         CH_STATE_SUSPENDED,
143         CH_STATE_CLEARED,
144 };
145
146 /**
147  * LCS device state machine
148  */
149 enum lcs_dev_states {
150         DEV_STATE_DOWN,
151         DEV_STATE_UP,
152         DEV_STATE_RECOVER,
153 };
154
155 /**
156  * LCS struct declarations
157  */
158 struct lcs_header {
159         __u16  offset;
160         __u8   type;
161         __u8   slot;
162 }  __attribute__ ((packed));
163
164 struct lcs_ip_mac_pair {
165         __u32  ip_addr;
166         __u8   mac_addr[LCS_MAC_LENGTH];
167         __u8   reserved[2];
168 }  __attribute__ ((packed));
169
170 struct lcs_ipm_list {
171         struct list_head list;
172         struct lcs_ip_mac_pair ipm;
173         __u8 ipm_state;
174 };
175
176 struct lcs_cmd {
177         __u16  offset;
178         __u8   type;
179         __u8   slot;
180         __u8   cmd_code;
181         __u8   initiator;
182         __u16  sequence_no;
183         __u16  return_code;
184         union {
185                 struct {
186                         __u8   lan_type;
187                         __u8   portno;
188                         __u16  parameter_count;
189                         __u8   operator_flags[3];
190                         __u8   reserved[3];
191                 } lcs_std_cmd;
192                 struct {
193                         __u16  unused1;
194                         __u16  buff_size;
195                         __u8   unused2[6];
196                 } lcs_startup;
197                 struct {
198                         __u8   lan_type;
199                         __u8   portno;
200                         __u8   unused[10];
201                         __u8   mac_addr[LCS_MAC_LENGTH];
202                         __u32  num_packets_deblocked;
203                         __u32  num_packets_blocked;
204                         __u32  num_packets_tx_on_lan;
205                         __u32  num_tx_errors_detected;
206                         __u32  num_tx_packets_disgarded;
207                         __u32  num_packets_rx_from_lan;
208                         __u32  num_rx_errors_detected;
209                         __u32  num_rx_discarded_nobuffs_avail;
210                         __u32  num_rx_packets_too_large;
211                 } lcs_lanstat_cmd;
212 #ifdef CONFIG_IP_MULTICAST
213                 struct {
214                         __u8   lan_type;
215                         __u8   portno;
216                         __u16  num_ip_pairs;
217                         __u16  ip_assists_supported;
218                         __u16  ip_assists_enabled;
219                         __u16  version;
220                         struct {
221                                 struct lcs_ip_mac_pair
222                                 ip_mac_pair[32];
223                                 __u32     response_data;
224                         } lcs_ipass_ctlmsg;
225                 } lcs_qipassist;
226 #endif /*CONFIG_IP_MULTICAST */
227         } cmd __attribute__ ((packed));
228 }  __attribute__ ((packed));
229
230 /**
231  * Forward declarations.
232  */
233 struct lcs_card;
234 struct lcs_channel;
235
236 /**
237  * Definition of an lcs buffer.
238  */
239 struct lcs_buffer {
240         enum lcs_buffer_states state;
241         void *data;
242         int count;
243         /* Callback for completion notification. */
244         void (*callback)(struct lcs_channel *, struct lcs_buffer *);
245 };
246
247 struct lcs_reply {
248         struct list_head list;
249         __u16 sequence_no;
250         /* Callback for completion notification. */
251         void (*callback)(struct lcs_card *, struct lcs_cmd *);
252         wait_queue_head_t wait_q;
253         int received;
254         int rc;
255 };
256
257 /**
258  * Definition of an lcs channel
259  */
260 struct lcs_channel {
261         enum lcs_channel_states state;
262         struct ccw_device *ccwdev;
263         struct ccw1 ccws[LCS_NUM_BUFFS + 1];
264         wait_queue_head_t wait_q;
265         struct tasklet_struct irq_tasklet;
266         struct lcs_buffer iob[LCS_NUM_BUFFS];
267         int io_idx;
268         int buf_idx;
269 };
270
271 /**
272  * definition of the lcs card
273  */
274 struct lcs_card {
275         spinlock_t lock;
276         spinlock_t ipm_lock;
277         enum lcs_dev_states state;
278         struct net_device *dev;
279         struct net_device_stats stats;
280         unsigned short (*lan_type_trans)(struct sk_buff *skb,
281                                          struct net_device *dev);
282         struct lcs_channel read;
283         struct lcs_channel write;
284         struct lcs_buffer *tx_buffer;
285         int tx_emitted;
286         struct list_head lancmd_waiters;
287         int lancmd_timeout;
288
289         struct work_struct kernel_thread_starter;
290         unsigned long thread_mask;
291
292 #ifdef CONFIG_IP_MULTICAST
293         struct list_head ipm_list;
294 #endif
295         __u8 mac[LCS_MAC_LENGTH];
296         __u16 ip_assists_supported;
297         __u16 ip_assists_enabled;
298         __s8 lan_type;
299         __u16 sequence_no;
300         __s16 portno;
301         /* Some info copied from probeinfo */
302         u8 device_forced;
303         u8 max_port_no;
304         u8 hint_port_no;
305         s16 port_protocol_no;
306 }  __attribute__ ((aligned(8)));
307