void *wil_if_alloc(struct device *dev, void __iomem *csr) { struct net_device *ndev; struct wireless_dev *wdev; struct wil6210_priv *wil; struct ieee80211_channel *ch; int rc = 0; wdev = wil_cfg80211_init(dev); if (IS_ERR(wdev)) { dev_err(dev, "wil_cfg80211_init failed\n"); return wdev; } wil = wdev_to_wil(wdev); wil->csr = csr; wil->wdev = wdev; rc = wil_priv_init(wil); if (rc) { dev_err(dev, "wil_priv_init failed\n"); goto out_wdev; } wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */ /* default monitor channel */ ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels; cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT); ndev = alloc_netdev(0, "wlan%d", ether_setup); if (!ndev) { dev_err(dev, "alloc_netdev_mqs failed\n"); rc = -ENOMEM; goto out_priv; } ndev->netdev_ops = &wil_netdev_ops; ndev->ieee80211_ptr = wdev; ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM; ndev->features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM; SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); wdev->netdev = ndev; netif_napi_add(ndev, &wil->napi_rx, wil6210_netdev_poll_rx, WIL6210_NAPI_BUDGET); netif_napi_add(ndev, &wil->napi_tx, wil6210_netdev_poll_tx, WIL6210_NAPI_BUDGET); wil_link_off(wil); return wil; out_priv: wil_priv_deinit(wil); out_wdev: wil_wdev_free(wil); return ERR_PTR(rc); }
void mv_eth_set_l2fw(int cmd, int rx_port, int out_tx_port) { struct eth_port *pp; struct net_device *dev; int group; pp = mv_eth_ports[rx_port]; if (!pp) { mvOsPrintf("pp is NULL in setting L2FW (%s)\n", __func__); return; } dev = pp->dev; if (dev == NULL) { mvOsPrintf("device is NULL in in setting L2FW (%s)\n", __func__); return; } if (!test_bit(MV_ETH_F_STARTED_BIT, &(pp->flags))) { mvOsPrintf("Device is down for port=%d ; MV_ETH_F_STARTED_BIT is not set in %s\n", rx_port, __func__); mvOsPrintf("Cannot set to L2FW mode in %s\n", __func__); return; } /* when disabling l2fw, and then ifdown/up, we should enable MV_ETH_F_CONNECT_LINUX_BIT bit so that the port will be started ok. TBD: remember last state */ if (cmd == L2FW_DISABLE) set_bit(MV_ETH_F_CONNECT_LINUX_BIT, &(pp->flags)); else clear_bit(MV_ETH_F_CONNECT_LINUX_BIT, &(pp->flags)); for (group = 0; group < CONFIG_MV_ETH_NAPI_GROUPS; group++) { if (cmd == L2FW_DISABLE) { if (test_bit(MV_ETH_F_STARTED_BIT, &(pp->flags))) napi_disable(pp->napiGroup[group]); netif_napi_del(pp->napiGroup[group]); netif_napi_add(dev, pp->napiGroup[group], mv_eth_poll, pp->weight); if (test_bit(MV_ETH_F_STARTED_BIT, &(pp->flags))) napi_enable(pp->napiGroup[group]); } else { if (test_bit(MV_ETH_F_STARTED_BIT, &(pp->flags))) napi_disable(pp->napiGroup[group]); netif_napi_del(pp->napiGroup[group]); printk(KERN_INFO "pp->weight=%d in %s\n", pp->weight, __func__); netif_napi_add(dev, pp->napiGroup[group], mv_eth_poll_l2fw, pp->weight); if (test_bit(MV_ETH_F_STARTED_BIT, &(pp->flags))) napi_enable(pp->napiGroup[group]); } } }
/********************ccmni driver register ccci function********************/ static inline int ccmni_inst_init(int md_id, ccmni_instance_t * ccmni, struct net_device *dev) { ccmni_ctl_block_t *ctlb = ccmni_ctl_blk[md_id]; struct ccmni_ch channel; int ret = 0; ret = ctlb->ccci_ops->get_ccmni_ch(md_id, ccmni->index, &channel); if (ret) { CCMNI_ERR_MSG(md_id, "get ccmni%d channel fail\n", ccmni->index); return ret; } ccmni->dev = dev; ccmni->ctlb = ctlb; ccmni->md_id = md_id; //ccmni tx/rx channel setting ccmni->ch.rx = channel.rx; ccmni->ch.rx_ack = channel.rx_ack; ccmni->ch.tx = channel.tx; ccmni->ch.tx_ack = channel.tx_ack; //register napi device if(dev && (ctlb->ccci_ops->md_ability & MODEM_CAP_NAPI)) { init_timer(&ccmni->timer); ccmni->timer.function = ccmni_napi_poll_timeout; ccmni->timer.data = (unsigned long)ccmni; netif_napi_add(dev, &ccmni->napi, ccmni_napi_poll, ctlb->ccci_ops->napi_poll_weigh); } atomic_set(&ccmni->usage, 0); spin_lock_init(&ccmni->spinlock); return ret; }
struct net_device *ixpdev_alloc(int channel, int sizeof_priv) { struct net_device *dev; struct ixpdev_priv *ip; dev = alloc_etherdev(sizeof_priv); if (dev == NULL) return NULL; dev->hard_start_xmit = ixpdev_xmit; dev->open = ixpdev_open; dev->stop = ixpdev_close; #ifdef CONFIG_NET_POLL_CONTROLLER dev->poll_controller = ixpdev_poll_controller; #endif dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; ip = netdev_priv(dev); ip->dev = dev; netif_napi_add(dev, &ip->napi, ixpdev_poll, 64); ip->channel = channel; ip->tx_queue_entries = 0; return dev; }
/* Init/Probe function (invoked by register_netdev()) */ void blaze_init(struct net_device *dev) { struct blaze_priv *priv; /* * Hardware specific code will go here: check_region(), * probe irq, ... Return -ENODEV if no device is found. * No resource should be grabbed (this is done on open()) */ /* Setup dev fields */ ether_setup(dev); /* set some of these manually? */ dev->watchdog_timeo = BLAZE_TIMEOUT; dev->netdev_ops = &blaze_netdev_ops; dev->header_ops = &blaze_header_ops; dev->flags |= IFF_NOARP; /* use ARP? */ dev->features |= NETIF_F_HW_CSUM; /* Intialize priv field */ priv = netdev_priv(dev); if (USE_NAPI) { /* weight = 2 (> weight = interface more important) */ netif_napi_add(dev, &priv->napi, blaze_poll, 2); } memset(priv, 0, sizeof(struct blaze_priv)); spin_lock_init(&priv->lock); /* Enable receive interrupts */ blaze_rx_ints(dev, 1); blaze_setup_pool(dev); }
int roq_eth_open(struct net_device *ndev) { struct roq_eth_priv *priv = netdev_priv(ndev); int rv; if (priv->ibdev == NULL) { pr_warn("roq_eth_open: no transport device set\n"); return -ENODEV; } if ((rv = roq_eth_init_qp(ndev)) != 0) return rv; netif_napi_add(ndev, &priv->napi, roq_eth_napi, MAX_RX_SKBS); netif_start_queue(ndev); napi_enable(&priv->napi); rv = roq_cm_init(); if (rv) { pr_warn("roq_eth_open: cannot init RoQ CM\n"); return rv; } return 0; }
struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device, u8 port_num, enum rdma_netdev_t type, const char *name, unsigned char name_assign_type, void (*setup)(struct net_device *)) { struct hfi1_devdata *dd = dd_from_ibdev(device); struct hfi1_vnic_vport_info *vinfo; struct net_device *netdev; struct rdma_netdev *rn; int i, size, rc; if (!port_num || (port_num > dd->num_pports)) return ERR_PTR(-EINVAL); if (type != RDMA_NETDEV_OPA_VNIC) return ERR_PTR(-EOPNOTSUPP); size = sizeof(struct opa_vnic_rdma_netdev) + sizeof(*vinfo); netdev = alloc_netdev_mqs(size, name, name_assign_type, setup, dd->chip_sdma_engines, HFI1_NUM_VNIC_CTXT); if (!netdev) return ERR_PTR(-ENOMEM); rn = netdev_priv(netdev); vinfo = opa_vnic_dev_priv(netdev); vinfo->dd = dd; vinfo->num_tx_q = dd->chip_sdma_engines; vinfo->num_rx_q = HFI1_NUM_VNIC_CTXT; vinfo->netdev = netdev; rn->set_id = hfi1_vnic_set_vesw_id; netdev->features = NETIF_F_HIGHDMA | NETIF_F_SG; netdev->hw_features = netdev->features; netdev->vlan_features = netdev->features; netdev->watchdog_timeo = msecs_to_jiffies(HFI_TX_TIMEOUT_MS); netdev->netdev_ops = &hfi1_netdev_ops; mutex_init(&vinfo->lock); for (i = 0; i < vinfo->num_rx_q; i++) { struct hfi1_vnic_rx_queue *rxq = &vinfo->rxq[i]; rxq->idx = i; rxq->vinfo = vinfo; rxq->netdev = netdev; netif_napi_add(netdev, &rxq->napi, hfi1_vnic_napi, 64); } rc = hfi1_vnic_init(vinfo); if (rc) goto init_fail; return netdev; init_fail: mutex_destroy(&vinfo->lock); free_netdev(netdev); return ERR_PTR(rc); }
static int fjes_sw_init(struct fjes_adapter *adapter) { struct net_device *netdev = adapter->netdev; netif_napi_add(netdev, &adapter->napi, fjes_poll, 64); return 0; }
static int xge_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct net_device *ndev; struct xge_pdata *pdata; int ret; ndev = alloc_etherdev(sizeof(*pdata)); if (!ndev) return -ENOMEM; pdata = netdev_priv(ndev); pdata->pdev = pdev; pdata->ndev = ndev; SET_NETDEV_DEV(ndev, dev); platform_set_drvdata(pdev, pdata); ndev->netdev_ops = &xgene_ndev_ops; ndev->features |= NETIF_F_GSO | NETIF_F_GRO; ret = xge_get_resources(pdata); if (ret) goto err; ndev->hw_features = ndev->features; xge_set_ethtool_ops(ndev); ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64)); if (ret) { netdev_err(ndev, "No usable DMA configuration\n"); goto err; } ret = xge_init_hw(ndev); if (ret) goto err; ret = xge_mdio_config(ndev); if (ret) goto err; netif_napi_add(ndev, &pdata->napi, xge_napi, NAPI_POLL_WEIGHT); ret = register_netdev(ndev); if (ret) { netdev_err(ndev, "Failed to register netdev\n"); goto err; } return 0; err: free_netdev(ndev); return ret; }
static int __devinit octeon_mgmt_probe(struct platform_device *pdev) { struct resource *res_irq; struct net_device *netdev; struct octeon_mgmt *p; int i; netdev = alloc_etherdev(sizeof(struct octeon_mgmt)); if (netdev == NULL) return -ENOMEM; dev_set_drvdata(&pdev->dev, netdev); p = netdev_priv(netdev); netif_napi_add(netdev, &p->napi, octeon_mgmt_napi_poll, OCTEON_MGMT_NAPI_WEIGHT); p->netdev = netdev; p->dev = &pdev->dev; p->port = pdev->id; snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port); res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res_irq) goto err; p->irq = res_irq->start; spin_lock_init(&p->lock); skb_queue_head_init(&p->tx_list); skb_queue_head_init(&p->rx_list); tasklet_init(&p->tx_clean_tasklet, octeon_mgmt_clean_tx_tasklet, (unsigned long)p); netdev->priv_flags |= IFF_UNICAST_FLT; netdev->netdev_ops = &octeon_mgmt_ops; netdev->ethtool_ops = &octeon_mgmt_ethtool_ops; /* The mgmt ports get the first N MACs. */ for (i = 0; i < 6; i++) netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i]; netdev->dev_addr[5] += p->port; if (p->port >= octeon_bootinfo->mac_addr_count) dev_err(&pdev->dev, "Error %s: Using MAC outside of the assigned range: %pM\n", netdev->name, netdev->dev_addr); if (register_netdev(netdev)) goto err; dev_info(&pdev->dev, "Version " DRV_VERSION "\n"); return 0; err: free_netdev(netdev); return -ENOENT; }
static void sca_init_port(port_t *port) { card_t *card = port->card; u16 dmac_rx = get_dmac_rx(port), dmac_tx = get_dmac_tx(port); int transmit, i; port->rxin = 0; port->txin = 0; port->txlast = 0; for (transmit = 0; transmit < 2; transmit++) { u16 buffs = transmit ? card->tx_ring_buffers : card->rx_ring_buffers; for (i = 0; i < buffs; i++) { pkt_desc __iomem *desc = desc_address(port, i, transmit); u16 chain_off = hd_desc_offset(port, i + 1, transmit); u32 buff_off = buffer_offset(port, i, transmit); writel(chain_off, &desc->cp); writel(buff_off, &desc->bp); writew(0, &desc->len); writeb(0, &desc->stat); } } /* DMA disable - to halt state */ sca_out(0, DSR_RX(port->chan), card); sca_out(0, DSR_TX(port->chan), card); /* software ABORT - to initial state */ sca_out(DCR_ABORT, DCR_RX(port->chan), card); sca_out(DCR_ABORT, DCR_TX(port->chan), card); /* current desc addr */ sca_outl(hd_desc_offset(port, 0, 0), dmac_rx + CDAL, card); sca_outl(hd_desc_offset(port, card->tx_ring_buffers - 1, 0), dmac_rx + EDAL, card); sca_outl(hd_desc_offset(port, 0, 1), dmac_tx + CDAL, card); sca_outl(hd_desc_offset(port, 0, 1), dmac_tx + EDAL, card); /* clear frame end interrupt counter */ sca_out(DCR_CLEAR_EOF, DCR_RX(port->chan), card); sca_out(DCR_CLEAR_EOF, DCR_TX(port->chan), card); /* Receive */ sca_outw(HDLC_MAX_MRU, dmac_rx + BFLL, card); /* set buffer length */ sca_out(0x14, DMR_RX(port->chan), card); /* Chain mode, Multi-frame */ sca_out(DIR_EOME, DIR_RX(port->chan), card); /* enable interrupts */ sca_out(DSR_DE, DSR_RX(port->chan), card); /* DMA enable */ /* Transmit */ sca_out(0x14, DMR_TX(port->chan), card); /* Chain mode, Multi-frame */ sca_out(DIR_EOME, DIR_TX(port->chan), card); /* enable interrupts */ sca_set_carrier(port); netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT); }
int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) { struct mlx4_en_dev *mdev = priv->mdev; int err = 0; char name[25]; cq->dev = mdev->pndev[priv->port]; cq->mcq.set_ci_db = cq->wqres.db.db; cq->mcq.arm_db = cq->wqres.db.db + 1; *cq->mcq.set_ci_db = 0; *cq->mcq.arm_db = 0; memset(cq->buf, 0, cq->buf_size); if (cq->is_tx == RX) { if (mdev->dev->caps.comp_pool) { if (!cq->vector) { sprintf(name , "%s-rx-%d", priv->dev->name, cq->ring); if (mlx4_assign_eq(mdev->dev, name, &cq->vector)) { cq->vector = (cq->ring + 1 + priv->port) % mdev->dev->caps.num_comp_vectors; mlx4_warn(mdev, "Failed Assigning an EQ to " "%s_rx-%d ,Falling back to legacy EQ's\n", priv->dev->name, cq->ring); } } } else { cq->vector = (cq->ring + 1 + priv->port) % mdev->dev->caps.num_comp_vectors; } } else { if (!cq->vector || !mdev->dev->caps.comp_pool) { /*Fallback to legacy pool in case of error*/ cq->vector = 0; } } if (!cq->is_tx) cq->size = priv->rx_ring[cq->ring].actual_size; err = mlx4_cq_alloc(mdev->dev, cq->size, &cq->wqres.mtt, &mdev->priv_uar, cq->wqres.db.dma, &cq->mcq, cq->vector, cq->is_tx); if (err) return err; cq->mcq.comp = cq->is_tx ? mlx4_en_tx_irq : mlx4_en_rx_irq; cq->mcq.event = mlx4_en_cq_event; if (cq->is_tx) { init_timer(&cq->timer); cq->timer.function = mlx4_en_poll_tx_cq; cq->timer.data = (unsigned long) cq; } else { netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, 64); napi_enable(&cq->napi); } return 0; }
/** * gelic_ether_setup_netdev_ops - initialization of net_device operations * @netdev: net_device structure * * fills out function pointers in the net_device structure */ static void __devinit gelic_ether_setup_netdev_ops(struct net_device *netdev, struct napi_struct *napi) { netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT; /* NAPI */ netif_napi_add(netdev, napi, gelic_net_poll, GELIC_NET_NAPI_WEIGHT); netdev->ethtool_ops = &gelic_ether_ethtool_ops; netdev->netdev_ops = &gelic_netdevice_ops; }
/** * vb_net_register - Register a new network interface. * @vb: voicebus card to register the interface for. * * The network interface is primarily used for debugging in order to watch the * traffic between the transcoder and the host. * */ int vb_net_register(struct voicebus *vb, const char *board_name) { int res; struct net_device *netdev; struct voicebus_netdev_priv *priv; const char our_mac[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; netdev = alloc_netdev(sizeof(*priv), board_name, ether_setup); if (!netdev) return -ENOMEM; priv = netdev_priv(netdev); priv->vb = vb; memcpy(netdev->dev_addr, our_mac, sizeof(our_mac)); # ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops = &vb_netdev_ops; # else netdev->set_multicast_list = vb_net_set_multi; netdev->open = vb_net_up; netdev->stop = vb_net_down; netdev->hard_start_xmit = vb_net_hard_start_xmit; netdev->get_stats = vb_net_get_stats; # endif netdev->promiscuity = 0; netdev->flags |= IFF_NOARP; # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) netdev->poll = vb_net_poll; netdev->weight = 64; # else netif_napi_add(netdev, &vb->napi, vb_net_poll, 64); # endif skb_queue_head_init(&vb->captured_packets); res = register_netdev(netdev); if (res) { dev_warn(&vb->pdev->dev, "Failed to register network device %s.\n", board_name); goto error_sw; } vb->netdev = netdev; dev_dbg(&vb->pdev->dev, "Created network device %s for debug.\n", board_name); return 0; error_sw: if (netdev) free_netdev(netdev); return res; }
static int __devinit hss_init_one(struct platform_device *pdev) { struct port *port; struct net_device *dev; hdlc_device *hdlc; int err; if ((port = kzalloc(sizeof(*port), GFP_KERNEL)) == NULL) return -ENOMEM; if ((port->npe = npe_request(0)) == NULL) { err = -ENOSYS; goto err_free; } if ((port->netdev = dev = alloc_hdlcdev(port)) == NULL) { err = -ENOMEM; goto err_plat; } SET_NETDEV_DEV(dev, &pdev->dev); hdlc = dev_to_hdlc(dev); hdlc->attach = hss_hdlc_attach; hdlc->xmit = hss_hdlc_xmit; dev->open = hss_hdlc_open; dev->stop = hss_hdlc_close; dev->do_ioctl = hss_hdlc_ioctl; dev->tx_queue_len = 100; port->clock_type = CLOCK_EXT; port->clock_rate = 2048000; port->id = pdev->id; port->dev = &pdev->dev; port->plat = pdev->dev.platform_data; netif_napi_add(dev, &port->napi, hss_hdlc_poll, NAPI_WEIGHT); if ((err = register_hdlc_device(dev))) goto err_free_netdev; platform_set_drvdata(pdev, port); printk(KERN_INFO "%s: HSS-%i\n", dev->name, port->id); return 0; err_free_netdev: free_netdev(dev); err_plat: npe_release(port->npe); err_free: kfree(port); return err; }
static int hss_init_one(struct platform_device *pdev) { struct port *port; struct net_device *dev; hdlc_device *hdlc; int err; if ((port = kzalloc(sizeof(*port), GFP_KERNEL)) == NULL) return -ENOMEM; if ((port->npe = npe_request(0)) == NULL) { err = -ENODEV; goto err_free; } if ((port->netdev = dev = alloc_hdlcdev(port)) == NULL) { err = -ENOMEM; goto err_plat; } SET_NETDEV_DEV(dev, &pdev->dev); hdlc = dev_to_hdlc(dev); hdlc->attach = hss_hdlc_attach; hdlc->xmit = hss_hdlc_xmit; dev->netdev_ops = &hss_hdlc_ops; dev->tx_queue_len = 100; port->clock_type = CLOCK_EXT; port->clock_rate = 0; port->clock_reg = CLK42X_SPEED_2048KHZ; port->id = pdev->id; port->dev = &pdev->dev; port->plat = pdev->dev.platform_data; netif_napi_add(dev, &port->napi, hss_hdlc_poll, NAPI_WEIGHT); if ((err = register_hdlc_device(dev))) goto err_free_netdev; platform_set_drvdata(pdev, port); netdev_info(dev, "initialized\n"); return 0; err_free_netdev: free_netdev(dev); err_plat: npe_release(port->npe); err_free: kfree(port); return err; }
static void ptm_setup(struct net_device *dev, int ndev) { /* hook network operations */ dev->netdev_ops = &g_ptm_netdev_ops; netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 25); dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT; dev->dev_addr[0] = 0x00; dev->dev_addr[1] = 0x20; dev->dev_addr[2] = 0xda; dev->dev_addr[3] = 0x86; dev->dev_addr[4] = 0x23; dev->dev_addr[5] = 0x75 + ndev; }
static void xlgmac_napi_enable(struct xlgmac_pdata *pdata, unsigned int add) { struct xlgmac_channel *channel; unsigned int i; if (pdata->per_channel_irq) { channel = pdata->channel_head; for (i = 0; i < pdata->channel_count; i++, channel++) { if (add) netif_napi_add(pdata->netdev, &channel->napi, xlgmac_one_poll, NAPI_POLL_WEIGHT); napi_enable(&channel->napi); } } else { if (add) netif_napi_add(pdata->netdev, &pdata->napi, xlgmac_all_poll, NAPI_POLL_WEIGHT); napi_enable(&pdata->napi); } }
static int qtnf_pcie_pearl_probe(struct qtnf_bus *bus, unsigned int tx_bd_size) { struct qtnf_shm_ipc_int ipc_int; struct qtnf_pcie_pearl_state *ps = get_bus_priv(bus); struct pci_dev *pdev = ps->base.pdev; int ret; bus->bus_ops = &qtnf_pcie_pearl_bus_ops; spin_lock_init(&ps->irq_lock); INIT_WORK(&bus->fw_work, qtnf_pearl_fw_work_handler); ps->pcie_reg_base = ps->base.dmareg_bar; ps->bda = ps->base.epmem_bar; writel(ps->base.msi_enabled, &ps->bda->bda_rc_msi_enabled); ret = qtnf_pcie_pearl_init_xfer(ps, tx_bd_size); if (ret) { pr_err("PCIE xfer init failed\n"); return ret; } /* init default irq settings */ qtnf_init_hdp_irqs(ps); /* start with disabled irqs */ qtnf_disable_hdp_irqs(ps); ret = devm_request_irq(&pdev->dev, pdev->irq, &qtnf_pcie_pearl_interrupt, 0, "qtnf_pearl_irq", (void *)bus); if (ret) { pr_err("failed to request pcie irq %d\n", pdev->irq); qtnf_pearl_free_xfer_buffers(ps); return ret; } tasklet_init(&ps->base.reclaim_tq, qtnf_pearl_reclaim_tasklet_fn, (unsigned long)ps); netif_napi_add(&bus->mux_dev, &bus->mux_napi, qtnf_pcie_pearl_rx_poll, 10); ipc_int.fn = qtnf_pcie_pearl_ipc_gen_ep_int; ipc_int.arg = ps; qtnf_pcie_init_shm_ipc(&ps->base, &ps->bda->bda_shm_reg1, &ps->bda->bda_shm_reg2, &ipc_int); return 0; }
/** * stmmac_probe - Initialization of the adapter . * @dev : device pointer * Description: The function initializes the network device structure for * the STMMAC driver. It also calls the low level routines * in order to init the HW (i.e. the DMA engine) */ static int stmmac_probe(struct net_device *dev) { int ret = 0; struct stmmac_priv *priv = netdev_priv(dev); ether_setup(dev); dev->netdev_ops = &stmmac_netdev_ops; stmmac_set_ethtool_ops(dev); dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; dev->features |= dev->hw_features | NETIF_F_HIGHDMA; dev->watchdog_timeo = msecs_to_jiffies(watchdog); #ifdef STMMAC_VLAN_TAG_USED /* Both mac100 and gmac support receive VLAN tag detection */ dev->features |= NETIF_F_HW_VLAN_RX; #endif priv->msg_enable = netif_msg_init(debug, default_msg_level); if (flow_ctrl) priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ priv->pause = pause; netif_napi_add(dev, &priv->napi, stmmac_poll, 64); /* Get the MAC address */ priv->hw->mac->get_umac_addr((void __iomem *) dev->base_addr, dev->dev_addr, 0); if (!is_valid_ether_addr(dev->dev_addr)) pr_warning("\tno valid MAC address;" "please, use ifconfig or nwhwconfig!\n"); spin_lock_init(&priv->lock); ret = register_netdev(dev); if (ret) { pr_err("%s: ERROR %i registering the device\n", __func__, ret); return -ENODEV; } DBG(probe, DEBUG, "%s: Scatter/Gather: %s - HW checksums: %s\n", dev->name, (dev->features & NETIF_F_SG) ? "on" : "off", (dev->features & NETIF_F_IP_CSUM) ? "on" : "off"); return ret; }
static int mt76_dma_init(struct mt76_dev *dev) { int i; init_dummy_netdev(&dev->napi_dev); for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) { netif_napi_add(&dev->napi_dev, &dev->napi[i], mt76_dma_rx_poll, 64); mt76_dma_rx_fill(dev, &dev->q_rx[i], false); skb_queue_head_init(&dev->rx_skb[i]); napi_enable(&dev->napi[i]); } return 0; }
struct net_device *ixpdev_alloc(int channel, int sizeof_priv) { struct net_device *dev; struct ixpdev_priv *ip; dev = alloc_etherdev(sizeof_priv); if (dev == NULL) return NULL; dev->netdev_ops = &ixpdev_netdev_ops; dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; ip = netdev_priv(dev); ip->dev = dev; netif_napi_add(dev, &ip->napi, ixpdev_poll, 64); ip->channel = channel; ip->tx_queue_entries = 0; return dev; }
struct net_device *alloc_c_can_dev(void) { struct net_device *dev; struct c_can_priv *priv; dev = alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM); if (!dev) return NULL; priv = netdev_priv(dev); netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT); priv->dev = dev; priv->can.bittiming_const = &c_can_bittiming_const; priv->can.do_set_mode = c_can_set_mode; priv->can.do_get_berr_counter = c_can_get_berr_counter; priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_BERR_REPORTING; return dev; }
static int port_net_init(struct ccci_port *port) { struct ccci_port **temp; struct net_device *dev = NULL; struct netdev_entity *nent = NULL; CCCI_DBG_MSG(port->modem->index, NET, "network port is initializing\n"); dev = alloc_etherdev(sizeof(struct ccci_port *)); dev->header_ops = NULL; dev->mtu = CCMNI_MTU; dev->tx_queue_len = 1000; dev->watchdog_timeo = 1*HZ; dev->flags = IFF_NOARP & /* ccmni is a pure IP device */ (~IFF_BROADCAST & ~IFF_MULTICAST); /* ccmni is P2P */ dev->features = NETIF_F_VLAN_CHALLENGED; /* not support VLAN */ dev->addr_len = ETH_ALEN; /* ethernet header size */ dev->destructor = free_netdev; dev->hard_header_len += sizeof(struct ccci_header); /* reserve Tx CCCI header room */ dev->netdev_ops = &ccmni_netdev_ops; temp = netdev_priv(dev); *temp = port; sprintf(dev->name, "%s", port->name); random_ether_addr((u8 *) dev->dev_addr); nent = kzalloc(sizeof(struct netdev_entity), GFP_KERNEL); nent->ndev = dev; if(likely(port->modem->capability & MODEM_CAP_NAPI)) netif_napi_add(dev, &nent->napi, port_net_poll, NAPI_POLL_WEIGHT); // hardcode port->private_data = nent; init_timer(&nent->polling_timer); nent->polling_timer.function = napi_polling_timer_func; nent->polling_timer.data = (unsigned long)port; register_netdev(dev); CCCI_DBG_MSG(port->modem->index, NET, "network device %s hard_header_len=%d\n", dev->name, dev->hard_header_len); return 0; }
static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; long ret; struct net_device *netdev; struct ibmveth_adapter *adapter; unsigned long set_attr, ret_attr; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; ibmveth_debug_printk_no_adapter("entering ibmveth_probe for UA 0x%x\n", dev->unit_address); mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, NULL); if(!mac_addr_p) { printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find VETH_MAC_ADDR " "attribute\n", __FILE__, __LINE__); return 0; } mcastFilterSize_p = (unsigned int *) vio_get_attribute(dev, VETH_MCAST_FILTER_SIZE, NULL); if(!mcastFilterSize_p) { printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find " "VETH_MCAST_FILTER_SIZE attribute\n", __FILE__, __LINE__); return 0; } netdev = alloc_etherdev(sizeof(struct ibmveth_adapter)); if(!netdev) return -ENOMEM; adapter = netdev_priv(netdev); dev_set_drvdata(&dev->dev, netdev); adapter->vdev = dev; adapter->netdev = netdev; adapter->mcastFilterSize= *mcastFilterSize_p; adapter->pool_config = 0; netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16); if ((*mac_addr_p & 0x3) != 0x02) mac_addr_p += 2; adapter->mac_addr = 0; memcpy(&adapter->mac_addr, mac_addr_p, 6); netdev->irq = dev->irq; netdev->netdev_ops = &ibmveth_netdev_ops; netdev->ethtool_ops = &netdev_ethtool_ops; SET_NETDEV_DEV(netdev, &dev->dev); netdev->features |= NETIF_F_LLTX; spin_lock_init(&adapter->stats_lock); memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len); for(i = 0; i<IbmVethNumBufferPools; i++) { struct kobject *kobj = &adapter->rx_buff_pool[i].kobj; int error; ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i, pool_count[i], pool_size[i], pool_active[i]); error = kobject_init_and_add(kobj, &ktype_veth_pool, &dev->dev.kobj, "pool%d", i); if (!error) kobject_uevent(kobj, KOBJ_ADD); } ibmveth_debug_printk("adapter @ 0x%p\n", adapter); adapter->buffer_list_dma = DMA_ERROR_CODE; adapter->filter_list_dma = DMA_ERROR_CODE; adapter->rx_queue.queue_dma = DMA_ERROR_CODE; ibmveth_debug_printk("registering netdev...\n"); ret = h_illan_attributes(dev->unit_address, 0, 0, &ret_attr); if (ret == H_SUCCESS && !(ret_attr & IBMVETH_ILLAN_ACTIVE_TRUNK) && !(ret_attr & IBMVETH_ILLAN_TRUNK_PRI_MASK) && (ret_attr & IBMVETH_ILLAN_PADDED_PKT_CSUM)) { set_attr = IBMVETH_ILLAN_IPV4_TCP_CSUM; ret = h_illan_attributes(dev->unit_address, 0, set_attr, &ret_attr); if (ret == H_SUCCESS) { adapter->rx_csum = 1; netdev->features |= NETIF_F_IP_CSUM; } else ret = h_illan_attributes(dev->unit_address, set_attr, 0, &ret_attr); } rc = register_netdev(netdev); if(rc) { ibmveth_debug_printk("failed to register netdev rc=%d\n", rc); free_netdev(netdev); return rc; } ibmveth_debug_printk("registered\n"); ibmveth_proc_register_adapter(adapter); return 0; }
/** * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector * @adapter: board private structure to initialize * @v_count: q_vectors allocated on adapter, used for ring interleaving * @v_idx: index of vector in adapter struct * @txr_count: total number of Tx rings to allocate * @txr_idx: index of first Tx ring to allocate * @rxr_count: total number of Rx rings to allocate * @rxr_idx: index of first Rx ring to allocate * * We allocate one q_vector. If allocation fails we return -ENOMEM. **/ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_count, int v_idx, int txr_count, int txr_idx, int rxr_count, int rxr_idx) { struct ixgbe_q_vector *q_vector; struct ixgbe_ring *ring; int node = -1; int cpu = -1; int ring_count, size; ring_count = txr_count + rxr_count; size = sizeof(struct ixgbe_q_vector) + (sizeof(struct ixgbe_ring) * ring_count); /* customize cpu for Flow Director mapping */ if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { if (cpu_online(v_idx)) { cpu = v_idx; node = cpu_to_node(cpu); } } /* allocate q_vector and rings */ q_vector = kzalloc_node(size, GFP_KERNEL, node); if (!q_vector) q_vector = kzalloc(size, GFP_KERNEL); if (!q_vector) return -ENOMEM; /* setup affinity mask and node */ if (cpu != -1) cpumask_set_cpu(cpu, &q_vector->affinity_mask); q_vector->numa_node = node; #ifdef CONFIG_IXGBE_DCA /* initialize CPU for DCA */ q_vector->cpu = -1; #endif /* initialize NAPI */ netif_napi_add(adapter->netdev, &q_vector->napi, ixgbe_poll, 64); /* tie q_vector and adapter together */ adapter->q_vector[v_idx] = q_vector; q_vector->adapter = adapter; q_vector->v_idx = v_idx; /* initialize work limits */ q_vector->tx.work_limit = adapter->tx_work_limit; /* initialize pointer to rings */ ring = q_vector->ring; /* intialize ITR */ if (txr_count && !rxr_count) { /* tx only vector */ if (adapter->tx_itr_setting == 1) q_vector->itr = IXGBE_10K_ITR; else q_vector->itr = adapter->tx_itr_setting; } else { /* rx or rx/tx vector */ if (adapter->rx_itr_setting == 1) q_vector->itr = IXGBE_20K_ITR; else q_vector->itr = adapter->rx_itr_setting; } while (txr_count) { /* assign generic ring traits */ ring->dev = &adapter->pdev->dev; ring->netdev = adapter->netdev; /* configure backlink on ring */ ring->q_vector = q_vector; /* update q_vector Tx values */ ixgbe_add_ring(ring, &q_vector->tx); /* apply Tx specific ring traits */ ring->count = adapter->tx_ring_count; ring->queue_index = txr_idx; /* assign ring to adapter */ adapter->tx_ring[txr_idx] = ring; /* update count and index */ txr_count--; txr_idx += v_count; /* push pointer to next ring */ ring++; } while (rxr_count) { /* assign generic ring traits */ ring->dev = &adapter->pdev->dev; ring->netdev = adapter->netdev; /* configure backlink on ring */ ring->q_vector = q_vector; /* update q_vector Rx values */ ixgbe_add_ring(ring, &q_vector->rx); /* * 82599 errata, UDP frames with a 0 checksum * can be marked as checksum errors. */ if (adapter->hw.mac.type == ixgbe_mac_82599EB) set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); #ifdef IXGBE_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) { struct ixgbe_ring_feature *f; f = &adapter->ring_feature[RING_F_FCOE]; if ((rxr_idx >= f->offset) && (rxr_idx < f->offset + f->indices)) set_bit(__IXGBE_RX_FCOE, &ring->state); } #endif /* IXGBE_FCOE */ /* apply Rx specific ring traits */ ring->count = adapter->rx_ring_count; ring->queue_index = rxr_idx; /* assign ring to adapter */ adapter->rx_ring[rxr_idx] = ring; /* update count and index */ rxr_count--; rxr_idx += v_count; /* push pointer to next ring */ ring++; } return 0; }
static int fs_enet_probe(struct platform_device *ofdev) { const struct of_device_id *match; struct net_device *ndev; struct fs_enet_private *fep; struct fs_platform_info *fpi; const u32 *data; struct clk *clk; int err; const u8 *mac_addr; const char *phy_connection_type; int privsize, len, ret = -ENODEV; match = of_match_device(fs_enet_match, &ofdev->dev); if (!match) return -EINVAL; fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); if (!fpi) return -ENOMEM; if (!IS_FEC(match)) { data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); if (!data || len != 4) goto out_free_fpi; fpi->cp_command = *data; } fpi->rx_ring = 32; fpi->tx_ring = 32; fpi->rx_copybreak = 240; fpi->use_napi = 1; fpi->napi_weight = 17; fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); if ((!fpi->phy_node) && (!of_get_property(ofdev->dev.of_node, "fixed-link", NULL))) goto out_free_fpi; if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) { phy_connection_type = of_get_property(ofdev->dev.of_node, "phy-connection-type", NULL); if (phy_connection_type && !strcmp("rmii", phy_connection_type)) fpi->use_rmii = 1; } /* make clock lookup non-fatal (the driver is shared among platforms), * but require enable to succeed when a clock was specified/found, * keep a reference to the clock upon successful acquisition */ clk = devm_clk_get(&ofdev->dev, "per"); if (!IS_ERR(clk)) { err = clk_prepare_enable(clk); if (err) { ret = err; goto out_free_fpi; } fpi->clk_per = clk; } privsize = sizeof(*fep) + sizeof(struct sk_buff **) * (fpi->rx_ring + fpi->tx_ring); ndev = alloc_etherdev(privsize); if (!ndev) { ret = -ENOMEM; goto out_put; } SET_NETDEV_DEV(ndev, &ofdev->dev); platform_set_drvdata(ofdev, ndev); fep = netdev_priv(ndev); fep->dev = &ofdev->dev; fep->ndev = ndev; fep->fpi = fpi; fep->ops = match->data; ret = fep->ops->setup_data(ndev); if (ret) goto out_free_dev; fep->rx_skbuff = (struct sk_buff **)&fep[1]; fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring; spin_lock_init(&fep->lock); spin_lock_init(&fep->tx_lock); mac_addr = of_get_mac_address(ofdev->dev.of_node); if (mac_addr) memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); ret = fep->ops->allocate_bd(ndev); if (ret) goto out_cleanup_data; fep->rx_bd_base = fep->ring_base; fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring; fep->tx_ring = fpi->tx_ring; fep->rx_ring = fpi->rx_ring; ndev->netdev_ops = &fs_enet_netdev_ops; ndev->watchdog_timeo = 2 * HZ; if (fpi->use_napi) netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); ndev->ethtool_ops = &fs_ethtool_ops; init_timer(&fep->phy_timer_list); netif_carrier_off(ndev); ret = register_netdev(ndev); if (ret) goto out_free_bd; pr_info("%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr); return 0; out_free_bd: fep->ops->free_bd(ndev); out_cleanup_data: fep->ops->cleanup_data(ndev); out_free_dev: free_netdev(ndev); out_put: of_node_put(fpi->phy_node); if (fpi->clk_per) clk_disable_unprepare(fpi->clk_per); out_free_fpi: kfree(fpi); return ret; }
static int ti_hecc_probe(struct platform_device *pdev) { struct net_device *ndev = (struct net_device *)0; struct ti_hecc_priv *priv; struct ti_hecc_platform_data *pdata; struct resource *mem, *irq; void __iomem *addr; int err = -ENODEV; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data\n"); goto probe_exit; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "No mem resources\n"); goto probe_exit; } irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!irq) { dev_err(&pdev->dev, "No irq resource\n"); goto probe_exit; } if (!request_mem_region(mem->start, resource_size(mem), pdev->name)) { dev_err(&pdev->dev, "HECC region already claimed\n"); err = -EBUSY; goto probe_exit; } addr = ioremap(mem->start, resource_size(mem)); if (!addr) { dev_err(&pdev->dev, "ioremap failed\n"); err = -ENOMEM; goto probe_exit_free_region; } ndev = alloc_candev(sizeof(struct ti_hecc_priv), HECC_MAX_TX_MBOX); if (!ndev) { dev_err(&pdev->dev, "alloc_candev failed\n"); err = -ENOMEM; goto probe_exit_iounmap; } priv = netdev_priv(ndev); priv->ndev = ndev; priv->base = addr; priv->scc_ram_offset = pdata->scc_ram_offset; priv->hecc_ram_offset = pdata->hecc_ram_offset; priv->mbx_offset = pdata->mbx_offset; priv->int_line = pdata->int_line; priv->transceiver_switch = pdata->transceiver_switch; priv->can.bittiming_const = &ti_hecc_bittiming_const; priv->can.do_set_mode = ti_hecc_do_set_mode; priv->can.do_get_state = ti_hecc_get_state; priv->can.do_get_berr_counter = ti_hecc_get_berr_counter; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; spin_lock_init(&priv->mbx_lock); ndev->irq = irq->start; ndev->flags |= IFF_ECHO; platform_set_drvdata(pdev, ndev); SET_NETDEV_DEV(ndev, &pdev->dev); ndev->netdev_ops = &ti_hecc_netdev_ops; priv->clk = clk_get(&pdev->dev, "hecc_ck"); if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "No clock available\n"); err = PTR_ERR(priv->clk); priv->clk = NULL; goto probe_exit_candev; } priv->can.clock.freq = clk_get_rate(priv->clk); netif_napi_add(ndev, &priv->napi, ti_hecc_rx_poll, HECC_DEF_NAPI_WEIGHT); clk_enable(priv->clk); err = register_candev(ndev); if (err) { dev_err(&pdev->dev, "register_candev() failed\n"); goto probe_exit_clk; } dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n", priv->base, (u32) ndev->irq); return 0; probe_exit_clk: clk_put(priv->clk); probe_exit_candev: free_candev(ndev); probe_exit_iounmap: iounmap(addr); probe_exit_free_region: release_mem_region(mem->start, resource_size(mem)); probe_exit: return err; }
static int __init ag71xx_probe(struct platform_device *pdev) { struct net_device *dev; struct resource *res; struct ag71xx *ag; struct ag71xx_platform_data *pdata; int err; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "no platform data specified\n"); err = -ENXIO; goto err_out; } dev = alloc_etherdev(sizeof(*ag)); if (!dev) { dev_err(&pdev->dev, "alloc_etherdev failed\n"); err = -ENOMEM; goto err_out; } SET_NETDEV_DEV(dev, &pdev->dev); ag = netdev_priv(dev); ag->pdev = pdev; ag->dev = dev; ag->mii_bus = ag71xx_mdio_bus->mii_bus; ag->msg_enable = netif_msg_init(ag71xx_debug, AG71XX_DEFAULT_MSG_ENABLE); spin_lock_init(&ag->lock); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base"); if (!res) { dev_err(&pdev->dev, "no mac_base resource found\n"); err = -ENXIO; goto err_out; } ag->mac_base = ioremap_nocache(res->start, res->end - res->start + 1); if (!ag->mac_base) { dev_err(&pdev->dev, "unable to ioremap mac_base\n"); err = -ENOMEM; goto err_free_dev; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base2"); if (!res) { dev_err(&pdev->dev, "no mac_base2 resource found\n"); err = -ENXIO; goto err_unmap_base1; } ag->mac_base2 = ioremap_nocache(res->start, res->end - res->start + 1); if (!ag->mac_base) { dev_err(&pdev->dev, "unable to ioremap mac_base2\n"); err = -ENOMEM; goto err_unmap_base1; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mii_ctrl"); if (!res) { dev_err(&pdev->dev, "no mii_ctrl resource found\n"); err = -ENXIO; goto err_unmap_base2; } ag->mii_ctrl = ioremap_nocache(res->start, res->end - res->start + 1); if (!ag->mii_ctrl) { dev_err(&pdev->dev, "unable to ioremap mii_ctrl\n"); err = -ENOMEM; goto err_unmap_base2; } dev->irq = platform_get_irq(pdev, 0); err = request_irq(dev->irq, ag71xx_interrupt, IRQF_DISABLED | IRQF_SAMPLE_RANDOM, dev->name, dev); if (err) { dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq); goto err_unmap_mii_ctrl; } dev->base_addr = (unsigned long)ag->mac_base; dev->open = ag71xx_open; dev->stop = ag71xx_stop; dev->hard_start_xmit = ag71xx_hard_start_xmit; dev->set_multicast_list = ag71xx_set_multicast_list; dev->do_ioctl = ag71xx_do_ioctl; dev->ethtool_ops = &ag71xx_ethtool_ops; dev->tx_timeout = ag71xx_tx_timeout; INIT_WORK(&ag->restart_work, ag71xx_restart_work_func); init_timer(&ag->oom_timer); ag->oom_timer.data = (unsigned long) dev; ag->oom_timer.function = ag71xx_oom_timer_handler; memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN); netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT); err = register_netdev(dev); if (err) { dev_err(&pdev->dev, "unable to register net device\n"); goto err_free_irq; } printk(KERN_INFO "%s: Atheros AG71xx at 0x%08lx, irq %d\n", dev->name, dev->base_addr, dev->irq); ag71xx_dump_regs(ag); ag71xx_hw_init(ag); ag71xx_dump_regs(ag); /* Reset the mdio bus explicitly */ if (ag->mii_bus) { mutex_lock(&ag->mii_bus->mdio_lock); ag->mii_bus->reset(ag->mii_bus); mutex_unlock(&ag->mii_bus->mdio_lock); } err = ag71xx_phy_connect(ag); if (err) goto err_unregister_netdev; platform_set_drvdata(pdev, dev); return 0; err_unregister_netdev: unregister_netdev(dev); err_free_irq: free_irq(dev->irq, dev); err_unmap_mii_ctrl: iounmap(ag->mii_ctrl); err_unmap_base2: iounmap(ag->mac_base2); err_unmap_base1: iounmap(ag->mac_base); err_free_dev: kfree(dev); err_out: platform_set_drvdata(pdev, NULL); return err; }
static int __devinit fs_enet_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct net_device *ndev; struct fs_enet_private *fep; struct fs_platform_info *fpi; const u32 *data; const u8 *mac_addr; int privsize, len, ret = -ENODEV; fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); if (!fpi) return -ENOMEM; if (!IS_FEC(match)) { data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); if (!data || len != 4) goto out_free_fpi; fpi->cp_command = *data; } fpi->rx_ring = 32; fpi->tx_ring = 32; fpi->rx_copybreak = 240; fpi->use_napi = 1; fpi->napi_weight = 17; fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); if ((!fpi->phy_node) && (!of_get_property(ofdev->dev.of_node, "fixed-link", NULL))) goto out_free_fpi; privsize = sizeof(*fep) + sizeof(struct sk_buff **) * (fpi->rx_ring + fpi->tx_ring); ndev = alloc_etherdev(privsize); if (!ndev) { ret = -ENOMEM; goto out_put; } SET_NETDEV_DEV(ndev, &ofdev->dev); dev_set_drvdata(&ofdev->dev, ndev); fep = netdev_priv(ndev); fep->dev = &ofdev->dev; fep->ndev = ndev; fep->fpi = fpi; fep->ops = match->data; ret = fep->ops->setup_data(ndev); if (ret) goto out_free_dev; fep->rx_skbuff = (struct sk_buff **)&fep[1]; fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring; spin_lock_init(&fep->lock); spin_lock_init(&fep->tx_lock); mac_addr = of_get_mac_address(ofdev->dev.of_node); if (mac_addr) memcpy(ndev->dev_addr, mac_addr, 6); ret = fep->ops->allocate_bd(ndev); if (ret) goto out_cleanup_data; fep->rx_bd_base = fep->ring_base; fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring; fep->tx_ring = fpi->tx_ring; fep->rx_ring = fpi->rx_ring; ndev->netdev_ops = &fs_enet_netdev_ops; ndev->watchdog_timeo = 2 * HZ; if (fpi->use_napi) netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); ndev->ethtool_ops = &fs_ethtool_ops; init_timer(&fep->phy_timer_list); netif_carrier_off(ndev); ret = register_netdev(ndev); if (ret) goto out_free_bd; pr_info("%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr); return 0; out_free_bd: fep->ops->free_bd(ndev); out_cleanup_data: fep->ops->cleanup_data(ndev); out_free_dev: free_netdev(ndev); dev_set_drvdata(&ofdev->dev, NULL); out_put: of_node_put(fpi->phy_node); out_free_fpi: kfree(fpi); return ret; }