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: [RFC v2 10/18] lpfc: vmid: vmid resource allocation
Date: Mon, 19 Oct 2020 13:13:05 +0530 [thread overview]
Message-ID: <1603093393-12875-11-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1603093393-12875-1-git-send-email-muneendra.kumar@broadcom.com>
[-- Attachment #1.1: Type: text/plain, Size: 4382 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>
---
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
next prev parent reply other threads:[~2020-10-19 14:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 7:42 [RFC v2 00/18] blkcg:Support to track FC storage blk io traffic Muneendra
2020-10-19 7:42 ` [RFC v2 01/18] cgroup: Added cgroup_get_from_kernfs_id Muneendra
2020-10-19 14:43 ` Tejun Heo
2020-10-19 7:42 ` [RFC v2 02/18] blkcg: Added a app identifier support for blkcg Muneendra
2020-10-19 14:46 ` Tejun Heo
2020-10-19 15:13 ` Muneendra Kumar M
2020-10-19 15:19 ` Tejun Heo
2020-10-19 15:20 ` Muneendra Kumar M
2020-10-19 7:42 ` [RFC v2 03/18] nvme: Added a newsysfs attribute appid_store Muneendra
2020-10-19 7:42 ` [RFC v2 04/18] lpfc: vmid: Add the datastructure for supporting VMID in lpfc Muneendra
2020-10-19 7:43 ` [RFC v2 05/18] lpfc: vmid: API to check if VMID is enabled Muneendra
2020-10-19 7:43 ` [RFC v2 06/18] lpfc: vmid: Supplementary data structures for vmid Muneendra
2020-10-19 7:43 ` [RFC v2 07/18] lpfc: vmid: Forward declarations for APIs Muneendra
2020-10-19 7:43 ` [RFC v2 08/18] lpfc: vmid: Add support for vmid in mailbox command Muneendra
2020-10-19 7:43 ` [RFC v2 09/18] lpfc: vmid: VMID params initialization Muneendra
2020-10-19 7:43 ` Muneendra [this message]
2020-10-19 7:43 ` [RFC v2 11/18] lpfc: vmid: cleanup vmid resources Muneendra
2020-10-19 7:43 ` [RFC v2 12/18] lpfc: vmid: Implements ELS commands for appid patch Muneendra
2020-10-19 7:43 ` [RFC v2 13/18] lpfc: vmid: Functions to manage vmids Muneendra
2020-10-19 7:43 ` [RFC v2 14/18] lpfc: vmid: Implements CT commands for appid Muneendra
2020-10-19 7:43 ` [RFC v2 15/18] lpfc: vmid: Appends the vmid in the wqe before sending request Muneendra
2020-10-19 7:43 ` [RFC v2 16/18] lpfc: vmid: Timeout implementation for vmid Muneendra
2020-10-19 7:43 ` [RFC v2 17/18] lpfc: vmid: Adding qfpa and vmid timeout check in worker thread Muneendra
2020-10-19 7:43 ` [RFC v2 18/18] lpfc: vmid: Introducing vmid in io path Muneendra
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=1603093393-12875-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).