1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

net: Remove unneeded NULL check for the allocated ifnet

Change 4787572d05 made if_alloc_domain() never fail, then also do the
wrappers if_alloc(), if_alloc_dev(), and if_gethandle().

No functional change intended.

Reviewed by:	kp, imp, glebius, stevek
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45740

(cherry picked from commit aa3860851b)
This commit is contained in:
Zhenlei Huang 2024-06-28 18:16:29 +08:00
parent 72f8b18b8d
commit 6b1f530935
109 changed files with 33 additions and 608 deletions

View File

@ -941,11 +941,6 @@ emac_attach(device_t dev)
emac_reset(sc);
ifp = sc->emac_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "unable to allocate ifp\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
/* Setup MII */

View File

@ -1025,11 +1025,6 @@ cpswp_attach(device_t dev)
/* Allocate network interface */
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
cpswp_detach(dev);
return (ENXIO);
}
if_initname(ifp, device_get_name(sc->dev), sc->unit);
if_setsoftc(ifp, sc);
if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);

View File

@ -327,12 +327,6 @@ ae_attach(device_t dev)
goto fail;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "could not allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -591,12 +591,6 @@ age_attach(device_t dev)
age_get_macaddr(sc);
ifp = sc->age_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1585,12 +1585,6 @@ alc_attach(device_t dev)
alc_get_macaddr(sc);
ifp = sc->alc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -610,12 +610,6 @@ ale_attach(device_t dev)
ale_get_macaddr(sc);
ifp = sc->ale_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1372,11 +1372,6 @@ atse_attach(device_t dev)
/* Setup interface. */
ifp = sc->atse_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "if_alloc() failed\n");
error = ENOSPC;
goto err;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -389,11 +389,6 @@ axgbe_attach(device_t dev)
OF_getprop(node, "mac-address", sc->mac_addr, ETHER_ADDR_LEN);
sc->prv.netdev = ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "Cannot alloc ifnet\n");
return (ENXIO);
}
sc->prv.dev = dev;
sc->prv.dmat = bus_get_dma_tag(dev);
sc->prv.phy.advertising = ADVERTISED_10000baseKR_Full |

View File

@ -1351,12 +1351,6 @@ bce_attach(device_t dev)
/* Allocate an ifnet structure. */
ifp = sc->bce_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
BCE_PRINTF("%s(%d): Interface allocation failed!\n",
__FILE__, __LINE__);
rc = ENXIO;
goto bce_attach_fail;
}
/* Initialize the ifnet interface. */
if_setsoftc(ifp, sc);

View File

@ -478,11 +478,6 @@ bfe_attach(device_t dev)
/* Set up ifnet structure */
ifp = sc->bfe_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "failed to if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -3712,11 +3712,6 @@ bge_attach(device_t dev)
/* Set up ifnet structure */
ifp = sc->bge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->bge_dev, "failed to if_alloc()\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -12965,7 +12965,7 @@ bxe_init(void *xsc)
BXE_CORE_UNLOCK(sc);
}
static int
static void
bxe_init_ifnet(struct bxe_softc *sc)
{
if_t ifp;
@ -12985,10 +12985,7 @@ bxe_init_ifnet(struct bxe_softc *sc)
BLOGI(sc, "IFMEDIA flags : %x\n", sc->ifmedia.ifm_media);
/* allocate the ifnet structure */
if ((ifp = if_gethandle(IFT_ETHER)) == NULL) {
BLOGE(sc, "Interface allocation failed!\n");
return (ENXIO);
}
ifp = if_gethandle(IFT_ETHER);
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
@ -13034,8 +13031,6 @@ bxe_init_ifnet(struct bxe_softc *sc)
/* Attach driver debugnet methods. */
DEBUGNET_SET(ifp, bxe);
return (0);
}
static void
@ -16261,12 +16256,7 @@ bxe_attach(device_t dev)
bxe_get_phy_info(sc);
/* initialize the FreeBSD ifnet interface */
if (bxe_init_ifnet(sc) != 0) {
bxe_release_mutexes(sc);
bxe_deallocate_bars(sc);
pci_disable_busmaster(dev);
return (ENXIO);
}
bxe_init_ifnet(sc);
if (bxe_add_cdev(sc) != 0) {
if (sc->ifp != NULL) {

View File

@ -1814,11 +1814,6 @@ cgem_attach(device_t dev)
/* Set up ifnet structure. */
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "could not allocate ifnet structure\n");
cgem_detach(dev);
return (ENOMEM);
}
if_setsoftc(ifp, sc);
if_initname(ifp, IF_CGEM_NAME, device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -188,8 +188,6 @@ cas_attach(struct cas_softc *sc)
/* Set up ifnet structure. */
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(sc->sc_dev),
device_get_unit(sc->sc_dev));

View File

@ -1011,11 +1011,6 @@ cxgb_port_attach(device_t dev)
/* Allocate an ifnet object and set it up */
ifp = p->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "Cannot allocate ifnet\n");
return (ENOMEM);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setinitfn(ifp, cxgb_init);
if_setsoftc(ifp, p);

View File

