| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (c) 2000-2001 Adaptec Inc. | 
|  | 3 | * All rights reserved. | 
|  | 4 | * | 
|  | 5 | * Redistribution and use in source and binary forms, with or without | 
|  | 6 | * modification, are permitted provided that the following conditions | 
|  | 7 | * are met: | 
|  | 8 | * 1. Redistributions of source code must retain the above copyright | 
|  | 9 | *    notice, this list of conditions, and the following disclaimer, | 
|  | 10 | *    without modification. | 
|  | 11 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
|  | 12 | *    substantially similar to the "NO WARRANTY" disclaimer below | 
|  | 13 | *    ("Disclaimer") and any redistribution must be conditioned upon | 
|  | 14 | *    including a substantially similar Disclaimer requirement for further | 
|  | 15 | *    binary redistribution. | 
|  | 16 | * 3. Neither the names of the above-listed copyright holders nor the names | 
|  | 17 | *    of any contributors may be used to endorse or promote products derived | 
|  | 18 | *    from this software without specific prior written permission. | 
|  | 19 | * | 
|  | 20 | * Alternatively, this software may be distributed under the terms of the | 
|  | 21 | * GNU General Public License ("GPL") version 2 as published by the Free | 
|  | 22 | * Software Foundation. | 
|  | 23 | * | 
|  | 24 | * NO WARRANTY | 
|  | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
|  | 26 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
|  | 27 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
|  | 28 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
|  | 29 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|  | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|  | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|  | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
|  | 33 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
|  | 34 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|  | 35 | * POSSIBILITY OF SUCH DAMAGES. | 
|  | 36 | * | 
|  | 37 | * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr> | 
|  | 38 | * sym driver. | 
|  | 39 | * | 
|  | 40 | * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#29 $ | 
|  | 41 | */ | 
|  | 42 | #include "aic7xxx_osm.h" | 
|  | 43 | #include "aic7xxx_inline.h" | 
|  | 44 | #include "aic7xxx_93cx6.h" | 
|  | 45 |  | 
|  | 46 | static void	copy_mem_info(struct info_str *info, char *data, int len); | 
|  | 47 | static int	copy_info(struct info_str *info, char *fmt, ...); | 
|  | 48 | static void	ahc_dump_target_state(struct ahc_softc *ahc, | 
|  | 49 | struct info_str *info, | 
|  | 50 | u_int our_id, char channel, | 
|  | 51 | u_int target_id, u_int target_offset); | 
|  | 52 | static void	ahc_dump_device_state(struct info_str *info, | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 53 | struct scsi_device *dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | static int	ahc_proc_write_seeprom(struct ahc_softc *ahc, | 
|  | 55 | char *buffer, int length); | 
|  | 56 |  | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 57 | /* | 
|  | 58 | * Table of syncrates that don't follow the "divisible by 4" | 
|  | 59 | * rule. This table will be expanded in future SCSI specs. | 
|  | 60 | */ | 
| Denys Vlasenko | 980b306 | 2008-04-25 04:36:01 +0200 | [diff] [blame] | 61 | static const struct { | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 62 | u_int period_factor; | 
|  | 63 | u_int period;	/* in 100ths of ns */ | 
|  | 64 | } scsi_syncrates[] = { | 
|  | 65 | { 0x08, 625 },	/* FAST-160 */ | 
|  | 66 | { 0x09, 1250 },	/* FAST-80 */ | 
|  | 67 | { 0x0a, 2500 },	/* FAST-40 40MHz */ | 
|  | 68 | { 0x0b, 3030 },	/* FAST-40 33MHz */ | 
|  | 69 | { 0x0c, 5000 }	/* FAST-20 */ | 
|  | 70 | }; | 
|  | 71 |  | 
|  | 72 | /* | 
|  | 73 | * Return the frequency in kHz corresponding to the given | 
|  | 74 | * sync period factor. | 
|  | 75 | */ | 
|  | 76 | static u_int | 
|  | 77 | ahc_calc_syncsrate(u_int period_factor) | 
|  | 78 | { | 
|  | 79 | int i; | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 80 |  | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 81 | /* See if the period is in the "exception" table */ | 
| Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 82 | for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) { | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 83 |  | 
|  | 84 | if (period_factor == scsi_syncrates[i].period_factor) { | 
|  | 85 | /* Period in kHz */ | 
|  | 86 | return (100000000 / scsi_syncrates[i].period); | 
|  | 87 | } | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | /* | 
|  | 91 | * Wasn't in the table, so use the standard | 
|  | 92 | * 4 times conversion. | 
|  | 93 | */ | 
|  | 94 | return (10000000 / (period_factor * 4 * 10)); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | static void | 
|  | 99 | copy_mem_info(struct info_str *info, char *data, int len) | 
|  | 100 | { | 
|  | 101 | if (info->pos + len > info->offset + info->length) | 
|  | 102 | len = info->offset + info->length - info->pos; | 
|  | 103 |  | 
|  | 104 | if (info->pos + len < info->offset) { | 
|  | 105 | info->pos += len; | 
|  | 106 | return; | 
|  | 107 | } | 
|  | 108 |  | 
|  | 109 | if (info->pos < info->offset) { | 
|  | 110 | off_t partial; | 
|  | 111 |  | 
|  | 112 | partial = info->offset - info->pos; | 
|  | 113 | data += partial; | 
|  | 114 | info->pos += partial; | 
|  | 115 | len  -= partial; | 
|  | 116 | } | 
|  | 117 |  | 
|  | 118 | if (len > 0) { | 
|  | 119 | memcpy(info->buffer, data, len); | 
|  | 120 | info->pos += len; | 
|  | 121 | info->buffer += len; | 
|  | 122 | } | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | static int | 
|  | 126 | copy_info(struct info_str *info, char *fmt, ...) | 
|  | 127 | { | 
|  | 128 | va_list args; | 
|  | 129 | char buf[256]; | 
|  | 130 | int len; | 
|  | 131 |  | 
|  | 132 | va_start(args, fmt); | 
|  | 133 | len = vsprintf(buf, fmt, args); | 
|  | 134 | va_end(args); | 
|  | 135 |  | 
|  | 136 | copy_mem_info(info, buf, len); | 
|  | 137 | return (len); | 
|  | 138 | } | 
|  | 139 |  | 
| Denys Vlasenko | d1d7b19 | 2008-04-25 04:34:49 +0200 | [diff] [blame] | 140 | static void | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) | 
|  | 142 | { | 
|  | 143 | u_int speed; | 
|  | 144 | u_int freq; | 
|  | 145 | u_int mb; | 
|  | 146 |  | 
|  | 147 | speed = 3300; | 
|  | 148 | freq = 0; | 
|  | 149 | if (tinfo->offset != 0) { | 
| Christoph Hellwig | 1ff9273 | 2005-08-19 18:57:13 +0200 | [diff] [blame] | 150 | freq = ahc_calc_syncsrate(tinfo->period); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | speed = freq; | 
|  | 152 | } | 
|  | 153 | speed *= (0x01 << tinfo->width); | 
|  | 154 | mb = speed / 1000; | 
|  | 155 | if (mb > 0) | 
|  | 156 | copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000); | 
|  | 157 | else | 
|  | 158 | copy_info(info, "%dKB/s transfers", speed); | 
|  | 159 |  | 
|  | 160 | if (freq != 0) { | 
|  | 161 | copy_info(info, " (%d.%03dMHz%s, offset %d", | 
|  | 162 | freq / 1000, freq % 1000, | 
|  | 163 | (tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0 | 
|  | 164 | ? " DT" : "", tinfo->offset); | 
|  | 165 | } | 
|  | 166 |  | 
|  | 167 | if (tinfo->width > 0) { | 
|  | 168 | if (freq != 0) { | 
|  | 169 | copy_info(info, ", "); | 
|  | 170 | } else { | 
|  | 171 | copy_info(info, " ("); | 
|  | 172 | } | 
|  | 173 | copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width)); | 
|  | 174 | } else if (freq != 0) { | 
|  | 175 | copy_info(info, ")"); | 
|  | 176 | } | 
|  | 177 | copy_info(info, "\n"); | 
|  | 178 | } | 
|  | 179 |  | 
|  | 180 | static void | 
|  | 181 | ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info, | 
|  | 182 | u_int our_id, char channel, u_int target_id, | 
|  | 183 | u_int target_offset) | 
|  | 184 | { | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 185 | struct	scsi_target *starget; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | struct	ahc_initiator_tinfo *tinfo; | 
|  | 187 | struct	ahc_tmode_tstate *tstate; | 
|  | 188 | int	lun; | 
|  | 189 |  | 
|  | 190 | tinfo = ahc_fetch_transinfo(ahc, channel, our_id, | 
|  | 191 | target_id, &tstate); | 
|  | 192 | if ((ahc->features & AHC_TWIN) != 0) | 
|  | 193 | copy_info(info, "Channel %c ", channel); | 
|  | 194 | copy_info(info, "Target %d Negotiation Settings\n", target_id); | 
|  | 195 | copy_info(info, "\tUser: "); | 
|  | 196 | ahc_format_transinfo(info, &tinfo->user); | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 197 | starget = ahc->platform_data->starget[target_offset]; | 
| James Bottomley | c0df28c | 2005-06-25 16:23:44 -0500 | [diff] [blame] | 198 | if (!starget) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | return; | 
|  | 200 |  | 
|  | 201 | copy_info(info, "\tGoal: "); | 
|  | 202 | ahc_format_transinfo(info, &tinfo->goal); | 
|  | 203 | copy_info(info, "\tCurr: "); | 
|  | 204 | ahc_format_transinfo(info, &tinfo->curr); | 
|  | 205 |  | 
|  | 206 | for (lun = 0; lun < AHC_NUM_LUNS; lun++) { | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 207 | struct scsi_device *sdev; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 |  | 
| Hannes Reinecke | 9080063 | 2006-10-23 15:25:36 +0200 | [diff] [blame] | 209 | sdev = scsi_device_lookup_by_target(starget, lun); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 |  | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 211 | if (sdev == NULL) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | continue; | 
|  | 213 |  | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 214 | ahc_dump_device_state(info, sdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | static void | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 219 | ahc_dump_device_state(struct info_str *info, struct scsi_device *sdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | { | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 221 | struct ahc_linux_device *dev = scsi_transport_device_data(sdev); | 
|  | 222 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", | 
| James Bottomley | b1abb4d | 2005-05-24 17:15:43 -0500 | [diff] [blame] | 224 | sdev->sdev_target->channel + 'A', | 
|  | 225 | sdev->sdev_target->id, sdev->lun); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 |  | 
|  | 227 | copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); | 
|  | 228 | copy_info(info, "\t\tCommands Active %d\n", dev->active); | 
|  | 229 | copy_info(info, "\t\tCommand Openings %d\n", dev->openings); | 
|  | 230 | copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags); | 
|  | 231 | copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); | 
|  | 232 | } | 
|  | 233 |  | 
|  | 234 | static int | 
|  | 235 | ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length) | 
|  | 236 | { | 
|  | 237 | struct seeprom_descriptor sd; | 
|  | 238 | int have_seeprom; | 
|  | 239 | u_long s; | 
|  | 240 | int paused; | 
|  | 241 | int written; | 
|  | 242 |  | 
|  | 243 | /* Default to failure. */ | 
|  | 244 | written = -EINVAL; | 
|  | 245 | ahc_lock(ahc, &s); | 
|  | 246 | paused = ahc_is_paused(ahc); | 
|  | 247 | if (!paused) | 
|  | 248 | ahc_pause(ahc); | 
|  | 249 |  | 
|  | 250 | if (length != sizeof(struct seeprom_config)) { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 251 | printk("ahc_proc_write_seeprom: incorrect buffer size\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | goto done; | 
|  | 253 | } | 
|  | 254 |  | 
|  | 255 | have_seeprom = ahc_verify_cksum((struct seeprom_config*)buffer); | 
|  | 256 | if (have_seeprom == 0) { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 257 | printk("ahc_proc_write_seeprom: cksum verification failed\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | goto done; | 
|  | 259 | } | 
|  | 260 |  | 
|  | 261 | sd.sd_ahc = ahc; | 
|  | 262 | #if AHC_PCI_CONFIG > 0 | 
|  | 263 | if ((ahc->chip & AHC_PCI) != 0) { | 
|  | 264 | sd.sd_control_offset = SEECTL; | 
|  | 265 | sd.sd_status_offset = SEECTL; | 
|  | 266 | sd.sd_dataout_offset = SEECTL; | 
|  | 267 | if (ahc->flags & AHC_LARGE_SEEPROM) | 
|  | 268 | sd.sd_chip = C56_66; | 
|  | 269 | else | 
|  | 270 | sd.sd_chip = C46; | 
|  | 271 | sd.sd_MS = SEEMS; | 
|  | 272 | sd.sd_RDY = SEERDY; | 
|  | 273 | sd.sd_CS = SEECS; | 
|  | 274 | sd.sd_CK = SEECK; | 
|  | 275 | sd.sd_DO = SEEDO; | 
|  | 276 | sd.sd_DI = SEEDI; | 
|  | 277 | have_seeprom = ahc_acquire_seeprom(ahc, &sd); | 
|  | 278 | } else | 
|  | 279 | #endif | 
|  | 280 | if ((ahc->chip & AHC_VL) != 0) { | 
|  | 281 | sd.sd_control_offset = SEECTL_2840; | 
|  | 282 | sd.sd_status_offset = STATUS_2840; | 
|  | 283 | sd.sd_dataout_offset = STATUS_2840; | 
|  | 284 | sd.sd_chip = C46; | 
|  | 285 | sd.sd_MS = 0; | 
|  | 286 | sd.sd_RDY = EEPROM_TF; | 
|  | 287 | sd.sd_CS = CS_2840; | 
|  | 288 | sd.sd_CK = CK_2840; | 
|  | 289 | sd.sd_DO = DO_2840; | 
|  | 290 | sd.sd_DI = DI_2840; | 
|  | 291 | have_seeprom = TRUE; | 
|  | 292 | } else { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 293 | printk("ahc_proc_write_seeprom: unsupported adapter type\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | goto done; | 
|  | 295 | } | 
|  | 296 |  | 
|  | 297 | if (!have_seeprom) { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 298 | printk("ahc_proc_write_seeprom: No Serial EEPROM\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | goto done; | 
|  | 300 | } else { | 
|  | 301 | u_int start_addr; | 
|  | 302 |  | 
|  | 303 | if (ahc->seep_config == NULL) { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 304 | ahc->seep_config = kmalloc(sizeof(*ahc->seep_config), GFP_ATOMIC); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | if (ahc->seep_config == NULL) { | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 306 | printk("aic7xxx: Unable to allocate serial " | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | "eeprom buffer.  Write failing\n"); | 
|  | 308 | goto done; | 
|  | 309 | } | 
|  | 310 | } | 
| Pekka Enberg | 48813cf | 2010-07-14 13:12:57 +0300 | [diff] [blame] | 311 | printk("aic7xxx: Writing Serial EEPROM\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | start_addr = 32 * (ahc->channel - 'A'); | 
|  | 313 | ahc_write_seeprom(&sd, (u_int16_t *)buffer, start_addr, | 
|  | 314 | sizeof(struct seeprom_config)/2); | 
|  | 315 | ahc_read_seeprom(&sd, (uint16_t *)ahc->seep_config, | 
|  | 316 | start_addr, sizeof(struct seeprom_config)/2); | 
|  | 317 | #if AHC_PCI_CONFIG > 0 | 
|  | 318 | if ((ahc->chip & AHC_VL) == 0) | 
|  | 319 | ahc_release_seeprom(&sd); | 
|  | 320 | #endif | 
|  | 321 | written = length; | 
|  | 322 | } | 
|  | 323 |  | 
|  | 324 | done: | 
|  | 325 | if (!paused) | 
|  | 326 | ahc_unpause(ahc); | 
|  | 327 | ahc_unlock(ahc, &s); | 
|  | 328 | return (written); | 
|  | 329 | } | 
|  | 330 |  | 
|  | 331 | /* | 
|  | 332 | * Return information to handle /proc support for the driver. | 
|  | 333 | */ | 
|  | 334 | int | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, | 
|  | 336 | off_t offset, int length, int inout) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { | 
| Christoph Hellwig | 3d65692 | 2005-06-11 00:14:30 +0200 | [diff] [blame] | 338 | struct	ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | struct	info_str info; | 
|  | 340 | char	ahc_info[256]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | u_int	max_targ; | 
|  | 342 | u_int	i; | 
|  | 343 | int	retval; | 
|  | 344 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | /* Has data been written to the file? */ | 
|  | 346 | if (inout == TRUE) { | 
|  | 347 | retval = ahc_proc_write_seeprom(ahc, buffer, length); | 
|  | 348 | goto done; | 
|  | 349 | } | 
|  | 350 |  | 
|  | 351 | if (start) | 
|  | 352 | *start = buffer; | 
|  | 353 |  | 
|  | 354 | info.buffer	= buffer; | 
|  | 355 | info.length	= length; | 
|  | 356 | info.offset	= offset; | 
|  | 357 | info.pos	= 0; | 
|  | 358 |  | 
|  | 359 | copy_info(&info, "Adaptec AIC7xxx driver version: %s\n", | 
|  | 360 | AIC7XXX_DRIVER_VERSION); | 
|  | 361 | copy_info(&info, "%s\n", ahc->description); | 
|  | 362 | ahc_controller_info(ahc, ahc_info); | 
|  | 363 | copy_info(&info, "%s\n", ahc_info); | 
|  | 364 | copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", | 
|  | 365 | ahc->scb_data->numscbs, AHC_NSEG); | 
|  | 366 |  | 
|  | 367 |  | 
|  | 368 | if (ahc->seep_config == NULL) | 
|  | 369 | copy_info(&info, "No Serial EEPROM\n"); | 
|  | 370 | else { | 
|  | 371 | copy_info(&info, "Serial EEPROM:\n"); | 
|  | 372 | for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) { | 
|  | 373 | if (((i % 8) == 0) && (i != 0)) { | 
|  | 374 | copy_info(&info, "\n"); | 
|  | 375 | } | 
|  | 376 | copy_info(&info, "0x%.4x ", | 
|  | 377 | ((uint16_t*)ahc->seep_config)[i]); | 
|  | 378 | } | 
|  | 379 | copy_info(&info, "\n"); | 
|  | 380 | } | 
|  | 381 | copy_info(&info, "\n"); | 
|  | 382 |  | 
| Hannes Reinecke | 9080063 | 2006-10-23 15:25:36 +0200 | [diff] [blame] | 383 | max_targ = 16; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) | 
| Hannes Reinecke | 9080063 | 2006-10-23 15:25:36 +0200 | [diff] [blame] | 385 | max_targ = 8; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 |  | 
| Hannes Reinecke | 9080063 | 2006-10-23 15:25:36 +0200 | [diff] [blame] | 387 | for (i = 0; i < max_targ; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | u_int our_id; | 
|  | 389 | u_int target_id; | 
|  | 390 | char channel; | 
|  | 391 |  | 
|  | 392 | channel = 'A'; | 
|  | 393 | our_id = ahc->our_id; | 
|  | 394 | target_id = i; | 
|  | 395 | if (i > 7 && (ahc->features & AHC_TWIN) != 0) { | 
|  | 396 | channel = 'B'; | 
|  | 397 | our_id = ahc->our_id_b; | 
|  | 398 | target_id = i % 8; | 
|  | 399 | } | 
|  | 400 |  | 
|  | 401 | ahc_dump_target_state(ahc, &info, our_id, | 
|  | 402 | channel, target_id, i); | 
|  | 403 | } | 
|  | 404 | retval = info.pos > info.offset ? info.pos - info.offset : 0; | 
|  | 405 | done: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | return (retval); | 
|  | 407 | } |