error = ENOBUFS; goto out;
return (ENOBUFS);
nge_alloc_jumbo_mem(sc)	struct nge_softc	*sc;{	caddr_t			ptr, kva;	bus_dma_segment_t	seg;	bus_dmamap_t		dmamap;	int			i, rseg, state, error;	struct nge_jpool_entry	*entry;	state = error = 0;	if (bus_dmamem_alloc(sc->sc_dmatag, NGE_JMEM, PAGE_SIZE, 0,			     &seg, 1, &rseg, BUS_DMA_NOWAIT)) {		printf("%s: can't alloc rx buffers\n", sc->sc_dv.dv_xname);		error = ENOBUFS;		goto out;	}	state = 1;	if (bus_dmamem_map(sc->sc_dmatag, &seg, rseg, NGE_JMEM, &kva,			   BUS_DMA_NOWAIT)) {		printf("%s: can't map dma buffers (%d bytes)\n",		       sc->sc_dv.dv_xname, NGE_JMEM);		error = ENOBUFS;		goto out;	}	state = 2;	if (bus_dmamap_create(sc->sc_dmatag, NGE_JMEM, 1,			      NGE_JMEM, 0, BUS_DMA_NOWAIT, &dmamap)) {		printf("%s: can't create dma map\n", sc->sc_dv.dv_xname);		error = ENOBUFS;		goto out;	}	state = 3;	if (bus_dmamap_load(sc->sc_dmatag, dmamap, kva, NGE_JMEM,			    NULL, BUS_DMA_NOWAIT)) {		printf("%s: can't load dma map\n", sc->sc_dv.dv_xname);		error = ENOBUFS;		goto out;        }	state = 4;	sc->nge_cdata.nge_jumbo_buf = (caddr_t)kva;	DPRINTFN(1,("%s: nge_jumbo_buf=%#x, NGE_MCLBYTES=%#x\n",		    sc->sc_dv.dv_xname , sc->nge_cdata.nge_jumbo_buf,		    NGE_MCLBYTES));	LIST_INIT(&sc->nge_jfree_listhead);	LIST_INIT(&sc->nge_jinuse_listhead);	/*	 * Now divide it up into 9K pieces and save the addresses	 * in an array. Note that we play an evil trick here by using	 * the first few bytes in the buffer to hold the address	 * of the softc structure for this interface. This is because	 * nge_jfree() needs it, but it is called by the mbuf management	 * code which will not pass it to us explicitly.	 */	ptr = sc->nge_cdata.nge_jumbo_buf;	for (i = 0; i < NGE_JSLOTS; i++) {		sc->nge_cdata.nge_jslots[i].nge_buf = ptr;		sc->nge_cdata.nge_jslots[i].nge_inuse = 0;		ptr += NGE_MCLBYTES;		entry = malloc(sizeof(struct nge_jpool_entry),			       M_DEVBUF, M_NOWAIT);		if (entry == NULL) {			sc->nge_cdata.nge_jumbo_buf = NULL;			printf("%s: no memory for jumbo buffer queue!\n",			       sc->sc_dv.dv_xname);			error = ENOBUFS;			goto out;		}		entry->slot = i;		LIST_INSERT_HEAD(&sc->nge_jfree_listhead, entry,				 jpool_entries);	}out:	if (error != 0) {		switch (state) {		case 4:			bus_dmamap_unload(sc->sc_dmatag, dmamap);		case 3:			bus_dmamap_destroy(sc->sc_dmatag, dmamap);		case 2:			bus_dmamem_unmap(sc->sc_dmatag, kva, NGE_JMEM);		case 1:			bus_dmamem_free(sc->sc_dmatag, &seg, rseg);			break;		default:			break;		}	} 	return (error);}