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