All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muneendra <muneendra.kumar@broadcom.com>
To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	tj@kernel.org, linux-nvme@lists.infradead.org
Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com,
	pbonzini@redhat.com,
	Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Subject: [PATCH v4 10/19] lpfc: vmid: vmid resource allocation
Date: Mon,  9 Nov 2020 09:53:56 +0530	[thread overview]
Message-ID: <1604895845-2587-11-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com>

[-- Attachment #1: Type: text/plain, Size: 4412 bytes --]

From: Gaurav Srivastava <gaurav.srivastava@broadcom.com>

This patch allocates the resource for vmid and checks if the firmware
supports the feature or not.

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

---
v4:
No change

v3:
No change

v2:
Ported the patch on top of 5.10/scsi-queue
---
 drivers/scsi/lpfc/lpfc_init.c | 64 +++++++++++++++++++++++++++++++++++
 drivers/scsi/lpfc/lpfc_mbox.c |  6 ++++
 drivers/scsi/lpfc/lpfc_sli.c  |  9 +++++
 3 files changed, 79 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ca25e54bb782..e32d69515586 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4284,6 +4284,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 1;
+
+		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 1;
+		}
+	}
+	return 0;
+}
+
 /**
  * lpfc_create_port - Create an FC port
  * @phba: pointer to lpfc hba data structure.
@@ -4439,6 +4495,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);
@@ -4463,6 +4525,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_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4cd7ded656b7..51b99b7beaf9 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -7558,6 +7558,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.
-- 
2.26.2


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4177 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Muneendra <muneendra.kumar@broadcom.com>
To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	tj@kernel.org, linux-nvme@lists.infradead.org
Cc: pbonzini@redhat.com, jsmart2021@gmail.com, mkumar@redhat.com,
	emilne@redhat.com,
	Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Subject: [PATCH v4 10/19] lpfc: vmid: vmid resource allocation
Date: Mon,  9 Nov 2020 09:53:56 +0530	[thread overview]
Message-ID: <1604895845-2587-11-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com>


[-- Attachment #1.1: Type: text/plain, Size: 4412 bytes --]

From: Gaurav Srivastava <gaurav.srivastava@broadcom.com>

This patch allocates the resource for vmid and checks if the firmware
supports the feature or not.

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

---
v4:
No change

v3:
No change

v2:
Ported the patch on top of 5.10/scsi-queue
---
 drivers/scsi/lpfc/lpfc_init.c | 64 +++++++++++++++++++++++++++++++++++
 drivers/scsi/lpfc/lpfc_mbox.c |  6 ++++
 drivers/scsi/lpfc/lpfc_sli.c  |  9 +++++
 3 files changed, 79 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ca25e54bb782..e32d69515586 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4284,6 +4284,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 1;
+
+		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 1;
+		}
+	}
+	return 0;
+}
+
 /**
  * lpfc_create_port - Create an FC port
  * @phba: pointer to lpfc hba data structure.
@@ -4439,6 +4495,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);
@@ -4463,6 +4525,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_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4cd7ded656b7..51b99b7beaf9 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -7558,6 +7558,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.
-- 
2.26.2


[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4177 bytes --]

[-- Attachment #2: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-11-09 11:18 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09  4:23 [PATCH v4 00/19] blkcg:Support to track FC storage blk io traffic Muneendra
2020-11-09  4:23 ` Muneendra
2020-11-09  4:23 ` [PATCH v4 01/19] cgroup: Added cgroup_get_from_kernfs_id Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:25   ` Hannes Reinecke
2020-11-16  7:25     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 02/19] blkcg: Added a app identifier support for blkcg Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-09 13:55   ` Tejun Heo
2020-11-09 13:55     ` Tejun Heo
2020-11-16  7:31   ` Hannes Reinecke
2020-11-16  7:31     ` Hannes Reinecke
2020-11-18  9:39     ` Muneendra Kumar M
2020-11-18  9:39       ` Muneendra Kumar M
2020-11-09  4:23 ` [PATCH v4 03/19] nvme: Added a newsysfs attribute appid_store Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:39   ` Hannes Reinecke
2020-11-16  7:39     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 04/19] lpfc: vmid: Add the datastructure for supporting VMID in lpfc Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:41   ` Hannes Reinecke
2020-11-16  7:41     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 05/19] lpfc: vmid: API to check if VMID is enabled Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:44   ` Hannes Reinecke
2020-11-16  7:44     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 06/19] lpfc: vmid: Supplementary data structures for vmid Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:49   ` Hannes Reinecke
2020-11-16  7:49     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 07/19] lpfc: vmid: Forward declarations for APIs Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:50   ` Hannes Reinecke
2020-11-16  7:50     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 08/19] lpfc: vmid: Add support for vmid in mailbox command Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:52   ` Hannes Reinecke
2020-11-16  7:52     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 09/19] lpfc: vmid: VMID params initialization Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:53   ` Hannes Reinecke
2020-11-16  7:53     ` Hannes Reinecke
2020-11-09  4:23 ` Muneendra [this message]
2020-11-09  4:23   ` [PATCH v4 10/19] lpfc: vmid: vmid resource allocation Muneendra
2020-11-16  7:56   ` Hannes Reinecke
2020-11-16  7:56     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 11/19] lpfc: vmid: cleanup vmid resources Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  7:56   ` Hannes Reinecke
2020-11-16  7:56     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 12/19] lpfc: vmid: Implements ELS commands for appid patch Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  8:03   ` Hannes Reinecke
2020-11-16  8:03     ` Hannes Reinecke
2020-11-09  4:23 ` [PATCH v4 13/19] lpfc: vmid: Functions to manage vmids Muneendra
2020-11-09  4:23   ` Muneendra
2020-11-16  8:06   ` Hannes Reinecke
2020-11-16  8:06     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 14/19] lpfc: vmid: Implements CT commands for appid Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:08   ` Hannes Reinecke
2020-11-16  8:08     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 15/19] lpfc: vmid: Appends the vmid in the wqe before sending request Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:10   ` Hannes Reinecke
2020-11-16  8:10     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 16/19] lpfc: vmid: Timeout implementation for vmid Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:11   ` Hannes Reinecke
2020-11-16  8:11     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 17/19] lpfc: vmid: Adding qfpa and vmid timeout check in worker thread Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:12   ` Hannes Reinecke
2020-11-16  8:12     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 18/19] lpfc: vmid: Introducing vmid in io path Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:13   ` Hannes Reinecke
2020-11-16  8:13     ` Hannes Reinecke
2020-11-09  4:24 ` [PATCH v4 19/19] scsi: Made changes in Kconfig to select BLK_CGROUP_FC_APPID Muneendra
2020-11-09  4:24   ` Muneendra
2020-11-16  8:15   ` Hannes Reinecke
2020-11-16  8:15     ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1604895845-2587-11-git-send-email-muneendra.kumar@broadcom.com \
    --to=muneendra.kumar@broadcom.com \
    --cc=emilne@redhat.com \
    --cc=gaurav.srivastava@broadcom.com \
    --cc=jsmart2021@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkumar@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.