diff mbox series

[v5,11/16] lpfc: vmid: Implements CT commands for appid.

Message ID 1608096586-21656-12-git-send-email-muneendra.kumar@broadcom.com (mailing list archive)
State Superseded
Headers show
Series blkcg:Support to track FC storage blk io traffic | expand

Commit Message

Muneendra Kumar M Dec. 16, 2020, 5:29 a.m. UTC
From: Gaurav Srivastava <gaurav.srivastava@broadcom.com>

The patch implements CT commands for registering and deregistering the
appid for the application. Also, a small change in decrementing the ndlp
ref counter has been added.

Signed-off-by: Gaurav Srivastava  <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>

---
v5:
No change

v4:
No change

v3:
No change

v2:
Ported the patch on top of 5.10/scsi-queue
Removed redundant code due to changes since last submit
---
 drivers/scsi/lpfc/lpfc_ct.c | 249 ++++++++++++++++++++++++++++++++++++
 1 file changed, 249 insertions(+)

Comments

kernel test robot Dec. 16, 2020, 4:57 p.m. UTC | #1
Hi Muneendra,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next next-20201215]
[cannot apply to cgroup/for-next v5.10]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Muneendra/blkcg-Support-to-track-FC-storage-blk-io-traffic/20201216-202913
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/2c2a03c1111ef8a2c5aac440b227390d40d1e2cb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Muneendra/blkcg-Support-to-track-FC-storage-blk-io-traffic/20201216-202913
        git checkout 2c2a03c1111ef8a2c5aac440b227390d40d1e2cb
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/scsi/lpfc/lpfc_ct.c:3749:1: warning: no previous prototype for 'lpfc_cmpl_ct_cmd_vmid' [-Wmissing-prototypes]
    3749 | lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
         | ^~~~~~~~~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for FRAME_POINTER
   Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
   Selected by
   - FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86


vim +/lpfc_cmpl_ct_cmd_vmid +3749 drivers/scsi/lpfc/lpfc_ct.c

  3747	
  3748	void
> 3749	lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
  3750			      struct lpfc_iocbq *rspiocb)
  3751	{
  3752		struct lpfc_vport *vport = cmdiocb->vport;
  3753		struct lpfc_dmabuf *inp = cmdiocb->context1;
  3754		struct lpfc_dmabuf *outp = cmdiocb->context2;
  3755		struct lpfc_sli_ct_request *ctcmd = inp->virt;
  3756		struct lpfc_sli_ct_request *ctrsp = outp->virt;
  3757		u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
  3758		struct app_id_object *app;
  3759		u32 cmd, hash;
  3760		struct lpfc_vmid *vmp;
  3761		u8 *data = outp->virt;
  3762		int i;
  3763	
  3764		cmd = be16_to_cpu(ctcmd->CommandResponse.bits.CmdRsp);
  3765		if (cmd == SLI_CTAS_DALLAPP_ID)
  3766			lpfc_ct_free_iocb(phba, cmdiocb);
  3767	
  3768		if (lpfc_els_chk_latt(vport) || rspiocb->iocb.ulpStatus) {
  3769			if (cmd != SLI_CTAS_DALLAPP_ID)
  3770				return;
  3771		}
  3772		/* Check for a CT LS_RJT response */
  3773		if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
  3774			if (cmd != SLI_CTAS_DALLAPP_ID)
  3775				lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3776						 "3306 VMID FS_RJT Data: x%x  %x %x\n",
  3777					 cmd, ctrsp->ReasonCode, ctrsp->Explanation);
  3778			if ((cmd != SLI_CTAS_DALLAPP_ID) ||
  3779			    (ctrsp->ReasonCode != SLI_CT_UNABLE_TO_PERFORM_REQ) ||
  3780			    (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) {
  3781				/* If DALLAPP_ID failed retry later */
  3782				if (cmd == SLI_CTAS_DALLAPP_ID)
  3783					vport->load_flag |= FC_DEREGISTER_ALL_APP_ID;
  3784				return;
  3785			}
  3786		}
  3787	
  3788		switch (cmd) {
  3789		case SLI_CTAS_RAPP_IDENT:
  3790			app = (struct app_id_object *)(RAPP_IDENT_OFFSET + data);
  3791			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3792					 "6712 RAPP_IDENT app id %d  port id %x id\n"
  3793					 "len %d\n", be32_to_cpu(app->app_id),
  3794					 be32_to_cpu(app->port_id),
  3795					 app->obj.entity_id_len);
  3796	
  3797			if (app->obj.entity_id_len == 0 || app->port_id == 0)
  3798				return;
  3799	
  3800			hash = lpfc_vmid_hash_fn(app->obj.entity_id,
  3801						 app->obj.entity_id_len);
  3802			vmp = lpfc_get_vmid_from_hastable(vport, hash,
  3803							  app->obj.entity_id);
  3804			if (vmp) {
  3805				vmp->un.app_id = be32_to_cpu(app->app_id);
  3806				vmp->flag |= LPFC_VMID_REGISTERED;
  3807				vmp->flag &= ~LPFC_VMID_REQ_REGISTER;
  3808				/* Set IN USE flag */
  3809				vport->vmid_flag |= LPFC_VMID_IN_USE;
  3810			} else {
  3811				lpfc_printf_vlog(vport, KERN_DEBUG,
  3812						 LOG_DISCOVERY, "6901 No entry found\n"
  3813						 "%s hash %d\n", app->obj.entity_id,
  3814						 hash);
  3815			}
  3816			break;
  3817		case SLI_CTAS_DAPP_IDENT:
  3818			app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data);
  3819			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3820					 "6713 DAPP_IDENT app id %d  port id %x",
  3821					 cpu_to_be32(app->app_id),
  3822					 cpu_to_be32(app->port_id));
  3823			break;
  3824		case SLI_CTAS_DALLAPP_ID:
  3825			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3826					 "8856 Deregistered all app ids");
  3827			for (i = 0; i < phba->cfg_max_vmid; i++) {
  3828				vmp = &vport->vmid[i];
  3829				if (vmp->flag != LPFC_VMID_SLOT_FREE)
  3830					memset(vmp, 0, sizeof(struct lpfc_vmid));
  3831			}
  3832			for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
  3833				vport->hash_table[i] = NULL;
  3834			vport->load_flag |= FC_ALLOW_VMID;
  3835			break;
  3836		default:
  3837			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3838					 "8857 Invalid command code");
  3839		}
  3840	}
  3841	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Dec. 19, 2020, 11:27 p.m. UTC | #2
