patch-2.1.42 linux/drivers/isdn/hisax/isdnl2.c
Next file: linux/drivers/isdn/hisax/isdnl2.h
Previous file: linux/drivers/isdn/hisax/isdnl1.h
Back to the patch index
Back to the overall index
- Lines: 1589
- Date:
Wed May 28 10:49:09 1997
- Orig file:
v2.1.41/linux/drivers/isdn/hisax/isdnl2.c
- Orig date:
Thu Feb 27 10:57:29 1997
diff -u --recursive --new-file v2.1.41/linux/drivers/isdn/hisax/isdnl2.c linux/drivers/isdn/hisax/isdnl2.c
@@ -1,4 +1,4 @@
-/* $Id: isdnl2.c,v 1.7 1997/02/09 00:25:44 keil Exp $
+/* $Id: isdnl2.c,v 1.10 1997/05/06 09:38:13 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,6 +7,19 @@
* Fritz Elfert
*
* $Log: isdnl2.c,v $
+ * Revision 1.10 1997/05/06 09:38:13 keil
+ * Bugfixes: - clear ack queue entries after resend
+ * - acknowlege each frame to linklevel
+ * - UA for SABM is Response, not command
+ * - only RR was send as supervisor frame (X.75 hangs after a
+ * sequence error)
+ *
+ * Revision 1.9 1997/04/07 23:02:11 keil
+ * missing braces
+ *
+ * Revision 1.8 1997/04/06 22:59:59 keil
+ * Using SKB's; changing function names; some minor changes
+ *
* Revision 1.7 1997/02/09 00:25:44 keil
* new interface handling, one interface per card
*
@@ -35,14 +48,12 @@
#include "hisax.h"
#include "isdnl2.h"
-#define TIMER_1 2000
-
-const char *l2_revision = "$Revision: 1.7 $";
+const char *l2_revision = "$Revision: 1.10 $";
static void l2m_debug(struct FsmInst *fi, char *s);
struct Fsm l2fsm =
-{NULL, 0, 0};
+{NULL, 0, 0, NULL, NULL};
enum {
ST_L2_1,
@@ -118,6 +129,33 @@
static int l2addrsize(struct Layer2 *tsp);
+static void
+InitWin(struct Layer2 *l2)
+{
+ int i;
+
+ for (i = 0; i < MAX_WINDOW; i++)
+ l2->windowar[i] = NULL;
+}
+
+static void
+ReleaseWin(struct Layer2 *l2)
+{
+ int i, cnt = 0;
+
+
+ for (i = 0; i < MAX_WINDOW; i++) {
+ if (l2->windowar[i]) {
+ cnt++;
+ SET_SKB_FREE(l2->windowar[i]);
+ dev_kfree_skb(l2->windowar[i], FREE_WRITE);
+ l2->windowar[i] = NULL;
+ }
+ }
+ if (cnt)
+ printk(KERN_WARNING "isdl2 freed %d skbuffs in release\n", cnt);
+}
+
static int
cansend(struct PStack *st)
{
@@ -130,10 +168,12 @@
static void
discard_i_queue(struct PStack *st)
{
- struct BufHeader *ibh;
+ struct sk_buff *skb;
- while (!BufQueueUnlink(&ibh, &st->l2.i_queue))
- BufPoolRelease(ibh);
+ while ((skb = skb_dequeue(&st->l2.i_queue))) {
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
+ }
}
int
@@ -150,9 +190,9 @@
static int
sethdraddr(struct Layer2 *tsp,
- struct BufHeader *ibh, int rsp)
+ u_char * header, int rsp)
{
- byte *ptr = DATAPTR(ibh);
+ u_char *ptr = header;
int crbit;
if (tsp->laptype == LAPD) {
@@ -176,16 +216,16 @@
static void
enqueue_ui(struct PStack *st,
- struct BufHeader *ibh)
+ struct sk_buff *skb)
{
- st->l2.l2l1(st, PH_DATA, ibh);
+ st->l2.l2l1(st, PH_DATA, skb);
}
static void
enqueue_super(struct PStack *st,
- struct BufHeader *ibh)
+ struct sk_buff *skb)
{
- st->l2.l2l1(st, PH_DATA, ibh);
+ st->l2.l2l1(st, PH_DATA, skb);
}
static int
@@ -207,11 +247,13 @@
if (l2->va != nr) {
while (l2->va != nr) {
l2->va = (l2->va + 1) % (l2->extended ? 128 : 8);
- BufPoolRelease(l2->windowar[l2->sow]);
+ SET_SKB_FREE(l2->windowar[l2->sow]);
+ dev_kfree_skb(l2->windowar[l2->sow], FREE_WRITE);
+ l2->windowar[l2->sow] = NULL;
l2->sow = (l2->sow + 1) % l2->window;
+ if (st->l4.l2writewakeup)
+ st->l4.l2writewakeup(st);
}
- if (st->l4.l2writewakeup)
- st->l4.l2writewakeup(st);
}
}
@@ -225,38 +267,51 @@
}
static void
-l2s2(struct FsmInst *fi, int event, void *arg)
+l2_send_ui(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
-
- byte *ptr;
+ struct sk_buff *skb = arg;
+ u_char header[MAX_HEADER_LEN];
int i;
- i = sethdraddr(&(st->l2), ibh, CMD);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = UI;
-
- enqueue_ui(st, ibh);
+ i = sethdraddr(&(st->l2), header, CMD);
+ header[i++] = UI;
+ memcpy(skb_push(skb, i), header, i);
+ enqueue_ui(st, skb);
}
static void
-l2s3(struct FsmInst *fi, int event, void *arg)
+l2_receive_ui(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
+ struct sk_buff *skb = arg;
- st->l2.l2l3(st, DL_UNIT_DATA, ibh);
+ skb_pull(skb, l2headersize(&st->l2, 1));
+ st->l2.l2l3(st, DL_UNIT_DATA, skb);
+}
+
+inline void
+send_uframe(struct PStack *st, u_char cmd, u_char cr)
+{
+ struct sk_buff *skb;
+ u_char tmp[MAX_HEADER_LEN];
+ int i;
+
+ i = sethdraddr(&st->l2, tmp, cr);
+ tmp[i++] = cmd;
+ if (!(skb = alloc_skb(i, GFP_ATOMIC))) {
+ printk(KERN_WARNING "isdl2 can't alloc sbbuff for send_uframe\n");
+ return;
+ }
+ memcpy(skb_put(skb, i), tmp, i);
+ enqueue_super(st, skb);
}
static void
establishlink(struct FsmInst *fi)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh;
- int i;
- byte *ptr;
+ u_char cmd;
FsmChangeState(fi, ST_L2_5);
st->l2.rc = 0;
@@ -266,34 +321,21 @@
l2m_debug(&st->l2.l2m, "FAT 1");
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15))
- return;
- i = sethdraddr(&st->l2, ibh, CMD);
- ptr = DATAPTR(ibh);
- ptr += i;
- if (st->l2.extended)
- *ptr = SABME | 0x10;
- else
- *ptr = 0x3f;
- ibh->datasize = i + 1;
-
- enqueue_super(st, ibh);
+ cmd = (st->l2.extended ? SABME : SABM) | 0x10;
+ send_uframe(st, cmd, CMD);
}
static void
-l2s11(struct FsmInst *fi, int event, void *arg)
+l2_establish(struct FsmInst *fi, int event, void *arg)
{
establishlink(fi);
}
static void
-l2s13(struct FsmInst *fi, int event, void *arg)
+l2_send_disconn(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct Channel *chanp = st->l4.userdata;
- byte *ptr;
- struct BufHeader *ibh;
- int i;
FsmChangeState(fi, ST_L2_6);
@@ -308,70 +350,71 @@
l2m_debug(&st->l2.l2m, "FAT 2");
- if ((chanp->impair == 2) && (st->l2.laptype == LAPB))
- goto nodisc;
+ if (!((chanp->impair == 2) && (st->l2.laptype == LAPB)))
+ send_uframe(st, DISC | 0x10, CMD);
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 9))
- return;
- i = sethdraddr(&(st->l2), ibh, CMD);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = DISC | 0x10;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
-
- nodisc:
discard_i_queue(st);
}
static void
-l2s12(struct FsmInst *fi, int event, void *arg)
+l2_got_SABMX(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- byte *ptr;
- int i, p;
-
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(&(st->l2));
- p = (*ptr) & 0x10;
- BufPoolRelease(ibh);
+ struct sk_buff *skb = arg;
+ int est = 1, state;
+ u_char PollFlag;
+
+ state = fi->state;
+
+ skb_pull(skb, l2addrsize(&(st->l2)));
+ PollFlag = *skb->data & 0x10;
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
+
+ if (ST_L2_4 != state)
+ if (st->l2.vs != st->l2.va) {
+ discard_i_queue(st);
+ est = 1;
+ } else
+ est = 0;
st->l2.vs = 0;
st->l2.va = 0;
st->l2.vr = 0;
st->l2.sow = 0;
- FsmChangeState(fi, ST_L2_7);
+ if (ST_L2_7 != state)
+ FsmChangeState(fi, ST_L2_7);
+
+ send_uframe(st, UA | PollFlag, RSP);
+
+ if (st->l2.t200_running) {
+ FsmDelTimer(&st->l2.t200_timer, 15);
+ st->l2.t200_running = 0;
+ }
if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 3))
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 3");
- st->l2.l2man(st, DL_ESTABLISH, NULL);
-
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 10))
- return;
- i = sethdraddr(&(st->l2), ibh, RSP);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = UA | p;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
+ if (est)
+ st->l2.l2man(st, DL_ESTABLISH, NULL);
+ if (ST_L2_8 == state)
+ if (skb_queue_len(&st->l2.i_queue) && cansend(st))
+ st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
static void
-l2s14(struct FsmInst *fi, int event, void *arg)
+l2_got_disconn(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
+ struct sk_buff *skb = arg;
struct Channel *chanp = st->l4.userdata;
- byte *ptr;
- int i, p;
+ u_char PollFlag;
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(&(st->l2));
- p = (*ptr) & 0x10;
- BufPoolRelease(ibh);
+ skb_pull(skb, l2addrsize(&(st->l2)));
+ PollFlag = *skb->data & 0x10;
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
FsmChangeState(fi, ST_L2_4);
@@ -380,68 +423,41 @@
FsmDelTimer(&st->l2.t200_timer, 4);
st->l2.t200_running = 0;
}
- if ((chanp->impair == 1) && (st->l2.laptype == LAPB))
- goto noresponse;
-
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 11))
- return;
- i = sethdraddr(&(st->l2), ibh, RSP);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = UA | p;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
+ if (!((chanp->impair == 1) && (st->l2.laptype == LAPB)))
+ send_uframe(st, UA | PollFlag, RSP);
- noresponse:
st->l2.l2man(st, DL_RELEASE, NULL);
-
}
static void
-l2s14_1(struct FsmInst *fi, int event, void *arg)
+l2_got_st4_disc(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
+ struct sk_buff *skb = arg;
struct Channel *chanp = st->l4.userdata;
- byte *ptr;
- int i, p;
-
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(&(st->l2));
- p = (*ptr) & 0x10;
- BufPoolRelease(ibh);
-
- if ((chanp->impair == 1) && (st->l2.laptype == LAPB))
- goto noresponse;
-
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 11))
- return;
- i = sethdraddr(&(st->l2), ibh, RSP);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = DM | (p ? 0x10 : 0x0);
+ u_char PollFlag;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
+ skb_pull(skb, l2addrsize(&(st->l2)));
+ PollFlag = *skb->data & 0x10;
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
- noresponse:
+ if (!((chanp->impair == 1) && (st->l2.laptype == LAPB)))
+ send_uframe(st, DM | (PollFlag ? 0x10 : 0x0), RSP);
}
static void
-l2s5(struct FsmInst *fi, int event, void *arg)
+l2_got_ua_establish(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- int f;
- byte *data;
-
- data = DATAPTR(ibh);
- data += l2addrsize(&(st->l2));
-
- f = *data & 0x10;
- BufPoolRelease(ibh);
+ struct sk_buff *skb = arg;
+ u_char f;
+ skb_pull(skb, l2addrsize(&(st->l2)));
+ f = *skb->data & 0x10;
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
if (f) {
st->l2.vs = 0;
st->l2.va = 0;
@@ -454,25 +470,21 @@
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 4");
-
st->l2.l2man(st, DL_ESTABLISH, NULL);
}
}
static void
-l2s15(struct FsmInst *fi, int event, void *arg)
+l2_got_ua_disconn(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- int f;
- byte *data;
-
- data = DATAPTR(ibh);
- data += l2addrsize(&st->l2);
-
- f = *data & 0x10;
- BufPoolRelease(ibh);
+ struct sk_buff *skb = arg;
+ u_char f;
+ skb_pull(skb, l2addrsize(&(st->l2)));
+ f = *skb->data & 0x10;
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
if (f) {
FsmDelTimer(&st->l2.t200_timer, 6);
FsmChangeState(fi, ST_L2_4);
@@ -480,31 +492,39 @@
}
}
-static void
-enquiry_response(struct PStack *st)
+inline void
+enquiry_cr(struct PStack *st, u_char typ, u_char cr, u_char pf)
{
- struct BufHeader *ibh2;
- int i;
- byte *ptr;
+ struct sk_buff *skb;
struct Layer2 *l2;
+ u_char tmp[MAX_HEADER_LEN];
+ int i;
l2 = &st->l2;
- if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 16)) {
- i = sethdraddr(l2, ibh2, RSP);
- ptr = DATAPTR(ibh2);
- ptr += i;
-
- if (l2->extended) {
- *ptr++ = RR;
- *ptr++ = (l2->vr << 1) | 0x1;
- i += 2;
- } else {
- *ptr++ = (l2->vr << 5) | 0x1 | 0x10;
- i += 1;
- }
- ibh2->datasize = i;
- enqueue_super(st, ibh2);
+ i = sethdraddr(l2, tmp, cr);
+ if (l2->extended) {
+ tmp[i++] = typ;
+ tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0);
+ } else
+ tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0);
+ if (!(skb = alloc_skb(i, GFP_ATOMIC))) {
+ printk(KERN_WARNING "isdl2 can't alloc sbbuff for enquiry_cr\n");
+ return;
}
+ memcpy(skb_put(skb, i), tmp, i);
+ enqueue_super(st, skb);
+}
+
+inline void
+enquiry_response(struct PStack *st, u_char typ, u_char final)
+{
+ enquiry_cr(st, typ, RSP, final);
+}
+
+inline void
+enquiry_command(struct PStack *st, u_char typ, u_char poll)
+{
+ enquiry_cr(st, typ, CMD, poll);
}
static void
@@ -515,88 +535,74 @@
}
static void
-l2s6(struct FsmInst *fi, int event, void *arg)
+l2_got_st7_RR(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct Channel *chanp = st->l4.userdata;
- struct BufHeader *ibh = arg;
- int p, seq, rsp;
- byte *ptr;
+ struct sk_buff *skb = arg;
+ int PollFlag, seq, rsp;
struct Layer2 *l2;
l2 = &st->l2;
- ptr = DATAPTR(ibh);
-
- if (l2->laptype == LAPD) {
- rsp = ptr[0] & 0x2;
- if (l2->orig)
- rsp = !rsp;
- } else {
- rsp = ptr[0] == 0x3;
- if (l2->orig)
- rsp = !rsp;
- }
-
- ptr += l2addrsize(l2);
+ if (l2->laptype == LAPD)
+ rsp = *skb->data & 0x2;
+ else
+ rsp = *skb->data == 0x3;
+ if (l2->orig)
+ rsp = !rsp;
+ skb_pull(skb, l2addrsize(l2));
if (l2->extended) {
- p = (ptr[1] & 0x1) == 0x1;
- seq = ptr[1] >> 1;
+ PollFlag = (skb->data[1] & 0x1) == 0x1;
+ seq = skb->data[1] >> 1;
} else {
- p = (ptr[0] & 0x10);
- seq = (ptr[0] >> 5) & 0x7;
+ PollFlag = (skb->data[0] & 0x10);
+ seq = (skb->data[0] >> 5) & 0x7;
}
- BufPoolRelease(ibh);
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
- if ((chanp->impair == 4) && (st->l2.laptype == LAPB))
- goto noresp;
+ if (!((chanp->impair == 4) && (st->l2.laptype == LAPB)))
+ if ((!rsp) && PollFlag)
+ enquiry_response(st, RR, PollFlag);
- if ((!rsp) && p)
- enquiry_response(st);
-
- noresp:
if (legalnr(st, seq)) {
- if (seq == st->l2.vs) {
+ if (seq == l2->vs) {
setva(st, seq);
- FsmDelTimer(&st->l2.t200_timer, 7);
- st->l2.t200_running = 0;
- FsmDelTimer(&st->l2.t203_timer, 8);
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 5))
- if (st->l2.l2m.debug)
+ FsmDelTimer(&l2->t200_timer, 7);
+ l2->t200_running = 0;
+ FsmDelTimer(&l2->t203_timer, 8);
+ if (FsmAddTimer(&l2->t203_timer, l2->t203, EV_L2_T203, NULL, 5))
+ if (l2->l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 5");
- if (st->l2.i_queue.head)
+ if (skb_queue_len(&st->l2.i_queue))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- } else if (st->l2.va != seq) {
+ } else if (l2->va != seq) {
setva(st, seq);
FsmDelTimer(&st->l2.t200_timer, 9);
if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 6))
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 6");
-
- if (st->l2.i_queue.head)
+ if (skb_queue_len(&st->l2.i_queue))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
} else
nrerrorrecovery(fi);
- if ((fi->userint & LC_FLUSH_WAIT) && rsp && !l2->i_queue.head) {
+ if ((fi->userint & LC_FLUSH_WAIT) && rsp && !(skb_queue_len(&st->l2.i_queue))) {
fi->userint &= ~LC_FLUSH_WAIT;
st->l2.l2man(st, DL_FLUSH, NULL);
}
}
static void
-l2s7(struct FsmInst *fi, int event, void *arg)
+l2_feed_iqueue(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- int i;
- byte *ptr;
+ struct sk_buff *skb = arg;
- i = sethdraddr(&st->l2, ibh, CMD);
- ptr = DATAPTR(ibh);
- BufQueueLink(&st->l2.i_queue, ibh);
+ skb_queue_tail(&st->l2.i_queue, skb);
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
@@ -605,24 +611,21 @@
{
struct PStack *st = fi->userdata;
struct Channel *chanp = st->l4.userdata;
- struct BufHeader *ibh = arg;
- byte *ptr;
- struct BufHeader *ibh2;
+ struct sk_buff *skb = arg;
struct IsdnCardState *sp = st->l1.hardware;
struct Layer2 *l2 = &(st->l2);
int i, p, seq, wasok;
char str[64];
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(l2);
+ i = l2addrsize(l2);
if (l2->extended) {
- p = (ptr[1] & 0x1) == 0x1;
- seq = ptr[0] >> 1;
- *nr = (ptr[1] >> 1) & 0x7f;
+ p = (skb->data[i + 1] & 0x1) == 0x1;
+ seq = skb->data[i] >> 1;
+ *nr = (skb->data[i + 1] >> 1) & 0x7f;
} else {
- p = (ptr[0] & 0x10);
- seq = (ptr[0] >> 1) & 0x7;
- *nr = (ptr[0] >> 5) & 0x7;
+ p = (skb->data[i] & 0x10);
+ seq = (skb->data[i] >> 1) & 0x7;
+ *nr = (skb->data[i] >> 5) & 0x7;
}
if (l2->vr == seq) {
@@ -631,72 +634,39 @@
l2->vr = (l2->vr + 1) % (l2->extended ? 128 : 8);
l2->rejexp = 0;
- ptr = DATAPTR(ibh);
if (st->l2.laptype == LAPD)
if (sp->dlogflag) {
- LogFrame(st->l1.hardware, ptr, ibh->datasize);
+ LogFrame(st->l1.hardware, skb->data, skb->len);
sprintf(str, "Q.931 frame network->user tei %d", st->l2.tei);
- dlogframe(st->l1.hardware, ptr + l2->ihsize,
- ibh->datasize - l2->ihsize, str);
+ dlogframe(st->l1.hardware, skb->data + l2->ihsize,
+ skb->len - l2->ihsize, str);
}
- label8_1:
- if ((chanp->impair == 3) && (st->l2.laptype == LAPB))
- goto noRR;
-
- if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 13)) {
- i = sethdraddr(&(st->l2), ibh2, RSP);
- ptr = DATAPTR(ibh2);
- ptr += i;
-
- if (l2->extended) {
- *ptr++ = RR;
- *ptr++ = (l2->vr << 1) | (p ? 1 : 0);
- i += 2;
- } else {
- *ptr++ = (l2->vr << 5) | 0x1 | (p ? 0x10 : 0x0);
- i += 1;
- }
- ibh2->datasize = i;
- enqueue_super(st, ibh2);
- noRR:
- }
+ if (!((chanp->impair == 3) && (st->l2.laptype == LAPB)))
+ if (p || (!skb_queue_len(&st->l2.i_queue)))
+ enquiry_response(st, RR, p);
+ skb_pull(skb, l2headersize(l2, 0));
} else {
/* n(s)!=v(r) */
wasok = 0;
- BufPoolRelease(ibh);
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
if (st->l2.rejexp) {
if (p)
- goto label8_1;
+ if (!((chanp->impair == 3) && (st->l2.laptype == LAPB)))
+ enquiry_response(st, RR, p);
} else {
st->l2.rejexp = !0;
- if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 14)) {
- i = sethdraddr(&(st->l2), ibh2, RSP);
- ptr = DATAPTR(ibh2);
- ptr += i;
-
- if (l2->extended) {
- *ptr++ = REJ;
- *ptr++ = (l2->vr << 1) | (p ? 1 : 0);
- i += 2;
- } else {
- *ptr++ = (l2->vr << 5) | 0x9 | (p ? 0x10 : 0x0);
- i += 1;
- }
- ibh2->datasize = i;
- enqueue_super(st, ibh2);
- }
+ enquiry_command(st, REJ, 1);
}
}
-
return wasok;
-
}
static void
-l2s8(struct FsmInst *fi, int event, void *arg)
+l2_got_st7_data(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
+ struct sk_buff *skb = arg;
int nr, wasok;
wasok = icommandreceived(fi, event, arg, &nr);
@@ -711,7 +681,7 @@
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 5");
- if (st->l2.i_queue.head)
+ if (skb_queue_len(&st->l2.i_queue))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
} else if (nr != st->l2.va) {
setva(st, nr);
@@ -720,38 +690,38 @@
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 6");
- if (st->l2.i_queue.head)
+ if (skb_queue_len(&st->l2.i_queue))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
} else
nrerrorrecovery(fi);
if (wasok)
- st->l2.l2l3(st, DL_DATA, ibh);
+ st->l2.l2l3(st, DL_DATA, skb);
}
static void
-l2s8_1(struct FsmInst *fi, int event, void *arg)
+l2_got_st8_data(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
+ struct sk_buff *skb = arg;
int nr, wasok;
wasok = icommandreceived(fi, event, arg, &nr);
if (legalnr(st, nr)) {
setva(st, nr);
- if (st->l2.i_queue.head)
+ if (skb_queue_len(&st->l2.i_queue))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
} else
nrerrorrecovery(fi);
if (wasok)
- st->l2.l2l3(st, DL_DATA, ibh);
+ st->l2.l2l3(st, DL_DATA, skb);
}
static void
-l2s17(struct FsmInst *fi, int event, void *arg)
+l2_got_tei(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
@@ -777,70 +747,61 @@
p1 += l2->extended ? 128 : 8;
p1 = (p1 + l2->sow) % l2->window;
- BufQueueLinkFront(&l2->i_queue, l2->windowar[p1]);
+ skb_queue_head(&l2->i_queue, l2->windowar[p1]);
+ l2->windowar[p1] = NULL;
}
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
}
static void
-l2s16(struct FsmInst *fi, int event, void *arg)
+l2_got_st7_rej(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- int p, seq, rsp;
- byte *ptr;
+ struct sk_buff *skb = arg;
+ int PollFlag, seq, rsp;
struct Layer2 *l2;
- l2 = &(st->l2);
- ptr = DATAPTR(ibh);
-
- if (l2->laptype == LAPD) {
- rsp = ptr[0] & 0x2;
- if (l2->orig)
- rsp = !rsp;
- } else {
- rsp = ptr[0] == 0x3;
- if (l2->orig)
- rsp = !rsp;
- }
-
-
- ptr += l2addrsize(l2);
+ l2 = &st->l2;
+ if (l2->laptype == LAPD)
+ rsp = *skb->data & 0x2;
+ else
+ rsp = *skb->data == 0x3;
+ if (l2->orig)
+ rsp = !rsp;
+ skb_pull(skb, l2addrsize(l2));
if (l2->extended) {
- p = (ptr[1] & 0x1) == 0x1;
- seq = ptr[1] >> 1;
+ PollFlag = (skb->data[1] & 0x1) == 0x1;
+ seq = skb->data[1] >> 1;
} else {
- p = (ptr[0] & 0x10);
- seq = (ptr[0] >> 5) & 0x7;
+ PollFlag = (skb->data[0] & 0x10);
+ seq = (skb->data[0] >> 5) & 0x7;
}
- BufPoolRelease(ibh);
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
- if ((!rsp) && p)
- enquiry_response(st);
+ if ((!rsp) && PollFlag)
+ enquiry_response(st, RR, PollFlag);
if (!legalnr(st, seq))
return;
setva(st, seq);
invoke_retransmission(st, seq);
-
}
static void
-l2s19(struct FsmInst *fi, int event, void *arg)
+l2_no_tei(struct FsmInst *fi, int event, void *arg)
{
FsmChangeState(fi, ST_L2_4);
}
static void
-l2s20(struct FsmInst *fi, int event, void *arg)
+l2_st5_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- int i;
- struct BufHeader *ibh;
- byte *ptr;
+ u_char cmd;
if (st->l2.rc == st->l2.n200) {
FsmChangeState(fi, ST_L2_4);
@@ -853,29 +814,16 @@
if (st->l2.l2m.debug)
l2m_debug(&st->l2.l2m, "FAT 7");
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15))
- return;
-
- i = sethdraddr(&st->l2, ibh, CMD);
- ptr = DATAPTR(ibh);
- ptr += i;
- if (st->l2.extended)
- *ptr = SABME | 0x10;
- else
- *ptr = 0x3f;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
+ cmd = (st->l2.extended ? SABME : SABM) | 0x10;
+ send_uframe(st, cmd, CMD);
}
}
static void
-l2s21(struct FsmInst *fi, int event, void *arg)
+l2_st6_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct Channel *chanp = st->l4.userdata;
- int i;
- struct BufHeader *ibh;
- byte *ptr;
if (st->l2.rc == st->l2.n200) {
FsmChangeState(fi, ST_L2_4);
@@ -888,59 +836,53 @@
l2m_debug(&st->l2.l2m, "FAT 8");
- if ((chanp->impair == 2) && (st->l2.laptype == LAPB))
- goto nodisc;
-
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15))
- return;
-
- i = sethdraddr(&st->l2, ibh, CMD);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = DISC | 0x10;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
- nodisc:
+ if (!((chanp->impair == 2) && (st->l2.laptype == LAPB)))
+ send_uframe(st, DISC | 0x10, CMD);
}
}
static void
-l2s22(struct FsmInst *fi, int event, void *arg)
+l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh;
+ struct sk_buff *skb;
struct Layer2 *l2 = &st->l2;
- byte *ptr;
- int p1;
+ u_char header[MAX_HEADER_LEN];
+ int p1, i;
if (!cansend(st))
return;
- if (BufQueueUnlink(&ibh, &l2->i_queue))
+ skb = skb_dequeue(&l2->i_queue);
+ if (!skb)
return;
-
p1 = l2->vs - l2->va;
if (p1 < 0)
p1 += l2->extended ? 128 : 8;
p1 = (p1 + l2->sow) % l2->window;
- l2->windowar[p1] = ibh;
+ if (l2->windowar[p1]) {
+ printk(KERN_WARNING "isdnl2 try overwrite ack queue entry %d\n",
+ p1);
+ SET_SKB_FREE(l2->windowar[p1]);
+ dev_kfree_skb(l2->windowar[p1], FREE_WRITE);
+ }
+ l2->windowar[p1] = skb_clone(skb, GFP_ATOMIC);
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(l2);
+ i = sethdraddr(&st->l2, header, CMD);
if (l2->extended) {
- *ptr++ = l2->vs << 1;
- *ptr++ = l2->vr << 1;
+ header[i++] = l2->vs << 1;
+ header[i++] = l2->vr << 1;
l2->vs = (l2->vs + 1) % 128;
} else {
- *ptr++ = (l2->vr << 5) | (l2->vs << 1);
+ header[i++] = (l2->vr << 5) | (l2->vs << 1);
l2->vs = (l2->vs + 1) % 8;
}
- st->l2.l2l1(st, PH_DATA_PULLED, ibh);
-
+ memcpy(skb_push(skb, i), header, i);
+ st->l2.l2l1(st, PH_DATA_PULLED, skb);
if (!st->l2.t200_running) {
FsmDelTimer(&st->l2.t203_timer, 13);
if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 11))
@@ -949,38 +891,24 @@
st->l2.t200_running = !0;
}
- if (l2->i_queue.head && cansend(st))
+ if (skb_queue_len(&l2->i_queue) && cansend(st))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
}
static void
transmit_enquiry(struct PStack *st)
{
- struct BufHeader *ibh;
- byte *ptr;
- if (!BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 12)) {
- ptr = DATAPTR(ibh);
- ptr += sethdraddr(&st->l2, ibh, CMD);
-
- if (st->l2.extended) {
- *ptr++ = RR;
- *ptr++ = (st->l2.vr << 1) | 1;
- } else {
- *ptr++ = (st->l2.vr << 5) | 0x11;
- }
- ibh->datasize = ptr - DATAPTR(ibh);
- enqueue_super(st, ibh);
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 12))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 10");
+ enquiry_command(st, RR, 1);
+ if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 12))
+ if (st->l2.l2m.debug)
+ l2m_debug(&st->l2.l2m, "FAT 10");
- st->l2.t200_running = !0;
- }
+ st->l2.t200_running = !0;
}
static void
-l2s23(struct FsmInst *fi, int event, void *arg)
+l2_st7_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
@@ -992,40 +920,33 @@
}
static void
-l2s24(struct FsmInst *fi, int event, void *arg)
+l2_got_st8_rr_rej(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- int p, seq, rsp;
- byte *ptr;
+ struct sk_buff *skb = arg;
+ int PollFlag, seq, rsp;
struct Layer2 *l2;
l2 = &st->l2;
- ptr = DATAPTR(ibh);
-
- if (l2->laptype == LAPD) {
- rsp = ptr[0] & 0x2;
- if (l2->orig)
- rsp = !rsp;
- } else {
- rsp = ptr[0] == 0x3;
- if (l2->orig)
- rsp = !rsp;
- }
-
-
- ptr += l2addrsize(l2);
+ if (l2->laptype == LAPD)
+ rsp = *skb->data & 0x2;
+ else
+ rsp = *skb->data == 0x3;
+ if (l2->orig)
+ rsp = !rsp;
+ skb_pull(skb, l2addrsize(l2));
if (l2->extended) {
- p = (ptr[1] & 0x1) == 0x1;
- seq = ptr[1] >> 1;
+ PollFlag = (skb->data[1] & 0x1) == 0x1;
+ seq = skb->data[1] >> 1;
} else {
- p = (ptr[0] & 0x10);
- seq = (ptr[0] >> 5) & 0x7;
+ PollFlag = (skb->data[0] & 0x10);
+ seq = (skb->data[0] >> 5) & 0x7;
}
- BufPoolRelease(ibh);
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
- if (rsp && p) {
+ if (rsp && PollFlag) {
if (legalnr(st, seq)) {
FsmChangeState(fi, ST_L2_7);
setva(st, seq);
@@ -1039,7 +960,7 @@
invoke_retransmission(st, seq);
- if (l2->i_queue.head && cansend(st))
+ if (skb_queue_len(&l2->i_queue) && cansend(st))
st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
else if (fi->userint & LC_FLUSH_WAIT) {
fi->userint &= ~LC_FLUSH_WAIT;
@@ -1047,8 +968,8 @@
}
}
} else {
- if (!rsp && p)
- enquiry_response(st);
+ if (!rsp && PollFlag)
+ enquiry_response(st, RR, PollFlag);
if (legalnr(st, seq)) {
setva(st, seq);
}
@@ -1056,7 +977,7 @@
}
static void
-l2s25(struct FsmInst *fi, int event, void *arg)
+l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
@@ -1066,7 +987,7 @@
}
static void
-l2s26(struct FsmInst *fi, int event, void *arg)
+l2_st8_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
@@ -1079,92 +1000,30 @@
}
static void
-l2s27(struct FsmInst *fi, int event, void *arg)
+l2_got_FRMR(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- byte *ptr;
- int i, p, est;
-
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(&st->l2);
-
- p = ptr[0] & 0x10;
-
- BufPoolRelease(ibh);
-
- if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 10))
- return;
- i = sethdraddr(&st->l2, ibh, RSP);
- ptr = DATAPTR(ibh);
- ptr += i;
- *ptr = UA | p;
- ibh->datasize = i + 1;
- enqueue_super(st, ibh);
-
- if (st->l2.vs != st->l2.va) {
- discard_i_queue(st);
- est = !0;
- } else
- est = 0;
-
- FsmDelTimer(&st->l2.t200_timer, 15);
- st->l2.t200_running = 0;
-
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 3))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 12");
-
- st->l2.vs = 0;
- st->l2.va = 0;
- st->l2.vr = 0;
- st->l2.sow = 0;
-
-
- if (est)
- st->l2.l2man(st, DL_ESTABLISH, NULL);
-
-}
-
-static void
-l2s27_1(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
-
- FsmChangeState(fi, ST_L2_7);
- l2s27(fi, event, arg);
-
- if (st->l2.i_queue.head && cansend(st))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
-}
-
-static void
-l2s28(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
- struct BufHeader *ibh = arg;
- byte *ptr;
+ struct sk_buff *skb = arg;
char tmp[64];
- ptr = DATAPTR(ibh);
- ptr += l2addrsize(&st->l2);
- ptr++;
-
+ skb_pull(skb, l2addrsize(&st->l2));
if (st->l2.l2m.debug) {
if (st->l2.extended)
sprintf(tmp, "FRMR information %2x %2x %2x %2x %2x",
- ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]);
+ skb->data[0], skb->data[1], skb->data[2],
+ skb->data[3], skb->data[4]);
else
sprintf(tmp, "FRMR information %2x %2x %2x",
- ptr[0], ptr[1], ptr[2]);
+ skb->data[0], skb->data[1], skb->data[2]);
l2m_debug(&st->l2.l2m, tmp);
}
- BufPoolRelease(ibh);
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
}
static void
-l2s30(struct FsmInst *fi, int event, void *arg)
+l2_tei_remove(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
@@ -1188,26 +1047,26 @@
FsmChangeState(fi, ST_L2_1);
}
-static int
-IsUI(byte * data, int ext)
+inline int
+IsUI(u_char * data, int ext)
{
return ((data[0] & 0xef) == UI);
}
-static int
-IsUA(byte * data, int ext)
+inline int
+IsUA(u_char * data, int ext)
{
return ((data[0] & 0xef) == UA);
}
-static int
-IsDISC(byte * data, int ext)
+inline int
+IsDISC(u_char * data, int ext)
{
return ((data[0] & 0xef) == DISC);
}
-static int
-IsRR(byte * data, int ext)
+inline int
+IsRR(u_char * data, int ext)
{
if (ext)
return (data[0] == RR);
@@ -1215,32 +1074,34 @@
return ((data[0] & 0xf) == 1);
}
-static int
-IsI(byte * data, int ext)
+inline int
+IsI(u_char * data, int ext)
{
return ((data[0] & 0x1) == 0x0);
}
-static int
-IsSABMX(byte * data, int ext)
+inline int
+IsSABMX(u_char * data, int ext)
{
- return (ext ? (data[0] & ~0x10) == SABME : data[0] == 0x3f);
+ u_char d = data[0] & ~0x10;
+
+ return (ext ? d == SABME : d == SABM);
}
-static int
-IsREJ(byte * data, int ext)
+inline int
+IsREJ(u_char * data, int ext)
{
return (ext ? data[0] == REJ : (data[0] & 0xf) == 0x9);
}
-static int
-IsFRMR(byte * data, int ext)
+inline int
+IsFRMR(u_char * data, int ext)
{
return ((data[0] & 0xef) == FRMR);
}
-static int
-IsRNR(byte * data, int ext)
+inline int
+IsRNR(u_char * data, int ext)
{
if (ext)
return (data[0] == RNR);
@@ -1251,91 +1112,89 @@
static struct FsmNode L2FnList[] =
{
{ST_L2_1, EV_L2_DL_ESTABLISH, l2s1},
- {ST_L2_1, EV_L2_MDL_NOTEIPROC, l2s19},
- {ST_L2_3, EV_L2_MDL_ASSIGN, l2s17},
- {ST_L2_4, EV_L2_DL_UNIT_DATA, l2s2},
- {ST_L2_4, EV_L2_DL_ESTABLISH, l2s11},
- {ST_L2_7, EV_L2_DL_UNIT_DATA, l2s2},
- {ST_L2_7, EV_L2_DL_DATA, l2s7},
- {ST_L2_7, EV_L2_DL_RELEASE, l2s13},
- {ST_L2_7, EV_L2_ACK_PULL, l2s22},
- {ST_L2_8, EV_L2_DL_DATA, l2s7},
- {ST_L2_8, EV_L2_DL_RELEASE, l2s13},
-
- {ST_L2_1, EV_L2_UI, l2s3},
- {ST_L2_4, EV_L2_UI, l2s3},
- {ST_L2_4, EV_L2_SABMX, l2s12},
- {ST_L2_4, EV_L2_DISC, l2s14_1},
- {ST_L2_5, EV_L2_UA, l2s5},
- {ST_L2_6, EV_L2_UA, l2s15},
- {ST_L2_7, EV_L2_UI, l2s3},
- {ST_L2_7, EV_L2_DISC, l2s14},
- {ST_L2_7, EV_L2_I, l2s8},
- {ST_L2_7, EV_L2_RR, l2s6},
- {ST_L2_7, EV_L2_REJ, l2s16},
- {ST_L2_7, EV_L2_SABMX, l2s27},
- {ST_L2_7, EV_L2_FRMR, l2s28},
- {ST_L2_8, EV_L2_RR, l2s24},
- {ST_L2_8, EV_L2_REJ, l2s24},
- {ST_L2_8, EV_L2_SABMX, l2s27_1},
- {ST_L2_8, EV_L2_DISC, l2s14},
- {ST_L2_8, EV_L2_FRMR, l2s28},
- {ST_L2_8, EV_L2_I, l2s8_1},
-
- {ST_L2_5, EV_L2_T200, l2s20},
- {ST_L2_6, EV_L2_T200, l2s21},
- {ST_L2_7, EV_L2_T200, l2s23},
- {ST_L2_7, EV_L2_T203, l2s25},
- {ST_L2_8, EV_L2_T200, l2s26},
-
- {ST_L2_1, EV_L2_MDL_REMOVE, l2s30},
-/* {ST_L2_2, EV_L2_MDL_REMOVE, l2s30 }, */
- {ST_L2_3, EV_L2_MDL_REMOVE, l2s30},
- {ST_L2_4, EV_L2_MDL_REMOVE, l2s30},
- {ST_L2_5, EV_L2_MDL_REMOVE, l2s30},
- {ST_L2_6, EV_L2_MDL_REMOVE, l2s30},
- {ST_L2_7, EV_L2_MDL_REMOVE, l2s30},
- {ST_L2_8, EV_L2_MDL_REMOVE, l2s30},
+ {ST_L2_1, EV_L2_MDL_NOTEIPROC, l2_no_tei},
+ {ST_L2_3, EV_L2_MDL_ASSIGN, l2_got_tei},
+ {ST_L2_4, EV_L2_DL_UNIT_DATA, l2_send_ui},
+ {ST_L2_4, EV_L2_DL_ESTABLISH, l2_establish},
+ {ST_L2_7, EV_L2_DL_UNIT_DATA, l2_send_ui},
+ {ST_L2_7, EV_L2_DL_DATA, l2_feed_iqueue},
+ {ST_L2_7, EV_L2_DL_RELEASE, l2_send_disconn},
+ {ST_L2_7, EV_L2_ACK_PULL, l2_pull_iqueue},
+ {ST_L2_8, EV_L2_DL_DATA, l2_feed_iqueue},
+ {ST_L2_8, EV_L2_DL_RELEASE, l2_send_disconn},
+
+ {ST_L2_1, EV_L2_UI, l2_receive_ui},
+ {ST_L2_4, EV_L2_UI, l2_receive_ui},
+ {ST_L2_4, EV_L2_SABMX, l2_got_SABMX},
+ {ST_L2_4, EV_L2_DISC, l2_got_st4_disc},
+ {ST_L2_5, EV_L2_UA, l2_got_ua_establish},
+ {ST_L2_6, EV_L2_UA, l2_got_ua_disconn},
+ {ST_L2_7, EV_L2_UI, l2_receive_ui},
+ {ST_L2_7, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_7, EV_L2_I, l2_got_st7_data},
+ {ST_L2_7, EV_L2_RR, l2_got_st7_RR},
+ {ST_L2_7, EV_L2_REJ, l2_got_st7_rej},
+ {ST_L2_7, EV_L2_SABMX, l2_got_SABMX},
+ {ST_L2_7, EV_L2_FRMR, l2_got_FRMR},
+ {ST_L2_8, EV_L2_RR, l2_got_st8_rr_rej},
+ {ST_L2_8, EV_L2_REJ, l2_got_st8_rr_rej},
+ {ST_L2_8, EV_L2_SABMX, l2_got_SABMX},
+ {ST_L2_8, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_8, EV_L2_FRMR, l2_got_FRMR},
+ {ST_L2_8, EV_L2_I, l2_got_st8_data},
+
+ {ST_L2_5, EV_L2_T200, l2_st5_tout_200},
+ {ST_L2_6, EV_L2_T200, l2_st6_tout_200},
+ {ST_L2_7, EV_L2_T200, l2_st7_tout_200},
+ {ST_L2_7, EV_L2_T203, l2_st7_tout_203},
+ {ST_L2_8, EV_L2_T200, l2_st8_tout_200},
+
+ {ST_L2_1, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_3, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_4, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_5, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_6, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_7, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_8, EV_L2_MDL_REMOVE, l2_tei_remove},
};
#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
static void
-isdnl2_l1l2(struct PStack *st, int pr, struct BufHeader *arg)
+isdnl2_l1l2(struct PStack *st, int pr, void *arg)
{
- struct BufHeader *ibh;
- byte *datap;
+ struct sk_buff *skb = arg;
+ u_char *datap;
int ret = !0;
switch (pr) {
case (PH_DATA):
-
- ibh = arg;
- datap = DATAPTR(ibh);
+ datap = skb->data;
datap += l2addrsize(&st->l2);
if (IsI(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_I, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_I, skb);
else if (IsRR(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_RR, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_RR, skb);
else if (IsUI(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_UI, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_UI, skb);
else if (IsSABMX(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_SABMX, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_SABMX, skb);
else if (IsUA(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_UA, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_UA, skb);
else if (IsDISC(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, skb);
else if (IsREJ(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_REJ, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_REJ, skb);
else if (IsFRMR(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, skb);
else if (IsRNR(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_RNR, ibh);
-
- if (ret)
- BufPoolRelease(ibh);
+ ret = FsmEvent(&st->l2.l2m, EV_L2_RNR, skb);
+ if (ret) {
+ SET_SKB_FREE(skb);
+ dev_kfree_skb(skb, FREE_READ);
+ }
break;
case (PH_PULL_ACK):
FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg);
@@ -1344,24 +1203,26 @@
}
static void
-isdnl2_l3l2(struct PStack *st, int pr,
- void *arg)
+isdnl2_l3l2(struct PStack *st, int pr, void *arg)
{
switch (pr) {
case (DL_DATA):
- if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg))
- BufPoolRelease((struct BufHeader *) arg);
+ if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) {
+ SET_SKB_FREE(((struct sk_buff *) arg));
+ dev_kfree_skb((struct sk_buff *) arg, FREE_READ);
+ }
break;
case (DL_UNIT_DATA):
- if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg))
- BufPoolRelease((struct BufHeader *) arg);
+ if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) {
+ SET_SKB_FREE(((struct sk_buff *) arg));
+ dev_kfree_skb((struct sk_buff *) arg, FREE_READ);
+ }
break;
}
}
static void
-isdnl2_manl2(struct PStack *st, int pr,
- void *arg)
+isdnl2_manl2(struct PStack *st, int pr, void *arg)
{
switch (pr) {
case (DL_ESTABLISH):
@@ -1380,8 +1241,7 @@
}
static void
-isdnl2_teil2(struct PStack *st, int pr,
- void *arg)
+isdnl2_teil2(struct PStack *st, int pr, void *arg)
{
switch (pr) {
case (MDL_ASSIGN):
@@ -1398,6 +1258,8 @@
{
FsmDelTimer(&st->l2.t200_timer, 15);
FsmDelTimer(&st->l2.t203_timer, 16);
+ discard_i_queue(st);
+ ReleaseWin(&st->l2);
}
static void
@@ -1421,7 +1283,8 @@
st->l2.uihsize = l2headersize(&st->l2, !0);
st->l2.ihsize = l2headersize(&st->l2, 0);
- BufQueueInit(&(st->l2.i_queue));
+ skb_queue_head_init(&st->l2.i_queue);
+ InitWin(&st->l2);
st->l2.rejexp = 0;
st->l2.debug = 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov