OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [scsi/] [aic7xxx_proc.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*+M*************************************************************************
2
 * Adaptec AIC7xxx device driver proc support for Linux.
3
 *
4
 * Copyright (c) 1995, 1996 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-DMA /proc support.
22
 *  o Additional support for device block statistics provided by
23
 *    Matthew Jacob.
24
 *  o Correction of overflow by Heinz Mauelshagen
25
 *  o Adittional corrections by Doug Ledford
26
 *
27
 *  Dean W. Gehnert, deang@teleport.com, 05/01/96
28
 *
29
 *  $Id: aic7xxx_proc.c,v 1.1 2005-12-20 10:17:45 jcastillo Exp $
30
 *-M*************************************************************************/
31
 
32
#define BLS     (&aic7xxx_buffer[size])
33
#define HDRB \
34
"             < 2K      2K+     4K+     8K+    16K+    32K+    64K+   128K+"
35
 
36
#ifdef PROC_DEBUG
37
extern int vsprintf(char *, const char *, va_list);
38
 
39
static void
40
proc_debug(const char *fmt, ...)
41
{
42
  va_list ap;
43
  char buf[256];
44
 
45
  va_start(ap, fmt);
46
  vsprintf(buf, fmt, ap);
47
  printk(buf);
48
  va_end(ap);
49
}
50
#else /* PROC_DEBUG */
51
#  define proc_debug(fmt, args...)
52
#endif /* PROC_DEBUG */
53
 
54
static int aic7xxx_buffer_size = 0;
55
static char *aic7xxx_buffer = NULL;
56
 
57
 
58
/*+F*************************************************************************
59
 * Function:
60
 *   aic7xxx_set_info
61
 *
62
 * Description:
63
 *   Set parameters for the driver from the /proc filesystem.
64
 *-F*************************************************************************/
65
int
66
aic7xxx_set_info(char *buffer, int length, struct Scsi_Host *HBAptr)
67
{
68
  proc_debug("aic7xxx_set_info(): %s\n", buffer);
69
  return (-ENOSYS);  /* Currently this is a no-op */
70
}
71
 
72
 
73
/*+F*************************************************************************
74
 * Function:
75
 *   aic7xxx_proc_info
76
 *
77
 * Description:
78
 *   Return information to handle /proc support for the driver.
79
 *-F*************************************************************************/
80
int
81
aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length,
82
                    int hostno, int inout)