Hi Muneendra,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next next-20201218]
[cannot apply to cgroup/for-next v5.10]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Muneendra/blkcg-Support-to-track-FC-storage-blk-io-traffic/20201216-202913
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: powerpc64-randconfig-r023-20201217 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cee1e7d14f4628d6174b33640d502bff3b54ae45)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://github.com/0day-ci/linux/commit/2c2a03c1111ef8a2c5aac440b227390d40d1e2cb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Muneendra/blkcg-Support-to-track-FC-storage-blk-io-traffic/20201216-202913
        git checkout 2c2a03c1111ef8a2c5aac440b227390d40d1e2cb
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/scsi/lpfc/lpfc_ct.c:3749:1: warning: no previous prototype for function 'lpfc_cmpl_ct_cmd_vmid' [-Wmissing-prototypes]
   lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
   ^
   drivers/scsi/lpfc/lpfc_ct.c:3748:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void
   ^
   static 
   1 warning generated.


vim +/lpfc_cmpl_ct_cmd_vmid +3749 drivers/scsi/lpfc/lpfc_ct.c

  3747	
  3748	void
> 3749	lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
  3750			      struct lpfc_iocbq *rspiocb)
  3751	{
  3752		struct lpfc_vport *vport = cmdiocb->vport;
  3753		struct lpfc_dmabuf *inp = cmdiocb->context1;
  3754		struct lpfc_dmabuf *outp = cmdiocb->context2;
  3755		struct lpfc_sli_ct_request *ctcmd = inp->virt;
  3756		struct lpfc_sli_ct_request *ctrsp = outp->virt;
  3757		u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
  3758		struct app_id_object *app;
  3759		u32 cmd, hash;
  3760		struct lpfc_vmid *vmp;
  3761		u8 *data = outp->virt;
  3762		int i;
  3763	
  3764		cmd = be16_to_cpu(ctcmd->CommandResponse.bits.CmdRsp);
  3765		if (cmd == SLI_CTAS_DALLAPP_ID)
  3766			lpfc_ct_free_iocb(phba, cmdiocb);
  3767	
  3768		if (lpfc_els_chk_latt(vport) || rspiocb->iocb.ulpStatus) {
  3769			if (cmd != SLI_CTAS_DALLAPP_ID)
  3770				return;
  3771		}
  3772		/* Check for a CT LS_RJT response */
  3773		if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
  3774			if (cmd != SLI_CTAS_DALLAPP_ID)
  3775				lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3776						 "3306 VMID FS_RJT Data: x%x  %x %x\n",
  3777					 cmd, ctrsp->ReasonCode, ctrsp->Explanation);
  3778			if ((cmd != SLI_CTAS_DALLAPP_ID) ||
  3779			    (ctrsp->ReasonCode != SLI_CT_UNABLE_TO_PERFORM_REQ) ||
  3780			    (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) {
  3781				/* If DALLAPP_ID failed retry later */
  3782				if (cmd == SLI_CTAS_DALLAPP_ID)
  3783					vport->load_flag |= FC_DEREGISTER_ALL_APP_ID;
  3784				return;
  3785			}
  3786		}
  3787	
  3788		switch (cmd) {
  3789		case SLI_CTAS_RAPP_IDENT:
  3790			app = (struct app_id_object *)(RAPP_IDENT_OFFSET + data);
  3791			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3792					 "6712 RAPP_IDENT app id %d  port id %x id\n"
  3793					 "len %d\n", be32_to_cpu(app->app_id),
  3794					 be32_to_cpu(app->port_id),
  3795					 app->obj.entity_id_len);
  3796	
  3797			if (app->obj.entity_id_len == 0 || app->port_id == 0)
  3798				return;
  3799	
  3800			hash = lpfc_vmid_hash_fn(app->obj.entity_id,
  3801						 app->obj.entity_id_len);
  3802			vmp = lpfc_get_vmid_from_hastable(vport, hash,
  3803							  app->obj.entity_id);
  3804			if (vmp) {
  3805				vmp->un.app_id = be32_to_cpu(app->app_id);
  3806				vmp->flag |= LPFC_VMID_REGISTERED;
  3807				vmp->flag &= ~LPFC_VMID_REQ_REGISTER;
  3808				/* Set IN USE flag */
  3809				vport->vmid_flag |= LPFC_VMID_IN_USE;
  3810			} else {
  3811				lpfc_printf_vlog(vport, KERN_DEBUG,
  3812						 LOG_DISCOVERY, "6901 No entry found\n"
  3813						 "%s hash %d\n", app->obj.entity_id,
  3814						 hash);
  3815			}
  3816			break;
  3817		case SLI_CTAS_DAPP_IDENT:
  3818			app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data);
  3819			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3820					 "6713 DAPP_IDENT app id %d  port id %x",
  3821					 cpu_to_be32(app->app_id),
  3822					 cpu_to_be32(app->port_id));
  3823			break;
  3824		case SLI_CTAS_DALLAPP_ID:
  3825			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3826					 "8856 Deregistered all app ids");
  3827			for (i = 0; i < phba->cfg_max_vmid; i++) {
  3828				vmp = &vport->vmid[i];
  3829				if (vmp->flag != LPFC_VMID_SLOT_FREE)
  3830					memset(vmp, 0, sizeof(struct lpfc_vmid));
  3831			}
  3832			for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
  3833				vport->hash_table[i] = NULL;
  3834			vport->load_flag |= FC_ALLOW_VMID;
  3835			break;
  3836		default:
  3837			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
  3838					 "8857 Invalid command code");
  3839		}
  3840	}
  3841	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index dd0b432f7ac5..5099c46f4c4e 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -3744,3 +3744,252 @@  lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag)
 	}
 	return;
 }
