示例#1
0
文件: ni52.c 项目: xricson/knoppix
/*
 * DUMP .. we expect a not running CMD unit and enough space
 */
void ni52_dump(struct net_device *dev,void *ptr)
{
	struct priv *p = (struct priv *) dev->priv;
	struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
	int i;

	p->scb->cmd_cuc = CUC_ABORT;
	ni_attn586();
	WAIT_4_SCB_CMD();
	WAIT_4_SCB_CMD_RUC();

	dump_cmd->cmd_status = 0;
	dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
	dump_cmd->dump_offset = make16((dump_cmd + 1));
	dump_cmd->cmd_link = 0xffff;

	p->scb->cbl_offset = make16(dump_cmd);
	p->scb->cmd_cuc = CUC_START;
	ni_attn586();
	WAIT_4_STAT_COMPL(dump_cmd);

	if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
				printk("%s: Can't get dump information.\n",dev->name);

	for(i=0;i<170;i++) {
		printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
		if(i % 24 == 23)
			printk("\n");
	}
	printk("\n");
}
示例#2
0
文件: ni52.c 项目: xricson/knoppix
static void ni52_timeout(struct net_device *dev)
{
	struct priv *p = (struct priv *) dev->priv;
#ifndef NO_NOPCOMMANDS
	if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
	{
		netif_wake_queue(dev);
#ifdef DEBUG
		printk("%s: strange ... timeout with CU active?!?\n",dev->name);
		printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)p->xmit_cmds[0]->cmd_status,(int)p->nop_cmds[0]->cmd_status,(int)p->nop_cmds[1]->cmd_status,(int)p->nop_point);
#endif
		p->scb->cmd_cuc = CUC_ABORT;
		ni_attn586();
		WAIT_4_SCB_CMD();
		p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
		p->scb->cmd_cuc = CUC_START;
		ni_attn586();
		WAIT_4_SCB_CMD();
		dev->trans_start = jiffies;
		return 0;
	}
#endif
	{
#ifdef DEBUG
		printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
		printk("%s: command-stats: %04x %04x\n",dev->name,p->xmit_cmds[0]->cmd_status,p->xmit_cmds[1]->cmd_status);
		printk("%s: check, whether you set the right interrupt number!\n",dev->name);
#endif
		ni52_close(dev);
		ni52_open(dev);
	}
	dev->trans_start = jiffies;
}
示例#3
0
文件: ni52.c 项目: openmach/openmach
static void ni52_interrupt(int irq,struct pt_regs *reg_ptr)
{
  struct device *dev = (struct device *) irq2dev_map[irq];
  unsigned short stat;
  struct priv *p;

  if (dev == NULL) {
    printk ("ni52-interrupt: irq %d for unknown device.\n",(int) -(((struct pt_regs *)reg_ptr)->orig_eax+2));
    return;
  }
  p = (struct priv *) dev->priv;

  dev->interrupt = 1;

  while((stat=p->scb->status & STAT_MASK))
  {
    p->scb->cmd = stat;
    ni_attn586(); /* ack inter. */

   if(stat & STAT_CX)    /* command with I-bit set complete */
      ni52_xmt_int(dev);

    if(stat & STAT_FR)   /* received a frame */
      ni52_rcv_int(dev);

#ifndef NO_NOPCOMMANDS
    if(stat & STAT_CNA)  /* CU went 'not ready' */
    {
      if(dev->start)
        printk("%s: oops! CU has left active state. stat: %04x/%04x.\n",dev->name,(int) stat,(int) p->scb->status);
    }
#endif

    if(stat & STAT_RNR) /* RU went 'not ready' */
    {
      if(p->scb->status & RU_SUSPEND) /* special case: RU_SUSPEND */
      {
        WAIT_4_SCB_CMD();
        p->scb->cmd = RUC_RESUME;
        ni_attn586();
      }
      else
      {
        printk("%s: Receiver-Unit went 'NOT READY': %04x/%04x.\n",dev->name,(int) stat,(int) p->scb->status);
        ni52_rnr_int(dev); 
      }
    }
    WAIT_4_SCB_CMD(); /* wait for ack. (ni52_xmt_int can be faster than ack!!) */
    if(p->scb->cmd)   /* timed out? */
      break;
  }

  dev->interrupt = 0;
}
示例#4
0
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs)
{
/*
  struct priv *p = (struct priv *) dev->priv;
  volatile struct configure_cmd_struct  *cfg_cmd;
*/

  if(!num_addrs)
    printk("%s: Currently, the Ni52 driver doesn't support promiscuous or multicast mode.\n",dev->name);

#if 0
  p->scb->cmd = CUC_SUSPEND;
  ni_attn586();
  while(p->scb->cmd);
  p->scb->cmd = RUC_SUSPEND; 
  ni_attn586();
  while(p->scb->cmd);

  cfg_cmd = (struct configure_cmd_struct *) p->xmit_cbuffs[0]; /* we're using a transmitcommand */
 
  cfg_cmd->cmd_status = 0;
  cfg_cmd->cmd_cmd    = CMD_CONFIGURE | CMD_LAST;
  cfg_cmd->cmd_link   = 0xffff;

  cfg_cmd->byte_cnt   = 0x0a; /* number of cfg bytes */
  cfg_cmd->fifo       = 0x08; /* fifo-limit (8=tx:32/rx:64) */
  cfg_cmd->sav_bf     = 0x40; /* hold or discard bad recv frames (bit 7) */
  cfg_cmd->adr_len    = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
  cfg_cmd->priority   = 0x00;
  cfg_cmd->ifd        = 0x60;
  cfg_cmd->time_low   = 0x00;
  cfg_cmd->time_high  = 0xf2;
  cfg_cmd->promisc    = 0x01; /* promisc on */
  cfg_cmd->carr_coll  = 0x00;

  p->scb->cbl_offset = make16(cfg_cmd);

  p->scb->cmd = CUC_START; /* cmd.-unit start */
  ni_attn586();
  while(p->scb->cmd);

  p->scb->cbl_offset = p->nop_cmds[0]->cmd_link = make16(p->nop_cmds[0]);
  p->scb->cmd = CUC_START;
  ni_atthn586();
  while(p->scb->cmd);
  p->scb->cmd = RUC_RESUME;
  ni_atthn586();
  while(p->scb->cmd);
#endif

}
示例#5
0
static void startrecv586(struct device *dev)
{
  struct priv *p = (struct priv *) dev->priv;

  p->scb->rfa_offset = make16(p->rfd_first);
  p->scb->cmd = RUC_START;
  ni_attn586(); /* start cmd. */
  while(p->scb->cmd); /* wait for accept cmd. (no timeout!!) */

  DELAY(2); /* isn't necess. */

  p->scb->cmd = p->scb->status & STAT_MASK;
  ni_attn586(); /* ack interr */
}
示例#6
0
文件: ni52.c 项目: xricson/knoppix
/******************************************************************
 * set iscp at the right place, called by ni52_probe1 and open586.
 */
