Linux Audio

Check our new training course

Loading...
v3.1
  1/*
  2 *	drivers/s390/net/ctcm_main.h
  3 *
  4 *	Copyright IBM Corp. 2001, 2007
  5 *	Authors:	Fritz Elfert (felfert@millenux.com)
  6 *			Peter Tiedemann (ptiedem@de.ibm.com)
  7 */
  8
  9#ifndef _CTCM_MAIN_H_
 10#define _CTCM_MAIN_H_
 11
 12#include <asm/ccwdev.h>
 13#include <asm/ccwgroup.h>
 14
 15#include <linux/skbuff.h>
 16#include <linux/netdevice.h>
 17
 18#include "fsm.h"
 19#include "ctcm_dbug.h"
 20#include "ctcm_mpc.h"
 21
 22#define CTC_DRIVER_NAME	"ctcm"
 23#define CTC_DEVICE_NAME	"ctc"
 24#define MPC_DEVICE_NAME	"mpc"
 25#define CTC_DEVICE_GENE CTC_DEVICE_NAME "%d"
 26#define MPC_DEVICE_GENE	MPC_DEVICE_NAME "%d"
 27
 28#define CHANNEL_FLAGS_READ	0
 29#define CHANNEL_FLAGS_WRITE	1
 30#define CHANNEL_FLAGS_INUSE	2
 31#define CHANNEL_FLAGS_BUFSIZE_CHANGED	4
 32#define CHANNEL_FLAGS_FAILED	8
 33#define CHANNEL_FLAGS_WAITIRQ	16
 34#define CHANNEL_FLAGS_RWMASK	1
 35#define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
 36
 37#define LOG_FLAG_ILLEGALPKT	1
 38#define LOG_FLAG_ILLEGALSIZE	2
 39#define LOG_FLAG_OVERRUN	4
 40#define LOG_FLAG_NOMEM		8
 41
 42#define ctcm_pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
 43
 44#define CTCM_PR_DEBUG(fmt, arg...) \
 45	do { \
 46		if (do_debug) \
 47			printk(KERN_DEBUG fmt, ##arg); \
 48	} while (0)
 49
 50#define	CTCM_PR_DBGDATA(fmt, arg...) \
 51	do { \
 52		if (do_debug_data) \
 53			printk(KERN_DEBUG fmt, ##arg); \
 54	} while (0)
 55
 56#define	CTCM_D3_DUMP(buf, len) \
 57	do { \
 58		if (do_debug_data) \
 59			ctcmpc_dumpit(buf, len); \
 60	} while (0)
 61
 62#define	CTCM_CCW_DUMP(buf, len) \
 63	do { \
 64		if (do_debug_ccw) \
 65			ctcmpc_dumpit(buf, len); \
 66	} while (0)
 67
 68/**
 69 * Enum for classifying detected devices
 70 */
 71enum ctcm_channel_types {
 72	/* Device is not a channel  */
 73	ctcm_channel_type_none,
 74
 75	/* Device is a CTC/A */
 76	ctcm_channel_type_parallel,
 77
 78	/* Device is a FICON channel */
 79	ctcm_channel_type_ficon,
 80
 81	/* Device is a ESCON channel */
 82	ctcm_channel_type_escon
 83};
 84
 85/*
 86 * CCW commands, used in this driver.
 87 */
 88#define CCW_CMD_WRITE		0x01
 89#define CCW_CMD_READ		0x02
 90#define CCW_CMD_NOOP		0x03
 91#define CCW_CMD_TIC             0x08
 92#define CCW_CMD_SENSE_CMD	0x14
 93#define CCW_CMD_WRITE_CTL	0x17
 94#define CCW_CMD_SET_EXTENDED	0xc3
 95#define CCW_CMD_PREPARE		0xe3
 96
 97#define CTCM_PROTO_S390		0
 98#define CTCM_PROTO_LINUX	1
 99#define CTCM_PROTO_LINUX_TTY	2
100#define CTCM_PROTO_OS390	3
101#define CTCM_PROTO_MPC		4
102#define CTCM_PROTO_MAX		4
103
104#define CTCM_BUFSIZE_LIMIT	65535
105#define CTCM_BUFSIZE_DEFAULT	32768
106#define MPC_BUFSIZE_DEFAULT	CTCM_BUFSIZE_LIMIT
107
108#define CTCM_TIME_1_SEC		1000
109#define CTCM_TIME_5_SEC		5000
110#define CTCM_TIME_10_SEC	10000
111
112#define CTCM_INITIAL_BLOCKLEN	2
113
114#define CTCM_READ		0
115#define CTCM_WRITE		1
116
117#define CTCM_ID_SIZE		20+3
118
119struct ctcm_profile {
120	unsigned long maxmulti;
121	unsigned long maxcqueue;
122	unsigned long doios_single;
123	unsigned long doios_multi;
124	unsigned long txlen;
125	unsigned long tx_time;
126	struct timespec send_stamp;
127};
128
129/*
130 * Definition of one channel
131 */
132struct channel {
133	struct channel *next;
134	char id[CTCM_ID_SIZE];
135	struct ccw_device *cdev;
136	/*
137	 * Type of this channel.
138	 * CTC/A or Escon for valid channels.
139	 */
140	enum ctcm_channel_types type;
141	/*
142	 * Misc. flags. See CHANNEL_FLAGS_... below
143	 */
144	__u32 flags;
145	__u16 protocol;		/* protocol of this channel (4 = MPC) */
146	/*
147	 * I/O and irq related stuff
148	 */
149	struct ccw1 *ccw;
150	struct irb *irb;
151	/*
152	 * RX/TX buffer size
153	 */
154	int max_bufsize;
155	struct sk_buff *trans_skb;	/* transmit/receive buffer */
156	struct sk_buff_head io_queue;	/* universal I/O queue */
157	struct tasklet_struct ch_tasklet;	/* MPC ONLY */
158	/*
159	 * TX queue for collecting skb's during busy.
160	 */
161	struct sk_buff_head collect_queue;
162	/*
163	 * Amount of data in collect_queue.
164	 */
165	int collect_len;
166	/*
167	 * spinlock for collect_queue and collect_len
168	 */
169	spinlock_t collect_lock;
170	/*
171	 * Timer for detecting unresposive
172	 * I/O operations.
173	 */
174	fsm_timer timer;
175	/* MPC ONLY section begin */
176	__u32	th_seq_num;	/* SNA TH seq number */
177	__u8	th_seg;
178	__u32	pdu_seq;
179	struct sk_buff		*xid_skb;
180	char			*xid_skb_data;
181	struct th_header	*xid_th;
182	struct xid2		*xid;
183	char			*xid_id;
184	struct th_header	*rcvd_xid_th;
185	struct xid2		*rcvd_xid;
186	char			*rcvd_xid_id;
187	__u8			in_mpcgroup;
188	fsm_timer		sweep_timer;
189	struct sk_buff_head	sweep_queue;
190	struct th_header	*discontact_th;
191	struct tasklet_struct	ch_disc_tasklet;
192	/* MPC ONLY section end */
193
194	int retry;		/* retry counter for misc. operations */
195	fsm_instance *fsm;	/* finite state machine of this channel */
196	struct net_device *netdev;	/* corresponding net_device */
197	struct ctcm_profile prof;
198	__u8 *trans_skb_data;
199	__u16 logflags;
200	__u8  sense_rc; /* last unit check sense code report control */
201};
202
203struct ctcm_priv {
204	struct net_device_stats	stats;
205	unsigned long	tbusy;
206
207	/* The MPC group struct of this interface */
208	struct	mpc_group	*mpcg;	/* MPC only */
209	struct	xid2		*xid;	/* MPC only */
210
211	/* The finite state machine of this interface */
212	fsm_instance *fsm;
213
214	/* The protocol of this device */
215	__u16 protocol;
216
217	/* Timer for restarting after I/O Errors */
218	fsm_timer	restart_timer;
219
220	int buffer_size;	/* ctc only */
221
222	struct channel *channel[2];
223};
224
225int ctcm_open(struct net_device *dev);
226int ctcm_close(struct net_device *dev);
227
228/*
229 * prototypes for non-static sysfs functions
230 */
231int ctcm_add_attributes(struct device *dev);
232void ctcm_remove_attributes(struct device *dev);
233int ctcm_add_files(struct device *dev);
234void ctcm_remove_files(struct device *dev);
235
236/*
237 * Compatibility macros for busy handling
238 * of network devices.
239 */
240static inline void ctcm_clear_busy_do(struct net_device *dev)
241{
242	clear_bit(0, &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
243	netif_wake_queue(dev);
244}
245
246static inline void ctcm_clear_busy(struct net_device *dev)
247{
248	struct mpc_group *grp;
249	grp = ((struct ctcm_priv *)dev->ml_priv)->mpcg;
250
251	if (!(grp && grp->in_sweep))
252		ctcm_clear_busy_do(dev);
253}
254
255
256static inline int ctcm_test_and_set_busy(struct net_device *dev)
257{
258	netif_stop_queue(dev);
259	return test_and_set_bit(0,
260			&(((struct ctcm_priv *)dev->ml_priv)->tbusy));
261}
262
263extern int loglevel;
264extern struct channel *channels;
265
266void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb);
267
268/*
269 * Functions related to setup and device detection.
270 */
271
272static inline int ctcm_less_than(char *id1, char *id2)
273{
274	unsigned long dev1, dev2;
275
276	id1 = id1 + 5;
277	id2 = id2 + 5;
278
279	dev1 = simple_strtoul(id1, &id1, 16);
280	dev2 = simple_strtoul(id2, &id2, 16);
281
282	return (dev1 < dev2);
283}
284
285int ctcm_ch_alloc_buffer(struct channel *ch);
286
287static inline int ctcm_checkalloc_buffer(struct channel *ch)
288{
289	if (ch->trans_skb == NULL)
290		return ctcm_ch_alloc_buffer(ch);
291	if (ch->flags & CHANNEL_FLAGS_BUFSIZE_CHANGED) {
292		dev_kfree_skb(ch->trans_skb);
293		return ctcm_ch_alloc_buffer(ch);
294	}
295	return 0;
296}
297
298struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv);
299
300/* test if protocol attribute (of struct ctcm_priv or struct channel)
301 * has MPC protocol setting. Type is not checked
302 */
303#define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC)
304
305/* test if struct ctcm_priv of struct net_device has MPC protocol setting */
306#define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv)
307
308static inline gfp_t gfp_type(void)
309{
310	return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
311}
312
313/*
314 * Definition of our link level header.
315 */
316struct ll_header {
317	__u16 length;
318	__u16 type;
319	__u16 unused;
320};
321#define LL_HEADER_LENGTH (sizeof(struct ll_header))
322
323#endif
v4.6
  1/*
 
 
  2 *	Copyright IBM Corp. 2001, 2007
  3 *	Authors:	Fritz Elfert (felfert@millenux.com)
  4 *			Peter Tiedemann (ptiedem@de.ibm.com)
  5 */
  6
  7#ifndef _CTCM_MAIN_H_
  8#define _CTCM_MAIN_H_
  9
 10#include <asm/ccwdev.h>
 11#include <asm/ccwgroup.h>
 12
 13#include <linux/skbuff.h>
 14#include <linux/netdevice.h>
 15
 16#include "fsm.h"
 17#include "ctcm_dbug.h"
 18#include "ctcm_mpc.h"
 19
 20#define CTC_DRIVER_NAME	"ctcm"
 21#define CTC_DEVICE_NAME	"ctc"
 22#define MPC_DEVICE_NAME	"mpc"
 23#define CTC_DEVICE_GENE CTC_DEVICE_NAME "%d"
 24#define MPC_DEVICE_GENE	MPC_DEVICE_NAME "%d"
 25
 26#define CHANNEL_FLAGS_READ	0
 27#define CHANNEL_FLAGS_WRITE	1
 28#define CHANNEL_FLAGS_INUSE	2
 29#define CHANNEL_FLAGS_BUFSIZE_CHANGED	4
 30#define CHANNEL_FLAGS_FAILED	8
 31#define CHANNEL_FLAGS_WAITIRQ	16
 32#define CHANNEL_FLAGS_RWMASK	1
 33#define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
 34
 35#define LOG_FLAG_ILLEGALPKT	1
 36#define LOG_FLAG_ILLEGALSIZE	2
 37#define LOG_FLAG_OVERRUN	4
 38#define LOG_FLAG_NOMEM		8
 39
 40#define ctcm_pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
 41
 42#define CTCM_PR_DEBUG(fmt, arg...) \
 43	do { \
 44		if (do_debug) \
 45			printk(KERN_DEBUG fmt, ##arg); \
 46	} while (0)
 47
 48#define	CTCM_PR_DBGDATA(fmt, arg...) \
 49	do { \
 50		if (do_debug_data) \
 51			printk(KERN_DEBUG fmt, ##arg); \
 52	} while (0)
 53
 54#define	CTCM_D3_DUMP(buf, len) \
 55	do { \
 56		if (do_debug_data) \
 57			ctcmpc_dumpit(buf, len); \
 58	} while (0)
 59
 60#define	CTCM_CCW_DUMP(buf, len) \
 61	do { \
 62		if (do_debug_ccw) \
 63			ctcmpc_dumpit(buf, len); \
 64	} while (0)
 65
 66/**
 67 * Enum for classifying detected devices
 68 */
 69enum ctcm_channel_types {
 70	/* Device is not a channel  */
 71	ctcm_channel_type_none,
 72
 73	/* Device is a CTC/A */
 74	ctcm_channel_type_parallel,
 75
 76	/* Device is a FICON channel */
 77	ctcm_channel_type_ficon,
 78
 79	/* Device is a ESCON channel */
 80	ctcm_channel_type_escon
 81};
 82
 83/*
 84 * CCW commands, used in this driver.
 85 */
 86#define CCW_CMD_WRITE		0x01
 87#define CCW_CMD_READ		0x02
 88#define CCW_CMD_NOOP		0x03
 89#define CCW_CMD_TIC             0x08
 90#define CCW_CMD_SENSE_CMD	0x14
 91#define CCW_CMD_WRITE_CTL	0x17
 92#define CCW_CMD_SET_EXTENDED	0xc3
 93#define CCW_CMD_PREPARE		0xe3
 94
 95#define CTCM_PROTO_S390		0
 96#define CTCM_PROTO_LINUX	1
 97#define CTCM_PROTO_LINUX_TTY	2
 98#define CTCM_PROTO_OS390	3
 99#define CTCM_PROTO_MPC		4
100#define CTCM_PROTO_MAX		4
101
102#define CTCM_BUFSIZE_LIMIT	65535
103#define CTCM_BUFSIZE_DEFAULT	32768
104#define MPC_BUFSIZE_DEFAULT	CTCM_BUFSIZE_LIMIT
105
106#define CTCM_TIME_1_SEC		1000
107#define CTCM_TIME_5_SEC		5000
108#define CTCM_TIME_10_SEC	10000
109
110#define CTCM_INITIAL_BLOCKLEN	2
111
112#define CTCM_READ		0
113#define CTCM_WRITE		1
114
115#define CTCM_ID_SIZE		20+3
116
117struct ctcm_profile {
118	unsigned long maxmulti;
119	unsigned long maxcqueue;
120	unsigned long doios_single;
121	unsigned long doios_multi;
122	unsigned long txlen;
123	unsigned long tx_time;
124	unsigned long send_stamp;
125};
126
127/*
128 * Definition of one channel
129 */
130struct channel {
131	struct channel *next;
132	char id[CTCM_ID_SIZE];
133	struct ccw_device *cdev;
134	/*
135	 * Type of this channel.
136	 * CTC/A or Escon for valid channels.
137	 */
138	enum ctcm_channel_types type;
139	/*
140	 * Misc. flags. See CHANNEL_FLAGS_... below
141	 */
142	__u32 flags;
143	__u16 protocol;		/* protocol of this channel (4 = MPC) */
144	/*
145	 * I/O and irq related stuff
146	 */
147	struct ccw1 *ccw;
148	struct irb *irb;
149	/*
150	 * RX/TX buffer size
151	 */
152	int max_bufsize;
153	struct sk_buff *trans_skb;	/* transmit/receive buffer */
154	struct sk_buff_head io_queue;	/* universal I/O queue */
155	struct tasklet_struct ch_tasklet;	/* MPC ONLY */
156	/*
157	 * TX queue for collecting skb's during busy.
158	 */
159	struct sk_buff_head collect_queue;
160	/*
161	 * Amount of data in collect_queue.
162	 */
163	int collect_len;
164	/*
165	 * spinlock for collect_queue and collect_len
166	 */
167	spinlock_t collect_lock;
168	/*
169	 * Timer for detecting unresposive
170	 * I/O operations.
171	 */
172	fsm_timer timer;
173	/* MPC ONLY section begin */
174	__u32	th_seq_num;	/* SNA TH seq number */
175	__u8	th_seg;
176	__u32	pdu_seq;
177	struct sk_buff		*xid_skb;
178	char			*xid_skb_data;
179	struct th_header	*xid_th;
180	struct xid2		*xid;
181	char			*xid_id;
182	struct th_header	*rcvd_xid_th;
183	struct xid2		*rcvd_xid;
184	char			*rcvd_xid_id;
185	__u8			in_mpcgroup;
186	fsm_timer		sweep_timer;
187	struct sk_buff_head	sweep_queue;
188	struct th_header	*discontact_th;
189	struct tasklet_struct	ch_disc_tasklet;
190	/* MPC ONLY section end */
191
192	int retry;		/* retry counter for misc. operations */
193	fsm_instance *fsm;	/* finite state machine of this channel */
194	struct net_device *netdev;	/* corresponding net_device */
195	struct ctcm_profile prof;
196	__u8 *trans_skb_data;
197	__u16 logflags;
198	__u8  sense_rc; /* last unit check sense code report control */
199};
200
201struct ctcm_priv {
202	struct net_device_stats	stats;
203	unsigned long	tbusy;
204
205	/* The MPC group struct of this interface */
206	struct	mpc_group	*mpcg;	/* MPC only */
207	struct	xid2		*xid;	/* MPC only */
208
209	/* The finite state machine of this interface */
210	fsm_instance *fsm;
211
212	/* The protocol of this device */
213	__u16 protocol;
214
215	/* Timer for restarting after I/O Errors */
216	fsm_timer	restart_timer;
217
218	int buffer_size;	/* ctc only */
219
220	struct channel *channel[2];
221};
222
223int ctcm_open(struct net_device *dev);
224int ctcm_close(struct net_device *dev);
225
226extern const struct attribute_group *ctcm_attr_groups[];
 
 
 
 
 
 
227
228/*
229 * Compatibility macros for busy handling
230 * of network devices.
231 */
232static inline void ctcm_clear_busy_do(struct net_device *dev)
233{
234	clear_bit(0, &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
235	netif_wake_queue(dev);
236}
237
238static inline void ctcm_clear_busy(struct net_device *dev)
239{
240	struct mpc_group *grp;
241	grp = ((struct ctcm_priv *)dev->ml_priv)->mpcg;
242
243	if (!(grp && grp->in_sweep))
244		ctcm_clear_busy_do(dev);
245}
246
247
248static inline int ctcm_test_and_set_busy(struct net_device *dev)
249{
250	netif_stop_queue(dev);
251	return test_and_set_bit(0,
252			&(((struct ctcm_priv *)dev->ml_priv)->tbusy));
253}
254
255extern int loglevel;
256extern struct channel *channels;
257
258void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb);
259
260/*
261 * Functions related to setup and device detection.
262 */
263
264static inline int ctcm_less_than(char *id1, char *id2)
265{
266	unsigned long dev1, dev2;
267
268	id1 = id1 + 5;
269	id2 = id2 + 5;
270
271	dev1 = simple_strtoul(id1, &id1, 16);
272	dev2 = simple_strtoul(id2, &id2, 16);
273
274	return (dev1 < dev2);
275}
276
277int ctcm_ch_alloc_buffer(struct channel *ch);
278
279static inline int ctcm_checkalloc_buffer(struct channel *ch)
280{
281	if (ch->trans_skb == NULL)
282		return ctcm_ch_alloc_buffer(ch);
283	if (ch->flags & CHANNEL_FLAGS_BUFSIZE_CHANGED) {
284		dev_kfree_skb(ch->trans_skb);
285		return ctcm_ch_alloc_buffer(ch);
286	}
287	return 0;
288}
289
290struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv);
291
292/* test if protocol attribute (of struct ctcm_priv or struct channel)
293 * has MPC protocol setting. Type is not checked
294 */
295#define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC)
296
297/* test if struct ctcm_priv of struct net_device has MPC protocol setting */
298#define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv)
299
300static inline gfp_t gfp_type(void)
301{
302	return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
303}
304
305/*
306 * Definition of our link level header.
307 */
308struct ll_header {
309	__u16 length;
310	__u16 type;
311	__u16 unused;
312};
313#define LL_HEADER_LENGTH (sizeof(struct ll_header))
314
315#endif