/* Routine to read len bytes from the i82593's ring buffer, starting at chip address addr. The results read from the chip are stored in buf. The return value is the address to use for next the call.  */
static int read_ringbuf(struct net_device *dev, int addr, char *buf, int len)
/* Routine to read len bytes from the i82593's ring buffer, starting at chip address addr. The results read from the chip are stored in buf. The return value is the address to use for next the call.  */
static int read_ringbuf(struct net_device *dev, int addr, char *buf, int len)
{
  unsigned int	base = dev->base_addr;
  int		ring_ptr = addr;
  int		chunk_len;
  char *	buf_ptr = buf;
  while(len > 0)
    {
      outb(ring_ptr & 0xff, PIORL(base));
      outb(((ring_ptr >> 8) & PIORH_MASK), PIORH(base));
      if((addr + len) < (RX_BASE + RX_SIZE))
	chunk_len = len;
      else
	chunk_len = RX_BASE + RX_SIZE - addr;
      insb(PIOP(base), buf_ptr, chunk_len);
      buf_ptr += chunk_len;
      len -= chunk_len;
      ring_ptr = (ring_ptr - RX_BASE + chunk_len) % RX_SIZE + RX_BASE;
    }
  return(ring_ptr);
}