/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/ethernet.h>
#include <sys/sysmacros.h>
#include <sys/dditypes.h>
#include <sys/byteorder.h>
#include "atge.h"
#include "atge_l1_reg.h"
#include "atge_cmn_reg.h"
DMA_ATTR_V0, /* dma_attr_version */
0, /* dma_attr_addr_lo */
0x0000ffffffffull, /* dma_attr_addr_hi */
0x0000ffffffffull, /* dma_attr_count_max */
L1_TX_RING_ALIGN, /* dma_attr_align */
0x0000fffc, /* dma_attr_burstsizes */
1, /* dma_attr_minxfer */
0x0000ffffffffull, /* dma_attr_maxxfer */
0x0000ffffffffull, /* dma_attr_seg */
1, /* dma_attr_sgllen */
1, /* dma_attr_granular */
0 /* dma_attr_flags */
};
DMA_ATTR_V0, /* dma_attr_version */
0, /* dma_attr_addr_lo */
0x0000ffffffffull, /* dma_attr_addr_hi */
0x0000ffffffffull, /* dma_attr_count_max */
L1_RX_RING_ALIGN, /* dma_attr_align */
0x0000fffc, /* dma_attr_burstsizes */
1, /* dma_attr_minxfer */
0x0000ffffffffull, /* dma_attr_maxxfer */
0x0000ffffffffull, /* dma_attr_seg */
1, /* dma_attr_sgllen */
1, /* dma_attr_granular */
0 /* dma_attr_flags */
};
DMA_ATTR_V0, /* dma_attr_version */
0, /* dma_attr_addr_lo */
0x0000ffffffffull, /* dma_attr_addr_hi */
0x0000ffffffffull, /* dma_attr_count_max */
L1_CMB_ALIGN, /* dma_attr_align */
0x0000fffc, /* dma_attr_burstsizes */
1, /* dma_attr_minxfer */
0x0000ffffffffull, /* dma_attr_maxxfer */
0x0000ffffffffull, /* dma_attr_seg */
1, /* dma_attr_sgllen */
1, /* dma_attr_granular */
0 /* dma_attr_flags */
};
DMA_ATTR_V0, /* dma_attr_version */
0, /* dma_attr_addr_lo */
0x0000ffffffffull, /* dma_attr_addr_hi */
0x0000ffffffffull, /* dma_attr_count_max */
L1_SMB_ALIGN, /* dma_attr_align */
0x0000fffc, /* dma_attr_burstsizes */
1, /* dma_attr_minxfer */
0x0000ffffffffull, /* dma_attr_maxxfer */
0x0000ffffffffull, /* dma_attr_seg */
1, /* dma_attr_sgllen */
1, /* dma_attr_granular */
0 /* dma_attr_flags */
};
DMA_ATTR_V0, /* dma_attr_version */
0, /* dma_attr_addr_lo */
0x0000ffffffffull, /* dma_attr_addr_hi */
0x0000ffffffffull, /* dma_attr_count_max */
L1_RR_RING_ALIGN, /* dma_attr_align */
0x0000fffc, /* dma_attr_burstsizes */
1, /* dma_attr_minxfer */
0x0000ffffffffull, /* dma_attr_maxxfer */
0x0000ffffffffull, /* dma_attr_seg */
1, /* dma_attr_sgllen */
1, /* dma_attr_granular */
0 /* dma_attr_flags */
};
int
{
int err;
/*
* Allocate TX ring descriptor.
*/
" desc ring");
return (DDI_FAILURE);
}
/*
* Allocate DMA buffers for TX ring.
*/
if (err != DDI_SUCCESS) {
" TX Ring");
return (err);
}
/*
* Allocate RX ring.
*/
" for RX Ring");
return (DDI_FAILURE);
}
/*
* Allocate DMA buffers for RX ring.
*/
if (err != DDI_SUCCESS) {
" RX buffers");
return (err);
}
/*
* Allocate CMB used for fetching interrupt status data.
*/
return (DDI_FAILURE);
}
/*
* RR ring (Return Ring for RX and TX).
*/
" for RX RR ring");
return (DDI_FAILURE);
}
/*
* SMB for statistics.
*/
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
void
{
/*
* Free TX ring.
*/
}
}
}
}
}
/*
* Free RX ring.
*/
}
}
/*
* Free the memory allocated for gathering hw stats.
*/
}
}
void
{
int i;
for (i = 0; i < L1_RX_RING_CNT; i++) {
}
}
void
{
}
void
{
l1->atge_l1_rr_consumers = 0;
}
void
{
}
void
{
}
void
{
((l1->atge_l1_rr_consumers <<
}
void
{
atge_ring_t *r;
/* TX */
r = atgep->atge_tx_ring;
/* RX */
r = l1->atge_rx_ring;
/* RR Ring */
/* CMB */
/* SMB */
/*
* Set RX return ring (RR) counter.
*/
((L1_RR_RING_CNT << DESC_RRD_CNT_SHIFT) &
/*
* Set TX descriptor counter.
*/
/*
* Inform hardware that we have loaded DMA registers.
*/
/*
* Initialize mailbox register (mbox).
*/
}
void
{
/* Rx stats. */
/* Tx stats. */
/*
* Update global counters in atge_t.
*/
/*
* tx_pkts_truncated counter looks suspicious. It constantly
* increments with no sign of Tx errors. Hence we don't factor it.
*/
}
void
{
int t;
if ((reg & ATGE_CFG_TX_ENB) != 0) {
reg &= ~ATGE_CFG_TX_ENB;
}
/* Stop TX DMA engine. */
if ((reg & DMA_CFG_RD_ENB) != 0) {
reg &= ~DMA_CFG_RD_ENB;
}
for (t = ATGE_RESET_TIMEOUT; t > 0; t--) {
(IDLE_STATUS_TXMAC | IDLE_STATUS_DMARD)) == 0)
break;
drv_usecwait(10);
}
if (t == 0) {
}
}
void
{
int t;
if ((reg & ATGE_CFG_RX_ENB) != 0) {
reg &= ~ATGE_CFG_RX_ENB;
}
/* Stop RX DMA engine. */
if ((reg & DMA_CFG_WR_ENB) != 0) {
reg &= ~DMA_CFG_WR_ENB;
}
for (t = ATGE_RESET_TIMEOUT; t > 0; t--) {
(IDLE_STATUS_RXMAC | IDLE_STATUS_DMAWR)) == 0)
break;
drv_usecwait(10);
}
if (t == 0) {
}
}
/*
* Receives (consumes) packets.
*/
static mblk_t *
{
int sync = 0;
ATGE_DB(("%s: %s() PKT -- index : %d, flags : %x, totlen : %d,"
if (nsegs == 0)
break;
if ((flags & L1_RRD_ERROR) &&
break;
}
atgep->atge_ipackets++;
/*
* If there are more than one segments, then the first
* segment should be of size MTU. We couldn't verify
* this as our driver does not support changing MTU
* or Jumbo Frames.
*/
if (nsegs > 1) {
} else {
}
} else {
ATGE_DB(("%s: %s() PKT mp == NULL totlen : %d",
atgep->atge_norcvbuf++;
}
break;
}
rxd = (l1_rx_desc_t *)(
(rx_cons * sizeof (l1_rx_desc_t)));
if (cnt != 0) {
}
ATGE_DB(("%s: %s() len : %d, rxcons : %d, pktlen : %d",
pktlen));
}
} else {
}
} else {
}
/*
* Tell the chip that this RR can be reused.
*/
sync++;
}
if (sync) {
ATGE_DB(("%s: %s() PKT Recved -> r_consumer : %d, rx_cons : %d"
" atge_l1_rr_consumers : %d",
}
return (rx_head);
}
/*
* The interrupt handler for L1 chip.
*/
/*ARGSUSED*/
{
int resched = 0;
return (DDI_INTR_UNCLAIMED);
}
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_CLAIMED);
}
ATGE_DB(("%s: %s() entry status : %x",
/*
* Disable interrupts.
*/
/*
* Check if chip is running, only then do the work.
*/
ATGE_DB(("%s: %s() atge_l1_intr_status : %x, "
"atge_l1_rx_prod_cons : %d, atge_l1_tx_prod_cons : %d"
" atge_l1_rr_consumers : %d",
/*
* Inform the hardware that CMB was served.
*/
cmb->intr_status = 0;
/*
* We must check for RX Overflow condition and restart the
* chip. This needs to be done only when producer and consumer
* counters are same for the RR ring (Return RX).
*/
(INTR_RX_FIFO_OFLOW | INTR_RRD_OFLOW) &&
ATGE_DB(("%s: %s() RX OVERFLOW :"
" atge_l1_rx_prod_cons : %d,"
" l1->atge_l1_rr_consumers : %d",
goto done;
}
if (atgep->atge_tx_resched) {
atgep->atge_tx_resched = 0;
resched = 1;
}
}
"DMA transfer error");
ATGE_DB(("%s: %s() DMA transfer error",
goto done;
}
}
done:
ATGE_DB(("%s: %s() MII_CHECK Requested",
(void) atge_mii_read(atgep,
}
}
/*
* Pass the list of packets received from chip to MAC layer.
*/
if (rx_head) {
}
if (rx_head1) {
}
/*
* Let MAC start sending pkts if the downstream was asked to pause.
*/
if (resched)
return (DDI_INTR_CLAIMED);
}
void
{
atge_l1_sync_mbox(r->r_atge);
}