FreeBSD/sys/dev/vxge/vxge.c
/*
 * vxge_rx_rxd_1b_set
 * Allocates new mbufs to be placed into descriptors
 */
vxge_rx_rxd_1b_set
Allocates new mbufs to be placed into descriptors
vxge_rx_rxd_1b_set Allocates new mbufs to be placed into descriptors
int
vxge_rx_rxd_1b_set(vxge_vpath_t *vpath, vxge_hal_rxd_h rxdh, void *dtr_priv)
{
	int num_segs, err = 0;
	mbuf_t mbuf_pkt;
	bus_dmamap_t dma_map;
	bus_dma_segment_t dma_buffers[1];
	vxge_rxd_priv_t *rxd_priv = (vxge_rxd_priv_t *) dtr_priv;
	vxge_dev_t *vdev = vpath->vdev;
	mbuf_pkt = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, vdev->rx_mbuf_sz);
	if (!mbuf_pkt) {
		err = ENOBUFS;
		VXGE_DRV_STATS(vpath, rx_no_buf);
		device_printf(vdev->ndev, "out of memory to allocate mbuf\n");
		goto _exit0;
	}
	mbuf_pkt->m_len = vdev->rx_mbuf_sz;
	mbuf_pkt->m_pkthdr.len = vdev->rx_mbuf_sz;
	mbuf_pkt->m_pkthdr.rcvif = vdev->ifp;
	err = vxge_dma_mbuf_coalesce(vpath->dma_tag_rx, vpath->extra_dma_map,
	    &mbuf_pkt, dma_buffers, &num_segs);
	if (err != 0) {
		VXGE_DRV_STATS(vpath, rx_map_fail);
		vxge_free_packet(mbuf_pkt);
		goto _exit0;
	}
	bus_dmamap_sync(vpath->dma_tag_rx, rxd_priv->dma_map,
	    BUS_DMASYNC_POSTREAD);
	bus_dmamap_unload(vpath->dma_tag_rx, rxd_priv->dma_map);
	dma_map = rxd_priv->dma_map;
	rxd_priv->mbuf_pkt = mbuf_pkt;
	rxd_priv->dma_addr[0] = htole64(dma_buffers->ds_addr);
	rxd_priv->dma_map = vpath->extra_dma_map;
	vpath->extra_dma_map = dma_map;
	bus_dmamap_sync(vpath->dma_tag_rx, rxd_priv->dma_map,
	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
	vxge_hal_ring_rxd_1b_set(rxdh, rxd_priv->dma_addr[0], vdev->rx_mbuf_sz);
_exit0:
	return (err);
}
int vxge_rx_rxd_1b_set ( vxge_vpath_t * vpath , vxge_hal_rxd_h rxdh , void * dtr_priv ) { int num_segs , err = 0 ; mbuf_t mbuf_pkt ; bus_dmamap_t dma_map ; bus_dma_segment_t dma_buffers [ 1 ] ; vxge_rxd_priv_t * rxd_priv = ( vxge_rxd_priv_t * ) dtr_priv ; vxge_dev_t * vdev = vpath -> vdev ; mbuf_pkt = m_getjcl ( M_NOWAIT , MT_DATA , M_PKTHDR , vdev -> rx_mbuf_sz ) ; if ( ! mbuf_pkt ) { err = ENOBUFS ; VXGE_DRV_STATS ( vpath , rx_no_buf ) ; device_printf ( vdev -> ndev , " \n " ) ; goto _exit0 ; } mbuf_pkt -> m_len = vdev -> rx_mbuf_sz ; mbuf_pkt -> m_pkthdr . len = vdev -> rx_mbuf_sz ; mbuf_pkt -> m_pkthdr . rcvif = vdev -> ifp ; err = vxge_dma_mbuf_coalesce ( vpath -> dma_tag_rx , vpath -> extra_dma_map , & mbuf_pkt , dma_buffers , & num_segs ) ; if ( err != 0 ) { VXGE_DRV_STATS ( vpath , rx_map_fail ) ; vxge_free_packet ( mbuf_pkt ) ; goto _exit0 ; } bus_dmamap_sync ( vpath -> dma_tag_rx , rxd_priv -> dma_map , BUS_DMASYNC_POSTREAD ) ; bus_dmamap_unload ( vpath -> dma_tag_rx , rxd_priv -> dma_map ) ; dma_map = rxd_priv -> dma_map ; rxd_priv -> mbuf_pkt = mbuf_pkt ; rxd_priv -> dma_addr [ 0 ] = htole64 ( dma_buffers -> ds_addr ) ; rxd_priv -> dma_map = vpath -> extra_dma_map ; vpath -> extra_dma_map = dma_map ; bus_dmamap_sync ( vpath -> dma_tag_rx , rxd_priv -> dma_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; vxge_hal_ring_rxd_1b_set ( rxdh , rxd_priv -> dma_addr [ 0 ] , vdev -> rx_mbuf_sz ) ; _exit0 : return ( err ) ; }
vxge_rx_rxd_1b_set
 Allocates new mbufs to be placed into descriptors
vxge_rx_rxd_1b_set Allocates new mbufs to be placed into descriptors
/* Update mbuf's length, packet length and receive interface */ /* Load DMA map */ /* Unload DMA map of mbuf in current descriptor */ /* Update descriptor private data */ /* Pre-Read/Write sync */ /* Set descriptor buffer */