patch-2.3.49 linux/drivers/net/tokenring/ibmtr.c

Next file: linux/drivers/net/tokenring/ibmtr.h
Previous file: linux/drivers/net/sunlance.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.48/linux/drivers/net/tokenring/ibmtr.c linux/drivers/net/tokenring/ibmtr.c
@@ -83,6 +83,11 @@
  *      Changes by Jochen Friedrich to enable RFC1469 Option 2 multicasting
  *      i.e. using functional address C0 00 00 04 00 00 to transmit and 
  *      receive multicast packets.
+ * 
+ *      Changes by Mike Sullivan (based on original sram patch by Dave Grothe
+ *      to support windowing into on adapter shared ram.
+ *      i.e. Use LANAID to setup a PnP configuration with 16K RAM. Paging
+ *      will shift this 16K window over the entire available shared RAM.
  */
 
 /* change the define of IBMTR_DEBUG_MESSAGES to a nonzero value 
@@ -102,7 +107,8 @@
 
 #define NO_AUTODETECT 1
 #undef NO_AUTODETECT
-#undef ENABLE_PAGING
+/* #undef ENABLE_PAGING */
+#define ENABLE_PAGING 1
 
 
 #define FALSE 0
@@ -119,7 +125,8 @@
 static char *version =
 "ibmtr.c: v1.3.57   8/ 7/94 Peter De Schrijver and Mark Swanson\n"
 "         v2.1.125 10/20/98 Paul Norton <pnorton@ieee.org>\n"
-"         v2.2.0   12/30/98 Joel Sloan <jjs@c-me.com>\n";
+"         v2.2.0   12/30/98 Joel Sloan <jjs@c-me.com>\n"
+"         v2.2.1   02/08/00 Mike Sullivan <sullivam@us.ibm.com>\n";
 
 static char pcchannelid[] = {
 	0x05, 0x00, 0x04, 0x09,
@@ -570,7 +577,7 @@
 		ti->mapped_ram_size = ti->avail_shared_ram;
 	} else {
 #ifdef ENABLE_PAGING
-		unsigned char pg_size;
+		unsigned char pg_size=0;
 #endif
 
 #if !TR_NEWFORMAT
@@ -590,15 +597,16 @@
 			pg_size=64;   /* 32KB page size */
 			break;
 		case 0xc:
-			ti->page_mask=(ti->mapped_ram_size==32) ? 0xc0 : 0;
-			ti->page_mask=(ti->mapped_ram_size==64) ? 0x80 : 0;
-			DPRINTK("Dual size shared RAM page (code=0xC), don't support it!\n");
-			/* nb/dwm: I did this because RRR (3,2) bits are documented as
-			   R/O and I can't find how to select which page size
-			   Also, the above conditional statement sequence is invalid
-			   as page_mask will always be set by the second stmt */
-			kfree_s(ti, sizeof(struct tok_info));
-			return -ENODEV;
+		        switch (ti->mapped_ram_size) {
+			  case 32:
+			    ti->page_mask=0xc0;
+                            pg_size=32;
+                            break;
+			  case 64:
+                            ti->page_mask=0x80;
+                            pg_size=64;
+                            break;
+                        }
 			break;
 		default:
 			DPRINTK("Unknown shared ram paging info %01X\n",ti->shared_ram_paging);
@@ -606,16 +614,22 @@
 			return -ENODEV;
 			break;
 	}
+
+ 	if (ibmtr_debug_trace & TRC_INIT)
+ 	  DPRINTK("Shared RAM paging code: "
+ 		 "%02X mapped RAM size: %dK shared RAM size: %dK page mask: %0xX\n:",
+ 		 ti->shared_ram_paging, ti->mapped_ram_size/2, ti->avail_shared_ram/2, ti->page_mask);
+
 	if (ti->page_mask) {
 		if (pg_size > ti->mapped_ram_size) {
 			DPRINTK("Page size (%d) > mapped ram window (%d), can't page.\n",
-				pg_size, ti->mapped_ram_size);
+				pg_size/2, ti->mapped_ram_size/2);
 				ti->page_mask = 0;    /* reset paging */
-		} else {
-			ti->mapped_ram_size=ti->avail_shared_ram;
-			DPRINTK("Shared RAM paging enabled. Page size : %uK\n",
-				((ti->page_mask^ 0xff)+1)>>2);
-		}
+                }
+	} else if (pg_size > ti->mapped_ram_size) {
+	                DPRINTK("Page size (%d) > mapped ram window (%d), can't page.\n",
+				pg_size/2, ti->mapped_ram_size/2);
+	}
 #endif
 	}
 	/* finish figuring the shared RAM address */