83
{
84
  struct Scsi_Host *HBAptr;
85
  struct aic7xxx_host *p;
86
  int    size = 0;
87
  unsigned char i;
88
  struct aic7xxx_xferstats *sp;
89
  unsigned char target;
90
 
91
  HBAptr = NULL;
92
 
93
  for(p=first_aic7xxx; p->host->host_no != hostno; p=p->next)
94
    ;
95
 
96
  if (!p)
97
  {
98
    size += sprintf(buffer, "Can't find adapter for host number %d\n", hostno);
99
    if (size > length)
100
    {
101
      return (size);
102
    }
103
    else
104
    {
105
      return (length);
106
    }
107
  }
108
 
109
  HBAptr = p->host;
110
 
111
  if (inout == TRUE) /* Has data been written to the file? */
112
  {
113
    return (aic7xxx_set_info(buffer, length, HBAptr));
114
  }
115
 
116
  p = (struct aic7xxx_host *) HBAptr->hostdata;
117
 
118
  /*
119
   * It takes roughly 1K of space to hold all relevant card info, not
120
   * counting any proc stats, so we start out with a 1.5k buffer size and
121
   * if proc_stats is defined, then we sweep the stats structure to see
122
   * how many drives we will be printing out for and add 384 bytes per
123
   * device with active stats.
124
   *
125
   * Hmmmm...that 1.5k seems to keep growing as items get added so they
126
   * can be easily viewed for debugging purposes.  So, we bumped that
127
   * 1.5k to 4k so we can quit having to bump it all the time.
128
   */
129
 
130
  size = 4096;
131
  for (target = 0; target < MAX_TARGETS; target++)
132
  {
133
    if (p->dev_flags[target] & DEVICE_PRESENT)
134
#ifdef AIC7XXX_PROC_STATS
135
      size += 512;
136
#else
137
      size += 256;
138
#endif
139
  }
140
  if (aic7xxx_buffer_size != size)
141
  {
142
    if (aic7xxx_buffer != NULL)
143
    {
144
      kfree(aic7xxx_buffer);
145
      aic7xxx_buffer_size = 0;
146
    }
147
    aic7xxx_buffer = kmalloc(size, GFP_KERNEL);
148
  }
149
  if (aic7xxx_buffer == NULL)
150
  {
151
    size = sprintf(buffer, "AIC7xxx - kmalloc error at line %d\n",
152
        __LINE__);
153
    return size;
154
  }
155
  aic7xxx_buffer_size = size;
156
 
157
  size = 0;
158
  size += sprintf(BLS, "Adaptec AIC7xxx driver version: ");
159
  size += sprintf(BLS, "%s/", AIC7XXX_C_VERSION);
160
  size += sprintf(BLS, "%s", AIC7XXX_H_VERSION);
161
  size += sprintf(BLS, "\n");
162
  size += sprintf(BLS, "Compile Options:\n");
163
#ifdef CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT
164
  size += sprintf(BLS, "  TCQ Enabled By Default : Enabled\n");
165
#else
166
  size += sprintf(BLS, "  TCQ Enabled By Default : Disabled\n");
167
#endif
168
#ifdef AIC7XXX_PROC_STATS
169
  size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Enabled\n");
170
#else
171
  size += sprintf(BLS, "  AIC7XXX_PROC_STATS     : Disabled\n");
172
#endif
173
  size += sprintf(BLS, "  AIC7XXX_RESET_DELAY    : %d\n", AIC7XXX_RESET_DELAY);
174
  size += sprintf(BLS, "\n");
175
  size += sprintf(BLS, "Adapter Configuration:\n");
176
  size += sprintf(BLS, "           SCSI Adapter: %s\n",
177
      board_names[p->board_name_index]);
178
  if (p->flags & AHC_TWIN)
179
    size += sprintf(BLS, "                         Twin Channel\n");
180
  else
181
  {
182
    char *channel = "";
183
    char *ultra = "";
184
    char *wide = "Narrow ";
185
    if (p->flags & AHC_MULTI_CHANNEL)
186
    {
187
      channel = " Channel A";
188
      if (p->flags & (AHC_CHNLB|AHC_CHNLC))
189
        channel = (p->flags & AHC_CHNLB) ? " Channel B" : " Channel C";
190
    }
191
    if (p->features & AHC_WIDE)
192
      wide = "Wide ";
193
    if (p->features & AHC_ULTRA2)
194
      ultra = "Ultra2-LVD/SE ";
195
    else if (p->features & AHC_ULTRA)
196
      ultra = "Ultra ";
197
    size += sprintf(BLS, "                           %s%sController%s\n",
198
      ultra, wide, channel);
199
  }
200
  if( !(p->maddr) )
201
  {
202
    size += sprintf(BLS, "    Programmed I/O Base: %lx\n", p->base);
203
  }
204
  else
205
  {
206
    size += sprintf(BLS, "    PCI MMAPed I/O Base: 0x%lx\n", p->mbase);
207
  }
208
  if( (p->chip & (AHC_VL | AHC_EISA)) )
209
  {
210
    size += sprintf(BLS, "    BIOS Memory Address: 0x%08x\n", p->bios_address);
211
  }
212
  size += sprintf(BLS, " Adapter SEEPROM Config: %s\n",
213
          (p->flags & AHC_SEEPROM_FOUND) ? "SEEPROM found and used." :
214
         ((p->flags & AHC_USEDEFAULTS) ? "SEEPROM not found, using defaults." :
215
           "SEEPROM not found, using leftover BIOS values.") );
216
  size += sprintf(BLS, "      Adaptec SCSI BIOS: %s\n",
217
          (p->flags & AHC_BIOS_ENABLED) ? "Enabled" : "Disabled");
218
  size += sprintf(BLS, "                    IRQ: %d\n", HBAptr->irq);
219
  size += sprintf(BLS, "                   SCBs: Active %d, Max Active %d,\n",
220
            p->activescbs, p->max_activescbs);
221
  size += sprintf(BLS, "                         Allocated %d, HW %d, "
222
            "Page %d\n", p->scb_data->numscbs, p->scb_data->maxhscbs,
223
            p->scb_data->maxscbs);
224
  if (p->flags & AHC_EXTERNAL_SRAM)
225
    size += sprintf(BLS, "                         Using External SCB SRAM\n");
226
  size += sprintf(BLS, "             Interrupts: %ld", p->isr_count);
227
  if (p->chip & AHC_EISA)
228
  {
229
    size += sprintf(BLS, " %s\n",
230
        (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)");
231
  }
232
  else
233
  {
234
    size += sprintf(BLS, "\n");
235
  }
236
  size += sprintf(BLS, "      BIOS Control Word: 0x%04x\n",
237
            p->bios_control);
238
  size += sprintf(BLS, "   Adapter Control Word: 0x%04x\n",
239
            p->adapter_control);
240
  size += sprintf(BLS, "   Extended Translation: %sabled\n",
241
      (p->flags & AHC_EXTEND_TRANS_A) ? "En" : "Dis");
242
  size += sprintf(BLS, "Disconnect Enable Flags: 0x%04x\n", p->discenable);
243
  if (p->features & (AHC_ULTRA | AHC_ULTRA2))
244
  {
245
    size += sprintf(BLS, "     Ultra Enable Flags: 0x%04x\n", p->ultraenb);
246
  }
247
  size += sprintf(BLS, " Tag Queue Enable Flags: 0x%04x\n", p->tagenable);
248
  size += sprintf(BLS, "Ordered Queue Tag Flags: 0x%04x\n", p->orderedtag);
249
  size += sprintf(BLS, "Default Tag Queue Depth: %d\n", AIC7XXX_CMDS_PER_DEVICE);
250
  size += sprintf(BLS, "    Tagged Queue By Device array for aic7xxx host "
251
                       "instance %d:\n", p->instance);
252
  size += sprintf(BLS, "      {");
253
  for(i=0; i < (MAX_TARGETS - 1); i++)
254
    size += sprintf(BLS, "%d,",aic7xxx_tag_info[p->instance].tag_commands[i]);
255
  size += sprintf(BLS, "%d}\n",aic7xxx_tag_info[p->instance].tag_commands[i]);
256
  size += sprintf(BLS, "    Actual queue depth per device for aic7xxx host "
257
                       "instance %d:\n", p->instance);
258
  size += sprintf(BLS, "      {");
259
  for(i=0; i < (MAX_TARGETS - 1); i++)
260
    size += sprintf(BLS, "%d,", p->dev_max_queue_depth[i]);
261
  size += sprintf(BLS, "%d}\n", p->dev_max_queue_depth[i]);
262
 
263
  size += sprintf(BLS, "\n");
264
  size += sprintf(BLS, "Statistics:\n\n");
265
  for (target = 0; target < MAX_TARGETS; target++)
266
  {
267
    sp = &p->stats[target];
268
    if ((p->dev_flags[target] & DEVICE_PRESENT) == 0)
269
    {
270
      continue;
271
    }
272
    if (p->features & AHC_TWIN)
273
    {
274
      size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n",
275
          p->host_no, (target >> 3), (target & 0x7), 0);
276
    }
277
    else
278
    {
279
      size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n",
280
          p->host_no, 0, target, 0);
281
    }
282
    size += sprintf(BLS, "  Device using %s/%s",
283
          (p->transinfo[target].cur_width == MSG_EXT_WDTR_BUS_16_BIT) ?
284
          "Wide" : "Narrow",
285
          (p->transinfo[target].cur_offset != 0) ?
286
          "Sync transfers at " : "Async transfers.\n" );
287
    if (p->transinfo[target].cur_offset != 0)
288
    {
289
      struct aic7xxx_syncrate *sync_rate;
290
      int period = p->transinfo[target].cur_period;
291
      int rate = (p->transinfo[target].cur_width ==
292
                  MSG_EXT_WDTR_BUS_16_BIT) ? 1 : 0;
293
 
294
      sync_rate = aic7xxx_find_syncrate(p, &period, AHC_SYNCRATE_ULTRA2);
295
      if (sync_rate != NULL)
296
      {
297
        size += sprintf(BLS, "%s MByte/sec, offset %d\n",
298
                        sync_rate->rate[rate],
299
                        p->transinfo[target].cur_offset );
300
      }
301
      else
302
      {
303
        size += sprintf(BLS, "3.3 MByte/sec, offset %d\n",
304
                        p->transinfo[target].cur_offset );
305
      }
306
    }
307
    size += sprintf(BLS, "  Transinfo settings: ");
308
    size += sprintf(BLS, "current(%d/%d/%d), ",
309
                    p->transinfo[target].cur_period,
310
                    p->transinfo[target].cur_offset,
311
                    p->transinfo[target].cur_width);
312
    size += sprintf(BLS, "goal(%d/%d/%d), ",
313
                    p->transinfo[target].goal_period,
314
                    p->transinfo[target].goal_offset,
315
                    p->transinfo[target].goal_width);
316
    size += sprintf(BLS, "user(%d/%d/%d)\n",
317
                    p->transinfo[target].user_period,
318
                    p->transinfo[target].user_offset,
319
                    p->transinfo[target].user_width);
320
#ifdef AIC7XXX_PROC_STATS
321
    size += sprintf(BLS, "  Total transfers %ld (%ld reads and %ld writes)\n",
322
        sp->r_total + sp->w_total, sp->r_total, sp->w_total);
323
    size += sprintf(BLS, "%s\n", HDRB);
324
    size += sprintf(BLS, "   Reads:");
325
    for (i = 0; i < NUMBER(sp->r_bins); i++)
326
    {
327
      size += sprintf(BLS, " %7ld", sp->r_bins[i]);
328
    }
329
    size += sprintf(BLS, "\n");
330
    size += sprintf(BLS, "  Writes:");
331
    for (i = 0; i < NUMBER(sp->w_bins); i++)
332
    {
333
      size += sprintf(BLS, " %7ld", sp->w_bins[i]);
334
    }
335
    size += sprintf(BLS, "\n");
336
#else
337
    size += sprintf(BLS, "  Total transfers %ld (%ld reads and %ld writes)\n",
338
        sp->r_total + sp->w_total, sp->r_total, sp->w_total);
339
#endif /* AIC7XXX_PROC_STATS */
340
    size += sprintf(BLS, "\n\n");
341
  }
