root/drivers/scsi/eata_dma_proc.c

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

DEFINITIONS

This source file includes following definitions.
  1. swap_statistics
  2. eata_set_info
  3. eata_proc_info

   1 
   2 #define MAX_SCSI_DEVICE_CODE 10
   3 const char *const scsi_dev_types[MAX_SCSI_DEVICE_CODE] =
   4 {
   5     "Direct-Access    ",
   6     "Sequential-Access",
   7     "Printer          ",
   8     "Processor        ",
   9     "WORM             ",
  10     "CD-ROM           ",
  11     "Scanner          ",
  12     "Optical Device   ",
  13     "Medium Changer   ",
  14     "Communications   "
  15 };
  16 
  17 
  18 void swap_statistics(u8 *p)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20     u32 y;
  21     u32 *lp, h_lp;
  22     u16 *sp, h_sp;
  23     u8 *bp;
  24     
  25     lp = (u32 *)p;
  26     sp = ((short *)lp) + 1;         /* Convert Header */
  27     h_sp = *sp = ntohs(*sp);
  28     lp++;
  29 
  30     do {
  31         sp = (u16 *)lp;           /* Convert SubHeader */
  32     *sp = ntohs(*sp);
  33     bp = (u8 *) lp;
  34     y = *(bp + 3);
  35     lp++;
  36     for (h_lp = (u32)lp; (u32)lp < h_lp + ((u32)*(bp + 3)); lp++)
  37         *lp = ntohl(*lp);
  38     }while ((u32)lp < ((u32)p) + 4 + h_sp);
  39 
  40 }
  41 
  42 /*
  43  * eata_set_info
  44  * buffer : pointer to the data that has been written to the hostfile
  45  * length : number of bytes written to the hostfile
  46  * HBA_ptr: pointer to the Scsi_Host struct
  47  */
  48 int eata_set_info(char *buffer, int length, struct Scsi_Host *HBA_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50     if (length >= 8 && strncmp(buffer, "eata_dma", 8) == 0) {
  51         buffer += 9;
  52         length -= 9;
  53         if(length >= 8 && strncmp(buffer, "latency", 7) == 0) {
  54             SD(HBA_ptr)->do_latency = TRUE;
  55             return(length+9);
  56         } 
  57         
  58         if(length >=10 && strncmp(buffer, "nolatency", 9) == 0) {
  59             SD(HBA_ptr)->do_latency = FALSE;
  60             return(length+9);
  61         } 
  62         
  63         printk("Unknown command:%s length: %d\n", buffer, length);
  64     } else 
  65         printk("Wrong Signature:%10s\n", (char *) ((ulong)buffer-9));
  66     
  67     return(-EINVAL);
  68 }
  69 
  70 /*
  71  * eata_proc_info
  72  * inout : decides on the direction of the dataflow and the meaning of the 
  73  *         variables
  74  * buffer: If inout==FALSE data is beeing written to it else read from it
  75  * *start: If inout==FALSE start of the valid data in the buffer
  76  * offset: If inout==FALSE offset from the beginning of the imaginary file 
  77  *         from which we start writing into the buffer
  78  * length: If inout==FALSE max number of bytes to be written into the buffer 
  79  *         else number of bytes in the buffer
  80  */
  81 int eata_proc_info(char *buffer, char **start, off_t offset, int length, 
     /* [previous][next][first][last][top][bottom][index][help] */
  82                    int hostno, int inout)
  83 {
  84 
  85     Scsi_Device *scd;
  86     struct Scsi_Host *HBA_ptr;
  87     Scsi_Cmnd scmd;
  88     static u8 buff[512];
  89     static u8 buff2[512];
  90     hst_cmd_stat *rhcs, *whcs;
  91     coco         *cc;
  92     scsitrans    *st;
  93     scsimod      *sm;
  94     hobu         *hb;
  95     scbu         *sb;
  96     boty         *bt;
  97     memco        *mc;
  98     firm         *fm;
  99     subinf       *si; 
 100     pcinf        *pi;
 101     arrlim       *al;
 102     int i, x; 
 103     int   size, len = 0;
 104     off_t begin = 0;
 105     off_t pos = 0;
 106 
 107     HBA_ptr = first_HBA;
 108     for (i = 1; i <= registered_HBAs; i++) {
 109         if (HBA_ptr->host_no == hostno)
 110             break;
 111         HBA_ptr = SD(HBA_ptr)->next;
 112     }        
 113 
 114     if(inout == TRUE) /* Has data been writen to the file ? */ 
 115         return(eata_set_info(buffer, length, HBA_ptr));
 116 
 117     if (offset == 0)
 118         memset(buff, 0, sizeof(buff));
 119 
 120     cc = (coco *)     (buff + 0x148);
 121     st = (scsitrans *)(buff + 0x164); 
 122     sm = (scsimod *)  (buff + 0x16c);
 123     hb = (hobu *)     (buff + 0x172);
 124     sb = (scbu *)     (buff + 0x178);
 125     bt = (boty *)     (buff + 0x17e);
 126     mc = (memco *)    (buff + 0x186);
 127     fm = (firm *)     (buff + 0x18e);
 128     si = (subinf *)   (buff + 0x196); 
 129     pi = (pcinf *)    (buff + 0x19c);
 130     al = (arrlim *)   (buff + 0x1a2);
 131 
 132     size = sprintf(buffer+len, "EATA (Extended Attachment) driver version: "
 133                    "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
 134     len += size; pos = begin + len;
 135     size = sprintf(buffer + len, "queued commands:     %10ld\n"
 136                    "processed interrupts:%10ld\n", queue_counter, int_counter);
 137     len += size; pos = begin + len;
 138 
 139     size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
 140                    HBA_ptr->host_no, SD(HBA_ptr)->name);
 141     len += size; 
 142     pos = begin + len;
 143     size = sprintf(buffer + len, "Firmware revision: v%s\n", 
 144                    SD(HBA_ptr)->revision);
 145     len += size;
 146     pos = begin + len;
 147     size = sprintf(buffer + len, "Hardware Configuration:\n");
 148     len += size; 
 149     pos = begin + len;
 150     
 151     if(SD(HBA_ptr)->bustype == IS_EISA) {
 152         if (HBA_ptr->dma_channel == 0xff)
 153             size = sprintf(buffer + len, "DMA: BUSMASTER\n");
 154         else
 155             size = sprintf(buffer + len, "DMA: %d\n", HBA_ptr->dma_channel);
 156         len += size; 
 157         pos = begin + len;
 158 
 159         size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) HBA_ptr->base);
 160         len += size; 
 161         pos = begin + len;
 162         size = sprintf(buffer + len, "Host Bus: EISA\n"); 
 163         len += size; 
 164         pos = begin + len;
 165     } else {
 166 
 167         scmd.cmnd[0] = LOG_SENSE;
 168         scmd.cmnd[1] = 0;
 169         scmd.cmnd[2] = 0x33 + (3<<6);
 170         scmd.cmnd[3] = 0;
 171         scmd.cmnd[4] = 0;
 172         scmd.cmnd[5] = 0;
 173         scmd.cmnd[6] = 0;
 174         scmd.cmnd[7] = 0x00;
 175         scmd.cmnd[8] = 0x66;
 176         scmd.cmnd[9] = 0;
 177         scmd.cmd_len = 10;
 178         
 179         scmd.host = HBA_ptr; 
 180         scmd.target = HBA_ptr->this_id; 
 181         scmd.lun = 0; 
 182         scmd.channel = 0;
 183         
 184         scmd.use_sg = 0;
 185         scmd.request_bufflen = 0x66;
 186         scmd.request_buffer = buff + 0x144;
 187         HBA_interpret = TRUE;
 188         
 189         eata_queue(&scmd, (void *) eata_scsi_done);
 190         while (internal_command_finished == FALSE)
 191             barrier();
 192         
 193         size = sprintf(buffer + len, "IRQ: %2d, %s triggered\n", cc->interrupt,
 194                        (cc->intt == TRUE)?"level":"edge");
 195         len += size; 
 196         pos = begin + len;
 197         if (HBA_ptr->dma_channel == 0xff)
 198             size = sprintf(buffer + len, "DMA: BUSMASTER\n");
 199         else
 200             size = sprintf(buffer + len, "DMA: %d\n", HBA_ptr->dma_channel);
 201         len += size; 
 202         pos = begin + len;
 203         size = sprintf(buffer + len, "CPU: MC680%02d %dMHz\n", bt->cpu_type,
 204                        bt->cpu_speed);
 205         len += size; 
 206         pos = begin + len;
 207         size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) HBA_ptr->base);
 208         len += size; 
 209         pos = begin + len;
 210         size = sprintf(buffer + len, "Host Bus: %s\n", 
 211                        (SD(HBA_ptr)->bustype == IS_PCI)?"PCI ":
 212                        (SD(HBA_ptr)->bustype == IS_EISA)?"EISA":"ISA ");
 213         
 214         len += size; 
 215         pos = begin + len;
 216         size = sprintf(buffer + len, "SCSI Bus:%s%s Speed: %sMB/sec. %s\n",
 217                        (sb->wide == TRUE)?" WIDE":"", 
 218                        (sb->dif == TRUE)?" DIFFERENTIAL":"",
 219                        (sb->speed == 0)?"5":(sb->speed == 1)?"10":"20",
 220                        (sb->ext == TRUE)?"With external cable detection":"");
 221         len += size; 
 222         pos = begin + len;
 223         size = sprintf(buffer + len, "SCSI channel expansion Module: %s installed\n",
 224                        (bt->sx1 == TRUE)?"SX1 (one channel)":
 225                        ((bt->sx2 == TRUE)?"SX2 (two channels)":"not"));
 226         len += size; 
 227         pos = begin + len;
 228         size = sprintf(buffer + len, "SmartRAID hardware: %spresent.\n",
 229                        (cc->srs == TRUE)?"":"not ");
 230         len += size; 
 231         pos = begin + len;
 232         size = sprintf(buffer + len, "    Type: %s\n",
 233                        ((cc->key == TRUE)?((bt->dmi == TRUE)?"integrated"
 234                                            :((bt->dm4 == TRUE)?"DM401X"
 235                                            :(bt->dm4k == TRUE)?"DM4000"
 236                                            :"-"))
 237                                            :"-"));
 238         len += size; 
 239         pos = begin + len;
 240         
 241         size = sprintf(buffer + len, "    Max array groups:              %d\n",
 242                        (al->code == 0x0e)?al->max_groups:7);
 243         len += size; 
 244         pos = begin + len;
 245         size = sprintf(buffer + len, "    Max drives per RAID 0 array:   %d\n",
 246                        (al->code == 0x0e)?al->raid0_drv:7);
 247         len += size; 
 248         pos = begin + len;
 249         size = sprintf(buffer + len, "    Max drives per RAID 3/5 array: %d\n",
 250                        (al->code == 0x0e)?al->raid35_drv:7);
 251         len += size; 
 252         pos = begin + len;
 253         size = sprintf(buffer + len, "Cache Module: %sinstalled.\n",
 254                        (cc->csh)?"":"not ");
 255         len += size; 
 256         pos = begin + len;
 257         size = sprintf(buffer + len, "    Type: %s\n",
 258                        ((cc->csh == TRUE)?((bt->cmi == TRUE)?"integrated"
 259                                          :((bt->cm4 == TRUE)?"CM401X"
 260                                          :((bt->cm4k == TRUE)?"CM4000"
 261                                          :"-")))
 262                                          :"-"));
 263         len += size; 
 264         pos = begin + len;
 265         for (x = 0; x <= 3; x++) {
 266             size = sprintf(buffer + len, "    Bank%d: %dMB with%s ECC\n",x,
 267                            mc->banksize[x] & 0x7f, 
 268                            (mc->banksize[x] & 0x80)?"":"out");
 269             len += size; 
 270             pos = begin + len;      
 271         }   
 272         size = sprintf(buffer + len, "Timer Modification: %sinstalled\n",
 273                        (cc->tmr == TRUE)?"":"not ");
 274         len += size; 
 275         pos = begin + len;
 276         size = sprintf(buffer + len, "NVRAM: %spresent\n",
 277                        (cc->nvr == TRUE)?"":"not ");
 278         len += size; 
 279         pos = begin + len;
 280         size = sprintf(buffer + len, "SmartROM: %senabled\n",
 281                        (bt->srom == TRUE)?"not ":"");
 282         len += size; 
 283         pos = begin + len;
 284         size = sprintf(buffer + len, "HBA indicates %salarm.\n",
 285                        (bt->alrm == TRUE)?"":"no ");
 286         len += size; 
 287         pos = begin + len;
 288         
 289         if (pos < offset) {
 290             len = 0;
 291             begin = pos;
 292         }
 293         if (pos > offset + length)
 294             goto stop_output; 
 295         
 296         scmd.cmnd[0] = LOG_SENSE;
 297         scmd.cmnd[1] = 0;
 298         scmd.cmnd[2] = 0x32 + (3<<6); 
 299         scmd.cmnd[3] = 0;
 300         scmd.cmnd[4] = 0;
 301         scmd.cmnd[5] = 0;
 302         scmd.cmnd[6] = 0;
 303         scmd.cmnd[7] = 0x01;
 304         scmd.cmnd[8] = 0x44;
 305         scmd.cmnd[9] = 0;
 306         scmd.cmd_len = 10;
 307         scmd.host = HBA_ptr; 
 308         scmd.target = HBA_ptr->this_id; 
 309         scmd.lun = 0; 
 310         scmd.channel = 0;
 311         scmd.use_sg = 0;
 312         scmd.request_bufflen = 0x144;
 313         scmd.request_buffer = buff2;
 314         HBA_interpret = TRUE;
 315         
 316         eata_queue(&scmd, (void *) eata_scsi_done);
 317         while (internal_command_finished == FALSE)
 318             barrier();
 319         
 320         swap_statistics(buff2);
 321         rhcs = (hst_cmd_stat *)(buff2 + 0x2c); 
 322         whcs = (hst_cmd_stat *)(buff2 + 0x8c);           
 323         
 324         for (x = 0; x <= 11; x++) {
 325             SD(HBA_ptr)->reads[x] += rhcs->sizes[x];
 326             SD(HBA_ptr)->writes[x] += whcs->sizes[x];
 327             SD(HBA_ptr)->reads[12] += rhcs->sizes[x];
 328             SD(HBA_ptr)->writes[12] += whcs->sizes[x];
 329         }
 330         size = sprintf(buffer + len, "Host Disk Command Statistics:\n"
 331                        "         Reads:      Writes:\n");
 332         len += size; 
 333         pos = begin + len;
 334         for (x = 0; x <= 10; x++) {
 335             size = sprintf(buffer+len,"%5dk:%12u %12u\n", 1 << x,
 336                            SD(HBA_ptr)->reads[x], 
 337                            SD(HBA_ptr)->writes[x]);
 338             len += size; 
 339             pos = begin + len;
 340         }
 341         size = sprintf(buffer+len,">1024k:%12u %12u\n",
 342                        SD(HBA_ptr)->reads[11], 
 343                        SD(HBA_ptr)->writes[11]);
 344         len += size; 
 345         pos = begin + len;
 346         size = sprintf(buffer+len,"Sum   : %12u %12u\n",
 347                        SD(HBA_ptr)->reads[12], 
 348                        SD(HBA_ptr)->writes[12]);
 349         len += size; 
 350         pos = begin + len;
 351     }
 352     
 353     if (pos < offset) {
 354         len = 0;
 355         begin = pos;
 356     }
 357     if (pos > offset + length)
 358         goto stop_output;
 359 
 360     if(SD(HBA_ptr)->do_latency == TRUE) {
 361         size = sprintf(buffer + len, "Host Latency Command Statistics:\n"
 362                        "Current timer resolution: 10ms\n"
 363                        "         Reads:       Min:(ms)     Max:(ms)     Ave:(ms)\n");
 364         len += size; 
 365         pos = begin + len;
 366         for (x = 0; x <= 10; x++) {
 367             size = sprintf(buffer+len,"%5dk:%12u %12u %12u %12u\n", 
 368                            1 << x,
 369                            SD(HBA_ptr)->reads_lat[x][0], 
 370                            (SD(HBA_ptr)->reads_lat[x][1] == 0xffffffff) 
 371                            ? 0:(SD(HBA_ptr)->reads_lat[x][1] * 10), 
 372                            SD(HBA_ptr)->reads_lat[x][2] * 10, 
 373                            SD(HBA_ptr)->reads_lat[x][3] * 10 /
 374                            ((SD(HBA_ptr)->reads_lat[x][0])
 375                             ? SD(HBA_ptr)->reads_lat[x][0]:1));
 376             len += size; 
 377             pos = begin + len;
 378         }
 379         size = sprintf(buffer+len,">1024k:%12u %12u %12u %12u\n",
 380                            SD(HBA_ptr)->reads_lat[11][0], 
 381                            (SD(HBA_ptr)->reads_lat[11][1] == 0xffffffff)
 382                            ? 0:(SD(HBA_ptr)->reads_lat[11][1] * 10), 
 383                            SD(HBA_ptr)->reads_lat[11][2] * 10, 
 384                            SD(HBA_ptr)->reads_lat[11][3] * 10 /
 385                            ((SD(HBA_ptr)->reads_lat[x][0])
 386                             ? SD(HBA_ptr)->reads_lat[x][0]:1));
 387         len += size; 
 388         pos = begin + len;
 389 
 390         if (pos < offset) {
 391             len = 0;
 392             begin = pos;
 393         }
 394         if (pos > offset + length)
 395             goto stop_output;
 396 
 397         size = sprintf(buffer + len,
 398                        "         Writes:      Min:(ms)     Max:(ms)     Ave:(ms)\n");
 399         len += size; 
 400         pos = begin + len;
 401         for (x = 0; x <= 10; x++) {
 402             size = sprintf(buffer+len,"%5dk:%12u %12u %12u %12u\n", 
 403                            1 << x,
 404                            SD(HBA_ptr)->writes_lat[x][0], 
 405                            (SD(HBA_ptr)->writes_lat[x][1] == 0xffffffff)
 406                            ? 0:(SD(HBA_ptr)->writes_lat[x][1] * 10), 
 407                            SD(HBA_ptr)->writes_lat[x][2] * 10, 
 408                            SD(HBA_ptr)->writes_lat[x][3] * 10 /
 409                            ((SD(HBA_ptr)->writes_lat[x][0])
 410                             ? SD(HBA_ptr)->writes_lat[x][0]:1));
 411             len += size; 
 412             pos = begin + len;
 413         }
 414         size = sprintf(buffer+len,">1024k:%12u %12u %12u %12u\n",
 415                            SD(HBA_ptr)->writes_lat[11][0], 
 416                            (SD(HBA_ptr)->writes_lat[11][1] == 0xffffffff)
 417                            ? 0:(SD(HBA_ptr)->writes_lat[x][1] * 10), 
 418                            SD(HBA_ptr)->writes_lat[11][2] * 10, 
 419                            SD(HBA_ptr)->writes_lat[11][3] * 10/
 420                            ((SD(HBA_ptr)->writes_lat[x][0])
 421                             ? SD(HBA_ptr)->writes_lat[x][0]:1));
 422         len += size; 
 423         pos = begin + len;
 424 
 425         if (pos < offset) {
 426             len = 0;
 427             begin = pos;
 428         }
 429         if (pos > offset + length)
 430             goto stop_output;
 431     }
 432 
 433     scd = scsi_devices;
 434     
 435     size = sprintf(buffer+len,"Attached devices: %s\n", (scd)?"":"none");
 436     len += size; 
 437     pos = begin + len;
 438     
 439     while (scd) {
 440         if (scd->host == HBA_ptr) {
 441             
 442             size = sprintf(buffer + len, 
 443                            "Channel: %02d Id: %02d Lun: %02d\n  Vendor: ",
 444                            scd->channel, scd->id, scd->lun);
 445             for (x = 0; x < 8; x++) {
 446                 if (scd->vendor[x] >= 0x20)
 447                     size += sprintf(buffer + len + size, "%c", scd->vendor[x]);
 448                 else
 449                     size += sprintf(buffer + len + size," ");
 450             }
 451             size += sprintf(buffer + len + size, " Model: ");
 452             for (x = 0; x < 16; x++) {
 453                 if (scd->model[x] >= 0x20)
 454                     size +=  sprintf(buffer + len + size, "%c", scd->model[x]);
 455                 else
 456                     size += sprintf(buffer + len + size, " ");
 457             }
 458             size += sprintf(buffer + len + size, " Rev: ");
 459             for (x = 0; x < 4; x++) {
 460                 if (scd->rev[x] >= 0x20)
 461                     size += sprintf(buffer + len + size, "%c", scd->rev[x]);
 462                 else
 463                     size += sprintf(buffer + len + size, " ");
 464             }
 465             size += sprintf(buffer + len + size, "\n");
 466             
 467             size += sprintf(buffer + len + size, "  Type:   %s ",
 468                             scd->type < MAX_SCSI_DEVICE_CODE ? 
 469                             scsi_dev_types[(int)scd->type] : "Unknown          " );
 470             size += sprintf(buffer + len + size, "               ANSI"
 471                             " SCSI revision: %02x", (scd->scsi_level < 3)?1:2);
 472             if (scd->scsi_level == 2)
 473                 size += sprintf(buffer + len + size, " CCS\n");
 474             else
 475                 size += sprintf(buffer + len + size, "\n");
 476             len += size; 
 477             pos = begin + len;
 478             
 479             if (pos < offset) {
 480                 len = 0;
 481                 begin = pos;
 482             }
 483             if (pos > offset + length)
 484                 goto stop_output;
 485         }
 486         scd = scd->next;
 487     }
 488     
 489  stop_output:
 490     DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
 491     *start=buffer+(offset-begin);   /* Start of wanted data */
 492     len-=(offset-begin);            /* Start slop */
 493     if(len>length)
 494         len = length;               /* Ending slop */
 495     DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
 496     
 497     return (len);     
 498 }
 499 
 500 /*
 501  * Overrides for Emacs so that we follow Linus's tabbing style.
 502  * Emacs will notice this stuff at the end of the file and automatically
 503  * adjust the settings for this buffer only.  This must remain at the end
 504  * of the file.
 505  * ---------------------------------------------------------------------------
 506  * Local variables:
 507  * c-indent-level: 4
 508  * c-brace-imaginary-offset: 0
 509  * c-brace-offset: -4
 510  * c-argdecl-indent: 4
 511  * c-label-offset: -4
 512  * c-continued-statement-offset: 4
 513  * c-continued-brace-offset: 0
 514  * indent-tabs-mode: nil
 515  * tab-width: 8
 516  * End:
 517  */

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