FreeBSD/sys/compat/ndis/subr_ndis.c
/*
 * NDIS has two methods for dealing with NICs that support DMA.
 * One is to just pass packets to the driver and let it call
 * NdisMStartBufferPhysicalMapping() to map each buffer in the packet
 * all by itself, and the other is to let the NDIS library handle the
 * buffer mapping internally, and hand the driver an already populated
 * scatter/gather fragment list. If the driver calls
 * NdisMInitializeScatterGatherDma(), it wants to use the latter
 * method.
 */
NDIS has two methods for dealing with NICs that support DMA.
One is to just pass packets to the driver and let it call
NdisMStartBufferPhysicalMapping() to map each buffer in the packet
all by itself, and the other is to let the NDIS library handle the
buffer mapping internally, and hand the driver an already populated
scatter/gather fragment list. If the driver calls
NdisMInitializeScatterGatherDma(), it wants to use the latter
method.
NDIS has two methods for dealing with NICs that support DMA . One is to just pass packets to the driver and let it call NdisMStartBufferPhysicalMapping () to map each buffer in the packet all by itself and the other is to let the NDIS library handle the buffer mapping internally and hand the driver an already populated scatter / gather fragment list . If the driver calls NdisMInitializeScatterGatherDma () it wants to use the latter method .
static ndis_status
NdisMInitializeScatterGatherDma(ndis_handle adapter, uint8_t is64,
    uint32_t maxphysmap)
{
	struct ndis_softc	*sc;
	ndis_miniport_block	*block;
	int			error;
	if (adapter == NULL)
		return (NDIS_STATUS_FAILURE);
	block = (ndis_miniport_block *)adapter;
	sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
	if (sc->ndis_sc == 1)
		return (NDIS_STATUS_SUCCESS);
	error = bus_dma_tag_create(sc->ndis_parent_tag, ETHER_ALIGN, 0,
	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
	    MCLBYTES * NDIS_MAXSEG, NDIS_MAXSEG, MCLBYTES, BUS_DMA_ALLOCNOW,
	    NULL, NULL, &sc->ndis_ttag);
	sc->ndis_sc = 1;
	return (NDIS_STATUS_SUCCESS);
}
static ndis_status NdisMInitializeScatterGatherDma ( ndis_handle adapter , uint8_t is64 , uint32_t maxphysmap ) { struct ndis_softc * sc ; ndis_miniport_block * block ; int error ; if ( adapter == NULL ) return ( NDIS_STATUS_FAILURE ) ; block = ( ndis_miniport_block * ) adapter ; sc = device_get_softc ( block -> nmb_physdeviceobj -> do_devext ) ; if ( sc -> ndis_sc == 1 ) return ( NDIS_STATUS_SUCCESS ) ; error = bus_dma_tag_create ( sc -> ndis_parent_tag , ETHER_ALIGN , 0 , BUS_SPACE_MAXADDR_32BIT , BUS_SPACE_MAXADDR , NULL , NULL , MCLBYTES * NDIS_MAXSEG , NDIS_MAXSEG , MCLBYTES , BUS_DMA_ALLOCNOW , NULL , NULL , & sc -> ndis_ttag ) ; sc -> ndis_sc = 1 ; return ( NDIS_STATUS_SUCCESS ) ; }
NDIS has two methods for dealing with NICs that support DMA.
NDIS has two methods for dealing with NICs that support DMA .
/* Don't do this twice. */