root/drivers/scsi/aic7xxx_proc.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. proc_debug
  2. aic7xxx_set_info
  3. aic7xxx_proc_info

   1 /*+M*************************************************************************
   2  * Adaptec 274x/284x/294x device driver proc support for Linux.
   3  *
   4  * Copyright (c) 1995 Dean W. Gehnert
   5  *
   6  * This program is free software; you can redistribute it and/or modify
   7  * it under the terms of the GNU General Public License as published by
   8  * the Free Software Foundation; either version 2, or (at your option)
   9  * any later version.
  10  *
  11  * This program is distributed in the hope that it will be useful,
  12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  * GNU General Public License for more details.
  15  *
  16  * You should have received a copy of the GNU General Public License
  17  * along with this program; see the file COPYING.  If not, write to
  18  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19  *
  20  * ----------------------------------------------------------------
  21  *  o Modified from the EATA /proc support.
  22  *  o Additional support for device block statistics provided by
  23  *    Matthew Jacob.
  24  *
  25  *  Dean W. Gehnert, deang@ims.com, 08/30/95
  26  *
  27  *  $Id: aic7xxx_proc.c,v 2.2 1995/09/12 05:24:37 deang Exp $
  28  *-M*************************************************************************/
  29 
  30 #define BLS buffer + len + size
  31 #define HDRB \
  32 "        < 512 512-1K   1-2K   2-4K   4-8K  8-16K 16-32K 32-64K 64-128K >128K"
  33 
  34 #ifdef PROC_DEBUG
  35 extern int vsprintf(char *, const char *, va_list);
  36 
  37 static void
  38 proc_debug(const char *fmt, ...)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40   va_list ap;
  41   char buf[256];
  42 
  43   va_start(ap, fmt);
  44   vsprintf(buf, fmt, ap);
  45   printk(buf);
  46   va_end(ap);
  47 }
  48 #else /* PROC_DEBUG */
  49 #  define proc_debug(fmt, args...)
  50 #endif /* PROC_DEBUG */
  51 
  52 /*+F*************************************************************************
  53  * Function:
  54  *   aic7xxx_set_info
  55  *
  56  * Description:
  57  *   Set parameters for the driver from the /proc filesystem.
  58  *-F*************************************************************************/
  59 int
  60 aic7xxx_set_info(char *buffer, int length, struct Scsi_Host *HBAptr)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62   proc_debug("aic7xxx_set_info(): %s\n", buffer);
  63   return (-ENOSYS);  /* Currently this is a no-op */
  64 }
  65 
  66 /*+F*************************************************************************
  67  * Function:
  68  *   aic7xxx_proc_info
  69  *
  70  * Description:
  71  *   Return information to handle /proc support for the driver.
  72  *-F*************************************************************************/
  73 int
  74 aic7xxx_proc_info(char *buffer, char **start, off_t offset, int length, 
     /* [previous][next][first][last][top][bottom][index][help] */
  75     int hostno, int inout)
  76 {
  77   struct Scsi_Host *HBAptr;
  78   struct aic7xxx_host *p;
  79   static u8 buff[512];
  80   int   i; 
  81   int   size = 0;
  82   int   len = 0;
  83   off_t begin = 0;
  84   off_t pos = 0;
  85   static char *board_name[] = {"None", "274x", "284x", "7870", "7850", "7872"};
  86   static char *bus_name[] = {"Single", "Twin", "Wide"};
  87 
  88   HBAptr = NULL;
  89   for (i = 0; i < NUMBER(aic7xxx_boards); i++)
  90   {
  91     if ((HBAptr = aic7xxx_boards[i]) != NULL)
  92     {
  93       if (HBAptr->host_no == hostno)
  94       {
  95         break;
  96       }
  97 
  98       while ((HBAptr->hostdata != NULL) &&
  99           ((HBAptr = ((struct aic7xxx_host *) HBAptr->hostdata)->next) != NULL))
 100       {
 101         if (HBAptr->host_no == hostno)
 102         {
 103           break; break;
 104         }
 105       }
 106 
 107       HBAptr = NULL;
 108     }
 109   }
 110 
 111   if (HBAptr == NULL)
 112   {
 113     size += sprintf(BLS, "Can't find adapter for host number %d\n", hostno);
 114     len += size; pos = begin + len; size = 0;
 115     goto stop_output;
 116   }
 117 
 118   if (inout == TRUE) /* Has data been written to the file? */ 
 119   {
 120     return (aic7xxx_set_info(buffer, length, HBAptr));
 121   }
 122 
 123   if (offset == 0)
 124   {
 125     memset(buff, 0, sizeof(buff));
 126   }
 127 
 128   p = (struct aic7xxx_host *) HBAptr->hostdata;
 129 
 130   size += sprintf(BLS, "Adaptec AIC7xxx driver version: ");
 131   size += sprintf(BLS, "%s/", rcs_version(AIC7XXX_C_VERSION));
 132   size += sprintf(BLS, "%s/", rcs_version(AIC7XXX_H_VERSION));
 133   size += sprintf(BLS, "%s\n", rcs_version(AIC7XXX_SEQ_VER));
 134   len += size; pos = begin + len; size = 0;
 135 
 136   size += sprintf(BLS, "\n");
 137   size += sprintf(BLS, "Compile Options:\n");
 138 #ifdef AIC7XXX_RESET_DELAY
 139   size += sprintf(BLS, "  AIC7XXX_RESET_DELAY    : %d\n", AIC7XXX_RESET_DELAY);
 140 #endif
 141 #ifdef AIC7XXX_TWIN_SUPPORT
 142   size += sprintf(BLS, "  AIC7XXX_TWIN_SUPPORT   : Enabled\n");
 143 #else
 144   size += sprintf(BLS, "  AIC7XXX_TWIN_SUPPORT   : Disabled\n");
 145 #endif
 146 #ifdef AIC7XXX_TAGGED_QUEUEING
 147   size += sprintf(BLS, "  AIC7XXX_TAGGED_QUEUEING: Enabled\n");
 148 #else
 149   size += sprintf(BLS, "  AIC7XXX_TAGGED_QUEUEING: Disabled\n");
 150 #endif
 151 #ifdef AIC7XXX_SHARE_IRQS
 152   size += sprintf(BLS, "  AIC7XXX_SHARE_IRQS     : Enabled\n");
 153 #else
 154   size += sprintf(BLS, "  AIC7XXX_SHARE_IRQS     : Disabled\n");
 155 #endif
 156 #ifdef AIC7XXX_PROC_STATS
 157   size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Enabled\n");
 158 #else
 159   size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Disabled\n");
 160 #endif
 161 #ifdef AIC7XXX_POLL
 162   size += sprintf(BLS, "  AIC7XXX_POLL           : Enabled\n");
 163 #else
 164   size += sprintf(BLS, "  AIC7XXX_POLL           : Disabled\n");
 165 #endif
 166   len += size; pos = begin + len; size = 0;
 167 
 168   size += sprintf(BLS, "\n");
 169   size += sprintf(BLS, "Adapter Configuration:\n");
 170   size += sprintf(BLS, "          SCSI Adapter: %s\n", board_name[p->type]);
 171   size += sprintf(BLS, "              Host Bus: %s\n", bus_name[p->bus_type]);
 172   size += sprintf(BLS, "               Base IO: %#.4x\n", p->base);
 173   size += sprintf(BLS, "                   IRQ: %d\n", HBAptr->irq);
 174   size += sprintf(BLS, "                   SCB: %d (%d)\n", p->numscb, p->maxscb);
 175   size += sprintf(BLS, "            Interrupts: %d", p->isr_count);
 176   if ((p->type == AIC_274x) || (p->type == AIC_284x))
 177   {
 178     size += sprintf(BLS, " %s\n",
 179         (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)");
 180   }
 181   else
 182   {
 183     size += sprintf(BLS, "\n");
 184   }
 185   size += sprintf(BLS, "         Serial EEPROM: %s\n",
 186       p->have_seeprom ? "True" : "False");
 187   size += sprintf(BLS, "         Pause/Unpause: %#.2x/%#.2x\n", p->pause,
 188       p->unpause);
 189   size += sprintf(BLS, "  Extended Translation: %sabled\n",
 190       p->extended ? "En" : "Dis");
 191   size += sprintf(BLS, "        SCSI Bus Reset: %sabled\n",
 192       aic7xxx_no_reset ? "Dis" : "En");
 193   len += size; pos = begin + len; size = 0;
 194 
 195 #ifdef AIC7XXX_PROC_STATS
 196   {
 197     struct aic7xxx_xferstats *sp;
 198     int channel, target, lun;
 199 
 200     /*
 201      * XXX: Need to fix this to avoid overflow...
 202      */
 203     size += sprintf(BLS, "\n");
 204     size += sprintf(BLS, "Statistics:\n");
 205     for (channel = 0; channel < 2; channel++)
 206     {
 207       for (target = 0; target < 16; target++)
 208       {
 209         for (lun = 0; lun < 8; lun++)
 210         {
 211           sp = &p->stats[channel][target][lun];
 212           if (sp->xfers == 0)
 213           {
 214             continue;
 215           }
 216           size += sprintf(BLS, "CHAN#%c (TGT %d LUN %d):\n",
 217               'A' + channel, target, lun);
 218           size += sprintf(BLS, "nxfers %ld (%ld read;%ld written)\n",
 219               sp->xfers, sp->r_total, sp->w_total);
 220           size += sprintf(BLS, "blks(512) rd=%ld; blks(512) wr=%ld\n",
 221               sp->r_total512, sp->w_total512);
 222           size += sprintf(BLS, "%s\n", HDRB);
 223           size += sprintf(BLS, " Reads:");
 224           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->r_bins[0],
 225               sp->r_bins[1], sp->r_bins[2], sp->r_bins[3]);
 226           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->r_bins[4],
 227               sp->r_bins[5], sp->r_bins[6], sp->r_bins[7]);
 228           size += sprintf(BLS, "%6ld %6ld\n", sp->r_bins[8],
 229               sp->r_bins[9]);
 230           size += sprintf(BLS, "Writes:");
 231           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->w_bins[0],
 232               sp->w_bins[1], sp->w_bins[2], sp->w_bins[3]);
 233           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->w_bins[4],
 234               sp->w_bins[5], sp->w_bins[6], sp->w_bins[7]);
 235           size += sprintf(BLS, "%6ld %6ld\n", sp->w_bins[8],
 236               sp->w_bins[9]);
 237           size += sprintf(BLS, "\n");
 238         }
 239       }
 240     }
 241     len += size; pos = begin + len; size = 0;
 242   }
 243 #endif /* AIC7XXX_PROC_STATS */
 244 
 245 stop_output:
 246   proc_debug("2pos: %ld offset: %ld len: %d\n", pos, offset, len);
 247   *start = buffer + (offset - begin);   /* Start of wanted data */
 248   len -= (offset - begin);      /* Start slop */
 249   if (len > length)
 250   {
 251     len = length;               /* Ending slop */
 252   }
 253   proc_debug("3pos: %ld offset: %ld len: %d\n", pos, offset, len);
 254   
 255   return (len);     
 256 }
 257 
 258 /*
 259  * Overrides for Emacs so that we follow Linus's tabbing style.
 260  * Emacs will notice this stuff at the end of the file and automatically
 261  * adjust the settings for this buffer only.  This must remain at the end
 262  * of the file.
 263  * ---------------------------------------------------------------------------
 264  * Local variables:
 265  * c-indent-level: 2
 266  * c-brace-imaginary-offset: 0
 267  * c-brace-offset: -2
 268  * c-argdecl-indent: 2
 269  * c-label-offset: -2
 270  * c-continued-statement-offset: 2
 271  * c-continued-brace-offset: 0
 272  * indent-tabs-mode: nil
 273  * tab-width: 8
 274  * End:
 275  */

/* [previous][next][first][last][top][bottom][index][help] */