@@ -673,9 +687,17 @@
 	DPRINTK("Hardware address : %02X:%02X:%02X:%02X:%02X:%02X\n",
 		dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
 		dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+ 	if (ti->page_mask)
+ 	  DPRINTK("Shared RAM paging enabled. Page size: %uK Shared Ram size %dK\n",
+ 		  ((ti->page_mask ^ 0xff)+1)>>2,ti->avail_shared_ram/2);
+ 	else
+ 	  DPRINTK("Shared RAM paging disabled. ti->page_mask %x\n",ti->page_mask);
 #endif
 	/* Calculate the maximum DHB we can use */
-	switch (ti->mapped_ram_size) {
+	if (!ti->page_mask) {
+	  ti->avail_shared_ram=ti->mapped_ram_size;
+	}
+	switch (ti->avail_shared_ram) {
 	case  16 : /* 8KB shared RAM */
 		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 2048);
 		ti->rbuf_len4 = 1032;
@@ -685,34 +707,34 @@
 		ti->rbuf_cnt16 = 2;
 		break;
 	case  32 : /* 16KB shared RAM */
-		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 4464);
+		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 2048);
 		ti->rbuf_len4 = 520;
 		ti->rbuf_cnt4 = 9;
-		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 4096);
+		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 2048);
 		ti->rbuf_len16 = 1032; /* 1024 usable */
 		ti->rbuf_cnt16 = 4;
 		break;
 	case  64 : /* 32KB shared RAM */
-		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 4464);
+		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 2048);
 		ti->rbuf_len4 = 1032;
 		ti->rbuf_cnt4 = 6;
-		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 10240);
+		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 2048);
 		ti->rbuf_len16 = 1032;
 		ti->rbuf_cnt16 = 10;
 		break;
 	case 127 : /* 63KB shared RAM */
-		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 4464);
+		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 2048);
 		ti->rbuf_len4 = 1032;
 		ti->rbuf_cnt4 = 6;
-		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 16384);
+		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 2048);
 		ti->rbuf_len16 = 1032;
 		ti->rbuf_cnt16 = 16;
 		break;
 	case 128 : /* 64KB shared RAM */
-		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 4464);
+		ti->dhb_size4mb  = MIN(ti->dhb_size4mb, 2048);
 		ti->rbuf_len4 = 1032;
 		ti->rbuf_cnt4 = 6;
-		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 17960);
+		ti->dhb_size16mb = MIN(ti->dhb_size16mb, 2048);
 		ti->rbuf_len16 = 1032;
 		ti->rbuf_cnt16 = 18;
 		break;
@@ -764,6 +786,7 @@
 {
 	struct tok_info *ti=(struct tok_info *)dev->priv;
 
+	SET_PAGE(ti->srb_page);
 	ti->open_status		= CLOSED;
 
 	dev->init		= tok_init_card;
@@ -802,7 +825,7 @@
 		address[3] |= mclist->dmi_addr[5];
 		mclist = mclist->next;
 	}
-	SET_PAGE(ti->srb);
+	SET_PAGE(ti->srb_page);
 	for (i=0; i<sizeof(struct srb_set_funct_addr); i++)
 		isa_writeb(0, ti->srb+i);
 
