From: Manish Rangankar <[email protected]>
Signed-off-by: Manish Rangankar <[email protected]>
Signed-off-by: Vikas Chaudhary <[email protected]>
---
drivers/scsi/qla4xxx/ql4_os.c | 69 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 62 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 171c0e4..5271807 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6977,17 +6977,72 @@ exit_login_st_clr_bit:
}
static int qla4xxx_ddb_login_nt(struct scsi_qla_host *ha,
- struct dev_db_entry *fw_ddb_entry,
+ struct dev_db_entry *sfw_ddb_entry,
uint16_t idx)
{
- int ret = QLA_ERROR;
+ struct ql4_tuple_ddb *temp_tddb = NULL;
+ struct ql4_tuple_ddb *src_tddb = NULL;
+ struct ddb_entry *ddb_entry = NULL;
+ struct iscsi_session *session = NULL;
+ uint8_t is_isid_compare;
+ int ret = QLA_ERROR, status;
+ int i, max_ddbs;
- ret = qla4xxx_is_session_exists(ha, fw_ddb_entry);
- if (ret != QLA_SUCCESS)
- ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, RESET_ADAPTER,
+ max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
+ MAX_DEV_DB_ENTRIES;
+
+ src_tddb = vzalloc(sizeof(*src_tddb));
+ if (!src_tddb) {
+ ql4_printk(KERN_WARNING, ha, "%s:Memory allocation failed\n",
+ __func__);
+ ret = -ENOMEM;
+ goto exit_ddb_login;
+ }
+
+ temp_tddb = vzalloc(sizeof(*temp_tddb));
+ if (!temp_tddb) {
+ ql4_printk(KERN_WARNING, ha, "%s:Memory allocation failed\n",
+ __func__);
+ ret = -ENOMEM;
+ goto exit_ddb_login;
+ }
+
+ qla4xxx_convert_param_ddb(sfw_ddb_entry, src_tddb, NULL);
+
+ for (i = 0; i < max_ddbs; i++) {
+ ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, i);
+ if (ddb_entry == NULL)
+ continue;
+
+ memset(temp_tddb, 0, sizeof(*temp_tddb));
+ qla4xxx_get_param_ddb(ddb_entry, temp_tddb);
+
+ if (ddb_entry->ddb_type != FLASH_DDB) {
+ is_isid_compare = false;
+ } else {
+ session = ddb_entry->sess->dd_data;
+ COPY_ISID(temp_tddb->isid, session->isid);
+ is_isid_compare = true;
+ }
+
+ status = qla4xxx_compare_tuple_ddb(ha, src_tddb, temp_tddb,
+ is_isid_compare);
+ if (status == QLA_SUCCESS) {
+ ret = -EEXIST;
+ goto exit_ddb_login;
+ } else {
+ continue;
+ }
+ }
+
+ if (i == max_ddbs)
+ ret = qla4xxx_sess_conn_setup(ha, sfw_ddb_entry, RESET_ADAPTER,
idx);
- else
- ret = -EPERM;
+exit_ddb_login:
+ if (src_tddb)
+ vfree(src_tddb);
+ if (temp_tddb)
+ vfree(temp_tddb);
return ret;
}
--
1.8.2.GIT
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html