vserver 1.9.5.x5
[linux-2.6.git] / drivers / scsi / sym53c8xx_2 / sym_misc.c
1 /*
2  * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family 
3  * of PCI-SCSI IO processors.
4  *
5  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
6  *
7  * This driver is derived from the Linux sym53c8xx driver.
8  * Copyright (C) 1998-2000  Gerard Roudier
9  *
10  * The sym53c8xx driver is derived from the ncr53c8xx driver that had been 
11  * a port of the FreeBSD ncr driver to Linux-1.2.13.
12  *
13  * The original ncr driver has been written for 386bsd and FreeBSD by
14  *         Wolfgang Stanglmeier        <wolf@cologne.de>
15  *         Stefan Esser                <se@mi.Uni-Koeln.de>
16  * Copyright (C) 1994  Wolfgang Stanglmeier
17  *
18  * Other major contributions:
19  *
20  * NVRAM detection and reading.
21  * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
22  *
23  *-----------------------------------------------------------------------------
24  *
25  * This program is free software; you can redistribute it and/or modify
26  * it under the terms of the GNU General Public License as published by
27  * the Free Software Foundation; either version 2 of the License, or
28  * (at your option) any later version.
29  *
30  * This program is distributed in the hope that it will be useful,
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33  * GNU General Public License for more details.
34  *
35  * You should have received a copy of the GNU General Public License
36  * along with this program; if not, write to the Free Software
37  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38  */
39
40 #include "sym_glue.h"
41
42 #ifdef  SYM_OPT_ANNOUNCE_TRANSFER_RATE
43 /*
44  *  Announce transfer rate if anything changed since last announcement.
45  */
46 void sym_announce_transfer_rate(struct sym_hcb *np, int target)
47 {
48         tcb_p tp = &np->target[target];
49
50 #define __tprev tp->tinfo.prev
51 #define __tcurr tp->tinfo.curr
52
53         if (__tprev.options  == __tcurr.options &&
54             __tprev.width    == __tcurr.width   &&
55             __tprev.offset   == __tcurr.offset  &&
56             !(__tprev.offset && __tprev.period != __tcurr.period))
57                 return;
58
59         __tprev.options  = __tcurr.options;
60         __tprev.width    = __tcurr.width;
61         __tprev.offset   = __tcurr.offset;
62         __tprev.period   = __tcurr.period;
63
64         if (__tcurr.offset && __tcurr.period) {
65                 u_int period, f10, mb10;
66                 char *scsi;
67
68                 period = f10 = mb10 = 0;
69                 scsi = "FAST-5";
70
71                 if (__tcurr.period <= 9) {
72                         scsi = "FAST-80";
73                         period = 125;
74                         mb10 = 1600;
75                 }
76                 else {
77                         if      (__tcurr.period <= 11) {
78                                 scsi = "FAST-40";
79                                 period = 250;
80                                 if (__tcurr.period == 11)
81                                         period = 303;
82                         }
83                         else if (__tcurr.period < 25) {
84                                 scsi = "FAST-20";
85                                 if (__tcurr.period == 12)
86                                         period = 500;
87                         }
88                         else if (__tcurr.period <= 50) {
89                                 scsi = "FAST-10";
90                         }
91                         if (!period)
92                                 period = 40 * __tcurr.period;
93                         f10 = 100000 << (__tcurr.width ? 1 : 0);
94                         mb10 = (f10 + period/2) / period;
95                 }
96                 printf_info (
97                     "%s:%d: %s %sSCSI %d.%d MB/s %s%s%s (%d.%d ns, offset %d)\n",
98                     sym_name(np), target, scsi, __tcurr.width? "WIDE " : "",
99                     mb10/10, mb10%10,
100                     (__tcurr.options & PPR_OPT_DT) ? "DT" : "ST",
101                     (__tcurr.options & PPR_OPT_IU) ? " IU" : "",
102                     (__tcurr.options & PPR_OPT_QAS) ? " QAS" : "",
103                     period/10, period%10, __tcurr.offset);
104         }
105         else
106                 printf_info ("%s:%d: %sasynchronous.\n", 
107                              sym_name(np), target, __tcurr.width? "wide " : "");
108 }
109 #undef __tprev
110 #undef __tcurr
111 #endif  /* SYM_OPT_ANNOUNCE_TRANSFER_RATE */