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