@@ -848,7 +871,7 @@
 	struct tok_info *ti=(struct tok_info *) dev->priv;
 
 	netif_stop_queue(dev);
-	
+	SET_PAGE(ti->srb_page);	
 	isa_writeb(DIR_CLOSE_ADAPTER,
 	       ti->srb + offsetof(struct srb_close_adapter, command));
 	isa_writeb(CMD_IN_SRB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
@@ -857,6 +880,7 @@
 
 	sleep_on(&ti->wait_for_tok_int);
 
+	SET_PAGE(ti->srb_page);
 	if (isa_readb(ti->srb + offsetof(struct srb_close_adapter, ret_code)))
 		DPRINTK("close adapter failed: %02X\n",
 			(int)isa_readb(ti->srb + offsetof(struct srb_close_adapter, ret_code)));
@@ -875,6 +899,9 @@
 	unsigned char status;
 	struct tok_info *ti;
 	struct net_device *dev;
+#ifdef ENABLE_PAGING
+	unsigned char save_srpr;
+#endif
 
 	dev = dev_id;
 #if TR_VERBOSE
@@ -882,6 +909,9 @@
 #endif
 	ti  = (struct tok_info *) dev->priv;
 	spin_lock(&(ti->lock));
+#ifdef ENABLE_PAGING
+	save_srpr=isa_readb(ti->mmio+ACA_OFFSET+ACA_RW+SRPR_EVEN);
+#endif
 
       	/* Disable interrupts till processing is finished */
 	isa_writeb((~INT_ENABLE), ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
@@ -907,17 +937,15 @@
     		if (status == 0xFF)
        		{
 		          DPRINTK("PCMCIA card removed.\n");
-			  spin_unlock(&(ti->lock));
-         		  return;
+			  goto return_point ; 
        		}
 
     	        /* Check ISRP EVEN too. */
       	        if ( isa_readb (ti->mmio + ACA_OFFSET + ACA_RW + ISRP_EVEN) == 0xFF)
     	        {
          		 DPRINTK("PCMCIA card removed.\n");
-			 spin_unlock(&(ti->lock));
-         		 return;
-      		 }
+			 goto return_point ; 
+      		}
 #endif
 
 
@@ -925,8 +953,15 @@
 
 			int i;
 			__u32 check_reason;
+                        __u8  check_reason_page=0;
 
-			check_reason=ti->mmio + ntohs(isa_readw(ti->sram + ACA_OFFSET + ACA_RW +WWCR_EVEN));
+			check_reason=ntohs(isa_readw(ti->sram + ACA_OFFSET + ACA_RW +WWCR_EVEN));
+			if (ti->page_mask) {
+			  check_reason_page=(check_reason>>8) & ti->page_mask;
+			  check_reason &= ~(ti->page_mask << 8);
+			}
+			check_reason += ti->sram;
+			SET_PAGE(check_reason_page);
 
 			DPRINTK("Adapter check interrupt\n");
 			DPRINTK("8 reason bytes follow: ");
@@ -951,6 +986,12 @@
 			/* SRB, ASB, ARB or SSB response */
 
 			if (status & SRB_RESP_INT) { /* SRB response */
+           		        SET_PAGE(ti->srb_page);
+#if TR_VERBOSE
+ 				DPRINTK("SRB resp: cmd=%02X rsp=%02X\n",
+					isa_readb(ti->srb),
+					isa_readb(ti->srb + offsetof(struct srb_xmit, ret_code)));
+#endif
 
 				switch(isa_readb(ti->srb)) { /* SRB command check */
 
@@ -962,7 +1003,7 @@
 						      DPRINTK("error on xmit_dir_frame request: %02X\n",
 							      xmit_ret_code);
 						      if (ti->current_skb) {
-							      dev_kfree_skb(ti->current_skb);
+							      dev_kfree_skb_irq(ti->current_skb);
 							      ti->current_skb=NULL;
 						      }
 						      netif_wake_queue(dev);
@@ -979,7 +1020,7 @@
 						      DPRINTK("error on xmit_ui_frame request: %02X\n",
 							      xmit_ret_code);
 						      if (ti->current_skb) {
-							      dev_kfree_skb(ti->current_skb);
+							      dev_kfree_skb_irq(ti->current_skb);
 							      ti->current_skb=NULL;
 						      }
 						      netif_wake_queue(dev);
@@ -993,10 +1034,25 @@
 					      unsigned char open_ret_code;
 					      __u16 open_error_code;
 
-					      ti->srb=ti->sram+ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, srb_addr)));
-					      ti->ssb=ti->sram+ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, ssb_addr)));
-					      ti->arb=ti->sram+ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, arb_addr)));
-					      ti->asb=ti->sram+ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, asb_addr)));
+ 					      ti->srb=ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, srb_addr)));
+ 					      ti->ssb=ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, ssb_addr)));
+ 					      ti->arb=ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, arb_addr)));
+ 					      ti->asb=ntohs(isa_readw(ti->init_srb +offsetof(struct srb_open_response, asb_addr)));
+					      if (ti->page_mask) {
+						ti->srb_page=(ti->srb>>8) & ti->page_mask;
+						ti->srb &= ~(ti->page_mask<<8);
+						ti->ssb_page=(ti->ssb>>8) & ti->page_mask;
+						ti->ssb &= ~(ti->page_mask<<8);
+						ti->arb_page=(ti->arb>>8) & ti->page_mask;
+						ti->arb &= ~(ti->page_mask<<8);
+						ti->asb_page=(ti->asb>>8) & ti->page_mask;
+						ti->asb &= ~(ti->page_mask<<8);
+					      }
+					      ti->srb+=ti->sram;
+					      ti->ssb+=ti->sram;
+					      ti->arb+=ti->sram;
+					      ti->asb+=ti->sram;
+
 					      ti->current_skb=NULL;
 
 					      open_ret_code = isa_readb(ti->init_srb +offsetof(struct srb_open_response, ret_code));
