2 * Serial Attached SCSI (SAS) class common functions
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
7 * This file is licensed under GPLv2.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: //depot/sas-class/sas_common.c#9 $
27 #include <scsi/sas/sas_class.h>
28 #include "sas_internal.h"
30 int sas_show_class(enum sas_class class, char *buf)
32 static const char *class_str[] = {
34 [EXPANDER] = "EXPANDER",
36 return sprintf(buf, "%s\n", class_str[class]);
39 int sas_show_proto(enum sas_proto proto, char *page)
41 static const char *proto_str[] = {
42 [SATA_PROTO] = "SATA",
43 [SAS_PROTO_SMP] = "SMP",
44 [SAS_PROTO_STP] = "STP",
45 [SAS_PROTO_SSP] = "SSP",
50 for (v = 1; proto != 0 && v <= SAS_PROTO_SSP; v <<= 1) {
52 buf += sprintf(buf, "%s", proto_str[v]);
54 if (proto & ~((v<<1)-1))
55 buf += sprintf(buf, "|");
57 buf += sprintf(buf, "\n");
63 int sas_show_linkrate(enum sas_phy_linkrate linkrate, char *page)
65 static const char *phy_linkrate_str[] = {
66 [PHY_LINKRATE_NONE] = "",
67 [PHY_DISABLED] = "disabled",
68 [PHY_RESET_PROBLEM] = "phy reset problem",
69 [PHY_SPINUP_HOLD] = "phy spinup hold",
70 [PHY_PORT_SELECTOR] = "phy port selector",
71 [PHY_LINKRATE_1_5] = "1,5 GB/s",
72 [PHY_LINKRATE_3] = "3,0 GB/s",
73 [PHY_LINKRATE_6] = "6,0 GB/s",
75 return sprintf(page, "%s\n", phy_linkrate_str[linkrate]);
78 int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf)
81 case OOB_NOT_CONNECTED:
82 return sprintf(buf, "%s", "");
85 return sprintf(buf, "%s\n", "SATA");
88 return sprintf(buf, "%s\n", "SAS");
94 void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
96 const u32 poly = 0x00DB2777;
100 for (i = 0; i < 8; i++) {
102 for (b = 7; b >= 0; b--) {
104 if ((1 << b) & sas_addr[i]) {
105 if (!(r & 0x01000000))
107 } else if (r & 0x01000000)
112 hashed[0] = (r >> 16) & 0xFF;
113 hashed[1] = (r >> 8) & 0xFF ;
114 hashed[2] = r & 0xFF;