--- plip.c	Thu Oct  6 06:17:24 1994
+++ /usr/src/linux.devel/drivers/net/plip.c	Sat Oct  8 23:48:02 1994
@@ -19,6 +19,9 @@
  *		modify it under the terms of the GNU General Public License
  *		as published by the Free Software Foundation; either version
  *		2 of the License, or (at your option) any later version.
+ *
+ *
+ *		BUG: What happens if you reduce dev->mtu...
  */
 
 /*
@@ -78,7 +81,6 @@
 #include <netinet/in.h>
 #include <errno.h>
 #include <linux/delay.h>
-#include <linux/lp.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -118,15 +120,10 @@
 #define PAR_CONTROL(dev)	(dev->base_addr+2)
 
 /* Index to functions, as function prototypes. */
-static int plip_tx_packet(struct sk_buff *skb, struct device *dev);
+static int plip_tx_packet(sk_buff *skb, struct device *dev);
 static int plip_open(struct device *dev);
 static int plip_close(struct device *dev);
-static int plip_header(unsigned char *buff, struct device *dev,
-		       unsigned short type, void *dest,
-		       void *source, unsigned len, struct sk_buff *skb);
 static struct enet_statistics *plip_get_stats(struct device *dev);
-static int plip_rebuild_header(void *buff, struct device *dev,
-			       unsigned long raddr, struct sk_buff *skb);
 
 enum plip_state {
     PLIP_ST_DONE=0,
@@ -163,7 +160,7 @@
     unsigned short byte;
     unsigned char  checksum;
     unsigned char  data;
-    struct sk_buff *skb;
+    sk_buff *skb;
 };
 
 struct net_local {
@@ -197,7 +194,7 @@
     struct net_local *pl;
 
     /* Check that there is something at base_addr. */
-    outb(LP_PINITP, PAR_CONTROL(dev));
+    outb(LP_PINITP, PAR_CONTROL(dev));
     outb(0x00, PAR_DATA(dev));
     if (inb(PAR_DATA(dev)) != 0x00)
 	return -ENODEV;
@@ -213,9 +210,9 @@
 	printk("%s: configured for parallel port at %#3x",
 	       dev->name, dev->base_addr);
 	autoirq_setup(0);
-	outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
-	outb(LP_PINITP|LP_PSELECP|LP_PINTEN, PAR_CONTROL(dev));
-	outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
+	outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
+	outb(LP_PINITP|LP_PSELECP|LP_PINTEN, PAR_CONTROL(dev));
+	outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
 	dev->irq = autoirq_report(1);
 	if (dev->irq)
 	    printk(", probed IRQ %d.\n", dev->irq);
@@ -242,8 +239,7 @@
     dev->hard_start_xmit	= plip_tx_packet;
     dev->open			= plip_open;
     dev->stop			= plip_close;
-    dev->hard_header		= plip_header;
-    dev->type_trans		= eth_type_trans;
+/*    dev->hard_header		= plip_header;*/
     dev->get_stats 		= plip_get_stats;
     dev->set_config		= plip_config;
     dev->do_ioctl		= plip_ioctl;
@@ -252,7 +248,7 @@
     dev->hard_header_len	= ETH_HLEN;
     dev->addr_len		= ETH_ALEN;
     dev->type			= ARPHRD_ETHER;
-    dev->rebuild_header 	= plip_rebuild_header;
+/*    dev->rebuild_header 	= plip_rebuild_header;*/
 
     for (i = 0; i < DEV_NUMBUFFS; i++)
 	skb_queue_head_init(&dev->buffs[i]);
@@ -275,12 +271,24 @@
 }
 
 static int