@ -2549,7 +2549,7 @@ cxgbe_probe(device_t dev)
IFCAP_HWRXTSTMP | IFCAP_MEXTPG)
#define T4_CAP_ENABLE (T4_CAP)
static int
static void
cxgbe_vi_attach(device_t dev, struct vi_info *vi)
{
if_t ifp;
@ -2588,10 +2588,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
/* Allocate an ifnet and set it up */
ifp = if_alloc_dev(IFT_ETHER, dev);
if (ifp == NULL) {
device_printf(dev, "Cannot allocate ifnet\n");
return (ENOMEM);
}
vi->ifp = ifp;
if_setsoftc(ifp, vi);
@ -2694,8 +2690,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
pa.pa_type = PFIL_TYPE_ETHERNET;
pa.pa_headname = if_name(ifp);
vi->pfil = pfil_head_register(&pa);
return (0);
}
static int
@ -2704,13 +2698,11 @@ cxgbe_attach(device_t dev)
struct port_info *pi = device_get_softc(dev);
struct adapter *sc = pi->adapter;
struct vi_info *vi;
int i, rc;
int i;
sysctl_ctx_init(&pi->ctx);
rc = cxgbe_vi_attach(dev, &pi->vi[0]);
if (rc)
return (rc);
cxgbe_vi_attach(dev, &pi->vi[0]);
for_each_vi(pi, i, vi) {
if (i == 0)
@ -3589,11 +3581,8 @@ vcxgbe_attach(device_t dev)
if (rc)
return (rc);
rc = cxgbe_vi_attach(dev, vi);
if (rc) {
t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid);
return (rc);
}
cxgbe_vi_attach(dev, vi);
return (0);
}

View File

@ -167,11 +167,6 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
}
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
rc = ENOMEM;
goto done;
}
/* Note that if_xname is identical to the nexus nameunit */
if_initname(ifp, name, -1);
if_setdname(ifp, t4_cloner_name);

View File

@ -2380,11 +2380,6 @@ dc_attach(device_t dev)
goto fail;
ifp = sc->dc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -678,12 +678,6 @@ dtsec_attach(device_t dev)
/* Create network interface for upper layers */
ifp = sc->sc_ifnet = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->sc_dev, "if_alloc() failed.\n");
dtsec_detach(dev);
return (ENOMEM);
}
if_setsoftc(ifp, sc);
if_setflags(ifp, IFF_SIMPLEX | IFF_BROADCAST);

View File

@ -548,11 +548,6 @@ dpaa2_ni_attach(device_t dev)
/* Allocate network interface */
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "%s: failed to allocate network interface\n",
__func__);
goto err_exit;
}
sc->ifp = ifp;
if_initname(ifp, DPAA2_NI_IFNAME, device_get_unit(sc->dev));

View File

@ -148,7 +148,7 @@ static int ena_ioctl(if_t, u_long, caddr_t);
static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *);
static void ena_update_host_info(struct ena_admin_host_info *, if_t);
static void ena_update_hwassist(struct ena_adapter *);
static int ena_setup_ifnet(device_t, struct ena_adapter *,
static void ena_setup_ifnet(device_t, struct ena_adapter *,
struct ena_com_dev_get_features_ctx *);
static int ena_enable_wc(device_t, struct resource *);
static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *,
@ -2462,7 +2462,7 @@ ena_update_hwassist(struct ena_adapter *adapter)
if_sethwassistbits(ifp, flags, 0);
}
static int
static void
ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
struct ena_com_dev_get_features_ctx *feat)
{
@ -2470,10 +2470,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
int caps = 0;
ifp = adapter->ifp = if_gethandle(IFT_ETHER);
if (unlikely(ifp == NULL)) {
ena_log(pdev, ERR, "can not allocate ifnet structure\n");
return (ENXIO);
}
if_initname(ifp, device_get_name(pdev), device_get_unit(pdev));
if_setdev(ifp, pdev);
if_setsoftc(ifp, adapter);
@ -2516,8 +2512,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
ether_ifattach(ifp, adapter->mac_addr);
return (0);
}
void
@ -3811,11 +3805,7 @@ ena_attach(device_t pdev)
ena_sysctl_add_nodes(adapter);
/* setup network interface */
rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx);
if (unlikely(rc != 0)) {
ena_log(pdev, ERR, "Error with network interface setup\n");
goto err_customer_metrics_alloc;
}
ena_setup_ifnet(pdev, adapter, &get_feat_ctx);
/* Initialize reset task queue */
TASK_INIT(&adapter->reset_task, 0, ena_reset_task, adapter);
@ -3852,7 +3842,6 @@ ena_attach(device_t pdev)
err_detach:
ether_ifdetach(adapter->ifp);
#endif /* DEV_NETMAP */
err_customer_metrics_alloc:
free(adapter->customer_metrics_array, M_DEVBUF);
err_metrics_buffer_destroy:
ena_com_delete_customer_metrics_buffer(ena_dev);

View File

