sfxge_dma.c revision 49ef7e0638c8b771d8a136eae78b1c0f99acc8e0
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Copyright (c) 2008-2016 Solarflare Communications Inc.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * All rights reserved.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Redistribution and use in source and binary forms, with or without
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * modification, are permitted provided that the following conditions are met:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 1. Redistributions of source code must retain the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer in the documentation
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * and/or other materials provided with the distribution.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * The views and conclusions contained in the software and documentation are
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * those of the authors and should not be interpreted as representing official
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * policies, either expressed or implied, of the FreeBSD Project.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoresfxge_dma_buffer_unbind_handle(efsys_mem_t *esmp)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore rc = ddi_dma_unbind_handle(esmp->esm_dma_handle);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoresfxge_dma_buffer_handle_free(ddi_dma_handle_t *dhandlep)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoresfxge_dma_buffer_create(efsys_mem_t *esmp, const sfxge_dma_buffer_attr_t *sdbap)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Allocate a DMA handle */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore err = ddi_dma_alloc_handle(sdbap->sdba_dip, sdbap->sdba_dattrp,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore sdbap->sdba_callback, NULL, &(esmp->esm_dma_handle));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Allocate some DMA memory */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore err = ddi_dma_mem_alloc(esmp->esm_dma_handle, sdbap->sdba_length,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore &(esmp->esm_base), &unit, &(esmp->esm_acc_handle));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Bind the DMA memory to the DMA handle */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* We aren't handling partial mappings */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore ASSERT3U(sdbap->sdba_bindflags & DDI_DMA_PARTIAL, !=, DDI_DMA_PARTIAL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore err = ddi_dma_addr_bind_handle(esmp->esm_dma_handle, NULL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore esmp->esm_base, sdbap->sdba_length, sdbap->sdba_bindflags,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore sdbap->sdba_callback, NULL, &dmac, &ncookies);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore ASSERT3U(ncookies, <=, sdbap->sdba_maxcookies);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore DTRACE_PROBE1(addr, efsys_dma_addr_t, esmp->esm_addr);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore sfxge_dma_buffer_handle_free(&(esmp->esm_dma_handle));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore cmn_err(CE_WARN, SFXGE_CMN_ERR "DMA Unbind failed rc=%d", rc);