MINI2440: Added new T35 (QVGA) and Innolux 5.6" (VGA) TFTs
[linux-2.6/mini2440.git] / drivers / s390 / net / lcs.h
blob6d668642af270e27b6b376ce99c2b3276cbc63a8
1 /*lcs.h*/
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>
9 #define LCS_DBF_TEXT(level, name, text) \
10 do { \
11 debug_text_event(lcs_dbf_##name, level, text); \
12 } while (0)
14 #define LCS_DBF_HEX(level,name,addr,len) \
15 do { \
16 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
17 } while (0)
19 /* Allow to sort out low debug levels early to avoid wasted sprints */
20 static inline int lcs_dbf_passes(debug_info_t *dbf_grp, int level)
22 return (level <= dbf_grp->level);
25 #define LCS_DBF_TEXT_(level,name,text...) \
26 do { \
27 if (lcs_dbf_passes(lcs_dbf_##name, level)) { \
28 sprintf(debug_buffer, text); \
29 debug_text_event(lcs_dbf_##name, level, debug_buffer); \
30 } \
31 } while (0)
33 /**
34 * sysfs related stuff
36 #define CARD_FROM_DEV(cdev) \
37 (struct lcs_card *) dev_get_drvdata( \
38 &((struct ccwgroup_device *)dev_get_drvdata(&cdev->dev))->dev);
39 /**
40 * CCW commands used in this driver
42 #define LCS_CCW_WRITE 0x01
43 #define LCS_CCW_READ 0x02
44 #define LCS_CCW_TRANSFER 0x08
46 /**
47 * LCS device status primitives
49 #define LCS_CMD_STARTLAN 0x01
50 #define LCS_CMD_STOPLAN 0x02
51 #define LCS_CMD_LANSTAT 0x04
52 #define LCS_CMD_STARTUP 0x07
53 #define LCS_CMD_SHUTDOWN 0x08
54 #define LCS_CMD_QIPASSIST 0xb2
55 #define LCS_CMD_SETIPM 0xb4
56 #define LCS_CMD_DELIPM 0xb5
58 #define LCS_INITIATOR_TCPIP 0x00
59 #define LCS_INITIATOR_LGW 0x01
60 #define LCS_STD_CMD_SIZE 16
61 #define LCS_MULTICAST_CMD_SIZE 404
63 /**
64 * LCS IPASSIST MASKS,only used when multicast is switched on
66 /* Not supported by LCS */
67 #define LCS_IPASS_ARP_PROCESSING 0x0001
68 #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
69 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
70 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
71 #define LCS_IPASS_IP_FILTERING 0x0010
72 /* Supported by lcs 3172 */
73 #define LCS_IPASS_IPV6_SUPPORT 0x0020
74 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
76 /**
77 * LCS sense byte definitions
79 #define LCS_SENSE_BYTE_0 0
80 #define LCS_SENSE_BYTE_1 1
81 #define LCS_SENSE_BYTE_2 2
82 #define LCS_SENSE_BYTE_3 3
83 #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
84 #define LCS_SENSE_EQUIPMENT_CHECK 0x10
85 #define LCS_SENSE_BUS_OUT_CHECK 0x20
86 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
87 #define LCS_SENSE_CMD_REJECT 0x80
88 #define LCS_SENSE_RESETTING_EVENT 0x80
89 #define LCS_SENSE_DEVICE_ONLINE 0x20
91 /**
92 * LCS packet type definitions
94 #define LCS_FRAME_TYPE_CONTROL 0
95 #define LCS_FRAME_TYPE_ENET 1
96 #define LCS_FRAME_TYPE_TR 2
97 #define LCS_FRAME_TYPE_FDDI 7
98 #define LCS_FRAME_TYPE_AUTO -1
101 * some more definitions,we will sort them later
103 #define LCS_ILLEGAL_OFFSET 0xffff
104 #define LCS_IOBUFFERSIZE 0x5000
105 #define LCS_NUM_BUFFS 32 /* needs to be power of 2 */
106 #define LCS_MAC_LENGTH 6
107 #define LCS_INVALID_PORT_NO -1
108 #define LCS_LANCMD_TIMEOUT_DEFAULT 5
111 * Multicast state
113 #define LCS_IPM_STATE_SET_REQUIRED 0
114 #define LCS_IPM_STATE_DEL_REQUIRED 1
115 #define LCS_IPM_STATE_ON_CARD 2
118 * LCS IP Assist declarations
119 * seems to be only used for multicast
121 #define LCS_IPASS_ARP_PROCESSING 0x0001
122 #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
123 #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
124 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
125 #define LCS_IPASS_IP_FILTERING 0x0010
126 #define LCS_IPASS_IPV6_SUPPORT 0x0020
127 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
130 * LCS Buffer states
132 enum lcs_buffer_states {
133 LCS_BUF_STATE_EMPTY, /* buffer is empty */
134 LCS_BUF_STATE_LOCKED, /* buffer is locked, don't touch */
135 LCS_BUF_STATE_READY, /* buffer is ready for read/write */
136 LCS_BUF_STATE_PROCESSED,
140 * LCS Channel State Machine declarations
142 enum lcs_channel_states {
143 LCS_CH_STATE_INIT,
144 LCS_CH_STATE_HALTED,
145 LCS_CH_STATE_STOPPED,
146 LCS_CH_STATE_RUNNING,
147 LCS_CH_STATE_SUSPENDED,
148 LCS_CH_STATE_CLEARED,
149 LCS_CH_STATE_ERROR,
153 * LCS device state machine
155 enum lcs_dev_states {
156 DEV_STATE_DOWN,
157 DEV_STATE_UP,
158 DEV_STATE_RECOVER,
161 enum lcs_threads {
162 LCS_SET_MC_THREAD = 1,
163 LCS_RECOVERY_THREAD = 2,
167 * LCS struct declarations
169 struct lcs_header {
170 __u16 offset;
171 __u8 type;
172 __u8 slot;
173 } __attribute__ ((packed));
175 struct lcs_ip_mac_pair {
176 __be32 ip_addr;
177 __u8 mac_addr[LCS_MAC_LENGTH];
178 __u8 reserved[2];
179 } __attribute__ ((packed));
181 struct lcs_ipm_list {
182 struct list_head list;
183 struct lcs_ip_mac_pair ipm;
184 __u8 ipm_state;
187 struct lcs_cmd {
188 __u16 offset;
189 __u8 type;
190 __u8 slot;
191 __u8 cmd_code;
192 __u8 initiator;
193 __u16 sequence_no;
194 __u16 return_code;
195 union {
196 struct {
197 __u8 lan_type;
198 __u8 portno;
199 __u16 parameter_count;
200 __u8 operator_flags[3];
201 __u8 reserved[3];
202 } lcs_std_cmd;
203 struct {
204 __u16 unused1;
205 __u16 buff_size;
206 __u8 unused2[6];
207 } lcs_startup;
208 struct {
209 __u8 lan_type;
210 __u8 portno;
211 __u8 unused[10];
212 __u8 mac_addr[LCS_MAC_LENGTH];
213 __u32 num_packets_deblocked;
214 __u32 num_packets_blocked;
215 __u32 num_packets_tx_on_lan;
216 __u32 num_tx_errors_detected;
217 __u32 num_tx_packets_disgarded;
218 __u32 num_packets_rx_from_lan;
219 __u32 num_rx_errors_detected;
220 __u32 num_rx_discarded_nobuffs_avail;
221 __u32 num_rx_packets_too_large;
222 } lcs_lanstat_cmd;
223 #ifdef CONFIG_IP_MULTICAST
224 struct {
225 __u8 lan_type;
226 __u8 portno;
227 __u16 num_ip_pairs;
228 __u16 ip_assists_supported;
229 __u16 ip_assists_enabled;
230 __u16 version;
231 struct {
232 struct lcs_ip_mac_pair
233 ip_mac_pair[32];
234 __u32 response_data;
235 } lcs_ipass_ctlmsg __attribute ((packed));
236 } lcs_qipassist __attribute__ ((packed));
237 #endif /*CONFIG_IP_MULTICAST */
238 } cmd __attribute__ ((packed));
239 } __attribute__ ((packed));
242 * Forward declarations.
244 struct lcs_card;
245 struct lcs_channel;
248 * Definition of an lcs buffer.
250 struct lcs_buffer {
251 enum lcs_buffer_states state;
252 void *data;
253 int count;
254 /* Callback for completion notification. */
255 void (*callback)(struct lcs_channel *, struct lcs_buffer *);
258 struct lcs_reply {
259 struct list_head list;
260 __u16 sequence_no;
261 atomic_t refcnt;
262 /* Callback for completion notification. */
263 void (*callback)(struct lcs_card *, struct lcs_cmd *);
264 wait_queue_head_t wait_q;
265 struct lcs_card *card;
266 int received;
267 int rc;
271 * Definition of an lcs channel
273 struct lcs_channel {
274 enum lcs_channel_states state;
275 struct ccw_device *ccwdev;
276 struct ccw1 ccws[LCS_NUM_BUFFS + 1];
277 wait_queue_head_t wait_q;
278 struct tasklet_struct irq_tasklet;
279 struct lcs_buffer iob[LCS_NUM_BUFFS];
280 int io_idx;
281 int buf_idx;
286 * definition of the lcs card
288 struct lcs_card {
289 spinlock_t lock;
290 spinlock_t ipm_lock;
291 enum lcs_dev_states state;
292 struct net_device *dev;
293 struct net_device_stats stats;
294 __be16 (*lan_type_trans)(struct sk_buff *skb,
295 struct net_device *dev);
296 struct ccwgroup_device *gdev;
297 struct lcs_channel read;
298 struct lcs_channel write;
299 struct lcs_buffer *tx_buffer;
300 int tx_emitted;
301 struct list_head lancmd_waiters;
302 int lancmd_timeout;
304 struct work_struct kernel_thread_starter;
305 spinlock_t mask_lock;
306 unsigned long thread_start_mask;
307 unsigned long thread_running_mask;
308 unsigned long thread_allowed_mask;
309 wait_queue_head_t wait_q;
311 #ifdef CONFIG_IP_MULTICAST
312 struct list_head ipm_list;
313 #endif
314 __u8 mac[LCS_MAC_LENGTH];
315 __u16 ip_assists_supported;
316 __u16 ip_assists_enabled;
317 __s8 lan_type;
318 __u32 pkt_seq;
319 __u16 sequence_no;
320 __s16 portno;
321 /* Some info copied from probeinfo */
322 u8 device_forced;
323 u8 max_port_no;
324 u8 hint_port_no;
325 s16 port_protocol_no;
326 } __attribute__ ((aligned(8)));