blob: ac7975b7a837a9a3db240787d162e57d0fe26e17 [file] [log] [blame]
Peter Tiedemann293d9842008-02-08 00:03:49 +01001/*
2 * drivers/s390/net/ctcm_mpc.c
3 *
4 * Copyright IBM Corp. 2004, 2007
5 * Authors: Belinda Thompson (belindat@us.ibm.com)
6 * Andy Richter (richtera@us.ibm.com)
7 * Peter Tiedemann (ptiedem@de.ibm.com)
8 */
9
10/*
11 This module exports functions to be used by CCS:
12 EXPORT_SYMBOL(ctc_mpc_alloc_channel);
13 EXPORT_SYMBOL(ctc_mpc_establish_connectivity);
14 EXPORT_SYMBOL(ctc_mpc_dealloc_ch);
15 EXPORT_SYMBOL(ctc_mpc_flow_control);
16*/
17
18#undef DEBUG
19#undef DEBUGDATA
20#undef DEBUGCCW
21
Peter Tiedemann2a7c6f22008-12-25 13:39:54 +010022#define KMSG_COMPONENT "ctcm"
23#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
24
Peter Tiedemann293d9842008-02-08 00:03:49 +010025#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/errno.h>
30#include <linux/types.h>
31#include <linux/interrupt.h>
32#include <linux/timer.h>
33#include <linux/sched.h>
34
35#include <linux/signal.h>
36#include <linux/string.h>
37#include <linux/proc_fs.h>
38
39#include <linux/ip.h>
40#include <linux/if_arp.h>
41#include <linux/tcp.h>
42#include <linux/skbuff.h>
43#include <linux/ctype.h>
44#include <linux/netdevice.h>
45#include <net/dst.h>
46
47#include <linux/io.h> /* instead of <asm/io.h> ok ? */
48#include <asm/ccwdev.h>
49#include <asm/ccwgroup.h>
50#include <linux/bitops.h> /* instead of <asm/bitops.h> ok ? */
51#include <linux/uaccess.h> /* instead of <asm/uaccess.h> ok ? */
52#include <linux/wait.h>
53#include <linux/moduleparam.h>
54#include <asm/idals.h>
55
Peter Tiedemann293d9842008-02-08 00:03:49 +010056#include "ctcm_main.h"
Ursula Braunce1f8932012-03-07 02:06:26 +000057#include "ctcm_mpc.h"
Peter Tiedemann293d9842008-02-08 00:03:49 +010058#include "ctcm_fsms.h"
59
60static const struct xid2 init_xid = {
61 .xid2_type_id = XID_FM2,
62 .xid2_len = 0x45,
63 .xid2_adj_id = 0,
64 .xid2_rlen = 0x31,
65 .xid2_resv1 = 0,
66 .xid2_flag1 = 0,
67 .xid2_fmtt = 0,
68 .xid2_flag4 = 0x80,
69 .xid2_resv2 = 0,
70 .xid2_tgnum = 0,
71 .xid2_sender_id = 0,
72 .xid2_flag2 = 0,
73 .xid2_option = XID2_0,
74 .xid2_resv3 = "\x00",
75 .xid2_resv4 = 0,
76 .xid2_dlc_type = XID2_READ_SIDE,
77 .xid2_resv5 = 0,
78 .xid2_mpc_flag = 0,
79 .xid2_resv6 = 0,
80 .xid2_buf_len = (MPC_BUFSIZE_DEFAULT - 35),
81};
82
83static const struct th_header thnorm = {
84 .th_seg = 0x00,
85 .th_ch_flag = TH_IS_XID,
86 .th_blk_flag = TH_DATA_IS_XID,
87 .th_is_xid = 0x01,
88 .th_seq_num = 0x00000000,
89};
90
91static const struct th_header thdummy = {
92 .th_seg = 0x00,
93 .th_ch_flag = 0x00,
94 .th_blk_flag = TH_DATA_IS_XID,
95 .th_is_xid = 0x01,
96 .th_seq_num = 0x00000000,
97};
98
99/*
100 * Definition of one MPC group
101 */
102
103/*
104 * Compatibility macros for busy handling
105 * of network devices.
106 */
107
108static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb);
109
110/*
111 * MPC Group state machine actions (static prototypes)
112 */
113static void mpc_action_nop(fsm_instance *fsm, int event, void *arg);
114static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg);
115static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg);
116static void mpc_action_timeout(fsm_instance *fi, int event, void *arg);
117static int mpc_validate_xid(struct mpcg_info *mpcginfo);
118static void mpc_action_yside_xid(fsm_instance *fsm, int event, void *arg);
119static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg);
120static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg);
121static void mpc_action_xside_xid(fsm_instance *fsm, int event, void *arg);
122static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg);
123static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg);
124
125#ifdef DEBUGDATA
126/*-------------------------------------------------------------------*
127* Dump buffer format *
128* *
129*--------------------------------------------------------------------*/
130void ctcmpc_dumpit(char *buf, int len)
131{
132 __u32 ct, sw, rm, dup;
133 char *ptr, *rptr;
134 char tbuf[82], tdup[82];
Ursula Braunce1f8932012-03-07 02:06:26 +0000135 #ifdef CONFIG_64BIT
Peter Tiedemann293d9842008-02-08 00:03:49 +0100136 char addr[22];
137 #else
138 char addr[12];
139 #endif
140 char boff[12];
141 char bhex[82], duphex[82];
142 char basc[40];
143
144 sw = 0;
145 rptr = ptr = buf;
146 rm = 16;
147 duphex[0] = 0x00;
148 dup = 0;
149
150 for (ct = 0; ct < len; ct++, ptr++, rptr++) {
151 if (sw == 0) {
Ursula Braunce1f8932012-03-07 02:06:26 +0000152 #ifdef CONFIG_64BIT
153 sprintf(addr, "%16.16llx", (__u64)rptr);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100154 #else
155 sprintf(addr, "%8.8X", (__u32)rptr);
156 #endif
157
158 sprintf(boff, "%4.4X", (__u32)ct);
159 bhex[0] = '\0';
160 basc[0] = '\0';
161 }
162 if ((sw == 4) || (sw == 12))
163 strcat(bhex, " ");
164 if (sw == 8)
165 strcat(bhex, " ");
166
Ursula Braunce1f8932012-03-07 02:06:26 +0000167 #if CONFIG_64BIT
168 sprintf(tbuf, "%2.2llX", (__u64)*ptr);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100169 #else
170 sprintf(tbuf, "%2.2X", (__u32)*ptr);
171 #endif
172
173 tbuf[2] = '\0';
174 strcat(bhex, tbuf);
175 if ((0 != isprint(*ptr)) && (*ptr >= 0x20))
176 basc[sw] = *ptr;
177 else
178 basc[sw] = '.';
179
180 basc[sw+1] = '\0';
181 sw++;
182 rm--;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200183 if (sw != 16)
184 continue;
185 if ((strcmp(duphex, bhex)) != 0) {
186 if (dup != 0) {
187 sprintf(tdup,
188 "Duplicate as above to %s", addr);
189 ctcm_pr_debug(" --- %s ---\n",
190 tdup);
191 }
192 ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
Peter Tiedemann293d9842008-02-08 00:03:49 +0100193 addr, boff, bhex, basc);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200194 dup = 0;
195 strcpy(duphex, bhex);
196 } else
197 dup++;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100198
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200199 sw = 0;
200 rm = 16;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100201 } /* endfor */
202
203 if (sw != 0) {
204 for ( ; rm > 0; rm--, sw++) {
205 if ((sw == 4) || (sw == 12))
206 strcat(bhex, " ");
207 if (sw == 8)
208 strcat(bhex, " ");
209 strcat(bhex, " ");
210 strcat(basc, " ");
211 }
212 if (dup != 0) {
213 sprintf(tdup, "Duplicate as above to %s", addr);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200214 ctcm_pr_debug(" --- %s ---\n", tdup);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100215 }
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200216 ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
217 addr, boff, bhex, basc);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100218 } else {
219 if (dup >= 1) {
220 sprintf(tdup, "Duplicate as above to %s", addr);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200221 ctcm_pr_debug(" --- %s ---\n", tdup);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100222 }
223 if (dup != 0) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200224 ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
Peter Tiedemann293d9842008-02-08 00:03:49 +0100225 addr, boff, bhex, basc);
226 }
227 }
228
229 return;
230
231} /* end of ctcmpc_dumpit */
232#endif
233
234#ifdef DEBUGDATA
235/*
236 * Dump header and first 16 bytes of an sk_buff for debugging purposes.
237 *
238 * skb The sk_buff to dump.
239 * offset Offset relative to skb-data, where to start the dump.
240 */
241void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
242{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200243 __u8 *p = skb->data;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100244 struct th_header *header;
245 struct pdu *pheader;
246 int bl = skb->len;
247 int i;
248
249 if (p == NULL)
250 return;
251
252 p += offset;
253 header = (struct th_header *)p;
254
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200255 ctcm_pr_debug("dump:\n");
256 ctcm_pr_debug("skb len=%d \n", skb->len);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100257 if (skb->len > 2) {
258 switch (header->th_ch_flag) {
259 case TH_HAS_PDU:
260 break;
261 case 0x00:
262 case TH_IS_XID:
263 if ((header->th_blk_flag == TH_DATA_IS_XID) &&
264 (header->th_is_xid == 0x01))
265 goto dumpth;
266 case TH_SWEEP_REQ:
267 goto dumpth;
268 case TH_SWEEP_RESP:
269 goto dumpth;
270 default:
271 break;
272 }
273
274 pheader = (struct pdu *)p;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200275 ctcm_pr_debug("pdu->offset: %d hex: %04x\n",
276 pheader->pdu_offset, pheader->pdu_offset);
277 ctcm_pr_debug("pdu->flag : %02x\n", pheader->pdu_flag);
278 ctcm_pr_debug("pdu->proto : %02x\n", pheader->pdu_proto);
279 ctcm_pr_debug("pdu->seq : %02x\n", pheader->pdu_seq);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100280 goto dumpdata;
281
282dumpth:
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200283 ctcm_pr_debug("th->seg : %02x\n", header->th_seg);
284 ctcm_pr_debug("th->ch : %02x\n", header->th_ch_flag);
285 ctcm_pr_debug("th->blk_flag: %02x\n", header->th_blk_flag);
286 ctcm_pr_debug("th->type : %s\n",
287 (header->th_is_xid) ? "DATA" : "XID");
288 ctcm_pr_debug("th->seqnum : %04x\n", header->th_seq_num);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100289
290 }
291dumpdata:
292 if (bl > 32)
293 bl = 32;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200294 ctcm_pr_debug("data: ");
Peter Tiedemann293d9842008-02-08 00:03:49 +0100295 for (i = 0; i < bl; i++)
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200296 ctcm_pr_debug("%02x%s", *p++, (i % 16) ? " " : "\n");
297 ctcm_pr_debug("\n");
Peter Tiedemann293d9842008-02-08 00:03:49 +0100298}
299#endif
300
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200301static struct net_device *ctcmpc_get_dev(int port_num)
302{
303 char device[20];
304 struct net_device *dev;
305 struct ctcm_priv *priv;
306
307 sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num);
308
309 dev = __dev_get_by_name(&init_net, device);
310
311 if (dev == NULL) {
312 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
313 "%s: Device not found by name: %s",
314 CTCM_FUNTAIL, device);
315 return NULL;
316 }
Peter Tiedemann261893d2008-08-21 17:10:24 +0200317 priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200318 if (priv == NULL) {
319 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
Peter Tiedemann261893d2008-08-21 17:10:24 +0200320 "%s(%s): dev->ml_priv is NULL",
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200321 CTCM_FUNTAIL, device);
322 return NULL;
323 }
324 if (priv->mpcg == NULL) {
325 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
326 "%s(%s): priv->mpcg is NULL",
327 CTCM_FUNTAIL, device);
328 return NULL;
329 }
330 return dev;
331}
332
Peter Tiedemann293d9842008-02-08 00:03:49 +0100333/*
334 * ctc_mpc_alloc_channel
335 * (exported interface)
336 *
337 * Device Initialization :
338 * ACTPATH driven IO operations
339 */
340int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int))
341{
Peter Tiedemann293d9842008-02-08 00:03:49 +0100342 struct net_device *dev;
343 struct mpc_group *grp;
344 struct ctcm_priv *priv;
345
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200346 dev = ctcmpc_get_dev(port_num);
347 if (dev == NULL)
Peter Tiedemann293d9842008-02-08 00:03:49 +0100348 return 1;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200349 priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100350 grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100351
352 grp->allochanfunc = callback;
353 grp->port_num = port_num;
354 grp->port_persist = 1;
355
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200356 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
357 "%s(%s): state=%s",
358 CTCM_FUNTAIL, dev->name, fsm_getstate_str(grp->fsm));
Peter Tiedemann293d9842008-02-08 00:03:49 +0100359
360 switch (fsm_getstate(grp->fsm)) {
361 case MPCG_STATE_INOP:
362 /* Group is in the process of terminating */
363 grp->alloc_called = 1;
364 break;
365 case MPCG_STATE_RESET:
366 /* MPC Group will transition to state */
367 /* MPCG_STATE_XID2INITW iff the minimum number */
368 /* of 1 read and 1 write channel have successfully*/
369 /* activated */
370 /*fsm_newstate(grp->fsm, MPCG_STATE_XID2INITW);*/
371 if (callback)
372 grp->send_qllc_disc = 1;
373 case MPCG_STATE_XID0IOWAIT:
374 fsm_deltimer(&grp->timer);
375 grp->outstanding_xid2 = 0;
376 grp->outstanding_xid7 = 0;
377 grp->outstanding_xid7_p2 = 0;
378 grp->saved_xid2 = NULL;
379 if (callback)
380 ctcm_open(dev);
381 fsm_event(priv->fsm, DEV_EVENT_START, dev);
382 break;
383 case MPCG_STATE_READY:
384 /* XID exchanges completed after PORT was activated */
385 /* Link station already active */
386 /* Maybe timing issue...retry callback */
387 grp->allocchan_callback_retries++;
388 if (grp->allocchan_callback_retries < 4) {
389 if (grp->allochanfunc)
390 grp->allochanfunc(grp->port_num,
Peter Tiedemann2a7c6f22008-12-25 13:39:54 +0100391 grp->group_max_buflen);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100392 } else {
393 /* there are problems...bail out */
394 /* there may be a state mismatch so restart */
Peter Tiedemann293d9842008-02-08 00:03:49 +0100395 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
396 grp->allocchan_callback_retries = 0;
397 }
398 break;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100399 }
400
Peter Tiedemann293d9842008-02-08 00:03:49 +0100401 return 0;
402}
403EXPORT_SYMBOL(ctc_mpc_alloc_channel);
404
405/*
406 * ctc_mpc_establish_connectivity
407 * (exported interface)
408 */
409void ctc_mpc_establish_connectivity(int port_num,
410 void (*callback)(int, int, int))
411{
Peter Tiedemann293d9842008-02-08 00:03:49 +0100412 struct net_device *dev;
413 struct mpc_group *grp;
414 struct ctcm_priv *priv;
415 struct channel *rch, *wch;
416
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200417 dev = ctcmpc_get_dev(port_num);
418 if (dev == NULL)
Peter Tiedemann293d9842008-02-08 00:03:49 +0100419 return;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200420 priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200421 grp = priv->mpcg;
Ursula Braun3c09e262010-08-12 01:58:28 +0000422 rch = priv->channel[CTCM_READ];
423 wch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100424
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200425 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
426 "%s(%s): state=%s",
427 CTCM_FUNTAIL, dev->name, fsm_getstate_str(grp->fsm));
Peter Tiedemann293d9842008-02-08 00:03:49 +0100428
429 grp->estconnfunc = callback;
430 grp->port_num = port_num;
431
432 switch (fsm_getstate(grp->fsm)) {
433 case MPCG_STATE_READY:
434 /* XID exchanges completed after PORT was activated */
435 /* Link station already active */
436 /* Maybe timing issue...retry callback */
437 fsm_deltimer(&grp->timer);
438 grp->estconn_callback_retries++;
439 if (grp->estconn_callback_retries < 4) {
440 if (grp->estconnfunc) {
441 grp->estconnfunc(grp->port_num, 0,
442 grp->group_max_buflen);
443 grp->estconnfunc = NULL;
444 }
445 } else {
446 /* there are problems...bail out */
447 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
448 grp->estconn_callback_retries = 0;
449 }
450 break;
451 case MPCG_STATE_INOP:
452 case MPCG_STATE_RESET:
453 /* MPC Group is not ready to start XID - min num of */
454 /* 1 read and 1 write channel have not been acquired*/
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200455
456 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
457 "%s(%s): REJECTED - inactive channels",
458 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100459 if (grp->estconnfunc) {
460 grp->estconnfunc(grp->port_num, -1, 0);
461 grp->estconnfunc = NULL;
462 }
463 break;
464 case MPCG_STATE_XID2INITW:
465 /* alloc channel was called but no XID exchange */
466 /* has occurred. initiate xside XID exchange */
467 /* make sure yside XID0 processing has not started */
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200468
Peter Tiedemann293d9842008-02-08 00:03:49 +0100469 if ((fsm_getstate(rch->fsm) > CH_XID0_PENDING) ||
470 (fsm_getstate(wch->fsm) > CH_XID0_PENDING)) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200471 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
472 "%s(%s): ABORT - PASSIVE XID",
473 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100474 break;
475 }
476 grp->send_qllc_disc = 1;
477 fsm_newstate(grp->fsm, MPCG_STATE_XID0IOWAIT);
478 fsm_deltimer(&grp->timer);
479 fsm_addtimer(&grp->timer, MPC_XID_TIMEOUT_VALUE,
480 MPCG_EVENT_TIMER, dev);
481 grp->outstanding_xid7 = 0;
482 grp->outstanding_xid7_p2 = 0;
483 grp->saved_xid2 = NULL;
484 if ((rch->in_mpcgroup) &&
485 (fsm_getstate(rch->fsm) == CH_XID0_PENDING))
486 fsm_event(grp->fsm, MPCG_EVENT_XID0DO, rch);
487 else {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200488 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
489 "%s(%s): RX-%s not ready for ACTIVE XID0",
490 CTCM_FUNTAIL, dev->name, rch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100491 if (grp->estconnfunc) {
492 grp->estconnfunc(grp->port_num, -1, 0);
493 grp->estconnfunc = NULL;
494 }
495 fsm_deltimer(&grp->timer);
496 goto done;
497 }
498 if ((wch->in_mpcgroup) &&
499 (fsm_getstate(wch->fsm) == CH_XID0_PENDING))
500 fsm_event(grp->fsm, MPCG_EVENT_XID0DO, wch);
501 else {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200502 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
503 "%s(%s): WX-%s not ready for ACTIVE XID0",
504 CTCM_FUNTAIL, dev->name, wch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100505 if (grp->estconnfunc) {
506 grp->estconnfunc(grp->port_num, -1, 0);
507 grp->estconnfunc = NULL;
508 }
509 fsm_deltimer(&grp->timer);
510 goto done;
511 }
512 break;
513 case MPCG_STATE_XID0IOWAIT:
514 /* already in active XID negotiations */
515 default:
516 break;
517 }
518
519done:
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200520 CTCM_PR_DEBUG("Exit %s()\n", __func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100521 return;
522}
523EXPORT_SYMBOL(ctc_mpc_establish_connectivity);
524
525/*
526 * ctc_mpc_dealloc_ch
527 * (exported interface)
528 */
529void ctc_mpc_dealloc_ch(int port_num)
530{
531 struct net_device *dev;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100532 struct ctcm_priv *priv;
533 struct mpc_group *grp;
534
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200535 dev = ctcmpc_get_dev(port_num);
536 if (dev == NULL)
537 return;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200538 priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100539 grp = priv->mpcg;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200540
541 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_DEBUG,
542 "%s: %s: refcount = %d\n",
David S. Miller9fbb7112010-10-13 09:11:26 -0700543 CTCM_FUNTAIL, dev->name, netdev_refcnt_read(dev));
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200544
545 fsm_deltimer(&priv->restart_timer);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100546 grp->channels_terminating = 0;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100547 fsm_deltimer(&grp->timer);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100548 grp->allochanfunc = NULL;
549 grp->estconnfunc = NULL;
550 grp->port_persist = 0;
551 grp->send_qllc_disc = 0;
552 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
553
554 ctcm_close(dev);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100555 return;
556}
557EXPORT_SYMBOL(ctc_mpc_dealloc_ch);
558
559/*
560 * ctc_mpc_flow_control
561 * (exported interface)
562 */
563void ctc_mpc_flow_control(int port_num, int flowc)
564{
Peter Tiedemann293d9842008-02-08 00:03:49 +0100565 struct ctcm_priv *priv;
566 struct mpc_group *grp;
567 struct net_device *dev;
568 struct channel *rch;
569 int mpcg_state;
570
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200571 dev = ctcmpc_get_dev(port_num);
572 if (dev == NULL)
Peter Tiedemann293d9842008-02-08 00:03:49 +0100573 return;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200574 priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100575 grp = priv->mpcg;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200576
577 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
578 "%s: %s: flowc = %d",
579 CTCM_FUNTAIL, dev->name, flowc);
580
Ursula Braun3c09e262010-08-12 01:58:28 +0000581 rch = priv->channel[CTCM_READ];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100582
583 mpcg_state = fsm_getstate(grp->fsm);
584 switch (flowc) {
585 case 1:
586 if (mpcg_state == MPCG_STATE_FLOWC)
587 break;
588 if (mpcg_state == MPCG_STATE_READY) {
589 if (grp->flow_off_called == 1)
590 grp->flow_off_called = 0;
591 else
592 fsm_newstate(grp->fsm, MPCG_STATE_FLOWC);
593 break;
594 }
595 break;
596 case 0:
597 if (mpcg_state == MPCG_STATE_FLOWC) {
598 fsm_newstate(grp->fsm, MPCG_STATE_READY);
599 /* ensure any data that has accumulated */
600 /* on the io_queue will now be sen t */
601 tasklet_schedule(&rch->ch_tasklet);
602 }
603 /* possible race condition */
604 if (mpcg_state == MPCG_STATE_READY) {
605 grp->flow_off_called = 1;
606 break;
607 }
608 break;
609 }
610
Peter Tiedemann293d9842008-02-08 00:03:49 +0100611}
612EXPORT_SYMBOL(ctc_mpc_flow_control);
613
614static int mpc_send_qllc_discontact(struct net_device *);
615
616/*
617 * helper function of ctcmpc_unpack_skb
618*/
619static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo)
620{
621 struct channel *rch = mpcginfo->ch;
622 struct net_device *dev = rch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200623 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100624 struct mpc_group *grp = priv->mpcg;
Ursula Braun3c09e262010-08-12 01:58:28 +0000625 struct channel *ch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100626
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200627 CTCM_PR_DEBUG("%s: ch=0x%p id=%s\n", __func__, ch, ch->id);
628 CTCM_D3_DUMP((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100629
630 grp->sweep_rsp_pend_num--;
631
632 if ((grp->sweep_req_pend_num == 0) &&
633 (grp->sweep_rsp_pend_num == 0)) {
634 fsm_deltimer(&ch->sweep_timer);
635 grp->in_sweep = 0;
636 rch->th_seq_num = 0x00;
637 ch->th_seq_num = 0x00;
638 ctcm_clear_busy_do(dev);
639 }
640
641 kfree(mpcginfo);
642
643 return;
644
645}
646
647/*
648 * helper function of mpc_rcvd_sweep_req
649 * which is a helper of ctcmpc_unpack_skb
650 */
651static void ctcmpc_send_sweep_resp(struct channel *rch)
652{
653 struct net_device *dev = rch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200654 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100655 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100656 struct th_sweep *header;
657 struct sk_buff *sweep_skb;
Ursula Braun3c09e262010-08-12 01:58:28 +0000658 struct channel *ch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100659
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200660 CTCM_PR_DEBUG("%s: ch=0x%p id=%s\n", __func__, rch, rch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100661
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200662 sweep_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC | GFP_DMA);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100663 if (sweep_skb == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200664 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
665 "%s(%s): sweep_skb allocation ERROR\n",
666 CTCM_FUNTAIL, rch->id);
Ursula Braunff2aed72011-05-12 18:45:06 +0000667 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100668 }
669
Julia Lawallae57b202010-05-16 21:15:13 +0000670 header = kmalloc(sizeof(struct th_sweep), gfp_type());
Peter Tiedemann293d9842008-02-08 00:03:49 +0100671
672 if (!header) {
673 dev_kfree_skb_any(sweep_skb);
Ursula Braunff2aed72011-05-12 18:45:06 +0000674 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100675 }
676
677 header->th.th_seg = 0x00 ;
678 header->th.th_ch_flag = TH_SWEEP_RESP;
679 header->th.th_blk_flag = 0x00;
680 header->th.th_is_xid = 0x00;
681 header->th.th_seq_num = 0x00;
682 header->sw.th_last_seq = ch->th_seq_num;
683
684 memcpy(skb_put(sweep_skb, TH_SWEEP_LENGTH), header, TH_SWEEP_LENGTH);
685
686 kfree(header);
687
688 dev->trans_start = jiffies;
689 skb_queue_tail(&ch->sweep_queue, sweep_skb);
690
691 fsm_addtimer(&ch->sweep_timer, 100, CTC_EVENT_RSWEEP_TIMER, ch);
692
693 return;
694
695done:
Joel A. Fowlere2fc8cb2009-03-24 03:27:49 +0000696 grp->in_sweep = 0;
697 ctcm_clear_busy_do(dev);
698 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100699
700 return;
701}
702
703/*
704 * helper function of ctcmpc_unpack_skb
705 */
706static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo)
707{
708 struct channel *rch = mpcginfo->ch;
709 struct net_device *dev = rch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200710 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100711 struct mpc_group *grp = priv->mpcg;
Ursula Braun3c09e262010-08-12 01:58:28 +0000712 struct channel *ch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100713
714 if (do_debug)
715 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200716 " %s(): ch=0x%p id=%s\n", __func__, ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100717
718 if (grp->in_sweep == 0) {
719 grp->in_sweep = 1;
720 ctcm_test_and_set_busy(dev);
Ursula Braun3c09e262010-08-12 01:58:28 +0000721 grp->sweep_req_pend_num = grp->active_channels[CTCM_READ];
722 grp->sweep_rsp_pend_num = grp->active_channels[CTCM_READ];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100723 }
724
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200725 CTCM_D3_DUMP((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100726
727 grp->sweep_req_pend_num--;
728 ctcmpc_send_sweep_resp(ch);
729 kfree(mpcginfo);
730 return;
731}
732
733/*
734 * MPC Group Station FSM definitions
735 */
736static const char *mpcg_event_names[] = {
737 [MPCG_EVENT_INOP] = "INOP Condition",
738 [MPCG_EVENT_DISCONC] = "Discontact Received",
739 [MPCG_EVENT_XID0DO] = "Channel Active - Start XID",
740 [MPCG_EVENT_XID2] = "XID2 Received",
741 [MPCG_EVENT_XID2DONE] = "XID0 Complete",
742 [MPCG_EVENT_XID7DONE] = "XID7 Complete",
743 [MPCG_EVENT_TIMER] = "XID Setup Timer",
744 [MPCG_EVENT_DOIO] = "XID DoIO",
745};
746
747static const char *mpcg_state_names[] = {
748 [MPCG_STATE_RESET] = "Reset",
749 [MPCG_STATE_INOP] = "INOP",
750 [MPCG_STATE_XID2INITW] = "Passive XID- XID0 Pending Start",
751 [MPCG_STATE_XID2INITX] = "Passive XID- XID0 Pending Complete",
752 [MPCG_STATE_XID7INITW] = "Passive XID- XID7 Pending P1 Start",
753 [MPCG_STATE_XID7INITX] = "Passive XID- XID7 Pending P2 Complete",
754 [MPCG_STATE_XID0IOWAIT] = "Active XID- XID0 Pending Start",
755 [MPCG_STATE_XID0IOWAIX] = "Active XID- XID0 Pending Complete",
756 [MPCG_STATE_XID7INITI] = "Active XID- XID7 Pending Start",
757 [MPCG_STATE_XID7INITZ] = "Active XID- XID7 Pending Complete ",
758 [MPCG_STATE_XID7INITF] = "XID - XID7 Complete ",
759 [MPCG_STATE_FLOWC] = "FLOW CONTROL ON",
760 [MPCG_STATE_READY] = "READY",
761};
762
763/*
764 * The MPC Group Station FSM
765 * 22 events
766 */
767static const fsm_node mpcg_fsm[] = {
768 { MPCG_STATE_RESET, MPCG_EVENT_INOP, mpc_action_go_inop },
769 { MPCG_STATE_INOP, MPCG_EVENT_INOP, mpc_action_nop },
770 { MPCG_STATE_FLOWC, MPCG_EVENT_INOP, mpc_action_go_inop },
771
772 { MPCG_STATE_READY, MPCG_EVENT_DISCONC, mpc_action_discontact },
773 { MPCG_STATE_READY, MPCG_EVENT_INOP, mpc_action_go_inop },
774
775 { MPCG_STATE_XID2INITW, MPCG_EVENT_XID0DO, mpc_action_doxid0 },
776 { MPCG_STATE_XID2INITW, MPCG_EVENT_XID2, mpc_action_rcvd_xid0 },
777 { MPCG_STATE_XID2INITW, MPCG_EVENT_INOP, mpc_action_go_inop },
778 { MPCG_STATE_XID2INITW, MPCG_EVENT_TIMER, mpc_action_timeout },
779 { MPCG_STATE_XID2INITW, MPCG_EVENT_DOIO, mpc_action_yside_xid },
780
781 { MPCG_STATE_XID2INITX, MPCG_EVENT_XID0DO, mpc_action_doxid0 },
782 { MPCG_STATE_XID2INITX, MPCG_EVENT_XID2, mpc_action_rcvd_xid0 },
783 { MPCG_STATE_XID2INITX, MPCG_EVENT_INOP, mpc_action_go_inop },
784 { MPCG_STATE_XID2INITX, MPCG_EVENT_TIMER, mpc_action_timeout },
785 { MPCG_STATE_XID2INITX, MPCG_EVENT_DOIO, mpc_action_yside_xid },
786
787 { MPCG_STATE_XID7INITW, MPCG_EVENT_XID2DONE, mpc_action_doxid7 },
788 { MPCG_STATE_XID7INITW, MPCG_EVENT_DISCONC, mpc_action_discontact },
789 { MPCG_STATE_XID7INITW, MPCG_EVENT_XID2, mpc_action_rcvd_xid7 },
790 { MPCG_STATE_XID7INITW, MPCG_EVENT_INOP, mpc_action_go_inop },
791 { MPCG_STATE_XID7INITW, MPCG_EVENT_TIMER, mpc_action_timeout },
792 { MPCG_STATE_XID7INITW, MPCG_EVENT_XID7DONE, mpc_action_doxid7 },
793 { MPCG_STATE_XID7INITW, MPCG_EVENT_DOIO, mpc_action_yside_xid },
794
795 { MPCG_STATE_XID7INITX, MPCG_EVENT_DISCONC, mpc_action_discontact },
796 { MPCG_STATE_XID7INITX, MPCG_EVENT_XID2, mpc_action_rcvd_xid7 },
797 { MPCG_STATE_XID7INITX, MPCG_EVENT_INOP, mpc_action_go_inop },
798 { MPCG_STATE_XID7INITX, MPCG_EVENT_XID7DONE, mpc_action_doxid7 },
799 { MPCG_STATE_XID7INITX, MPCG_EVENT_TIMER, mpc_action_timeout },
800 { MPCG_STATE_XID7INITX, MPCG_EVENT_DOIO, mpc_action_yside_xid },
801
802 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_XID0DO, mpc_action_doxid0 },
803 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_DISCONC, mpc_action_discontact },
804 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_XID2, mpc_action_rcvd_xid0 },
805 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_INOP, mpc_action_go_inop },
806 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_TIMER, mpc_action_timeout },
807 { MPCG_STATE_XID0IOWAIT, MPCG_EVENT_DOIO, mpc_action_xside_xid },
808
809 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_XID0DO, mpc_action_doxid0 },
810 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_DISCONC, mpc_action_discontact },
811 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_XID2, mpc_action_rcvd_xid0 },
812 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_INOP, mpc_action_go_inop },
813 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_TIMER, mpc_action_timeout },
814 { MPCG_STATE_XID0IOWAIX, MPCG_EVENT_DOIO, mpc_action_xside_xid },
815
816 { MPCG_STATE_XID7INITI, MPCG_EVENT_XID2DONE, mpc_action_doxid7 },
817 { MPCG_STATE_XID7INITI, MPCG_EVENT_XID2, mpc_action_rcvd_xid7 },
818 { MPCG_STATE_XID7INITI, MPCG_EVENT_DISCONC, mpc_action_discontact },
819 { MPCG_STATE_XID7INITI, MPCG_EVENT_INOP, mpc_action_go_inop },
820 { MPCG_STATE_XID7INITI, MPCG_EVENT_TIMER, mpc_action_timeout },
821 { MPCG_STATE_XID7INITI, MPCG_EVENT_XID7DONE, mpc_action_doxid7 },
822 { MPCG_STATE_XID7INITI, MPCG_EVENT_DOIO, mpc_action_xside_xid },
823
824 { MPCG_STATE_XID7INITZ, MPCG_EVENT_XID2, mpc_action_rcvd_xid7 },
825 { MPCG_STATE_XID7INITZ, MPCG_EVENT_XID7DONE, mpc_action_doxid7 },
826 { MPCG_STATE_XID7INITZ, MPCG_EVENT_DISCONC, mpc_action_discontact },
827 { MPCG_STATE_XID7INITZ, MPCG_EVENT_INOP, mpc_action_go_inop },
828 { MPCG_STATE_XID7INITZ, MPCG_EVENT_TIMER, mpc_action_timeout },
829 { MPCG_STATE_XID7INITZ, MPCG_EVENT_DOIO, mpc_action_xside_xid },
830
831 { MPCG_STATE_XID7INITF, MPCG_EVENT_INOP, mpc_action_go_inop },
832 { MPCG_STATE_XID7INITF, MPCG_EVENT_XID7DONE, mpc_action_go_ready },
833};
834
835static int mpcg_fsm_len = ARRAY_SIZE(mpcg_fsm);
836
837/*
838 * MPC Group Station FSM action
839 * CTCM_PROTO_MPC only
840 */
841static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
842{
843 struct net_device *dev = arg;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200844 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200845 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100846
Peter Tiedemann293d9842008-02-08 00:03:49 +0100847 if (grp == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200848 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
849 "%s(%s): No MPC group",
850 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100851 return;
852 }
853
854 fsm_deltimer(&grp->timer);
855
856 if (grp->saved_xid2->xid2_flag2 == 0x40) {
857 priv->xid->xid2_flag2 = 0x00;
858 if (grp->estconnfunc) {
859 grp->estconnfunc(grp->port_num, 1,
860 grp->group_max_buflen);
861 grp->estconnfunc = NULL;
862 } else if (grp->allochanfunc)
863 grp->send_qllc_disc = 1;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200864
865 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
866 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
867 "%s(%s): fails",
868 CTCM_FUNTAIL, dev->name);
869 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100870 }
871
872 grp->port_persist = 1;
873 grp->out_of_sequence = 0;
874 grp->estconn_called = 0;
875
876 tasklet_hi_schedule(&grp->mpc_tasklet2);
877
Peter Tiedemann293d9842008-02-08 00:03:49 +0100878 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100879}
880
881/*
882 * helper of ctcm_init_netdevice
883 * CTCM_PROTO_MPC only
884 */
885void mpc_group_ready(unsigned long adev)
886{
887 struct net_device *dev = (struct net_device *)adev;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200888 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200889 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100890 struct channel *ch = NULL;
891
Peter Tiedemann293d9842008-02-08 00:03:49 +0100892 if (grp == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200893 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
894 "%s(%s): No MPC group",
895 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100896 return;
897 }
898
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200899 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_NOTICE,
900 "%s: %s: GROUP TRANSITIONED TO READY, maxbuf = %d\n",
901 CTCM_FUNTAIL, dev->name, grp->group_max_buflen);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100902
903 fsm_newstate(grp->fsm, MPCG_STATE_READY);
904
905 /* Put up a read on the channel */
Ursula Braun3c09e262010-08-12 01:58:28 +0000906 ch = priv->channel[CTCM_READ];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100907 ch->pdu_seq = 0;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200908 CTCM_PR_DBGDATA("ctcmpc: %s() ToDCM_pdu_seq= %08x\n" ,
909 __func__, ch->pdu_seq);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100910
911 ctcmpc_chx_rxidle(ch->fsm, CTC_EVENT_START, ch);
912 /* Put the write channel in idle state */
Ursula Braun3c09e262010-08-12 01:58:28 +0000913 ch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +0100914 if (ch->collect_len > 0) {
915 spin_lock(&ch->collect_lock);
916 ctcm_purge_skb_queue(&ch->collect_queue);
917 ch->collect_len = 0;
918 spin_unlock(&ch->collect_lock);
919 }
920 ctcm_chx_txidle(ch->fsm, CTC_EVENT_START, ch);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100921 ctcm_clear_busy(dev);
922
923 if (grp->estconnfunc) {
924 grp->estconnfunc(grp->port_num, 0,
925 grp->group_max_buflen);
926 grp->estconnfunc = NULL;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200927 } else if (grp->allochanfunc)
928 grp->allochanfunc(grp->port_num, grp->group_max_buflen);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100929
930 grp->send_qllc_disc = 1;
931 grp->changed_side = 0;
932
Peter Tiedemann293d9842008-02-08 00:03:49 +0100933 return;
934
935}
936
937/*
938 * Increment the MPC Group Active Channel Counts
939 * helper of dev_action (called from channel fsm)
940 */
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200941void mpc_channel_action(struct channel *ch, int direction, int action)
Peter Tiedemann293d9842008-02-08 00:03:49 +0100942{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200943 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +0200944 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200945 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100946
947 if (grp == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200948 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
949 "%s(%s): No MPC group",
950 CTCM_FUNTAIL, dev->name);
951 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100952 }
953
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200954 CTCM_PR_DEBUG("enter %s: ch=0x%p id=%s\n", __func__, ch, ch->id);
955
956 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
957 "%s: %i / Grp:%s total_channels=%i, active_channels: "
958 "read=%i, write=%i\n", __func__, action,
959 fsm_getstate_str(grp->fsm), grp->num_channel_paths,
Ursula Braun3c09e262010-08-12 01:58:28 +0000960 grp->active_channels[CTCM_READ],
961 grp->active_channels[CTCM_WRITE]);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100962
963 if ((action == MPC_CHANNEL_ADD) && (ch->in_mpcgroup == 0)) {
964 grp->num_channel_paths++;
965 grp->active_channels[direction]++;
966 grp->outstanding_xid2++;
967 ch->in_mpcgroup = 1;
968
969 if (ch->xid_skb != NULL)
970 dev_kfree_skb_any(ch->xid_skb);
971
972 ch->xid_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT,
973 GFP_ATOMIC | GFP_DMA);
974 if (ch->xid_skb == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200975 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
976 "%s(%s): Couldn't alloc ch xid_skb\n",
977 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +0100978 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +0200979 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +0100980 }
981 ch->xid_skb_data = ch->xid_skb->data;
982 ch->xid_th = (struct th_header *)ch->xid_skb->data;
983 skb_put(ch->xid_skb, TH_HEADER_LENGTH);
984 ch->xid = (struct xid2 *)skb_tail_pointer(ch->xid_skb);
985 skb_put(ch->xid_skb, XID2_LENGTH);
986 ch->xid_id = skb_tail_pointer(ch->xid_skb);
987 ch->xid_skb->data = ch->xid_skb_data;
988 skb_reset_tail_pointer(ch->xid_skb);
989 ch->xid_skb->len = 0;
990
991 memcpy(skb_put(ch->xid_skb, grp->xid_skb->len),
992 grp->xid_skb->data,
993 grp->xid_skb->len);
994
Ursula Braun3c09e262010-08-12 01:58:28 +0000995 ch->xid->xid2_dlc_type =
996 ((CHANNEL_DIRECTION(ch->flags) == CTCM_READ)
Peter Tiedemann293d9842008-02-08 00:03:49 +0100997 ? XID2_READ_SIDE : XID2_WRITE_SIDE);
998
Ursula Braun3c09e262010-08-12 01:58:28 +0000999 if (CHANNEL_DIRECTION(ch->flags) == CTCM_WRITE)
Peter Tiedemann293d9842008-02-08 00:03:49 +01001000 ch->xid->xid2_buf_len = 0x00;
1001
1002 ch->xid_skb->data = ch->xid_skb_data;
1003 skb_reset_tail_pointer(ch->xid_skb);
1004 ch->xid_skb->len = 0;
1005
1006 fsm_newstate(ch->fsm, CH_XID0_PENDING);
1007
Ursula Braun3c09e262010-08-12 01:58:28 +00001008 if ((grp->active_channels[CTCM_READ] > 0) &&
1009 (grp->active_channels[CTCM_WRITE] > 0) &&
Peter Tiedemann293d9842008-02-08 00:03:49 +01001010 (fsm_getstate(grp->fsm) < MPCG_STATE_XID2INITW)) {
1011 fsm_newstate(grp->fsm, MPCG_STATE_XID2INITW);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001012 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_NOTICE,
1013 "%s: %s: MPC GROUP CHANNELS ACTIVE\n",
1014 __func__, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001015 }
1016 } else if ((action == MPC_CHANNEL_REMOVE) &&
1017 (ch->in_mpcgroup == 1)) {
1018 ch->in_mpcgroup = 0;
1019 grp->num_channel_paths--;
1020 grp->active_channels[direction]--;
1021
1022 if (ch->xid_skb != NULL)
1023 dev_kfree_skb_any(ch->xid_skb);
1024 ch->xid_skb = NULL;
1025
1026 if (grp->channels_terminating)
1027 goto done;
1028
Ursula Braun3c09e262010-08-12 01:58:28 +00001029 if (((grp->active_channels[CTCM_READ] == 0) &&
1030 (grp->active_channels[CTCM_WRITE] > 0))
1031 || ((grp->active_channels[CTCM_WRITE] == 0) &&
1032 (grp->active_channels[CTCM_READ] > 0)))
Peter Tiedemann293d9842008-02-08 00:03:49 +01001033 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
1034 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01001035done:
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001036 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
1037 "exit %s: %i / Grp:%s total_channels=%i, active_channels: "
1038 "read=%i, write=%i\n", __func__, action,
1039 fsm_getstate_str(grp->fsm), grp->num_channel_paths,
Ursula Braun3c09e262010-08-12 01:58:28 +00001040 grp->active_channels[CTCM_READ],
1041 grp->active_channels[CTCM_WRITE]);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001042
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001043 CTCM_PR_DEBUG("exit %s: ch=0x%p id=%s\n", __func__, ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001044}
1045
1046/**
1047 * Unpack a just received skb and hand it over to
1048 * upper layers.
1049 * special MPC version of unpack_skb.
1050 *
1051 * ch The channel where this skb has been received.
1052 * pskb The received skb.
1053 */
1054static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
1055{
1056 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001057 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001058 struct mpc_group *grp = priv->mpcg;
1059 struct pdu *curr_pdu;
1060 struct mpcg_info *mpcginfo;
1061 struct th_header *header = NULL;
1062 struct th_sweep *sweep = NULL;
1063 int pdu_last_seen = 0;
1064 __u32 new_len;
1065 struct sk_buff *skb;
1066 int skblen;
1067 int sendrc = 0;
1068
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001069 CTCM_PR_DEBUG("ctcmpc enter: %s() %s cp:%i ch:%s\n",
1070 __func__, dev->name, smp_processor_id(), ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001071
1072 header = (struct th_header *)pskb->data;
1073 if ((header->th_seg == 0) &&
1074 (header->th_ch_flag == 0) &&
1075 (header->th_blk_flag == 0) &&
1076 (header->th_seq_num == 0))
1077 /* nothing for us */ goto done;
1078
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001079 CTCM_PR_DBGDATA("%s: th_header\n", __func__);
1080 CTCM_D3_DUMP((char *)header, TH_HEADER_LENGTH);
1081 CTCM_PR_DBGDATA("%s: pskb len: %04x \n", __func__, pskb->len);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001082
1083 pskb->dev = dev;
1084 pskb->ip_summed = CHECKSUM_UNNECESSARY;
1085 skb_pull(pskb, TH_HEADER_LENGTH);
1086
1087 if (likely(header->th_ch_flag == TH_HAS_PDU)) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001088 CTCM_PR_DBGDATA("%s: came into th_has_pdu\n", __func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001089 if ((fsm_getstate(grp->fsm) == MPCG_STATE_FLOWC) ||
1090 ((fsm_getstate(grp->fsm) == MPCG_STATE_READY) &&
1091 (header->th_seq_num != ch->th_seq_num + 1) &&
1092 (ch->th_seq_num != 0))) {
1093 /* This is NOT the next segment *
1094 * we are not the correct race winner *
1095 * go away and let someone else win *
1096 * BUT..this only applies if xid negot *
1097 * is done *
1098 */
1099 grp->out_of_sequence += 1;
1100 __skb_push(pskb, TH_HEADER_LENGTH);
1101 skb_queue_tail(&ch->io_queue, pskb);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001102 CTCM_PR_DBGDATA("%s: th_seq_num expect:%08x "
1103 "got:%08x\n", __func__,
1104 ch->th_seq_num + 1, header->th_seq_num);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001105
1106 return;
1107 }
1108 grp->out_of_sequence = 0;
1109 ch->th_seq_num = header->th_seq_num;
1110
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001111 CTCM_PR_DBGDATA("ctcmpc: %s() FromVTAM_th_seq=%08x\n",
1112 __func__, ch->th_seq_num);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001113
1114 if (unlikely(fsm_getstate(grp->fsm) != MPCG_STATE_READY))
1115 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001116 while ((pskb->len > 0) && !pdu_last_seen) {
1117 curr_pdu = (struct pdu *)pskb->data;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001118
1119 CTCM_PR_DBGDATA("%s: pdu_header\n", __func__);
1120 CTCM_D3_DUMP((char *)pskb->data, PDU_HEADER_LENGTH);
1121 CTCM_PR_DBGDATA("%s: pskb len: %04x \n",
1122 __func__, pskb->len);
1123
Peter Tiedemann293d9842008-02-08 00:03:49 +01001124 skb_pull(pskb, PDU_HEADER_LENGTH);
1125
1126 if (curr_pdu->pdu_flag & PDU_LAST)
1127 pdu_last_seen = 1;
1128 if (curr_pdu->pdu_flag & PDU_CNTL)
1129 pskb->protocol = htons(ETH_P_SNAP);
1130 else
1131 pskb->protocol = htons(ETH_P_SNA_DIX);
1132
1133 if ((pskb->len <= 0) || (pskb->len > ch->max_bufsize)) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001134 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1135 "%s(%s): Dropping packet with "
1136 "illegal siize %d",
1137 CTCM_FUNTAIL, dev->name, pskb->len);
1138
Peter Tiedemann293d9842008-02-08 00:03:49 +01001139 priv->stats.rx_dropped++;
1140 priv->stats.rx_length_errors++;
1141 goto done;
1142 }
1143 skb_reset_mac_header(pskb);
1144 new_len = curr_pdu->pdu_offset;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001145 CTCM_PR_DBGDATA("%s: new_len: %04x \n",
1146 __func__, new_len);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001147 if ((new_len == 0) || (new_len > pskb->len)) {
1148 /* should never happen */
1149 /* pskb len must be hosed...bail out */
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001150 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1151 "%s(%s): non valid pdu_offset: %04x",
1152 /* "data may be lost", */
1153 CTCM_FUNTAIL, dev->name, new_len);
1154 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001155 }
1156 skb = __dev_alloc_skb(new_len+4, GFP_ATOMIC);
1157
1158 if (!skb) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001159 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1160 "%s(%s): MEMORY allocation error",
1161 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001162 priv->stats.rx_dropped++;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001163 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001164 goto done;
1165 }
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001166 memcpy(skb_put(skb, new_len), pskb->data, new_len);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001167
1168 skb_reset_mac_header(skb);
1169 skb->dev = pskb->dev;
1170 skb->protocol = pskb->protocol;
1171 skb->ip_summed = CHECKSUM_UNNECESSARY;
1172 *((__u32 *) skb_push(skb, 4)) = ch->pdu_seq;
1173 ch->pdu_seq++;
1174
Peter Tiedemann293d9842008-02-08 00:03:49 +01001175 if (do_debug_data) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001176 ctcm_pr_debug("%s: ToDCM_pdu_seq= %08x\n",
1177 __func__, ch->pdu_seq);
1178 ctcm_pr_debug("%s: skb:%0lx "
1179 "skb len: %d \n", __func__,
1180 (unsigned long)skb, skb->len);
1181 ctcm_pr_debug("%s: up to 32 bytes "
1182 "of pdu_data sent\n", __func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001183 ctcmpc_dump32((char *)skb->data, skb->len);
1184 }
1185
1186 skblen = skb->len;
1187 sendrc = netif_rx(skb);
1188 priv->stats.rx_packets++;
1189 priv->stats.rx_bytes += skblen;
1190 skb_pull(pskb, new_len); /* point to next PDU */
1191 }
1192 } else {
Julia Lawallae57b202010-05-16 21:15:13 +00001193 mpcginfo = kmalloc(sizeof(struct mpcg_info), gfp_type());
Peter Tiedemann293d9842008-02-08 00:03:49 +01001194 if (mpcginfo == NULL)
1195 goto done;
1196
1197 mpcginfo->ch = ch;
1198 mpcginfo->th = header;
1199 mpcginfo->skb = pskb;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001200 CTCM_PR_DEBUG("%s: Not PDU - may be control pkt\n",
1201 __func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001202 /* it's a sweep? */
1203 sweep = (struct th_sweep *)pskb->data;
1204 mpcginfo->sweep = sweep;
1205 if (header->th_ch_flag == TH_SWEEP_REQ)
1206 mpc_rcvd_sweep_req(mpcginfo);
1207 else if (header->th_ch_flag == TH_SWEEP_RESP)
1208 mpc_rcvd_sweep_resp(mpcginfo);
1209 else if (header->th_blk_flag == TH_DATA_IS_XID) {
1210 struct xid2 *thisxid = (struct xid2 *)pskb->data;
1211 skb_pull(pskb, XID2_LENGTH);
1212 mpcginfo->xid = thisxid;
1213 fsm_event(grp->fsm, MPCG_EVENT_XID2, mpcginfo);
1214 } else if (header->th_blk_flag == TH_DISCONTACT)
1215 fsm_event(grp->fsm, MPCG_EVENT_DISCONC, mpcginfo);
1216 else if (header->th_seq_num != 0) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001217 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1218 "%s(%s): control pkt expected\n",
1219 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001220 priv->stats.rx_dropped++;
1221 /* mpcginfo only used for non-data transfers */
1222 kfree(mpcginfo);
1223 if (do_debug_data)
1224 ctcmpc_dump_skb(pskb, -8);
1225 }
1226 }
1227done:
1228
1229 dev_kfree_skb_any(pskb);
1230 if (sendrc == NET_RX_DROP) {
Peter Tiedemann2a7c6f22008-12-25 13:39:54 +01001231 dev_warn(&dev->dev,
1232 "The network backlog for %s is exceeded, "
1233 "package dropped\n", __func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001234 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
1235 }
1236
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001237 CTCM_PR_DEBUG("exit %s: %s: ch=0x%p id=%s\n",
1238 __func__, dev->name, ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001239}
1240
1241/**
1242 * tasklet helper for mpc's skb unpacking.
1243 *
1244 * ch The channel to work on.
1245 * Allow flow control back pressure to occur here.
1246 * Throttling back channel can result in excessive
1247 * channel inactivity and system deact of channel
1248 */
1249void ctcmpc_bh(unsigned long thischan)
1250{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001251 struct channel *ch = (struct channel *)thischan;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001252 struct sk_buff *skb;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001253 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001254 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001255 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001256
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001257 CTCM_PR_DEBUG("%s cp:%i enter: %s() %s\n",
1258 dev->name, smp_processor_id(), __func__, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001259 /* caller has requested driver to throttle back */
1260 while ((fsm_getstate(grp->fsm) != MPCG_STATE_FLOWC) &&
1261 (skb = skb_dequeue(&ch->io_queue))) {
1262 ctcmpc_unpack_skb(ch, skb);
1263 if (grp->out_of_sequence > 20) {
1264 /* assume data loss has occurred if */
1265 /* missing seq_num for extended */
1266 /* period of time */
1267 grp->out_of_sequence = 0;
1268 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
1269 break;
1270 }
1271 if (skb == skb_peek(&ch->io_queue))
1272 break;
1273 }
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001274 CTCM_PR_DEBUG("exit %s: %s: ch=0x%p id=%s\n",
1275 __func__, dev->name, ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001276 return;
1277}
1278
1279/*
1280 * MPC Group Initializations
1281 */
1282struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv)
1283{
1284 struct mpc_group *grp;
1285
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001286 CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
1287 "Enter %s(%p)", CTCM_FUNTAIL, priv);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001288
1289 grp = kzalloc(sizeof(struct mpc_group), GFP_KERNEL);
1290 if (grp == NULL)
1291 return NULL;
1292
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001293 grp->fsm = init_fsm("mpcg", mpcg_state_names, mpcg_event_names,
1294 MPCG_NR_STATES, MPCG_NR_EVENTS, mpcg_fsm,
1295 mpcg_fsm_len, GFP_KERNEL);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001296 if (grp->fsm == NULL) {
1297 kfree(grp);
1298 return NULL;
1299 }
1300
1301 fsm_newstate(grp->fsm, MPCG_STATE_RESET);
1302 fsm_settimer(grp->fsm, &grp->timer);
1303
1304 grp->xid_skb =
1305 __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC | GFP_DMA);
1306 if (grp->xid_skb == NULL) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001307 kfree_fsm(grp->fsm);
1308 kfree(grp);
1309 return NULL;
1310 }
1311 /* base xid for all channels in group */
1312 grp->xid_skb_data = grp->xid_skb->data;
1313 grp->xid_th = (struct th_header *)grp->xid_skb->data;
1314 memcpy(skb_put(grp->xid_skb, TH_HEADER_LENGTH),
1315 &thnorm, TH_HEADER_LENGTH);
1316
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001317 grp->xid = (struct xid2 *)skb_tail_pointer(grp->xid_skb);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001318 memcpy(skb_put(grp->xid_skb, XID2_LENGTH), &init_xid, XID2_LENGTH);
1319 grp->xid->xid2_adj_id = jiffies | 0xfff00000;
1320 grp->xid->xid2_sender_id = jiffies;
1321
1322 grp->xid_id = skb_tail_pointer(grp->xid_skb);
1323 memcpy(skb_put(grp->xid_skb, 4), "VTAM", 4);
1324
1325 grp->rcvd_xid_skb =
1326 __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC|GFP_DMA);
1327 if (grp->rcvd_xid_skb == NULL) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001328 kfree_fsm(grp->fsm);
1329 dev_kfree_skb(grp->xid_skb);
1330 kfree(grp);
1331 return NULL;
1332 }
1333 grp->rcvd_xid_data = grp->rcvd_xid_skb->data;
1334 grp->rcvd_xid_th = (struct th_header *)grp->rcvd_xid_skb->data;
1335 memcpy(skb_put(grp->rcvd_xid_skb, TH_HEADER_LENGTH),
1336 &thnorm, TH_HEADER_LENGTH);
1337 grp->saved_xid2 = NULL;
1338 priv->xid = grp->xid;
1339 priv->mpcg = grp;
1340 return grp;
1341}
1342
1343/*
1344 * The MPC Group Station FSM
1345 */
1346
1347/*
1348 * MPC Group Station FSM actions
1349 * CTCM_PROTO_MPC only
1350 */
1351
1352/**
1353 * NOP action for statemachines
1354 */
1355static void mpc_action_nop(fsm_instance *fi, int event, void *arg)
1356{
1357}
1358
1359/*
1360 * invoked when the device transitions to dev_stopped
1361 * MPC will stop each individual channel if a single XID failure
1362 * occurs, or will intitiate all channels be stopped if a GROUP
1363 * level failure occurs.
1364 */
1365static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg)
1366{
1367 struct net_device *dev = arg;
1368 struct ctcm_priv *priv;
1369 struct mpc_group *grp;
Ursula Braunff2aed72011-05-12 18:45:06 +00001370 struct channel *wch;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001371
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001372 BUG_ON(dev == NULL);
1373 CTCM_PR_DEBUG("Enter %s: %s\n", __func__, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001374
Peter Tiedemann261893d2008-08-21 17:10:24 +02001375 priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001376 grp = priv->mpcg;
1377 grp->flow_off_called = 0;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001378 fsm_deltimer(&grp->timer);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001379 if (grp->channels_terminating)
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001380 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001381
1382 grp->channels_terminating = 1;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001383 grp->saved_state = fsm_getstate(grp->fsm);
1384 fsm_newstate(grp->fsm, MPCG_STATE_INOP);
1385 if (grp->saved_state > MPCG_STATE_XID7INITF)
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001386 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
1387 "%s(%s): MPC GROUP INOPERATIVE",
1388 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001389 if ((grp->saved_state != MPCG_STATE_RESET) ||
1390 /* dealloc_channel has been called */
Joel A. Fowlere2fc8cb2009-03-24 03:27:49 +00001391 (grp->port_persist == 0))
Peter Tiedemann293d9842008-02-08 00:03:49 +01001392 fsm_deltimer(&priv->restart_timer);
1393
Ursula Braun3c09e262010-08-12 01:58:28 +00001394 wch = priv->channel[CTCM_WRITE];
Peter Tiedemann293d9842008-02-08 00:03:49 +01001395
1396 switch (grp->saved_state) {
1397 case MPCG_STATE_RESET:
1398 case MPCG_STATE_INOP:
1399 case MPCG_STATE_XID2INITW:
1400 case MPCG_STATE_XID0IOWAIT:
1401 case MPCG_STATE_XID2INITX:
1402 case MPCG_STATE_XID7INITW:
1403 case MPCG_STATE_XID7INITX:
1404 case MPCG_STATE_XID0IOWAIX:
1405 case MPCG_STATE_XID7INITI:
1406 case MPCG_STATE_XID7INITZ:
1407 case MPCG_STATE_XID7INITF:
1408 break;
1409 case MPCG_STATE_FLOWC:
1410 case MPCG_STATE_READY:
1411 default:
1412 tasklet_hi_schedule(&wch->ch_disc_tasklet);
1413 }
1414
1415 grp->xid2_tgnum = 0;
1416 grp->group_max_buflen = 0; /*min of all received */
1417 grp->outstanding_xid2 = 0;
1418 grp->outstanding_xid7 = 0;
1419 grp->outstanding_xid7_p2 = 0;
1420 grp->saved_xid2 = NULL;
1421 grp->xidnogood = 0;
1422 grp->changed_side = 0;
1423
1424 grp->rcvd_xid_skb->data = grp->rcvd_xid_data;
1425 skb_reset_tail_pointer(grp->rcvd_xid_skb);
1426 grp->rcvd_xid_skb->len = 0;
1427 grp->rcvd_xid_th = (struct th_header *)grp->rcvd_xid_skb->data;
1428 memcpy(skb_put(grp->rcvd_xid_skb, TH_HEADER_LENGTH), &thnorm,
1429 TH_HEADER_LENGTH);
1430
1431 if (grp->send_qllc_disc == 1) {
1432 grp->send_qllc_disc = 0;
Ursula Braunff2aed72011-05-12 18:45:06 +00001433 mpc_send_qllc_discontact(dev);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001434 }
1435
1436 /* DO NOT issue DEV_EVENT_STOP directly out of this code */
1437 /* This can result in INOP of VTAM PU due to halting of */
1438 /* outstanding IO which causes a sense to be returned */
1439 /* Only about 3 senses are allowed and then IOS/VTAM will*/
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001440 /* become unreachable without manual intervention */
1441 if ((grp->port_persist == 1) || (grp->alloc_called)) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001442 grp->alloc_called = 0;
1443 fsm_deltimer(&priv->restart_timer);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001444 fsm_addtimer(&priv->restart_timer, 500, DEV_EVENT_RESTART, dev);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001445 fsm_newstate(grp->fsm, MPCG_STATE_RESET);
1446 if (grp->saved_state > MPCG_STATE_XID7INITF)
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001447 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ALWAYS,
1448 "%s(%s): MPC GROUP RECOVERY SCHEDULED",
1449 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001450 } else {
1451 fsm_deltimer(&priv->restart_timer);
1452 fsm_addtimer(&priv->restart_timer, 500, DEV_EVENT_STOP, dev);
1453 fsm_newstate(grp->fsm, MPCG_STATE_RESET);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001454 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ALWAYS,
1455 "%s(%s): NO MPC GROUP RECOVERY ATTEMPTED",
1456 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001457 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01001458}
1459
1460/**
1461 * Handle mpc group action timeout.
1462 * MPC Group Station FSM action
1463 * CTCM_PROTO_MPC only
1464 *
1465 * fi An instance of an mpc_group fsm.
1466 * event The event, just happened.
1467 * arg Generic pointer, casted from net_device * upon call.
1468 */
1469static void mpc_action_timeout(fsm_instance *fi, int event, void *arg)
1470{
1471 struct net_device *dev = arg;
1472 struct ctcm_priv *priv;
1473 struct mpc_group *grp;
1474 struct channel *wch;
1475 struct channel *rch;
1476
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001477 BUG_ON(dev == NULL);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001478
Peter Tiedemann261893d2008-08-21 17:10:24 +02001479 priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001480 grp = priv->mpcg;
Ursula Braun3c09e262010-08-12 01:58:28 +00001481 wch = priv->channel[CTCM_WRITE];
1482 rch = priv->channel[CTCM_READ];
Peter Tiedemann293d9842008-02-08 00:03:49 +01001483
1484 switch (fsm_getstate(grp->fsm)) {
1485 case MPCG_STATE_XID2INITW:
1486 /* Unless there is outstanding IO on the */
1487 /* channel just return and wait for ATTN */
1488 /* interrupt to begin XID negotiations */
1489 if ((fsm_getstate(rch->fsm) == CH_XID0_PENDING) &&
1490 (fsm_getstate(wch->fsm) == CH_XID0_PENDING))
1491 break;
1492 default:
1493 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
1494 }
1495
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001496 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
1497 "%s: dev=%s exit",
1498 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001499 return;
1500}
1501
1502/*
1503 * MPC Group Station FSM action
1504 * CTCM_PROTO_MPC only
1505 */
1506void mpc_action_discontact(fsm_instance *fi, int event, void *arg)
1507{
1508 struct mpcg_info *mpcginfo = arg;
1509 struct channel *ch = mpcginfo->ch;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001510 struct net_device *dev;
1511 struct ctcm_priv *priv;
1512 struct mpc_group *grp;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001513
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001514 if (ch) {
1515 dev = ch->netdev;
1516 if (dev) {
Peter Tiedemann261893d2008-08-21 17:10:24 +02001517 priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001518 if (priv) {
1519 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
1520 "%s: %s: %s\n",
1521 CTCM_FUNTAIL, dev->name, ch->id);
1522 grp = priv->mpcg;
1523 grp->send_qllc_disc = 1;
1524 fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
1525 }
1526 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01001527 }
1528
Peter Tiedemann293d9842008-02-08 00:03:49 +01001529 return;
1530}
1531
1532/*
1533 * MPC Group Station - not part of FSM
1534 * CTCM_PROTO_MPC only
1535 * called from add_channel in ctcm_main.c
1536 */
1537void mpc_action_send_discontact(unsigned long thischan)
1538{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001539 int rc;
1540 struct channel *ch = (struct channel *)thischan;
1541 unsigned long saveflags = 0;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001542
1543 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
1544 rc = ccw_device_start(ch->cdev, &ch->ccw[15],
1545 (unsigned long)ch, 0xff, 0);
1546 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
1547
1548 if (rc != 0) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001549 ctcm_ccw_check_rc(ch, rc, (char *)__func__);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001550 }
1551
Peter Tiedemann293d9842008-02-08 00:03:49 +01001552 return;
1553}
1554
1555
1556/*
1557 * helper function of mpc FSM
1558 * CTCM_PROTO_MPC only
1559 * mpc_action_rcvd_xid7
1560*/
1561static int mpc_validate_xid(struct mpcg_info *mpcginfo)
1562{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001563 struct channel *ch = mpcginfo->ch;
1564 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001565 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001566 struct mpc_group *grp = priv->mpcg;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001567 struct xid2 *xid = mpcginfo->xid;
1568 int rc = 0;
1569 __u64 our_id = 0;
1570 __u64 their_id = 0;
1571 int len = TH_HEADER_LENGTH + PDU_HEADER_LENGTH;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001572
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001573 CTCM_PR_DEBUG("Enter %s: xid=%p\n", __func__, xid);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001574
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001575 if (xid == NULL) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001576 rc = 1;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001577 /* XID REJECTED: xid == NULL */
1578 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1579 "%s(%s): xid = NULL",
1580 CTCM_FUNTAIL, ch->id);
1581 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001582 }
1583
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001584 CTCM_D3_DUMP((char *)xid, XID2_LENGTH);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001585
1586 /*the received direction should be the opposite of ours */
Ursula Braun3c09e262010-08-12 01:58:28 +00001587 if (((CHANNEL_DIRECTION(ch->flags) == CTCM_READ) ? XID2_WRITE_SIDE :
Peter Tiedemann293d9842008-02-08 00:03:49 +01001588 XID2_READ_SIDE) != xid->xid2_dlc_type) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001589 rc = 2;
1590 /* XID REJECTED: r/w channel pairing mismatch */
1591 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1592 "%s(%s): r/w channel pairing mismatch",
1593 CTCM_FUNTAIL, ch->id);
1594 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001595 }
1596
1597 if (xid->xid2_dlc_type == XID2_READ_SIDE) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001598 CTCM_PR_DEBUG("%s: grpmaxbuf:%d xid2buflen:%d\n", __func__,
1599 grp->group_max_buflen, xid->xid2_buf_len);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001600
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001601 if (grp->group_max_buflen == 0 || grp->group_max_buflen >
1602 xid->xid2_buf_len - len)
Peter Tiedemann293d9842008-02-08 00:03:49 +01001603 grp->group_max_buflen = xid->xid2_buf_len - len;
1604 }
1605
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001606 if (grp->saved_xid2 == NULL) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001607 grp->saved_xid2 =
1608 (struct xid2 *)skb_tail_pointer(grp->rcvd_xid_skb);
1609
1610 memcpy(skb_put(grp->rcvd_xid_skb,
1611 XID2_LENGTH), xid, XID2_LENGTH);
1612 grp->rcvd_xid_skb->data = grp->rcvd_xid_data;
1613
1614 skb_reset_tail_pointer(grp->rcvd_xid_skb);
1615 grp->rcvd_xid_skb->len = 0;
1616
1617 /* convert two 32 bit numbers into 1 64 bit for id compare */
1618 our_id = (__u64)priv->xid->xid2_adj_id;
1619 our_id = our_id << 32;
1620 our_id = our_id + priv->xid->xid2_sender_id;
1621 their_id = (__u64)xid->xid2_adj_id;
1622 their_id = their_id << 32;
1623 their_id = their_id + xid->xid2_sender_id;
1624 /* lower id assume the xside role */
1625 if (our_id < their_id) {
1626 grp->roll = XSIDE;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001627 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
1628 "%s(%s): WE HAVE LOW ID - TAKE XSIDE",
1629 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001630 } else {
1631 grp->roll = YSIDE;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001632 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
1633 "%s(%s): WE HAVE HIGH ID - TAKE YSIDE",
1634 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001635 }
1636
1637 } else {
1638 if (xid->xid2_flag4 != grp->saved_xid2->xid2_flag4) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001639 rc = 3;
1640 /* XID REJECTED: xid flag byte4 mismatch */
1641 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1642 "%s(%s): xid flag byte4 mismatch",
1643 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001644 }
1645 if (xid->xid2_flag2 == 0x40) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001646 rc = 4;
1647 /* XID REJECTED - xid NOGOOD */
1648 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1649 "%s(%s): xid NOGOOD",
1650 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001651 }
1652 if (xid->xid2_adj_id != grp->saved_xid2->xid2_adj_id) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001653 rc = 5;
1654 /* XID REJECTED - Adjacent Station ID Mismatch */
1655 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1656 "%s(%s): Adjacent Station ID Mismatch",
1657 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001658 }
1659 if (xid->xid2_sender_id != grp->saved_xid2->xid2_sender_id) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001660 rc = 6;
1661 /* XID REJECTED - Sender Address Mismatch */
1662 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1663 "%s(%s): Sender Address Mismatch",
1664 CTCM_FUNTAIL, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001665 }
1666 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01001667done:
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001668 if (rc) {
Peter Tiedemann2a7c6f22008-12-25 13:39:54 +01001669 dev_warn(&dev->dev,
1670 "The XID used in the MPC protocol is not valid, "
1671 "rc = %d\n", rc);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001672 priv->xid->xid2_flag2 = 0x40;
1673 grp->saved_xid2->xid2_flag2 = 0x40;
1674 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01001675
Peter Tiedemann293d9842008-02-08 00:03:49 +01001676 return rc;
1677}
1678
1679/*
1680 * MPC Group Station FSM action
1681 * CTCM_PROTO_MPC only
1682 */
1683static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
1684{
1685 struct channel *ch = arg;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001686 int rc = 0;
1687 int gotlock = 0;
1688 unsigned long saveflags = 0; /* avoids compiler warning with
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001689 spin_unlock_irqrestore */
Peter Tiedemann293d9842008-02-08 00:03:49 +01001690
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001691 CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
1692 __func__, smp_processor_id(), ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001693
1694 if (ctcm_checkalloc_buffer(ch))
1695 goto done;
1696
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001697 /*
1698 * skb data-buffer referencing:
1699 */
Peter Tiedemann293d9842008-02-08 00:03:49 +01001700 ch->trans_skb->data = ch->trans_skb_data;
1701 skb_reset_tail_pointer(ch->trans_skb);
1702 ch->trans_skb->len = 0;
1703 /* result of the previous 3 statements is NOT always
1704 * already set after ctcm_checkalloc_buffer
1705 * because of possible reuse of the trans_skb
1706 */
1707 memset(ch->trans_skb->data, 0, 16);
1708 ch->rcvd_xid_th = (struct th_header *)ch->trans_skb_data;
1709 /* check is main purpose here: */
1710 skb_put(ch->trans_skb, TH_HEADER_LENGTH);
1711 ch->rcvd_xid = (struct xid2 *)skb_tail_pointer(ch->trans_skb);
1712 /* check is main purpose here: */
1713 skb_put(ch->trans_skb, XID2_LENGTH);
1714 ch->rcvd_xid_id = skb_tail_pointer(ch->trans_skb);
1715 /* cleanup back to startpoint */
1716 ch->trans_skb->data = ch->trans_skb_data;
1717 skb_reset_tail_pointer(ch->trans_skb);
1718 ch->trans_skb->len = 0;
1719
1720 /* non-checking rewrite of above skb data-buffer referencing: */
1721 /*
1722 memset(ch->trans_skb->data, 0, 16);
1723 ch->rcvd_xid_th = (struct th_header *)ch->trans_skb_data;
1724 ch->rcvd_xid = (struct xid2 *)(ch->trans_skb_data + TH_HEADER_LENGTH);
1725 ch->rcvd_xid_id = ch->trans_skb_data + TH_HEADER_LENGTH + XID2_LENGTH;
1726 */
1727
1728 ch->ccw[8].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1729 ch->ccw[8].count = 0;
1730 ch->ccw[8].cda = 0x00;
1731
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001732 if (!(ch->xid_th && ch->xid && ch->xid_id))
1733 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_INFO,
1734 "%s(%s): xid_th=%p, xid=%p, xid_id=%p",
1735 CTCM_FUNTAIL, ch->id, ch->xid_th, ch->xid, ch->xid_id);
1736
Peter Tiedemann293d9842008-02-08 00:03:49 +01001737 if (side == XSIDE) {
1738 /* mpc_action_xside_xid */
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001739 if (ch->xid_th == NULL)
1740 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001741 ch->ccw[9].cmd_code = CCW_CMD_WRITE;
1742 ch->ccw[9].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1743 ch->ccw[9].count = TH_HEADER_LENGTH;
1744 ch->ccw[9].cda = virt_to_phys(ch->xid_th);
1745
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001746 if (ch->xid == NULL)
1747 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001748 ch->ccw[10].cmd_code = CCW_CMD_WRITE;
1749 ch->ccw[10].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1750 ch->ccw[10].count = XID2_LENGTH;
1751 ch->ccw[10].cda = virt_to_phys(ch->xid);
1752
1753 ch->ccw[11].cmd_code = CCW_CMD_READ;
1754 ch->ccw[11].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1755 ch->ccw[11].count = TH_HEADER_LENGTH;
1756 ch->ccw[11].cda = virt_to_phys(ch->rcvd_xid_th);
1757
1758 ch->ccw[12].cmd_code = CCW_CMD_READ;
1759 ch->ccw[12].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1760 ch->ccw[12].count = XID2_LENGTH;
1761 ch->ccw[12].cda = virt_to_phys(ch->rcvd_xid);
1762
1763 ch->ccw[13].cmd_code = CCW_CMD_READ;
1764 ch->ccw[13].cda = virt_to_phys(ch->rcvd_xid_id);
1765
1766 } else { /* side == YSIDE : mpc_action_yside_xid */
1767 ch->ccw[9].cmd_code = CCW_CMD_READ;
1768 ch->ccw[9].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1769 ch->ccw[9].count = TH_HEADER_LENGTH;
1770 ch->ccw[9].cda = virt_to_phys(ch->rcvd_xid_th);
1771
1772 ch->ccw[10].cmd_code = CCW_CMD_READ;
1773 ch->ccw[10].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1774 ch->ccw[10].count = XID2_LENGTH;
1775 ch->ccw[10].cda = virt_to_phys(ch->rcvd_xid);
1776
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001777 if (ch->xid_th == NULL)
1778 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001779 ch->ccw[11].cmd_code = CCW_CMD_WRITE;
1780 ch->ccw[11].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1781 ch->ccw[11].count = TH_HEADER_LENGTH;
1782 ch->ccw[11].cda = virt_to_phys(ch->xid_th);
1783
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001784 if (ch->xid == NULL)
1785 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001786 ch->ccw[12].cmd_code = CCW_CMD_WRITE;
1787 ch->ccw[12].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1788 ch->ccw[12].count = XID2_LENGTH;
1789 ch->ccw[12].cda = virt_to_phys(ch->xid);
1790
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001791 if (ch->xid_id == NULL)
1792 goto done;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001793 ch->ccw[13].cmd_code = CCW_CMD_WRITE;
1794 ch->ccw[13].cda = virt_to_phys(ch->xid_id);
1795
1796 }
1797 ch->ccw[13].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1798 ch->ccw[13].count = 4;
1799
1800 ch->ccw[14].cmd_code = CCW_CMD_NOOP;
1801 ch->ccw[14].flags = CCW_FLAG_SLI;
1802 ch->ccw[14].count = 0;
1803 ch->ccw[14].cda = 0;
1804
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001805 CTCM_CCW_DUMP((char *)&ch->ccw[8], sizeof(struct ccw1) * 7);
1806 CTCM_D3_DUMP((char *)ch->xid_th, TH_HEADER_LENGTH);
1807 CTCM_D3_DUMP((char *)ch->xid, XID2_LENGTH);
1808 CTCM_D3_DUMP((char *)ch->xid_id, 4);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001809
Peter Tiedemann293d9842008-02-08 00:03:49 +01001810 if (!in_irq()) {
1811 /* Such conditional locking is a known problem for
1812 * sparse because its static undeterministic.
1813 * Warnings should be ignored here. */
1814 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
1815 gotlock = 1;
1816 }
1817
1818 fsm_addtimer(&ch->timer, 5000 , CTC_EVENT_TIMER, ch);
1819 rc = ccw_device_start(ch->cdev, &ch->ccw[8],
1820 (unsigned long)ch, 0xff, 0);
1821
1822 if (gotlock) /* see remark above about conditional locking */
1823 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
1824
1825 if (rc != 0) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001826 ctcm_ccw_check_rc(ch, rc,
1827 (side == XSIDE) ? "x-side XID" : "y-side XID");
1828 }
1829
1830done:
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001831 CTCM_PR_DEBUG("Exit %s: ch=0x%p id=%s\n",
1832 __func__, ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001833 return;
1834
1835}
1836
1837/*
1838 * MPC Group Station FSM action
1839 * CTCM_PROTO_MPC only
1840 */
1841static void mpc_action_xside_xid(fsm_instance *fsm, int event, void *arg)
1842{
1843 mpc_action_side_xid(fsm, arg, XSIDE);
1844}
1845
1846/*
1847 * MPC Group Station FSM action
1848 * CTCM_PROTO_MPC only
1849 */
1850static void mpc_action_yside_xid(fsm_instance *fsm, int event, void *arg)
1851{
1852 mpc_action_side_xid(fsm, arg, YSIDE);
1853}
1854
1855/*
1856 * MPC Group Station FSM action
1857 * CTCM_PROTO_MPC only
1858 */
1859static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg)
1860{
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001861 struct channel *ch = arg;
1862 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001863 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001864 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001865
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001866 CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
1867 __func__, smp_processor_id(), ch, ch->id);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001868
1869 if (ch->xid == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001870 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
1871 "%s(%s): ch->xid == NULL",
1872 CTCM_FUNTAIL, dev->name);
1873 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001874 }
1875
1876 fsm_newstate(ch->fsm, CH_XID0_INPROGRESS);
1877
1878 ch->xid->xid2_option = XID2_0;
1879
1880 switch (fsm_getstate(grp->fsm)) {
1881 case MPCG_STATE_XID2INITW:
1882 case MPCG_STATE_XID2INITX:
1883 ch->ccw[8].cmd_code = CCW_CMD_SENSE_CMD;
1884 break;
1885 case MPCG_STATE_XID0IOWAIT:
1886 case MPCG_STATE_XID0IOWAIX:
1887 ch->ccw[8].cmd_code = CCW_CMD_WRITE_CTL;
1888 break;
1889 }
1890
1891 fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch);
1892
Peter Tiedemann293d9842008-02-08 00:03:49 +01001893 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001894}
1895
1896/*
1897 * MPC Group Station FSM action
1898 * CTCM_PROTO_MPC only
1899*/
1900static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg)
1901{
1902 struct net_device *dev = arg;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001903 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001904 struct mpc_group *grp = NULL;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001905 int direction;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001906 int send = 0;
1907
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001908 if (priv)
1909 grp = priv->mpcg;
Joel A. Fowlere2fc8cb2009-03-24 03:27:49 +00001910 if (grp == NULL)
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001911 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001912
Ursula Braun3c09e262010-08-12 01:58:28 +00001913 for (direction = CTCM_READ; direction <= CTCM_WRITE; direction++) {
Peter Tiedemann293d9842008-02-08 00:03:49 +01001914 struct channel *ch = priv->channel[direction];
1915 struct xid2 *thisxid = ch->xid;
1916 ch->xid_skb->data = ch->xid_skb_data;
1917 skb_reset_tail_pointer(ch->xid_skb);
1918 ch->xid_skb->len = 0;
1919 thisxid->xid2_option = XID2_7;
1920 send = 0;
1921
1922 /* xid7 phase 1 */
1923 if (grp->outstanding_xid7_p2 > 0) {
1924 if (grp->roll == YSIDE) {
1925 if (fsm_getstate(ch->fsm) == CH_XID7_PENDING1) {
1926 fsm_newstate(ch->fsm, CH_XID7_PENDING2);
1927 ch->ccw[8].cmd_code = CCW_CMD_SENSE_CMD;
1928 memcpy(skb_put(ch->xid_skb,
1929 TH_HEADER_LENGTH),
1930 &thdummy, TH_HEADER_LENGTH);
1931 send = 1;
1932 }
1933 } else if (fsm_getstate(ch->fsm) < CH_XID7_PENDING2) {
1934 fsm_newstate(ch->fsm, CH_XID7_PENDING2);
1935 ch->ccw[8].cmd_code = CCW_CMD_WRITE_CTL;
1936 memcpy(skb_put(ch->xid_skb,
1937 TH_HEADER_LENGTH),
1938 &thnorm, TH_HEADER_LENGTH);
1939 send = 1;
1940 }
1941 } else {
1942 /* xid7 phase 2 */
1943 if (grp->roll == YSIDE) {
1944 if (fsm_getstate(ch->fsm) < CH_XID7_PENDING4) {
1945 fsm_newstate(ch->fsm, CH_XID7_PENDING4);
1946 memcpy(skb_put(ch->xid_skb,
1947 TH_HEADER_LENGTH),
1948 &thnorm, TH_HEADER_LENGTH);
1949 ch->ccw[8].cmd_code = CCW_CMD_WRITE_CTL;
1950 send = 1;
1951 }
1952 } else if (fsm_getstate(ch->fsm) == CH_XID7_PENDING3) {
1953 fsm_newstate(ch->fsm, CH_XID7_PENDING4);
1954 ch->ccw[8].cmd_code = CCW_CMD_SENSE_CMD;
1955 memcpy(skb_put(ch->xid_skb, TH_HEADER_LENGTH),
1956 &thdummy, TH_HEADER_LENGTH);
1957 send = 1;
1958 }
1959 }
1960
1961 if (send)
1962 fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch);
1963 }
1964
Peter Tiedemann293d9842008-02-08 00:03:49 +01001965 return;
1966}
1967
1968/*
1969 * MPC Group Station FSM action
1970 * CTCM_PROTO_MPC only
1971 */
1972static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg)
1973{
1974
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001975 struct mpcg_info *mpcginfo = arg;
1976 struct channel *ch = mpcginfo->ch;
1977 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02001978 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001979 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +01001980
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02001981 CTCM_PR_DEBUG("%s: ch-id:%s xid2:%i xid7:%i xidt_p2:%i \n",
1982 __func__, ch->id, grp->outstanding_xid2,
1983 grp->outstanding_xid7, grp->outstanding_xid7_p2);
Peter Tiedemann293d9842008-02-08 00:03:49 +01001984
1985 if (fsm_getstate(ch->fsm) < CH_XID7_PENDING)
1986 fsm_newstate(ch->fsm, CH_XID7_PENDING);
1987
1988 grp->outstanding_xid2--;
1989 grp->outstanding_xid7++;
1990 grp->outstanding_xid7_p2++;
1991
1992 /* must change state before validating xid to */
1993 /* properly handle interim interrupts received*/
1994 switch (fsm_getstate(grp->fsm)) {
1995 case MPCG_STATE_XID2INITW:
1996 fsm_newstate(grp->fsm, MPCG_STATE_XID2INITX);
1997 mpc_validate_xid(mpcginfo);
1998 break;
1999 case MPCG_STATE_XID0IOWAIT:
2000 fsm_newstate(grp->fsm, MPCG_STATE_XID0IOWAIX);
2001 mpc_validate_xid(mpcginfo);
2002 break;
2003 case MPCG_STATE_XID2INITX:
2004 if (grp->outstanding_xid2 == 0) {
2005 fsm_newstate(grp->fsm, MPCG_STATE_XID7INITW);
2006 mpc_validate_xid(mpcginfo);
2007 fsm_event(grp->fsm, MPCG_EVENT_XID2DONE, dev);
2008 }
2009 break;
2010 case MPCG_STATE_XID0IOWAIX:
2011 if (grp->outstanding_xid2 == 0) {
2012 fsm_newstate(grp->fsm, MPCG_STATE_XID7INITI);
2013 mpc_validate_xid(mpcginfo);
2014 fsm_event(grp->fsm, MPCG_EVENT_XID2DONE, dev);
2015 }
2016 break;
2017 }
2018 kfree(mpcginfo);
2019
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002020 CTCM_PR_DEBUG("ctcmpc:%s() %s xid2:%i xid7:%i xidt_p2:%i \n",
2021 __func__, ch->id, grp->outstanding_xid2,
2022 grp->outstanding_xid7, grp->outstanding_xid7_p2);
2023 CTCM_PR_DEBUG("ctcmpc:%s() %s grpstate: %s chanstate: %s \n",
2024 __func__, ch->id,
2025 fsm_getstate_str(grp->fsm), fsm_getstate_str(ch->fsm));
Peter Tiedemann293d9842008-02-08 00:03:49 +01002026 return;
2027
2028}
2029
2030
2031/*
2032 * MPC Group Station FSM action
2033 * CTCM_PROTO_MPC only
2034 */
2035static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg)
2036{
2037 struct mpcg_info *mpcginfo = arg;
2038 struct channel *ch = mpcginfo->ch;
2039 struct net_device *dev = ch->netdev;
Peter Tiedemann261893d2008-08-21 17:10:24 +02002040 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002041 struct mpc_group *grp = priv->mpcg;
2042
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002043 CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
2044 __func__, smp_processor_id(), ch, ch->id);
2045 CTCM_PR_DEBUG("%s: outstanding_xid7: %i, outstanding_xid7_p2: %i\n",
2046 __func__, grp->outstanding_xid7, grp->outstanding_xid7_p2);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002047
2048 grp->outstanding_xid7--;
2049 ch->xid_skb->data = ch->xid_skb_data;
2050 skb_reset_tail_pointer(ch->xid_skb);
2051 ch->xid_skb->len = 0;
2052
2053 switch (fsm_getstate(grp->fsm)) {
2054 case MPCG_STATE_XID7INITI:
2055 fsm_newstate(grp->fsm, MPCG_STATE_XID7INITZ);
2056 mpc_validate_xid(mpcginfo);
2057 break;
2058 case MPCG_STATE_XID7INITW:
2059 fsm_newstate(grp->fsm, MPCG_STATE_XID7INITX);
2060 mpc_validate_xid(mpcginfo);
2061 break;
2062 case MPCG_STATE_XID7INITZ:
2063 case MPCG_STATE_XID7INITX:
2064 if (grp->outstanding_xid7 == 0) {
2065 if (grp->outstanding_xid7_p2 > 0) {
2066 grp->outstanding_xid7 =
2067 grp->outstanding_xid7_p2;
2068 grp->outstanding_xid7_p2 = 0;
2069 } else
2070 fsm_newstate(grp->fsm, MPCG_STATE_XID7INITF);
2071
2072 mpc_validate_xid(mpcginfo);
2073 fsm_event(grp->fsm, MPCG_EVENT_XID7DONE, dev);
2074 break;
2075 }
2076 mpc_validate_xid(mpcginfo);
2077 break;
2078 }
Peter Tiedemann293d9842008-02-08 00:03:49 +01002079 kfree(mpcginfo);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002080 return;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002081}
2082
2083/*
2084 * mpc_action helper of an MPC Group Station FSM action
2085 * CTCM_PROTO_MPC only
2086 */
2087static int mpc_send_qllc_discontact(struct net_device *dev)
2088{
Peter Tiedemann293d9842008-02-08 00:03:49 +01002089 __u32 new_len = 0;
2090 struct sk_buff *skb;
2091 struct qllc *qllcptr;
Peter Tiedemann261893d2008-08-21 17:10:24 +02002092 struct ctcm_priv *priv = dev->ml_priv;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002093 struct mpc_group *grp = priv->mpcg;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002094
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002095 CTCM_PR_DEBUG("%s: GROUP STATE: %s\n",
2096 __func__, mpcg_state_names[grp->saved_state]);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002097
2098 switch (grp->saved_state) {
2099 /*
2100 * establish conn callback function is
2101 * preferred method to report failure
2102 */
2103 case MPCG_STATE_XID0IOWAIT:
2104 case MPCG_STATE_XID0IOWAIX:
2105 case MPCG_STATE_XID7INITI:
2106 case MPCG_STATE_XID7INITZ:
2107 case MPCG_STATE_XID2INITW:
2108 case MPCG_STATE_XID2INITX:
2109 case MPCG_STATE_XID7INITW:
2110 case MPCG_STATE_XID7INITX:
2111 if (grp->estconnfunc) {
2112 grp->estconnfunc(grp->port_num, -1, 0);
2113 grp->estconnfunc = NULL;
2114 break;
2115 }
2116 case MPCG_STATE_FLOWC:
2117 case MPCG_STATE_READY:
2118 grp->send_qllc_disc = 2;
2119 new_len = sizeof(struct qllc);
2120 qllcptr = kzalloc(new_len, gfp_type() | GFP_DMA);
2121 if (qllcptr == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002122 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
2123 "%s(%s): qllcptr allocation error",
2124 CTCM_FUNTAIL, dev->name);
2125 return -ENOMEM;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002126 }
2127
2128 qllcptr->qllc_address = 0xcc;
2129 qllcptr->qllc_commands = 0x03;
2130
2131 skb = __dev_alloc_skb(new_len, GFP_ATOMIC);
2132
2133 if (skb == NULL) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002134 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
2135 "%s(%s): skb allocation error",
2136 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002137 priv->stats.rx_dropped++;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002138 kfree(qllcptr);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002139 return -ENOMEM;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002140 }
2141
2142 memcpy(skb_put(skb, new_len), qllcptr, new_len);
2143 kfree(qllcptr);
2144
2145 if (skb_headroom(skb) < 4) {
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002146 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
2147 "%s(%s): skb_headroom error",
2148 CTCM_FUNTAIL, dev->name);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002149 dev_kfree_skb_any(skb);
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002150 return -ENOMEM;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002151 }
2152
Ursula Braun3c09e262010-08-12 01:58:28 +00002153 *((__u32 *)skb_push(skb, 4)) =
2154 priv->channel[CTCM_READ]->pdu_seq;
2155 priv->channel[CTCM_READ]->pdu_seq++;
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002156 CTCM_PR_DBGDATA("ctcmpc: %s ToDCM_pdu_seq= %08x\n",
Ursula Braun3c09e262010-08-12 01:58:28 +00002157 __func__, priv->channel[CTCM_READ]->pdu_seq);
Peter Tiedemann293d9842008-02-08 00:03:49 +01002158
2159 /* receipt of CC03 resets anticipated sequence number on
2160 receiving side */
Ursula Braun3c09e262010-08-12 01:58:28 +00002161 priv->channel[CTCM_READ]->pdu_seq = 0x00;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002162 skb_reset_mac_header(skb);
2163 skb->dev = dev;
2164 skb->protocol = htons(ETH_P_SNAP);
2165 skb->ip_summed = CHECKSUM_UNNECESSARY;
2166
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002167 CTCM_D3_DUMP(skb->data, (sizeof(struct qllc) + 4));
Peter Tiedemann293d9842008-02-08 00:03:49 +01002168
2169 netif_rx(skb);
2170 break;
2171 default:
2172 break;
2173
2174 }
2175
Peter Tiedemannaa3f2cb2008-07-18 15:24:57 +02002176 return 0;
Peter Tiedemann293d9842008-02-08 00:03:49 +01002177}
2178/* --- This is the END my friend --- */
2179