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

Subversion Repositories or1k

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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