aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfad_bsg.c
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-06-24 23:28:17 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-06-29 18:25:44 -0400
commit3d7fc66dcd8d510aaa46ab9b914b632bc149b05c (patch)
tree256cf906d79359a90c462b5c1d08dc1969b6b7ed /drivers/scsi/bfa/bfad_bsg.c
parent5a54b1d576d1880eb249e906e0c8e2ffe64506d3 (diff)
[SCSI] bfa: Added HBA diagnostics support.
- Added diagnostics sub-module to BFA. - Implemented interface to perform memtest/loopback test and some other diagnostics tests. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfad_bsg.c')
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c206
1 files changed, 206 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 5444661f1150..a60270287064 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -1214,6 +1214,185 @@ out:
1214 return 0; 1214 return 0;
1215} 1215}
1216 1216
1217int
1218bfad_iocmd_diag_temp(struct bfad_s *bfad, void *cmd)
1219{
1220 struct bfa_bsg_diag_get_temp_s *iocmd =
1221 (struct bfa_bsg_diag_get_temp_s *)cmd;
1222 struct bfad_hal_comp fcomp;
1223 unsigned long flags;
1224
1225 init_completion(&fcomp.comp);
1226 spin_lock_irqsave(&bfad->bfad_lock, flags);
1227 iocmd->status = bfa_diag_tsensor_query(BFA_DIAG_MOD(&bfad->bfa),
1228 &iocmd->result, bfad_hcb_comp, &fcomp);
1229 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1230 bfa_trc(bfad, iocmd->status);
1231 if (iocmd->status != BFA_STATUS_OK)
1232 goto out;
1233 wait_for_completion(&fcomp.comp);
1234 iocmd->status = fcomp.status;
1235out:
1236 return 0;
1237}
1238
1239int
1240bfad_iocmd_diag_memtest(struct bfad_s *bfad, void *cmd)
1241{
1242 struct bfa_bsg_diag_memtest_s *iocmd =
1243 (struct bfa_bsg_diag_memtest_s *)cmd;
1244 struct bfad_hal_comp fcomp;
1245 unsigned long flags;
1246
1247 init_completion(&fcomp.comp);
1248 spin_lock_irqsave(&bfad->bfad_lock, flags);
1249 iocmd->status = bfa_diag_memtest(BFA_DIAG_MOD(&bfad->bfa),
1250 &iocmd->memtest, iocmd->pat,
1251 &iocmd->result, bfad_hcb_comp, &fcomp);
1252 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1253 bfa_trc(bfad, iocmd->status);
1254 if (iocmd->status != BFA_STATUS_OK)
1255 goto out;
1256 wait_for_completion(&fcomp.comp);
1257 iocmd->status = fcomp.status;
1258out:
1259 return 0;
1260}
1261
1262int
1263bfad_iocmd_diag_loopback(struct bfad_s *bfad, void *cmd)
1264{
1265 struct bfa_bsg_diag_loopback_s *iocmd =
1266 (struct bfa_bsg_diag_loopback_s *)cmd;
1267 struct bfad_hal_comp fcomp;
1268 unsigned long flags;
1269
1270 init_completion(&fcomp.comp);
1271 spin_lock_irqsave(&bfad->bfad_lock, flags);
1272 iocmd->status = bfa_fcdiag_loopback(&bfad->bfa, iocmd->opmode,
1273 iocmd->speed, iocmd->lpcnt, iocmd->pat,
1274 &iocmd->result, bfad_hcb_comp, &fcomp);
1275 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1276 bfa_trc(bfad, iocmd->status);
1277 if (iocmd->status != BFA_STATUS_OK)
1278 goto out;
1279 wait_for_completion(&fcomp.comp);
1280 iocmd->status = fcomp.status;
1281out:
1282 return 0;
1283}
1284
1285int
1286bfad_iocmd_diag_fwping(struct bfad_s *bfad, void *cmd)
1287{
1288 struct bfa_bsg_diag_fwping_s *iocmd =
1289 (struct bfa_bsg_diag_fwping_s *)cmd;
1290 struct bfad_hal_comp fcomp;
1291 unsigned long flags;
1292
1293 init_completion(&fcomp.comp);
1294 spin_lock_irqsave(&bfad->bfad_lock, flags);
1295 iocmd->status = bfa_diag_fwping(BFA_DIAG_MOD(&bfad->bfa), iocmd->cnt,
1296 iocmd->pattern, &iocmd->result,
1297 bfad_hcb_comp, &fcomp);
1298 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1299 bfa_trc(bfad, iocmd->status);
1300 if (iocmd->status != BFA_STATUS_OK)
1301 goto out;
1302 bfa_trc(bfad, 0x77771);
1303 wait_for_completion(&fcomp.comp);
1304 iocmd->status = fcomp.status;
1305out:
1306 return 0;
1307}
1308
1309int
1310bfad_iocmd_diag_queuetest(struct bfad_s *bfad, void *cmd)
1311{
1312 struct bfa_bsg_diag_qtest_s *iocmd = (struct bfa_bsg_diag_qtest_s *)cmd;
1313 struct bfad_hal_comp fcomp;
1314 unsigned long flags;
1315
1316 init_completion(&fcomp.comp);
1317 spin_lock_irqsave(&bfad->bfad_lock, flags);
1318 iocmd->status = bfa_fcdiag_queuetest(&bfad->bfa, iocmd->force,
1319 iocmd->queue, &iocmd->result,
1320 bfad_hcb_comp, &fcomp);
1321 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1322 if (iocmd->status != BFA_STATUS_OK)
1323 goto out;
1324 wait_for_completion(&fcomp.comp);
1325 iocmd->status = fcomp.status;
1326out:
1327 return 0;
1328}
1329
1330int
1331bfad_iocmd_diag_sfp(struct bfad_s *bfad, void *cmd)
1332{
1333 struct bfa_bsg_sfp_show_s *iocmd =
1334 (struct bfa_bsg_sfp_show_s *)cmd;
1335 struct bfad_hal_comp fcomp;
1336 unsigned long flags;
1337
1338 init_completion(&fcomp.comp);
1339 spin_lock_irqsave(&bfad->bfad_lock, flags);
1340 iocmd->status = bfa_sfp_show(BFA_SFP_MOD(&bfad->bfa), &iocmd->sfp,
1341 bfad_hcb_comp, &fcomp);
1342 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1343 bfa_trc(bfad, iocmd->status);
1344 if (iocmd->status != BFA_STATUS_OK)
1345 goto out;
1346 wait_for_completion(&fcomp.comp);
1347 iocmd->status = fcomp.status;
1348 bfa_trc(bfad, iocmd->status);
1349out:
1350 return 0;
1351}
1352
1353int
1354bfad_iocmd_diag_led(struct bfad_s *bfad, void *cmd)
1355{
1356 struct bfa_bsg_diag_led_s *iocmd = (struct bfa_bsg_diag_led_s *)cmd;
1357 unsigned long flags;
1358
1359 spin_lock_irqsave(&bfad->bfad_lock, flags);
1360 iocmd->status = bfa_diag_ledtest(BFA_DIAG_MOD(&bfad->bfa),
1361 &iocmd->ledtest);
1362 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1363 return 0;
1364}
1365
1366int
1367bfad_iocmd_diag_beacon_lport(struct bfad_s *bfad, void *cmd)
1368{
1369 struct bfa_bsg_diag_beacon_s *iocmd =
1370 (struct bfa_bsg_diag_beacon_s *)cmd;
1371 unsigned long flags;
1372
1373 spin_lock_irqsave(&bfad->bfad_lock, flags);
1374 iocmd->status = bfa_diag_beacon_port(BFA_DIAG_MOD(&bfad->bfa),
1375 iocmd->beacon, iocmd->link_e2e_beacon,
1376 iocmd->second);
1377 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1378 return 0;
1379}
1380
1381int
1382bfad_iocmd_diag_lb_stat(struct bfad_s *bfad, void *cmd)
1383{
1384 struct bfa_bsg_diag_lb_stat_s *iocmd =
1385 (struct bfa_bsg_diag_lb_stat_s *)cmd;
1386 unsigned long flags;
1387
1388 spin_lock_irqsave(&bfad->bfad_lock, flags);
1389 iocmd->status = bfa_fcdiag_lb_is_running(&bfad->bfa);
1390 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1391 bfa_trc(bfad, iocmd->status);
1392
1393 return 0;
1394}
1395
1217static int 1396static int
1218bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, 1397bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
1219 unsigned int payload_len) 1398 unsigned int payload_len)
@@ -1360,6 +1539,33 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
1360 case IOCMD_FLASH_READ_PART: 1539 case IOCMD_FLASH_READ_PART:
1361 rc = bfad_iocmd_flash_read_part(bfad, iocmd, payload_len); 1540 rc = bfad_iocmd_flash_read_part(bfad, iocmd, payload_len);
1362 break; 1541 break;
1542 case IOCMD_DIAG_TEMP:
1543 rc = bfad_iocmd_diag_temp(bfad, iocmd);
1544 break;
1545 case IOCMD_DIAG_MEMTEST:
1546 rc = bfad_iocmd_diag_memtest(bfad, iocmd);
1547 break;
1548 case IOCMD_DIAG_LOOPBACK:
1549 rc = bfad_iocmd_diag_loopback(bfad, iocmd);
1550 break;
1551 case IOCMD_DIAG_FWPING:
1552 rc = bfad_iocmd_diag_fwping(bfad, iocmd);
1553 break;
1554 case IOCMD_DIAG_QUEUETEST:
1555 rc = bfad_iocmd_diag_queuetest(bfad, iocmd);
1556 break;
1557 case IOCMD_DIAG_SFP:
1558 rc = bfad_iocmd_diag_sfp(bfad, iocmd);
1559 break;
1560 case IOCMD_DIAG_LED:
1561 rc = bfad_iocmd_diag_led(bfad, iocmd);
1562 break;
1563 case IOCMD_DIAG_BEACON_LPORT:
1564 rc = bfad_iocmd_diag_beacon_lport(bfad, iocmd);
1565 break;
1566 case IOCMD_DIAG_LB_STAT:
1567 rc = bfad_iocmd_diag_lb_stat(bfad, iocmd);
1568 break;
1363 default: 1569 default:
1364 rc = EINVAL; 1570 rc = EINVAL;
1365 break; 1571 break;