Ejemplo n.º 1
0
/* Set chassis MAC address */
int c3725_chassis_set_mac_addr(c3725_t *router,char *mac_addr)
{
   if (parse_mac_addr(&router->mac_addr,mac_addr) == -1) {
      vm_error(router->vm,"unable to parse MAC address '%s'.\n",mac_addr);
      return(-1);
   }

   /* Set the chassis base MAC address */
   c3725_burn_mac_addr(router,&router->mac_addr);
   return(0);
}
Ejemplo n.º 2
0
int acacia_probe(int port_num)
{
    struct acacia_local *lp = NULL;
    struct acacia_if_t *bif = NULL;
    struct net_device *dev = NULL;
    int i, retval;
    bif = &acacia_iflist[port_num];
    if (port_num == 0) {

        request_region(bif->iobase, 0x24C, "ACACIA0");
    }
    else if (port_num == 1)
    {
        request_region(bif->iobase, 0x24C, "ACACIA1");
    }
    /* Allocate a new 'dev' if needed */
    dev = init_etherdev(0, sizeof(struct acacia_local));
    bif->dev = dev;

    if (port_num == 0) {
        info("RC32438 ethernet0 found at 0x%08x\n", bif->iobase);
    }
    else if (port_num == 1)
        info("RC32438 ethernet1 found at 0x%08x\n", bif->iobase);

    /* Fill in the 'dev' fields. */
    dev->base_addr = bif->iobase;
    dev->irq = bif->rx_dma_irq; /* just use the rx dma irq */

    if ((retval = parse_mac_addr(dev, bif->mac_str))) {
        err("%s: MAC address parse failed\n", __func__);
        retval = -EINVAL;
        goto probe1_err_out;
    }

    info("HW Address ");
    for (i = 0; i < 6; i++) {
        printk("%2.2x", dev->dev_addr[i]);
        if (i<5)
            printk(":");
    }
    printk("\n");

    info("Rx IRQ %d, Tx IRQ %d\n", bif->rx_dma_irq, bif->tx_dma_irq);

    /* Initialize the device structure. */
    if (dev->priv == NULL) {
        lp = (struct acacia_local *)kmalloc(sizeof(*lp), GFP_KERNEL);
        memset(lp, 0, sizeof(struct acacia_local));
    } else {
        lp = (struct acacia_local *)dev->priv;
    }

    dev->priv = lp;

    lp->rx_irq = bif->rx_dma_irq;
    lp->tx_irq = bif->tx_dma_irq;
    lp->ovr_irq = bif->rx_ovr_irq;

    lp->eth_regs = ioremap_nocache(bif->iobase,
                                   sizeof(*lp->eth_regs));
    if (!lp->eth_regs) {
        err("Can't remap eth registers\n");
        retval = -ENXIO;
        goto probe1_err_out;
    }
    if (port_num == 0) {
        lp->rx_dma_regs =
            ioremap_nocache(DMA0_PhysicalAddress + 2*DMA_CHAN_OFFSET,
                            sizeof(struct DMA_Chan_s));
        if (!lp->rx_dma_regs) {
            err("Can't remap Rx DMA registers\n");
            retval = -ENXIO;
            goto probe1_err_out;
        }

        lp->tx_dma_regs =
            ioremap_nocache(DMA0_PhysicalAddress  + 3*DMA_CHAN_OFFSET,
                            sizeof(struct DMA_Chan_s));
        if (!lp->tx_dma_regs) {
            err("Can't remap Tx DMA registers\n");
            retval = -ENXIO;
            goto probe1_err_out;
        }
    }
    else if (port_num == 1) {
        lp->rx_dma_regs =
            ioremap_nocache(DMA0_PhysicalAddress  + 4*DMA_CHAN_OFFSET,
                            sizeof(struct DMA_Chan_s));
        if (!lp->rx_dma_regs) {
            err("Can't remap Rx DMA registers\n");
            retval = -ENXIO;
            goto probe1_err_out;
        }

        lp->tx_dma_regs =
            ioremap_nocache(DMA0_PhysicalAddress  + 5*DMA_CHAN_OFFSET,
                            sizeof(struct DMA_Chan_s));
        if (!lp->tx_dma_regs) {
            err("Can't remap Tx DMA registers\n");
            retval = -ENXIO;
            goto probe1_err_out;
        }

    }
    lp->td_ring =
        (DMAD_t)kmalloc(TD_RING_SIZE + RD_RING_SIZE,
                        GFP_KERNEL);
    if (!lp->td_ring) {
        err("Can't allocate descriptors\n");
        retval = -ENOMEM;
        goto probe1_err_out;
    }

    dma_cache_inv((unsigned long)(lp->td_ring),
                  TD_RING_SIZE + RD_RING_SIZE);

    /* now convert TD_RING pointer to KSEG1 */
    lp->td_ring = (DMAD_t )KSEG1ADDR(lp->td_ring);
    lp->rd_ring = &lp->td_ring[ACACIA_NUM_TDS];

    /* allocate receive buffer area */
    /* FIXME, maybe we should use skbs */
    if ((lp->rba = (u8*)kmalloc(ACACIA_NUM_RDS * ACACIA_RBSIZE,
                                GFP_KERNEL)) == NULL) {
        err("couldn't allocate receive buffers\n");
        retval = -ENOMEM;
        goto probe1_err_out;
    } 	 	/* get virtual dma address */

    dma_cache_inv((unsigned long)(lp->rba),
                  ACACIA_NUM_RDS * ACACIA_RBSIZE);

    spin_lock_init(&lp->lock);

    dev->open = acacia_open;
    dev->stop = acacia_close;
    dev->hard_start_xmit = acacia_send_packet;
    dev->get_stats	= acacia_get_stats;
    dev->set_multicast_list = &acacia_multicast_list;
    dev->tx_timeout = acacia_tx_timeout;
    dev->watchdog_timeo = ACACIA_TX_TIMEOUT;

#ifdef ACACIA_PROC_DEBUG
    lp->ps = create_proc_read_entry ("net/rc32438", 0, NULL,
                                     acacia_read_proc, dev);
#endif
    /*
     * clear tally counter
     */

    /* Fill in the fields of the device structure with ethernet values. */
    ether_setup(dev);
    return 0;

probe1_err_out:
    acacia_cleanup_module();
    err("%s failed.  Returns %d\n", __func__, retval);
    return retval;
}