diff mbox series

[v5,08/16] lpfc: vmid: Add support for vmid in mailbox command, does vmid resource allocation and vmid cleanup

Message ID 1608096586-21656-9-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>

This patch does the following -
1.adds supporting datastructures for mailbox command which helps in
determining if the firmware supports appid or not.
2.This patch allocates the resource for vmid and checks if the firmware
supports the feature or not.
3.The patch cleans up the vmid resources and stops the timer.

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

---
v5:
Merged patches 8 and 11 of v4 to this patch
Changed Return code to non-numeric/Symbol

v4:
No change

v3:
No change

v2:
Ported the patch on top of 5.10/scsi-queue
---
 drivers/scsi/lpfc/lpfc_hw4.h  | 12 +++++++
 drivers/scsi/lpfc/lpfc_init.c | 68 +++++++++++++++++++++++++++++++++++
 drivers/scsi/lpfc/lpfc_mbox.c |  6 ++++
 drivers/scsi/lpfc/lpfc_scsi.c | 21 +++++++++++
 drivers/scsi/lpfc/lpfc_sli.c  |  9 +++++
 5 files changed, 116 insertions(+)

Comments

kernel test robot Dec. 16, 2020, 3:13 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/03480ee8b62a90ab2917fccf45d0e56185c1f8a5
        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 03480ee8b62a90ab2917fccf45d0e56185c1f8a5
        # 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_init.c:4288:1: warning: no previous prototype for 'lpfc_vmid_res_alloc' [-Wmissing-prototypes]
    4288 | lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport)
         | ^~~~~~~~~~~~~~~~~~~

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_vmid_res_alloc +4288 drivers/scsi/lpfc/lpfc_init.c

  4275	
  4276	/**
  4277	 * lpfc_vmid_res_alloc - Allocates resources for VMID
  4278	 * @phba: pointer to lpfc hba data structure.
  4279	 * @vport: pointer to vport data structure
  4280	 *
  4281	 * This routine allocated the resources needed for the vmid.
  4282	 *
  4283	 * Return codes
  4284	 *	0 on Succeess
  4285	 *	Non-0 on Failure
  4286	 */
  4287	u8
> 4288	lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport)
  4289	{
  4290		u16 i;
  4291	
  4292		/* vmid feature is supported only on SLI4 */
  4293		if (phba->sli_rev == LPFC_SLI_REV3) {
  4294			phba->cfg_vmid_app_header = 0;
  4295			phba->cfg_vmid_priority_tagging = 0;
  4296		}
  4297	
  4298		/* if enabled, then allocated the resources */
  4299		if (lpfc_is_vmid_enabled(phba)) {
  4300			vport->vmid =
  4301			    kmalloc_array(phba->cfg_max_vmid, sizeof(struct lpfc_vmid),
  4302					  GFP_KERNEL);
  4303			if (!vport->vmid)
  4304				return FAILURE;
  4305	
  4306			memset(vport->vmid, 0,
  4307			       phba->cfg_max_vmid * sizeof(struct lpfc_vmid));
  4308	
  4309			rwlock_init(&vport->vmid_lock);
  4310	
  4311			/* setting the VMID parameters for the vport */
  4312			vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging;
  4313			vport->vmid_inactivity_timeout =
  4314			    phba->cfg_vmid_inactivity_timeout;
  4315			vport->max_vmid = phba->cfg_max_vmid;
  4316			vport->cur_vmid_cnt = 0;
  4317	
  4318			for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
  4319				vport->hash_table[i] = NULL;
  4320	
  4321			vport->vmid_priority_range = bitmap_zalloc
  4322				(LPFC_VMID_MAX_PRIORITY_RANGE, GFP_KERNEL);
  4323	
  4324			if (!vport->vmid_priority_range) {
  4325				kfree(vport->vmid);
  4326				return FAILURE;
  4327			}
  4328		}
  4329		return 0;
  4330	}
  4331	

---
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, 3:58 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/03480ee8b62a90ab2917fccf45d0e56185c1f8a5
        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 03480ee8b62a90ab2917fccf45d0e56185c1f8a5
        # 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_init.c:4288:1: warning: no previous prototype for function 'lpfc_vmid_res_alloc' [-Wmissing-prototypes]
   lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport)
   ^
   drivers/scsi/lpfc/lpfc_init.c:4287:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   u8
   ^
   static 
   1 warning generated.


vim +/lpfc_vmid_res_alloc +4288 drivers/scsi/lpfc/lpfc_init.c

  4275	
  4276	/**
  4277	 * lpfc_vmid_res_alloc - Allocates resources for VMID
  4278	 * @phba: pointer to lpfc hba data structure.
  4279	 * @vport: pointer to vport data structure
  4280	 *
  4281	 * This routine allocated the resources needed for the vmid.
  4282	 *
  4283	 * Return codes
  4284	 *	0 on Succeess
  4285	 *	Non-0 on Failure
  4286	 */
  4287	u8