@@ -1125,6 +1181,10 @@
 			} /* SRB response */
 
 			if (status & ASB_FREE_INT) { /* ASB response */
+			        SET_PAGE(ti->asb_page);
+#if TR_VERBOSE
+ 				DPRINTK("ASB resp: cmd=%02X\n", isa_readb(ti->asb));
+ #endif
 
 				switch(isa_readb(ti->asb)) { /* ASB command check */
 
@@ -1147,6 +1207,12 @@
 			} /* ASB response */
 
 			if (status & ARB_CMD_INT) { /* ARB response */
+            		        SET_PAGE(ti->arb_page);
+#if TR_VERBOSE 
+ 				DPRINTK("ARB resp: cmd=%02X rsp=%02X\n",
+ 					isa_readb(ti->arb),
+ 					isa_readb(ti->arb + offsetof(struct arb_dlc_status, status)));
+#endif
 
 				switch (isa_readb(ti->arb)) { /* ARB command check */
 
@@ -1203,6 +1269,11 @@
 
 			if (status & SSB_RESP_INT) { /* SSB response */
 				unsigned char retcode;
+ 				SET_PAGE(ti->ssb_page);
+#if TR_VERBOSE
+ 				DPRINTK("SSB resp: cmd=%02X rsp=%02X\n",
+ 					isa_readb(ti->ssb), isa_readb(ti->ssb+2));
+#endif
 				switch (isa_readb(ti->ssb)) { /* SSB command check */
 				      
 				      case XMIT_DIR_FRAME:
@@ -1216,6 +1287,7 @@
 
 				      case XMIT_XID_CMD:
 					DPRINTK("xmit xid ret_code: %02X\n", (int)isa_readb(ti->ssb+2));
+                                        break;
 
 				      default:
 					DPRINTK("Unknown command %02X in ssb\n", (int)isa_readb(ti->ssb));
@@ -1240,6 +1312,13 @@
 		DPRINTK("Unexpected interrupt from tr adapter\n");
 
 	}
+#ifdef PCMCIA
+ return_point:
+#endif
+#ifdef ENABLE_PAGING
+ 	isa_writeb(save_srpr, ti->mmio+ACA_OFFSET+ACA_RW+SRPR_EVEN);
+#endif
+
 	spin_unlock(&(ti->lock));
 }
 
@@ -1262,9 +1341,26 @@
 		isa_writeb(ti->sram_base, ti->mmio + ACA_OFFSET + ACA_RW + RRR_EVEN);
 		ti->sram=((__u32)ti->sram_base << 12);
 	}
-	ti->init_srb=ti->sram
-		+ntohs((unsigned short)isa_readw(ti->mmio+ ACA_OFFSET + WRBR_EVEN));
-	SET_PAGE(ntohs((unsigned short)isa_readw(ti->mmio+ACA_OFFSET + WRBR_EVEN)));
+ 	ti->init_srb=ntohs((unsigned short)isa_readw(ti->mmio+ ACA_OFFSET + WRBR_EVEN));
+	if (ti->page_mask) {
+	  ti->init_srb_page=(ti->init_srb>>8)&ti->page_mask;
+	  ti->init_srb &= ~(ti->page_mask<<8);
+	}
+	ti->init_srb+=ti->sram;
+	
+	if (ti->avail_shared_ram == 127) {
+	  int i;
+	  int last_512=0xfe00;
+ 	  if (ti->page_mask) {
+	    last_512 &= ~(ti->page_mask<<8);
+	  }
+	  /*  initialize high section of ram (if necessary) */
+	  SET_PAGE(0xc0);
+	  for (i=0; i<512; i++) {
+	    isa_writeb(0,ti->sram+last_512+i);
+	  }
+	}  
+	SET_PAGE(ti->init_srb_page);
 
 	dev->mem_start = ti->sram;
 	dev->mem_end = ti->sram + (ti->mapped_ram_size<<9) - 1;
@@ -1272,7 +1368,7 @@
 #if TR_VERBOSE
 	{
 		int i;
-		DPRINTK("init_srb(%p):", ti->init_srb);
+		DPRINTK("init_srb(%lx):", (long)ti->init_srb);
 		for (i=0;i<17;i++) printk("%02X ", (int)isa_readb(ti->init_srb+i));
 		printk("\n");
 	}
@@ -1325,11 +1421,6 @@
 	/* Reset adapter */
 	netif_stop_queue(dev);
 
-#ifdef ENABLE_PAGING
-	if(ti->page_mask)
-		isa_writeb(SRPR_ENABLE_PAGING, ti->mmio + ACA_OFFSET + ACA_RW + SRPR_EVEN);
-#endif
-
 	isa_writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
 
 #if !TR_NEWFORMAT
@@ -1339,6 +1430,10 @@
 	outb(0, PIOaddr+ADAPTRESET);
 	for (i=jiffies+TR_RESET_INTERVAL; time_before_eq(jiffies, i);); /* wait 50ms */
 	outb(0,PIOaddr+ADAPTRESETREL);
+#ifdef ENABLE_PAGING
+	if(ti->page_mask)
+		isa_writeb(SRPR_ENABLE_PAGING, ti->mmio + ACA_OFFSET + ACA_RW + SRPR_EVEN);
+#endif
 
 #if !TR_NEWFORMAT
 	DPRINTK("card reset\n");
@@ -1354,7 +1449,7 @@
 	int i;
 	struct tok_info *ti=(struct tok_info *) dev->priv;
 
-	SET_PAGE(ti->srb);
+	SET_PAGE(ti->srb_page);
 	for (i=0; i<sizeof(struct dlc_open_sap); i++)
 		isa_writeb(0, ti->srb+i);
 
@@ -1417,6 +1512,12 @@
 	       ti->init_srb + offsetof(struct dir_open_adapter, dlc_max_sta));
 
 	ti->srb=ti->init_srb; /* We use this one in the interrupt handler */
+	ti->srb_page=ti->init_srb_page;
+	DPRINTK("Opend adapter: Xmit bfrs: %d X %d, Rcv bfrs: %d X %d\n",
+		isa_readb(ti->init_srb+offsetof(struct dir_open_adapter,num_dhb)),
+		ntohs(isa_readw(ti->init_srb+offsetof(struct dir_open_adapter,dhb_length))),
+		ntohs(isa_readw(ti->init_srb+offsetof(struct dir_open_adapter,num_rcv_buf))),
+		ntohs(isa_readw(ti->init_srb+offsetof(struct dir_open_adapter,rcv_buf_len))) );
 
 	isa_writeb(INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_SET + ISRP_EVEN);
 	isa_writeb(CMD_IN_SRB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
@@ -1432,7 +1533,11 @@
 	unsigned char xmit_command;
 	int i;
 	struct trllc	*llc;
+	struct srb_xmit  xsrb;
+	__u8  dhb_page=0;
+	__u8  llc_ssap;
 
+	SET_PAGE(ti->asb_page);
 	if (isa_readb(ti->asb + offsetof(struct asb_xmit_resp, ret_code))!=0xFF)
 		DPRINTK("ASB not free !!!\n");
 
@@ -1441,8 +1546,13 @@
 	   providing a shared memory address for us
 	   to stuff with data.  Here we compute the
 	   effective address where we will place data.*/
-	dhb=ti->sram
-		+ntohs(isa_readw(ti->arb + offsetof(struct arb_xmit_req, dhb_address)));
+        SET_PAGE(ti->arb_page);
+ 	dhb=ntohs(isa_readw(ti->arb + offsetof(struct arb_xmit_req, dhb_address)));
+        if (ti->page_mask) {
+	  dhb_page=(dhb >> 8) & ti->page_mask;
+	  dhb &= ~(ti->page_mask << 8);
+        }
+        dhb+=ti->sram;
 	
 	/* Figure out the size of the 802.5 header */
 	if (!(trhdr->saddr[0] & 0x80)) /* RIF present? */
@@ -1453,13 +1563,17 @@
 
 	llc = (struct trllc *)(ti->current_skb->data + hdr_len);
 
-	xmit_command = isa_readb(ti->srb + offsetof(struct srb_xmit, command));
-
+	llc_ssap=llc->ssap;
+ 	SET_PAGE(ti->srb_page);
+ 	isa_memcpy_fromio(&xsrb, ti->srb, sizeof(xsrb));
+ 	SET_PAGE(ti->asb_page);
+ 	xmit_command=xsrb.command;
+	
 	isa_writeb(xmit_command, ti->asb + offsetof(struct asb_xmit_resp, command));
-	isa_writew(isa_readb(ti->srb + offsetof(struct srb_xmit, station_id)),
+	isa_writew(xsrb.station_id,
 	       ti->asb + offsetof(struct asb_xmit_resp, station_id));
-	isa_writeb(llc->ssap, ti->asb + offsetof(struct asb_xmit_resp, rsap_value));
-	isa_writeb(isa_readb(ti->srb + offsetof(struct srb_xmit, cmd_corr)),
+	isa_writeb(llc_ssap, ti->asb + offsetof(struct asb_xmit_resp, rsap_value));
+ 	isa_writeb(xsrb.cmd_corr,
 	       ti->asb + offsetof(struct asb_xmit_resp, cmd_corr));
 	isa_writeb(0, ti->asb + offsetof(struct asb_xmit_resp, ret_code));
 
@@ -1468,6 +1582,7 @@
 		isa_writew(htons(0x11),
 		       ti->asb + offsetof(struct asb_xmit_resp, frame_length));
 		isa_writeb(0x0e, ti->asb + offsetof(struct asb_xmit_resp, hdr_length));
+		SET_PAGE(dhb_page);
 		isa_writeb(AC, dhb);
 		isa_writeb(LLC_FRAME, dhb+1);
 
@@ -1487,11 +1602,12 @@
 	isa_writew(htons(ti->current_skb->len),
 	       ti->asb + offsetof(struct asb_xmit_resp, frame_length));
 
+	SET_PAGE(dhb_page);
 	isa_memcpy_toio(dhb, ti->current_skb->data, ti->current_skb->len);
 
 	isa_writeb(RESP_IN_ASB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
 	ti->tr_stats.tx_bytes+=ti->current_skb->len;
-	dev_kfree_skb(ti->current_skb);
+	dev_kfree_skb_irq(ti->current_skb);
 	ti->current_skb=NULL;
 	netif_wake_queue(dev);
 	if (ti->readlog_pending) ibmtr_readlog(dev);
@@ -1501,6 +1617,7 @@
 {
 	struct tok_info *ti=(struct tok_info *) dev->priv;
 	__u32 rbuffer, rbufdata;
+	__u8  rbuffer_page=0;
 	__u32 llc;
 	unsigned char *data;
 	unsigned int rbuffer_len, lan_hdr_len, hdr_len, ip_len, length;
@@ -1509,31 +1626,40 @@
 	int	IPv4_p = 0;
 	unsigned int chksum = 0;
 	struct iphdr *iph;
+	struct arb_rec_req rarb;
 
-	rbuffer=(ti->sram
-		 +ntohs(isa_readw(ti->arb + offsetof(struct arb_rec_req, rec_buf_addr))))+2;
- 
+	SET_PAGE(ti->arb_page);
+ 	isa_memcpy_fromio(&rarb, ti->arb, sizeof(rarb));
+ 	rbuffer=ntohs(rarb.rec_buf_addr)+2;
+	if (ti->page_mask) {
+	  rbuffer_page=(rbuffer >> 8) & ti->page_mask;
+	  rbuffer &= ~(ti->page_mask<<8);
+	}
+	rbuffer += ti->sram;
+	
+	SET_PAGE(ti->asb_page);
 	if(isa_readb(ti->asb + offsetof(struct asb_rec, ret_code))!=0xFF)
 		DPRINTK("ASB not free !!!\n");
 
 	isa_writeb(REC_DATA,
 	       ti->asb + offsetof(struct asb_rec, command));
-	isa_writew(isa_readw(ti->arb + offsetof(struct arb_rec_req, station_id)),
+	isa_writew(rarb.station_id,
 	       ti->asb + offsetof(struct asb_rec, station_id));
-	isa_writew(isa_readw(ti->arb + offsetof(struct arb_rec_req, rec_buf_addr)),
+	isa_writew(rarb.rec_buf_addr,
 	       ti->asb + offsetof(struct asb_rec, rec_buf_addr));
 
-	lan_hdr_len=isa_readb(ti->arb + offsetof(struct arb_rec_req, lan_hdr_len));
+	lan_hdr_len=rarb.lan_hdr_len;
 	hdr_len = lan_hdr_len + sizeof(struct trllc) + sizeof(struct iphdr);
-	
+
+	SET_PAGE(rbuffer_page);
 	llc=(rbuffer + offsetof(struct rec_buf, data) + lan_hdr_len);
 
 #if TR_VERBOSE
 	DPRINTK("offsetof data: %02X lan_hdr_len: %02X\n",
 		(unsigned int)offsetof(struct rec_buf,data), (unsigned int)lan_hdr_len);
-	DPRINTK("llc: %08X rec_buf_addr: %04X ti->sram: %p\n", llc,
-		ntohs(isa_readw(ti->arb + offsetof(struct arb_rec_req, rec_buf_addr))),
-		ti->sram);
+	DPRINTK("llc: %08X rec_buf_addr: %04X ti->sram: %lx\n", llc,
+		ntohs(rarb.rec_buf_addr),
+		(long)ti->sram);
 	DPRINTK("dsap: %02X, ssap: %02X, llc: %02X, protid: %02X%02X%02X, "
 		"ethertype: %04X\n",
 		(int)isa_readb(llc + offsetof(struct trllc, dsap)),
@@ -1545,14 +1671,15 @@
 		(int)isa_readw(llc + offsetof(struct trllc, ethertype)));
 #endif
 	if (isa_readb(llc + offsetof(struct trllc, llc))!=UI_CMD) {
+                SET_PAGE(ti->asb_page);
 		isa_writeb(DATA_LOST, ti->asb + offsetof(struct asb_rec, ret_code));
 		ti->tr_stats.rx_dropped++;
 		isa_writeb(RESP_IN_ASB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
 		return;
 	}
 
-	length = ntohs(isa_readw(ti->arb+offsetof(struct arb_rec_req, frame_len)));
-       	if ((isa_readb(llc + offsetof(struct trllc, dsap))==EXTENDED_SAP) &&
+	length = ntohs(rarb.frame_len);
+	if ((isa_readb(llc + offsetof(struct trllc, dsap))==EXTENDED_SAP) &&
        	    (isa_readb(llc + offsetof(struct trllc, ssap))==EXTENDED_SAP) &&
 		(length>=hdr_len)) {
        		IPv4_p = 1;
@@ -1585,11 +1712,12 @@
        	}
 #endif
 
-       	skb_size = length-lan_hdr_len+sizeof(struct trh_hdr)+sizeof(struct trllc);
+       	skb_size = length;
  
        	if (!(skb=dev_alloc_skb(skb_size))) {
        		DPRINTK("out of memory. frame dropped.\n");
        		ti->tr_stats.rx_dropped++;
+		SET_PAGE(ti->asb_page);
        		isa_writeb(DATA_LOST, ti->asb + offsetof(struct asb_rec, ret_code));
        		isa_writeb(RESP_IN_ASB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
        		return;
@@ -1630,11 +1758,17 @@
 			break;
 		length -= rbuffer_len;
 		data += rbuffer_len;
+		if (ti->page_mask) {
+		  rbuffer_page=(rbuffer>>8) & ti->page_mask;
+		  rbuffer &= ~(ti->page_mask << 8);
+		}
 		rbuffer += ti->sram;
+		SET_PAGE(rbuffer_page);
 		rbuffer_len = ntohs(isa_readw(rbuffer + offsetof(struct rec_buf, buf_len)));
 		rbufdata = rbuffer + offsetof(struct rec_buf, data);
 	}
 
+	SET_PAGE(ti->asb_page);
        	isa_writeb(0, ti->asb + offsetof(struct asb_rec, ret_code));
 
        	isa_writeb(RESP_IN_ASB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);
@@ -1663,6 +1797,7 @@
 
 	/* Save skb; we'll need it when the adapter asks for the data */
 	ti->current_skb=skb;
+	SET_PAGE(ti->srb_page);
 	isa_writeb(XMIT_UI_FRAME, ti->srb + offsetof(struct srb_xmit, command));
 	isa_writew(ti->exsap_station_id, ti->srb
 	       +offsetof(struct srb_xmit, station_id));
@@ -1685,6 +1820,7 @@
 	 ti=(struct tok_info *) dev->priv;
 
 	 ti->readlog_pending = 0;
+	 SET_PAGE(ti->srb_page);
 	 isa_writeb(DIR_READ_LOG, ti->srb);
 	 isa_writeb(INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_SET + ISRP_EVEN);
 	 isa_writeb(CMD_IN_SRB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)