9da57d7b0ddd8d73b676ce12c040362132cdd538bt * CDDL HEADER START
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The contents of this file are subject to the terms of the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Common Development and Distribution License (the "License").
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * You may not use this file except in compliance with the License.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * You can obtain a copy of the license at:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * See the License for the specific language governing permissions
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and limitations under the License.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * When using or redistributing this file, you may do so under the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * License only. No other modification of this header is permitted.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If applicable, add the following below this CDDL HEADER, with the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * fields enclosed by brackets "[]" replaced with your own identifying
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * information: Portions Copyright [yyyy] [name of copyright owner]
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * CDDL HEADER END
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Use is subject to license terms.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_rbd_ring(ixgbe_rx_data_t *);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_rbd_ring(ixgbe_rx_data_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_alloc_dma_buffer(ixgbe_t *, dma_buffer_t *, size_t);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_rcb_lists(ixgbe_rx_data_t *);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_rcb_lists(ixgbe_rx_data_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * DMA attributes for tx/rx descriptors.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * DMA attributes for tx/rx buffers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * DMA attributes for transmit.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * DMA access attributes for descriptors.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * DMA access attributes for buffers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_dma - Allocate DMA resources for all rx/tx rings.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate receive desciptor ring and control block lists
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rbd_ring(rx_data) != IXGBE_SUCCESS)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rcb_lists(rx_data) != IXGBE_SUCCESS)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate transmit desciptor ring and control block lists
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_dma - Free all the DMA resources of all rx/tx rings.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free DMA resources of rx rings
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rbd_ring(rx_data);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rcb_lists(rx_data);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free DMA resources of tx rings
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rx_ring_data(ixgbe_rx_ring_t *rx_ring)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_ring->ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China uint32_t rcb_count;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Allocate memory for software receive rings
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data = kmem_zalloc(sizeof (ixgbe_rx_data_t), KM_NOSLEEP);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data == NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Allocate software receive rings failed");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rx_ring = rx_ring;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_init(&rx_data->recycle_lock, NULL,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->ring_size = ixgbe->rx_ring_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->free_list_size = ixgbe->rx_ring_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rcb_head = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rcb_tail = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rcb_free = rx_data->free_list_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Allocate memory for the work list.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->work_list = kmem_zalloc(sizeof (rx_control_block_t *) *
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->ring_size, KM_NOSLEEP);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->work_list == NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China "Could not allocate memory for rx work list");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Allocate memory for the free list.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->free_list = kmem_zalloc(sizeof (rx_control_block_t *) *
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->free_list_size, KM_NOSLEEP);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->free_list == NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx free list");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Allocate memory for the rx control blocks for work list and
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rcb_area =
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China kmem_zalloc(sizeof (rx_control_block_t) * rcb_count,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_area == NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx control blocks");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_ring->rx_data = rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaalloc_rx_data_failure:
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rx_ring_data(rx_data);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_free_rx_ring_data(ixgbe_rx_data_t *rx_data)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China uint32_t rcb_count;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data == NULL)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ASSERT(rx_data->rcb_pending == 0);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_area != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->rcb_area,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t) * rcb_count);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rcb_area = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->work_list != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->work_list,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->ring_size);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->work_list = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->free_list != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->free_list,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->free_list_size);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->free_list = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_destroy(&rx_data->recycle_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data, sizeof (ixgbe_rx_data_t));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_tbd_ring - Memory allocation for the tx descriptors of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = sizeof (union ixgbe_adv_tx_desc) * tx_ring->ring_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If tx head write-back is enabled, an extra tbd is allocated
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * to save the head write-back value
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate a DMA handle for the transmit descriptor
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * memory area.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ret = ddi_dma_alloc_handle(devinfo, &ixgbe_desc_dma_attr,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory to DMA data to and from the transmit
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * descriptors.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the entire transmit buffer descriptor area to zero
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocates DMA resources for the memory that was allocated by
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the ddi_dma_mem_alloc call. The DMA resources then get bound to the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the memory address
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ret = ddi_dma_addr_bind_handle(tx_ring->tbd_area.dma_handle,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_ring = (union ixgbe_adv_tx_desc *)(uintptr_t)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_tbd_ring - Free the tx descriptors of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ddi_dma_unbind_handle(tx_ring->tbd_area.dma_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_rbd_ring - Memory allocation for the rx descriptors of one ring.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rbd_ring(ixgbe_rx_data_t *rx_data)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_data->rx_ring->ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China size = sizeof (union ixgbe_adv_rx_desc) * rx_data->ring_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate a new DMA handle for the receive descriptor
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * memory area.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ret = ddi_dma_alloc_handle(devinfo, &ixgbe_desc_dma_attr,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China &rx_data->rbd_area.dma_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory to DMA data to and from the receive
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * descriptors.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ret = ddi_dma_mem_alloc(rx_data->rbd_area.dma_handle,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (caddr_t *)&rx_data->rbd_area.address,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China &len, &rx_data->rbd_area.acc_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the entire transmit buffer descriptor area to zero
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China bzero(rx_data->rbd_area.address, len);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocates DMA resources for the memory that was allocated by
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the ddi_dma_mem_alloc call.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ret = ddi_dma_addr_bind_handle(rx_data->rbd_area.dma_handle,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China NULL, (caddr_t)rx_data->rbd_area.address,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = cookie.dmac_laddress;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = len;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_ring = (union ixgbe_adv_rx_desc *)(uintptr_t)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_rbd_ring - Free the rx descriptors of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_free_rbd_ring(ixgbe_rx_data_t *rx_data)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (void) ddi_dma_unbind_handle(rx_data->rbd_area.dma_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_ring = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_dma_buffer - Allocate DMA resources for a DMA buffer.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_alloc_dma_buffer(ixgbe_t *ixgbe, dma_buffer_t *buf, size_t size)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_dma_buffer - Free one allocated area of dma memory and handle.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_tcb_lists - Memory allocation for the transmit control bolcks
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory for the work list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->work_list = kmem_zalloc(sizeof (tx_control_block_t *) *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Cound not allocate memory for tx work list");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory for the free list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->free_list = kmem_zalloc(sizeof (tx_control_block_t *) *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Cound not allocate memory for tx free list");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory for the tx control blocks of free list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (tx_control_block_t *) * tx_ring->free_list_size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Cound not allocate memory for tx control blocks");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate dma memory for the tx control block of free list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Pre-allocate dma handles for transmit. These dma handles
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * will be dynamically bound to the data buffers passed down
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * from the upper layers at the time of transmitting.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Pre-allocate transmit buffers for packets that the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * size is less than bcopy_thresh.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_tcb_lists - Release the memory allocated for
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the transmit control bolcks of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Free the tx dma handle for dynamical binding */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If the dma handle is NULL, then we don't
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * have to check the remaining.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (tx_control_block_t *) * tx_ring->free_list_size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_rcb_lists - Memory allocation for the receive control blocks
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of one ring.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rcb_lists(ixgbe_rx_data_t *rx_data)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_data->rx_ring->ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory for the rx control blocks for work list and
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * free list.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb = rx_data->rcb_area;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (i < rx_data->ring_size) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Attach the rx control block to the work list */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->work_list[i] = rcb;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Attach the rx control block to the free list */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->free_list[i - rx_data->ring_size] = rcb;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb->ref_cnt = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb->rx_data = (ixgbe_rx_data_t *)rx_data;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China rcb->lro_prev = -1;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China rcb->lro_next = -1;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China rcb->lro_pkt = B_FALSE;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rcb_lists(rx_data);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_rcb_lists - Free the receive control blocks of one ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_free_rcb_lists(ixgbe_rx_data_t *rx_data)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China uint32_t ref_cnt;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe = rx_data->rx_ring->ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_enter(&ixgbe->rx_pending_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb = rx_data->rcb_area;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ref_cnt = atomic_dec_32_nv(&rcb->ref_cnt);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ref_cnt == 0) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rcb->mp != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China freemsg(rcb->mp);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb->mp = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_dma_buffer(&rcb->rx_buf);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China atomic_inc_32(&rx_data->rcb_pending);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China atomic_inc_32(&ixgbe->rcb_pending);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->rx_pending_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_set_fma_flags - Set the attribute for fma support.