linux/drivers/scsi/bfa/include/cs/bfa_trc.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
   3 * All rights reserved
   4 * www.brocade.com
   5 *
   6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
   7 *
   8 * This program is free software; you can redistribute it and/or modify it
   9 * under the terms of the GNU General Public License (GPL) Version 2 as
  10 * published by the Free Software Foundation
  11 *
  12 * This program is distributed in the hope that it will be useful, but
  13 * WITHOUT ANY WARRANTY; without even the implied warranty of
  14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15 * General Public License for more details.
  16 */
  17#ifndef __BFA_TRC_H__
  18#define __BFA_TRC_H__
  19
  20#include <bfa_os_inc.h>
  21
  22#ifndef BFA_TRC_MAX
  23#define BFA_TRC_MAX     (4 * 1024)
  24#endif
  25
  26#ifndef BFA_TRC_TS
  27#define BFA_TRC_TS(_trcm)       ((_trcm)->ticks ++)
  28#endif
  29
  30struct bfa_trc_s {
  31#ifdef __BIGENDIAN
  32        u16     fileno;
  33        u16     line;
  34#else
  35        u16     line;
  36        u16     fileno;
  37#endif
  38        u32     timestamp;
  39        union {
  40                struct {
  41                        u32     rsvd;
  42                        u32     u32;
  43                } u32;
  44                u64     u64;
  45        } data;
  46};
  47
  48
  49struct bfa_trc_mod_s {
  50        u32     head;
  51        u32     tail;
  52        u32     ntrc;
  53        u32     stopped;
  54        u32     ticks;
  55        u32     rsvd[3];
  56        struct bfa_trc_s trc[BFA_TRC_MAX];
  57};
  58
  59
  60enum {
  61        BFA_TRC_FW   = 1,       /*  firmware modules */
  62        BFA_TRC_HAL  = 2,       /*  BFA modules */
  63        BFA_TRC_FCS  = 3,       /*  BFA FCS modules */
  64        BFA_TRC_LDRV = 4,       /*  Linux driver modules */
  65        BFA_TRC_SDRV = 5,       /*  Solaris driver modules */
  66        BFA_TRC_VDRV = 6,       /*  vmware driver modules */
  67        BFA_TRC_WDRV = 7,       /*  windows driver modules */
  68        BFA_TRC_AEN  = 8,       /*  AEN module */
  69        BFA_TRC_BIOS = 9,       /*  bios driver modules */
  70        BFA_TRC_EFI  = 10,      /*  EFI driver modules */
  71        BNA_TRC_WDRV = 11,      /*  BNA windows driver modules */
  72        BNA_TRC_VDRV = 12,      /*  BNA vmware driver modules */
  73        BNA_TRC_SDRV = 13,      /*  BNA Solaris driver modules */
  74        BNA_TRC_LDRV = 14,      /*  BNA Linux driver modules */
  75        BNA_TRC_HAL  = 15,      /*  BNA modules */
  76        BFA_TRC_CNA  = 16,      /*  Common modules */
  77        BNA_TRC_IMDRV = 17      /*  BNA windows intermediate driver modules */
  78};
  79#define BFA_TRC_MOD_SH  10
  80#define BFA_TRC_MOD(__mod)      ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
  81
  82/**
  83 * Define a new tracing file (module). Module should match one defined above.
  84 */
  85#define BFA_TRC_FILE(__mod, __submod)                                   \
  86        static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
  87                                                 BFA_TRC_MOD(__mod))
  88
  89
  90#define bfa_trc32(_trcp, _data) \
  91        __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
  92
  93
  94#ifndef BFA_BOOT_BUILD
  95#define bfa_trc(_trcp, _data)   \
  96        __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
  97#else
  98void bfa_boot_trc(struct bfa_trc_mod_s *trcmod, u16 fileno,
  99                        u16 line, u32 data);
 100#define bfa_trc(_trcp, _data)   \
 101        bfa_boot_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
 102#endif
 103
 104
 105static inline void
 106bfa_trc_init(struct bfa_trc_mod_s *trcm)
 107{
 108        trcm->head = trcm->tail = trcm->stopped = 0;
 109        trcm->ntrc = BFA_TRC_MAX;
 110}
 111
 112
 113static inline void
 114bfa_trc_stop(struct bfa_trc_mod_s *trcm)
 115{
 116        trcm->stopped = 1;
 117}
 118
 119#ifdef FWTRC
 120extern void dc_flush(void *data);
 121#else
 122#define dc_flush(data)
 123#endif
 124
 125
 126static inline void
 127__bfa_trc(struct bfa_trc_mod_s *trcm, int fileno, int line, u64 data)
 128{
 129        int             tail = trcm->tail;
 130        struct bfa_trc_s        *trc = &trcm->trc[tail];
 131
 132        if (trcm->stopped)
 133                return;
 134
 135        trc->fileno = (u16) fileno;
 136        trc->line = (u16) line;
 137        trc->data.u64 = data;
 138        trc->timestamp = BFA_TRC_TS(trcm);
 139        dc_flush(trc);
 140
 141        trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
 142        if (trcm->tail == trcm->head)
 143                trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
 144        dc_flush(trcm);
 145}
 146
 147
 148static inline void
 149__bfa_trc32(struct bfa_trc_mod_s *trcm, int fileno, int line, u32 data)
 150{
 151        int             tail = trcm->tail;
 152        struct bfa_trc_s *trc = &trcm->trc[tail];
 153
 154        if (trcm->stopped)
 155                return;
 156
 157        trc->fileno = (u16) fileno;
 158        trc->line = (u16) line;
 159        trc->data.u32.u32 = data;
 160        trc->timestamp = BFA_TRC_TS(trcm);
 161        dc_flush(trc);
 162
 163        trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
 164        if (trcm->tail == trcm->head)
 165                trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
 166        dc_flush(trcm);
 167}
 168
 169#ifndef BFA_PERF_BUILD
 170#define bfa_trc_fp(_trcp, _data)        bfa_trc(_trcp, _data)
 171#else
 172#define bfa_trc_fp(_trcp, _data)
 173#endif
 174
 175#endif /* __BFA_TRC_H__ */
 176
 177