+
+void
+lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
+		      struct lpfc_iocbq *rspiocb)
+{
+	struct lpfc_vport *vport = cmdiocb->vport;
+	struct lpfc_dmabuf *inp = cmdiocb->context1;
+	struct lpfc_dmabuf *outp = cmdiocb->context2;
+	struct lpfc_sli_ct_request *ctcmd = inp->virt;
+	struct lpfc_sli_ct_request *ctrsp = outp->virt;
+	u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
+	struct app_id_object *app;
+	u32 cmd, hash;
+	struct lpfc_vmid *vmp;
+	u8 *data = outp->virt;
+	int i;
+
+	cmd = be16_to_cpu(ctcmd->CommandResponse.bits.CmdRsp);
+	if (cmd == SLI_CTAS_DALLAPP_ID)
+		lpfc_ct_free_iocb(phba, cmdiocb);
+
+	if (lpfc_els_chk_latt(vport) || rspiocb->iocb.ulpStatus) {
+		if (cmd != SLI_CTAS_DALLAPP_ID)
+			return;
+	}
+	/* Check for a CT LS_RJT response */
+	if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
+		if (cmd != SLI_CTAS_DALLAPP_ID)
+			lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+					 "3306 VMID FS_RJT Data: x%x  %x %x\n",
+				 cmd, ctrsp->ReasonCode, ctrsp->Explanation);
+		if ((cmd != SLI_CTAS_DALLAPP_ID) ||
+		    (ctrsp->ReasonCode != SLI_CT_UNABLE_TO_PERFORM_REQ) ||
+		    (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) {
+			/* If DALLAPP_ID failed retry later */
+			if (cmd == SLI_CTAS_DALLAPP_ID)
+				vport->load_flag |= FC_DEREGISTER_ALL_APP_ID;
+			return;
+		}
+	}
+
+	switch (cmd) {
+	case SLI_CTAS_RAPP_IDENT:
+		app = (struct app_id_object *)(RAPP_IDENT_OFFSET + data);
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "6712 RAPP_IDENT app id %d  port id %x id\n"
+				 "len %d\n", be32_to_cpu(app->app_id),
+				 be32_to_cpu(app->port_id),
+				 app->obj.entity_id_len);
+
+		if (app->obj.entity_id_len == 0 || app->port_id == 0)
+			return;
+
+		hash = lpfc_vmid_hash_fn(app->obj.entity_id,
+					 app->obj.entity_id_len);
+		vmp = lpfc_get_vmid_from_hastable(vport, hash,
+						  app->obj.entity_id);
+		if (vmp) {
+			vmp->un.app_id = be32_to_cpu(app->app_id);
+			vmp->flag |= LPFC_VMID_REGISTERED;
+			vmp->flag &= ~LPFC_VMID_REQ_REGISTER;
+			/* Set IN USE flag */
+			vport->vmid_flag |= LPFC_VMID_IN_USE;
+		} else {
+			lpfc_printf_vlog(vport, KERN_DEBUG,
+					 LOG_DISCOVERY, "6901 No entry found\n"
+					 "%s hash %d\n", app->obj.entity_id,
+					 hash);
+		}
+		break;
+	case SLI_CTAS_DAPP_IDENT:
+		app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data);
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "6713 DAPP_IDENT app id %d  port id %x",
+				 cpu_to_be32(app->app_id),
+				 cpu_to_be32(app->port_id));
+		break;
+	case SLI_CTAS_DALLAPP_ID:
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "8856 Deregistered all app ids");
+		for (i = 0; i < phba->cfg_max_vmid; i++) {
+			vmp = &vport->vmid[i];
+			if (vmp->flag != LPFC_VMID_SLOT_FREE)
+				memset(vmp, 0, sizeof(struct lpfc_vmid));
+		}
+		for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
+			vport->hash_table[i] = NULL;
+		vport->load_flag |= FC_ALLOW_VMID;
+		break;
+	default:
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "8857 Invalid command code");
+	}
+}
+
+/**
+ * lpfc_vmid_cmd - Build and send a FDMI cmd to the specified NPort
+ * @vport: pointer to a host virtual N_Port data structure.
+ * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID)
+ * cmdcode: FDMI command to send
+ * mask: Mask of HBA or PORT Attributes to send
+ *
+ * Builds and sends a FDMI command using the CT subsystem.
+ */
+int
+lpfc_vmid_cmd(struct lpfc_vport *vport,
+	      int cmdcode, struct lpfc_vmid *vmid)
+{
+	struct lpfc_hba *phba = vport->phba;
+	struct lpfc_dmabuf *mp, *bmp;
+	struct lpfc_sli_ct_request *ctreq;
+	struct ulp_bde64 *bpl;
+	u32 size;
+	u32 rsp_size;
+	u8 *data;
+	struct lpfc_vmid_rapp_ident_list *rap;
+	struct lpfc_vmid_dapp_ident_list *dap;
+	u8 retry = 0;
+	struct lpfc_nodelist *ndlp;
+
+	void (*cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
+		     struct lpfc_iocbq *rspiocb);
+
+	ndlp = lpfc_findnode_did(vport, FDMI_DID);
+	if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
+		return 0;
+
+	cmpl = lpfc_cmpl_ct_cmd_vmid;
+
+	/* fill in BDEs for command */
+	/* Allocate buffer for command payload */
+	mp = kmalloc(sizeof(*mp), GFP_KERNEL);
+	if (!mp)
+		goto vmid_free_mp_exit;
+
+	mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
+	if (!mp->virt)
+		goto vmid_free_mp_virt_exit;
+
+	/* Allocate buffer for Buffer ptr list */
+	bmp = kmalloc(sizeof(*bmp), GFP_KERNEL);
+	if (!bmp)
+		goto vmid_free_bmp_exit;
+
+	bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys);
+	if (!bmp->virt)
+		goto vmid_free_bmp_virt_exit;
+
+	INIT_LIST_HEAD(&mp->list);
+	INIT_LIST_HEAD(&bmp->list);
+
+	lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
+			 "0218 VMID Request Data: x%x x%x x%x",
+			 vport->fc_flag, vport->port_state, cmdcode);
+	ctreq = (struct lpfc_sli_ct_request *)mp->virt;
+	data = mp->virt;
+	/* First populate the CT_IU preamble */
+	memset(data, 0, LPFC_BPL_SIZE);
+	ctreq->RevisionId.bits.Revision = SLI_CT_REVISION;
+	ctreq->RevisionId.bits.InId = 0;
+
+	ctreq->FsType = SLI_CT_MANAGEMENT_SERVICE;
+	ctreq->FsSubType = SLI_CT_APP_SEV_Subtypes;
+
+	ctreq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode);
+	rsp_size = LPFC_BPL_SIZE;
+	size = 0;
+
+	switch (cmdcode) {
+	case SLI_CTAS_RAPP_IDENT:
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "1329 RAPP_IDENT for %s", vmid->host_vmid);
+		ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
+		rap = (struct lpfc_vmid_rapp_ident_list *)
+			(DAPP_IDENT_OFFSET + data);
+		rap->no_of_objects = cpu_to_be32(1);
+		rap->obj[0].entity_id_len = vmid->vmid_len;
+		memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
+		size = RAPP_IDENT_OFFSET +
+			sizeof(struct lpfc_vmid_rapp_ident_list);
+		retry = 1;
+		break;
+
+	case SLI_CTAS_GALLAPPIA_ID:
+		ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
+		size = GALLAPPIA_ID_SIZE;
+		break;
+
+	case SLI_CTAS_DAPP_IDENT:
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "1469 DAPP_IDENT for %s", vmid->host_vmid);
+		ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
+		dap = (struct lpfc_vmid_dapp_ident_list *)
+			(DAPP_IDENT_OFFSET + data);
+		dap->no_of_objects = cpu_to_be32(1);
+		dap->obj[0].entity_id_len = vmid->vmid_len;
+		memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
+		size = DAPP_IDENT_OFFSET +
+			sizeof(struct lpfc_vmid_dapp_ident_list);
+		vmid->flag &= ~LPFC_VMID_REGISTERED;
+		retry = 1;
+		break;
+
+	case SLI_CTAS_DALLAPP_ID:
+		ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
+		size = DALLAPP_ID_SIZE;
+		break;
+
+	default:
+		lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+				 "7062 VMID cmdcode x%x not supported",
+				 cmdcode);
+		goto vmid_free_all_mem;
+	}
+
+	ctreq->CommandResponse.bits.Size = cpu_to_be16(rsp_size);
+
+	bpl = (struct ulp_bde64 *)bmp->virt;
+	bpl->addrHigh = putPaddrHigh(mp->phys);
+	bpl->addrLow = putPaddrLow(mp->phys);
+	bpl->tus.f.bdeFlags = 0;
+	bpl->tus.f.bdeSize = size;
+
+	/* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
+	 * to hold ndlp reference for the corresponding callback function.
+	 */
+	if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry))
+		return 0;
+
+	/* Decrement ndlp reference count to release ndlp reference held
+	 * for the failed command's callback function.
+	 */
+	lpfc_nlp_put(ndlp);
+
+ vmid_free_all_mem:
+	lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
+ vmid_free_bmp_virt_exit:
+	kfree(bmp);
+ vmid_free_bmp_exit:
+	lpfc_mbuf_free(phba, mp->virt, mp->phys);
+ vmid_free_mp_virt_exit:
+	kfree(mp);
+ vmid_free_mp_exit:
+
+	/* Issue FDMI request failed */
+	lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
+			 "0244 Issue FDMI request failed Data: x%x", cmdcode);
+	return FAILURE;
+}