@ -232,11 +232,6 @@ et_attach(device_t dev)
callout_init_mtx(&sc->sc_tick, &sc->sc_mtx, 0);
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
/*
* Initialize tunables

View File

@ -200,14 +200,6 @@ ar40xx_attach_phys(struct ar40xx_softc *sc)
snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
for (phy = 0; phy < AR40XX_NUM_PHYS; phy++) {
sc->sc_phys.ifp[phy] = if_alloc(IFT_ETHER);
if (sc->sc_phys.ifp[phy] == NULL) {
device_printf(sc->sc_dev,
"PHY %d: couldn't allocate ifnet structure\n",
phy);
err = ENOMEM;
break;
}
sc->sc_phys.ifp[phy]->if_softc = sc;
sc->sc_phys.ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX;

View File

@ -150,12 +150,6 @@ arswitch_attach_phys(struct arswitch_softc *sc)
snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
for (phy = 0; phy < sc->numphys; phy++) {
sc->ifp[phy] = if_alloc(IFT_ETHER);
if (sc->ifp[phy] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
if_setsoftc(sc->ifp[phy], sc);
if_setflagbits(sc->ifp[phy], IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX, 0);

View File

@ -454,8 +454,6 @@ e6000sw_init_interface(e6000sw_softc_t *sc, int port)
snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev));
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL)
return (ENOMEM);
if_setsoftc(sc->ifp[port], sc);
if_setflagbits(sc->ifp[port], IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX, 0);

View File

@ -214,12 +214,6 @@ e6060sw_attach_phys(struct e6060sw_softc *sc)
sc->ifpport[phy] = port;
sc->portphy[port] = phy;
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
sc->ifp[port]->if_softc = sc;
sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX;

View File

@ -241,9 +241,6 @@ felix_init_interface(felix_softc_t sc, int port)
snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev));
sc->ports[port].ifp = if_alloc(IFT_ETHER);
if (sc->ports[port].ifp == NULL)
return (ENOMEM);
if_setsoftc(sc->ports[port].ifp, sc);
if_setflags(sc->ports[port].ifp, IFF_UP | IFF_BROADCAST | IFF_MULTICAST |
IFF_DRV_RUNNING | IFF_SIMPLEX);

View File

@ -173,12 +173,6 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc)
sc->ifpport[phy] = port;
sc->portphy[port] = phy;
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
sc->ifp[port]->if_softc = sc;
sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX;

View File

@ -172,12 +172,6 @@ ip17x_attach_phys(struct ip17x_softc *sc)
sc->phyport[phy] = port;
sc->portphy[port] = phy;
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
if_setsoftc(sc->ifp[port], sc);
if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX);

View File

@ -219,12 +219,6 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc)
sc->ifpport[phy] = port;
sc->portphy[port] = phy;
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
sc->ifp[port]->if_softc = sc;
sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX;

View File

@ -121,12 +121,6 @@ mtkswitch_attach_phys(struct mtkswitch_softc *sc)
continue;
}
sc->ifp[phy] = if_alloc(IFT_ETHER);
if (sc->ifp[phy] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
sc->ifp[phy]->if_softc = sc;
sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX;

View File

@ -238,12 +238,6 @@ rtl8366rb_attach(device_t dev)
/* PHYs need an interface, so we generate a dummy one */
for (i = 0; i < sc->numphys; i++) {
sc->ifp[i] = if_alloc(IFT_ETHER);
if (sc->ifp[i] == NULL) {
device_printf(dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
if_setsoftc(sc->ifp[i], sc);
if_setflagbits(sc->ifp[i], IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING
| IFF_SIMPLEX, 0);

View File

@ -124,12 +124,6 @@ ukswitch_attach_phys(struct ukswitch_softc *sc)
sc->ifpport[phy] = port;
sc->portphy[port] = phy;
sc->ifp[port] = if_alloc(IFT_ETHER);
if (sc->ifp[port] == NULL) {
device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
err = ENOMEM;
break;
}
if_setsoftc(sc->ifp[port], sc);
if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
IFF_DRV_RUNNING | IFF_SIMPLEX);

View File

@ -178,10 +178,6 @@ fwe_attach(device_t dev)
/* fill the rest and attach interface */
ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
return (ENOSPC);
}
if_setsoftc(ifp, &fwe->eth_softc);
if_initname(ifp, device_get_name(dev), unit);
@ -201,7 +197,7 @@ fwe_attach(device_t dev)
if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0);
FWEDEBUG(ifp, "interface created\n");
return 0;
return (0);
}
static void

View File

@ -153,8 +153,6 @@ fwip_attach(device_t dev)
fwip = ((struct fwip_softc *)device_get_softc(dev));
unit = device_get_unit(dev);
ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394);
if (ifp == NULL)
return (ENOSPC);
mtx_init(&fwip->mtx, "fwip", NULL, MTX_DEF);
/* XXX */
@ -199,7 +197,7 @@ fwip_attach(device_t dev)
splx(s);
FWIPDEBUG(ifp, "interface created\n");
return 0;
return (0);
}
static void

View File

