c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * CDDL HEADER START
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The contents of this file are subject to the terms of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common Development and Distribution License (the "License").
c869993e79c1eafbec61a56bf6cea848fe754c71xy * You may not use this file except in compliance with the License.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * or http://www.opensolaris.org/os/licensing.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * See the License for the specific language governing permissions
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and limitations under the License.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * When distributing Covered Code, include this CDDL HEADER in each
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If applicable, add the following below this CDDL HEADER, with the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * fields enclosed by brackets "[]" replaced with your own identifying
c869993e79c1eafbec61a56bf6cea848fe754c71xy * information: Portions Copyright [yyyy] [name of copyright owner]
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * CDDL HEADER END
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu */
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu/*
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#include "igb_sw.h"
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_alloc_tbd_ring(igb_tx_ring_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_free_tbd_ring(igb_tx_ring_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic int igb_alloc_rbd_ring(igb_rx_data_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void igb_free_rbd_ring(igb_rx_data_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_alloc_dma_buffer(igb_t *, dma_buffer_t *, size_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_alloc_tcb_lists(igb_tx_ring_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_free_tcb_lists(igb_tx_ring_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic int igb_alloc_rcb_lists(igb_rx_data_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void igb_free_rcb_lists(igb_rx_data_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#ifdef __sparc
c869993e79c1eafbec61a56bf6cea848fe754c71xy#define IGB_DMA_ALIGNMENT 0x0000000000002000ull
c869993e79c1eafbec61a56bf6cea848fe754c71xy#else
c869993e79c1eafbec61a56bf6cea848fe754c71xy#define IGB_DMA_ALIGNMENT 0x0000000000001000ull
c869993e79c1eafbec61a56bf6cea848fe754c71xy#endif
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DMA attributes for tx/rx descriptors
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic ddi_dma_attr_t igb_desc_dma_attr = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DMA_ATTR_V0, /* version number */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x0000000000000000ull, /* low address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* high address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* dma counter max */
c869993e79c1eafbec61a56bf6cea848fe754c71xy IGB_DMA_ALIGNMENT, /* alignment */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000FFF, /* burst sizes */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* minimum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* maximum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 1, /* scatter/gather list length */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* granularity */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_DMA_FLAGERR, /* DMA flags */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DMA attributes for tx/rx buffers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic ddi_dma_attr_t igb_buf_dma_attr = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DMA_ATTR_V0, /* version number */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x0000000000000000ull, /* low address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* high address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* dma counter max */
c869993e79c1eafbec61a56bf6cea848fe754c71xy IGB_DMA_ALIGNMENT, /* alignment */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000FFF, /* burst sizes */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* minimum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* maximum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 1, /* scatter/gather list length */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* granularity */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_DMA_FLAGERR, /* DMA flags */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DMA attributes for transmit
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic ddi_dma_attr_t igb_tx_dma_attr = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DMA_ATTR_V0, /* version number */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x0000000000000000ull, /* low address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* high address */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* dma counter max */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 1, /* alignment */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000FFF, /* burst sizes */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* minimum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000000FFFFFFFFull, /* maximum transfer size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0xFFFFFFFFFFFFFFFFull, /* maximum segment size */
c869993e79c1eafbec61a56bf6cea848fe754c71xy MAX_COOKIE, /* scatter/gather list length */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0x00000001, /* granularity */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_DMA_FLAGERR, /* DMA flags */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DMA access attributes for descriptors.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic ddi_device_acc_attr_t igb_desc_acc_attr = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DEVICE_ATTR_V0,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_STRUCTURE_LE_ACC,
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson DDI_STRICTORDER_ACC
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DMA access attributes for buffers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic ddi_device_acc_attr_t igb_buf_acc_attr = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DEVICE_ATTR_V0,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_NEVERSWAP_ACC,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_STRICTORDER_ACC
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_dma - Allocate DMA resources for all rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_dma(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate receive desciptor ring and control block lists
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_alloc_rbd_ring(rx_data) != IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_dma_failure;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_alloc_rcb_lists(rx_data) != IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_dma_failure;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate transmit desciptor ring and control block lists
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_alloc_tbd_ring(tx_ring) != IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_dma_failure;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_alloc_tcb_lists(tx_ring) != IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_dma_failure;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyalloc_dma_failure:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_dma(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_dma - Free all the DMA resources of all rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyvoid
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_free_dma(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free DMA resources of rx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rbd_ring(rx_data);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rcb_lists(rx_data);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free DMA resources of tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_tbd_ring(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_tcb_lists(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_tbd_ring - Memory allocation for the tx descriptors of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_tbd_ring(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int ret;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size_t size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size_t len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint_t cookie_num;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo;
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_cookie_t cookie;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = tx_ring->igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = sizeof (union e1000_adv_tx_desc) * tx_ring->ring_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If tx head write-back is enabled, an extra tbd is allocated
c869993e79c1eafbec61a56bf6cea848fe754c71xy * to save the head write-back value
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->tx_head_wb_enable) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy size += sizeof (union e1000_adv_tx_desc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate a DMA handle for the transmit descriptor
c869993e79c1eafbec61a56bf6cea848fe754c71xy * memory area.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_alloc_handle(devinfo, &igb_desc_dma_attr,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &tx_ring->tbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate tbd dma handle: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory to DMA data to and from the transmit
c869993e79c1eafbec61a56bf6cea848fe754c71xy * descriptors.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_mem_alloc(tx_ring->tbd_area.dma_handle,
c869993e79c1eafbec61a56bf6cea848fe754c71xy size, &igb_desc_acc_attr, DDI_DMA_CONSISTENT,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (caddr_t *)&tx_ring->tbd_area.address,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &len, &tx_ring->tbd_area.acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate tbd dma memory: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the entire transmit buffer descriptor area to zero
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy bzero(tx_ring->tbd_area.address, len);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocates DMA resources for the memory that was allocated by
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the ddi_dma_mem_alloc call. The DMA resources then get bound to the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the memory address
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_addr_bind_handle(tx_ring->tbd_area.dma_handle,
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL, (caddr_t)tx_ring->tbd_area.address,
c869993e79c1eafbec61a56bf6cea848fe754c71xy len, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_DMA_MAPPED) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not bind tbd dma resource: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.acc_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_mem_free(&tx_ring->tbd_area.acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(cookie_num == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_address = cookie.dmac_laddress;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.size = len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_ring = (union e1000_adv_tx_desc *)(uintptr_t)
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.address;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_tbd_ring - Free the tx descriptors of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_free_tbd_ring(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) ddi_dma_unbind_handle(tx_ring->tbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.acc_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_mem_free(&tx_ring->tbd_area.acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tbd_area.dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&tx_ring->tbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.dma_address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_area.size = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_ring = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaint
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_alloc_rx_ring_data(igb_rx_ring_t *rx_ring)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_t *igb = rx_ring->igb;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China uint32_t rcb_count;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Allocate memory for software receive rings
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data = kmem_zalloc(sizeof (igb_rx_data_t), KM_NOSLEEP);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Allocate software receive rings failed");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rx_ring = rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_init(&rx_data->recycle_lock, NULL,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->ring_size = igb->rx_ring_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->free_list_size = igb->rx_ring_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rcb_head = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rcb_tail = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rcb_free = rx_data->free_list_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Allocate memory for the work list.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->work_list = kmem_zalloc(sizeof (rx_control_block_t *) *
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->ring_size, KM_NOSLEEP);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->work_list == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China "Could not allocate memory for rx work list");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Allocate memory for the free list.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->free_list = kmem_zalloc(sizeof (rx_control_block_t *) *
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->free_list_size, KM_NOSLEEP);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->free_list == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx free list");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Allocate memory for the rx control blocks for work list and
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * free list.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rcb_area =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China kmem_zalloc(sizeof (rx_control_block_t) * rcb_count,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China KM_NOSLEEP);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_area == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China "Cound not allocate memory for rx control blocks");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China goto alloc_rx_data_failure;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_ring->rx_data = rx_data;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_SUCCESS);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaalloc_rx_data_failure:
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rx_ring_data(rx_data);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China}
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinavoid
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_free_rx_ring_data(igb_rx_data_t *rx_data)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China uint32_t rcb_count;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data == NULL)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ASSERT(rx_data->rcb_pending == 0);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_area != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->rcb_area,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t) * rcb_count);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rcb_area = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->work_list != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->work_list,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->ring_size);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->work_list = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->free_list != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data->free_list,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China sizeof (rx_control_block_t *) * rx_data->free_list_size);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->free_list = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_destroy(&rx_data->recycle_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China kmem_free(rx_data, sizeof (igb_rx_data_t));
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China}
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_rbd_ring - Memory allocation for the rx descriptors of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_alloc_rbd_ring(igb_rx_data_t *rx_data)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int ret;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size_t size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size_t len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint_t cookie_num;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo;
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_cookie_t cookie;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_t *igb = rx_data->rx_ring->igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy devinfo = igb->dip;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China size = sizeof (union e1000_adv_rx_desc) * rx_data->ring_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate a new DMA handle for the receive descriptor
c869993e79c1eafbec61a56bf6cea848fe754c71xy * memory area.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_alloc_handle(devinfo, &igb_desc_dma_attr,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China &rx_data->rbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate rbd dma handle: %x", ret);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory to DMA data to and from the receive
c869993e79c1eafbec61a56bf6cea848fe754c71xy * descriptors.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ret = ddi_dma_mem_alloc(rx_data->rbd_area.dma_handle,
c869993e79c1eafbec61a56bf6cea848fe754c71xy size, &igb_desc_acc_attr, DDI_DMA_CONSISTENT,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (caddr_t *)&rx_data->rbd_area.address,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China &len, &rx_data->rbd_area.acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate rbd dma memory: %x", ret);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the entire transmit buffer descriptor area to zero
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China bzero(rx_data->rbd_area.address, len);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocates DMA resources for the memory that was allocated by
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the ddi_dma_mem_alloc call.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ret = ddi_dma_addr_bind_handle(rx_data->rbd_area.dma_handle,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China NULL, (caddr_t)rx_data->rbd_area.address,
c869993e79c1eafbec61a56bf6cea848fe754c71xy len, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_DMA_MAPPED) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not bind rbd dma resource: %x", ret);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(cookie_num == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = cookie.dmac_laddress;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_ring = (union e1000_adv_rx_desc *)(uintptr_t)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_rbd_ring - Free the rx descriptors of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_free_rbd_ring(igb_rx_data_t *rx_data)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) ddi_dma_unbind_handle(rx_data->rbd_area.dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.acc_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ddi_dma_mem_free(&rx_data->rbd_area.acc_handle);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rbd_area.dma_handle != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ddi_dma_free_handle(&rx_data->rbd_area.dma_handle);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.address = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.dma_address = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_area.size = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_ring = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_dma_buffer - Allocate DMA resources for a DMA buffer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_dma_buffer(igb_t *igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy dma_buffer_t *buf, size_t size)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int ret;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_cookie_t cookie;
c869993e79c1eafbec61a56bf6cea848fe754c71xy size_t len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint_t cookie_num;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_alloc_handle(devinfo,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &igb_buf_dma_attr, DDI_DMA_DONTWAIT,
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL, &buf->dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_handle = NULL;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate dma buffer handle: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_mem_alloc(buf->dma_handle,
c869993e79c1eafbec61a56bf6cea848fe754c71xy size, &igb_buf_acc_attr, DDI_DMA_STREAMING,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL, &buf->address,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &len, &buf->acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&buf->dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate dma buffer memory: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_addr_bind_handle(buf->dma_handle, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->address,
c869993e79c1eafbec61a56bf6cea848fe754c71xy len, DDI_DMA_RDWR | DDI_DMA_STREAMING,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL, &cookie, &cookie_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_DMA_MAPPED) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->acc_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_mem_free(&buf->acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&buf->dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not bind dma buffer handle: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(cookie_num == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_address = cookie.dmac_laddress;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->size = len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->len = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_dma_buffer - Free one allocated area of dma memory and handle
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinavoid
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_free_dma_buffer(dma_buffer_t *buf)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) ddi_dma_unbind_handle(buf->dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->acc_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_mem_free(&buf->acc_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->acc_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->address = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (buf->dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&buf->dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->size = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf->len = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_tcb_lists - Memory allocation for the transmit control bolcks
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_tcb_lists(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int ret;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_control_block_t *tcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dma_buffer_t *tx_buf;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = tx_ring->igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory for the work list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->work_list = kmem_zalloc(sizeof (tx_control_block_t *) *
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->ring_size, KM_NOSLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->work_list == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Cound not allocate memory for tx work list");
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory for the free list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list = kmem_zalloc(sizeof (tx_control_block_t *) *
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list_size, KM_NOSLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->free_list == NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->work_list,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t *) * tx_ring->ring_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->work_list = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Cound not allocate memory for tx free list");
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory for the tx control blocks of free list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tcb_area =
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_zalloc(sizeof (tx_control_block_t) *
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list_size, KM_NOSLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tcb_area == NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->work_list,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t *) * tx_ring->ring_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->work_list = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->free_list,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t *) * tx_ring->free_list_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Cound not allocate memory for tx control blocks");
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate dma memory for the tx control block of free list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb = tx_ring->tcb_area;
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < tx_ring->free_list_size; i++, tcb++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(tcb != NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list[i] = tcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Pre-allocate dma handles for transmit. These dma handles
c869993e79c1eafbec61a56bf6cea848fe754c71xy * will be dynamically bound to the data buffers passed down
c869993e79c1eafbec61a56bf6cea848fe754c71xy * from the upper layers at the time of transmitting.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = ddi_dma_alloc_handle(devinfo,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &igb_tx_dma_attr,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_DMA_DONTWAIT, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &tcb->tx_dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb->tx_dma_handle = NULL;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Could not allocate tx dma handle: %x", ret);
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_tcb_lists_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Pre-allocate transmit buffers for packets that the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * size is less than bcopy_thresh.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_buf = &tcb->tx_buf;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = igb_alloc_dma_buffer(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_buf, igb->tx_buf_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != IGB_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(tcb->tx_dma_handle != NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&tcb->tx_dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb->tx_dma_handle = NULL;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Allocate tx dma buffer failed");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_tcb_lists_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu tcb->last_index = MAX_TX_RING_SIZE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyalloc_tcb_lists_fail:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_tcb_lists(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_tcb_lists - Release the memory allocated for
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the transmit control bolcks of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_free_tcb_lists(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_control_block_t *tcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb = tx_ring->tcb_area;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tcb == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < tx_ring->free_list_size; i++, tcb++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(tcb != NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Free the tx dma handle for dynamical binding */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tcb->tx_dma_handle != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_dma_free_handle(&tcb->tx_dma_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb->tx_dma_handle = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If the dma handle is NULL, then we don't
c869993e79c1eafbec61a56bf6cea848fe754c71xy * have to check the remaining.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_dma_buffer(&tcb->tx_buf);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->tcb_area != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->tcb_area,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t) * tx_ring->free_list_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tcb_area = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->work_list != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->work_list,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t *) * tx_ring->ring_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->work_list = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->free_list != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(tx_ring->free_list,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (tx_control_block_t *) * tx_ring->free_list_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_rcb_lists - Memory allocation for the receive control blocks
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_alloc_rcb_lists(igb_rx_data_t *rx_data)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int ret;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_control_block_t *rcb;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_t *igb = rx_data->rx_ring->igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy dma_buffer_t *rx_buf;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t rcb_count;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory for the rx control blocks for work list and
c869993e79c1eafbec61a56bf6cea848fe754c71xy * free list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb = rx_data->rcb_area;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < rcb_count; i++, rcb++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(rcb != NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (i < rx_data->ring_size) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Attach the rx control block to the work list */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->work_list[i] = rcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Attach the rx control block to the free list */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->free_list[i - rx_data->ring_size] = rcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_buf = &rcb->rx_buf;
c869993e79c1eafbec61a56bf6cea848fe754c71xy ret = igb_alloc_dma_buffer(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_buf, igb->rx_buf_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ret != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Allocate rx dma buffer failed");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto alloc_rcb_lists_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_buf->size -= IPHDR_ALIGN_ROOM;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_buf->address += IPHDR_ALIGN_ROOM;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_buf->dma_address += IPHDR_ALIGN_ROOM;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb->ref_cnt = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb->rx_data = (igb_rx_data_t *)rx_data;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rcb->free_rtn.free_func = igb_rx_recycle;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rcb->free_rtn.free_arg = (char *)rcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rcb->mp = desballoc((unsigned char *)
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China rx_buf->address,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China rx_buf->size,
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0, &rcb->free_rtn);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyalloc_rcb_lists_fail:
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rcb_lists(rx_data);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_rcb_lists - Free the receive control blocks of one ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_free_rcb_lists(igb_rx_data_t *rx_data)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_t *igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_control_block_t *rcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t rcb_count;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China uint32_t ref_cnt;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb = rx_data->rx_ring->igb;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_enter(&igb->rx_pending_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb = rx_data->rcb_area;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb_count = rx_data->ring_size + rx_data->free_list_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < rcb_count; i++, rcb++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(rcb != NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ref_cnt = atomic_dec_32_nv(&rcb->ref_cnt);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (ref_cnt == 0) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rcb->mp != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China freemsg(rcb->mp);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb->mp = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_dma_buffer(&rcb->rx_buf);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China } else {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China atomic_inc_32(&rx_data->rcb_pending);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China atomic_inc_32(&igb->rcb_pending);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->rx_pending_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglvoid
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hansonigb_set_fma_flags(int dma_flag)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (dma_flag) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_tx_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_buf_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_desc_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl } else {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_tx_dma_attr.dma_attr_flags = 0;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_buf_dma_attr.dma_attr_flags = 0;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_desc_dma_attr.dma_attr_flags = 0;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}