static void alloc586(struct net_device *dev)
{
	struct priv *p =	(struct priv *) dev->priv;

	ni_reset586();
	DELAY(1);

	p->scp	= (struct scp_struct *)	(p->base + SCP_DEFAULT_ADDRESS);
	p->scb	= (struct scb_struct *)	isa_bus_to_virt(dev->mem_start);
	p->iscp = (struct iscp_struct *) ((char *)p->scp - sizeof(struct iscp_struct));

	memset((char *) p->iscp,0,sizeof(struct iscp_struct));
	memset((char *) p->scp ,0,sizeof(struct scp_struct));

	p->scp->iscp = make24(p->iscp);
	p->scp->sysbus = SYSBUSVAL;
	p->iscp->scb_offset = make16(p->scb);

	p->iscp->busy = 1;
	ni_reset586();
	ni_attn586();

	DELAY(1);

	if(p->iscp->busy)
		printk("%s: Init-Problems (alloc).\n",dev->name);

	p->reseted = 0;

	memset((char *)p->scb,0,sizeof(struct scb_struct));
}
示例#7
0
void alloc586(struct device *dev)
{
  struct priv *p =  (struct priv *) dev->priv; 

  p->scp  = (struct scp_struct *)  (p->base + SCP_DEFAULT_ADDRESS);
  p->scb  = (struct scb_struct *)  (dev->mem_start);
  p->iscp = (struct iscp_struct *) ((char *)p->scp - sizeof(struct iscp_struct));

  memset((char *) p->iscp,0,sizeof(struct iscp_struct));
  memset((char *) p->scp ,0,sizeof(struct scp_struct));

  p->scp->iscp = make24(p->iscp);
  p->scp->sysbus = SYSBUSVAL;
  p->iscp->scb_offset = make16(p->scb);

  p->iscp->busy = 1;
  ni_reset586();
  ni_attn586();

#ifdef DEBUG
  DELAY(2); 

  if(p->iscp->busy)
    printk("%s: Init-Problems (alloc).\n",dev->name);
#endif

  memset((char *)p->scb,0,sizeof(struct scb_struct));
}
示例#8
0
static int check586(struct device *dev,char *where,unsigned size)
{
  struct priv *p = (struct priv *) dev->priv;
  char *iscp_addrs[2];
  int i;

  p->base = (unsigned long) where + size - 0x01000000;
  p->memtop = where + size;
  p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
  memset((char *)p->scp,0, sizeof(struct scp_struct));
  p->scp->sysbus = SYSBUSVAL;        /* 1 = 8Bit-Bus */
  
  iscp_addrs[0] = where;
  iscp_addrs[1]= (char *) p->scp - sizeof(struct iscp_struct);

  for(i=0;i<2;i++)
  {
    p->iscp = (struct iscp_struct *) iscp_addrs[i];
    memset((char *)p->iscp,0, sizeof(struct iscp_struct));

    p->scp->iscp = make24(p->iscp);
    p->iscp->busy = 1;

    ni_reset586();
    ni_attn586();
    DELAY(2);	/* wait a while... */

    if(p->iscp->busy)
      return 0;
  }
  return 1;
}
示例#9
0
static void alloc586(struct net_device *dev)
{
	struct priv *p = netdev_priv(dev);

	ni_reset586();
	mdelay(32);

	memset_io(p->iscp, 0, sizeof(struct iscp_struct));
	memset_io(p->scp , 0, sizeof(struct scp_struct));

	writel(make24(p->iscp), &p->scp->iscp);
	writeb(SYSBUSVAL, &p->scp->sysbus);
	writew(make16(p->scb), &p->iscp->scb_offset);

	writeb(1, &p->iscp->busy);
	ni_reset586();
	ni_attn586();

	mdelay(32);

	if (readb(&p->iscp->busy))
		printk(KERN_ERR "%s: Init-Problems (alloc).\n", dev->name);

	p->reset = 0;

	memset_io(p->scb, 0, sizeof(struct scb_struct));
}
示例#10
0
文件: ni52.c 项目: openmach/openmach
static void startrecv586(struct device *dev)
{
  struct priv *p = (struct priv *) dev->priv;

  p->scb->rfa_offset = make16(p->rfd_first);
  p->scb->cmd = RUC_START;
  ni_attn586();		/* start cmd. */
  WAIT_4_SCB_CMD();	/* wait for accept cmd. (no timeout!!) */
}
示例#11
0
static void ni52_timeout(struct net_device *dev)
{
	struct priv *p = netdev_priv(dev);
#ifndef NO_NOPCOMMANDS
	if (readb(&p->scb->cus) & CU_ACTIVE) { /*                      */
		netif_wake_queue(dev);
#ifdef DEBUG
		printk(KERN_ERR "%s: strange ... timeout with CU active?!?\n",
			dev->name);
		printk(KERN_ERR "%s: X0: %04x N0: %04x N1: %04x %d\n",
			dev->name, (int)p->xmit_cmds[0]->cmd_status,
			readw(&p->nop_cmds[0]->cmd_status),
			readw(&p->nop_cmds[1]->cmd_status),
			p->nop_point);
#endif
		writeb(CUC_ABORT, &p->scb->cmd_cuc);
		ni_attn586();
		wait_for_scb_cmd(dev);
		writew(make16(p->nop_cmds[p->nop_point]), &p->scb->cbl_offset);
		writeb(CUC_START, &p->scb->cmd_cuc);
		ni_attn586();
		wait_for_scb_cmd(dev);
		dev->trans_start = jiffies; /*                    */
		return 0;
	}
#endif
	{
#ifdef DEBUG
		printk(KERN_ERR "%s: xmitter timed out, try to restart! stat: %02x\n",
				dev->name, readb(&p->scb->cus));
		printk(KERN_ERR "%s: command-stats: %04x %04x\n",
				dev->name,
				readw(&p->xmit_cmds[0]->cmd_status),
				readw(&p->xmit_cmds[1]->cmd_status));
		printk(KERN_ERR "%s: check, whether you set the right interrupt number!\n",
				dev->name);
#endif
		ni52_close(dev);
		ni52_open(dev);
	}
	dev->trans_start = jiffies; /*                    */
}
示例#12
0
static void startrecv586(struct net_device *dev)
{
	struct priv *p = netdev_priv(dev);

	wait_for_scb_cmd(dev);
	wait_for_scb_cmd_ruc(dev);
	writew(make16(p->rfd_first), &p->scb->rfa_offset);
	writeb(RUC_START, &p->scb->cmd_ruc);
	ni_attn586();		/*            */
	wait_for_scb_cmd_ruc(dev);
	/*                                     */
}
示例#13
0
文件: ni52.c 项目: maraz/linux-2.6
static void startrecv586(struct net_device *dev)
{
	struct priv *p = (struct priv *) dev->priv;

	wait_for_scb_cmd(dev);
	wait_for_scb_cmd_ruc(dev);
	writew(make16(p->rfd_first), &p->scb->rfa_offset);
	writeb(RUC_START, &p->scb->cmd_ruc);
	ni_attn586();		/* start cmd. */
	wait_for_scb_cmd_ruc(dev);
	/* wait for accept cmd. (no timeout!!) */
}
示例#14
0
static void ni52_rnr_int(struct device *dev)
{
  struct priv *p = (struct priv *) dev->priv;

  p->stats.rx_errors++;

  while(p->scb->cmd);    /* wait for the last cmd */
  p->scb->cmd = RUC_ABORT;
  ni_attn586(); 
  while(p->scb->cmd);    /* wait for accept cmd. */

  alloc_rfa(dev,(char *)p->rfd_first);
  startrecv586(dev); /* restart */
}
示例#15
0
文件: ni52.c 项目: maraz/linux-2.6
static int check_iscp(struct net_device *dev, void __iomem *addr)
{
	struct iscp_struct __iomem *iscp = addr;
	struct priv *p = dev->priv;
	memset_io(iscp, 0, sizeof(struct iscp_struct));

	writel(make24(iscp), &p->scp->iscp);
	writeb(1, &iscp->busy);

	ni_reset586();
	ni_attn586();
	mdelay(32);	/* wait a while... */
	/* i82586 clears 'busy' after successful init */
	if (readb(&iscp->busy))
		return 0;
	return 1;
}
示例#16
0
文件: ni52.c 项目: openmach/openmach
static void ni52_rnr_int(struct device *dev)
{
  struct priv *p = (struct priv *) dev->priv;

  p->stats.rx_errors++;

  WAIT_4_SCB_CMD();    /* wait for the last cmd */
  p->scb->cmd = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
  ni_attn586(); 
  WAIT_4_SCB_CMD();    /* wait for accept cmd. */

  alloc_rfa(dev,(char *)p->rfd_first);
  startrecv586(dev); /* restart RU */

  printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->status);

}
示例#17
0
static int check_iscp(struct net_device *dev, void __iomem *addr)
{
	struct iscp_struct __iomem *iscp = addr;
	struct priv *p = netdev_priv(dev);
	memset_io(iscp, 0, sizeof(struct iscp_struct));

	writel(make24(iscp), &p->scp->iscp);
	writeb(1, &iscp->busy);

	ni_reset586();
	ni_attn586();
	mdelay(32);	/*                 */
	/*                                            */
	if (readb(&iscp->busy))
		return 0;
	return 1;
}
示例#18
0
static void ni52_rnr_int(struct net_device *dev)
{
	struct priv *p = netdev_priv(dev);

	dev->stats.rx_errors++;

	wait_for_scb_cmd(dev);		/*                                          */
	writeb(RUC_ABORT, &p->scb->cmd_ruc); /*                                                               */
	ni_attn586();
	wait_for_scb_cmd_ruc(dev);		/*                      */

	alloc_rfa(dev, p->rfd_first);
	/*                                                  */
	startrecv586(dev); /*            */

	printk(KERN_ERR "%s: Receive-Unit restarted. Status: %04x\n",
		dev->name, readb(&p->scb->rus));

}
示例#19
0
static void ni52_rnr_int(struct net_device *dev)
{
	struct priv *p = netdev_priv(dev);

	p->stats.rx_errors++;

	wait_for_scb_cmd(dev);		/* wait for the last cmd, WAIT_4_FULLSTAT?? */
	writeb(RUC_ABORT, &p->scb->cmd_ruc); /* usually the RU is in the 'no resource'-state .. abort it now. */
	ni_attn586();
	wait_for_scb_cmd_ruc(dev);		/* wait for accept cmd. */

	alloc_rfa(dev, p->rfd_first);
	/* maybe add a check here, before restarting the RU */
	startrecv586(dev); /* restart RU */

	printk(KERN_ERR "%s: Receive-Unit restarted. Status: %04x\n",
		dev->name, readb(&p->scb->rus));

}
示例#20
0
文件: ni52.c 项目: xricson/knoppix
/**********************************************
 * Check to see if there's an 82586 out there.
 */