@ -443,11 +443,6 @@ fxp_attach(device_t dev)
fxp_serial_ifmedia_sts);
ifp = sc->ifp = if_gethandle(IFT_ETHER);
if (ifp == (void *)NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
/*
* Enable bus mastering.

View File

@ -152,8 +152,6 @@ gem_attach(struct gem_softc *sc)
/* Set up ifnet structure. */
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
sc->sc_csum_features = GEM_CSUM_FEATURES;
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(sc->sc_dev),

View File

@ -352,18 +352,13 @@ gve_get_counter(if_t ifp, ift_counter cnt)
}
}
static int
static void
gve_setup_ifnet(device_t dev, struct gve_priv *priv)
{
int caps = 0;
if_t ifp;
ifp = priv->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(priv->dev, "Failed to allocate ifnet struct\n");
return (ENXIO);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setsoftc(ifp, priv);
if_setdev(ifp, dev);
@ -401,8 +396,6 @@ gve_setup_ifnet(device_t dev, struct gve_priv *priv)
ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
return (0);
}
static int
@ -794,9 +787,7 @@ gve_attach(device_t dev)
if (err != 0)
goto abort;
err = gve_setup_ifnet(dev, priv);
if (err != 0)
goto abort;
gve_setup_ifnet(dev, priv);
priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK;

View File

@ -162,8 +162,6 @@ icattach(device_t dev)
if_t ifp;
ifp = sc->ic_ifp = if_alloc(IFT_PARA);
if (ifp == NULL)
return (ENOSPC);
mtx_init(&sc->ic_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);

View File

@ -805,12 +805,6 @@ jme_attach(device_t dev)
goto fail;
ifp = sc->jme_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -110,8 +110,6 @@ lance_config(struct lance_softc *sc, const char* name, int unit)
return (ENXIO);
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0);

View File

@ -512,11 +512,6 @@ lge_attach(device_t dev)
}
ifp = sc->lge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1327,11 +1327,6 @@ lio_setup_nic_devices(struct octeon_device *octeon_dev)
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
lio_dev_err(octeon_dev, "Device allocation failed\n");
goto setup_nic_dev_fail;
}
lio = malloc(sizeof(struct lio), M_DEVBUF, M_NOWAIT | M_ZERO);
if (lio == NULL) {

View File

@ -2805,11 +2805,6 @@ mana_probe_port(struct mana_context *ac, int port_idx,
int err;
ndev = if_alloc_dev(IFT_ETHER, gc->dev);
if (!ndev) {
mana_err(NULL, "Failed to allocate ifnet struct\n");
return ENOMEM;
}
*ndev_storage = ndev;
apc = malloc(sizeof(*apc), M_DEVBUF, M_WAITOK | M_ZERO);

View File

@ -848,12 +848,6 @@ mge_attach(device_t dev)
/* Allocate network interface */
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "if_alloc() failed\n");
mge_detach(dev);
return (ENOMEM);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setsoftc(ifp, sc);
if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);

View File

@ -2143,11 +2143,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
dev = priv->dev = if_alloc(IFT_ETHER);
if (dev == NULL) {
en_err(priv, "Net device allocation failed\n");
kfree(priv);
return -ENOMEM;
}
if_setsoftc(dev, priv);
if_initname(dev, "mlxen", (device_get_unit(
mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1);

View File

@ -4488,10 +4488,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
M_MLX5EN, mlx5_dev_domainset(mdev), M_WAITOK | M_ZERO);
ifp = priv->ifp = if_alloc_dev(IFT_ETHER, mdev->pdev->dev.bsddev);
if (ifp == NULL) {
mlx5_core_err(mdev, "if_alloc() failed\n");
goto err_free_priv;
}
/* setup all static fields */
if (mlx5e_priv_static_init(priv, mdev, mdev->priv.eq_table.num_comp_vectors)) {
mlx5_core_err(mdev, "mlx5e_priv_static_init() failed\n");
@ -4831,8 +4827,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
err_free_ifp:
if_free(ifp);
err_free_priv:
free(priv, M_MLX5EN);
return (NULL);
}

View File

@ -1624,11 +1624,6 @@ msk_attach(device_t dev)
msk_rx_dma_jalloc(sc_if);
ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc_if->msk_if_dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc_if);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -4641,11 +4641,6 @@ mxge_attach(device_t dev)
}
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
err = ENOSPC;
goto abort_with_parent_dmat;
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
snprintf(sc->cmd_mtx_name, sizeof(sc->cmd_mtx_name), "%s:cmd",
@ -4814,7 +4809,6 @@ mxge_attach(device_t dev)
mtx_destroy(&sc->cmd_mtx);
mtx_destroy(&sc->driver_mtx);
if_free(ifp);
abort_with_parent_dmat:
bus_dma_tag_destroy(sc->parent_dmat);
abort_with_tq:
if (sc->tq != NULL) {

View File

@ -874,11 +874,6 @@ my_attach(device_t dev)
bzero(sc->my_ldata, sizeof(struct my_list_data));
ifp = sc->my_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto free_ldata;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
@ -962,7 +957,6 @@ my_attach(device_t dev)
ether_ifdetach(ifp);
free_if:
if_free(ifp);
free_ldata:
free(sc->my_ldata_ptr, M_DEVBUF);
release_irq:
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->my_irq);

View File

@ -612,11 +612,6 @@ mvneta_attach(device_t self)
/* Allocate network interface */
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(self, "if_alloc() failed\n");
mvneta_detach(self);
return (ENOMEM);
}
if_initname(ifp, device_get_name(self), device_get_unit(self));
/*

View File

@ -399,12 +399,6 @@ ptnet_attach(device_t dev)
/* Setup Ethernet interface. */
sc->ifp = ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "Failed to allocate ifnet\n");
err = ENOMEM;
goto err_path;
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setbaudrate(ifp, IF_Gbps(10));
if_setsoftc(ifp, sc);

