debug.h revision 201917
190792Sgshapiro/*- 2261194Sgshapiro * Copyright (c) 2003-2009 RMI Corporation 390792Sgshapiro * All rights reserved. 490792Sgshapiro * 590792Sgshapiro * Redistribution and use in source and binary forms, with or without 690792Sgshapiro * modification, are permitted provided that the following conditions 790792Sgshapiro * are met: 890792Sgshapiro * 1. Redistributions of source code must retain the above copyright 990792Sgshapiro * notice, this list of conditions and the following disclaimer. 1090792Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright 1190792Sgshapiro * notice, this list of conditions and the following disclaimer in the 1290792Sgshapiro * documentation and/or other materials provided with the distribution. 1390792Sgshapiro * 3. Neither the name of RMI Corporation, nor the names of its contributors, 1490792Sgshapiro * may be used to endorse or promote products derived from this software 1590792Sgshapiro * without specific prior written permission. 16266527Sgshapiro * 1790792Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1890792Sgshapiro * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1990792Sgshapiro * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2090792Sgshapiro * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2190792Sgshapiro * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2290792Sgshapiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2390792Sgshapiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2490792Sgshapiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2590792Sgshapiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2690792Sgshapiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2790792Sgshapiro * SUCH DAMAGE. 2890792Sgshapiro * 2990792Sgshapiro * RMI_BSD */ 3090792Sgshapiro#ifndef _RMI_DEBUG_H_ 3190792Sgshapiro#define _RMI_DEBUG_H_ 3290792Sgshapiro 3390792Sgshapiro#include <machine/atomic.h> 3490792Sgshapiro 3590792Sgshapiroenum { 3690792Sgshapiro //cacheline 0 3790792Sgshapiro MSGRNG_INT, 3890792Sgshapiro MSGRNG_PIC_INT, 3990792Sgshapiro MSGRNG_MSG, 4090792Sgshapiro MSGRNG_EXIT_STATUS, 4190792Sgshapiro MSGRNG_MSG_CYCLES, 4290792Sgshapiro //cacheline 1 4390792Sgshapiro NETIF_TX = 8, 4490792Sgshapiro NETIF_RX, 4590792Sgshapiro NETIF_TX_COMPLETE, 4690792Sgshapiro NETIF_TX_COMPLETE_TX, 4790792Sgshapiro NETIF_RX_CYCLES, 4890792Sgshapiro NETIF_TX_COMPLETE_CYCLES, 4990792Sgshapiro NETIF_TX_CYCLES, 5090792Sgshapiro NETIF_TIMER_START_Q, 5190792Sgshapiro //NETIF_REG_FRIN, 5290792Sgshapiro //NETIF_INT_REG, 5390792Sgshapiro //cacheline 2 5490792Sgshapiro REPLENISH_ENTER = 16, 5590792Sgshapiro REPLENISH_ENTER_COUNT, 5690792Sgshapiro REPLENISH_CPU, 5790792Sgshapiro REPLENISH_FRIN, 5890792Sgshapiro REPLENISH_CYCLES, 5990792Sgshapiro NETIF_STACK_TX, 6090792Sgshapiro NETIF_START_Q, 6190792Sgshapiro NETIF_STOP_Q, 6290792Sgshapiro //cacheline 3 6390792Sgshapiro USER_MAC_START = 24, 6490792Sgshapiro USER_MAC_INT = 24, 6590792Sgshapiro USER_MAC_TX_COMPLETE, 6690792Sgshapiro USER_MAC_RX, 6790792Sgshapiro USER_MAC_POLL, 68 USER_MAC_TX, 69 USER_MAC_TX_FAIL, 70 USER_MAC_TX_COUNT, 71 USER_MAC_FRIN, 72 //cacheline 4 73 USER_MAC_TX_FAIL_GMAC_CREDITS = 32, 74 USER_MAC_DO_PAGE_FAULT, 75 USER_MAC_UPDATE_TLB, 76 USER_MAC_UPDATE_BIGTLB, 77 USER_MAC_UPDATE_TLB_PFN0, 78 USER_MAC_UPDATE_TLB_PFN1, 79 80 XLR_MAX_COUNTERS = 40 81}; 82extern int xlr_counters[MAXCPU][XLR_MAX_COUNTERS]; 83extern __uint32_t msgrng_msg_cycles; 84 85#ifdef ENABLE_DEBUG 86#define xlr_inc_counter(x) atomic_add_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1) 87#define xlr_dec_counter(x) atomic_subtract_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1) 88#define xlr_set_counter(x, value) atomic_set_int(&xlr_counters[PCPU_GET(cpuid)][(x)], (value)) 89#define xlr_get_counter(x) (&xlr_counters[0][(x)]) 90 91#else /* default mode */ 92 93#define xlr_inc_counter(x) 94#define xlr_dec_counter(x) 95#define xlr_set_counter(x, value) 96#define xlr_get_counter(x) 97 98#endif 99 100#define dbg_msg(fmt, args...) printf(fmt, ##args) 101#define dbg_panic(fmt, args...) panic(fmt, ##args) 102 103#endif 104