static int check586(struct net_device *dev,char *where,unsigned size)
{
	struct priv pb;
	struct priv *p = /* (struct priv *) dev->priv*/ &pb;
	char *iscp_addrs[2];
	int i;

	p->base = (unsigned long) isa_bus_to_virt((unsigned long)where) + size - 0x01000000;
	p->memtop = isa_bus_to_virt((unsigned long)where) + size;
	p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
	memset((char *)p->scp,0, sizeof(struct scp_struct));
	for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
		if(((char *)p->scp)[i])
			return 0;
	p->scp->sysbus = SYSBUSVAL;				/* 1 = 8Bit-Bus, 0 = 16 Bit */
	if(p->scp->sysbus != SYSBUSVAL)
		return 0;

	iscp_addrs[0] = isa_bus_to_virt((unsigned long)where);
	iscp_addrs[1]= (char *) p->scp - sizeof(struct iscp_struct);

	for(i=0;i<2;i++)
	{
		p->iscp = (struct iscp_struct *) iscp_addrs[i];
		memset((char *)p->iscp,0, sizeof(struct iscp_struct));

		p->scp->iscp = make24(p->iscp);
		p->iscp->busy = 1;

		ni_reset586();
		ni_attn586();
		DELAY(1);	/* wait a while... */

		if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
			return 0;
	}
	return 1;
}
示例#21
0
文件: ni52.c 项目: xricson/knoppix
static void ni52_rcv_int(struct net_device *dev)
{
	int status,cnt=0;
	unsigned short totlen;
	struct sk_buff *skb;
	struct rbd_struct *rbd;
	struct priv *p = (struct priv *) dev->priv;

	if(debuglevel > 0)
		printk("R");

	for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
	{
			rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);

			if(status & RFD_OK) /* frame received without error? */
			{
				if( (totlen = rbd->status) & RBD_LAST) /* the first and the last buffer? */
				{
					totlen &= RBD_MASK; /* length of this frame */
					rbd->status = 0;
					skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
					if(skb != NULL)
					{
						skb->dev = dev;
						skb_reserve(skb,2);
						skb_put(skb,totlen);
						eth_copy_and_sum(skb,(char *) p->base+(unsigned long) rbd->buffer,totlen,0);
						skb->protocol=eth_type_trans(skb,dev);
						netif_rx(skb);
						dev->last_rx = jiffies;
						p->stats.rx_packets++;
						p->stats.rx_bytes += totlen;
					}
					else
						p->stats.rx_dropped++;
				}
				else
				{
					int rstat;
						 /* free all RBD's until RBD_LAST is set */
					totlen = 0;
					while(!((rstat=rbd->status) & RBD_LAST))
					{
						totlen += rstat & RBD_MASK;
						if(!rstat)
						{
							printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
							break;
						}
						rbd->status = 0;
						rbd = (struct rbd_struct *) make32(rbd->next);
					}
					totlen += rstat & RBD_MASK;
					rbd->status = 0;
					printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
					p->stats.rx_dropped++;
			 }
		}
		else /* frame !(ok), only with 'save-bad-frames' */
		{
			printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
			p->stats.rx_errors++;
		}
		p->rfd_top->stat_high = 0;
		p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
		p->rfd_top->rbd_offset = 0xffff;
		p->rfd_last->last = 0;				/* delete RFD_SUSP	*/
		p->rfd_last = p->rfd_top;
		p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
		p->scb->rfa_offset = make16(p->rfd_top);

		if(debuglevel > 0)
			printk("%d",cnt++);
	}

	if(automatic_resume)
	{
		WAIT_4_SCB_CMD();
		p->scb->cmd_ruc = RUC_RESUME;
		ni_attn586();
		WAIT_4_SCB_CMD_RUC();
	}

#ifdef WAIT_4_BUSY
	{
		int i;
		for(i=0;i<1024;i++)
		{
			if(p->rfd_top->status)
				break;
			DELAY_16();
			if(i == 1023)
				printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
		}
	}
#endif

#if 0
	if(!at_least_one)
	{
		int i;
		volatile struct rfd_struct *rfds=p->rfd_top;
		volatile struct rbd_struct *rbds;
		printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
		for(i=0;i< (p->num_recv_buffs+4);i++)
		{
			rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
			printk("%04x:%04x ",rfds->status,rbds->status);
			rfds = (struct rfd_struct *) make32(rfds->next);
		}
		printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
		printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
	}
	old_at_least = at_least_one;
