1 /*+M*************************************************************************
2 * Adaptec AIC7xxx device driver proc support for Linux.
4 * Copyright (c) 1995, 1996 Dean W. Gehnert
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)
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.
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.
20 * ----------------------------------------------------------------
21 * o Modified from the EATA-DMA /proc support.
22 * o Additional support for device block statistics provided by
24 * o Correction of overflow by Heinz Mauelshagen
25 * o Adittional corrections by Doug Ledford
27 * Dean W. Gehnert, deang@teleport.com, 05/01/96
29 * $Id: aic7xxx_proc.c,v 4.1 1997/06/97 08:23:42 deang Exp $
30 *-M*************************************************************************/
32 #include <linux/config.h>
34 #define BLS (&aic7xxx_buffer[size])
36 " < 2K 2K+ 4K+ 8K+ 16K+ 32K+ 64K+ 128K+"
39 extern int vsprintf(char *, const char *, va_list);
42 proc_debug(const char *fmt
, ...)
48 vsprintf(buf
, fmt
, ap
);
52 #else /* PROC_DEBUG */
53 # define proc_debug(fmt, args...)
54 #endif /* PROC_DEBUG */
56 static int aic7xxx_buffer_size
= 0;
57 static char *aic7xxx_buffer
= NULL
;
60 /*+F*************************************************************************
65 * Set parameters for the driver from the /proc filesystem.
66 *-F*************************************************************************/
68 aic7xxx_set_info(char *buffer
, int length
, struct Scsi_Host
*HBAptr
)
70 proc_debug("aic7xxx_set_info(): %s\n", buffer
);
71 return (-ENOSYS
); /* Currently this is a no-op */
75 /*+F*************************************************************************
80 * Return information to handle /proc support for the driver.
81 *-F*************************************************************************/
83 aic7xxx_proc_info ( char *buffer
, char **start
, off_t offset
, int length
,
84 int hostno
, int inout
)
86 struct Scsi_Host
*HBAptr
;
87 struct aic7xxx_host
*p
;
90 struct aic7xxx_xferstats
*sp
;
95 for(p
=first_aic7xxx
; p
->host
->host_no
!= hostno
; p
=p
->next
)
100 size
+= sprintf(buffer
, "Can't find adapter for host number %d\n", hostno
);
113 if (inout
== TRUE
) /* Has data been written to the file? */
115 return (aic7xxx_set_info(buffer
, length
, HBAptr
));
118 p
= (struct aic7xxx_host
*) HBAptr
->hostdata
;
121 * It takes roughly 1K of space to hold all relevant card info, not
122 * counting any proc stats, so we start out with a 1.5k buffer size and
123 * if proc_stats is defined, then we sweep the stats structure to see
124 * how many drives we will be printing out for and add 384 bytes per
125 * device with active stats.
127 * Hmmmm...that 1.5k seems to keep growing as items get added so they
128 * can be easily viewed for debugging purposes. So, we bumped that
129 * 1.5k to 4k so we can quit having to bump it all the time.
133 for (target
= 0; target
< MAX_TARGETS
; target
++)
135 if (p
->dev_flags
[target
] & DEVICE_PRESENT
)
136 #ifdef AIC7XXX_PROC_STATS
142 if (aic7xxx_buffer_size
!= size
)
144 if (aic7xxx_buffer
!= NULL
)
146 kfree(aic7xxx_buffer
);
147 aic7xxx_buffer_size
= 0;
149 aic7xxx_buffer
= kmalloc(size
, GFP_KERNEL
);
151 if (aic7xxx_buffer
== NULL
)
153 size
= sprintf(buffer
, "AIC7xxx - kmalloc error at line %d\n",
157 aic7xxx_buffer_size
= size
;
160 size
+= sprintf(BLS
, "Adaptec AIC7xxx driver version: ");
161 size
+= sprintf(BLS
, "%s/", AIC7XXX_C_VERSION
);
162 size
+= sprintf(BLS
, "%s", AIC7XXX_H_VERSION
);
163 size
+= sprintf(BLS
, "\n");
164 size
+= sprintf(BLS
, "Compile Options:\n");
165 #ifdef CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT
166 size
+= sprintf(BLS
, " TCQ Enabled By Default : Enabled\n");
168 size
+= sprintf(BLS
, " TCQ Enabled By Default : Disabled\n");
170 #ifdef AIC7XXX_PROC_STATS
171 size
+= sprintf(BLS
, " AIC7XXX_PROC_STATS : Enabled\n");
173 size
+= sprintf(BLS
, " AIC7XXX_PROC_STATS : Disabled\n");
175 size
+= sprintf(BLS
, " AIC7XXX_RESET_DELAY : %d\n", AIC7XXX_RESET_DELAY
);
176 size
+= sprintf(BLS
, "\n");
177 size
+= sprintf(BLS
, "Adapter Configuration:\n");
178 size
+= sprintf(BLS
, " SCSI Adapter: %s\n",
179 board_names
[p
->board_name_index
]);
180 if (p
->flags
& AHC_TWIN
)
181 size
+= sprintf(BLS
, " Twin Channel\n");
186 char *wide
= "Narrow ";
187 if (p
->flags
& AHC_MULTI_CHANNEL
)
189 channel
= " Channel A";
190 if (p
->flags
& (AHC_CHNLB
|AHC_CHNLC
))
191 channel
= (p
->flags
& AHC_CHNLB
) ? " Channel B" : " Channel C";
193 if (p
->features
& AHC_WIDE
)
195 if (p
->features
& AHC_ULTRA3
)
197 switch(p
->chip
& AHC_CHIPID_MASK
)
201 ultra
= "Ultra-160/m LVD/SE ";
204 ultra
= "Ultra-3 LVD/SE ";
208 else if (p
->features
& AHC_ULTRA2
)
209 ultra
= "Ultra-2 LVD/SE ";
210 else if (p
->features
& AHC_ULTRA
)
212 size
+= sprintf(BLS
, " %s%sController%s\n",
213 ultra
, wide
, channel
);
217 size
+= sprintf(BLS
, " Programmed I/O Base: %lx\n", p
->base
);
221 size
+= sprintf(BLS
, " PCI MMAPed I/O Base: 0x%lx\n", p
->mbase
);
223 if( (p
->chip
& (AHC_VL
| AHC_EISA
)) )
225 size
+= sprintf(BLS
, " BIOS Memory Address: 0x%08x\n", p
->bios_address
);
227 size
+= sprintf(BLS
, " Adapter SEEPROM Config: %s\n",
228 (p
->flags
& AHC_SEEPROM_FOUND
) ? "SEEPROM found and used." :
229 ((p
->flags
& AHC_USEDEFAULTS
) ? "SEEPROM not found, using defaults." :
230 "SEEPROM not found, using leftover BIOS values.") );
231 size
+= sprintf(BLS
, " Adaptec SCSI BIOS: %s\n",
232 (p
->flags
& AHC_BIOS_ENABLED
) ? "Enabled" : "Disabled");
233 size
+= sprintf(BLS
, " IRQ: %d\n", HBAptr
->irq
);
234 size
+= sprintf(BLS
, " SCBs: Active %d, Max Active %d,\n",
235 p
->activescbs
, p
->max_activescbs
);
236 size
+= sprintf(BLS
, " Allocated %d, HW %d, "
237 "Page %d\n", p
->scb_data
->numscbs
, p
->scb_data
->maxhscbs
,
238 p
->scb_data
->maxscbs
);
239 if (p
->flags
& AHC_EXTERNAL_SRAM
)
240 size
+= sprintf(BLS
, " Using External SCB SRAM\n");
241 size
+= sprintf(BLS
, " Interrupts: %ld", p
->isr_count
);
242 if (p
->chip
& AHC_EISA
)
244 size
+= sprintf(BLS
, " %s\n",
245 (p
->pause
& IRQMS
) ? "(Level Sensitive)" : "(Edge Triggered)");
249 size
+= sprintf(BLS
, "\n");
251 size
+= sprintf(BLS
, " BIOS Control Word: 0x%04x\n",
253 size
+= sprintf(BLS
, " Adapter Control Word: 0x%04x\n",
255 size
+= sprintf(BLS
, " Extended Translation: %sabled\n",
256 (p
->flags
& AHC_EXTEND_TRANS_A
) ? "En" : "Dis");
257 size
+= sprintf(BLS
, "Disconnect Enable Flags: 0x%04x\n", p
->discenable
);
258 if (p
->features
& (AHC_ULTRA
| AHC_ULTRA2
))
260 size
+= sprintf(BLS
, " Ultra Enable Flags: 0x%04x\n", p
->ultraenb
);
262 size
+= sprintf(BLS
, " Tag Queue Enable Flags: 0x%04x\n", p
->tagenable
);
263 size
+= sprintf(BLS
, "Ordered Queue Tag Flags: 0x%04x\n", p
->orderedtag
);
264 size
+= sprintf(BLS
, "Default Tag Queue Depth: %d\n", AIC7XXX_CMDS_PER_DEVICE
);
265 size
+= sprintf(BLS
, " Tagged Queue By Device array for aic7xxx host "
266 "instance %d:\n", p
->instance
);
267 size
+= sprintf(BLS
, " {");
268 for(i
=0; i
< (MAX_TARGETS
- 1); i
++)
269 size
+= sprintf(BLS
, "%d,",aic7xxx_tag_info
[p
->instance
].tag_commands
[i
]);
270 size
+= sprintf(BLS
, "%d}\n",aic7xxx_tag_info
[p
->instance
].tag_commands
[i
]);
271 size
+= sprintf(BLS
, " Actual queue depth per device for aic7xxx host "
272 "instance %d:\n", p
->instance
);
273 size
+= sprintf(BLS
, " {");
274 for(i
=0; i
< (MAX_TARGETS
- 1); i
++)
275 size
+= sprintf(BLS
, "%d,", p
->dev_max_queue_depth
[i
]);
276 size
+= sprintf(BLS
, "%d}\n", p
->dev_max_queue_depth
[i
]);
278 size
+= sprintf(BLS
, "\n");
279 size
+= sprintf(BLS
, "Statistics:\n\n");
280 for (target
= 0; target
< MAX_TARGETS
; target
++)
282 sp
= &p
->stats
[target
];
283 if ((p
->dev_flags
[target
] & DEVICE_PRESENT
) == 0)
287 if (p
->features
& AHC_TWIN
)
289 size
+= sprintf(BLS
, "(scsi%d:%d:%d:%d)\n",
290 p
->host_no
, (target
>> 3), (target
& 0x7), 0);
294 size
+= sprintf(BLS
, "(scsi%d:%d:%d:%d)\n",
295 p
->host_no
, 0, target
, 0);
297 size
+= sprintf(BLS
, " Device using %s/%s",
298 (p
->transinfo
[target
].cur_width
== MSG_EXT_WDTR_BUS_16_BIT
) ?
300 (p
->transinfo
[target
].cur_offset
!= 0) ?
301 "Sync transfers at " : "Async transfers.\n" );
302 if (p
->transinfo
[target
].cur_offset
!= 0)
304 struct aic7xxx_syncrate
*sync_rate
;
305 unsigned char options
= p
->transinfo
[target
].cur_options
;
306 int period
= p
->transinfo
[target
].cur_period
;
307 int rate
= (p
->transinfo
[target
].cur_width
==
308 MSG_EXT_WDTR_BUS_16_BIT
) ? 1 : 0;
310 sync_rate
= aic7xxx_find_syncrate(p
, &period
, 0, &options
);
311 if (sync_rate
!= NULL
)
313 size
+= sprintf(BLS
, "%s MByte/sec, offset %d\n",
314 sync_rate
->rate
[rate
],
315 p
->transinfo
[target
].cur_offset
);
319 size
+= sprintf(BLS
, "3.3 MByte/sec, offset %d\n",
320 p
->transinfo
[target
].cur_offset
);
323 size
+= sprintf(BLS
, " Transinfo settings: ");
324 size
+= sprintf(BLS
, "current(%d/%d/%d/%d), ",
325 p
->transinfo
[target
].cur_period
,
326 p
->transinfo
[target
].cur_offset
,
327 p
->transinfo
[target
].cur_width
,
328 p
->transinfo
[target
].cur_options
);
329 size
+= sprintf(BLS
, "goal(%d/%d/%d/%d), ",
330 p
->transinfo
[target
].goal_period
,
331 p
->transinfo
[target
].goal_offset
,
332 p
->transinfo
[target
].goal_width
,
333 p
->transinfo
[target
].goal_options
);
334 size
+= sprintf(BLS
, "user(%d/%d/%d/%d)\n",
335 p
->transinfo
[target
].user_period
,
336 p
->transinfo
[target
].user_offset
,
337 p
->transinfo
[target
].user_width
,
338 p
->transinfo
[target
].user_options
);
339 #ifdef AIC7XXX_PROC_STATS
340 size
+= sprintf(BLS
, " Total transfers %ld (%ld reads and %ld writes)\n",
341 sp
->r_total
+ sp
->w_total
, sp
->r_total
, sp
->w_total
);
342 size
+= sprintf(BLS
, "%s\n", HDRB
);
343 size
+= sprintf(BLS
, " Reads:");
344 for (i
= 0; i
< NUMBER(sp
->r_bins
); i
++)
346 size
+= sprintf(BLS
, " %7ld", sp
->r_bins
[i
]);
348 size
+= sprintf(BLS
, "\n");
349 size
+= sprintf(BLS
, " Writes:");
350 for (i
= 0; i
< NUMBER(sp
->w_bins
); i
++)
352 size
+= sprintf(BLS
, " %7ld", sp
->w_bins
[i
]);
354 size
+= sprintf(BLS
, "\n");
356 size
+= sprintf(BLS
, " Total transfers %ld (%ld reads and %ld writes)\n",
357 sp
->r_total
+ sp
->w_total
, sp
->r_total
, sp
->w_total
);
358 #endif /* AIC7XXX_PROC_STATS */
359 size
+= sprintf(BLS
, "\n\n");
362 if (size
>= aic7xxx_buffer_size
)
364 printk(KERN_WARNING
"aic7xxx: Overflow in aic7xxx_proc.c\n");
367 if (offset
> size
- 1)
369 kfree(aic7xxx_buffer
);
370 aic7xxx_buffer
= NULL
;
371 aic7xxx_buffer_size
= length
= 0;
376 *start
= &aic7xxx_buffer
[offset
]; /* Start of wanted data */
377 if (size
- offset
< length
)
379 length
= size
- offset
;
387 * Overrides for Emacs so that we follow Linus's tabbing style.
388 * Emacs will notice this stuff at the end of the file and automatically
389 * adjust the settings for this buffer only. This must remain at the end
391 * ---------------------------------------------------------------------------
394 * c-brace-imaginary-offset: 0
396 * c-argdecl-indent: 2
398 * c-continued-statement-offset: 2
399 * c-continued-brace-offset: 0
400 * indent-tabs-mode: nil