-plip_tx_packet (struct sk_buff *skb, struct device *dev)
+plip_tx_packet (sk_buff *skb, struct device *dev)
 {
     struct net_local *lp = (struct net_local *)dev->priv;
     struct plip_local *snd = &lp->snd_data;
 
-    if (dev->tbusy) {
+    /*
+     *	If the device hardware address isn't set - set it.
+     */
+     
+    if (*dev->dev_addr==0)
+    {
+    	dev->dev_addr[0]=0xFD;
+    	dev->dev_addr[1]=0xFD;
+    	memcpy(&dev->dev_addr[2],&dev->pa_addr,4);
+    }
+    
+    if (dev->tbusy) 
+    {
 	/* it is sending a packet now */
 	int tickssofar = jiffies - dev->trans_start;
 	if (tickssofar < 100)	/* please try later, again */
@@ -353,13 +361,13 @@
     struct net_local *lp = (struct net_local *)dev->priv;
     struct plip_local *rcv = &lp->rcv_data;
 
-    rcv->skb = alloc_skb(dev->mtu, GFP_KERNEL);
+    rcv->skb = dev_alloc_skb(dev->mtu);
     if (rcv->skb == NULL) {
 	printk("%s: couldn't get memory for receiving packet.\n", dev->name);
 	return -EAGAIN;
     }
-    rcv->skb->len = dev->mtu;
     rcv->skb->dev = dev;
+    skb_put(rcv->skb,dev->mtu);	/* We will fill some of this then trim */
     cli();
     if (request_irq(dev->irq , plip_interrupt, 0, "plip") != 0) {
 	sti();
@@ -369,7 +377,7 @@
     irq2dev_map[dev->irq] = dev;
     sti();
     /* enable rx interrupt. */
-    outb(LP_PINITP|LP_PSELECP|LP_PINTEN, PAR_CONTROL(dev));
+    outb(LP_PINITP|LP_PSELECP|LP_PINTEN, PAR_CONTROL(dev));
     plip_device_clear(dev);
     dev->start = 1;
 #ifdef MODULE
@@ -394,30 +402,13 @@
     /* make sure that we don't register the timer */
     del_timer(&lp->tl);
     /* release the interrupt. */
-    outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
+    outb(LP_PINITP|LP_PSELECP, PAR_CONTROL(dev));
 #ifdef MODULE
     MOD_DEC_USE_COUNT;
 #endif        
     return 0;
 }
 
-/* Fill in the MAC-level header. */
-static int
-plip_header(unsigned char *buff, struct device *dev,
-	    unsigned short type, void *daddr,
-	    void *saddr, unsigned len, struct sk_buff *skb)
-{
-    int i;
-
-    if (dev->dev_addr[0] == 0) {
-	for (i=0; i < ETH_ALEN - sizeof(unsigned long); i++)
-	    dev->dev_addr[i] = 0xfc;
-	memcpy(&(dev->dev_addr[i]), &dev->pa_addr, sizeof(unsigned long));
-    }
-
-    return eth_header(buff, dev, type, daddr, saddr, len, skb);
-}
-
 static struct enet_statistics *
 plip_get_stats(struct device *dev)
 {
@@ -425,25 +416,6 @@
     return localstats;
 }
 
-/* We don't need to send arp, for plip is point-to-point. */
-static int
-plip_rebuild_header(void *buff, struct device *dev, unsigned long dst,
-		    struct sk_buff *skb)
-{
-    struct ethhdr *eth = (struct ethhdr *)buff;
-    int i;
-
-    if (eth->h_proto != htons(ETH_P_IP)) {
-	printk("plip_rebuild_header: Don't know how to resolve type %d addresses?\n",(int)eth->h_proto);
-	memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
-	return 0;
-    }
-
-    for (i=0; i < ETH_ALEN - sizeof(unsigned long); i++)
-	eth->h_dest[i] = 0xfc;
-    memcpy(&(eth->h_dest[i]), &dst, sizeof(unsigned long));
-    return 0;
-}
 
 static void
 plip_device_clear(struct device *dev)
@@ -562,7 +534,7 @@
     struct enet_statistics *stats = (struct enet_statistics *) dev->priv;
     struct plip_local *snd = &lp->snd_data;
     struct plip_local *rcv = &lp->rcv_data;
-    unsigned char *lbuf = rcv->skb->data;
+    unsigned char *lbuf = skb_data(rcv->skb);
     unsigned char c0;
     unsigned char *s =  PLIP_STATE_STRING(rcv->state);
 
@@ -595,7 +567,7 @@
 		plip_error(dev);
 		return;
 	    }
-	    rcv->skb->len = rcv->length;
+	    skb_trim(rcv->skb,rcv->length);
 	    rcv->state = PLIP_ST_DATA;
 	    rcv->nibble = PLIP_NST_BEGIN;
 	    rcv->byte = 0;
@@ -628,13 +600,13 @@
 	    netif_rx(rcv->skb);
 
 	    /* Malloc up new buffer. */
-	    rcv->skb = alloc_skb(dev->mtu, GFP_ATOMIC);
+	    rcv->skb = dev_alloc_skb(dev->mtu);
 	    if (rcv->skb == NULL) {
 		printk("%s: Memory squeeze.\n", dev->name);
 		plip_error(dev);
 		return;
 	    }
-	    rcv->skb->len = dev->mtu;
+	    skb_put(rcv->skb,dev->mtu);
 	    rcv->skb->dev = dev;
 	    stats->rx_packets++;
 	    if (net_debug > 4)
@@ -806,7 +778,7 @@
     struct enet_statistics *stats = (struct enet_statistics *) dev->priv;
     struct net_local *lp = (struct net_local *)dev->priv;
     struct plip_local *snd = &lp->snd_data;
-    unsigned char *lbuf = snd->skb->data;
+    unsigned char *lbuf = skb_data(snd->skb);
     unsigned char c0;
     unsigned int cx;
     unsigned char *s =  PLIP_STATE_STRING(snd->state);