#endif

	if(debuglevel > 0)
		printk("r");
}
示例#22
0
文件: ni52.c 项目: xricson/knoppix
static irqreturn_t ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
{
	struct net_device *dev = dev_id;
	unsigned short stat;
	int cnt=0;
	struct priv *p;

	if (!dev) {
		printk ("ni5210-interrupt: irq %d for unknown device.\n",irq);
		return IRQ_NONE;
	}
	p = (struct priv *) dev->priv;

	if(debuglevel > 1)
		printk("I");

	WAIT_4_SCB_CMD(); /* wait for last command	*/

	while((stat=p->scb->cus & STAT_MASK))
	{
		p->scb->cmd_cuc = stat;
		ni_attn586();

		if(stat & STAT_FR)	 /* received a frame */
			ni52_rcv_int(dev);

		if(stat & STAT_RNR) /* RU went 'not ready' */
		{
			printk("(R)");
			if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
			{
				WAIT_4_SCB_CMD();
				p->scb->cmd_ruc = RUC_RESUME;
				ni_attn586();
				WAIT_4_SCB_CMD_RUC();
			}
			else
			{
				printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
				ni52_rnr_int(dev);
			}
		}

		if(stat & STAT_CX)		/* command with I-bit set complete */
			 ni52_xmt_int(dev);

#ifndef NO_NOPCOMMANDS
		if(stat & STAT_CNA)	/* CU went 'not ready' */
		{
			if(netif_running(dev))
				printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
		}
#endif

		if(debuglevel > 1)
			printk("%d",cnt++);

		WAIT_4_SCB_CMD(); /* wait for ack. (ni52_xmt_int can be faster than ack!!) */
		if(p->scb->cmd_cuc)	 /* timed out? */
		{
			printk("%s: Acknowledge timed out.\n",dev->name);
			ni_disint();
			break;
		}
	}

	if(debuglevel > 1)
		printk("i");
	return IRQ_HANDLED;
}
示例#23
0
文件: ni52.c 项目: xricson/knoppix
static int init586(struct net_device *dev)
{
	void *ptr;
	int i,result=0;
	struct priv *p = (struct priv *) dev->priv;
	volatile struct configure_cmd_struct	*cfg_cmd;
	volatile struct iasetup_cmd_struct *ias_cmd;
	volatile struct tdr_cmd_struct *tdr_cmd;
	volatile struct mcsetup_cmd_struct *mc_cmd;
	struct dev_mc_list *dmi=dev->mc_list;
	int num_addrs=dev->mc_count;

	ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));

	cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
	cfg_cmd->cmd_status	= 0;
	cfg_cmd->cmd_cmd	= CMD_CONFIGURE | CMD_LAST;
	cfg_cmd->cmd_link	= 0xffff;

	cfg_cmd->byte_cnt	= 0x0a; /* number of cfg bytes */
	cfg_cmd->fifo		= fifo; /* fifo-limit (8=tx:32/rx:64) */
	cfg_cmd->sav_bf		= 0x40; /* hold or discard bad recv frames (bit 7) */
	cfg_cmd->adr_len	= 0x2e; /* addr_len |!src_insert |pre-len |loopback */
	cfg_cmd->priority	= 0x00;
	cfg_cmd->ifs		= 0x60;
	cfg_cmd->time_low	= 0x00;
	cfg_cmd->time_high	= 0xf2;
	cfg_cmd->promisc	= 0;
	if(dev->flags & IFF_ALLMULTI) {
		int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
		if(num_addrs > len)	{
			printk("%s: switching to promisc. mode\n",dev->name);
			dev->flags|=IFF_PROMISC;
		}
	}
	if(dev->flags&IFF_PROMISC)
	{
			 cfg_cmd->promisc=1;
			 dev->flags|=IFF_PROMISC;
	}
	cfg_cmd->carr_coll	= 0x00;

	p->scb->cbl_offset	= make16(cfg_cmd);
	p->scb->cmd_ruc		= 0;

	p->scb->cmd_cuc		= CUC_START; /* cmd.-unit start */
	ni_attn586();

	WAIT_4_STAT_COMPL(cfg_cmd);

	if((cfg_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
	{
		printk("%s: configure command failed: %x\n",dev->name,cfg_cmd->cmd_status);
		return 1;
	}

	/*
	 * individual address setup
	 */

	ias_cmd = (struct iasetup_cmd_struct *)ptr;

	ias_cmd->cmd_status	= 0;
	ias_cmd->cmd_cmd	= CMD_IASETUP | CMD_LAST;
	ias_cmd->cmd_link	= 0xffff;

	memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);

	p->scb->cbl_offset = make16(ias_cmd);

	p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
	ni_attn586();

	WAIT_4_STAT_COMPL(ias_cmd);

	if((ias_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
		printk("%s (ni52): individual address setup command failed: %04x\n",dev->name,ias_cmd->cmd_status);
		return 1;
	}

	/*
	 * TDR, wire check .. e.g. no resistor e.t.c
	 */
	 
	tdr_cmd = (struct tdr_cmd_struct *)ptr;

	tdr_cmd->cmd_status	= 0;
	tdr_cmd->cmd_cmd	= CMD_TDR | CMD_LAST;
	tdr_cmd->cmd_link	= 0xffff;
	tdr_cmd->status		= 0;

	p->scb->cbl_offset = make16(tdr_cmd);
	p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
	ni_attn586();

	WAIT_4_STAT_COMPL(tdr_cmd);

	if(!(tdr_cmd->cmd_status & STAT_COMPL))
	{
		printk("%s: Problems while running the TDR.\n",dev->name);
	}
	else
	{
		DELAY_16(); /* wait for result */
		result = tdr_cmd->status;

		p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
		ni_attn586(); /* ack the interrupts */

		if(result & TDR_LNK_OK)
			;
		else if(result & TDR_XCVR_PRB)
			printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
		else if(result & TDR_ET_OPN)
			printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
		else if(result & TDR_ET_SRT)
		{
			if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
				printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
		}
		else
			printk("%s: TDR: Unknown status %04x\n",dev->name,result);
	}

	/*
	 * Multicast setup
	 */
	if(num_addrs && !(dev->flags & IFF_PROMISC) )
	{
		mc_cmd = (struct mcsetup_cmd_struct *) ptr;
		mc_cmd->cmd_status = 0;
		mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST;
		mc_cmd->cmd_link = 0xffff;
		mc_cmd->mc_cnt = num_addrs * 6;

		for(i=0;i<num_addrs;i++,dmi=dmi->next)
			memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6);

		p->scb->cbl_offset = make16(mc_cmd);
		p->scb->cmd_cuc = CUC_START;
		ni_attn586();

		WAIT_4_STAT_COMPL(mc_cmd);

		if( (mc_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
			printk("%s: Can't apply multicast-address-list.\n",dev->name);
	}

	/*
	 * alloc nop/xmit-cmds
	 */
#if (NUM_XMIT_BUFFS == 1)
	for(i=0;i<2;i++)
	{
		p->nop_cmds[i] 			= (struct nop_cmd_struct *)ptr;
		p->nop_cmds[i]->cmd_cmd		= CMD_NOP;
		p->nop_cmds[i]->cmd_status 	= 0;
		p->nop_cmds[i]->cmd_link	= make16((p->nop_cmds[i]));
		ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
	}
#else
	for(i=0;i<NUM_XMIT_BUFFS;i++)
	{
		p->nop_cmds[i]			= (struct nop_cmd_struct *)ptr;
		p->nop_cmds[i]->cmd_cmd		= CMD_NOP;
		p->nop_cmds[i]->cmd_status	= 0;
		p->nop_cmds[i]->cmd_link	= make16((p->nop_cmds[i]));
		ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
	}
#endif

	ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */

	/*
	 * alloc xmit-buffs / init xmit_cmds
	 */
	for(i=0;i<NUM_XMIT_BUFFS;i++)
	{
		p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
		ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
		p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
		ptr = (char *) ptr + XMIT_BUFF_SIZE;
		p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
		ptr = (char *) ptr + sizeof(struct tbd_struct);
		if((void *)ptr > (void *)p->iscp)
		{
			printk("%s: not enough shared-mem for your configuration!\n",dev->name);
			return 1;
		}
		memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
		memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
		p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
		p->xmit_cmds[i]->cmd_status = STAT_COMPL;
		p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT;
		p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
		p->xmit_buffs[i]->next = 0xffff;
		p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
	}

	p->xmit_count = 0;
	p->xmit_last	= 0;
#ifndef NO_NOPCOMMANDS
	p->nop_point	= 0;
#endif

	 /*
		* 'start transmitter'
		*/
#ifndef NO_NOPCOMMANDS
	p->scb->cbl_offset = make16(p->nop_cmds[0]);
	p->scb->cmd_cuc = CUC_START;
	ni_attn586();
	WAIT_4_SCB_CMD();
#else
	p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
	p->xmit_cmds[0]->cmd_cmd	= CMD_XMIT | CMD_SUSPEND | CMD_INT;
#endif

	/*
	 * ack. interrupts
	 */
	p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
	ni_attn586();
	DELAY_16();

	ni_enaint();

	return 0;
}
示例#24
0
文件: ni52.c 项目: xricson/knoppix
static int __init ni52_probe1(struct net_device *dev,int ioaddr)
{
	int i, size, retval;

	if (!request_region(ioaddr, NI52_TOTAL_SIZE, dev->name))
		return -EBUSY;

	if( !(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) ||
	    !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) {
		retval = -ENODEV;
		goto out;
	}

	for(i=0;i<ETH_ALEN;i++)
		dev->dev_addr[i] = inb(dev->base_addr+i);

	if(dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1
		 || dev->dev_addr[2] != NI52_ADDR2) {
		retval = -ENODEV;
		goto out;
	}

	printk("%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr);

	/*
	 * check (or search) IO-Memory, 8K and 16K
	 */
#ifdef MODULE
	size = dev->mem_end - dev->mem_start;
	if(size != 0x2000 && size != 0x4000) {
		printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n",dev->name,size);
		retval = -ENODEV;
		goto out;
	}
	if(!check586(dev,(char *) dev->mem_start,size)) {
		printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
		retval = -ENODEV;
		goto out;
	}
#else
	if(dev->mem_start != 0) /* no auto-mem-probe */
	{
		size = 0x4000; /* check for 16K mem */
		if(!check586(dev,(char *) dev->mem_start,size)) {
			size = 0x2000; /* check for 8K mem */
			if(!check586(dev,(char *) dev->mem_start,size)) {
				printk("?memprobe, Can't find memory at 0x%lx!\n",dev->mem_start);
				retval = -ENODEV;
				goto out;
			}
		}
	}
	else
	{
		static long memaddrs[] = { 0xc8000,0xca000,0xcc000,0xce000,0xd0000,0xd2000,
					0xd4000,0xd6000,0xd8000,0xda000,0xdc000, 0 };
		for(i=0;;i++)
		{
			if(!memaddrs[i]) {
				printk("?memprobe, Can't find io-memory!\n");
				retval = -ENODEV;
				goto out;
			}
			dev->mem_start = memaddrs[i];
			size = 0x2000; /* check for 8K mem */
			if(check586(dev,(char *)dev->mem_start,size)) /* 8K-check */
				break;
			size = 0x4000; /* check for 16K mem */
			if(check586(dev,(char *)dev->mem_start,size)) /* 16K-check */
				break;
		}
	}
	dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */
#endif

	dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL);
	if(dev->priv == NULL) {
		printk("%s: Ooops .. can't allocate private driver memory.\n",dev->name);
		retval = -ENOMEM;
		goto out;
	}
																	/* warning: we don't free it on errors */
	memset((char *) dev->priv,0,sizeof(struct priv));

	((struct priv *) (dev->priv))->memtop = isa_bus_to_virt(dev->mem_start) + size;
	((struct priv *) (dev->priv))->base =	(unsigned long) isa_bus_to_virt(dev->mem_start) + size - 0x01000000;
	alloc586(dev);

	/* set number of receive-buffs according to memsize */
	if(size == 0x2000)
		((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
	else
		((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;

	printk("Memaddr: 0x%lx, Memsize: %d, ",dev->mem_start,size);

	if(dev->irq < 2)
	{
		unsigned long irq_mask;

		irq_mask = probe_irq_on();
		ni_reset586();
		ni_attn586();

		mdelay(20);
		dev->irq = probe_irq_off(irq_mask);
		if(!dev->irq)
		{
			printk("?autoirq, Failed to detect IRQ line!\n");
			kfree(dev->priv);
			dev->priv = NULL;
			retval = -EAGAIN;
			goto out;
		}
		printk("IRQ %d (autodetected).\n",dev->irq);
	}
	else	{
		if(dev->irq == 2)
			dev->irq = 9;
		printk("IRQ %d (assigned and not checked!).\n",dev->irq);
	}

	dev->open		= ni52_open;
	dev->stop		= ni52_close;
	dev->get_stats		= ni52_get_stats;
	dev->tx_timeout 	= ni52_timeout;
	dev->watchdog_timeo	= HZ/20;
	dev->hard_start_xmit 	= ni52_send_packet;
	dev->set_multicast_list = set_multicast_list;

	dev->if_port 		= 0;

	ether_setup(dev);

	return 0;
out:
	release_region(ioaddr, NI52_TOTAL_SIZE);
	return retval;
}
示例#25
0
文件: ni52.c 项目: xricson/knoppix
static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
{
	int len,i;
#ifndef NO_NOPCOMMANDS
	int next_nop;
#endif
	struct priv *p = (struct priv *) dev->priv;

	if(skb->len > XMIT_BUFF_SIZE)
	{
		printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
		return 0;
	}

	netif_stop_queue(dev);

#if(NUM_XMIT_BUFFS > 1)
	if(test_and_set_bit(0,(void *) &p->lock)) {
		printk("%s: Queue was locked\n",dev->name);
		return 1;
	}
	else
#endif
	{
		memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
		len = skb->len;
		if (len < ETH_ZLEN) {
			len = ETH_ZLEN;
			memset((char *)p->xmit_cbuffs[p->xmit_count]+skb->len, 0, len - skb->len);
		}

#if (NUM_XMIT_BUFFS == 1)
#	ifdef NO_NOPCOMMANDS

#ifdef DEBUG
		if(p->scb->cus & CU_ACTIVE)
		{
			printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
			printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,p->xmit_cmds[0]->cmd_status);
		}
#endif

		p->xmit_buffs[0]->size = TBD_LAST | len;
		for(i=0;i<16;i++)
		{
			p->xmit_cmds[0]->cmd_status = 0;
			WAIT_4_SCB_CMD();
			if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
				p->scb->cmd_cuc = CUC_RESUME;
			else
			{
				p->scb->cbl_offset = make16(p->xmit_cmds[0]);
				p->scb->cmd_cuc = CUC_START;
			}

			ni_attn586();
			dev->trans_start = jiffies;
			if(!i)
				dev_kfree_skb(skb);
			WAIT_4_SCB_CMD();
			if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
				break;
			if(p->xmit_cmds[0]->cmd_status)
				break;
			if(i==15)
				printk("%s: Can't start transmit-command.\n",dev->name);
		}
#	else
		next_nop = (p->nop_point + 1) & 0x1;
		p->xmit_buffs[0]->size = TBD_LAST | len;

		p->xmit_cmds[0]->cmd_link	 = p->nop_cmds[next_nop]->cmd_link
																= make16((p->nop_cmds[next_nop]));
		p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;

		p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
		dev->trans_start = jiffies;
		p->nop_point = next_nop;
		dev_kfree_skb(skb);
#	endif
#else
		p->xmit_buffs[p->xmit_count]->size = TBD_LAST | len;
		if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
			next_nop = 0;

		p->xmit_cmds[p->xmit_count]->cmd_status	= 0;
		/* linkpointer of xmit-command already points to next nop cmd */
		p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
		p->nop_cmds[next_nop]->cmd_status = 0;

		p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
		dev->trans_start = jiffies;
		p->xmit_count = next_nop;

		{
			unsigned long flags;
			save_flags(flags);
			cli();
			if(p->xmit_count != p->xmit_last)
				netif_wake_queue(dev);
			p->lock = 0;
			restore_flags(flags);
		}
		dev_kfree_skb(skb);
#endif
	}
	return 0;
}
示例#26
0
static netdev_tx_t ni52_send_packet(struct sk_buff *skb,
				    struct net_device *dev)
{
	int len, i;
#ifndef NO_NOPCOMMANDS
	int next_nop;
#endif
	struct priv *p = netdev_priv(dev);

	if (skb->len > XMIT_BUFF_SIZE) {
		printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len);
		return NETDEV_TX_OK;
	}

	netif_stop_queue(dev);

	memcpy_toio(p->xmit_cbuffs[p->xmit_count], skb->data, skb->len);
	len = skb->len;
	if (len < ETH_ZLEN) {
		len = ETH_ZLEN;
		memset_io(p->xmit_cbuffs[p->xmit_count]+skb->len, 0,
							len - skb->len);
	}

#if (NUM_XMIT_BUFFS == 1)
#	ifdef NO_NOPCOMMANDS

#ifdef DEBUG
	if (readb(&p->scb->cus) & CU_ACTIVE) {
		printk(KERN_ERR "%s: Hmmm .. CU is still running and we wanna send a new packet.\n", dev->name);
		printk(KERN_ERR "%s: stat: %04x %04x\n",
				dev->name, readb(&p->scb->cus),
				readw(&p->xmit_cmds[0]->cmd_status));
	}
#endif
	writew(TBD_LAST | len, &p->xmit_buffs[0]->size);
	for (i = 0; i < 16; i++) {
		writew(0, &p->xmit_cmds[0]->cmd_status);
		wait_for_scb_cmd(dev);
		if ((readb(&p->scb->cus) & CU_STATUS) == CU_SUSPEND)
			writeb(CUC_RESUME, &p->scb->cmd_cuc);
		else {
			writew(make16(p->xmit_cmds[0]), &p->scb->cbl_offset);
			writeb(CUC_START, &p->scb->cmd_cuc);
		}
		ni_attn586();
		if (!i)
			dev_kfree_skb(skb);
		wait_for_scb_cmd(dev);
		/*                                                         */
		if (readb(&p->scb->cus) & CU_ACTIVE)
			break;
		if (readw(&p->xmit_cmds[0]->cmd_status))
			break;
		if (i == 15)
			printk(KERN_WARNING "%s: Can't start transmit-command.\n", dev->name);
	}
#	else
	next_nop = (p->nop_point + 1) & 0x1;
	writew(TBD_LAST | len, &p->xmit_buffs[0]->size);
	writew(make16(p->nop_cmds[next_nop]), &p->xmit_cmds[0]->cmd_link);
	writew(make16(p->nop_cmds[next_nop]),
				&p->nop_cmds[next_nop]->cmd_link);
	writew(0, &p->xmit_cmds[0]->cmd_status);
	writew(0, &p->nop_cmds[next_nop]->cmd_status);

	writew(make16(p->xmit_cmds[0]), &p->nop_cmds[p->nop_point]->cmd_link);
	p->nop_point = next_nop;
	dev_kfree_skb(skb);
#	endif
#else
	writew(TBD_LAST | len, &p->xmit_buffs[p->xmit_count]->size);
	next_nop = p->xmit_count + 1
	if (next_nop == NUM_XMIT_BUFFS)
		next_nop = 0;
	writew(0, &p->xmit_cmds[p->xmit_count]->cmd_status);
	/*                                                            */
	writew(make16(p->nop_cmds[next_nop]),
				&p->nop_cmds[next_nop]->cmd_link);
	writew(0, &p->nop_cmds[next_nop]->cmd_status);
	writew(make16(p->xmit_cmds[p->xmit_count]),
				&p->nop_cmds[p->xmit_count]->cmd_link);
	p->xmit_count = next_nop;
	{
		unsigned long flags;
		spin_lock_irqsave(&p->spinlock);
		if (p->xmit_count != p->xmit_last)
			netif_wake_queue(dev);
		spin_unlock_irqrestore(&p->spinlock);
	}
	dev_kfree_skb(skb);
#endif
	return NETDEV_TX_OK;
}
示例#27
0
static void ni52_rcv_int(struct net_device *dev)
{
	int status, cnt = 0;
	unsigned short totlen;
	struct sk_buff *skb;
	struct rbd_struct __iomem *rbd;
	struct priv *p = netdev_priv(dev);

	if (debuglevel > 0)
		printk("R");

	for (; (status = readb(&p->rfd_top->stat_high)) & RFD_COMPL;) {
		rbd = make32(readw(&p->rfd_top->rbd_offset));
		if (status & RFD_OK) { /*                               */
			totlen = readw(&rbd->status);
			if (totlen & RBD_LAST) {
				/*                                */
				totlen &= RBD_MASK; /*                      */
				writew(0x00, &rbd->status);
				skb = netdev_alloc_skb(dev, totlen + 2);
				if (skb != NULL) {
					skb_reserve(skb, 2);
					skb_put(skb, totlen);
					memcpy_fromio(skb->data, p->base + readl(&rbd->buffer), totlen);
					skb->protocol = eth_type_trans(skb, dev);
					netif_rx(skb);
					dev->stats.rx_packets++;
					dev->stats.rx_bytes += totlen;
				} else
					dev->stats.rx_dropped++;
			} else {
				int rstat;
				 /*                                      */
				totlen = 0;
				while (!((rstat = readw(&rbd->status)) & RBD_LAST)) {
					totlen += rstat & RBD_MASK;
					if (!rstat) {
						printk(KERN_ERR "%s: Whoops .. no end mark in RBD list\n", dev->name);
						break;
					}
					writew(0, &rbd->status);
					rbd = make32(readw(&rbd->next));
				}
				totlen += rstat & RBD_MASK;
				writew(0, &rbd->status);
				printk(KERN_ERR "%s: received oversized frame! length: %d\n",
					dev->name, totlen);
				dev->stats.rx_dropped++;
			 }
		} else {/*                                          */
			printk(KERN_ERR "%s: oops! rfd-error-status: %04x\n",
				dev->name, status);
			dev->stats.rx_errors++;
		}
		writeb(0, &p->rfd_top->stat_high);
		writeb(RFD_SUSP, &p->rfd_top->last); /*                            */
		writew(0xffff, &p->rfd_top->rbd_offset);
		writeb(0, &p->rfd_last->last);	/*                 */
		p->rfd_last = p->rfd_top;
		p->rfd_top = make32(readw(&p->rfd_top->next)); /*                  */
		writew(make16(p->rfd_top), &p->scb->rfa_offset);

		if (debuglevel > 0)
			printk("%d", cnt++);
	}

	if (automatic_resume) {
		wait_for_scb_cmd(dev);
		writeb(RUC_RESUME, &p->scb->cmd_ruc);
		ni_attn586();
		wait_for_scb_cmd_ruc(dev);
	}

#ifdef WAIT_4_BUSY
	{
		int i;
		for (i = 0; i < 1024; i++) {
			if (p->rfd_top->status)
				break;
			udelay(16);
			if (i == 1023)
				printk(KERN_ERR "%s: RU hasn't fetched next RFD (not busy/complete)\n", dev->name);
		}
	}
#endif
	if (debuglevel > 0)
		printk("r");
}
示例#28
0
static irqreturn_t ni52_interrupt(int irq, void *dev_id)
{
	struct net_device *dev = dev_id;
	unsigned int stat;
	int cnt = 0;
	struct priv *p;

	p = netdev_priv(dev);

	if (debuglevel > 1)
		printk("I");

	spin_lock(&p->spinlock);

	wait_for_scb_cmd(dev); /*                       */

	while ((stat = readb(&p->scb->cus) & STAT_MASK)) {
		writeb(stat, &p->scb->cmd_cuc);
		ni_attn586();

		if (stat & STAT_FR)	 /*                  */
			ni52_rcv_int(dev);

		if (stat & STAT_RNR) { /*                     */
			printk("(R)");
			if (readb(&p->scb->rus) & RU_SUSPEND) {
				/*                          */
				wait_for_scb_cmd(dev);
				writeb(RUC_RESUME, &p->scb->cmd_ruc);
				ni_attn586();
				wait_for_scb_cmd_ruc(dev);
			} else {
				printk(KERN_ERR "%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",
					dev->name, stat, readb(&p->scb->rus));
				ni52_rnr_int(dev);
			}
		}

		/*                                 */
		if (stat & STAT_CX)
			 ni52_xmt_int(dev);

#ifndef NO_NOPCOMMANDS
		if (stat & STAT_CNA) {	/*                     */
			if (netif_running(dev))
				printk(KERN_ERR "%s: oops! CU has left active state. stat: %04x/%02x.\n",
					dev->name, stat, readb(&p->scb->cus));
		}
#endif

		if (debuglevel > 1)
			printk("%d", cnt++);

		/*                                                       */
		wait_for_scb_cmd(dev);
		if (readb(&p->scb->cmd_cuc)) {	 /*            */
			printk(KERN_ERR "%s: Acknowledge timed out.\n",
				dev->name);
			ni_disint();
			break;
		}
	}
	spin_unlock(&p->spinlock);

	if (debuglevel > 1)
		printk("i");
	return IRQ_HANDLED;
}
示例#29
0
static int init586(struct net_device *dev)
{
	void __iomem *ptr;
	int i, result = 0;
	struct priv *p = netdev_priv(dev);
	struct configure_cmd_struct __iomem *cfg_cmd;
	struct iasetup_cmd_struct __iomem *ias_cmd;
	struct tdr_cmd_struct __iomem *tdr_cmd;
	struct mcsetup_cmd_struct __iomem *mc_cmd;
	struct netdev_hw_addr *ha;
	int num_addrs = netdev_mc_count(dev);

	ptr = p->scb + 1;

	cfg_cmd = ptr; /*                   */
	writew(0, &cfg_cmd->cmd_status);
	writew(CMD_CONFIGURE | CMD_LAST, &cfg_cmd->cmd_cmd);
	writew(0xFFFF, &cfg_cmd->cmd_link);

	/*                     */
	writeb(0x0a, &cfg_cmd->byte_cnt);
	/*                            */
	writeb(fifo, &cfg_cmd->fifo);
	/*                                         */
	writeb(0x40, &cfg_cmd->sav_bf);
	/*                                          */
	writeb(0x2e, &cfg_cmd->adr_len);
	writeb(0x00, &cfg_cmd->priority);
	writeb(0x60, &cfg_cmd->ifs);
	writeb(0x00, &cfg_cmd->time_low);
	writeb(0xf2, &cfg_cmd->time_high);
	writeb(0x00, &cfg_cmd->promisc);
	if (dev->flags & IFF_ALLMULTI) {
		int len = ((char __iomem *)p->iscp - (char __iomem *)ptr - 8) / 6;
		if (num_addrs > len) {
			printk(KERN_ERR "%s: switching to promisc. mode\n",
				dev->name);
			writeb(0x01, &cfg_cmd->promisc);
		}
	}
	if (dev->flags & IFF_PROMISC)
		writeb(0x01, &cfg_cmd->promisc);
	writeb(0x00, &cfg_cmd->carr_coll);
	writew(make16(cfg_cmd), &p->scb->cbl_offset);
	writeb(0, &p->scb->cmd_ruc);

	writeb(CUC_START, &p->scb->cmd_cuc); /*                 */
	ni_attn586();

	wait_for_stat_compl(cfg_cmd);

	if ((readw(&cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) !=
							(STAT_COMPL|STAT_OK)) {
		printk(KERN_ERR "%s: configure command failed: %x\n",
				dev->name, readw(&cfg_cmd->cmd_status));
		return 1;
	}

	/*
                            
  */

	ias_cmd = ptr;

	writew(0, &ias_cmd->cmd_status);
	writew(CMD_IASETUP | CMD_LAST, &ias_cmd->cmd_cmd);
	writew(0xffff, &ias_cmd->cmd_link);

	memcpy_toio(&ias_cmd->iaddr, (char *)dev->dev_addr, ETH_ALEN);

	writew(make16(ias_cmd), &p->scb->cbl_offset);

	writeb(CUC_START, &p->scb->cmd_cuc); /*                 */
	ni_attn586();

	wait_for_stat_compl(ias_cmd);

	if ((readw(&ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) !=
							(STAT_OK|STAT_COMPL)) {
		printk(KERN_ERR "%s (ni52): individual address setup command failed: %04x\n", dev->name, readw(&ias_cmd->cmd_status));
		return 1;
	}

	/*
                                             
  */

	tdr_cmd = ptr;

	writew(0, &tdr_cmd->cmd_status);
	writew(CMD_TDR | CMD_LAST, &tdr_cmd->cmd_cmd);
	writew(0xffff, &tdr_cmd->cmd_link);
	writew(0, &tdr_cmd->status);

	writew(make16(tdr_cmd), &p->scb->cbl_offset);
	writeb(CUC_START, &p->scb->cmd_cuc); /*                 */
	ni_attn586();

	wait_for_stat_compl(tdr_cmd);

	if (!(readw(&tdr_cmd->cmd_status) & STAT_COMPL))
		printk(KERN_ERR "%s: Problems while running the TDR.\n",
				dev->name);
	else {
		udelay(16);
		result = readw(&tdr_cmd->status);
		writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc);
		ni_attn586(); /*                    */

		if (result & TDR_LNK_OK)
			;
		else if (result & TDR_XCVR_PRB)
			printk(KERN_ERR "%s: TDR: Transceiver problem. Check the cable(s)!\n",
				dev->name);
		else if (result & TDR_ET_OPN)
			printk(KERN_ERR "%s: TDR: No correct termination %d clocks away.\n",
				dev->name, result & TDR_TIMEMASK);
		else if (result & TDR_ET_SRT) {
			/*                          */
			if (result & TDR_TIMEMASK)
				printk(KERN_ERR "%s: TDR: Detected a short circuit %d clocks away.\n",
					dev->name, result & TDR_TIMEMASK);
		} else
			printk(KERN_ERR "%s: TDR: Unknown status %04x\n",
						dev->name, result);
	}

	/*
                   
  */
	if (num_addrs && !(dev->flags & IFF_PROMISC)) {
		mc_cmd = ptr;
		writew(0, &mc_cmd->cmd_status);
		writew(CMD_MCSETUP | CMD_LAST, &mc_cmd->cmd_cmd);
		writew(0xffff, &mc_cmd->cmd_link);
		writew(num_addrs * 6, &mc_cmd->mc_cnt);

		i = 0;
		netdev_for_each_mc_addr(ha, dev)
			memcpy_toio(mc_cmd->mc_list[i++], ha->addr, 6);

		writew(make16(mc_cmd), &p->scb->cbl_offset);
		writeb(CUC_START, &p->scb->cmd_cuc);
		ni_attn586();

		wait_for_stat_compl(mc_cmd);

		if ((readw(&mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK))
						 != (STAT_COMPL|STAT_OK))
			printk(KERN_ERR "%s: Can't apply multicast-address-list.\n", dev->name);
	}

	/*
                       
  */
#if (NUM_XMIT_BUFFS == 1)
	for (i = 0; i < 2; i++) {
		p->nop_cmds[i] = ptr;
		writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd);
		writew(0, &p->nop_cmds[i]->cmd_status);
		writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link);
		ptr = ptr + sizeof(struct nop_cmd_struct);
	}
#else
	for (i = 0; i < NUM_XMIT_BUFFS; i++) {
		p->nop_cmds[i] = ptr;
		writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd);
		writew(0, &p->nop_cmds[i]->cmd_status);
		writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link);
		ptr = ptr + sizeof(struct nop_cmd_struct);
	}
#endif

	ptr = alloc_rfa(dev, ptr); /*                         */

	/*
                                     
  */
	for (i = 0; i < NUM_XMIT_BUFFS; i++) {
		/*                     */
		p->xmit_cmds[i] = ptr;
		ptr = ptr + sizeof(struct transmit_cmd_struct);
		p->xmit_cbuffs[i] = ptr; /*            */
		ptr = ptr + XMIT_BUFF_SIZE;
		p->xmit_buffs[i] = ptr; /*     */
		ptr = ptr + sizeof(struct tbd_struct);
		if ((void __iomem *)ptr > (void __iomem *)p->iscp) {
			printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n",
				dev->name);
			return 1;
		}
		memset_io(p->xmit_cmds[i], 0,
					sizeof(struct transmit_cmd_struct));
		memset_io(p->xmit_buffs[i], 0,
					sizeof(struct tbd_struct));
		writew(make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]),
					&p->xmit_cmds[i]->cmd_link);
		writew(STAT_COMPL, &p->xmit_cmds[i]->cmd_status);
		writew(CMD_XMIT|CMD_INT, &p->xmit_cmds[i]->cmd_cmd);
		writew(make16(p->xmit_buffs[i]), &p->xmit_cmds[i]->tbd_offset);
		writew(0xffff, &p->xmit_buffs[i]->next);
		writel(make24(p->xmit_cbuffs[i]), &p->xmit_buffs[i]->buffer);
	}

	p->xmit_count = 0;
	p->xmit_last	= 0;