> 4288	lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport)
  4289	{
  4290		u16 i;
  4291	
  4292		/* vmid feature is supported only on SLI4 */
  4293		if (phba->sli_rev == LPFC_SLI_REV3) {
  4294			phba->cfg_vmid_app_header = 0;
  4295			phba->cfg_vmid_priority_tagging = 0;
  4296		}
  4297	
  4298		/* if enabled, then allocated the resources */
  4299		if (lpfc_is_vmid_enabled(phba)) {
  4300			vport->vmid =
  4301			    kmalloc_array(phba->cfg_max_vmid, sizeof(struct lpfc_vmid),
  4302					  GFP_KERNEL);
  4303			if (!vport->vmid)
  4304				return FAILURE;
  4305	
  4306			memset(vport->vmid, 0,
  4307			       phba->cfg_max_vmid * sizeof(struct lpfc_vmid));
  4308	
  4309			rwlock_init(&vport->vmid_lock);
  4310	
  4311			/* setting the VMID parameters for the vport */
  4312			vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging;
  4313			vport->vmid_inactivity_timeout =
  4314			    phba->cfg_vmid_inactivity_timeout;
  4315			vport->max_vmid = phba->cfg_max_vmid;
  4316			vport->cur_vmid_cnt = 0;
  4317	
  4318			for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
  4319				vport->hash_table[i] = NULL;
  4320	
  4321			vport->vmid_priority_range = bitmap_zalloc
  4322				(LPFC_VMID_MAX_PRIORITY_RANGE, GFP_KERNEL);
  4323	
  4324			if (!vport->vmid_priority_range) {
  4325				kfree(vport->vmid);
  4326				return FAILURE;
  4327			}
  4328		}
  4329		return 0;
  4330	}
  4331	

