198849Sken/*-
298849Sken * Copyright (c) 1999, 2000 Kenneth D. Merry.
398849Sken * All rights reserved.
498849Sken *
598849Sken * Redistribution and use in source and binary forms, with or without
698849Sken * modification, are permitted provided that the following conditions
798849Sken * are met:
898849Sken * 1. Redistributions of source code must retain the above copyright
998849Sken *    notice, this list of conditions, and the following disclaimer,
1098849Sken *    without modification, immediately at the beginning of the file.
1198849Sken * 2. The name of the author may not be used to endorse or promote products
1298849Sken *    derived from this software without specific prior written permission.
1398849Sken *
1498849Sken * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1598849Sken * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1698849Sken * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1798849Sken * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1898849Sken * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1998849Sken * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2098849Sken * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2198849Sken * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2298849Sken * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2398849Sken * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2498849Sken * SUCH DAMAGE.
2598849Sken *
2698849Sken *	$FreeBSD$
2798849Sken */
2898849Sken/*
2998849Sken * The ti_stats structure below is from code with the following copyright,
3098849Sken * and originally comes from the Alteon firmware documentation.
3198849Sken */
3298849Sken/*
3398849Sken * Copyright (c) 1997, 1998, 1999
3498849Sken *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
3598849Sken *
3698849Sken * Redistribution and use in source and binary forms, with or without
3798849Sken * modification, are permitted provided that the following conditions
3898849Sken * are met:
3998849Sken * 1. Redistributions of source code must retain the above copyright
4098849Sken *    notice, this list of conditions and the following disclaimer.
4198849Sken * 2. Redistributions in binary form must reproduce the above copyright
4298849Sken *    notice, this list of conditions and the following disclaimer in the
4398849Sken *    documentation and/or other materials provided with the distribution.
4498849Sken * 3. All advertising materials mentioning features or use of this software
4598849Sken *    must display the following acknowledgement:
4698849Sken *	This product includes software developed by Bill Paul.
4798849Sken * 4. Neither the name of the author nor the names of any co-contributors
4898849Sken *    may be used to endorse or promote products derived from this software
4998849Sken *    without specific prior written permission.
5098849Sken *
5198849Sken * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
5298849Sken * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5398849Sken * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5498849Sken * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
5598849Sken * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5698849Sken * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5798849Sken * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5898849Sken * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5998849Sken * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6098849Sken * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
6198849Sken * THE POSSIBILITY OF SUCH DAMAGE.
6298849Sken *
6398849Sken *	from: if_tireg.h,v 1.8 1999/07/23 18:46:24 wpaul Exp $
6498849Sken */
6598849Sken
6698849Sken#ifndef _SYS_TIIO_H_
6798849Sken#define _SYS_TIIO_H_
6898849Sken
6998849Sken#include <sys/ioccom.h>
7098849Sken
7198849Sken/*
7298849Sken * Tigon statistics counters.
7398849Sken */
7498849Skenstruct ti_stats {
7598849Sken	/*
7698849Sken	 * MAC stats, taken from RFC 1643, ethernet-like MIB
7798849Sken	 */
7898849Sken	volatile u_int32_t dot3StatsAlignmentErrors;		/* 0 */
7998849Sken	volatile u_int32_t dot3StatsFCSErrors;			/* 1 */
8098849Sken	volatile u_int32_t dot3StatsSingleCollisionFrames;	/* 2 */
8198849Sken	volatile u_int32_t dot3StatsMultipleCollisionFrames;	/* 3 */
8298849Sken	volatile u_int32_t dot3StatsSQETestErrors;		/* 4 */
8398849Sken	volatile u_int32_t dot3StatsDeferredTransmissions;	/* 5 */
8498849Sken	volatile u_int32_t dot3StatsLateCollisions;		/* 6 */
8598849Sken	volatile u_int32_t dot3StatsExcessiveCollisions;	/* 7 */
8698849Sken	volatile u_int32_t dot3StatsInternalMacTransmitErrors;	/* 8 */
8798849Sken	volatile u_int32_t dot3StatsCarrierSenseErrors;		/* 9 */
8898849Sken	volatile u_int32_t dot3StatsFrameTooLongs;		/* 10 */
8998849Sken	volatile u_int32_t dot3StatsInternalMacReceiveErrors;	/* 11 */
9098849Sken	/*
9198849Sken	 * interface stats, taken from RFC 1213, MIB-II, interfaces group
9298849Sken	 */
9398849Sken	volatile u_int32_t ifIndex;				/* 12 */
9498849Sken	volatile u_int32_t ifType;				/* 13 */
9598849Sken	volatile u_int32_t ifMtu;				/* 14 */
9698849Sken	volatile u_int32_t ifSpeed;				/* 15 */
9798849Sken	volatile u_int32_t ifAdminStatus;			/* 16 */
9898849Sken#define IF_ADMIN_STATUS_UP      1
9998849Sken#define IF_ADMIN_STATUS_DOWN    2
10098849Sken#define IF_ADMIN_STATUS_TESTING 3
10198849Sken	volatile u_int32_t ifOperStatus;			/* 17 */
10298849Sken#define IF_OPER_STATUS_UP       1
10398849Sken#define IF_OPER_STATUS_DOWN     2
10498849Sken#define IF_OPER_STATUS_TESTING  3
10598849Sken#define IF_OPER_STATUS_UNKNOWN  4
10698849Sken#define IF_OPER_STATUS_DORMANT  5
10798849Sken	volatile u_int32_t ifLastChange;			/* 18 */
10898849Sken	volatile u_int32_t ifInDiscards;			/* 19 */
10998849Sken	volatile u_int32_t ifInErrors;				/* 20 */
11098849Sken	volatile u_int32_t ifInUnknownProtos;			/* 21 */
11198849Sken	volatile u_int32_t ifOutDiscards;			/* 22 */
11298849Sken	volatile u_int32_t ifOutErrors;				/* 23 */
11398849Sken	volatile u_int32_t ifOutQLen;     /* deprecated */	/* 24 */
11498849Sken	volatile u_int8_t  ifPhysAddress[8]; /* 8 bytes */	/* 25 - 26 */
11598849Sken	volatile u_int8_t  ifDescr[32];				/* 27 - 34 */
11698849Sken	u_int32_t alignIt;      /* align to 64 bit for u_int64_ts following */
11798849Sken	/*
11898849Sken	 * more interface stats, taken from RFC 1573, MIB-IIupdate,
11998849Sken	 * interfaces group
12098849Sken	 */
12198849Sken	volatile u_int64_t ifHCInOctets;			/* 36 - 37 */
12298849Sken	volatile u_int64_t ifHCInUcastPkts;			/* 38 - 39 */
12398849Sken	volatile u_int64_t ifHCInMulticastPkts;			/* 40 - 41 */
12498849Sken	volatile u_int64_t ifHCInBroadcastPkts;			/* 42 - 43 */
12598849Sken	volatile u_int64_t ifHCOutOctets;			/* 44 - 45 */
12698849Sken	volatile u_int64_t ifHCOutUcastPkts;			/* 46 - 47 */
12798849Sken	volatile u_int64_t ifHCOutMulticastPkts;		/* 48 - 49 */
12898849Sken	volatile u_int64_t ifHCOutBroadcastPkts;		/* 50 - 51 */
12998849Sken	volatile u_int32_t ifLinkUpDownTrapEnable;		/* 52 */
13098849Sken	volatile u_int32_t ifHighSpeed;				/* 53 */
13198849Sken	volatile u_int32_t ifPromiscuousMode; 			/* 54 */
13298849Sken	volatile u_int32_t ifConnectorPresent; /* follow link state 55 */
13398849Sken	/*
13498849Sken	 * Host Commands
13598849Sken	 */
13698849Sken	volatile u_int32_t nicCmdsHostState;			/* 56 */
13798849Sken	volatile u_int32_t nicCmdsFDRFiltering;			/* 57 */
13898849Sken	volatile u_int32_t nicCmdsSetRecvProdIndex;		/* 58 */
13998849Sken	volatile u_int32_t nicCmdsUpdateGencommStats;		/* 59 */
14098849Sken	volatile u_int32_t nicCmdsResetJumboRing;		/* 60 */
14198849Sken	volatile u_int32_t nicCmdsAddMCastAddr;			/* 61 */
14298849Sken	volatile u_int32_t nicCmdsDelMCastAddr;			/* 62 */
14398849Sken	volatile u_int32_t nicCmdsSetPromiscMode;		/* 63 */
14498849Sken	volatile u_int32_t nicCmdsLinkNegotiate;		/* 64 */
14598849Sken	volatile u_int32_t nicCmdsSetMACAddr;			/* 65 */
14698849Sken	volatile u_int32_t nicCmdsClearProfile;			/* 66 */
14798849Sken	volatile u_int32_t nicCmdsSetMulticastMode;		/* 67 */
14898849Sken	volatile u_int32_t nicCmdsClearStats;			/* 68 */
14998849Sken	volatile u_int32_t nicCmdsSetRecvJumboProdIndex;	/* 69 */
15098849Sken	volatile u_int32_t nicCmdsSetRecvMiniProdIndex;		/* 70 */
15198849Sken	volatile u_int32_t nicCmdsRefreshStats;			/* 71 */
15298849Sken	volatile u_int32_t nicCmdsUnknown;			/* 72 */
15398849Sken	/*
15498849Sken	 * NIC Events
15598849Sken	 */
15698849Sken	volatile u_int32_t nicEventsNICFirmwareOperational;	/* 73 */
15798849Sken	volatile u_int32_t nicEventsStatsUpdated;		/* 74 */
15898849Sken	volatile u_int32_t nicEventsLinkStateChanged;		/* 75 */
15998849Sken	volatile u_int32_t nicEventsError;			/* 76 */
16098849Sken	volatile u_int32_t nicEventsMCastListUpdated;		/* 77 */
16198849Sken	volatile u_int32_t nicEventsResetJumboRing;		/* 78 */
16298849Sken	/*
16398849Sken	 * Ring manipulation
16498849Sken	 */
16598849Sken	volatile u_int32_t nicRingSetSendProdIndex;		/* 79 */
16698849Sken	volatile u_int32_t nicRingSetSendConsIndex;		/* 80 */
16798849Sken	volatile u_int32_t nicRingSetRecvReturnProdIndex;	/* 81 */
16898849Sken	/*
16998849Sken	 * Interrupts
17098849Sken	 */
17198849Sken	volatile u_int32_t nicInterrupts;			/* 82 */
17298849Sken	volatile u_int32_t nicAvoidedInterrupts;		/* 83 */
17398849Sken	/*
17498849Sken	 * BD Coalessing Thresholds
17598849Sken	 */
17698849Sken	volatile u_int32_t nicEventThresholdHit;		/* 84 */
17798849Sken	volatile u_int32_t nicSendThresholdHit;			/* 85 */
17898849Sken	volatile u_int32_t nicRecvThresholdHit;			/* 86 */
17998849Sken	/*
18098849Sken	 * DMA Attentions
18198849Sken	 */
18298849Sken	volatile u_int32_t nicDmaRdOverrun;			/* 87 */
18398849Sken	volatile u_int32_t nicDmaRdUnderrun;			/* 88 */
18498849Sken	volatile u_int32_t nicDmaWrOverrun;			/* 89 */
18598849Sken	volatile u_int32_t nicDmaWrUnderrun;			/* 90 */
18698849Sken	volatile u_int32_t nicDmaWrMasterAborts;		/* 91 */
18798849Sken	volatile u_int32_t nicDmaRdMasterAborts;		/* 92 */
18898849Sken	/*
18998849Sken	 * NIC Resources
19098849Sken	 */
19198849Sken	volatile u_int32_t nicDmaWriteRingFull;			/* 93 */
19298849Sken	volatile u_int32_t nicDmaReadRingFull;			/* 94 */
19398849Sken	volatile u_int32_t nicEventRingFull;			/* 95 */
19498849Sken	volatile u_int32_t nicEventProducerRingFull;		/* 96 */
19598849Sken	volatile u_int32_t nicTxMacDescrRingFull;		/* 97 */
19698849Sken	volatile u_int32_t nicOutOfTxBufSpaceFrameRetry;	/* 98 */
19798849Sken	volatile u_int32_t nicNoMoreWrDMADescriptors;		/* 99 */
19898849Sken	volatile u_int32_t nicNoMoreRxBDs;			/* 100 */
19998849Sken	volatile u_int32_t nicNoSpaceInReturnRing;		/* 101 */
20098849Sken	volatile u_int32_t nicSendBDs;            /* current count 102 */
20198849Sken	volatile u_int32_t nicRecvBDs;            /* current count 103 */
20298849Sken	volatile u_int32_t nicJumboRecvBDs;       /* current count 104 */
20398849Sken	volatile u_int32_t nicMiniRecvBDs;        /* current count 105 */
20498849Sken	volatile u_int32_t nicTotalRecvBDs;       /* current count 106 */
20598849Sken	volatile u_int32_t nicTotalSendBDs;       /* current count 107 */
20698849Sken	volatile u_int32_t nicJumboSpillOver;			/* 108 */
20798849Sken	volatile u_int32_t nicSbusHangCleared;			/* 109 */
20898849Sken	volatile u_int32_t nicEnqEventDelayed;			/* 110 */
20998849Sken	/*
21098849Sken	 * Stats from MAC rx completion
21198849Sken	 */
21298849Sken	volatile u_int32_t nicMacRxLateColls;			/* 111 */
21398849Sken	volatile u_int32_t nicMacRxLinkLostDuringPkt;		/* 112 */
21498849Sken	volatile u_int32_t nicMacRxPhyDecodeErr;		/* 113 */
21598849Sken	volatile u_int32_t nicMacRxMacAbort;			/* 114 */
21698849Sken	volatile u_int32_t nicMacRxTruncNoResources;		/* 115 */
21798849Sken	/*
21898849Sken	 * Stats from the mac_stats area
21998849Sken	 */
22098849Sken	volatile u_int32_t nicMacRxDropUla;			/* 116 */
22198849Sken	volatile u_int32_t nicMacRxDropMcast;			/* 117 */
22298849Sken	volatile u_int32_t nicMacRxFlowControl;			/* 118 */
22398849Sken	volatile u_int32_t nicMacRxDropSpace;			/* 119 */
22498849Sken	volatile u_int32_t nicMacRxColls;			/* 120 */
22598849Sken	/*
22698849Sken 	 * MAC RX Attentions
22798849Sken	 */
22898849Sken	volatile u_int32_t nicMacRxTotalAttns;			/* 121 */
22998849Sken	volatile u_int32_t nicMacRxLinkAttns;			/* 122 */
23098849Sken	volatile u_int32_t nicMacRxSyncAttns;			/* 123 */
23198849Sken	volatile u_int32_t nicMacRxConfigAttns;			/* 124 */
23298849Sken	volatile u_int32_t nicMacReset;				/* 125 */
23398849Sken	volatile u_int32_t nicMacRxBufDescrAttns;		/* 126 */
23498849Sken	volatile u_int32_t nicMacRxBufAttns;			/* 127 */
23598849Sken	volatile u_int32_t nicMacRxZeroFrameCleanup;		/* 128 */
23698849Sken	volatile u_int32_t nicMacRxOneFrameCleanup;		/* 129 */
23798849Sken	volatile u_int32_t nicMacRxMultipleFrameCleanup;	/* 130 */
23898849Sken	volatile u_int32_t nicMacRxTimerCleanup;		/* 131 */
23998849Sken	volatile u_int32_t nicMacRxDmaCleanup;			/* 132 */
24098849Sken	/*
24198849Sken	 * Stats from the mac_stats area
24298849Sken	 */
24398849Sken	volatile u_int32_t nicMacTxCollisionHistogram[15];	/* 133 */
24498849Sken	/*
24598849Sken	 * MAC TX Attentions
24698849Sken	 */
24798849Sken	volatile u_int32_t nicMacTxTotalAttns;			/* 134 */
24898849Sken	/*
24998849Sken	 * NIC Profile
25098849Sken	 */
25198849Sken	volatile u_int32_t nicProfile[32];			/* 135 */
25298849Sken	/*
25398849Sken	 * Pat to 1024 bytes.
25498849Sken	 */
25598849Sken	u_int32_t		pad[75];
25698849Sken};
25798849Sken
25898849Skenstruct tg_reg {
25998849Sken	u_int32_t	data;
26098849Sken	u_int32_t	addr;
26198849Sken};
26298849Sken
26398849Skenstruct tg_mem {
26498849Sken	u_int32_t	tgAddr;
26598849Sken	caddr_t		userAddr;
26698849Sken	int		len;
26798849Sken};
26898849Sken
26998849Sken
27098849Skentypedef enum {
27198849Sken	TI_PARAM_NONE		= 0x00,
27298849Sken	TI_PARAM_STAT_TICKS	= 0x01,
27398849Sken	TI_PARAM_RX_COAL_TICKS	= 0x02,
27498849Sken	TI_PARAM_TX_COAL_TICKS	= 0x04,
27598849Sken	TI_PARAM_RX_COAL_BDS	= 0x08,
27698849Sken	TI_PARAM_TX_COAL_BDS	= 0x10,
27798849Sken	TI_PARAM_TX_BUF_RATIO	= 0x20,
27898849Sken	TI_PARAM_ALL		= 0x2f
27998849Sken} ti_param_mask;
28098849Sken
28198849Skenstruct ti_params {
28298849Sken	u_int32_t	ti_stat_ticks;
28398849Sken	u_int32_t	ti_rx_coal_ticks;
28498849Sken	u_int32_t	ti_tx_coal_ticks;
28598849Sken	u_int32_t	ti_rx_max_coal_bds;
28698849Sken	u_int32_t	ti_tx_max_coal_bds;
28798849Sken	u_int32_t	ti_tx_buf_ratio;
28898849Sken	ti_param_mask	param_mask;
28998849Sken};
29098849Sken
29198849Skentypedef enum {
29298849Sken	TI_TRACE_TYPE_NONE	= 0x00000000,
29398849Sken	TI_TRACE_TYPE_SEND	= 0x00000001,
29498849Sken	TI_TRACE_TYPE_RECV	= 0x00000002,
29598849Sken	TI_TRACE_TYPE_DMA	= 0x00000004,
29698849Sken	TI_TRACE_TYPE_EVENT	= 0x00000008,
29798849Sken	TI_TRACE_TYPE_COMMAND	= 0x00000010,
29898849Sken	TI_TRACE_TYPE_MAC	= 0x00000020,
29998849Sken	TI_TRACE_TYPE_STATS	= 0x00000040,
30098849Sken	TI_TRACE_TYPE_TIMER	= 0x00000080,
30198849Sken	TI_TRACE_TYPE_DISP	= 0x00000100,
30298849Sken	TI_TRACE_TYPE_MAILBOX	= 0x00000200,
30398849Sken	TI_TRACE_TYPE_RECV_BD	= 0x00000400,
30498849Sken	TI_TRACE_TYPE_LNK_PHY	= 0x00000800,
30598849Sken	TI_TRACE_TYPE_LNK_NEG	= 0x00001000,
30698849Sken	TI_TRACE_LEVEL_1	= 0x10000000,
30798849Sken	TI_TRACE_LEVEL_2	= 0x20000000
30898849Sken} ti_trace_type;
30998849Sken
31098849Skenstruct ti_trace_buf {
31198849Sken	u_long	*buf;
31298849Sken	int	buf_len;
31398849Sken	int	fill_len;
31498849Sken	u_long	cur_trace_ptr;
31598849Sken};
31698849Sken
31798849Sken#define	TIIOCGETSTATS	_IOR('T', 1, struct ti_stats)
31898849Sken#define	TIIOCGETPARAMS	_IOR('T', 2, struct ti_params)
31998849Sken#define	TIIOCSETPARAMS	_IOW('T', 3, struct ti_params)
32098849Sken#define TIIOCSETTRACE	_IOW('T', 11, ti_trace_type)
32198849Sken#define TIIOCGETTRACE	_IOWR('T', 12, struct ti_trace_buf)
32298849Sken
32398849Sken/*
32498849Sken * Taken from Alteon's altioctl.h.  Alteon's ioctl numbers 1-6 aren't
32598849Sken * used by the FreeBSD driver.
32698849Sken */
32798849Sken#define ALT_ATTACH		_IO('a', 7)
32898849Sken#define ALT_READ_TG_MEM		_IOWR('a', 10, struct tg_mem)
32998849Sken#define ALT_WRITE_TG_MEM	_IOWR('a', 11, struct tg_mem)
33098849Sken#define ALT_READ_TG_REG		_IOWR('a', 12, struct tg_reg)
33198849Sken#define ALT_WRITE_TG_REG	_IOWR('a', 13, struct tg_reg)
33298849Sken
33398849Sken#endif /* _SYS_TIIO_H_  */
334