1/*- 2 * Copyright (c) 2003-2009 RMI Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of RMI Corporation, nor the names of its contributors, 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * RMI_BSD 30 * $FreeBSD$ 31 */ 32#ifndef _RMI_DEBUG_H_ 33#define _RMI_DEBUG_H_ 34 35#include <machine/atomic.h> 36 37enum { 38 //cacheline 0 39 MSGRNG_INT, 40 MSGRNG_PIC_INT, 41 MSGRNG_MSG, 42 MSGRNG_EXIT_STATUS, 43 MSGRNG_MSG_CYCLES, 44 //cacheline 1 45 NETIF_TX = 8, 46 NETIF_RX, 47 NETIF_TX_COMPLETE, 48 NETIF_TX_COMPLETE_TX, 49 NETIF_RX_CYCLES, 50 NETIF_TX_COMPLETE_CYCLES, 51 NETIF_TX_CYCLES, 52 NETIF_TIMER_START_Q, 53 //NETIF_REG_FRIN, 54 //NETIF_INT_REG, 55 //cacheline 2 56 REPLENISH_ENTER = 16, 57 REPLENISH_ENTER_COUNT, 58 REPLENISH_CPU, 59 REPLENISH_FRIN, 60 REPLENISH_CYCLES, 61 NETIF_STACK_TX, 62 NETIF_START_Q, 63 NETIF_STOP_Q, 64 //cacheline 3 65 USER_MAC_START = 24, 66 USER_MAC_INT = 24, 67 USER_MAC_TX_COMPLETE, 68 USER_MAC_RX, 69 USER_MAC_POLL, 70 USER_MAC_TX, 71 USER_MAC_TX_FAIL, 72 USER_MAC_TX_COUNT, 73 USER_MAC_FRIN, 74 //cacheline 4 75 USER_MAC_TX_FAIL_GMAC_CREDITS = 32, 76 USER_MAC_DO_PAGE_FAULT, 77 USER_MAC_UPDATE_TLB, 78 USER_MAC_UPDATE_BIGTLB, 79 USER_MAC_UPDATE_TLB_PFN0, 80 USER_MAC_UPDATE_TLB_PFN1, 81 82 XLR_MAX_COUNTERS = 40 83}; 84extern int xlr_counters[MAXCPU][XLR_MAX_COUNTERS]; 85extern __uint32_t msgrng_msg_cycles; 86 87#ifdef ENABLE_DEBUG 88#define xlr_inc_counter(x) atomic_add_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1) 89#define xlr_dec_counter(x) atomic_subtract_int(&xlr_counters[PCPU_GET(cpuid)][(x)], 1) 90#define xlr_set_counter(x, value) atomic_set_int(&xlr_counters[PCPU_GET(cpuid)][(x)], (value)) 91#define xlr_get_counter(x) (&xlr_counters[0][(x)]) 92 93#else /* default mode */ 94 95#define xlr_inc_counter(x) 96#define xlr_dec_counter(x) 97#define xlr_set_counter(x, value) 98#define xlr_get_counter(x) 99 100#endif 101 102#define dbg_msg(fmt, args...) printf(fmt, ##args) 103#define dbg_panic(fmt, args...) panic(fmt, ##args) 104 105#endif 106