patch-2.1.42 linux/drivers/isdn/hisax/isdnl1.c

Next file: linux/drivers/isdn/hisax/isdnl1.h
Previous file: linux/drivers/isdn/hisax/hisax.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.41/linux/drivers/isdn/hisax/isdnl1.c linux/drivers/isdn/hisax/isdnl1.c
@@ -1,4 +1,4 @@
-/* $Id: isdnl1.c,v 1.8 1997/02/09 00:24:31 keil Exp $
+/* $Id: isdnl1.c,v 1.15 1997/05/27 15:17:55 fritz Exp $
 
  * isdnl1.c     common low level stuff for Siemens Chipsetbased isdn cards
  *              based on the teles driver from Jan den Ouden
@@ -11,6 +11,31 @@
  *
  *
  * $Log: isdnl1.c,v $
+ * Revision 1.15  1997/05/27 15:17:55  fritz
+ * Added changes for recent 2.1.x kernels:
+ *   changed return type of isdn_close
+ *   queue_task_* -> queue_task
+ *   clear/set_bit -> test_and_... where apropriate.
+ *   changed type of hard_header_cache parameter.
+ *
+ * Revision 1.14  1997/04/07 23:00:08  keil
+ * GFP_KERNEL ---> GFP_ATOMIC
+ *
+ * Revision 1.13  1997/04/06 22:55:50  keil
+ * Using SKB's
+ *
+ * Revision 1.12  1997/03/26 13:43:57  keil
+ * small cosmetics
+ *
+ * Revision 1.11  1997/03/25 23:11:23  keil
+ * US NI-1 protocol
+ *
+ * Revision 1.10  1997/03/13 14:45:05  keil
+ * using IRQ proof queue_task
+ *
+ * Revision 1.9  1997/03/12 21:44:21  keil
+ * change Interrupt routine from atomic quick to normal
+ *
  * Revision 1.8  1997/02/09 00:24:31  keil
  * new interface handling, one interface per card
  *
@@ -39,9 +64,10 @@
  *
  */
 
-const char *l1_revision = "$Revision: 1.8 $";
+const char *l1_revision = "$Revision: 1.15 $";
 
 #define __NO_VERSION__
+#include <linux/config.h>
 #include "hisax.h"
 #include "isdnl1.h"
 
@@ -65,6 +91,9 @@
 #include "ix1_micro.h"
 #endif
 
+/* #define I4L_IRQ_FLAG SA_INTERRUPT */
+#define I4L_IRQ_FLAG    0
+
 #define HISAX_STATUS_BUFSIZE 4096
 
 #define INCLUDE_INLINE_FUNCS
@@ -73,7 +102,12 @@
 
 const char *CardType[] =
 {"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
- "Creatix PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
+ "Creatix/Teles PnP", "AVM A1", "Elsa ML",
+#ifdef CONFIG_HISAX_ELSA_PCMCIA
+ "Elsa PCMCIA",
+#else
+ "Elsa Quickstep",
+#endif
  "Teles PCMCIA", "ITK ix1-micro Rev.2"};
 
 static char *HSCXVer[] =
@@ -84,8 +118,6 @@
 {"2086/2186 V1.1", "2085 B1", "2085 B2",
  "2085 V2.3"};
 
-extern void tei_handler(struct PStack *st, byte pr,
-			struct BufHeader *ibh);
 extern struct IsdnCard cards[];
 extern int nrcards;
 extern char *HiSax_id;
@@ -107,10 +139,10 @@
 }
 
 int
