aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-10-28 16:07:41 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-10-28 18:27:25 -0400
commitb5141128027c53b8ca40736d969f75c9a1cdb64b (patch)
treef09f3f7b608017329a3e44a41e975acbd0ea9af0 /drivers
parent28f22b031f8959cdf53202cd9f6ca8b9ce19b3a6 (diff)
[SCSI] mptsas: support link error attributes
.. and the fusion part. I had to move around the debug functions around a little bit so they are below the transport class methods. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/message/fusion/mptsas.c226
1 files changed, 153 insertions, 73 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 7de19a84dc7..6512027bc69 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -123,6 +123,101 @@ struct mptsas_portinfo {
123 struct mptsas_phyinfo *phy_info; 123 struct mptsas_phyinfo *phy_info;
124}; 124};
125 125
126
127#ifdef SASDEBUG
128static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
129{
130 printk("---- IO UNIT PAGE 0 ------------\n");
131 printk("Handle=0x%X\n",
132 le16_to_cpu(phy_data->AttachedDeviceHandle));
133 printk("Controller Handle=0x%X\n",
134 le16_to_cpu(phy_data->ControllerDevHandle));
135 printk("Port=0x%X\n", phy_data->Port);
136 printk("Port Flags=0x%X\n", phy_data->PortFlags);
137 printk("PHY Flags=0x%X\n", phy_data->PhyFlags);
138 printk("Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate);
139 printk("Controller PHY Device Info=0x%X\n",
140 le32_to_cpu(phy_data->ControllerPhyDeviceInfo));
141 printk("DiscoveryStatus=0x%X\n",
142 le32_to_cpu(phy_data->DiscoveryStatus));
143 printk("\n");
144}
145
146static void mptsas_print_phy_pg0(SasPhyPage0_t *pg0)
147{
148 __le64 sas_address;
149
150 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
151
152 printk("---- SAS PHY PAGE 0 ------------\n");
153 printk("Attached Device Handle=0x%X\n",
154 le16_to_cpu(pg0->AttachedDevHandle));
155 printk("SAS Address=0x%llX\n",
156 (unsigned long long)le64_to_cpu(sas_address));
157 printk("Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier);
158 printk("Attached Device Info=0x%X\n",
159 le32_to_cpu(pg0->AttachedDeviceInfo));
160 printk("Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate);
161 printk("Change Count=0x%X\n", pg0->ChangeCount);
162 printk("PHY Info=0x%X\n", le32_to_cpu(pg0->PhyInfo));
163 printk("\n");
164}
165
166static void mptsas_print_phy_pg1(SasPhyPage1_t *pg1)
167{
168 printk("---- SAS PHY PAGE 1 ------------\n");
169 printk("Invalid Dword Count=0x%x\n", pg1->InvalidDwordCount);
170 printk("Running Disparity Error Count=0x%x\n",
171 pg1->RunningDisparityErrorCount);
172 printk("Loss Dword Synch Count=0x%x\n", pg1->LossDwordSynchCount);
173 printk("PHY Reset Problem Count=0x%x\n", pg1->PhyResetProblemCount);
174 printk("\n");
175}
176
177static void mptsas_print_device_pg0(SasDevicePage0_t *pg0)
178{
179 __le64 sas_address;
180
181 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
182
183 printk("---- SAS DEVICE PAGE 0 ---------\n");
184 printk("Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle));
185 printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle));
186 printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot));
187 printk("SAS Address=0x%llX\n", le64_to_cpu(sas_address));
188 printk("Target ID=0x%X\n", pg0->TargetID);
189 printk("Bus=0x%X\n", pg0->Bus);
190 printk("PhyNum=0x%X\n", pg0->PhyNum);
191 printk("AccessStatus=0x%X\n", le16_to_cpu(pg0->AccessStatus));
192 printk("Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo));
193 printk("Flags=0x%X\n", le16_to_cpu(pg0->Flags));
194 printk("Physical Port=0x%X\n", pg0->PhysicalPort);
195 printk("\n");
196}
197
198static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1)
199{
200 printk("---- SAS EXPANDER PAGE 1 ------------\n");
201
202 printk("Physical Port=0x%X\n", pg1->PhysicalPort);
203 printk("PHY Identifier=0x%X\n", pg1->Phy);
204 printk("Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate);
205 printk("Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate);
206 printk("Hardware Link Rate=0x%X\n", pg1->HwLinkRate);
207 printk("Owner Device Handle=0x%X\n",
208 le16_to_cpu(pg1->OwnerDevHandle));
209 printk("Attached Device Handle=0x%X\n",
210 le16_to_cpu(pg1->AttachedDevHandle));
211}
212#else
213#define mptsas_print_phy_data(phy_data) do { } while (0)
214#define mptsas_print_phy_pg0(pg0) do { } while (0)
215#define mptsas_print_phy_pg1(pg1) do { } while (0)
216#define mptsas_print_device_pg0(pg0) do { } while (0)
217#define mptsas_print_expander_pg1(pg1) do { } while (0)
218#endif
219
220
126/* 221/*
127 * This is pretty ugly. We will be able to seriously clean it up 222 * This is pretty ugly. We will be able to seriously clean it up
128 * once the DV code in mptscsih goes away and we can properly 223 * once the DV code in mptscsih goes away and we can properly
@@ -200,91 +295,76 @@ static struct scsi_host_template mptsas_driver_template = {
200 .use_clustering = ENABLE_CLUSTERING, 295 .use_clustering = ENABLE_CLUSTERING,
201}; 296};
202 297
203static struct sas_function_template mptsas_transport_functions = { 298static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy)
204};
205
206static struct scsi_transport_template *mptsas_transport_template;
207
208#ifdef SASDEBUG
209static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
210{ 299{
211 printk("---- IO UNIT PAGE 0 ------------\n"); 300 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
212 printk("Handle=0x%X\n", 301 return ((MPT_SCSI_HOST *)shost->hostdata)->ioc;
213 le16_to_cpu(phy_data->AttachedDeviceHandle));
214 printk("Controller Handle=0x%X\n",
215 le16_to_cpu(phy_data->ControllerDevHandle));
216 printk("Port=0x%X\n", phy_data->Port);
217 printk("Port Flags=0x%X\n", phy_data->PortFlags);
218 printk("PHY Flags=0x%X\n", phy_data->PhyFlags);
219 printk("Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate);
220 printk("Controller PHY Device Info=0x%X\n",
221 le32_to_cpu(phy_data->ControllerPhyDeviceInfo));
222 printk("DiscoveryStatus=0x%X\n",
223 le32_to_cpu(phy_data->DiscoveryStatus));
224 printk("\n");
225} 302}
226 303
227static void mptsas_print_phy_pg0(SasPhyPage0_t *pg0) 304static int mptsas_get_linkerrors(struct sas_phy *phy)
228{ 305{
229 __le64 sas_address; 306 MPT_ADAPTER *ioc = phy_to_ioc(phy);
307 ConfigExtendedPageHeader_t hdr;
308 CONFIGPARMS cfg;
309 SasPhyPage1_t *buffer;
310 dma_addr_t dma_handle;
311 int error;
230 312
231 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 313 hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
314 hdr.ExtPageLength = 0;
315 hdr.PageNumber = 1 /* page number 1*/;
316 hdr.Reserved1 = 0;
317 hdr.Reserved2 = 0;
318 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
319 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_PHY;
232 320
233 printk("---- SAS PHY PAGE 0 ------------\n"); 321 cfg.cfghdr.ehdr = &hdr;
234 printk("Attached Device Handle=0x%X\n", 322 cfg.physAddr = -1;
235 le16_to_cpu(pg0->AttachedDevHandle)); 323 cfg.pageAddr = phy->identify.phy_identifier;
236 printk("SAS Address=0x%llX\n", 324 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
237 (unsigned long long)le64_to_cpu(sas_address)); 325 cfg.dir = 0; /* read */
238 printk("Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier); 326 cfg.timeout = 10;
239 printk("Attached Device Info=0x%X\n",
240 le32_to_cpu(pg0->AttachedDeviceInfo));
241 printk("Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate);
242 printk("Change Count=0x%X\n", pg0->ChangeCount);
243 printk("PHY Info=0x%X\n", le32_to_cpu(pg0->PhyInfo));
244 printk("\n");
245}
246 327
247static void mptsas_print_device_pg0(SasDevicePage0_t *pg0) 328 error = mpt_config(ioc, &cfg);
248{ 329 if (error)
249 __le64 sas_address; 330 return error;
331 if (!hdr.ExtPageLength)
332 return -ENXIO;
250 333
251 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 334 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
335 &dma_handle);
336 if (!buffer)
337 return -ENOMEM;
252 338
253 printk("---- SAS DEVICE PAGE 0 ---------\n"); 339 cfg.physAddr = dma_handle;
254 printk("Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle)); 340 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
255 printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle));
256 printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot));
257 printk("SAS Address=0x%llX\n", le64_to_cpu(sas_address));
258 printk("Target ID=0x%X\n", pg0->TargetID);
259 printk("Bus=0x%X\n", pg0->Bus);
260 printk("Parent Phy Num=0x%X\n", pg0->PhyNum);
261 printk("Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus));
262 printk("Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo));
263 printk("Flags=0x%X\n", le16_to_cpu(pg0->Flags));
264 printk("Physical Port=0x%X\n", pg0->PhysicalPort);
265 printk("\n");
266}
267 341
268static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1) 342 error = mpt_config(ioc, &cfg);
269{ 343 if (error)
270 printk("---- SAS EXPANDER PAGE 1 ------------\n"); 344 goto out_free_consistent;
271 345
272 printk("Physical Port=0x%X\n", pg1->PhysicalPort); 346 mptsas_print_phy_pg1(buffer);
273 printk("PHY Identifier=0x%X\n", pg1->PhyIdentifier); 347
274 printk("Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate); 348 phy->invalid_dword_count = le32_to_cpu(buffer->InvalidDwordCount);
275 printk("Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate); 349 phy->running_disparity_error_count =
276 printk("Hardware Link Rate=0x%X\n", pg1->HwLinkRate); 350 le32_to_cpu(buffer->RunningDisparityErrorCount);
277 printk("Owner Device Handle=0x%X\n", 351 phy->loss_of_dword_sync_count =
278 le16_to_cpu(pg1->OwnerDevHandle)); 352 le32_to_cpu(buffer->LossDwordSynchCount);
279 printk("Attached Device Handle=0x%X\n", 353 phy->phy_reset_problem_count =
280 le16_to_cpu(pg1->AttachedDevHandle)); 354 le32_to_cpu(buffer->PhyResetProblemCount);
355
356 out_free_consistent:
357 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
358 buffer, dma_handle);
359 return error;
281} 360}
282#else 361
283#define mptsas_print_phy_data(phy_data) do { } while (0) 362
284#define mptsas_print_phy_pg0(pg0) do { } while (0) 363static struct sas_function_template mptsas_transport_functions = {
285#define mptsas_print_device_pg0(pg0) do { } while (0) 364 .get_linkerrors = mptsas_get_linkerrors,
286#define mptsas_print_expander_pg1(pg1) do { } while (0) 365};
287#endif 366
367static struct scsi_transport_template *mptsas_transport_template;
288 368
289static int 369static int
290mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) 370mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)