---
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_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 541b9aef6bfe..5fdafc92fc2d 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -272,6 +272,9 @@  struct lpfc_sli4_flags {
 #define lpfc_vfi_rsrc_rdy_MASK		0x00000001
 #define lpfc_vfi_rsrc_rdy_WORD		word0
 #define LPFC_VFI_RSRC_RDY		1
+#define lpfc_ftr_ashdr_SHIFT            4
+#define lpfc_ftr_ashdr_MASK             0x00000001
+#define lpfc_ftr_ashdr_WORD             word0
 };
 
 struct sli4_bls_rsp {
@@ -2943,6 +2946,9 @@  struct lpfc_mbx_request_features {
 #define lpfc_mbx_rq_ftr_rq_mrqp_SHIFT		16
 #define lpfc_mbx_rq_ftr_rq_mrqp_MASK		0x00000001
 #define lpfc_mbx_rq_ftr_rq_mrqp_WORD		word2
+#define lpfc_mbx_rq_ftr_rq_ashdr_SHIFT          17
+#define lpfc_mbx_rq_ftr_rq_ashdr_MASK           0x00000001
+#define lpfc_mbx_rq_ftr_rq_ashdr_WORD           word2
 	uint32_t word3;
 #define lpfc_mbx_rq_ftr_rsp_iaab_SHIFT		0
 #define lpfc_mbx_rq_ftr_rsp_iaab_MASK		0x00000001
@@ -2974,6 +2980,9 @@  struct lpfc_mbx_request_features {
 #define lpfc_mbx_rq_ftr_rsp_mrqp_SHIFT		16
 #define lpfc_mbx_rq_ftr_rsp_mrqp_MASK		0x00000001
 #define lpfc_mbx_rq_ftr_rsp_mrqp_WORD		word3
+#define lpfc_mbx_rq_ftr_rsp_ashdr_SHIFT         17
+#define lpfc_mbx_rq_ftr_rsp_ashdr_MASK          0x00000001
+#define lpfc_mbx_rq_ftr_rsp_ashdr_WORD          word3
 };
 
 struct lpfc_mbx_supp_pages {
@@ -4391,6 +4400,9 @@  struct wqe_common {
 #define wqe_xchg_WORD         word10
 #define LPFC_SCSI_XCHG	      0x0
 #define LPFC_NVME_XCHG	      0x1
+#define wqe_appid_SHIFT       5
+#define wqe_appid_MASK        0x00000001
+#define wqe_appid_WORD        word10
 #define wqe_oas_SHIFT         6
 #define wqe_oas_MASK          0x00000001
 #define wqe_oas_WORD          word10
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ac67f420ec26..8318dfdc7d87 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -2843,6 +2843,10 @@  lpfc_cleanup(struct lpfc_vport *vport)
 	if (phba->link_state > LPFC_LINK_DOWN)
 		lpfc_port_link_failure(vport);
 
+	/* cleanup vmid resources */
+	if (lpfc_is_vmid_enabled(phba))
+		lpfc_vmid_vport_cleanup(vport);
+
 	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
 		if (vport->port_type != LPFC_PHYSICAL_PORT &&
 		    ndlp->nlp_DID == Fabric_DID) {
@@ -4269,6 +4273,62 @@  lpfc_get_wwpn(struct lpfc_hba *phba)
 		return rol64(wwn, 32);
 }
 
+/**
+ * lpfc_vmid_res_alloc - Allocates resources for VMID
+ * @phba: pointer to lpfc hba data structure.
+ * @vport: pointer to vport data structure
+ *
+ * This routine allocated the resources needed for the vmid.
+ *
+ * Return codes
+ *	0 on Succeess
+ *	Non-0 on Failure
+ */
+u8
+lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport)
+{
+	u16 i;
+
+	/* vmid feature is supported only on SLI4 */
+	if (phba->sli_rev == LPFC_SLI_REV3) {
+		phba->cfg_vmid_app_header = 0;
+		phba->cfg_vmid_priority_tagging = 0;
+	}
+
+	/* if enabled, then allocated the resources */
+	if (lpfc_is_vmid_enabled(phba)) {
+		vport->vmid =
+		    kmalloc_array(phba->cfg_max_vmid, sizeof(struct lpfc_vmid),
+				  GFP_KERNEL);
+		if (!vport->vmid)
+			return FAILURE;
+
+		memset(vport->vmid, 0,
+		       phba->cfg_max_vmid * sizeof(struct lpfc_vmid));
+
+		rwlock_init(&vport->vmid_lock);
+
+		/* setting the VMID parameters for the vport */
+		vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging;
+		vport->vmid_inactivity_timeout =
+		    phba->cfg_vmid_inactivity_timeout;
+		vport->max_vmid = phba->cfg_max_vmid;
+		vport->cur_vmid_cnt = 0;
+
+		for (i = 0; i < LPFC_VMID_HASH_SIZE; i++)
+			vport->hash_table[i] = NULL;
+
+		vport->vmid_priority_range = bitmap_zalloc
+			(LPFC_VMID_MAX_PRIORITY_RANGE, GFP_KERNEL);
+
+		if (!vport->vmid_priority_range) {
+			kfree(vport->vmid);
+			return FAILURE;
+		}
+	}
+	return 0;
+}
+
 /**
  * lpfc_create_port - Create an FC port
  * @phba: pointer to lpfc hba data structure.
@@ -4421,6 +4481,12 @@  lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
 			vport->port_type, shost->sg_tablesize,
 			phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt);
 
+	/* allocate the resources for vmid */
+	rc = lpfc_vmid_res_alloc(phba, vport);
+
+	if (rc)
+		goto out;
+
 	/* Initialize all internally managed lists. */
 	INIT_LIST_HEAD(&vport->fc_nodes);
 	INIT_LIST_HEAD(&vport->rcv_buffer_list);
@@ -4445,6 +4511,8 @@  lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
 	return vport;
 
 out_put_shost:
+	kfree(vport->vmid);
+	bitmap_free(vport->vmid_priority_range);
 	scsi_host_put(shost);
 out:
 	return NULL;
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 3414ffcb26fe..78a9b9baecf3 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -2100,6 +2100,12 @@  lpfc_request_features(struct lpfc_hba *phba, struct lpfcMboxq *mboxq)
 		bf_set(lpfc_mbx_rq_ftr_rq_iaab, &mboxq->u.mqe.un.req_ftrs, 0);
 		bf_set(lpfc_mbx_rq_ftr_rq_iaar, &mboxq->u.mqe.un.req_ftrs, 0);
 	}
+
+	/* Enable Application Services Header for apphedr VMID */
+	if (phba->cfg_vmid_app_header) {
+		bf_set(lpfc_mbx_rq_ftr_rq_ashdr, &mboxq->u.mqe.un.req_ftrs, 1);
+		bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 1);
+	}
 	return;
 }
 
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 3b989f720937..b79b6f03cdb6 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -5370,6 +5370,27 @@  lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
 	return 0;
 }
 
+/*
+ * lpfc_vmid_vport_cleanup - cleans up the resources associated with a vports
+ * @vport: The virtual port for which this call is being executed.
+ */
+void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport)
+{
+	/* delete the timer */
+	if (vport->port_type == LPFC_PHYSICAL_PORT)
+		del_timer_sync(&vport->phba->inactive_vmid_poll);
+
+	/* free the resources */
+	kfree(vport->qfpa_res);
+	kfree(vport->vmid_priority.vmid_range);
+	kfree(vport->vmid);
+
+	/* reset variables */
+	vport->qfpa_res = NULL;
+	vport->vmid_priority.vmid_range = NULL;
+	vport->vmid = NULL;
+	vport->cur_vmid_cnt = 0;
+}
 
 /**
  * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 95caad764fb7..f9b6e32db618 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -7696,6 +7696,15 @@  lpfc_sli4_hba_setup(struct lpfc_hba *phba)
 		goto out_free_mbox;
 	}
 
+	/* Disable vmid if app header is not supported */
+	if (phba->cfg_vmid_app_header && !(bf_get(lpfc_mbx_rq_ftr_rsp_ashdr,
+						  &mqe->un.req_ftrs))) {
+		bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 0);
+		phba->cfg_vmid_app_header = 0;
+		lpfc_printf_log(phba, KERN_DEBUG, LOG_SLI,
+				"1242 vmid feature not supported");
+	}
+
 	/*
 	 * The port must support FCP initiator mode as this is the
 	 * only mode running in the host.