-HiSax_readstatus(byte * buf, int len, int user, int id, int channel)
+HiSax_readstatus(u_char * buf, int len, int user, int id, int channel)
 {
 	int count;
-	byte *p;
+	u_char *p;
 	struct IsdnCardState *csta = hisax_findcard(id);
 
 	if (csta) {
@@ -135,7 +167,7 @@
 {
 	long flags;
 	int len, count, i;
-	byte *p;
+	u_char *p;
 	isdn_ctrl ic;
 
 	save_flags(flags);
@@ -198,11 +230,11 @@
 	ic.driver = csta->myid;
 	csta->iif.statcallb(&ic);
 	if (csta->status_buf)
-		Sfree(csta->status_buf);
+		kfree(csta->status_buf);
 	csta->status_read = NULL;
 	csta->status_write = NULL;
 	csta->status_end = NULL;
-	Sfree(csta->dlogspace);
+	kfree(csta->dlogspace);
 }
 
 void
@@ -221,7 +253,7 @@
 
 
 char *
-HscxVersion(byte v)
+HscxVersion(u_char v)
 {
 	return (HSCXVer[v & 0xf]);
 }
@@ -230,7 +262,7 @@
 hscx_sched_event(struct HscxState *hsp, int event)
 {
 	hsp->event |= 1 << event;
-	queue_task_irq_off(&hsp->tqueue, &tq_immediate);
+	queue_task(&hsp->tqueue, &tq_immediate);
 	mark_bh(IMMEDIATE_BH);
 }
 
@@ -239,7 +271,7 @@
  */
 
 char *
-ISACVersion(byte v)
+ISACVersion(u_char v)
 {
 	return (ISACVer[(v >> 5) & 3]);
 }
@@ -248,7 +280,7 @@
 isac_sched_event(struct IsdnCardState *sp, int event)
 {
 	sp->event |= 1 << event;
-	queue_task_irq_off(&sp->tqueue, &tq_immediate);
+	queue_task(&sp->tqueue, &tq_immediate);
 	mark_bh(IMMEDIATE_BH);
 }
 
@@ -301,21 +333,23 @@
 			sp->ph_command(sp, 8);
 			sp->ph_active = 5;
 			isac_sched_event(sp, ISAC_PHCHANGE);
-			if (!sp->xmtibh)
-				if (!BufQueueUnlink(&sp->xmtibh, &sp->sq))
-					sp->sendptr = 0;
-			if (sp->xmtibh)
+			if (!sp->tx_skb)
+				sp->tx_skb = skb_dequeue(&sp->sq);
+			if (sp->tx_skb) {
+				sp->tx_cnt = 0;
 				sp->isac_fill_fifo(sp);
+			}
 			break;
 		case (13):
 			sp->ph_command(sp, 9);
 			sp->ph_active = 5;
 			isac_sched_event(sp, ISAC_PHCHANGE);
-			if (!sp->xmtibh)
-				if (!BufQueueUnlink(&sp->xmtibh, &sp->sq))
-					sp->sendptr = 0;
-			if (sp->xmtibh)
+			if (!sp->tx_skb)
+				sp->tx_skb = skb_dequeue(&sp->sq);
+			if (sp->tx_skb) {
+				sp->tx_cnt = 0;
 				sp->isac_fill_fifo(sp);
+			}
 			break;
 		case (4):
 		case (8):
@@ -372,7 +406,7 @@
 {
 	struct PStack *stptr;
 
-	if (sp->xmtibh)
+	if (sp->tx_skb)
 		return;
 
 	stptr = sp->stlist;
@@ -388,48 +422,44 @@
 static void
 process_rcv(struct IsdnCardState *sp)
 {
-	struct BufHeader *ibh, *cibh;
+	struct sk_buff *skb, *nskb;
 	struct PStack *stptr;
-	byte *ptr;
 	int found, broadc;
 	char tmp[64];
 
-	while (!BufQueueUnlink(&ibh, &sp->rq)) {
+	while ((skb = skb_dequeue(&sp->rq))) {
 #ifdef L2FRAME_DEBUG		/* psa */
 		if (sp->debug & L1_DEB_LAPD)
-			Logl2Frame(sp, ibh, "PH_DATA", 1);
+			Logl2Frame(sp, skb, "PH_DATA", 1);
 #endif
 		stptr = sp->stlist;
-		ptr = DATAPTR(ibh);
-		broadc = (ptr[1] >> 1) == 127;
+		broadc = (skb->data[1] >> 1) == 127;
 
 		if (broadc) {
-			if (!(ptr[0] >> 2)) {	/* sapi 0 */
+			if (!(skb->data[0] >> 2)) {	/* sapi 0 */
 				sp->CallFlags = 3;
 				if (sp->dlogflag) {
-					LogFrame(sp, ptr, ibh->datasize);
-					dlogframe(sp, ptr + 3, ibh->datasize - 3,
+					LogFrame(sp, skb->data, skb->len);
+					dlogframe(sp, skb->data + 3, skb->len - 3,
 						  "Q.931 frame network->user broadcast");
 				}
 			}
 			while (stptr != NULL) {
-				if ((ptr[0] >> 2) == stptr->l2.sap)
-					if (!BufPoolGet(&cibh, &sp->rbufpool, GFP_ATOMIC,
-							(void *) 1, 5)) {
-						memcpy(DATAPTR(cibh), DATAPTR(ibh), ibh->datasize);
-						cibh->datasize = ibh->datasize;
-						stptr->l1.l1l2(stptr, PH_DATA, cibh);
-					} else
+				if ((skb->data[0] >> 2) == stptr->l2.sap)
+					if ((nskb = skb_clone(skb, GFP_ATOMIC)))
+						stptr->l1.l1l2(stptr, PH_DATA, nskb);
+					else
 						printk(KERN_WARNING "HiSax: isdn broadcast buffer shortage\n");
 				stptr = stptr->next;
 			}
-			BufPoolRelease(ibh);
+			SET_SKB_FREE(skb);
+			dev_kfree_skb(skb, FREE_READ);
 		} else {
 			found = 0;
 			while (stptr != NULL)
-				if (((ptr[0] >> 2) == stptr->l2.sap) &&
-				    ((ptr[1] >> 1) == stptr->l2.tei)) {
-					stptr->l1.l1l2(stptr, PH_DATA, ibh);
+				if (((skb->data[0] >> 2) == stptr->l2.sap) &&
+				((skb->data[1] >> 1) == stptr->l2.tei)) {
+					stptr->l1.l1l2(stptr, PH_DATA, skb);
 					found = !0;
 					break;
 				} else
@@ -440,14 +470,15 @@
 				 * by isdn4linux
 				 */
 
-				if ((!(ptr[0] >> 2)) && (!(ptr[2] & 0x01))) {
+				if ((!(skb->data[0] >> 2)) && (!(skb->data[2] & 0x01))) {
 					sprintf(tmp,
 						"Q.931 frame network->user with tei %d (not for us)",
-						ptr[1] >> 1);
-					LogFrame(sp, ptr, ibh->datasize);
-					dlogframe(sp, ptr + 4, ibh->datasize - 4, tmp);
+						skb->data[1] >> 1);
+					LogFrame(sp, skb->data, skb->len);
+					dlogframe(sp, skb->data + 4, skb->len - 4, tmp);
 				}
-				BufPoolRelease(ibh);
+				SET_SKB_FREE(skb);
+				dev_kfree_skb(skb, FREE_READ);
 			}
 		}
 
@@ -470,65 +501,62 @@
 }
 
 static void
-l2l1(struct PStack *st, int pr,
-     struct BufHeader *ibh)
+l2l1(struct PStack *st, int pr, void *arg)
 {
 	struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
-	byte *ptr = DATAPTR(ibh);
+	struct sk_buff *skb = arg;
 	char str[64];
 
 	switch (pr) {
 		case (PH_DATA):
-			if (sp->xmtibh) {
-				BufQueueLink(&sp->sq, ibh);
+			if (sp->tx_skb) {
+				skb_queue_tail(&sp->sq, skb);
 #ifdef L2FRAME_DEBUG		/* psa */
 				if (sp->debug & L1_DEB_LAPD)
-					Logl2Frame(sp, ibh, "PH_DATA Queued", 0);
+					Logl2Frame(sp, skb, "PH_DATA Queued", 0);
 #endif
 			} else {
-				if ((sp->dlogflag) && (!(ptr[2] & 1))) {	/* I-FRAME */
-					LogFrame(sp, ptr, ibh->datasize);
+				if ((sp->dlogflag) && (!(skb->data[2] & 1))) {	/* I-FRAME */
+					LogFrame(sp, skb->data, skb->len);
 					sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
-					dlogframe(sp, ptr + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
+					dlogframe(sp, skb->data + st->l2.ihsize, skb->len - st->l2.ihsize,
 						  str);
 				}
-				sp->xmtibh = ibh;
-				sp->sendptr = 0;
-				sp->releasebuf = !0;
-				sp->isac_fill_fifo(sp);
+				sp->tx_skb = skb;
+				sp->tx_cnt = 0;
 #ifdef L2FRAME_DEBUG		/* psa */
 				if (sp->debug & L1_DEB_LAPD)
-					Logl2Frame(sp, ibh, "PH_DATA", 0);
+					Logl2Frame(sp, skb, "PH_DATA", 0);
 #endif
+				sp->isac_fill_fifo(sp);
 			}
 			break;
 		case (PH_DATA_PULLED):
-			if (sp->xmtibh) {
+			if (sp->tx_skb) {
 				if (sp->debug & L1_DEB_WARN)
-					debugl1(sp, " l2l1 xmtibh exist this shouldn't happen");
+					debugl1(sp, " l2l1 tx_skb exist this shouldn't happen");
 				break;
 			}
-			if ((sp->dlogflag) && (!(ptr[2] & 1))) {	/* I-FRAME */
-				LogFrame(sp, ptr, ibh->datasize);
+			if ((sp->dlogflag) && (!(skb->data[2] & 1))) {	/* I-FRAME */
+				LogFrame(sp, skb->data, skb->len);
 				sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
-				dlogframe(sp, ptr + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
+				dlogframe(sp, skb->data + st->l2.ihsize, skb->len - st->l2.ihsize,
 					  str);
 			}
-			sp->xmtibh = ibh;
-			sp->sendptr = 0;
-			sp->releasebuf = 0;
-			sp->isac_fill_fifo(sp);
+			sp->tx_skb = skb;
+			sp->tx_cnt = 0;
 #ifdef L2FRAME_DEBUG		/* psa */
 			if (sp->debug & L1_DEB_LAPD)
-				Logl2Frame(sp, ibh, "PH_DATA_PULLED", 0);
+				Logl2Frame(sp, skb, "PH_DATA_PULLED", 0);
 #endif
+			sp->isac_fill_fifo(sp);
 			break;
 		case (PH_REQUEST_PULL):
 #ifdef L2FRAME_DEBUG		/* psa */
 			if (sp->debug & L1_DEB_LAPD)
 				debugl1(sp, "-> PH_REQUEST_PULL");
 #endif
-			if (!sp->xmtibh) {
+			if (!sp->tx_skb) {
 				st->l1.requestpull = 0;
 				st->l1.l1l2(st, PH_PULL_ACK, NULL);
 			} else
@@ -543,7 +571,7 @@
 {
 	struct PStack *st = hsp->st;
 
-	if (hsp->xmtibh)
+	if (hsp->tx_skb)
 		return;
 
 	if (st->l1.requestpull) {
@@ -551,14 +579,14 @@
 		st->l1.l1l2(st, PH_PULL_ACK, NULL);
 	}
 	if (!hsp->active)
-		if ((!hsp->xmtibh) && (!hsp->sq.head))
+		if ((!hsp->tx_skb) && (!skb_queue_len(&hsp->squeue)))
 			hsp->sp->modehscx(hsp, 0, 0);
 }
 
 static void
 hscx_process_rcv(struct HscxState *hsp)
 {
-	struct BufHeader *ibh;
+	struct sk_buff *skb;
 
 #ifdef DEBUG_MAGIC
 	if (hsp->magic != 301270) {
@@ -566,8 +594,8 @@
 		return;
 	}
 #endif
-	while (!BufQueueUnlink(&ibh, &hsp->rq)) {
-		hsp->st->l1.l1l2(hsp->st, PH_DATA, ibh);
+	while ((skb = skb_dequeue(&hsp->rqueue))) {
+		hsp->st->l1.l1l2(hsp->st, PH_DATA, skb);
 	}
 }
 
@@ -675,6 +703,7 @@
 		   void *heldby, int releasetoo)
 {
 	struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
+	struct sk_buff *skb;
 
 #ifdef DEBUG_MAGIC
 	if (sp->magic != 301271) {
@@ -683,16 +712,16 @@
 	}
 #endif
 
-	BufQueueDiscard(&sp->sq, pr, heldby, releasetoo);
+	while ((skb = skb_dequeue(&sp->sq))) {
+		SET_SKB_FREE(skb);
+		dev_kfree_skb(skb, FREE_WRITE);
+	}
 }
 
 void
 setstack_HiSax(struct PStack *st, struct IsdnCardState *sp)
 {
 	st->l1.hardware = sp;
-	st->l1.sbufpool = &(sp->sbufpool);
-	st->l1.rbufpool = &(sp->rbufpool);
-	st->l1.smallpool = &(sp->smallpool);
 	st->protocol = sp->protocol;
 
 	setstack_tei(st);
@@ -737,7 +766,7 @@
 	save_flags(flags);
 	cli();
 	if (request_irq(card->sp->irq, routine,
-			SA_INTERRUPT, "HiSax", NULL)) {
+			I4L_IRQ_FLAG, "HiSax", NULL)) {
 		printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
 		       card->sp->irq);
 		restore_flags(flags);
@@ -760,13 +789,28 @@
 void
 close_hscxstate(struct HscxState *hs)
 {
+	struct sk_buff *skb;
+
 	hs->sp->modehscx(hs, 0, 0);
 	hs->inuse = 0;
-
 	if (hs->init) {
-		BufPoolFree(&hs->smallpool);
-		BufPoolFree(&hs->rbufpool);
-		BufPoolFree(&hs->sbufpool);
+		if (hs->rcvbuf) {
+			kfree(hs->rcvbuf);
+			hs->rcvbuf = NULL;
+		}
+		while ((skb = skb_dequeue(&hs->rqueue))) {
+			SET_SKB_FREE(skb);
+			dev_kfree_skb(skb, FREE_READ);
+		}
+		while ((skb = skb_dequeue(&hs->squeue))) {
+			SET_SKB_FREE(skb);
+			dev_kfree_skb(skb, FREE_WRITE);
+		}
+		if (hs->tx_skb) {
+			SET_SKB_FREE(hs->tx_skb);
+			dev_kfree_skb(hs->tx_skb, FREE_WRITE);
+			hs->tx_skb = NULL;
+		}
 	}
 	hs->init = 0;
 }
@@ -775,14 +819,28 @@
 closecard(int cardnr)
 {
 	struct IsdnCardState *csta = cards[cardnr].sp;
-
-	BufPoolFree(&csta->smallpool);
-	BufPoolFree(&csta->rbufpool);
-	BufPoolFree(&csta->sbufpool);
+	struct sk_buff *skb;
 
 	close_hscxstate(csta->hs + 1);
 	close_hscxstate(csta->hs);
 
+	if (csta->rcvbuf) {
+		kfree(csta->rcvbuf);
+		csta->rcvbuf = NULL;
+	}
+	while ((skb = skb_dequeue(&csta->rq))) {
+		SET_SKB_FREE(skb);
+		dev_kfree_skb(skb, FREE_READ);
+	}
+	while ((skb = skb_dequeue(&csta->sq))) {
+		SET_SKB_FREE(skb);
+		dev_kfree_skb(skb, FREE_WRITE);
+	}
+	if (csta->tx_skb) {
+		SET_SKB_FREE(csta->tx_skb);
+		dev_kfree_skb(csta->tx_skb, FREE_WRITE);
+		csta->tx_skb = NULL;
+	}
 	switch (csta->typ) {
 #if CARD_TELES0
 		case ISDN_CTYPE_16_0:
@@ -830,8 +888,7 @@
 	save_flags(flags);
 	cli();
 	if (!(sp = (struct IsdnCardState *)
-	      Smalloc(sizeof(struct IsdnCardState), GFP_KERNEL,
-		      "struct IsdnCardState"))) {
+	      kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC))) {
 		printk(KERN_WARNING
 		       "HiSax: No memory for IsdnCardState(card %d)\n",
 		       cardnr + 1);
@@ -858,18 +915,18 @@
 		restore_flags(flags);
 		return (0);
 	}
-	if (!(sp->dlogspace = Smalloc(4096, GFP_KERNEL, "dlogspace"))) {
+	if (!(sp->dlogspace = kmalloc(4096, GFP_ATOMIC))) {
 		printk(KERN_WARNING
 		       "HiSax: No memory for dlogspace(card %d)\n",
 		       cardnr + 1);
 		restore_flags(flags);
 		return (0);
 	}
-	if (!(sp->status_buf = Smalloc(HISAX_STATUS_BUFSIZE, GFP_KERNEL, "status_buf"))) {
+	if (!(sp->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
 		printk(KERN_WARNING
 		       "HiSax: No memory for status_buf(card %d)\n",
 		       cardnr + 1);
-		Sfree(sp->dlogspace);
+		kfree(sp->dlogspace);
 		restore_flags(flags);
 		return (0);
 	}
@@ -880,7 +937,8 @@
 	sp->CallFlags = 0;
 	strcpy(sp->iif.id, id);
 	sp->iif.channels = 2;
-	sp->iif.maxbufsize = BUFFER_SIZE(HSCX_SBUF_ORDER, HSCX_SBUF_BPPS);
+	sp->iif.maxbufsize = MAX_DATA_SIZE;
+	sp->iif.hl_hdrlen = MAX_HEADER_LEN;
 	sp->iif.features =
 	    ISDN_FEATURE_L2_X75I |
 	    ISDN_FEATURE_L2_HDLC |
@@ -892,12 +950,15 @@
 #ifdef	CONFIG_HISAX_EURO
 	    ISDN_FEATURE_P_EURO |
 #endif
+#ifdef        CONFIG_HISAX_NI1
+	    ISDN_FEATURE_P_NI1 |
+#endif
 	    0;
 
 	sp->iif.command = HiSax_command;
-	sp->iif.writebuf = HiSax_writebuf;
+	sp->iif.writebuf = NULL;
 	sp->iif.writecmd = NULL;
-	sp->iif.writebuf_skb = NULL;
+	sp->iif.writebuf_skb = HiSax_writebuf_skb;
 	sp->iif.readstat = HiSax_readstatus;
 	register_isdn(&sp->iif);
 	sp->myid = sp->iif.channels;
@@ -907,6 +968,7 @@
 	       (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
 	       (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
 	       (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
+	       (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
 	       "NONE", sp->iif.id, sp->myid);
 	switch (card->typ) {
 #if CARD_TELES0
@@ -948,35 +1010,27 @@
 		ll_unload(sp);
 		return (0);
 	}
-	BufPoolInit(&sp->sbufpool, ISAC_SBUF_ORDER, ISAC_SBUF_BPPS,
-		    ISAC_SBUF_MAXPAGES);
-	BufPoolInit(&sp->rbufpool, ISAC_RBUF_ORDER, ISAC_RBUF_BPPS,
-		    ISAC_RBUF_MAXPAGES);
-	BufPoolInit(&sp->smallpool, ISAC_SMALLBUF_ORDER, ISAC_SMALLBUF_BPPS,
-		    ISAC_SMALLBUF_MAXPAGES);
-	sp->rcvibh = NULL;
-	sp->rcvptr = 0;
-	sp->xmtibh = NULL;
-	sp->sendptr = 0;
-	sp->mon_rx = NULL;
-	sp->mon_rxp = 0;
-	sp->mon_tx = NULL;
-	sp->mon_txp = 0;
-	sp->mon_flg = 0;
+	if (!(sp->rcvbuf = kmalloc(MAX_DFRAME_LEN, GFP_ATOMIC))) {
+		printk(KERN_WARNING
+		       "HiSax: No memory for isac rcvbuf\n");
+		return (1);
+	}
+	sp->rcvidx = 0;
+	sp->tx_skb = NULL;
+	sp->tx_cnt = 0;
 	sp->event = 0;
 	sp->tqueue.next = 0;
 	sp->tqueue.sync = 0;
 	sp->tqueue.routine = (void *) (void *) isac_bh;
 	sp->tqueue.data = sp;
 
-	BufQueueInit(&sp->rq);
-	BufQueueInit(&sp->sq);
+	skb_queue_head_init(&sp->rq);
+	skb_queue_head_init(&sp->sq);
 
 	sp->stlist = NULL;
 	sp->ph_active = 0;
 	sp->dlogflag = 0;
 	sp->debug = L1_DEB_WARN;
-	sp->releasebuf = 0;
 #ifdef DEBUG_MAGIC
 	sp->magic = 301271;
 #endif
@@ -1075,7 +1129,7 @@
 			printk(KERN_WARNING "HiSax: Card %s not installed !\n",
 			       CardType[cards[i].typ]);
 			if (cards[i].sp)
-				Sfree((void *) cards[i].sp);
+				kfree((void *) cards[i].sp);
 			cards[i].sp = NULL;
 			HiSax_shiftcards(i);
 		}
@@ -1098,7 +1152,7 @@
 			release_tei(cards[i].sp);
 			release_irq(i);
 			closecard(i);
-			Sfree((void *) cards[i].sp);
+			kfree((void *) cards[i].sp);
 			cards[i].sp = NULL;
 		}
 	Isdnl2Free();
@@ -1107,11 +1161,10 @@
 }
 
 static void
-hscx_l2l1(struct PStack *st, int pr,
-	  struct BufHeader *ibh)
+hscx_l2l1(struct PStack *st, int pr, void *arg)
 {
-	struct IsdnCardState *sp = (struct IsdnCardState *)
-	st->l1.hardware;
+	struct sk_buff *skb = arg;
+	struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
 	struct HscxState *hsp = sp->hs + st->l1.hscx;
 	long flags;
 
@@ -1119,29 +1172,27 @@
 		case (PH_DATA):
 			save_flags(flags);
 			cli();
-			if (hsp->xmtibh) {
-				BufQueueLink(&hsp->sq, ibh);
+			if (hsp->tx_skb) {
+				skb_queue_tail(&hsp->squeue, skb);
 				restore_flags(flags);
 			} else {
 				restore_flags(flags);
-				hsp->xmtibh = ibh;
-				hsp->sendptr = 0;
-				hsp->releasebuf = !0;
+				hsp->tx_skb = skb;
+				hsp->count = 0;
 				sp->hscx_fill_fifo(hsp);
 			}
 			break;
 		case (PH_DATA_PULLED):
-			if (hsp->xmtibh) {
+			if (hsp->tx_skb) {
 				printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n");
 				break;
 			}
-			hsp->xmtibh = ibh;
-			hsp->sendptr = 0;
-			hsp->releasebuf = 0;
+			hsp->tx_skb = skb;
+			hsp->count = 0;
 			sp->hscx_fill_fifo(hsp);
 			break;
 		case (PH_REQUEST_PULL):
-			if (!hsp->xmtibh) {
+			if (!hsp->tx_skb) {
 				st->l1.requestpull = 0;
 				st->l1.l1l2(st, PH_PULL_ACK, NULL);
 			} else
@@ -1159,6 +1210,7 @@
 	struct IsdnCardState *sp = (struct IsdnCardState *)
 	st->l1.hardware;
 	struct HscxState *hsp = sp->hs + st->l1.hscx;
+	struct sk_buff *skb;
 
 #ifdef DEBUG_MAGIC
 	if (hsp->magic != 301270) {
@@ -1167,7 +1219,10 @@
 	}
 #endif
 
-	BufQueueDiscard(&hsp->sq, pr, heldby, releasetoo);
+	while ((skb = skb_dequeue(&hsp->squeue))) {
+		SET_SKB_FREE(skb);
+		dev_kfree_skb(skb, FREE_WRITE);
+	}
 }
 
 static int
@@ -1177,24 +1232,20 @@
 	struct HscxState *hsp = sp->hs + hscx;
 
 	if (!hsp->init) {
-		BufPoolInit(&hsp->sbufpool, HSCX_SBUF_ORDER, HSCX_SBUF_BPPS,
-			    HSCX_SBUF_MAXPAGES);
-		BufPoolInit(&hsp->rbufpool, HSCX_RBUF_ORDER, HSCX_RBUF_BPPS,
-			    HSCX_RBUF_MAXPAGES);
-		BufPoolInit(&hsp->smallpool, HSCX_SMALLBUF_ORDER, HSCX_SMALLBUF_BPPS,
-			    HSCX_SMALLBUF_MAXPAGES);
+		if (!(hsp->rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
+			printk(KERN_WARNING
+			       "HiSax: No memory for hscx_rcvbuf\n");
+			return (1);
+		}
+		skb_queue_head_init(&hsp->rqueue);
+		skb_queue_head_init(&hsp->squeue);
 	}
 	hsp->init = !0;
 
-	BufQueueInit(&hsp->rq);
-	BufQueueInit(&hsp->sq);
-
-	hsp->releasebuf = 0;
-	hsp->rcvibh = NULL;
-	hsp->xmtibh = NULL;
-	hsp->rcvptr = 0;
-	hsp->sendptr = 0;
+	hsp->tx_skb = NULL;
 	hsp->event = 0;
+	hsp->rcvidx = 0;
+	hsp->tx_cnt = 0;
 	return (0);
 }
 
@@ -1212,7 +1263,7 @@
 			st->l1.l1man(st, PH_ACTIVATE, NULL);
 			break;
 		case (PH_DEACTIVATE):
-			if (!hsp->xmtibh)
+			if (!hsp->tx_skb)
 				sp->modehscx(hsp, 0, 0);
 
 			hsp->active = 0;
@@ -1231,9 +1282,6 @@
 	st->ma.manl1 = hscx_manl1;
 	st->l2.l2l1discardq = hscx_l2l1discardq;
 
-	st->l1.sbufpool = &hs->sbufpool;
-	st->l1.rbufpool = &hs->rbufpool;
-	st->l1.smallpool = &hs->smallpool;
 	st->l1.act_state = 0;
 	st->l1.requestpull = 0;
 
@@ -1256,7 +1304,7 @@
 #ifdef L2FRAME_DEBUG		/* psa */
 
 char *
-l2cmd(byte cmd)
+l2cmd(u_char cmd)
 {
 	switch (cmd & ~0x10) {
 		case 1:
@@ -1290,7 +1338,7 @@
 static char tmp[20];
 
 char *
-l2frames(byte * ptr)
+l2frames(u_char * ptr)
 {
 	switch (ptr[2] & ~0x10) {
 		case 1:
@@ -1320,12 +1368,12 @@
 }
 
 void
-Logl2Frame(struct IsdnCardState *sp, struct BufHeader *ibh, char *buf, int dir)
+Logl2Frame(struct IsdnCardState *sp, struct sk_buff *skb, char *buf, int dir)
 {
 	char tmp[132];
-	byte *ptr;
+	u_char *ptr;
 
-	ptr = DATAPTR(ibh);
+	ptr = skb->data;
 
 	if (ptr[0] & 1 || !(ptr[1] & 1))
 		debugl1(sp, "Addres not LAPD");

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov