1198160Srrs/*-
2198160Srrs * Copyright (c) 2003-2009 RMI Corporation
3198160Srrs * All rights reserved.
4198160Srrs *
5198160Srrs * Redistribution and use in source and binary forms, with or without
6198160Srrs * modification, are permitted provided that the following conditions
7198160Srrs * are met:
8198160Srrs * 1. Redistributions of source code must retain the above copyright
9198160Srrs *    notice, this list of conditions and the following disclaimer.
10198160Srrs * 2. Redistributions in binary form must reproduce the above copyright
11198160Srrs *    notice, this list of conditions and the following disclaimer in the
12198160Srrs *    documentation and/or other materials provided with the distribution.
13198160Srrs * 3. Neither the name of RMI Corporation, nor the names of its contributors,
14198160Srrs *    may be used to endorse or promote products derived from this software
15198160Srrs *    without specific prior written permission.
16198160Srrs *
17198160Srrs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18198160Srrs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19198160Srrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20198160Srrs * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21198160Srrs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22198160Srrs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23198160Srrs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24198160Srrs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25198160Srrs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26198160Srrs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27198160Srrs * SUCH DAMAGE.
28198160Srrs *
29211994Sjchandra * RMI_BSD
30211994Sjchandra * $FreeBSD$
31211994Sjchandra */
32198160Srrs#ifndef _RMI_DEBUG_H_
33198160Srrs#define _RMI_DEBUG_H_
34198160Srrs
35198160Srrs#include <machine/atomic.h>
36198160Srrs
37198160Srrsenum {
38198625Srrs	//cacheline 0
39198625Srrs	MSGRNG_INT,
40198625Srrs	MSGRNG_PIC_INT,
41198625Srrs	MSGRNG_MSG,
42198625Srrs	MSGRNG_EXIT_STATUS,
43198625Srrs	MSGRNG_MSG_CYCLES,
44198625Srrs	//cacheline 1
45198625Srrs	NETIF_TX = 8,
46198625Srrs	NETIF_RX,
47198625Srrs	NETIF_TX_COMPLETE,
48198625Srrs	NETIF_TX_COMPLETE_TX,
49198625Srrs	NETIF_RX_CYCLES,
50198625Srrs	NETIF_TX_COMPLETE_CYCLES,
51198625Srrs	NETIF_TX_CYCLES,
52198625Srrs	NETIF_TIMER_START_Q,
53198625Srrs	//NETIF_REG_FRIN,
54198625Srrs	//NETIF_INT_REG,
55198625Srrs	//cacheline 2
56198625Srrs	REPLENISH_ENTER = 16,
57198625Srrs	REPLENISH_ENTER_COUNT,
58198625Srrs	REPLENISH_CPU,
59198625Srrs	REPLENISH_FRIN,
60198625Srrs	REPLENISH_CYCLES,
61198625Srrs	NETIF_STACK_TX,
62198625Srrs	NETIF_START_Q,
63198625Srrs	NETIF_STOP_Q,
64198625Srrs	//cacheline 3
65198625Srrs	USER_MAC_START = 24,
66198625Srrs	USER_MAC_INT = 24,
67198625Srrs	USER_MAC_TX_COMPLETE,
68198625Srrs	USER_MAC_RX,
69198625Srrs	USER_MAC_POLL,
70198625Srrs	USER_MAC_TX,
71198625Srrs	USER_MAC_TX_FAIL,
72198625Srrs	USER_MAC_TX_COUNT,
73198625Srrs	USER_MAC_FRIN,
74198625Srrs	//cacheline 4
75198625Srrs	USER_MAC_TX_FAIL_GMAC_CREDITS = 32,
76198625Srrs	USER_MAC_DO_PAGE_FAULT,
77198625Srrs	USER_MAC_UPDATE_TLB,
78198625Srrs	USER_MAC_UPDATE_BIGTLB,
79198625Srrs	USER_MAC_UPDATE_TLB_PFN0,
80198625Srrs	USER_MAC_UPDATE_TLB_PFN1,
81198625Srrs
82198625Srrs	XLR_MAX_COUNTERS = 40
83198160Srrs};
84198160Srrsextern int xlr_counters[MAXCPU][XLR_MAX_COUNTERS];
85198160Srrsextern __uint32_t msgrng_msg_cycles;
86198160Srrs
87198160Srrs#ifdef ENABLE_DEBUG
88198160Srrs#define xlr_inc_counter(x) atomic_add_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1)
89198160Srrs#define xlr_dec_counter(x) atomic_subtract_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1)
90198160Srrs#define xlr_set_counter(x, value) atomic_set_int(&xlr_counters[PCPU_GET(cpuid)][(x)], (value))
91198160Srrs#define xlr_get_counter(x) (&xlr_counters[0][(x)])
92198160Srrs
93198625Srrs#else				/* default mode */
94198160Srrs
95198160Srrs#define xlr_inc_counter(x)
96198160Srrs#define xlr_dec_counter(x)
97198160Srrs#define xlr_set_counter(x, value)
98198160Srrs#define xlr_get_counter(x)
99198160Srrs
100198160Srrs#endif
101198160Srrs
102198160Srrs#define dbg_msg(fmt, args...) printf(fmt, ##args)
103198160Srrs#define dbg_panic(fmt, args...) panic(fmt, ##args)
104198160Srrs
105198160Srrs#endif
106