View File

@ -612,10 +612,6 @@ nm_os_vi_persist(const char *name, if_t *ret)
eaddr[5] = (uint8_t)unit;
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
nm_prerr("if_alloc failed");
return ENOMEM;
}
if_initname(ifp, name, IF_DUNIT_NONE);
if_setflags(ifp, IFF_UP | IFF_SIMPLEX | IFF_MULTICAST);
if_setinitfn(ifp, (void *)nm_vi_dummy);

View File

@ -567,11 +567,6 @@ nfe_attach(device_t dev)
goto fail;
ifp = sc->nfe_ifp = if_gethandle(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_gethandle()\n");
error = ENOSPC;
goto fail;
}
/*
* Allocate Tx and Rx rings.

View File

@ -900,11 +900,6 @@ nge_attach(device_t dev)
nge_sysctl_node(sc);
ifp = sc->nge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not allocate ifnet structure\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -137,10 +137,6 @@ ntb_net_attach(device_t dev)
int i;
ifp = sc->ifp = if_gethandle(IFT_ETHER);
if (ifp == NULL) {
printf("ntb: Cannot allocate ifnet structure\n");
return (ENOMEM);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setdev(ifp, dev);

View File

@ -170,7 +170,7 @@ static void oce_rx_lro(struct oce_rq *rq, struct nic_hwlro_singleton_cqe *cqe, s
static void oce_rx_mbuf_chain(struct oce_rq *rq, struct oce_common_cqe_info *cqe_info, struct mbuf **m);
/* Helper function prototypes in this file */
static int oce_attach_ifp(POCE_SOFTC sc);
static void oce_attach_ifp(POCE_SOFTC sc);
static void oce_add_vlan(void *arg, if_t ifp, uint16_t vtag);
static void oce_del_vlan(void *arg, if_t ifp, uint16_t vtag);
static int oce_vid_config(POCE_SOFTC sc);
@ -334,9 +334,7 @@ oce_attach(device_t dev)
if (rc)
goto intr_free;
rc = oce_attach_ifp(sc);
if (rc)
goto queues_free;
oce_attach_ifp(sc);
#if defined(INET6) || defined(INET)
rc = oce_init_lro(sc);
@ -392,7 +390,6 @@ oce_attach(device_t dev)
#endif
ether_ifdetach(sc->ifp);
if_free(sc->ifp);
queues_free:
oce_queue_release_all(sc);
intr_free:
oce_intr_free(sc);
@ -2099,13 +2096,11 @@ oce_rq_handler(void *arg)
* Helper function prototypes in this file *
*****************************************************************************/
static int
static void
oce_attach_ifp(POCE_SOFTC sc)
{
sc->ifp = if_alloc(IFT_ETHER);
if (!sc->ifp)
return ENOMEM;
ifmedia_init(&sc->media, IFM_IMASK, oce_media_change, oce_media_status);
ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
@ -2148,8 +2143,6 @@ oce_attach_ifp(POCE_SOFTC sc)
if_sethwtsomaxsegsize(sc->ifp, 4096);
ether_ifattach(sc->ifp, sc->macaddr.mac_addr);
return 0;
}
static void

View File

@ -249,10 +249,6 @@ lp_attach(device_t dev)
}
ifp = lp->sc_ifp = if_alloc(IFT_PARA);
if (ifp == NULL) {
return (ENOSPC);
}
if_setsoftc(ifp, lp);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setmtu(ifp, LPMTU);

View File

@ -2292,10 +2292,6 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha)
if_t ifp;
ifp = ha->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
device_id = pci_get_device(ha->pci_dev);

View File

@ -658,9 +658,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha)
ifp = ha->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setmtu(ifp, ETHERMTU);

View File

@ -852,10 +852,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha)
QL_DPRINT2(ha, (dev, "%s: enter\n", __func__));
ifp = ha->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setbaudrate(ifp, IF_Gbps(10));

View File

@ -719,10 +719,6 @@ qls_init_ifnet(device_t dev, qla_host_t *ha)
QL_DPRINT2((dev, "%s: enter\n", __func__));
ifp = ha->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setbaudrate(ifp, IF_Gbps(10));
if_setinitfn(ifp, qls_init);

View File

@ -1606,11 +1606,6 @@ re_attach(device_t dev)
re_add_sysctls(sc);
ifp = sc->rl_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
/* Take controller out of deep sleep mode. */
if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) {

View File

@ -780,11 +780,6 @@ rl_attach(device_t dev)
goto fail;
ifp = sc->rl_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
#define RL_PHYAD_INTERNAL 0

View File

@ -212,7 +212,7 @@ sbni_probe(struct sbni_softc *sc)
/*
* Install interface into kernel networking data structures
*/
int
void
sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
{
if_t ifp;
@ -220,8 +220,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
uint64_t baudrate;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOMEM);
sbni_outb(sc, CSR0, 0);
set_initial_values(sc, flags);
@ -250,7 +248,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
printf("auto\n");
else
printf("%d (fixed)\n", sc->cur_rxl_index);
return (0);
}
void

