ixgbe_buf.c revision ffd8e8832e01f996f32459073f4dd308fe5265ba
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * CDDL HEADER START
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * The contents of this file are subject to the terms of the
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Common Development and Distribution License (the "License").
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * You may not use this file except in compliance with the License.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * You can obtain a copy of the license at:
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * http://www.opensolaris.org/os/licensing.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * See the License for the specific language governing permissions
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * and limitations under the License.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * When using or redistributing this file, you may do so under the
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * License only. No other modification of this header is permitted.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * If applicable, add the following below this CDDL HEADER, with the
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * fields enclosed by brackets "[]" replaced with your own identifying
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * information: Portions Copyright [yyyy] [name of copyright owner]
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * CDDL HEADER END
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Use is subject to license terms.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#include "ixgbe_sw.h"
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_tbd_ring(ixgbe_tx_ring_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_tbd_ring(ixgbe_tx_ring_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_rbd_ring(ixgbe_rx_data_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_rbd_ring(ixgbe_rx_data_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_dma_buffer(ixgbe_t *, dma_buffer_t *, size_t);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_tcb_lists(ixgbe_tx_ring_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_tcb_lists(ixgbe_tx_ring_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_rcb_lists(ixgbe_rx_data_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_rcb_lists(ixgbe_rx_data_t *);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#ifdef __sparc
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#define IXGBE_DMA_ALIGNMENT 0x0000000000002000ull
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#else
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#define IXGBE_DMA_ALIGNMENT 0x0000000000001000ull
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China#endif
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * DMA attributes for tx/rx descriptors.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic ddi_dma_attr_t ixgbe_desc_dma_attr = {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DMA_ATTR_V0, /* version number */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x0000000000000000ull, /* low address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* high address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* dma counter max */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China IXGBE_DMA_ALIGNMENT, /* alignment */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000FFF, /* burst sizes */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* minimum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* maximum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 1, /* scatter/gather list length */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* granularity */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_FLAGERR /* DMA flags */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China};
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * DMA attributes for tx/rx buffers.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic ddi_dma_attr_t ixgbe_buf_dma_attr = {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DMA_ATTR_V0, /* version number */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x0000000000000000ull, /* low address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* high address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* dma counter max */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China IXGBE_DMA_ALIGNMENT, /* alignment */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000FFF, /* burst sizes */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* minimum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* maximum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 1, /* scatter/gather list length */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* granularity */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_FLAGERR /* DMA flags */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China};
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * DMA attributes for transmit.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic ddi_dma_attr_t ixgbe_tx_dma_attr = {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DMA_ATTR_V0, /* version number */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x0000000000000000ull, /* low address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* high address */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* dma counter max */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 1, /* alignment */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000FFF, /* burst sizes */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* minimum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000000FFFFFFFFull, /* maximum transfer size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China MAX_COOKIE, /* scatter/gather list length */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0x00000001, /* granularity */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_FLAGERR /* DMA flags */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China};
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * DMA access attributes for descriptors.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic ddi_device_acc_attr_t ixgbe_desc_acc_attr = {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DEVICE_ATTR_V0,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_STRUCTURE_LE_ACC,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_STRICTORDER_ACC
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China};
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * DMA access attributes for buffers.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic ddi_device_acc_attr_t ixgbe_buf_acc_attr = {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DEVICE_ATTR_V0,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_NEVERSWAP_ACC,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_STRICTORDER_ACC
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China};
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_dma - Allocate DMA resources for all rx/tx rings.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaint
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_dma(ixgbe_t *ixgbe)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_tx_ring_t *tx_ring;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int i;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_rx_rings; i++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate receive desciptor ring and control block lists
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_ring = &ixgbe->rx_rings[i];
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rbd_ring(rx_data) != IXGBE_SUCCESS)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_dma_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rcb_lists(rx_data) != IXGBE_SUCCESS)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_dma_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_tx_rings; i++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate transmit desciptor ring and control block lists
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring = &ixgbe->tx_rings[i];
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ixgbe_alloc_tbd_ring(tx_ring) != IXGBE_SUCCESS)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_dma_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ixgbe_alloc_tcb_lists(tx_ring) != IXGBE_SUCCESS)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_dma_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaalloc_dma_failure:
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_dma(ixgbe);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_free_dma - Free all the DMA resources of all rx/tx rings.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinavoid
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_dma(ixgbe_t *ixgbe)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_tx_ring_t *tx_ring;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int i;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Free DMA resources of rx rings
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_rx_rings; i++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_ring = &ixgbe->rx_rings[i];
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_rbd_ring(rx_data);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_rcb_lists(rx_data);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Free DMA resources of tx rings
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_tx_rings; i++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring = &ixgbe->tx_rings[i];
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_tbd_ring(tx_ring);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_tcb_lists(tx_ring);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaint
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rx_ring_data(ixgbe_rx_ring_t *rx_ring)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_ring->ixgbe;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint32_t rcb_count;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for software receive rings
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data = kmem_zalloc(sizeof (ixgbe_rx_data_t), KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Allocate software receive rings failed");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rx_ring = rx_ring;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China mutex_init(&rx_data->recycle_lock, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->ring_size = ixgbe->rx_ring_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->free_list_size = ixgbe->rx_ring_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rcb_head = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rcb_tail = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rcb_free = rx_data->free_list_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the work list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->work_list = kmem_zalloc(sizeof (rx_control_block_t *) *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->ring_size, KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->work_list == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate memory for rx work list");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->free_list = kmem_zalloc(sizeof (rx_control_block_t *) *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->free_list_size, KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->free_list == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx free list");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the rx control blocks for work list and
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rcb_area =
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_zalloc(sizeof (rx_control_block_t) * rcb_count,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rcb_area == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx control blocks");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_ring->rx_data = rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaalloc_rx_data_failure:
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_rx_ring_data(rx_data);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinavoid
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_rx_ring_data(ixgbe_rx_data_t *rx_data)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint32_t rcb_count;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data == NULL)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(rx_data->rcb_pending == 0);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rcb_area != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(rx_data->rcb_area,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t) * rcb_count);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rcb_area = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->work_list != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(rx_data->work_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->ring_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->work_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->free_list != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(rx_data->free_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->free_list_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->free_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China mutex_destroy(&rx_data->recycle_lock);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(rx_data, sizeof (ixgbe_rx_data_t));
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_tbd_ring - Memory allocation for the tx descriptors of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_tbd_ring(ixgbe_tx_ring_t *tx_ring)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int ret;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size_t size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size_t len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint_t cookie_num;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dev_info_t *devinfo;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_cookie_t cookie;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = tx_ring->ixgbe;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China devinfo = ixgbe->dip;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size = sizeof (union ixgbe_adv_tx_desc) * tx_ring->ring_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * If tx head write-back is enabled, an extra tbd is allocated
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * to save the head write-back value
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ixgbe->tx_head_wb_enable) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size += sizeof (union ixgbe_adv_tx_desc);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate a DMA handle for the transmit descriptor
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * memory area.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_alloc_handle(devinfo, &ixgbe_desc_dma_attr,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &tx_ring->tbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate tbd dma handle: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory to DMA data to and from the transmit
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * descriptors.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_mem_alloc(tx_ring->tbd_area.dma_handle,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size, &ixgbe_desc_acc_attr, DDI_DMA_CONSISTENT,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China (caddr_t *)&tx_ring->tbd_area.address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &len, &tx_ring->tbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate tbd dma memory: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Initialize the entire transmit buffer descriptor area to zero
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China bzero(tx_ring->tbd_area.address, len);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocates DMA resources for the memory that was allocated by
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * the ddi_dma_mem_alloc call. The DMA resources then get bound to the
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * the memory address
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_addr_bind_handle(tx_ring->tbd_area.dma_handle,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China NULL, (caddr_t)tx_ring->tbd_area.address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China len, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_DMA_MAPPED) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not bind tbd dma resource: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&tx_ring->tbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(cookie_num == 1);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_address = cookie.dmac_laddress;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.size = len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_ring = (union ixgbe_adv_tx_desc *)(uintptr_t)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.address;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_free_tbd_ring - Free the tx descriptors of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_tbd_ring(ixgbe_tx_ring_t *tx_ring)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China (void) ddi_dma_unbind_handle(tx_ring->tbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&tx_ring->tbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_area.size = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tbd_ring = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_rbd_ring - Memory allocation for the rx descriptors of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rbd_ring(ixgbe_rx_data_t *rx_data)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int ret;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size_t size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size_t len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint_t cookie_num;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dev_info_t *devinfo;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_cookie_t cookie;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_data->rx_ring->ixgbe;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China devinfo = ixgbe->dip;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size = sizeof (union ixgbe_adv_rx_desc) * rx_data->ring_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate a new DMA handle for the receive descriptor
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * memory area.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_alloc_handle(devinfo, &ixgbe_desc_dma_attr,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &rx_data->rbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate rbd dma handle: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory to DMA data to and from the receive
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * descriptors.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_mem_alloc(rx_data->rbd_area.dma_handle,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size, &ixgbe_desc_acc_attr, DDI_DMA_CONSISTENT,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China (caddr_t *)&rx_data->rbd_area.address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &len, &rx_data->rbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate rbd dma memory: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Initialize the entire transmit buffer descriptor area to zero
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China bzero(rx_data->rbd_area.address, len);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocates DMA resources for the memory that was allocated by
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * the ddi_dma_mem_alloc call.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_addr_bind_handle(rx_data->rbd_area.dma_handle,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China NULL, (caddr_t)rx_data->rbd_area.address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China len, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_DMA_MAPPED) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not bind rbd dma resource: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(cookie_num == 1);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = cookie.dmac_laddress;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_ring = (union ixgbe_adv_rx_desc *)(uintptr_t)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.address;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_free_rbd_ring - Free the rx descriptors of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_rbd_ring(ixgbe_rx_data_t *rx_data)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China (void) ddi_dma_unbind_handle(rx_data->rbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->rbd_ring = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_dma_buffer - Allocate DMA resources for a DMA buffer.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_dma_buffer(ixgbe_t *ixgbe, dma_buffer_t *buf, size_t size)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int ret;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dev_info_t *devinfo = ixgbe->dip;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_cookie_t cookie;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size_t len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint_t cookie_num;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_alloc_handle(devinfo,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &ixgbe_buf_dma_attr, DDI_DMA_DONTWAIT,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China NULL, &buf->dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate dma buffer handle: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_mem_alloc(buf->dma_handle,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China size, &ixgbe_buf_acc_attr, DDI_DMA_STREAMING,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL, &buf->address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &len, &buf->acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&buf->dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate dma buffer memory: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_addr_bind_handle(buf->dma_handle, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China len, DDI_DMA_RDWR | DDI_DMA_STREAMING,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_DMA_MAPPED) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&buf->acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&buf->dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not bind dma buffer handle: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(cookie_num == 1);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_address = cookie.dmac_laddress;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->size = len;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->len = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_free_dma_buffer - Free one allocated area of dma memory and handle.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinavoid
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_dma_buffer(dma_buffer_t *buf)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China (void) ddi_dma_unbind_handle(buf->dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China } else {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->acc_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&buf->acc_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->acc_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->address = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (buf->dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&buf->dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->size = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China buf->len = 0;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_tcb_lists - Memory allocation for the transmit control bolcks
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_tcb_lists(ixgbe_tx_ring_t *tx_ring)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int i;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int ret;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_control_block_t *tcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dma_buffer_t *tx_buf;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = tx_ring->ixgbe;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dev_info_t *devinfo = ixgbe->dip;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the work list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->work_list = kmem_zalloc(sizeof (tx_control_block_t *) *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->ring_size, KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->work_list == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Cound not allocate memory for tx work list");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list = kmem_zalloc(sizeof (tx_control_block_t *) *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list_size, KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->free_list == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->work_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t *) * tx_ring->ring_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->work_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Cound not allocate memory for tx free list");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the tx control blocks of free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tcb_area =
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_zalloc(sizeof (tx_control_block_t) *
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list_size, KM_NOSLEEP);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tcb_area == NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->work_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t *) * tx_ring->ring_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->work_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->free_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t *) * tx_ring->free_list_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Cound not allocate memory for tx control blocks");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate dma memory for the tx control block of free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb = tx_ring->tcb_area;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < tx_ring->free_list_size; i++, tcb++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(tcb != NULL);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list[i] = tcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Pre-allocate dma handles for transmit. These dma handles
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * will be dynamically bound to the data buffers passed down
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * from the upper layers at the time of transmitting.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ddi_dma_alloc_handle(devinfo,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &ixgbe_tx_dma_attr,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China DDI_DMA_DONTWAIT, NULL,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China &tcb->tx_dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != DDI_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb->tx_dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China "Could not allocate tx dma handle: %x", ret);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_tcb_lists_fail;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Pre-allocate transmit buffers for packets that the
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * size is less than bcopy_thresh.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_buf = &tcb->tx_buf;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ixgbe_alloc_dma_buffer(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_buf, ixgbe->tx_buf_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != IXGBE_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(tcb->tx_dma_handle != NULL);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&tcb->tx_dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb->tx_dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Allocate tx dma buffer failed");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_tcb_lists_fail;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb->last_index = MAX_TX_RING_SIZE;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaalloc_tcb_lists_fail:
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_tcb_lists(tx_ring);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_free_tcb_lists - Release the memory allocated for
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * the transmit control bolcks of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic void
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_free_tcb_lists(ixgbe_tx_ring_t *tx_ring)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int i;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_control_block_t *tcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb = tx_ring->tcb_area;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tcb == NULL)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China return;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < tx_ring->free_list_size; i++, tcb++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(tcb != NULL);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /* Free the tx dma handle for dynamical binding */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tcb->tx_dma_handle != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&tcb->tx_dma_handle);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tcb->tx_dma_handle = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China } else {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * If the dma handle is NULL, then we don't
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * have to check the remaining.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China break;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_free_dma_buffer(&tcb->tx_buf);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->tcb_area != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->tcb_area,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t) * tx_ring->free_list_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->tcb_area = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->work_list != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->work_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t *) * tx_ring->ring_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->work_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (tx_ring->free_list != NULL) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China kmem_free(tx_ring->free_list,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China sizeof (tx_control_block_t *) * tx_ring->free_list_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China tx_ring->free_list = NULL;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China}
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China/*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * ixgbe_alloc_rcb_lists - Memory allocation for the receive control blocks
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * of one ring.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinastatic int
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rcb_lists(ixgbe_rx_data_t *rx_data)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China{
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int i;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China int ret;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_control_block_t *rcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = rx_data->rx_ring->ixgbe;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China dma_buffer_t *rx_buf;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China uint32_t rcb_count;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /*
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * Allocate memory for the rx control blocks for work list and
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China * free list.
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb = rx_data->rcb_area;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China for (i = 0; i < rcb_count; i++, rcb++) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ASSERT(rcb != NULL);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (i < rx_data->ring_size) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /* Attach the rx control block to the work list */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->work_list[i] = rcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China } else {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China /* Attach the rx control block to the free list */
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_data->free_list[i - rx_data->ring_size] = rcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf = &rcb->rx_buf;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ret = ixgbe_alloc_dma_buffer(ixgbe,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf, ixgbe->rx_buf_size);
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China if (ret != IXGBE_SUCCESS) {
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Allocate rx dma buffer failed");
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China goto alloc_rcb_lists_fail;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China }
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf->size -= IPHDR_ALIGN_ROOM;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf->address += IPHDR_ALIGN_ROOM;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf->dma_address += IPHDR_ALIGN_ROOM;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->ref_cnt = 1;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->rx_data = (ixgbe_rx_data_t *)rx_data;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->free_rtn.free_func = ixgbe_rx_recycle;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->free_rtn.free_arg = (char *)rcb;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->lro_prev = -1;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->lro_next = -1;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->lro_pkt = B_FALSE;
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rcb->mp = desballoc((unsigned char *)
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf->address,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China rx_buf->size,
e8da18d8c173d57b68019b8d92471843c44ec746pengcheng chen - Sun Microsystems - Beijing China 0, &rcb->free_rtn);
}
return (IXGBE_SUCCESS);
alloc_rcb_lists_fail:
ixgbe_free_rcb_lists(rx_data);
return (IXGBE_FAILURE);
}
/*
* ixgbe_free_rcb_lists - Free the receive control blocks of one ring.
*/
static void
ixgbe_free_rcb_lists(ixgbe_rx_data_t *rx_data)
{
ixgbe_t *ixgbe;
rx_control_block_t *rcb;
uint32_t rcb_count;
uint32_t ref_cnt;
int i;
ixgbe = rx_data->rx_ring->ixgbe;
mutex_enter(&ixgbe->rx_pending_lock);
rcb = rx_data->rcb_area;
rcb_count = rx_data->ring_size + rx_data->free_list_size;
for (i = 0; i < rcb_count; i++, rcb++) {
ASSERT(rcb != NULL);
ref_cnt = atomic_dec_32_nv(&rcb->ref_cnt);
if (ref_cnt == 0) {
if (rcb->mp != NULL) {
freemsg(rcb->mp);
rcb->mp = NULL;
}
ixgbe_free_dma_buffer(&rcb->rx_buf);
} else {
atomic_inc_32(&rx_data->rcb_pending);
atomic_inc_32(&ixgbe->rcb_pending);
}
}
mutex_exit(&ixgbe->rx_pending_lock);
}
/*
* ixgbe_set_fma_flags - Set the attribute for fma support.
*/
void
ixgbe_set_fma_flags(int dma_flag)
{
if (dma_flag) {
ixgbe_tx_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
ixgbe_buf_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
ixgbe_desc_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
} else {
ixgbe_tx_dma_attr.dma_attr_flags = 0;
ixgbe_buf_dma_attr.dma_attr_flags = 0;
ixgbe_desc_dma_attr.dma_attr_flags = 0;
}
}