/* The typical workload of the driver: Handle the network interface interrupts. */ static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct device *dev = (struct device *)(irq2dev_map[irq]); struct net_local *lp; int ioaddr, status; if (dev == NULL) { printk ("fmv18x_interrupt(): irq %d for unknown device.\n", irq); return; } dev->interrupt = 1; ioaddr = dev->base_addr; lp = (struct net_local *)dev->priv; /* Avoid multiple interrupts. */ outw(0x0000, ioaddr + TX_INTR); status = inw(ioaddr + TX_STATUS); outw(status, ioaddr + TX_STATUS); if (net_debug > 4) printk("%s: Interrupt with status %04x.\n", dev->name, status); if (status & 0xff00 || (inb(ioaddr + RX_MODE) & 0x40) == 0) { /* Got a packet(s). */ net_rx(dev); } if (status & 0x00ff) { if (status & 0x80) { lp->stats.tx_packets++; if (lp->tx_queue) { outb(0x80 | lp->tx_queue, ioaddr + TX_START); lp->tx_queue = 0; lp->tx_queue_len = 0; dev->trans_start = jiffies; dev->tbusy = 0; mark_bh(NET_BH); /* Inform upper layers. */ } else { lp->tx_started = 0; dev->tbusy = 0; mark_bh(NET_BH); /* Inform upper layers. */ } } if (status & 0x02 ) { if (net_debug > 4) printk("%s: 16 Collision occur during Txing.\n", dev->name); /* Retry to send the packet */ outb(0x02, ioaddr + COL16CNTL); } } dev->interrupt = 0; outw(0x8182, ioaddr + TX_INTR); return; }
/* The typical workload of the driver: Handle the network interface interrupts. */ static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct net_device *dev = dev_id; struct net_local *lp; int ioaddr, status; ioaddr = dev->base_addr; lp = dev->priv; status = inw(ioaddr + TX_STATUS); outw(status, ioaddr + TX_STATUS); if (net_debug > 4) printk("%s: Interrupt with status %04x.\n", dev->name, status); if (lp->rx_started == 0 && (status & 0xff00 || (inb(ioaddr + RX_MODE) & 0x40) == 0)) { /* Got a packet(s). We cannot execute net_rx more than once at the same time for the same device. During executing net_rx, we possibly catch a Tx interrupt. Thus we flag on rx_started, so that we prevent the interrupt routine (net_interrupt) to dive into net_rx again. */ lp->rx_started = 1; outb(0x00, ioaddr + RX_INTR); /* Disable RX intr. */ net_rx(dev); outb(0x81, ioaddr + RX_INTR); /* Enable RX intr. */ lp->rx_started = 0; } if (status & 0x00ff) { if (status & 0x02) { /* More than 16 collisions occurred */ if (net_debug > 4) printk("%s: 16 Collision occur during Txing.\n", dev->name); /* Cancel sending a packet. */ outb(0x03, ioaddr + COL16CNTL); lp->stats.collisions++; } if (status & 0x82) { spin_lock(&lp->lock); lp->stats.tx_packets++; if (lp->tx_queue && lp->tx_queue_ready) { outb(0x80 | lp->tx_queue, ioaddr + TX_START); lp->tx_queue = 0; lp->tx_queue_len = 0; dev->trans_start = jiffies; netif_wake_queue(dev); /* Inform upper layers. */ } else { lp->tx_started = 0; netif_wake_queue(dev); /* Inform upper layers. */ } spin_unlock(&lp->lock); } } return; }
/* The typical workload of the driver: Handle the network interface interrupts. */ static void net_interrupt(int reg_ptr) { int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2); struct device *dev = (struct device *)(irq2dev_map[irq]); struct net_local *lp; int ioaddr, status, boguscount = 0; if (dev == NULL) { printk ("net_interrupt(): irq %d for unknown device.\n", irq); return; } dev->interrupt = 1; ioaddr = dev->base_addr; lp = (struct net_local *)dev->priv; status = inw(ioaddr + 0); do { if (status /*& RX_INTR*/) { /* Got a packet(s). */ net_rx(dev); } if (status /*& TX_INTR*/) { lp->stats.tx_packets++; dev->tbusy = 0; mark_bh(INET_BH); /* Inform upper layers. */ } if (status /*& COUNTERS_INTR*/) { /* Increment the appropriate 'localstats' field. */ lp->stats.tx_window_errors++; } } while (++boguscount < 20) ; return; }
/* The typical workload of the driver: Handle the network interface interrupts. */ static irqreturn_t net_interrupt(int irq, void *dev_id) { struct net_device *dev = dev_id; struct net_local *lp; int ioaddr, status; if (dev == NULL) { printk ("net_interrupt(): irq %d for unknown device.\n", irq); return IRQ_NONE; } ioaddr = dev->base_addr; lp = netdev_priv(dev); /* we MUST read all the events out of the ISQ, otherwise we'll never get interrupted again. As a consequence, we can't have any limit on the number of times we loop in the interrupt handler. The hardware guarantees that eventually we'll run out of events. Of course, if you're on a slow machine, and packets are arriving faster than you can read them off, you're screwed. Hasta la vista, baby! */ while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) { if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); switch(status & ISQ_EVENT_MASK) { case ISQ_RECEIVER_EVENT: /* Got a packet(s). */ net_rx(dev); break; case ISQ_TRANSMITTER_EVENT: lp->stats.tx_packets++; netif_wake_queue(dev); if ((status & TX_OK) == 0) lp->stats.tx_errors++; if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++; if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++; if (status & TX_LATE_COL) lp->stats.tx_window_errors++; if (status & TX_16_COL) lp->stats.tx_aborted_errors++; break; case ISQ_BUFFER_EVENT: if (status & READY_FOR_TX) { /* we tried to transmit a packet earlier, but inexplicably ran out of buffers. That shouldn't happen since we only ever load one packet. Shrug. Do the right thing anyway. */ netif_wake_queue(dev); } if (status & TX_UNDERRUN) { if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); lp->send_underrun++; if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381; else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL; } break; case ISQ_RX_MISS_EVENT: lp->stats.rx_missed_errors += (status >>6); break; case ISQ_TX_COL_EVENT: lp->stats.collisions += (status >>6); break; } } return IRQ_HANDLED; }
/* The typical workload of the driver: Handle the network interface interrupts. */ void cs8900_interrupt(int irq, void *dev_id, struct pt_regs * regs) { struct device *dev = (struct device *)(irq2dev_map[/* FIXME */0]); struct net_local *lp; int ioaddr, status; dev = irq2dev_map[0]; if (dev == NULL) { printk ("net_interrupt(): irq %d for unknown device.\n", irq); return; } if (dev->interrupt) printk("%s: Re-entering the interrupt handler.\n", dev->name); dev->interrupt = 1; ioaddr = dev->base_addr; lp = (struct net_local *)dev->priv; /* we MUST read all the events out of the ISQ, otherwise we'll never get interrupted again. As a consequence, we can't have any limit on the number of times we loop in the interrupt handler. The hardware guarantees that eventually we'll run out of events. Of course, if you're on a slow machine, and packets are arriving faster than you can read them off, you're screwed. Hasta la vista, baby! */ while ((status = readword(dev, ISQ_PORT))) { if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); switch(status & ISQ_EVENT_MASK) { case ISQ_RECEIVER_EVENT: /* Got a packet(s). */ net_rx(dev); break; case ISQ_TRANSMITTER_EVENT: lp->stats.tx_packets++; dev->tbusy = 0; mark_bh(NET_BH); /* Inform upper layers. */ if ((status & TX_OK) == 0) lp->stats.tx_errors++; if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++; if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++; if (status & TX_LATE_COL) lp->stats.tx_window_errors++; if (status & TX_16_COL) lp->stats.tx_aborted_errors++; break; case ISQ_BUFFER_EVENT: if (status & READY_FOR_TX) { /* we tried to transmit a packet earlier, but inexplicably ran out of buffers. That shouldn't happen since we only ever load one packet. Shrug. Do the right thing anyway. */ dev->tbusy = 0; mark_bh(NET_BH); /* Inform upper layers. */ } if (status & TX_UNDERRUN) { if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); lp->send_underrun++; if (lp->send_underrun > 3) lp->send_cmd = TX_AFTER_ALL; } break; case ISQ_RX_MISS_EVENT: lp->stats.rx_missed_errors += (status >>6); break; case ISQ_TX_COL_EVENT: lp->stats.collisions += (status >>6); break; } } dev->interrupt = 0; return; }
/* The typical workload of the driver: Handle the network interface interrupts. */ void cs8900_interrupt(int irq, void *dev_id, struct pt_regs * regs) { struct net_device *dev = dev_id; struct net_local *lp; int ioaddr, status; volatile unsigned long *icrp; #if defined (CONFIG_BOARD_UC5272) /* clear INT1 */ icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); *icrp = (*icrp & 0x77777777) | 0x80000000; #endif ioaddr = dev->base_addr; lp = (struct net_local *)dev->priv; /* we MUST read all the events out of the ISQ, otherwise we'll never get interrupted again. As a consequence, we can't have any limit on the number of times we loop in the interrupt handler. The hardware guarantees that eventually we'll run out of events. Of course, if you're on a slow machine, and packets are arriving faster than you can read them off, you're screwed. Hasta la vista, baby! */ while ((status = readword(dev, ISQ_PORT))) { #if 1 /* OZH */ if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); #endif switch(status & ISQ_EVENT_MASK) { case ISQ_RECEIVER_EVENT: /* Got a packet(s). */ net_rx(dev); break; case ISQ_TRANSMITTER_EVENT: lp->stats.tx_packets++; netif_wake_queue(dev); if ((status & TX_OK) == 0) lp->stats.tx_errors++; if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++; if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++; if (status & TX_LATE_COL) lp->stats.tx_window_errors++; if (status & TX_16_COL) lp->stats.tx_aborted_errors++; break; case ISQ_BUFFER_EVENT: if (status & READY_FOR_TX) { /* we tried to transmit a packet earlier, but inexplicably ran out of buffers. That shouldn't happen since we only ever load one packet. Shrug. Do the right thing anyway. */ netif_wake_queue(dev); } if (status & TX_UNDERRUN) { if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); lp->send_underrun++; if (lp->send_underrun > 3) lp->send_cmd = TX_AFTER_ALL; } break; case ISQ_RX_MISS_EVENT: lp->stats.rx_missed_errors += (status >>6); break; case ISQ_TX_COL_EVENT: lp->stats.collisions += (status >>6); break; } } }