View File

@ -137,12 +137,7 @@ sbni_attach_isa(device_t dev)
*(u_int32_t*)&flags = device_get_flags(dev);
error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (error) {
device_printf(dev, "cannot initialize driver\n");
sbni_release_resources(sc);
return (error);
}
sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (sc->irq_res) {
error = bus_setup_intr(

View File

@ -132,20 +132,9 @@ sbni_pci_attach(device_t dev)
memset(&flags, 0, sizeof(flags));
error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (error) {
device_printf(dev, "cannot initialize driver\n");
goto attach_failed;
}
if (sc->slave_sc) {
error = sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1,
flags);
if (error) {
device_printf(dev, "cannot initialize slave\n");
sbni_detach(sc);
goto attach_failed;
}
}
sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (sc->slave_sc)
sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1, flags);
if (sc->irq_res) {
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET |

View File

@ -125,7 +125,7 @@ struct sbni_softc {
void sbni_intr(void *);
int sbni_probe(struct sbni_softc *);
int sbni_attach(struct sbni_softc *, int, struct sbni_flags);
void sbni_attach(struct sbni_softc *, int, struct sbni_flags);
void sbni_detach(struct sbni_softc *);
void sbni_release_resources(struct sbni_softc *);

View File

@ -1081,11 +1081,6 @@ sfxge_attach(device_t dev)
/* Allocate ifnet. */
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "Couldn't allocate ifnet\n");
error = ENOMEM;
goto fail;
}
sc->ifnet = ifp;
/* Initialize hardware. */
@ -1122,8 +1117,6 @@ sfxge_attach(device_t dev)
fail2:
if_free(sc->ifnet);
fail:
DBGPRINT(sc->dev, "failed %d", error);
return (error);
}

View File

@ -603,11 +603,6 @@ sge_attach(device_t dev)
goto fail;
ifp = sc->sge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1057,11 +1057,6 @@ sis_attach(device_t dev)
goto fail;
ifp = sc->sis_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1279,11 +1279,6 @@ sk_attach(device_t dev)
sk_dma_jumbo_alloc(sc_if);
ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc_if->sk_if_dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc_if);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -313,10 +313,6 @@ smc_attach(device_t dev)
sc->smc_dev = dev;
ifp = sc->smc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
error = ENOSPC;
goto done;
}
mtx_init(&sc->smc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);

View File

@ -987,11 +987,6 @@ ste_attach(device_t dev)
goto fail;
ifp = sc->ste_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
/* Do MII setup. */
phy = MII_PHY_ANY;

View File

@ -560,12 +560,6 @@ stge_attach(device_t dev)
}
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->sc_dev, "failed to if_alloc()\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1144,7 +1144,7 @@ check_tx_queues(struct sume_adapter *adapter)
}
}
static int
static void
sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
{
if_t ifp;
@ -1152,11 +1152,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
M_ZERO | M_WAITOK);
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(adapter->dev, "cannot allocate ifnet\n");
return (ENOMEM);
}
adapter->ifp[port] = ifp;
if_setsoftc(ifp, nf_priv);
@ -1182,8 +1177,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
ifmedia_set(&nf_priv->media, IFM_ETHER | IFM_10G_SR);
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
return (0);
}
static void
@ -1453,11 +1446,8 @@ sume_attach(device_t dev)
goto error;
/* Now do the network interfaces. */
for (i = 0; i < SUME_NPORTS; i++) {
error = sume_ifp_alloc(adapter, i);
if (error != 0)
goto error;
}
for (i = 0; i < SUME_NPORTS; i++)
sume_ifp_alloc(adapter, i);
/* Register stats and register sysctls. */
sume_sysctl_init(adapter);

View File

@ -2384,11 +2384,6 @@ ti_attach(device_t dev)
callout_init_mtx(&sc->ti_watchdog, &sc->ti_mtx, 0);
ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts);
ifp = sc->ti_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_sethwassist(ifp, TI_CSUM_FEATURES);
if_setcapabilities(ifp, IFCAP_TXCSUM | IFCAP_RXCSUM);
if_setcapenable(ifp, if_getcapabilities(sc->ti_ifp));

View File

@ -239,12 +239,6 @@ tsec_attach(struct tsec_softc *sc)
/* Create network interface for upper layers */
ifp = sc->tsec_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->dev, "if_alloc() failed\n");
tsec_detach(sc);
return (ENOMEM);
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);

View File

@ -431,11 +431,6 @@ usie_attach(device_t self)
/* setup ifnet (Direct IP) */
sc->sc_ifp = ifp = if_alloc(IFT_OTHER);
if (ifp == NULL) {
device_printf(self, "Could not allocate a network interface\n");
goto detach;
}
if_initname(ifp, "usie", device_get_unit(self));
if_setsoftc(ifp, sc);

View File

