Annotation of Gnu-Mach/i386/i386at/gpl/linux/scsi/aic7xxx_proc.src, revision 1.1

1.1     ! root        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, [email protected], 08/30/95
        !            26:  *
        !            27:  *  $Id: aic7xxx_proc.src,v 1.1.1.1 1997/02/25 21:27:47 thomas 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, ...)
        !            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)
        !            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, 
        !            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 *bus_name[] = {"Single", "Twin", "Wide"};
        !            86: 
        !            87:   HBAptr = NULL;
        !            88:   for (i = 0; i < NUMBER(aic7xxx_boards); i++)
        !            89:   {
        !            90:     if ((HBAptr = aic7xxx_boards[i]) != NULL)
        !            91:     {
        !            92:       if (HBAptr->host_no == hostno)
        !            93:       {
        !            94:         break;
        !            95:       }
        !            96: 
        !            97:       while ((HBAptr->hostdata != NULL) &&
        !            98:           ((HBAptr = ((struct aic7xxx_host *) HBAptr->hostdata)->next) != NULL))
        !            99:       {
        !           100:         if (HBAptr->host_no == hostno)
        !           101:         {
        !           102:           break; break;
        !           103:         }
        !           104:       }
        !           105: 
        !           106:       HBAptr = NULL;
        !           107:     }
        !           108:   }
        !           109: 
        !           110:   if (HBAptr == NULL)
        !           111:   {
        !           112:     size += sprintf(BLS, "Can't find adapter for host number %d\n", hostno);
        !           113:     len += size; pos = begin + len; size = 0;
        !           114:     goto stop_output;
        !           115:   }
        !           116: 
        !           117:   if (inout == TRUE) /* Has data been written to the file? */ 
        !           118:   {
        !           119:     return (aic7xxx_set_info(buffer, length, HBAptr));
        !           120:   }
        !           121: 
        !           122:   if (offset == 0)
        !           123:   {
        !           124:     memset(buff, 0, sizeof(buff));
        !           125:   }
        !           126: 
        !           127:   p = (struct aic7xxx_host *) HBAptr->hostdata;
        !           128: 
        !           129:   size += sprintf(BLS, "Adaptec AIC7xxx driver version: ");
        !           130:   size += sprintf(BLS, "%s/", rcs_version(AIC7XXX_C_VERSION));
        !           131:   size += sprintf(BLS, "%s/", rcs_version(AIC7XXX_H_VERSION));
        !           132:   size += sprintf(BLS, "%s\n", rcs_version(AIC7XXX_SEQ_VER));
        !           133:   len += size; pos = begin + len; size = 0;
        !           134: 
        !           135:   size += sprintf(BLS, "\n");
        !           136:   size += sprintf(BLS, "Compile Options:\n");
        !           137: #ifdef AIC7XXX_RESET_DELAY
        !           138:   size += sprintf(BLS, "  AIC7XXX_RESET_DELAY    : %d\n", AIC7XXX_RESET_DELAY);
        !           139: #endif
        !           140: #ifdef AIC7XXX_TWIN_SUPPORT
        !           141:   size += sprintf(BLS, "  AIC7XXX_TWIN_SUPPORT   : Enabled\n");
        !           142: #else
        !           143:   size += sprintf(BLS, "  AIC7XXX_TWIN_SUPPORT   : Disabled\n");
        !           144: #endif
        !           145: #ifdef AIC7XXX_TAGGED_QUEUEING
        !           146:   size += sprintf(BLS, "  AIC7XXX_TAGGED_QUEUEING: Enabled\n");
        !           147: #else
        !           148:   size += sprintf(BLS, "  AIC7XXX_TAGGED_QUEUEING: Disabled\n");
        !           149: #endif
        !           150: #ifdef AIC7XXX_SHARE_IRQS
        !           151:   size += sprintf(BLS, "  AIC7XXX_SHARE_IRQS     : Enabled\n");
        !           152: #else
        !           153:   size += sprintf(BLS, "  AIC7XXX_SHARE_IRQS     : Disabled\n");
        !           154: #endif
        !           155: #ifdef AIC7XXX_PROC_STATS
        !           156:   size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Enabled\n");
        !           157: #else
        !           158:   size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Disabled\n");
        !           159: #endif
        !           160:   len += size; pos = begin + len; size = 0;
        !           161: 
        !           162:   size += sprintf(BLS, "\n");
        !           163:   size += sprintf(BLS, "Adapter Configuration:\n");
        !           164:   size += sprintf(BLS, "          SCSI Adapter: %s\n", board_names[p->type]);
        !           165:   size += sprintf(BLS, "              Host Bus: %s\n", bus_name[p->bus_type]);
        !           166:   size += sprintf(BLS, "               Base IO: %#.4x\n", p->base);
        !           167:   size += sprintf(BLS, "                   IRQ: %d\n", HBAptr->irq);
        !           168:   size += sprintf(BLS, "                   SCB: %d (%d)\n", p->numscb, p->maxscb);
        !           169:   size += sprintf(BLS, "            Interrupts: %d", p->isr_count);
        !           170:   if (p->chip_type == AIC_777x)
        !           171:   {
        !           172:     size += sprintf(BLS, " %s\n",
        !           173:         (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)");
        !           174:   }
        !           175:   else
        !           176:   {
        !           177:     size += sprintf(BLS, "\n");
        !           178:   }
        !           179:   size += sprintf(BLS, "         Serial EEPROM: %s\n",
        !           180:       p->have_seeprom ? "True" : "False");
        !           181:   size += sprintf(BLS, "         Pause/Unpause: %#.2x/%#.2x\n", p->pause,
        !           182:       p->unpause);
        !           183:   size += sprintf(BLS, "  Extended Translation: %sabled\n",
        !           184:       p->extended ? "En" : "Dis");
        !           185:   size += sprintf(BLS, "        SCSI Bus Reset: %sabled\n",
        !           186:       aic7xxx_no_reset ? "Dis" : "En");
        !           187:   size += sprintf(BLS, "            Ultra SCSI: %sabled\n",
        !           188:       p->ultra_enabled ? "En" : "Dis");
        !           189:   len += size; pos = begin + len; size = 0;
        !           190: 
        !           191: #ifdef AIC7XXX_PROC_STATS
        !           192:   {
        !           193:     struct aic7xxx_xferstats *sp;
        !           194:     int channel, target, lun;
        !           195: 
        !           196:     /*
        !           197:      * XXX: Need to fix this to avoid overflow...
        !           198:      */
        !           199:     size += sprintf(BLS, "\n");
        !           200:     size += sprintf(BLS, "Statistics:\n");
        !           201:     for (channel = 0; channel < 2; channel++)
        !           202:     {
        !           203:       for (target = 0; target < 16; target++)
        !           204:       {
        !           205:         for (lun = 0; lun < 8; lun++)
        !           206:         {
        !           207:           sp = &p->stats[channel][target][lun];
        !           208:           if (sp->xfers == 0)
        !           209:           {
        !           210:             continue;
        !           211:           }
        !           212:           size += sprintf(BLS, "CHAN#%c (TGT %d LUN %d):\n",
        !           213:               'A' + channel, target, lun);
        !           214:           size += sprintf(BLS, "nxfers %ld (%ld read;%ld written)\n",
        !           215:               sp->xfers, sp->r_total, sp->w_total);
        !           216:           size += sprintf(BLS, "blks(512) rd=%ld; blks(512) wr=%ld\n",
        !           217:               sp->r_total512, sp->w_total512);
        !           218:           size += sprintf(BLS, "%s\n", HDRB);
        !           219:           size += sprintf(BLS, " Reads:");
        !           220:           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->r_bins[0],
        !           221:               sp->r_bins[1], sp->r_bins[2], sp->r_bins[3]);
        !           222:           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->r_bins[4],
        !           223:               sp->r_bins[5], sp->r_bins[6], sp->r_bins[7]);
        !           224:           size += sprintf(BLS, "%6ld %6ld\n", sp->r_bins[8],
        !           225:               sp->r_bins[9]);
        !           226:           size += sprintf(BLS, "Writes:");
        !           227:           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->w_bins[0],
        !           228:               sp->w_bins[1], sp->w_bins[2], sp->w_bins[3]);
        !           229:           size += sprintf(BLS, "%6ld %6ld %6ld %6ld ", sp->w_bins[4],
        !           230:               sp->w_bins[5], sp->w_bins[6], sp->w_bins[7]);
        !           231:           size += sprintf(BLS, "%6ld %6ld\n", sp->w_bins[8],
        !           232:               sp->w_bins[9]);
        !           233:           size += sprintf(BLS, "\n");
        !           234:         }
        !           235:       }
        !           236:     }
        !           237:     len += size; pos = begin + len; size = 0;
        !           238:   }
        !           239: #endif /* AIC7XXX_PROC_STATS */
        !           240: 
        !           241: stop_output:
        !           242:   proc_debug("2pos: %ld offset: %ld len: %d\n", pos, offset, len);
        !           243:   *start = buffer + (offset - begin);   /* Start of wanted data */
        !           244:   len -= (offset - begin);      /* Start slop */
        !           245:   if (len > length)
        !           246:   {
        !           247:     len = length;               /* Ending slop */
        !           248:   }
        !           249:   proc_debug("3pos: %ld offset: %ld len: %d\n", pos, offset, len);
        !           250:   
        !           251:   return (len);     
        !           252: }
        !           253: 
        !           254: /*
        !           255:  * Overrides for Emacs so that we follow Linus's tabbing style.
        !           256:  * Emacs will notice this stuff at the end of the file and automatically
        !           257:  * adjust the settings for this buffer only.  This must remain at the end
        !           258:  * of the file.
        !           259:  * ---------------------------------------------------------------------------
        !           260:  * Local variables:
        !           261:  * c-indent-level: 2
        !           262:  * c-brace-imaginary-offset: 0
        !           263:  * c-brace-offset: -2
        !           264:  * c-argdecl-indent: 2
        !           265:  * c-label-offset: -2
        !           266:  * c-continued-statement-offset: 2
        !           267:  * c-continued-brace-offset: 0
        !           268:  * indent-tabs-mode: nil
        !           269:  * tab-width: 8
        !           270:  * End:
        !           271:  */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.