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) \
11 debug_text_event(lcs_dbf_##name, level, text); \
14 #define LCS_DBF_HEX(level,name,addr,len) \
16 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
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...) \
27 if (lcs_dbf_passes(lcs_dbf_##name, level)) { \
28 sprintf(debug_buffer, text); \
29 debug_text_event(lcs_dbf_##name, level, debug_buffer); \
36 #define CARD_FROM_DEV(cdev) \
38 ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
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
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
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
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
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
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
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
{
145 LCS_CH_STATE_STOPPED
,
146 LCS_CH_STATE_RUNNING
,
147 LCS_CH_STATE_SUSPENDED
,
148 LCS_CH_STATE_CLEARED
,
153 * LCS device state machine
155 enum lcs_dev_states
{
162 LCS_SET_MC_THREAD
= 1,
163 LCS_RECOVERY_THREAD
= 2,
167 * LCS struct declarations
173 } __attribute__ ((packed
));
175 struct lcs_ip_mac_pair
{
177 __u8 mac_addr
[LCS_MAC_LENGTH
];
179 } __attribute__ ((packed
));
181 struct lcs_ipm_list
{
182 struct list_head list
;
183 struct lcs_ip_mac_pair ipm
;
199 __u16 parameter_count
;
200 __u8 operator_flags
[3];
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
;
223 #ifdef CONFIG_IP_MULTICAST
228 __u16 ip_assists_supported
;
229 __u16 ip_assists_enabled
;
232 struct lcs_ip_mac_pair
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.
248 * Definition of an lcs buffer.
251 enum lcs_buffer_states state
;
254 /* Callback for completion notification. */
255 void (*callback
)(struct lcs_channel
*, struct lcs_buffer
*);
259 struct list_head list
;
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
;
271 * Definition of an 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
];
286 * definition of the lcs card
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
;
301 struct list_head lancmd_waiters
;
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
;
314 __u8 mac
[LCS_MAC_LENGTH
];
315 __u16 ip_assists_supported
;
316 __u16 ip_assists_enabled
;
321 /* Some info copied from probeinfo */
325 s16 port_protocol_no
;
326 } __attribute__ ((aligned(8)));