aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla4xxx/ql4_mbx.c
diff options
context:
space:
mode:
authorManish Rangankar <manish.rangankar@qlogic.com>2011-07-25 14:48:55 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-08-27 10:36:27 -0400
commit2a991c2159782b8d318ac9f88a36c22dda3e7185 (patch)
tree963cc3bec9517038458ad7e71b9a5d45ede4d360 /drivers/scsi/qla4xxx/ql4_mbx.c
parent0e7e85019c2709131b10c5f34b602cc6b94fe782 (diff)
[SCSI] qla4xxx: Boot from SAN support for open-iscsi
Hook qla4xxx in fw boot sysfs interface so iscsi tools can use the info to create boot sessions. Signed-off-by: Manish Rangankar <manish.rangankar@qlogic.com> Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla4xxx/ql4_mbx.c')
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 21884019dab8..72ec7e092296 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1262,6 +1262,83 @@ int qla4xxx_set_flash(struct scsi_qla_host *ha, dma_addr_t dma_addr,
1262 return status; 1262 return status;
1263} 1263}
1264 1264
1265int qla4xxx_bootdb_by_index(struct scsi_qla_host *ha,
1266 struct dev_db_entry *fw_ddb_entry,
1267 dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index)
1268{
1269 uint32_t dev_db_start_offset = FLASH_OFFSET_DB_INFO;
1270 uint32_t dev_db_end_offset;
1271 int status = QLA_ERROR;
1272
1273 memset(fw_ddb_entry, 0, sizeof(*fw_ddb_entry));
1274
1275 dev_db_start_offset += (ddb_index * sizeof(*fw_ddb_entry));
1276 dev_db_end_offset = FLASH_OFFSET_DB_END;
1277
1278 if (dev_db_start_offset > dev_db_end_offset) {
1279 DEBUG2(ql4_printk(KERN_ERR, ha,
1280 "%s:Invalid DDB index %d", __func__,
1281 ddb_index));
1282 goto exit_bootdb_failed;
1283 }
1284
1285 if (qla4xxx_get_flash(ha, fw_ddb_entry_dma, dev_db_start_offset,
1286 sizeof(*fw_ddb_entry)) != QLA_SUCCESS) {
1287 ql4_printk(KERN_ERR, ha, "scsi%ld: %s: Get Flash"
1288 "failed\n", ha->host_no, __func__);
1289 goto exit_bootdb_failed;
1290 }
1291
1292 if (fw_ddb_entry->cookie == DDB_VALID_COOKIE)
1293 status = QLA_SUCCESS;
1294
1295exit_bootdb_failed:
1296 return status;
1297}
1298
1299int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
1300 uint16_t idx)
1301{
1302 int ret = 0;
1303 int rval = QLA_ERROR;
1304 uint32_t offset = 0;
1305 struct ql4_chap_table *chap_table;
1306 dma_addr_t chap_dma;
1307
1308 chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
1309 if (chap_table == NULL) {
1310 ret = -ENOMEM;
1311 goto exit_get_chap;
1312 }
1313
1314 memset(chap_table, 0, sizeof(struct ql4_chap_table));
1315
1316 offset = 0x06000000 | (idx * sizeof(struct ql4_chap_table));
1317
1318 rval = qla4xxx_get_flash(ha, chap_dma, offset,
1319 sizeof(struct ql4_chap_table));
1320 if (rval != QLA_SUCCESS) {
1321 ret = -EINVAL;
1322 goto exit_get_chap;
1323 }
1324
1325 DEBUG2(ql4_printk(KERN_INFO, ha, "Chap Cookie: x%x\n",
1326 __le16_to_cpu(chap_table->cookie)));
1327
1328 if (__le16_to_cpu(chap_table->cookie) != CHAP_VALID_COOKIE) {
1329 ql4_printk(KERN_ERR, ha, "No valid chap entry found\n");
1330 goto exit_get_chap;
1331 }
1332
1333 strncpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
1334 strncpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
1335 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE);
1336
1337exit_get_chap:
1338 dma_pool_free(ha->chap_dma_pool, chap_table, chap_dma);
1339 return ret;
1340}
1341
1265static int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, 1342static int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username,
1266 char *password, uint16_t idx, int bidi) 1343 char *password, uint16_t idx, int bidi)
1267{ 1344{