aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas/sas_phy.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@SteelEye.com>2006-08-29 10:22:51 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-08-29 10:52:29 -0400
commit2908d778ab3e244900c310974e1fc1c69066e450 (patch)
tree440d56e98414cd2a8ca711dcd6424df1982d474e /drivers/scsi/libsas/sas_phy.c
parentf4ad7b5807385ad1fed0347d966e51a797cd1013 (diff)
[SCSI] aic94xx: new driver
This is the end point of the separate aic94xx driver based on the original driver and transport class from Luben Tuikov <ltuikov@yahoo.com> The log of the separate development is: Alexis Bruemmer: o aic94xx: fix hotplug/unplug for expanderless systems o aic94xx: disable split completion timer/setting by default o aic94xx: wide port off expander support o aic94xx: remove various inline functions o aic94xx: use bitops o aic94xx: remove queue comment o aic94xx: remove sas_common.c o aic94xx: sas remove depot's o aic94xx: use available list_for_each_entry_safe_reverse() o aic94xx: sas header file merge James Bottomley: o aic94xx: fix TF_TMF_NO_CTX processing o aic94xx: convert to request_firmware interface o aic94xx: fix hotplug/unplug o aic94xx: add link error counts to the expander phys o aic94xx: add transport class phy reset capability o aic94xx: remove local_attached flag o Remove README o Fixup Makefile variable for libsas rename o Rename sas->libsas o aic94xx: correct return code for sas_discover_event o aic94xx: use parent backlink port o aic94xx: remove channel abstraction o aic94xx: fix routing algorithms o aic94xx: add backlink port o aic94xx: fix cascaded expander properties o aic94xx: fix sleep under lock o aic94xx: fix panic on module removal in complex topology o aic94xx: make use of the new sas_port o rename sas_port to asd_sas_port o Fix for eh_strategy_handler move o aic94xx: move entirely over to correct transport class formulation o remove last vestages of sas_rphy_alloc() o update for eh_timed_out move o Preliminary expander support for aic94xx o sas: remove event thread o minor warning cleanups o remove last vestiges of id mapping arrays o Further updates o Convert aic94xx over entirely to the transport class end device and o update aic94xx/sas to use the new sas transport class end device o [PATCH] aic94xx: attaching to the sas transport class o Add missing completion removal from prior patch o [PATCH] aic94xx: attaching to the sas transport class o Build fixes from akpm Jeff Garzik: o [scsi aic94xx] Remove ->owner from PCI info table Luben Tuikov: o initial aic94xx driver Mike Anderson: o aic94xx: fix panic on module insertion o aic94xx: stub out SATA_DEV case o aic94xx: compile warning cleanups o aic94xx: sas_alloc_task o aic94xx: ref count update o aic94xx nexus loss time value o [PATCH] aic94xx: driver assertion in non-x86 BIOS env Randy Dunlap: o libsas: externs not needed Robert Tarte: o aic94xx: sequence patch - fixes SATA support Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/libsas/sas_phy.c')
-rw-r--r--drivers/scsi/libsas/sas_phy.c157
1 files changed, 157 insertions, 0 deletions
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
new file mode 100644
index 000000000000..024ab00e70d2
--- /dev/null
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -0,0 +1,157 @@
1/*
2 * Serial Attached SCSI (SAS) Phy class
3 *
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
6 *
7 * This file is licensed under GPLv2.
8 *
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.
13 *
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.
18 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 */
24
25#include "sas_internal.h"
26#include <scsi/scsi_host.h>
27#include <scsi/scsi_transport.h>
28#include <scsi/scsi_transport_sas.h>
29#include "../scsi_sas_internal.h"
30
31/* ---------- Phy events ---------- */
32
33static void sas_phye_loss_of_signal(void *data)
34{
35 struct asd_sas_phy *phy = data;
36
37 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock,
38 &phy->phy_events_pending);
39 phy->error = 0;
40 sas_deform_port(phy);
41}
42
43static void sas_phye_oob_done(void *data)
44{
45 struct asd_sas_phy *phy = data;
46
47 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock,
48 &phy->phy_events_pending);
49 phy->error = 0;
50}
51
52static void sas_phye_oob_error(void *data)
53{
54 struct asd_sas_phy *phy = data;
55 struct sas_ha_struct *sas_ha = phy->ha;
56 struct asd_sas_port *port = phy->port;
57 struct sas_internal *i =
58 to_sas_internal(sas_ha->core.shost->transportt);
59
60 sas_begin_event(PHYE_OOB_ERROR, &phy->ha->event_lock,
61 &phy->phy_events_pending);
62
63 sas_deform_port(phy);
64
65 if (!port && phy->enabled && i->dft->lldd_control_phy) {
66 phy->error++;
67 switch (phy->error) {
68 case 1:
69 case 2:
70 i->dft->lldd_control_phy(phy, PHY_FUNC_HARD_RESET);
71 break;
72 case 3:
73 default:
74 phy->error = 0;
75 phy->enabled = 0;
76 i->dft->lldd_control_phy(phy, PHY_FUNC_DISABLE);
77 break;
78 }
79 }
80}
81
82static void sas_phye_spinup_hold(void *data)
83{
84 struct asd_sas_phy *phy = data;
85 struct sas_ha_struct *sas_ha = phy->ha;
86 struct sas_internal *i =
87 to_sas_internal(sas_ha->core.shost->transportt);
88
89 sas_begin_event(PHYE_SPINUP_HOLD, &phy->ha->event_lock,
90 &phy->phy_events_pending);
91
92 phy->error = 0;
93 i->dft->lldd_control_phy(phy, PHY_FUNC_RELEASE_SPINUP_HOLD);
94}
95
96/* ---------- Phy class registration ---------- */
97
98int sas_register_phys(struct sas_ha_struct *sas_ha)
99{
100 int i;
101
102 static void (*sas_phy_event_fns[PHY_NUM_EVENTS])(void *) = {
103 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal,
104 [PHYE_OOB_DONE] = sas_phye_oob_done,
105 [PHYE_OOB_ERROR] = sas_phye_oob_error,
106 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold,
107 };
108
109 static void (*sas_port_event_fns[PORT_NUM_EVENTS])(void *) = {
110 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed,
111 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd,
112 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err,
113 [PORTE_TIMER_EVENT] = sas_porte_timer_event,
114 [PORTE_HARD_RESET] = sas_porte_hard_reset,
115 };
116
117 /* Now register the phys. */
118 for (i = 0; i < sas_ha->num_phys; i++) {
119 int k;
120 struct asd_sas_phy *phy = sas_ha->sas_phy[i];
121
122 phy->error = 0;
123 INIT_LIST_HEAD(&phy->port_phy_el);
124 for (k = 0; k < PORT_NUM_EVENTS; k++)
125 INIT_WORK(&phy->port_events[k], sas_port_event_fns[k],
126 phy);
127
128 for (k = 0; k < PHY_NUM_EVENTS; k++)
129 INIT_WORK(&phy->phy_events[k], sas_phy_event_fns[k],
130 phy);
131 phy->port = NULL;
132 phy->ha = sas_ha;
133 spin_lock_init(&phy->frame_rcvd_lock);
134 spin_lock_init(&phy->sas_prim_lock);
135 phy->frame_rcvd_size = 0;
136
137 phy->phy = sas_phy_alloc(&sas_ha->core.shost->shost_gendev,
138 i);
139 if (!phy->phy)
140 return -ENOMEM;
141
142 phy->phy->identify.initiator_port_protocols =
143 phy->iproto;
144 phy->phy->identify.target_port_protocols = phy->tproto;
145 phy->phy->identify.sas_address = SAS_ADDR(sas_ha->sas_addr);
146 phy->phy->identify.phy_identifier = i;
147 phy->phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
148 phy->phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
149 phy->phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
150 phy->phy->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS;
151 phy->phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
152
153 sas_phy_add(phy->phy);
154 }
155
156 return 0;
157}