@ -1566,10 +1566,6 @@ uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type)
}
sc->sc_ifp = ifp = if_alloc(IFT_OTHER);
if (sc->sc_ifp == NULL) {
device_printf(sc->sc_dev, "if_alloc() failed\n");
return (-1);
}
callout_init_mtx(&sc->sc_c, &sc->sc_mtx, 0);
mtx_lock(&sc->sc_mtx);

View File

@ -221,11 +221,6 @@ ue_attach_post_task(struct usb_proc_msg *_task)
error = 0;
CURVNET_SET_QUIET(vnet0);
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(ue->ue_dev, "could not allocate ifnet\n");
goto fail;
}
if_setsoftc(ifp, ue);
if_initname(ifp, "ue", ue->ue_unit);
if (ue->ue_methods->ue_attach_post_sub != NULL) {

View File

@ -195,12 +195,6 @@ usbpf_clone_create(struct if_clone *ifc, char *name, size_t len,
return (error);
}
ifp = ubus->ifp = if_alloc(IFT_USB);
if (ifp == NULL) {
ifc_free_unit(ifc, unit);
device_printf(ubus->parent, "usbpf: Could not allocate "
"instance\n");
return (ENOSPC);
}
if_setsoftc(ifp, ubus);
if_initname(ifp, usbusname, unit);
if_setname(ifp, name);

View File

@ -1093,12 +1093,6 @@ vge_attach(device_t dev)
goto fail;
ifp = sc->vge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
vge_miipoll_start(sc);
/* Do MII setup */
error = mii_attach(dev, &sc->vge_miibus, ifp, vge_ifmedia_upd,

View File

@ -116,7 +116,7 @@ static void vtnet_free_rxtx_queues(struct vtnet_softc *);
static int vtnet_alloc_rx_filters(struct vtnet_softc *);
static void vtnet_free_rx_filters(struct vtnet_softc *);
static int vtnet_alloc_virtqueues(struct vtnet_softc *);
static int vtnet_alloc_interface(struct vtnet_softc *);
static void vtnet_alloc_interface(struct vtnet_softc *);
static int vtnet_setup_interface(struct vtnet_softc *);
static int vtnet_ioctl_mtu(struct vtnet_softc *, u_int);
static int vtnet_ioctl_ifflags(struct vtnet_softc *);
@ -438,12 +438,7 @@ vtnet_attach(device_t dev)
callout_init_mtx(&sc->vtnet_tick_ch, VTNET_CORE_MTX(sc), 0);
vtnet_load_tunables(sc);
error = vtnet_alloc_interface(sc);
if (error) {
device_printf(dev, "cannot allocate interface\n");
goto fail;
}
vtnet_alloc_interface(sc);
vtnet_setup_sysctl(sc);
error = vtnet_setup_features(sc);
@ -1078,7 +1073,7 @@ vtnet_alloc_virtqueues(struct vtnet_softc *sc)
return (error);
}
static int
static void
vtnet_alloc_interface(struct vtnet_softc *sc)
{
device_t dev;
@ -1087,14 +1082,9 @@ vtnet_alloc_interface(struct vtnet_softc *sc)
dev = sc->vtnet_dev;
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOMEM);
sc->vtnet_ifp = ifp;
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
return (0);
}
static int

View File

@ -139,7 +139,7 @@ static void nicvf_config_cpi(struct nicvf *);
static int nicvf_rss_init(struct nicvf *);
static int nicvf_init_resources(struct nicvf *);
static int nicvf_setup_ifnet(struct nicvf *);
static void nicvf_setup_ifnet(struct nicvf *);
static int nicvf_setup_ifmedia(struct nicvf *);
static void nicvf_hw_addr_random(uint8_t *);
@ -247,11 +247,7 @@ nicvf_attach(device_t dev)
nicvf_rss_init(nic);
NICVF_CORE_UNLOCK(nic);
err = nicvf_setup_ifnet(nic);
if (err != 0) {
device_printf(dev, "Could not set-up ifnet\n");
goto err_release_intr;
}
nicvf_setup_ifnet(nic);
err = nicvf_setup_ifmedia(nic);
if (err != 0) {
@ -329,17 +325,12 @@ nicvf_hw_addr_random(uint8_t *hwaddr)
memcpy(hwaddr, addr, ETHER_ADDR_LEN);
}
static int
static void
nicvf_setup_ifnet(struct nicvf *nic)
{
if_t ifp;
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(nic->dev, "Could not allocate ifnet structure\n");
return (ENOMEM);
}
nic->ifp = ifp;
if_setsoftc(ifp, nic);
@ -379,8 +370,6 @@ nicvf_setup_ifnet(struct nicvf *nic)
if (nic->hw_tso)
if_sethwassistbits(ifp, (CSUM_TSO), 0);
if_setcapenable(ifp, if_getcapabilities(ifp));
return (0);
}
static int

View File

@ -454,10 +454,6 @@ thunder_mdio_phy_connect(device_t dev, int lmacid, int phy)
if (pd == NULL)
return (ENOMEM);
pd->ifp = if_alloc(IFT_ETHER);
if (pd->ifp == NULL) {
free(pd, M_THUNDER_MDIO);
return (ENOMEM);
}
pd->lmacid = lmacid;
}

