amd8111s_main.h revision 75ab5f91d942eea4138efe4799ca0589870c3899
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef AMD8111S_MAIN_H
2N/A#define AMD8111S_MAIN_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * Copyright (c) 2001-2006 Advanced Micro Devices, Inc. All rights reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions are met:
2N/A *
2N/A * + Redistributions of source code must retain the above copyright notice,
2N/A * + this list of conditions and the following disclaimer.
2N/A *
2N/A * + Redistributions in binary form must reproduce the above copyright
2N/A * + notice, this list of conditions and the following disclaimer in the
2N/A * + documentation and/or other materials provided with the distribution.
2N/A *
2N/A * + Neither the name of Advanced Micro Devices, Inc. nor the names of its
2N/A * + contributors may be used to endorse or promote products derived from
2N/A * + this software without specific prior written permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
2N/A * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
2N/A * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2N/A * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2N/A * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR
2N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2N/A * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2N/A * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2N/A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2N/A * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2N/A * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2N/A *
2N/A * Import/Export/Re-Export/Use/Release/Transfer Restrictions and
2N/A * Compliance with Applicable Laws. Notice is hereby given that
2N/A * the software may be subject to restrictions on use, release,
2N/A * transfer, importation, exportation and/or re-exportation under
2N/A * the laws and regulations of the United States or other
2N/A * countries ("Applicable Laws"), which include but are not
2N/A * limited to U.S. export control laws such as the Export
2N/A * Administration Regulations and national security controls as
2N/A * defined thereunder, as well as State Department controls under
2N/A * the U.S. Munitions List. Permission to use and/or
2N/A * redistribute the software is conditioned upon compliance with
2N/A * all Applicable Laws, including U.S. export control laws
2N/A * regarding specifically designated persons, countries and
2N/A * nationals of countries subject to national security controls.
2N/A */
2N/A
2N/A
2N/A#pragma ident "@(#)$RCSfile: odl.h,v $ $Revision: 1.1 $ " \
2N/A"$Date: 2004/04/22 15:22:52 $ AMD"
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/errno.h>
2N/A#include <sys/kmem.h>
2N/A#include <sys/conf.h>
2N/A#include <sys/stat.h>
2N/A#include <sys/note.h>
2N/A#include <sys/modctl.h>
2N/A
2N/A#include <sys/stream.h>
2N/A#include <sys/strsubr.h>
2N/A#include <sys/strsun.h>
2N/A
2N/A#include <sys/dditypes.h>
2N/A#include <sys/ddi.h>
2N/A#include <sys/sunddi.h>
2N/A
2N/A#include <sys/pci.h>
2N/A
2N/A#include <sys/ethernet.h>
2N/A#include <sys/dlpi.h>
2N/A#include <sys/mac.h>
2N/A#include <sys/mac_ether.h>
2N/A#include <sys/netlb.h>
2N/A#include "amd8111s_hw.h"
2N/A
2N/A#define MEM_REQ_MAX 100
2N/A#define MEMSET 4
2N/A
2N/A#define IOC_LINESIZE 40
2N/A
2N/A/*
2N/A * Loopback definitions
2N/A */
2N/A#define AMD8111S_LB_NONE 0
2N/A#define AMD8111S_LB_EXTERNAL_1000 1
2N/A#define AMD8111S_LB_EXTERNAL_100 2
2N/A#define AMD8111S_LB_EXTERNAL_10 3
2N/A#define AMD8111S_LB_INTERNAL_PHY 4
2N/A#define AMD8111S_LB_INTERNAL_MAC 5
2N/A
2N/A/* ((2 ^ (32 - 1)) * 8) / (10 ^ 8) >= 100 */
2N/A#define AMD8111S_DUMP_MIB_SECONDS_THRESHOLD 100
2N/A#define AMD8111S_DUMP_MIB_BYTES_THRESHOLD 0x80000000
2N/A
2N/A/* Bit flags for 'attach_progress' */
2N/A#define AMD8111S_ATTACH_PCI 0x0001 /* pci_config_setup() */
2N/A#define AMD8111S_ATTACH_RESOURCE 0x0002 /* odlInit() */
2N/A#define AMD8111S_ATTACH_REGS 0x0004 /* ddi_regs_map_setup() */
2N/A#define AMD8111S_ATTACH_INTRADDED 0x0010 /* intr_add() */
2N/A#define AMD8111S_ATTACH_MACREGED 0x0020 /* mac_register() */
2N/A#define AMD8111S_ATTACH_RESCHED 0x0040 /* soft_intr() */
2N/A
2N/A#define AMD8111S_TRY_SEND 0x0001
2N/A#define AMD8111S_SEND_READY 0x0002
2N/A
2N/A#define NEXT(buf, ptr) \
2N/A (buf.ptr + 1 >= buf.msg_buf + \
2N/A buf.ring_size ? \
2N/A buf.msg_buf : \
2N/A buf.ptr + 1)
2N/A/*
2N/A * (Internal) return values from ioctl subroutines
2N/A */
2N/Aenum ioc_reply {
2N/A IOC_INVAL = -1, /* bad, NAK with EINVAL */
2N/A IOC_DONE, /* OK, reply sent */
2N/A IOC_ACK, /* OK, just send ACK */
2N/A IOC_REPLY, /* OK, just send reply */
2N/A IOC_RESTART_ACK, /* OK, restart & ACK */
2N/A IOC_RESTART_REPLY /* OK, restart & reply */
2N/A};
2N/A
2N/Atypedef int (*TIMERfUNC) (struct LayerPointers *);
2N/A
2N/Astruct TimerStructure {
2N/A int Type;
2N/A int Period; /* in milliseconds */
2N/A timeout_id_t TimerHandle;
2N/A int (*TimerFunptr)(struct LayerPointers *);
2N/A struct LayerPointers *pLayerPointers;
2N/A};
2N/A
2N/Astruct amd8111s_statistics
2N/A{
2N/A uint64_t intr_TINT0; /* # of TINT0 (Tx interrupts) */
2N/A uint64_t intr_RINT0; /* # of RINT0 (Rx interrupts) */
2N/A uint64_t intr_STINT; /* # of STINT (Software Timer Intr) */
2N/A uint64_t intr_OTHER; /* Intr caused by other device */
2N/A
2N/A uint64_t tx_ok_packets;
2N/A uint64_t tx_no_descriptor;
2N/A uint64_t tx_no_buffer;
2N/A uint64_t tx_rescheduled;
2N/A uint64_t tx_unrescheduled;
2N/A
2N/A /* # of call amd8111s_dump_mib function */
2N/A uint64_t mib_dump_counter;
2N/A
2N/A /*
2N/A * From MIB registers (TX)
2N/A */
2N/A uint64_t tx_mib_packets; /* # of packets */
2N/A uint64_t tx_mib_multicst_packets; /* # of multicast packets */
2N/A uint64_t tx_mib_broadcst_packets; /* # of broadcast packets */
2N/A uint64_t tx_mib_flowctrl_packets; /* # of flow ctrl packets */
2N/A
2N/A uint64_t tx_mib_bytes; /* # of all Tx bytes */
2N/A
2N/A /* Packet drop due to Tx FIFO underrun */
2N/A uint64_t tx_mib_underrun_packets;
2N/A uint64_t tx_mib_collision_packets;
2N/A /* Packets successfully transmitted after experiencing one collision */
2N/A uint64_t tx_mib_one_coll_packets;
2N/A uint64_t tx_mib_multi_coll_packets;
2N/A /* # of late collisions that occur */
2N/A uint64_t tx_mib_late_coll_packets;
2N/A uint64_t tx_mib_ex_coll_packets; /* excessive collision */
2N/A uint64_t tx_mib_oversize_packets;
2N/A uint64_t tx_mib_defer_trans_packets; /* defer transmit */
2N/A
2N/A
2N/A /*
2N/A * Some error counter after "ifconfig amd8111sX unplumb"
2N/A */
2N/A /*
2N/A * Count Tx mp number from GLD even after NIC has been unplumbed.
2N/A * This value should always be 0.
2N/A */
2N/A uint64_t tx_afterunplumb;
2N/A /*
2N/A * We drain all pending tx packets during unplumb operation. This
2N/A * variable is to count the drain time.
2N/A * 30 means success; =30 means fail
2N/A */
2N/A uint64_t tx_draintime;
2N/A
2N/A uint64_t rx_ok_packets; /* # of all good packets */
2N/A uint64_t rx_allocfail; /* alloc memory fail during Rx */
2N/A uint64_t rx_error_zerosize;
2N/A
2N/A uint64_t rx_0_packets;
2N/A uint64_t rx_1_15_packets;
2N/A uint64_t rx_16_31_packets;
2N/A uint64_t rx_32_47_packets;
2N/A uint64_t rx_48_63_packets;
2N/A uint64_t rx_double_overflow;
2N/A
2N/A uint64_t rx_desc_err;
2N/A uint64_t rx_desc_err_FRAM; /* Framing error */
2N/A uint64_t rx_desc_err_OFLO; /* Overflow error */
2N/A uint64_t rx_desc_err_CRC; /* CRC error */
2N/A uint64_t rx_desc_err_BUFF; /* BCRC error */
2N/A
2N/A /*
2N/A * From MIB registers (RX)
2N/A */
2N/A uint64_t rx_mib_unicst_packets; /* # of unicast packets */
2N/A uint64_t rx_mib_multicst_packets; /* # of multicast packets */
2N/A uint64_t rx_mib_broadcst_packets; /* # of broadcast packets */
2N/A uint64_t rx_mib_macctrl_packets; /* # of mac ctrl packets */
2N/A uint64_t rx_mib_flowctrl_packets; /* # of flow ctrl packets */
2N/A
2N/A uint64_t rx_mib_bytes; /* # of all Rx bytes */
2N/A uint64_t rx_mib_good_bytes; /* # of all Rx bytes */
2N/A /*
2N/A * The total number of valid frames received that are less than 64
2N/A * bytes long (include the FCS).
2N/A */
2N/A uint64_t rx_mib_undersize_packets;
2N/A /*
2N/A * The total number of valid frames received that are greater than the
2N/A * maximum valid frame size (include the FCS).
2N/A */
2N/A uint64_t rx_mib_oversize_packets;
2N/A
2N/A uint64_t rx_mib_align_err_packets;
2N/A uint64_t rx_mib_fcs_err_packets; /* has a bad FCS */
2N/A /* Invalid data symbol (RX_ER) */
2N/A uint64_t rx_mib_symbol_err_packets;
2N/A /* Packets that were dropped because no descriptor was available */
2N/A uint64_t rx_mib_drop_packets;
2N/A /*
2N/A * Packets that were dropped due to lack of resources. This includes
2N/A * the number of times a packet was dropped due to receive FIFO
2N/A * overflow and lack of receive descriptor.
2N/A */
2N/A uint64_t rx_mib_miss_packets;
2N/A};
2N/A
2N/Astruct amd8111s_msgbuf {
2N/A uint64_t phy_addr;
2N/A caddr_t vir_addr;
2N/A uint32_t msg_size;
2N/A ddi_dma_handle_t p_hdl;
2N/A uint32_t offset;
2N/A};
2N/A
2N/Astruct amd8111s_dma_ringbuf {
2N/A ddi_dma_handle_t *dma_hdl;
2N/A ddi_acc_handle_t *acc_hdl;
2N/A ddi_dma_cookie_t *dma_cookie;
2N/A caddr_t *trunk_addr;
2N/A uint32_t buf_sz;
2N/A uint32_t trunk_sz;
2N/A uint32_t trunk_num;
2N/A struct amd8111s_msgbuf *msg_buf;
2N/A uint32_t ring_size;
2N/A uint32_t dma_buf_sz;
2N/A struct amd8111s_msgbuf *free;
2N/A struct amd8111s_msgbuf *next;
2N/A struct amd8111s_msgbuf *curr;
2N/A
2N/A kmutex_t ring_lock;
2N/A};
2N/A
2N/Astruct odl {
2N/A dev_info_t *devinfo;
2N/A
2N/A mac_handle_t mh; /* mac module handle */
2N/A mac_resource_handle_t mrh;
2N/A
2N/A struct amd8111s_statistics statistics;
2N/A
2N/A /* Locks */
2N/A kmutex_t mdlSendLock;
2N/A kmutex_t mdlRcvLock;
2N/A kmutex_t timer_lock;
2N/A kmutex_t send_cv_lock;
2N/A kcondvar_t send_cv;
2N/A
2N/A ddi_softintr_t drain_id;
2N/A /*
2N/A * The chip_lock assures that the Rx/Tx process must be stopped while
2N/A * other functions change the hardware configuration, such as attach()
2N/A * detach() etc are executed.
2N/A */
2N/A krwlock_t chip_lock;
2N/A
2N/A /*
2N/A * HW operators and parameters on attach period
2N/A */
2N/A ddi_iblock_cookie_t iblock; /* HW: interrupt block cookie */
2N/A ddi_acc_handle_t MemBasehandle;
2N/A
2N/A /* For pci configuration */
2N/A ddi_acc_handle_t pci_handle; /* HW: access handle of PCI space */
2N/A uint16_t vendor_id;
2N/A uint16_t device_id;
2N/A
2N/A /*
2N/A * FreeQ: Transfer Rx Buffer parameters from top layer to low layers.
2N/A * Format of parameter:
2N/A * (struct RxBufInfo *, physical address)
2N/A */
2N/A unsigned long FreeQ[2 * RX_RING_SIZE];
2N/A unsigned long *FreeQStart;
2N/A unsigned long *FreeQEnd;
2N/A long *FreeQWrite;
2N/A long *FreeQRead;
2N/A
2N/A /* For Rx descriptors */
2N/A ddi_dma_handle_t rx_desc_dma_handle;
2N/A ddi_acc_handle_t rx_desc_acc_handle;
2N/A ddi_dma_cookie_t rx_desc_dma_cookie;
2N/A
2N/A /* For Tx descriptors */
2N/A ddi_dma_handle_t tx_desc_dma_handle;
2N/A ddi_acc_handle_t tx_desc_acc_handle;
2N/A ddi_dma_cookie_t tx_desc_dma_cookie;
2N/A
2N/A /* For Tx buffers */
2N/A struct amd8111s_dma_ringbuf tx_buf;
2N/A
2N/A /* For Rx buffers */
2N/A struct amd8111s_dma_ringbuf rx_buf;
2N/A
2N/A ether_addr_t MacAddress; /* Mac address */
2N/A
2N/A /* Multicast addresses table */
2N/A UCHAR MulticastAddresses
2N/A [MAX_MULTICAST_ADDRESSES][ETH_LENGTH_OF_ADDRESS];
2N/A
2N/A link_state_t LinkStatus;
2N/A
2N/A /* Timer */
2N/A timeout_id_t Timer_id;
2N/A int (*TimerFunc)(struct LayerPointers *);
2N/A int timer_run;
2N/A int timer_linkdown;
2N/A
2N/A unsigned int dump_mib_seconds;
2N/A
2N/A uint32_t loopback_mode;
2N/A unsigned int rx_fcs_stripped;
2N/A
2N/A unsigned int rx_overflow_counter;
2N/A unsigned int pause_interval;
2N/A
2N/A};
2N/A
2N/A#endif /* AMD8111S_MAIN_H */
2N/A