Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] be2iscsi: Get Initiator Name for the iSCSI_Host

Implement the ISCSI_HOST_PARAM_INITIATOR_NAME for .get_host_param

Signed-off-by: John Soni Jose <sony.john-n@emulex.com>
Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

John Soni Jose and committed by
James Bottomley
2177199d 605c6cd2

+92
+2
drivers/scsi/be2iscsi/be_cmds.c
··· 15 15 * Costa Mesa, CA 92626 16 16 */ 17 17 18 + #include <scsi/iscsi_proto.h> 19 + 18 20 #include "be.h" 19 21 #include "be_mgmt.h" 20 22 #include "be_main.h"
+12
drivers/scsi/be2iscsi/be_cmds.h
··· 513 513 u32 rsvd[23]; 514 514 }; 515 515 516 + #define BEISCSI_ALIAS_LEN 32 517 + 518 + struct be_cmd_hba_name { 519 + struct be_cmd_req_hdr hdr; 520 + u16 flags; 521 + u16 rsvd0; 522 + u8 initiator_name[ISCSI_NAME_LEN]; 523 + u8 initiator_alias[BEISCSI_ALIAS_LEN]; 524 + } __packed; 525 + 526 + 516 527 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, 517 528 struct be_queue_info *eq, int eq_delay); 518 529 ··· 542 531 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, 543 532 struct beiscsi_hba *phba); 544 533 unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba); 534 + unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); 545 535 unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba); 546 536 unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba, 547 537 u32 boot_session_handle,
+50
drivers/scsi/be2iscsi/be_iscsi.c
··· 279 279 } 280 280 281 281 /** 282 + * beiscsi_get_initname - Read Initiator Name from flash 283 + * @buf: buffer bointer 284 + * @phba: The device priv structure instance 285 + * 286 + * returns number of bytes 287 + */ 288 + static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) 289 + { 290 + int rc; 291 + unsigned int tag, wrb_num; 292 + unsigned short status, extd_status; 293 + struct be_mcc_wrb *wrb; 294 + struct be_cmd_hba_name *resp; 295 + struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; 296 + 297 + tag = be_cmd_get_initname(phba); 298 + if (!tag) { 299 + SE_DEBUG(DBG_LVL_1, "Getting Initiator Name Failed\n"); 300 + return -EBUSY; 301 + } else 302 + wait_event_interruptible(phba->ctrl.mcc_wait[tag], 303 + phba->ctrl.mcc_numtag[tag]); 304 + 305 + wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; 306 + extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; 307 + status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; 308 + 309 + if (status || extd_status) { 310 + SE_DEBUG(DBG_LVL_1, "MailBox Command Failed with " 311 + "status = %d extd_status = %d\n", 312 + status, extd_status); 313 + free_mcc_tag(&phba->ctrl, tag); 314 + return -EAGAIN; 315 + } 316 + wrb = queue_get_wrb(mccq, wrb_num); 317 + free_mcc_tag(&phba->ctrl, tag); 318 + resp = embedded_payload(wrb); 319 + rc = sprintf(buf, "%s\n", resp->initiator_name); 320 + return rc; 321 + } 322 + 323 + /** 282 324 * beiscsi_get_host_param - get the iscsi parameter 283 325 * @shost: pointer to scsi_host structure 284 326 * @param: parameter type identifier ··· 340 298 status = beiscsi_get_macaddr(buf, phba); 341 299 if (status < 0) { 342 300 SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n"); 301 + return status; 302 + } 303 + break; 304 + case ISCSI_HOST_PARAM_INITIATOR_NAME: 305 + status = beiscsi_get_initname(buf, phba); 306 + if (status < 0) { 307 + SE_DEBUG(DBG_LVL_1, 308 + "Retreiving Initiator Name Failed\n"); 343 309 return status; 344 310 } 345 311 break;
+26
drivers/scsi/be2iscsi/be_mgmt.c
··· 447 447 return tag; 448 448 } 449 449 450 + unsigned int be_cmd_get_initname(struct beiscsi_hba *phba) 451 + { 452 + unsigned int tag = 0; 453 + struct be_mcc_wrb *wrb; 454 + struct be_cmd_hba_name *req; 455 + struct be_ctrl_info *ctrl = &phba->ctrl; 456 + 457 + spin_lock(&ctrl->mbox_lock); 458 + tag = alloc_mcc_tag(phba); 459 + if (!tag) { 460 + spin_unlock(&ctrl->mbox_lock); 461 + return tag; 462 + } 463 + 464 + wrb = wrb_from_mccq(phba); 465 + req = embedded_payload(wrb); 466 + wrb->tag0 |= tag; 467 + be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 468 + be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, 469 + OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, 470 + sizeof(*req)); 471 + 472 + be_mcc_notify(phba); 473 + spin_unlock(&ctrl->mbox_lock); 474 + return tag; 475 + }
+2
include/scsi/iscsi_proto.h
··· 661 661 662 662 #define ISCSI_DEF_TIME2WAIT 2 663 663 664 + #define ISCSI_NAME_LEN 224 665 + 664 666 /************************* RFC 3720 End *****************************/ 665 667 666 668 #endif /* ISCSI_PROTO_H */