View File

@ -656,11 +656,6 @@ vr_attach(device_t dev)
/* Allocate ifnet structure. */
ifp = sc->vr_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "couldn't allocate ifnet structure\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -436,12 +436,6 @@ vte_attach(device_t dev)
vte_get_macaddr(sc);
ifp = sc->vte_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "cannot allocate ifnet structure.\n");
error = ENXIO;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -991,11 +991,6 @@ xae_attach(device_t dev)
/* Set up the ethernet interface. */
sc->ifp = ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "could not allocate ifp.\n");
return (ENXIO);
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);

View File

@ -1188,11 +1188,6 @@ xl_attach(device_t dev)
/* Initialize interface name. */
ifp = sc->xl_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_setsoftc(ifp, sc);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));

View File

@ -754,10 +754,6 @@ bridge_clone_create(struct if_clone *ifc, char *name, size_t len,
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
free(sc, M_DEVBUF);
return (ENOSPC);
}
BRIDGE_LOCK_INIT(sc);
sc->sc_brtmax = BRIDGE_RTABLE_MAX;

View File

@ -87,11 +87,6 @@ disc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
if (ifp == NULL) {
free(sc, M_DISC);
return (ENOSPC);
}
ifp->if_softc = sc;
if_initname(ifp, discname, unit);
ifp->if_mtu = DSMTU;

View File

@ -104,11 +104,6 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
*/
sc = malloc(sizeof(struct edsc_softc), M_EDSC, M_WAITOK | M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
free(sc, M_EDSC);
return (ENOSPC);
}
ifp->if_softc = sc;
/*

View File

@ -163,10 +163,6 @@ enc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
sc = malloc(sizeof(struct enc_softc), M_DEVBUF,
M_WAITOK | M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_ENC);
if (ifp == NULL) {
free(sc, M_DEVBUF);
return (ENOSPC);
}
if (V_enc_sc != NULL) {
if_free(ifp);
free(sc, M_DEVBUF);

View File

@ -516,9 +516,6 @@ epair_alloc_sc(struct if_clone *ifc)
struct epair_softc *sc;
struct ifnet *ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (NULL);
sc = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO);
sc->ifp = ifp;
sc->num_queues = epair_tasks.tasks;
@ -614,8 +611,6 @@ epair_generate_mac(struct epair_softc *sc, uint8_t *eaddr)
static void
epair_free_sc(struct epair_softc *sc)
{
if (sc == NULL)
return;
if_free(sc->ifp);
ifmedia_removeall(&sc->media);
@ -714,12 +709,6 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len,
/* Allocate memory for both [ab] interfaces */
sca = epair_alloc_sc(ifc);
scb = epair_alloc_sc(ifc);
if (sca == NULL || scb == NULL) {
epair_free_sc(sca);
epair_free_sc(scb);
ifc_free_unit(ifc, unit);
return (ENOSPC);
}
/*
* Cross-reference the interfaces so we will be able to free both.

View File

@ -533,10 +533,6 @@ lagg_clone_create(struct if_clone *ifc, char *name, size_t len,
sc = malloc(sizeof(*sc), M_LAGG, M_WAITOK | M_ZERO);
ifp = sc->sc_ifp = if_alloc(if_type);
if (ifp == NULL) {
free(sc, M_LAGG);
return (ENOSPC);
}
LAGG_SX_INIT(sc);
mtx_init(&sc->sc_mtx, "lagg-mtx", NULL, MTX_DEF);

View File

@ -125,9 +125,6 @@ lo_clone_create(struct if_clone *ifc, char *name, size_t len,
struct ifnet *ifp;
ifp = if_alloc(IFT_LOOP);
if (ifp == NULL)
return (ENOSPC);
if_initname(ifp, loname, ifd->unit);
ifp->if_mtu = LOMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;

View File

@ -264,11 +264,6 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len,
sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
ifp = STF2IFP(sc) = if_alloc(IFT_STF);
if (ifp == NULL) {
free(sc, M_STF);
ifc_free_unit(ifc, unit);
return (ENOSPC);
}
ifp->if_softc = sc;
sc->sc_fibnum = curthread->td_proc->p_fibnum;

View File

@ -971,9 +971,6 @@ tuncreate(struct cdev *dev)
iflags |= IFF_POINTOPOINT;
}
ifp = tp->tun_ifp = if_alloc(type);
if (ifp == NULL)
panic("%s%d: failed to if_alloc() interface.\n",
drv->cdevsw.d_name, dev2unit(dev));
ifp->if_softc = tp;
if_initname(ifp, drv->cdevsw.d_name, dev2unit(dev));
ifp->if_ioctl = tunifioctl;

View File

@ -1163,14 +1163,6 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len,
ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO);
ifp = ifv->ifv_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
if (!subinterface)
ifc_free_unit(ifc, unit);
free(ifv, M_VLAN);
if (p != NULL)
if_rele(p);
return (ENOSPC);
}
CK_SLIST_INIT(&ifv->vlan_mc_listhead);
ifp->if_softc = ifv;
/*

Some files were not shown because too many files have changed in this diff Show More