342
 
343
  if (size >= aic7xxx_buffer_size)
344
  {
345
    printk(KERN_WARNING "aic7xxx: Overflow in aic7xxx_proc.c\n");
346
  }
347
 
348
  if (offset > size - 1)
349
  {
350
    kfree(aic7xxx_buffer);
351
    aic7xxx_buffer = NULL;
352
    aic7xxx_buffer_size = length = 0;
353
    *start = NULL;
354
  }
355
  else
356
  {
357
    *start = &aic7xxx_buffer[offset];   /* Start of wanted data */
358
    if (size - offset < length)
359
    {
360
      length = size - offset;
361
    }
362
  }
363
 
364
  return (length);
365
}
366
 
367
/*
368
 * Overrides for Emacs so that we follow Linus's tabbing style.
369
 * Emacs will notice this stuff at the end of the file and automatically
370
 * adjust the settings for this buffer only.  This must remain at the end
371
 * of the file.
372
 * ---------------------------------------------------------------------------
373
 * Local variables:
374
 * c-indent-level: 2
375
 * c-brace-imaginary-offset: 0
376
 * c-brace-offset: -2
377
 * c-argdecl-indent: 2
378
 * c-label-offset: -2
379
 * c-continued-statement-offset: 2
380
 * c-continued-brace-offset: 0
381
 * indent-tabs-mode: nil
382
 * tab-width: 8
383
 * End:
384
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.