#ifndef NO_NOPCOMMANDS
	p->nop_point	= 0;
#endif

	 /*
                       
  */
#ifndef NO_NOPCOMMANDS
	writew(make16(p->nop_cmds[0]), &p->scb->cbl_offset);
	writeb(CUC_START, &p->scb->cmd_cuc);
	ni_attn586();
	wait_for_scb_cmd(dev);
#else
	writew(make16(p->xmit_cmds[0]), &p->xmit_cmds[0]->cmd_link);
	writew(CMD_XMIT | CMD_SUSPEND | CMD_INT, &p->xmit_cmds[0]->cmd_cmd);
#endif

	/*
                   
  */
	writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc);
	ni_attn586();
	udelay(16);

	ni_enaint();

	return 0;
}
示例#30
0
static int __init ni52_probe1(struct net_device *dev, int ioaddr)
{
	int i, size, retval;
	struct priv *priv = netdev_priv(dev);

	dev->base_addr = ioaddr;
	dev->irq = irq;
	dev->mem_start = memstart;
	dev->mem_end = memend;

	spin_lock_init(&priv->spinlock);

	if (!request_region(ioaddr, NI52_TOTAL_SIZE, DRV_NAME))
		return -EBUSY;

	if (!(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) ||
	    !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) {
		retval = -ENODEV;
		goto out;
	}

	for (i = 0; i < ETH_ALEN; i++)
		dev->dev_addr[i] = inb(dev->base_addr+i);

	if (dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1 ||
	    dev->dev_addr[2] != NI52_ADDR2) {
		retval = -ENODEV;
		goto out;
	}

	printk(KERN_INFO "%s: NI5210 found at %#3lx, ",
				dev->name, dev->base_addr);

	/*
                                           
  */
#ifdef MODULE
	size = dev->mem_end - dev->mem_start;
	if (size != 0x2000 && size != 0x4000) {
		printk("\n");
		printk(KERN_ERR "%s: Invalid memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n", dev->name, size);
		retval = -ENODEV;
		goto out;
	}
	if (!check586(dev, size)) {
		printk(KERN_ERR "?memcheck, Can't find memory at 0x%lx with size %d!\n", dev->mem_start, size);
		retval = -ENODEV;
		goto out;
	}
#else
	if (dev->mem_start != 0) {
		/*                   */
		size = 0x4000; /*                   */
		if (!check586(dev, size)) {
			size = 0x2000; /*                  */
			if (!check586(dev, size)) {
				printk(KERN_ERR "?memprobe, Can't find memory at 0x%lx!\n", dev->mem_start);
				retval = -ENODEV;
				goto out;
			}
		}
	} else {
		static const unsigned long memaddrs[] = {
			0xc8000, 0xca000, 0xcc000, 0xce000, 0xd0000, 0xd2000,
			0xd4000, 0xd6000, 0xd8000, 0xda000, 0xdc000, 0
		};
		for (i = 0;; i++) {
			if (!memaddrs[i]) {
				printk(KERN_ERR "?memprobe, Can't find io-memory!\n");
				retval = -ENODEV;
				goto out;
			}
			dev->mem_start = memaddrs[i];
			size = 0x2000; /*                  */
			if (check586(dev, size))
				/*          */
				break;
			size = 0x4000; /*                   */
			if (check586(dev, size))
				/*           */
				break;
		}
	}
	/*                                  */
	dev->mem_end = dev->mem_start + size;
#endif

	alloc586(dev);

	/*                                                  */
	if (size == 0x2000)
		priv->num_recv_buffs = NUM_RECV_BUFFS_8;
	else
		priv->num_recv_buffs = NUM_RECV_BUFFS_16;

	printk(KERN_DEBUG "Memaddr: 0x%lx, Memsize: %d, ",
				dev->mem_start, size);

	if (dev->irq < 2) {
		unsigned long irq_mask;

		irq_mask = probe_irq_on();
		ni_reset586();
		ni_attn586();

		mdelay(20);
		dev->irq = probe_irq_off(irq_mask);
		if (!dev->irq) {
			printk("?autoirq, Failed to detect IRQ line!\n");
			retval = -EAGAIN;
			iounmap(priv->mapped);
			goto out;
		}
		printk("IRQ %d (autodetected).\n", dev->irq);
	} else {
		if (dev->irq == 2)
			dev->irq = 9;
		printk("IRQ %d (assigned and not checked!).\n", dev->irq);
	}

	dev->netdev_ops		= &ni52_netdev_ops;
	dev->watchdog_timeo	= HZ/20;

	return 0;
out:
	release_region(ioaddr, NI52_TOTAL_SIZE);
	return retval;
}