From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9608081636.ZM1292@Gepard.Informatik.RWTH-Aachen.DE> Date: Thu, 8 Aug 1996 16:36:47 -0600 From: Stefan Kanthak Subject: Re: PLIP In-Reply-To: Hello Alphicians! > I was able to ifconfig plip on the laptop just fine, but the moment I tried to > bring up the plip interface on the Alpha, the machine locked up solid. I had > to power cycle it. I had some trouble with PLIP, too, and took a look in the kernel driver. "Ooouh, what a mess", I though when I saw the broken code there. I tried to fix it and was sort of succesful. ifconfig does no longer crash, but I was still not able to do a ping to my notebook. It may work, because my notebook does not connect to other Intel boxes via PLIP. I am in a hurry and offline for 2.5 weeks from now on. But it is probably a good start to fix the PLIP driver competely (it is from kernel version 1.3.99 but should not have changed till now). Below is a small patch to be applied against 'plip.c.old' (rename first) in the directory linux/drivers/net. To Eric and Jay: I don't believe it is an interrupt problem, because I only fixed some lines which are _reasonably_ wrong code, and it worked much better! Small hint: install the modules package first if you want to experiment with the driver. Then you can easily load/unload it to/from kernel which saves lots of time. Ciao, Stephan -----------8<------------------------------------------------------------------- *** plip.c.old Thu Aug 8 16:23:57 1996 --- plip.c Thu Aug 8 16:29:20 1996 *************** *** 8,13 **** --- 8,14 ---- * Alan Cox, * Peter Bauer, <100136.3530@compuserve.com> * Niibe Yutaka, + * Stephan Kanthak * * Modularization and ifreq/ifmap support by Alan Cox. * Rewritten by Niibe Yutaka. *************** *** 20,26 **** * - added message if driver loaded as a module but no * interfaces present. * - release claimed I/O ports if malloc() fails during init. ! * * Niibe Yutaka * - Module initialization. You can specify I/O addr and IRQ: * # insmod plip.o io=0x3bc irq=7 --- 21,27 ---- * - added message if driver loaded as a module but no * interfaces present. * - release claimed I/O ports if malloc() fails during init. ! * * Niibe Yutaka * - Module initialization. You can specify I/O addr and IRQ: * # insmod plip.o io=0x3bc irq=7 *************** *** 28,33 **** --- 29,37 ---- * - Make sure other end is OK, before sending a packet. * - Fix immediate timer problem. * + * Stephan Kanthak + * - alpha fixes (might be incomplete) + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version *************** *** 44,50 **** * Crynwr packet driver, Peter Bauer changed the protocol again * back to original protocol. * ! * This version follows original PLIP protocol. * So, this PLIP can't communicate the PLIP of Linux v1.0. */ --- 48,54 ---- * Crynwr packet driver, Peter Bauer changed the protocol again * back to original protocol. * ! * This version follows original PLIP protocol. * So, this PLIP can't communicate the PLIP of Linux v1.0. */ *************** *** 144,150 **** /* Functions for DEV methods */ static int plip_rebuild_header(void *buff, struct device *dev, ! unsigned long raddr, struct sk_buff *skb); static int plip_tx_packet(struct sk_buff *skb, struct device *dev); static int plip_open(struct device *dev); static int plip_close(struct device *dev); --- 148,154 ---- /* Functions for DEV methods */ static int plip_rebuild_header(void *buff, struct device *dev, ! unsigned int raddr, struct sk_buff *skb); static int plip_tx_packet(struct sk_buff *skb, struct device *dev); static int plip_open(struct device *dev); static int plip_close(struct device *dev); *************** *** 151,157 **** static struct enet_statistics *plip_get_stats(struct device *dev); static int plip_config(struct device *dev, struct ifmap *map); static int plip_ioctl(struct device *dev, struct ifreq *ifr, int cmd); ! enum plip_connection_state { PLIP_CN_NONE=0, PLIP_CN_RECEIVE, --- 155,161 ---- static struct enet_statistics *plip_get_stats(struct device *dev); static int plip_config(struct device *dev, struct ifmap *map); static int plip_ioctl(struct device *dev, struct ifreq *ifr, int cmd); ! enum plip_connection_state { PLIP_CN_NONE=0, PLIP_CN_RECEIVE, *************** *** 188,194 **** unsigned char lsb; #else #error "Please fix the endianness defines in " ! #endif } b; unsigned short h; } length; --- 192,198 ---- unsigned char lsb; #else #error "Please fix the endianness defines in " ! #endif } b; unsigned short h; } length; *************** *** 210,218 **** unsigned short timeout_count; char is_deferred; int (*orig_rebuild_header)(void *eth, struct device *dev, ! unsigned long raddr, struct sk_buff *skb); }; ! /* Entry point of PLIP driver. Probe the hardware, and register/initialize the driver. */ int --- 214,222 ---- unsigned short timeout_count; char is_deferred; int (*orig_rebuild_header)(void *eth, struct device *dev, ! unsigned int raddr, struct sk_buff *skb); }; ! /* Entry point of PLIP driver. Probe the hardware, and register/initialize the driver. */ int *************** *** 303,309 **** return 0; } ! /* Bottom half handler for the delayed request. This routine is kicked by do_timer(). Request `plip_bh' to be invoked. */ --- 307,313 ---- return 0; } ! /* Bottom half handler for the delayed request. This routine is kicked by do_timer(). Request `plip_bh' to be invoked. */ *************** *** 432,438 **** return TIMEOUT; } ! static int plip_none(struct device *dev, struct net_local *nl, struct plip_local *snd, struct plip_local *rcv) --- 436,442 ---- return TIMEOUT; } ! static int plip_none(struct device *dev, struct net_local *nl, struct plip_local *snd, struct plip_local *rcv) *************** *** 537,543 **** return TIMEOUT; if (rcv->length.h > dev->mtu + dev->hard_header_len || rcv->length.h < 8) { ! printk("%s: bogus packet size %d.\n", dev->name, rcv->length.h); return ERROR; } /* Malloc up new buffer. */ --- 541,548 ---- return TIMEOUT; if (rcv->length.h > dev->mtu + dev->hard_header_len || rcv->length.h < 8) { ! printk("%s: bogus packet size %d.\n", dev->name, ! rcv->length.h); return ERROR; } /* Malloc up new buffer. */ *************** *** 555,561 **** case PLIP_PK_DATA: lbuf = rcv->skb->data; do ! if (plip_receive(nibble_timeout, status_addr, &rcv->nibble, &lbuf[rcv->byte])) return TIMEOUT; while (++rcv->byte < rcv->length.h); --- 560,566 ---- case PLIP_PK_DATA: lbuf = rcv->skb->data; do ! if (plip_receive(nibble_timeout, status_addr, &rcv->nibble, &lbuf[rcv->byte])) return TIMEOUT; while (++rcv->byte < rcv->length.h); *************** *** 607,613 **** return OK; } ! /* PLIP_SEND --- send a byte (two nibbles) Returns OK on success, TIMEOUT when timeout */ inline static int plip_send(unsigned short nibble_timeout, unsigned short data_addr, --- 612,618 ---- return OK; } ! /* PLIP_SEND --- send a byte (two nibbles) Returns OK on success, TIMEOUT when timeout */ inline static int plip_send(unsigned short nibble_timeout, unsigned short data_addr, *************** *** 627,633 **** data_addr++; while (1) { c0 = inb(data_addr); ! if ((c0 & 0x80) == 0) break; if (--cx == 0) return TIMEOUT; --- 632,638 ---- data_addr++; while (1) { c0 = inb(data_addr); ! if ((c0 & 0x80) == 0) break; if (--cx == 0) return TIMEOUT; *************** *** 799,805 **** return OK; } ! /* Handle the parallel port interrupts. */ static void plip_interrupt(int irq, void *dev_id, struct pt_regs * regs) --- 804,810 ---- return OK; } ! /* Handle the parallel port interrupts. */ static void plip_interrupt(int irq, void *dev_id, struct pt_regs * regs) *************** *** 844,850 **** case PLIP_CN_RECEIVE: sti(); ! printk("%s: receive interrupt when receiving packet\n", dev->name); break; case PLIP_CN_ERROR: --- 849,856 ---- case PLIP_CN_RECEIVE: sti(); ! printk("%s: receive interrupt when receiving packet\n", ! dev->name); break; case PLIP_CN_ERROR: *************** *** 853,862 **** break; } } ! /* 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 net_local *nl = (struct net_local *)dev->priv; --- 859,868 ---- break; } } ! /* We don't need to send arp, for plip is point-to-point. */ static int ! plip_rebuild_header(void *buff, struct device *dev, unsigned int dst, struct sk_buff *skb) { struct net_local *nl = (struct net_local *)dev->priv; *************** *** 867,880 **** return nl->orig_rebuild_header(buff, dev, dst, skb); 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; } --- 873,887 ---- return nl->orig_rebuild_header(buff, dev, dst, skb); 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 int); i++) eth->h_dest[i] = 0xfc; ! memcpy(&(eth->h_dest[i]), &dst, sizeof(unsigned int)); return 0; } *************** *** 938,944 **** int i; if (dev->irq == 0) { ! printk("%s: IRQ is not set. Please set it by ifconfig.\n", dev->name); return -EAGAIN; } cli(); --- 945,952 ---- int i; if (dev->irq == 0) { ! printk("%s: IRQ is not set. Please set it by ifconfig.\n", ! dev->name); return -EAGAIN; } cli(); *************** *** 963,971 **** nl->is_deferred = 0; /* Fill in the MAC-level header. */ ! 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)); dev->interrupt = 0; dev->start = 1; --- 971,979 ---- nl->is_deferred = 0; /* Fill in the MAC-level header. */ ! for (i=0; i < ETH_ALEN - sizeof(unsigned int); i++) dev->dev_addr[i] = 0xfc; ! memcpy(&(dev->dev_addr[i]), &dev->pa_addr, sizeof(unsigned int)); dev->interrupt = 0; dev->start = 1; *************** *** 1025,1033 **** if (dev->flags & IFF_UP) return -EBUSY; ! if (map->base_addr != (unsigned long)-1 && map->base_addr != dev->base_addr) ! printk("%s: You cannot change base_addr of this interface (ignored).\n", dev->name); if (map->irq != (unsigned char)-1) dev->irq = map->irq; --- 1033,1042 ---- if (dev->flags & IFF_UP) return -EBUSY; ! if (map->base_addr != (unsigned short)-1 && map->base_addr != dev->base_addr) ! printk("%s: You cannot change base_addr of this interface ! (ignored).\n", dev->name); if (map->irq != (unsigned char)-1) dev->irq = map->irq; *************** *** 1039,1045 **** { struct net_local *nl = (struct net_local *) dev->priv; struct plipconf *pc = (struct plipconf *) &rq->ifr_data; ! switch(pc->pcmd) { case PLIP_GET_TIMEOUT: pc->trigger = nl->trigger; --- 1048,1054 ---- { struct net_local *nl = (struct net_local *) dev->priv; struct plipconf *pc = (struct plipconf *) &rq->ifr_data; ! switch(pc->pcmd) { case PLIP_GET_TIMEOUT: pc->trigger = nl->trigger; *************** *** 1054,1060 **** } return 0; } ! #ifdef MODULE static int io[] = {0, 0, 0}; static int irq[] = {0, 0, 0}; --- 1063,1069 ---- } return 0; } ! #ifdef MODULE static int io[] = {0, 0, 0}; static int irq[] = {0, 0, 0}; *************** *** 1064,1082 **** "plip0", 0, 0, 0, 0, /* memory */ 0x3BC, 5, /* base, irq */ ! 0, 0, 0, NULL, plip_init }, { "plip1", 0, 0, 0, 0, /* memory */ 0x378, 7, /* base, irq */ ! 0, 0, 0, NULL, plip_init }, { "plip2", 0, 0, 0, 0, /* memory */ 0x278, 2, /* base, irq */ ! 0, 0, 0, NULL, plip_init } }; --- 1073,1091 ---- "plip0", 0, 0, 0, 0, /* memory */ 0x3BC, 5, /* base, irq */ ! 0, 0, 0, NULL, plip_init }, { "plip1", 0, 0, 0, 0, /* memory */ 0x378, 7, /* base, irq */ ! 0, 0, 0, NULL, plip_init }, { "plip2", 0, 0, 0, 0, /* memory */ 0x278, 2, /* base, irq */ ! 0, 0, 0, NULL, plip_init } }; *************** *** 1111,1117 **** return 0; /* No parameters. Default action is probing all interfaces. */ ! for (i=0; i < 3; i++) { if (register_netdev(&dev_plip[i]) == 0) devices++; } --- 1120,1126 ---- return 0; /* No parameters. Default action is probing all interfaces. */ ! for (i=0; i < 3; i++) { if (register_netdev(&dev_plip[i]) == 0) devices++; } *************** *** 1130,1136 **** for (i=0; i < 3; i++) { if (dev_plip[i].priv) { unregister_netdev(&dev_plip[i]); ! release_region(PAR_DATA(&dev_plip[i]), (PAR_DATA(&dev_plip[i]) == 0x3bc)? 3 : 8); kfree_s(dev_plip[i].priv, sizeof(struct net_local)); dev_plip[i].priv = NULL; } --- 1139,1146 ---- for (i=0; i < 3; i++) { if (dev_plip[i].priv) { unregister_netdev(&dev_plip[i]); ! release_region(PAR_DATA(&dev_plip[i]), ! (PAR_DATA(&dev_plip[i]) == 0x3bc)? 3 : 8); kfree_s(dev_plip[i].priv, sizeof(struct net_local)); dev_plip[i].priv = NULL; } *************** *** 1137,1145 **** } } #endif /* MODULE */ ! /* * Local variables: ! * compile-command: "gcc -DMODULE -DMODVERSIONS -D__KERNEL__ -Wall -Wstrict-prototypes -O2 -g -fomit-frame-pointer -pipe -m486 -c plip.c" * End: */ --- 1147,1156 ---- } } #endif /* MODULE */ ! /* * Local variables: ! * compile-command: "gcc -DMODULE -DMODVERSIONS -D__KERNEL__ -Wall ! -Wstrict-prototypes -O2 -g -fomit-frame-pointer -pipe -m486 -c plip.c" * End: */ ------------------------------------------------------------------>8------------ -- _______________________________________________________________________________ Stephan Kanthak Department of Computer Science VI Pattern- and Speech Recognition Research RWTH Aachen, Germany """"" e-mail: kanthak@i6.informatik.rwth-aachen.de | | http://www.informatik.rwth-aachen.de/I6/Colleagues/kanthak/ O - ______________________________________________________________.oO_| u |_Oo.____ \_/ -- To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null