From patchwork Mon Oct 19 07:43:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11844545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B109C433DF for ; Mon, 19 Oct 2020 14:37:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3849A222D9 for ; Mon, 19 Oct 2020 14:37:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="eDNlRCRU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729575AbgJSOhR (ORCPT ); Mon, 19 Oct 2020 10:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbgJSOhR (ORCPT ); Mon, 19 Oct 2020 10:37:17 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464E9C0613D0 for ; Mon, 19 Oct 2020 07:37:17 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id x13so68493pgp.7 for ; Mon, 19 Oct 2020 07:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ccMS9uvZTMBbdRbfwsuk3IaVlImO0MG0ZyHFGj5hA0M=; b=eDNlRCRUs8LvQUoNxgE6IfuHUIU4TFg8ZK+ja1a8iqsPvK/SZgjbBdgK7AThRkBeX/ 0hc4mZJocbRNd9R0wuzL3/cuSP+M9T4CrXh0qfMfaWthkHXSk2xIVhImEZfVU/KWN9JC ie3JDZVmv//vfCbJNqK1rmEb6pNQFIXidLwA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ccMS9uvZTMBbdRbfwsuk3IaVlImO0MG0ZyHFGj5hA0M=; b=NTsXYF57A4iiP11FflpK1g+B1gsBui/HWubmWKAeAWLpIZ3fn4A3DTEv1/fqdWa9ed SzAdylhA3K8kU08lWXzub3n6ZR2AJdWeWz/TeWy83jSa6iidv5k/M3T95zlR7GEjT8+d zKM6UZAqOn5L7eR5mov70QEV9YvszVJ/mUGsfpsoBMrd0qjKIKHg0VMrvr6LVptUxK/6 Nv/LBWvFqgMh5VXiqrYxs6tGaySgKyYVrreCLlUJbxa4oVVPQBIfbQB+NltZIJx0CuZJ OKut8EdamjSg7KPSo46hFgx6TGy4C05DF++MpbmnDDcWPgmy6tV8/PQiFr4LKLPK85QE qKqQ== X-Gm-Message-State: AOAM530hQMVHUQbkspiqMOEtXfEAWg3/Df9BDowFWUIJF4MEYm33lxb7 Eik0KMY/4XzQIDJQwQCDUI1MtkuJCtcPNkwg7uYFGK5X/1/gzLCewQpTGIAuJb4UDAlTz/vXqE5 bBMeh0BxWgIAAAMXyp59JSKKHIIRZKIjPXzWjDlYM0m2i9G85sklTPRNP+vfXXooqfr3bWSfolG V6f4Gwj5Kotyfu X-Google-Smtp-Source: ABdhPJyGVpkou5sCpia9KZTnSdiFIhb8ngXPym7Q3GepQbc1ybSN1xcJwy8Sk7L1f4KXwablD0vDFQ== X-Received: by 2002:a63:6547:: with SMTP id z68mr14547627pgb.411.1603118236261; Mon, 19 Oct 2020 07:37:16 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id kb15sm53377pjb.17.2020.10.19.07.37.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2020 07:37:15 -0700 (PDT) From: Muneendra 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 Subject: [RFC v2 10/18] lpfc: vmid: vmid resource allocation Date: Mon, 19 Oct 2020 13:13:05 +0530 Message-Id: <1603093393-12875-11-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603093393-12875-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603093393-12875-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gaurav Srivastava This patch allocates the resource for vmid and checks if the firmware supports the feature or not. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- 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.