drivers/net/ethernet/i825xx/sun3_82586.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/i825xx/sun3_82586.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/i825xx/sun3_82586.c
Extension
.c
Size
32749 bytes
Lines
1188
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct net_device_ops sun3_82586_netdev_ops = {
	.ndo_open		= sun3_82586_open,
	.ndo_stop		= sun3_82586_close,
	.ndo_start_xmit		= sun3_82586_send_packet,
	.ndo_set_rx_mode	= set_multicast_list,
	.ndo_tx_timeout		= sun3_82586_timeout,
	.ndo_get_stats		= sun3_82586_get_stats,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= eth_mac_addr,
};

static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
{
	int size, retval;

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

	/* copy in the ethernet address from the prom */
	eth_hw_addr_set(dev, idprom->id_ethaddr);

	printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);

	/*
	 * check (or search) IO-Memory, 32K
	 */
	size = 0x8000;

	dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
	dev->mem_end = dev->mem_start + size;

	if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
		printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 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;
	}

	((struct priv *)netdev_priv(dev))->memtop =
					(char *)dvma_btov(dev->mem_start);
	((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
	alloc586(dev);

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

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

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

	dev->if_port 		= 0;
	return 0;
out:
	release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
	return retval;
}


static int init586(struct net_device *dev)
{
	void *ptr;
	int i,result=0;
	struct priv *p = netdev_priv(dev);
	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 netdev_hw_addr *ha;
	int num_addrs=netdev_mc_count(dev);

	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	= swab16(CMD_CONFIGURE | CMD_LAST);
	cfg_cmd->cmd_link	= 0xffff;

Annotation

Implementation Notes