From patchwork Wed Dec 16 05:29:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344753 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 B11ECC0018C for ; Wed, 16 Dec 2020 12:23:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E5D4230FA for ; Wed, 16 Dec 2020 12:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725891AbgLPMXb (ORCPT ); Wed, 16 Dec 2020 07:23:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgLPMXb (ORCPT ); Wed, 16 Dec 2020 07:23:31 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22562C0617A6 for ; Wed, 16 Dec 2020 04:22:51 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id c22so2099507pgg.13 for ; Wed, 16 Dec 2020 04:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XydzqVCIfvQOdz6sh1D78ve4Odu9PhRS+RbZjruU+y0=; b=Ljx5/y1WmwqufwBGtalwHHnyjg8OiaXIcPpXFOvStWFEe+KqfVZ3YOO6IOhjvuqeqJ T6qVbeF2sFWpqtvT/C7VIJJze0Ly+MO4qRDdqdAukMUH/Y95nFIJ1Ft8u3Imu3uijQZx IgKcIBT4cPfr4z0c98TGZpzQgogADq7aSmwa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XydzqVCIfvQOdz6sh1D78ve4Odu9PhRS+RbZjruU+y0=; b=FSrlIDpyKUiz3USJj+IjTKbmSb/jjvcr0p6uS1GMx60thChOHZEaO+Ulp5EmEmjV0F Q+bMvXxUmb5jLN0Cnx+v/IhJTP5Q78UlHWenHf0ncwB2TEWUFcUeo8xIy9qd5jVir5/Z LF2zaHGVLuXrotiPKe5V3ZII97X+JEcOWIoaRnpNyIPf/UaUe/mFbF6OhX1E/jYDf9NO 3lQaP/GyTbpE6hHeQQrJvUSA/k0I86gYm73ojRIXQB6+mQTwKq+4HOW92xMRp3kODGd/ R9vYH1cdnqLafxTTBp2dJizDXRpYSo8kD5YeMX8Z4mdbvuqq1VePVsWcuWX9jvo6Q4Dq LIcw== MIME-Version: 1.0 X-Gm-Message-State: AOAM531Y1yE8bYuqfTe6s5Y2NeluRtHftWdMXo+fS0ryr4mmJb5qZcuL uBdjxOzr7nfZMXkrHzdz43zkXIopylJVQy4au1Y3eARCILCc87HE06c54w65+kK7+m/hxbbucMe 7ZAkpP3PfwcoeE9wfU2DoLKk= X-Google-Smtp-Source: ABdhPJwbLrQTS3ScEIvote8nd17uCJZURZtOX20Ej/Cj2v79zmUPlKpWHBQJ+FmN/lBghLWX8vKybA== X-Received: by 2002:a63:da4f:: with SMTP id l15mr6405369pgj.22.1608121370565; Wed, 16 Dec 2020 04:22:50 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.22.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:22:49 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Muneendra Subject: [PATCH v5 01/16] cgroup: Added cgroup_get_from_id Date: Wed, 16 Dec 2020 10:59:31 +0530 Message-Id: <1608096586-21656-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new function cgroup_get_from_id to retrieve the cgroup associated with cgroup id. Exported the same as this can be used by blk-cgorup.c Added function declaration of cgroup_get_from_id in cgorup.h This patch also exported the function cgroup_get_e_css as this is getting used in blk-cgroup.h Signed-off-by: Muneendra --- v5: renamed the function cgroup_get_from_kernfs_id to cgroup_get_from_id v4: No change v3: Exported the cgroup_get_e_css v2: New patch --- include/linux/cgroup.h | 6 ++++++ kernel/cgroup/cgroup.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 618838c48313..da31b14db198 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -696,6 +696,7 @@ static inline void cgroup_kthread_ready(void) } void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen); +struct cgroup *cgroup_get_from_id(u64 id); #else /* !CONFIG_CGROUPS */ struct cgroup_subsys_state; @@ -743,6 +744,11 @@ static inline bool task_under_cgroup_hierarchy(struct task_struct *task, static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) {} + +static struct cgroup *cgroup_get_from_id(u64 id) +{ + return NULL; +} #endif /* !CONFIG_CGROUPS */ #ifdef CONFIG_CGROUPS diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index e41c21819ba0..34ebfbeba098 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -580,6 +580,7 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp, rcu_read_unlock(); return css; } +EXPORT_SYMBOL_GPL(cgroup_get_e_css); static void cgroup_get_live(struct cgroup *cgrp) { @@ -5805,6 +5806,31 @@ void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) kernfs_put(kn); } +/* + * cgroup_get_from_id : get the cgroup associated with cgroup id + * @id: cgroup id + * On success it returns the cgrp on failure it returns NULL + */ +struct cgroup *cgroup_get_from_id(u64 id) +{ + struct kernfs_node *kn; + struct cgroup *cgrp = NULL; + + mutex_lock(&cgroup_mutex); + kn = kernfs_find_and_get_node_by_id(cgrp_dfl_root.kf_root, id); + if (!kn) + goto out_unlock; + + cgrp = kn->priv; + if (cgroup_is_dead(cgrp) || !cgroup_tryget(cgrp)) + cgrp = NULL; + kernfs_put(kn); +out_unlock: + mutex_unlock(&cgroup_mutex); + return cgrp; +} +EXPORT_SYMBOL_GPL(cgroup_get_from_id); + /* * proc_cgroup_show() * - Print task's cgroup paths into seq_file, one line for each hierarchy From patchwork Wed Dec 16 05:29:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344752 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 0EE65C2BBCA for ; Wed, 16 Dec 2020 12:24:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D232423123 for ; Wed, 16 Dec 2020 12:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725945AbgLPMYI (ORCPT ); Wed, 16 Dec 2020 07:24:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgLPMYI (ORCPT ); Wed, 16 Dec 2020 07:24:08 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D21FC061282 for ; Wed, 16 Dec 2020 04:22:58 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id t8so16489662pfg.8 for ; Wed, 16 Dec 2020 04:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8rxhI7YUg8IkvGmlLzdfqofHE1JNNxW4E5HwkHULBVM=; b=Y5MGQcTgi4eKhCtI723qZBfv+5frh/DMxnx0byaT/dXgiPyI+Oadq3OfIZpTOM6A4n JXfSiR0eJLZ6czxkmUOPWIt4PA/NbbVTSKv1mCE4L/Cn2EZ0g01VuXiVq4V1Iz0Uk0P0 Fsk7otqJ4R7z8GsaKhCwKWZimTy6v5IjaNHOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8rxhI7YUg8IkvGmlLzdfqofHE1JNNxW4E5HwkHULBVM=; b=oFmUDYckEtLAa2wNw3cmPNI1eL+eBLkIKU+Kkm/GJ/dBh+/yJf9IKrDkXXW+CKfZKe 5VeBvgP8DMdYdMiYpNw9SWwN0Qv9TfbFAx/bTmhKjrVfiPOx8zLQwAtQZtHk+bFgQjRh WuP7NKAJw44VvBuGTUkHrNoYnfyY0TH4p8iLUU7WfQ4dbTNW1F9uS+BBP8zFWWYBnBsz 7jTU+n1UDTHBfKm5thY39ppzs3zj1zWiwgYUmtROvMJxmbkHtHDEwmR8BDUAbrs9e+VF 5FMM4qFEiDPkNm9D98Aoa2KRnsyr7KodjojFgFvrwHMHSrsV/72W81igjLOA2+/tPviQ eZtg== MIME-Version: 1.0 X-Gm-Message-State: AOAM532oUOCAMkUsU3YnbC14E/igTOYQHXkCXsq0ky4jCTlK1/9z8abY Pc91aG5lP6iENPwpqCJlfl4nL4IQJgVKKbrVYfkn477A+wT11baLG9MexBPNjjgFQwU3bKbc85p HQyG/s72TCv5gBHZ++xHxmOw= X-Google-Smtp-Source: ABdhPJxNxXr1wDwqCu55kmcD4DMmKHPiRz3q1M7dhLZnna71/m8Oim6D2lbIXvQY50VzkhYbV9CphA== X-Received: by 2002:aa7:8ac1:0:b029:19d:beff:4e0f with SMTP id b1-20020aa78ac10000b029019dbeff4e0fmr3580778pfd.0.1608121377683; Wed, 16 Dec 2020 04:22:57 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.22.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:22:57 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Muneendra Subject: [PATCH v5 03/16] nvme: Added a newsysfs attribute appid_store Date: Wed, 16 Dec 2020 10:59:33 +0530 Message-Id: <1608096586-21656-4-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new sysfs attribute appid_store under /sys/class/fc/fc_udev_device/* With this new interface the user can set the application identfier in the blkcg associted with cgroup id. Once the application identifer has set with this interface it allows identification of traffic sources at an individual cgroup based Applications (ex:virtual machine (VM))level in both host and fabric infrastructure(FC). Below is the interface provided to set the app_id echo ":" >> /sys/class/fc/fc_udev_device/appid_store echo "457E:100000109b521d27" >> /sys/class/fc/fc_udev_device/appid_store Signed-off-by: Muneendra --- v5: Replaced APPID_LEN with FC_APPID_LEN v4: No change v3: Replaced blkcg_set_app_identifier function with blkcg_set_fc_appid v2: New Patch --- drivers/nvme/host/fc.c | 73 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 3c002bdcace3..ed689ba773b1 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -9,7 +9,7 @@ #include #include #include - +#include #include "nvme.h" #include "fabrics.h" #include @@ -3821,10 +3821,81 @@ static ssize_t nvme_fc_nvme_discovery_store(struct device *dev, return count; } + +/*parse the Cgroup id from a buf and returns the length of cgrpid*/ +static int fc_parse_cgrpid(const char *buf, u64 *id) +{ + char cgrp_id[16+1]; + int cgrpid_len, j; + + memset(cgrp_id, 0x0, sizeof(cgrp_id)); + for (cgrpid_len = 0, j = 0; cgrpid_len < 17; cgrpid_len++) { + if (buf[cgrpid_len] != ':') + cgrp_id[cgrpid_len] = buf[cgrpid_len]; + else { + j = 1; + break; + } + } + if (!j) + return -EINVAL; + if (kstrtou64(cgrp_id, 16, id) < 0) + return -EINVAL; + return cgrpid_len; +} + +/* + * fc_update_appid :parses and updates the appid in the blkcg associated with + * cgroupid. + * @buf: buf contains both cgrpid and appid info + * @count: size of the buffer + */ +static int fc_update_appid(const char *buf, size_t count) +{ + u64 cgrp_id; + int appid_len = 0; + int cgrpid_len = 0; + char app_id[FC_APPID_LEN]; + int ret = 0; + + if (buf[count-1] == '\n') + count--; + + if ((count > (16+1+FC_APPID_LEN)) || (!strchr(buf, ':'))) + return -EINVAL; + + cgrpid_len = fc_parse_cgrpid(buf, &cgrp_id); + if (cgrpid_len < 0) + return -EINVAL; + /*appid len is count - cgrpid_len -1 (: + \n) */ + appid_len = count - cgrpid_len - 1; + if (appid_len > FC_APPID_LEN) + return -EINVAL; + + memset(app_id, 0x0, sizeof(app_id)); + memcpy(app_id, &buf[cgrpid_len+1], appid_len); + ret = blkcg_set_fc_appid(app_id, cgrp_id, sizeof(app_id)); + if (ret < 0) + return ret; + return count; +} + +static ssize_t fc_appid_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int ret = 0; + + ret = fc_update_appid(buf, count); + if (ret < 0) + return -EINVAL; + return count; +} static DEVICE_ATTR(nvme_discovery, 0200, NULL, nvme_fc_nvme_discovery_store); +static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store); static struct attribute *nvme_fc_attrs[] = { &dev_attr_nvme_discovery.attr, + &dev_attr_appid_store.attr, NULL }; From patchwork Wed Dec 16 05:29:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344751 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 75EFFC2BBD4 for ; Wed, 16 Dec 2020 12:24:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48E16233A1 for ; Wed, 16 Dec 2020 12:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725954AbgLPMYL (ORCPT ); Wed, 16 Dec 2020 07:24:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgLPMYL (ORCPT ); Wed, 16 Dec 2020 07:24:11 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2C0C0611C5 for ; Wed, 16 Dec 2020 04:23:05 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id b5so1516508pjl.0 for ; Wed, 16 Dec 2020 04:23:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0llmgFbWb/vhI9FeqAqVUPfKgPP4R0ngwOqpuPvFMjM=; b=Mx6d7tsZ8M5ePy9O/6VsWo2gsQCkbJFxl+a3dCpJhPOorZwBdf2TBR5dvmNXdmBUf/ UWFNNWucic2DGDom5wqQSEobs92BpBA5XRoqjU4h7Jkhe8sNfMhMVZREOys+D79YzC37 xIYM6ke1t6bYHl6aIrTNor5enBMz9qHuDTl7U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0llmgFbWb/vhI9FeqAqVUPfKgPP4R0ngwOqpuPvFMjM=; b=Zh6Mvzbtsy7AW4HHbi2zb20RLVAmzp5yodBYI230Ixv4788/b7s6PGGiftiySNKm9N 0GR9eY7Hm+36yVfF0vg5lZ2WJCkrg3YrDILf06fyO7bQni6JxfX3RYl1fTABhmdakMI0 QM2U1EOzssW/4ozZaluuEUf5rzuoAFaTIP0+qfMDLfJkpZ/l7EvByZvh/7czzHhG+qPz ba00DTB9fqJq+yHHX9f1bHhtj3yyMiw+ucssikBNJudfQKnYP8vBLlbQp2BZgm5ieKAp /+FpfDWO3WGy9TizkbALoA8M0t8APkG/Va8pqd9kIzdzk1ijPKdRuPS7005IDwh3RQKO Flxw== MIME-Version: 1.0 X-Gm-Message-State: AOAM530L9q5YrAUkOoXRWYk/wX6QmxBuL7mnXeTCPJUgQyA86l/9Cwje KacG7hMuKzapReuO0uXgjdjg6TVMeyZpqeaTVuvWvpEDh3KzeQyTjqPEhkuom6A5+bYoVgp2y2N EiRaSX+NoKQ1s X-Google-Smtp-Source: ABdhPJx4VPU5gCQqywr4oCn6KwF0E15ODW+gRZ5BQ1WNFPFNF0mF4e0GVmDc+uxBVtzujuETskltTg== X-Received: by 2002:a17:90a:6a48:: with SMTP id d8mr2854235pjm.130.1608121384941; Wed, 16 Dec 2020 04:23:04 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:04 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 05/16] lpfc: vmid: Supplementary data structures for vmid and APIs Date: Wed, 16 Dec 2020 10:59:35 +0530 Message-Id: <1608096586-21656-6-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch adds additional data structures for supporting the two versions of vmid implementation. First type uses app header while the other types uses priority tagging mechanism. These data structures are used mostly for ELS and CT commands for the two vmid implementation. The API determines if VMID is enabled by the user or not. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v5: Merged the patch5 of v4 to this patch Uniform data type naming scheme v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc.h | 24 +++++++ drivers/scsi/lpfc/lpfc_disc.h | 1 + drivers/scsi/lpfc/lpfc_hw.h | 124 ++++++++++++++++++++++++++++++++-- drivers/scsi/lpfc/lpfc_sli.h | 8 +++ 4 files changed, 153 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index ab61352363d4..6d9617c47db0 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1513,3 +1513,27 @@ static const char *routine(enum enum_name table_key) \ } \ return name; \ } + +/** + * lpfc_is_vmid_enabled - returns if VMID is enabled for either switch types + * @phba: Pointer to HBA context object. + * + * Relationship between the enable, target support and if vmid tag is required + * for the particular combination + * --------------------------------------------------- + * Switch Enable Flag Target Support VMID Needed + * --------------------------------------------------- + * App Id 0 NA N + * App Id 1 0 N + * App Id 1 1 Y + * Pr Tag 0 NA N + * Pr Tag 1 0 N + * Pr Tag 1 1 Y + * Pr Tag 2 * Y + --------------------------------------------------- + * + **/ +static inline int lpfc_is_vmid_enabled(struct lpfc_hba *phba) +{ + return phba->cfg_vmid_app_header || phba->cfg_vmid_priority_tagging; +} diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index ea07afcb750a..25d119c005dd 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h @@ -117,6 +117,7 @@ struct lpfc_nodelist { uint8_t nlp_fcp_info; /* class info, bits 0-3 */ #define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */ u8 nlp_nvme_info; /* NVME NSLER Support */ + uint8_t vmid_support; /* destination VMID support */ #define NLP_NVME_NSLER 0x1 /* NVME NSLER device */ struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 42682d95af52..4a5a85ed42ec 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -275,6 +275,7 @@ struct lpfc_sli_ct_request { #define SLI_CT_ACCESS_DENIED 0x10 #define SLI_CT_INVALID_PORT_ID 0x11 #define SLI_CT_DATABASE_EMPTY 0x12 +#define SLI_CT_APP_ID_NOT_AVAILABLE 0x40 /* * Name Server Command Codes @@ -400,16 +401,16 @@ struct csp { uint16_t altBbCredit:1; /* FC Word 1, bit 27 */ uint16_t edtovResolution:1; /* FC Word 1, bit 26 */ uint16_t multicast:1; /* FC Word 1, bit 25 */ - uint16_t broadcast:1; /* FC Word 1, bit 24 */ + uint16_t app_hdr_support:1; /* FC Word 1, bit 24 */ - uint16_t huntgroup:1; /* FC Word 1, bit 23 */ + uint16_t priority_tagging:1; /* FC Word 1, bit 23 */ uint16_t simplex:1; /* FC Word 1, bit 22 */ uint16_t word1Reserved1:3; /* FC Word 1, bit 21:19 */ uint16_t dhd:1; /* FC Word 1, bit 18 */ uint16_t contIncSeqCnt:1; /* FC Word 1, bit 17 */ uint16_t payloadlength:1; /* FC Word 1, bit 16 */ #else /* __LITTLE_ENDIAN_BITFIELD */ - uint16_t broadcast:1; /* FC Word 1, bit 24 */ + uint16_t app_hdr_support:1; /* FC Word 1, bit 24 */ uint16_t multicast:1; /* FC Word 1, bit 25 */ uint16_t edtovResolution:1; /* FC Word 1, bit 26 */ uint16_t altBbCredit:1; /* FC Word 1, bit 27 */ @@ -423,7 +424,7 @@ struct csp { uint16_t dhd:1; /* FC Word 1, bit 18 */ uint16_t word1Reserved1:3; /* FC Word 1, bit 21:19 */ uint16_t simplex:1; /* FC Word 1, bit 22 */ - uint16_t huntgroup:1; /* FC Word 1, bit 23 */ + uint16_t priority_tagging:1; /* FC Word 1, bit 23 */ #endif uint8_t bbRcvSizeMsb; /* Upper nibble is reserved */ @@ -607,6 +608,8 @@ struct fc_vft_header { #define ELS_CMD_LIRR 0x7A000000 #define ELS_CMD_LCB 0x81000000 #define ELS_CMD_FPIN 0x16000000 +#define ELS_CMD_QFPA 0xB0000000 +#define ELS_CMD_UVEM 0xB1000000 #else /* __LITTLE_ENDIAN_BITFIELD */ #define ELS_CMD_MASK 0xffff #define ELS_RSP_MASK 0xff @@ -649,6 +652,8 @@ struct fc_vft_header { #define ELS_CMD_LIRR 0x7A #define ELS_CMD_LCB 0x81 #define ELS_CMD_FPIN ELS_FPIN +#define ELS_CMD_QFPA 0xB0 +#define ELS_CMD_UVEM 0xB1 #endif /* @@ -1317,6 +1322,117 @@ struct fc_rdp_res_frame { }; +/* UVEM */ + +#define LPFC_UVEM_SIZE 60 +#define LPFC_UVEM_VEM_ID_DESC_SIZE 16 +#define LPFC_UVEM_VE_MAP_DESC_SIZE 20 + +#define VEM_ID_DESC_TAG 0x0001000A +struct lpfc_vem_id_desc { + uint32_t tag; + uint32_t length; + uint8_t vem_id[16]; +}; + +#define LPFC_QFPA_SIZE 4 + +#define INSTANTIATED_VE_DESC_TAG 0x0001000B +struct instantiated_ve_desc { + uint32_t tag; + uint32_t length; + uint8_t global_vem_id[16]; + uint32_t word6; +#define lpfc_instantiated_local_id_SHIFT 0 +#define lpfc_instantiated_local_id_MASK 0x000000ff +#define lpfc_instantiated_local_id_WORD word6 +#define lpfc_instantiated_nport_id_SHIFT 8 +#define lpfc_instantiated_nport_id_MASK 0x00ffffff +#define lpfc_instantiated_nport_id_WORD word6 +}; + +#define DEINSTANTIATED_VE_DESC_TAG 0x0001000C +struct deinstantiated_ve_desc { + uint32_t tag; + uint32_t length; + uint8_t global_vem_id[16]; + uint32_t word6; +#define lpfc_deinstantiated_nport_id_SHIFT 0 +#define lpfc_deinstantiated_nport_id_MASK 0x000000ff +#define lpfc_deinstantiated_nport_id_WORD word6 +#define lpfc_deinstantiated_local_id_SHIFT 24 +#define lpfc_deinstantiated_local_id_MASK 0x00ffffff +#define lpfc_deinstantiated_local_id_WORD word6 +}; + +/* Query Fabric Priority Allocation Response */ +#define LPFC_PRIORITY_RANGE_DESC_SIZE 12 + +struct priority_range_desc { + uint32_t tag; + uint32_t length; + uint8_t lo_range; + uint8_t hi_range; + uint8_t qos_priority; + uint8_t local_ve_id; +}; + +struct fc_qfpa_res { + uint32_t reply_sequence; /* LS_ACC or LS_RJT */ + uint32_t length; /* FC Word 1 */ + struct priority_range_desc desc[1]; +}; + +/* Application Server command code */ +/* VMID */ + +#define SLI_CT_APP_SEV_Subtypes 0x20 /* Application Server subtype */ + +#define SLI_CTAS_GAPPIA_ENT 0x0100 /* Get Application Identifier */ +#define SLI_CTAS_GALLAPPIA 0x0101 /* Get All Application Identifier */ +#define SLI_CTAS_GALLAPPIA_ID 0x0102 /* Get All Application Identifier */ + /* for Nport */ +#define SLI_CTAS_GAPPIA_IDAPP 0x0103 /* Get Application Identifier */ + /* for Nport */ +#define SLI_CTAS_RAPP_IDENT 0x0200 /* Register Application Identifier */ +#define SLI_CTAS_DAPP_IDENT 0x0300 /* Deregister Application */ + /* Identifier */ +#define SLI_CTAS_DALLAPP_ID 0x0301 /* Deregister All Application */ + /* Identifier */ + +struct entity_id_object { + uint8_t entity_id_len; + uint8_t entity_id[255]; /* VM UUID */ +}; + +struct app_id_object { + uint32_t port_id; + uint32_t app_id; + struct entity_id_object obj; +}; + +struct lpfc_vmid_rapp_ident_list { + uint32_t no_of_objects; + struct entity_id_object obj[1]; +}; + +struct lpfc_vmid_dapp_ident_list { + uint32_t no_of_objects; + struct entity_id_object obj[1]; +}; + +#define GALLAPPIA_ID_LAST 0x80 +struct lpfc_vmid_gallapp_ident_list { + uint8_t control; + uint8_t reserved[3]; + struct app_id_object app_id; +}; + +#define RAPP_IDENT_OFFSET (offsetof(struct lpfc_sli_ct_request, un) + 4) +#define DAPP_IDENT_OFFSET (offsetof(struct lpfc_sli_ct_request, un) + 4) +#define GALLAPPIA_ID_SIZE (offsetof(struct lpfc_sli_ct_request, un) + 4) +#define DALLAPP_ID_SIZE (offsetof(struct lpfc_sli_ct_request, un) + 4) + /******** FDMI ********/ /* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */ diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h index 4f6936014ff5..ff5a2a492405 100644 --- a/drivers/scsi/lpfc/lpfc_sli.h +++ b/drivers/scsi/lpfc/lpfc_sli.h @@ -35,6 +35,12 @@ typedef enum _lpfc_ctx_cmd { LPFC_CTX_HOST } lpfc_ctx_cmd; +union lpfc_vmid_iocb_tag { + uint32_t app_id; + uint8_t cs_ctl_vmid; + struct lpfc_vmid_context *vmid_context; /* UVEM context information */ +}; + struct lpfc_cq_event { struct list_head list; uint16_t hdwq; @@ -100,6 +106,7 @@ struct lpfc_iocbq { #define LPFC_IO_NVME 0x200000 /* NVME FCP command */ #define LPFC_IO_NVME_LS 0x400000 /* NVME LS command */ #define LPFC_IO_NVMET 0x800000 /* NVMET command */ +#define LPFC_IO_VMID 0x1000000 /* VMID tagged IO */ uint32_t drvrTimeout; /* driver timeout in seconds */ struct lpfc_vport *vport;/* virtual port pointer */ @@ -114,6 +121,7 @@ struct lpfc_iocbq { struct lpfc_node_rrq *rrq; } context_un; + union lpfc_vmid_iocb_tag vmid_tag; void (*fabric_iocb_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *, struct lpfc_iocbq *); void (*wait_iocb_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *, From patchwork Wed Dec 16 05:29:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344750 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 52214C3526C for ; Wed, 16 Dec 2020 12:24:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16A81233CF for ; Wed, 16 Dec 2020 12:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725957AbgLPMYP (ORCPT ); Wed, 16 Dec 2020 07:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgLPMYP (ORCPT ); Wed, 16 Dec 2020 07:24:15 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5BD2C0611CD for ; Wed, 16 Dec 2020 04:23:12 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id m6so6751621pfm.6 for ; Wed, 16 Dec 2020 04:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BEQqln29eaiclCpyhZmJXavsCzBgob0v96HbVR7Pd40=; b=J9l4FIDjQrNuegQtot/GJn94EW0ar/TyjOEbEMBF61hqAN1wirXKD1o4uV9Dgm5Bbs 1rySrc/UcmbbZ3Otd4GFyUZ/D+1kXabBm6tCb6TNfKwHk1DKKecHKu7OoNlOTBrlPtec zIBU9c5rXaDe9teTjMcdVxQXTetwiOtii2hzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BEQqln29eaiclCpyhZmJXavsCzBgob0v96HbVR7Pd40=; b=iFOnxJHLL7GOidjnFWyy8Fgva/aBwSQoPaS98QG797sHc6TiCpIVA3NmxVkXtL39VE mlAw4XD+PN37LmuLsx6bLVe1/YvHQn3yQa0+yccxrmY04rBUDwKeDkLDcQG4rbZPrMCB uErMmZhK4gOM2YWvfyPPe1SvKUsQn6plGnVnd6RvOCmwXSX0G1AOsxmBJo1T9GfLnQYn oeU4aZPgXMFs8wn8BiJN6Iteib5PCRx+bC+zM1jKYzp6sF+8jeDlqmB8UVWRGAAMUvc/ OhDfXi+NHE8XCBumRuDvjCNlLP6rV2RdhhKnDvS8SSqk1/pKW4/+vT7RasTp0huyXGsQ eAXQ== MIME-Version: 1.0 X-Gm-Message-State: AOAM5301iadyV7U14dZZEXZsR+tpJ2JZYC5K1LLLeB2NV9IkNLJM0qX8 NnNtr4LaMVqoBKSDHdIPe6jEbdHQy0It4bOwATB+2Wwwv7omm0MTLiHnRDRNThg4Csj/y/2jV2D ziXYQ5U2+tdnl X-Google-Smtp-Source: ABdhPJwIUtauJQL9UdezhJRTC+FhX5P8ujtXz3QzOpTc2EEI7XvaZytCYO45hFCtETFnxjg9+o4jkA== X-Received: by 2002:a63:e0f:: with SMTP id d15mr32147358pgl.310.1608121392072; Wed, 16 Dec 2020 04:23:12 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:11 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 07/16] lpfc: vmid: VMID params initialization Date: Wed, 16 Dec 2020 10:59:37 +0530 Message-Id: <1608096586-21656-8-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch initializes the VMID parameters like the type of vmid, max number of vmids supported and timeout value for the vmid registration based on the user input. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v5: No change v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_attr.c | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 4528166dee36..d8cca950fa3b 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -6151,6 +6151,44 @@ LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); */ LPFC_ATTR_R(enable_mi, 1, 0, 1, "Enable MI"); +/* + * lpfc_max_vmid: Maximum number of VMs to be tagged. This is valid only if + * either vmid_app_header or vmid_priority_tagging is enabled. + * 4 - 255 = vmid support enabled for 4-255 VMs + * Value range is [4,255]. + */ +LPFC_ATTR_RW(max_vmid, LPFC_MIN_VMID, LPFC_MIN_VMID, LPFC_MAX_VMID, + "Maximum number of VMs supported"); + +/* + * lpfc_vmid_inactivity_timeout: Inactivity timeout duration in hours + * 0 = Timeout is disabled + * Value range is [0,24]. + */ +LPFC_ATTR_RW(vmid_inactivity_timeout, 4, 0, 24, + "Inactivity timeout in hours"); + +/* + * lpfc_vmid_app_header: Enable App Header VMID support + * 0 = Support is disabled (default) + * 1 = Support is enabled + * Value range is [0,1]. + */ +LPFC_ATTR_RW(vmid_app_header, LPFC_VMID_APP_HEADER_DISABLE, + LPFC_VMID_APP_HEADER_DISABLE, LPFC_VMID_APP_HEADER_ENABLE, + "Enable App Header VMID support"); + +/* + * lpfc_vmid_priority_tagging: Enable Priority Tagging VMID support + * 0 = Support is disabled (default) + * 1 = Support is enabled + * Value range is [0,1].. + */ +LPFC_ATTR_RW(vmid_priority_tagging, LPFC_VMID_PRIO_TAG_DISABLE, + LPFC_VMID_PRIO_TAG_DISABLE, + LPFC_VMID_PRIO_TAG_ALL_TARGETS, + "Enable Priority Tagging VMID support"); + struct device_attribute *lpfc_hba_attrs[] = { &dev_attr_nvme_info, &dev_attr_scsi_stat, @@ -6269,6 +6307,10 @@ struct device_attribute *lpfc_hba_attrs[] = { &dev_attr_lpfc_enable_bbcr, &dev_attr_lpfc_enable_dpp, &dev_attr_lpfc_enable_mi, + &dev_attr_lpfc_max_vmid, + &dev_attr_lpfc_vmid_inactivity_timeout, + &dev_attr_lpfc_vmid_app_header, + &dev_attr_lpfc_vmid_priority_tagging, NULL, }; @@ -7328,6 +7370,11 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); lpfc_EnableXLane_init(phba, lpfc_EnableXLane); + /* VMID Inits */ + lpfc_max_vmid_init(phba, lpfc_max_vmid); + lpfc_vmid_inactivity_timeout_init(phba, lpfc_vmid_inactivity_timeout); + lpfc_vmid_app_header_init(phba, lpfc_vmid_app_header); + lpfc_vmid_priority_tagging_init(phba, lpfc_vmid_priority_tagging); if (phba->sli_rev != LPFC_SLI_REV4) phba->cfg_EnableXLane = 0; lpfc_XLanePriority_init(phba, lpfc_XLanePriority); From patchwork Wed Dec 16 05:29:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344749 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=-14.4 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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, 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 C2DE0C3526D for ; Wed, 16 Dec 2020 12:24:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96DFF23123 for ; Wed, 16 Dec 2020 12:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbgLPMYY (ORCPT ); Wed, 16 Dec 2020 07:24:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgLPMYX (ORCPT ); Wed, 16 Dec 2020 07:24:23 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC781C0611E4 for ; Wed, 16 Dec 2020 04:23:19 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id z21so380306pgj.4 for ; Wed, 16 Dec 2020 04:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LN1yfdkCiObbPjOmuxBwEXX75hiormJyd8vlijyGeQU=; b=XldwKrJcTC1J00Tm8zMX3PfRvb/pc8bR08shbBrZPWZbiuAQ5Zai/F+VCHnF2fcnBd T8OU0KX8NMLWjj9YWnYyPfWldpxOUjoXvsdpHPs/1mp6Mkhi8elc0NW17qwnV4N73lgU 9FAVp7p9fFUtsMM1bHQY2oeSDxrn6KV83OLEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=LN1yfdkCiObbPjOmuxBwEXX75hiormJyd8vlijyGeQU=; b=Q8qIblhgbDiAyh8irmDTtUl8MFAUorZQyusH8aq+fXIcGM2ENATFLlCK4wvdWrHc/L NoR40LGL+hMpg0YinFXvERl7BR6gDUDSaDkrOtKAb5zvTkME3z2f5ujY7rURm+PMHR+R XLNqv2A/lE1/qaeu2t/Ijjh5rvksMwuV7/O9MforIhUrlklJ3ThBLkTa5a+gfYXWut/y As8mLjzlvSku++Fxlj3X5eyurHXF4bqkGp5xXJtPWpu06KvUmG+a8bKzMJ6J43zOB5ny FyyAKq4COiuaUPkEjxiv6UeI27LM2xOUqpnABXI0IU+Mx6vZ48GZb7Cx/rd6+0vJgxsF j/Xw== MIME-Version: 1.0 X-Gm-Message-State: AOAM533Opxvez/cOEKiwvQO2LKecKgThrYS7+T+sxuQ8lmJG0ktO1Xfk ZXHjz1HY6Z/Em6nE0zdpjuEmp0kHelmsLH4PPJaZtBSwQM/x1qdJx6W0JeFzhtAuek+Je6aZULc Oa6oY39eYRmMG X-Google-Smtp-Source: ABdhPJxM1n2GD6j/IHzDhU2QNLz9g2enoY0/rGsPJ62CRn6o5p/xlMjasQvGVBd5deE6wWtzm5O51w== X-Received: by 2002:a62:6456:0:b029:1a1:e39e:cb46 with SMTP id y83-20020a6264560000b02901a1e39ecb46mr22674700pfb.0.1608121399278; Wed, 16 Dec 2020 04:23:19 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:18 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 09/16] lpfc: vmid: Implements ELS commands for appid patch Date: Wed, 16 Dec 2020 10:59:39 +0530 Message-Id: <1608096586-21656-10-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch implements ELS command like QFPA and UVEM for the priority tagging appid support. Other supporting functions are also part of this patch. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reported-by: kernel test robot --- v5: Changed Return code to non-numeric/Symbol. Addressed the review comments by Hannes v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_els.c | 371 ++++++++++++++++++++++++++++++++++- 1 file changed, 364 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 96c087b8b474..fae390b29a71 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,8 @@ static int lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, uint8_t retry); static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb); +static void lpfc_cmpl_els_uvem(struct lpfc_hba *, struct lpfc_iocbq *, + struct lpfc_iocbq *); static int lpfc_max_els_tries = 3; @@ -312,12 +315,12 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, if (expectRsp) { /* Xmit ELS command to remote NPORT */ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, - "0116 Xmit ELS command x%x to remote " - "NPORT x%x I/O tag: x%x, port state:x%x " - "rpi x%x fc_flag:x%x\n", + "0116 Xmit ELS command x%x to remote\n" + "NPORT x%x I/O tag: x%x, port state:x%x\n" + "rpi x%x fc_flag:x%x nlp_flag:x%x vport:x%p\n", elscmd, did, elsiocb->iotag, vport->port_state, ndlp->nlp_rpi, - vport->fc_flag); + vport->fc_flag, ndlp->nlp_flag, vport); } else { /* Xmit ELS response to remote NPORT */ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, @@ -1111,12 +1114,16 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* FLOGI completes successfully */ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, - "0101 FLOGI completes successfully, I/O tag:x%x, " - "xri x%x Data: x%x x%x x%x x%x x%x %x\n", + "0101 FLOGI completes successfully, I/O tag:x%x,\n" + "xri x%x Data: x%x x%x x%x x%x x%x %x %x\n", cmdiocb->iotag, cmdiocb->sli4_xritag, irsp->un.ulpWord[4], sp->cmn.e_d_tov, sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution, - vport->port_state, vport->fc_flag); + vport->port_state, vport->fc_flag, + sp->cmn.priority_tagging); + + if (sp->cmn.priority_tagging) + vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA; if (vport->port_state == LPFC_FLOGI) { /* @@ -1298,6 +1305,18 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, if (sp->cmn.fcphHigh < FC_PH3) sp->cmn.fcphHigh = FC_PH3; + /* to deterine if switch supports priority tagging */ + if (phba->cfg_vmid_priority_tagging) { + sp->cmn.priority_tagging = 1; + /* lpfc_vmid_host_uuid is combination of wwpn and wwnn */ + if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) { + memcpy(vport->lpfc_vmid_host_uuid, phba->wwpn, + sizeof(phba->wwpn)); + memcpy(&vport->lpfc_vmid_host_uuid[8], phba->wwnn, + sizeof(phba->wwnn)); + } + } + if (phba->sli_rev == LPFC_SLI_REV4) { if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == LPFC_SLI_INTF_IF_TYPE_0) { @@ -1928,6 +1947,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp, *free_ndlp; struct lpfc_dmabuf *prsp; int disc; + struct serv_parm *sp = NULL; /* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb; @@ -2018,6 +2038,23 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, cmdiocb->context2)->list.next, struct lpfc_dmabuf, list); ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); + + sp = (struct serv_parm *)((u8 *)prsp->virt + + sizeof(u32)); + + ndlp->vmid_support = 0; + if ((phba->cfg_vmid_app_header && sp->cmn.app_hdr_support) || + (phba->cfg_vmid_priority_tagging && + sp->cmn.priority_tagging)) { + lpfc_printf_log(phba, KERN_DEBUG, LOG_ELS, + "4018 app_hdr_support %d tagging %d DID x%x", + sp->cmn.app_hdr_support, + sp->cmn.priority_tagging, + ndlp->nlp_DID); + /* if the dest port supports VMID, mark it in ndlp */ + ndlp->vmid_support = 1; + } + lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_PLOGI); } @@ -2142,6 +2179,14 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) memset(sp->un.vendorVersion, 0, sizeof(sp->un.vendorVersion)); sp->cmn.bbRcvSizeMsb &= 0xF; + /* check if the destination port supports VMID */ + ndlp->vmid_support = 0; + if (vport->vmid_priority_tagging) + sp->cmn.priority_tagging = 1; + else if (phba->cfg_vmid_app_header && + bf_get(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags)) + sp->cmn.app_hdr_support = 1; + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, "Issue PLOGI: did:x%x", did, 0, 0); @@ -10306,3 +10351,315 @@ lpfc_sli_abts_recover_port(struct lpfc_vport *vport, lpfc_unreg_rpi(vport, ndlp); } +void lpfc_init_cs_ctl_bitmap(struct lpfc_vport *vport) +{ + bitmap_zero(vport->vmid_priority_range, LPFC_VMID_MAX_PRIORITY_RANGE); +} + +void +lpfc_vmid_set_cs_ctl_range(struct lpfc_vport *vport, u32 min, u32 max) +{ + u32 i; + + if ((min > max) || (max > LPFC_VMID_MAX_PRIORITY_RANGE)) + return; + + for (i = min; i <= max; i++) + set_bit(i, vport->vmid_priority_range); +} + +void lpfc_vmid_put_cs_ctl(struct lpfc_vport *vport, u32 ctcl_vmid) +{ + set_bit(ctcl_vmid, vport->vmid_priority_range); +} + +u32 lpfc_vmid_get_cs_ctl(struct lpfc_vport *vport) +{ + u32 i; + + i = find_first_bit(vport->vmid_priority_range, + LPFC_VMID_MAX_PRIORITY_RANGE); + + if (i == LPFC_VMID_MAX_PRIORITY_RANGE) + return 0; + + clear_bit(i, vport->vmid_priority_range); + return i; +} + +#define MAX_PRIORITY_DESC 255 + +static void +lpfc_cmpl_els_qfpa(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + struct lpfc_iocbq *rspiocb) +{ + struct lpfc_vport *vport = cmdiocb->vport; + struct priority_range_desc *desc; + struct lpfc_dmabuf *prsp = NULL; + struct lpfc_vmid_priority_range *vmid_range = NULL; + u32 *data; + struct lpfc_dmabuf *dmabuf = cmdiocb->context2; + IOCB_t *irsp = &rspiocb->iocb; + u8 *pcmd; + u32 len, i; + struct lpfc_nodelist *ndlp; + + prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list); + if (!prsp) + goto out; + + ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + pcmd = prsp->virt; + data = (u32 *)pcmd; + if (data[0] == ELS_CMD_LS_RJT) { + lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI, + "6528 QFPA LS_RJT %x %x ", data[0], data[1]); + goto out; + } + if (irsp->ulpStatus) { + lpfc_printf_vlog(vport, KERN_ERR, LOG_SLI, + "6529 QFPA failed with status %x %x ", + irsp->ulpStatus, irsp->un.ulpWord[4]); + goto out; + } + + if (!vport->qfpa_res) { + vport->qfpa_res = kmalloc(FCELSSIZE, GFP_KERNEL); + if (!vport->qfpa_res) + goto out; + memset(vport->qfpa_res, 0, FCELSSIZE); + } + + len = *((u32 *)(pcmd + 4)); + len = be32_to_cpu(len); + memcpy(vport->qfpa_res, pcmd, len + 8); + len = len / LPFC_PRIORITY_RANGE_DESC_SIZE; + + desc = (struct priority_range_desc *)(pcmd + 8); + vmid_range = vport->vmid_priority.vmid_range; + if (!vmid_range) { + vmid_range = kmalloc_array(MAX_PRIORITY_DESC, + sizeof + (struct lpfc_vmid_priority_range), + GFP_KERNEL); + if (!vmid_range) + goto out; + memset(vmid_range, 0, MAX_PRIORITY_DESC * + sizeof(struct lpfc_vmid_priority_range)); + vport->vmid_priority.vmid_range = vmid_range; + } + vport->vmid_priority.num_descriptors = len; + + for (i = 0; i < len; i++, vmid_range++, desc++) { + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_ELS, + "6539 vmid values low=%d, high=%d, qos=%d,\n" + " local ve id=%d\n", desc->lo_range, + desc->hi_range, desc->qos_priority, + desc->local_ve_id); + + vmid_range->low = desc->lo_range << 1; + if (desc->local_ve_id == QFPA_ODD_ONLY) + vmid_range->low++; + if (desc->qos_priority) + vport->vmid_flag |= LPFC_VMID_QOS_ENABLED; + vmid_range->qos = desc->qos_priority; + + vmid_range->high = desc->hi_range << 1; + if ((desc->local_ve_id == QFPA_ODD_ONLY) || + (desc->local_ve_id == QFPA_EVEN_ODD)) + vmid_range->high++; + } + lpfc_init_cs_ctl_bitmap(vport); + for (i = 0; i < vport->vmid_priority.num_descriptors; i++) { + lpfc_vmid_set_cs_ctl_range(vport, + vport->vmid_priority.vmid_range[i].low, + vport->vmid_priority.vmid_range[i].high); + } + + vport->vmid_flag |= LPFC_VMID_QFPA_CMPL; + out: + lpfc_els_free_iocb(phba, cmdiocb); + lpfc_nlp_put(ndlp); +} + +int lpfc_issue_els_qfpa(struct lpfc_vport *vport) +{ + struct lpfc_hba *phba = vport->phba; + IOCB_t *icmd; + struct lpfc_nodelist *ndlp; + struct lpfc_iocbq *elsiocb; + struct lpfc_sli *psli; + u8 *pcmd; + int ret; + + psli = &phba->sli; + + ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); + if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) + return FAILURE; + + if (!ndlp) + return FAILURE; + + elsiocb = lpfc_prep_els_iocb(vport, 1, LPFC_QFPA_SIZE, 2, ndlp, + ndlp->nlp_DID, ELS_CMD_QFPA); + if (!elsiocb) + return FAILURE; + + icmd = &elsiocb->iocb; + pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + + *((u32 *)(pcmd)) = ELS_CMD_QFPA; + pcmd += 4; + + elsiocb->iocb_cmpl = lpfc_cmpl_els_qfpa; + + elsiocb->context1 = lpfc_nlp_get(ndlp); + if (!elsiocb->context1) + return FAILURE; + + ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 2); + if (ret != IOCB_SUCCESS) { + lpfc_nlp_put(ndlp); + lpfc_els_free_iocb(phba, elsiocb); + return FAILURE; + } + vport->vmid_flag &= ~LPFC_VMID_QOS_ENABLED; + return 0; +} + +int +lpfc_vmid_uvem(struct lpfc_vport *vport, + struct lpfc_vmid *vmid, bool instantiated) +{ + struct lpfc_vem_id_desc *vem_id_desc; + struct lpfc_nodelist *ndlp; + IOCB_t *icmd; + struct lpfc_iocbq *elsiocb; + struct instantiated_ve_desc *inst_desc; + struct lpfc_vmid_context *vmid_context; + u8 *pcmd; + u32 *len; + int ret = 0; + + ndlp = lpfc_findnode_did(vport, Fabric_DID); + if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) + return FAILURE; + + vmid_context = kmalloc(sizeof(*vmid_context), GFP_KERNEL); + if (!vmid_context) + return FAILURE; + elsiocb = lpfc_prep_els_iocb(vport, 1, LPFC_UVEM_SIZE, 2, + ndlp, Fabric_DID, ELS_CMD_UVEM); + if (!elsiocb) + goto out; + + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_ELS, + "3427 %s %d", vmid->host_vmid, instantiated); + vmid_context->vmp = vmid; + vmid_context->nlp = ndlp; + vmid_context->instantiated = instantiated; + elsiocb->vmid_tag.vmid_context = vmid_context; + icmd = &elsiocb->iocb; + pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + + if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) + memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid, + LPFC_COMPRESS_VMID_SIZE); + + *((u32 *)(pcmd)) = ELS_CMD_UVEM; + len = (u32 *)(pcmd + 4); + *len = cpu_to_be32(LPFC_UVEM_SIZE - 8); + + vem_id_desc = (struct lpfc_vem_id_desc *)(pcmd + 8); + vem_id_desc->tag = be32_to_cpu(VEM_ID_DESC_TAG); + vem_id_desc->length = be32_to_cpu(LPFC_UVEM_VEM_ID_DESC_SIZE); + memcpy(vem_id_desc->vem_id, vport->lpfc_vmid_host_uuid, + LPFC_COMPRESS_VMID_SIZE); + + inst_desc = (struct instantiated_ve_desc *)(pcmd + 32); + inst_desc->tag = be32_to_cpu(INSTANTIATED_VE_DESC_TAG); + inst_desc->length = be32_to_cpu(LPFC_UVEM_VE_MAP_DESC_SIZE); + memcpy(inst_desc->global_vem_id, vmid->host_vmid, + LPFC_COMPRESS_VMID_SIZE); + + bf_set(lpfc_instantiated_nport_id, inst_desc, vport->fc_myDID); + bf_set(lpfc_instantiated_local_id, inst_desc, + vmid->un.cs_ctl_vmid); + if (instantiated) { + inst_desc->tag = be32_to_cpu(INSTANTIATED_VE_DESC_TAG); + } else { + inst_desc->tag = be32_to_cpu(DEINSTANTIATED_VE_DESC_TAG); + lpfc_vmid_put_cs_ctl(vport, vmid->un.cs_ctl_vmid); + } + inst_desc->word6 = cpu_to_be32(inst_desc->word6); + + elsiocb->iocb_cmpl = lpfc_cmpl_els_uvem; + + elsiocb->context1 = lpfc_nlp_get(ndlp); + if (!elsiocb->context1) + return FAILURE; + + ret = lpfc_sli_issue_iocb(vport->phba, LPFC_ELS_RING, elsiocb, 0); + if (ret != IOCB_SUCCESS) { + lpfc_els_free_iocb(vport->phba, elsiocb); + goto out; + } + + return 0; + out: + kfree(vmid_context); + return FAILURE; +} + +static void +lpfc_cmpl_els_uvem(struct lpfc_hba *phba, struct lpfc_iocbq *icmdiocb, + struct lpfc_iocbq *rspiocb) +{ + struct lpfc_vport *vport = icmdiocb->vport; + struct lpfc_dmabuf *prsp = NULL; + struct lpfc_vmid_context *vmid_context = + icmdiocb->vmid_tag.vmid_context; + struct lpfc_nodelist *ndlp = icmdiocb->context1; + u8 *pcmd; + u32 *data; + IOCB_t *irsp = &rspiocb->iocb; + struct lpfc_dmabuf *dmabuf = icmdiocb->context2; + struct lpfc_vmid *vmid; + + vmid = vmid_context->vmp; + if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) + ndlp = NULL; + + prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list); + if (!prsp) + goto out; + pcmd = prsp->virt; + data = (u32 *)pcmd; + if (data[0] == ELS_CMD_LS_RJT) { + lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI, + "4532 UVEM LS_RJT %x %x ", data[0], data[1]); + goto out; + } + if (irsp->ulpStatus) { + lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI, + "4533 UVEM error status %x: %x ", + irsp->ulpStatus, irsp->un.ulpWord[4]); + goto out; + } + spin_lock(&phba->hbalock); + /* Set IN USE flag */ + vport->vmid_flag |= LPFC_VMID_IN_USE; + phba->pport->vmid_flag |= LPFC_VMID_IN_USE; + spin_unlock(&phba->hbalock); + + if (vmid_context->instantiated) { + vmid->flag |= LPFC_VMID_REGISTERED; + vmid->flag &= ~LPFC_VMID_REQ_REGISTER; + } + + out: + kfree(vmid_context); + lpfc_els_free_iocb(phba, icmdiocb); + lpfc_nlp_put(ndlp); +} From patchwork Wed Dec 16 05:29:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344747 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 677AAC2BBCA for ; Wed, 16 Dec 2020 12:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28989233A0 for ; Wed, 16 Dec 2020 12:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725837AbgLPMYt (ORCPT ); Wed, 16 Dec 2020 07:24:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbgLPMYs (ORCPT ); Wed, 16 Dec 2020 07:24:48 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F72C0619D2 for ; Wed, 16 Dec 2020 04:23:23 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id w6so16513036pfu.1 for ; Wed, 16 Dec 2020 04:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R/vvMh+6NnWNWMaMP+THHzEq8dDMQ+MEOYvy9f384ac=; b=dugIkgVv5uHKXgXoin5gVk7lrAIca2MZLcPleLkTnKpwPtnCtQJDWqhwscNf6oUkHq w5rU1Ecl1+MKCuu+Bkg8s1koFg6qilw8P6uMzD3rm2HH9faIoQbRaQ6rDiOlFUKkKjEh Ken8hV/tmJcSnbf4y+LiE+seFNyNqUuw13WeY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=R/vvMh+6NnWNWMaMP+THHzEq8dDMQ+MEOYvy9f384ac=; b=YctuZjE0XDmLCNDXVdZTpnV+qNF6IqC/iwv0+wtHRIm9oXI+E354U4bAQZwgatEUlc Xs93RruApYMY+zvw14ZGmT1etuQG2kepe+DSUC5pHl4Cudx09vpum6LHdvYUf/tRJZ+T STRCKGgizV2kV+NvD1vvgjDShC1xrVows4RIKYaMrTNCQAHX0TqAwqC1WCX3XV+VMzKk G+vgwTRR0MJmPSue+ixHcxoqvAgN13IR+5RobyW9jZconPVolBvq/FYZzBWGQJ1TY/IP SVYz+KDysGITKehEzdTpALBsBozN3gRJ+OVv/lOqlprDLPL+wZVAImB0S79ZUKLb3eal i3Eg== MIME-Version: 1.0 X-Gm-Message-State: AOAM531tWMzna1X0i3aEUZzg/uR90lrF4KkKDstpp9O0Cc8IWsHxWVFa SR7AlylWZUCyqPUXQivCkag5n0pNOaw3oPpdEOW/VZ9qAxHj6asmuXRGpIXp55cnpb7R7HoQdFc VBsFa+AISfuA2 X-Google-Smtp-Source: ABdhPJzxDa+ZvKNSZatFKOTkqlRz+Pf9rYsY1pfv0zEUAnUUWk6S6icLAWsLJSgZLaa8GxgbP0mwYw== X-Received: by 2002:a62:5e44:0:b029:1a4:daae:e765 with SMTP id s65-20020a625e440000b02901a4daaee765mr15525385pfb.8.1608121403024; Wed, 16 Dec 2020 04:23:23 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:22 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 10/16] lpfc: vmid: Functions to manage vmids Date: Wed, 16 Dec 2020 10:59:40 +0530 Message-Id: <1608096586-21656-11-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch contains the routines to save, retrieve and remove the vmids from the data structure. A hash table is used to save the vmids and the corresponding UUIDs associated with the application/VMs. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reported-by: kernel test robot Reported-by: kernel test robot --- v5: 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_scsi.c | 139 ++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index b79b6f03cdb6..6a6a9a314368 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -5131,6 +5132,144 @@ void lpfc_poll_timeout(struct timer_list *t) } } +/* + * lpfc_get_vmid_from_hastable - search the UUID in the hash table + * @vport: The virtual port for which this call is being executed. + * @hash: calculated hash value + * @buf: uuid associated with the VE + * Returns the vmid entry associated with the UUID + * Make sure to acquire the appropriate lock before invoking this routine. + */ +struct lpfc_vmid *lpfc_get_vmid_from_hastable(struct lpfc_vport *vport, + u32 hash, u8 *buf) +{ + struct lpfc_vmid *vmp; + u16 count = 0; + + while (count < LPFC_VMID_HASH_SIZE) { + vmp = vport->hash_table[hash]; + if (vmp) { + if (strncmp(&vmp->host_vmid[0], buf, 16) == 0) + return vmp; + } else { + return NULL; + } + /* search the next available slot and continue till entry */ + /* is found */ + count++; + hash++; + + /* or the end is reached */ + if (hash == LPFC_VMID_HASH_SIZE) + hash = 0; + } + return NULL; +} + +/* + * lpfc_put_vmid_from_hastable - put the VMID in the hash table + * @vport: The virtual port for which this call is being executed. + * @hash - calculated hash value + * @vmp: Pointer to a VMID entry representing a VM sending IO + * + * This routine will insert the newly acquired vmid entity in the hash table. + * Make sure to acquire the appropriate lock before invoking this routine. + */ +int +lpfc_put_vmid_in_hashtable(struct lpfc_vport *vport, u32 hash, + struct lpfc_vmid *vmp) +{ + int count = 0; + + while (count < LPFC_VMID_HASH_SIZE) { + if (!vport->hash_table[hash]) { + vport->hash_table[hash] = vmp; + vmp->hash_index = hash; + return FAILURE; + } + /* if the slot is already occupied, a collision has occurred. */ + /* Store in the next available slot */ + count++; + hash++; + /* table is full */ + if (hash == LPFC_VMID_HASH_SIZE) + hash = 0; + } + return 0; +} + +/* + * lpfc_vmid_hash_fn- creates a hash value of the UUID + * @uuid: uuid associated with the VE + * @len: length of the UUID + * Returns the calculated hash value + */ +int lpfc_vmid_hash_fn(char *vmid, int len) +{ + int c; + int hash = 0; + + if (len == 0) + return 0; + while (len--) { + c = *vmid++; + if (c >= 'A' && c <= 'Z') + c += 'a' - 'A'; + + hash = (hash + (c << LPFC_VMID_HASH_SHIFT) + + (c >> LPFC_VMID_HASH_SHIFT)) * 19; + } + + return hash & LPFC_VMID_HASH_MASK; +} + +/* + * lpfc_vmid_update_entry - update the vmid entry in the hash table + * @vport: The virtual port for which this call is being executed. + * @cmd: address of scsi cmmd descriptor + * @vmp: Pointer to a VMID entry representing a VM sending IO + * @tag: VMID tag + */ +void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmnd + *cmd, struct lpfc_vmid *vmp, + union lpfc_vmid_io_tag *tag) +{ + u64 *lta; + + if (vport->vmid_priority_tagging) + tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid; + else + tag->app_id = vmp->un.app_id; + + if (cmd->sc_data_direction == DMA_TO_DEVICE) + vmp->io_wr_cnt++; + else + vmp->io_rd_cnt++; + + /* update the last access timestamp in the table */ + lta = per_cpu_ptr(vmp->last_io_time, raw_smp_processor_id()); + *lta = jiffies; +} + +void lpfc_vmid_assign_cs_ctl(struct lpfc_vport *vport, struct lpfc_vmid *vmid) +{ + u32 hash; + struct lpfc_vmid *pvmid; + + if (vport->port_type == LPFC_PHYSICAL_PORT) { + vmid->un.cs_ctl_vmid = lpfc_vmid_get_cs_ctl(vport); + } else { + hash = lpfc_vmid_hash_fn(vmid->host_vmid, vmid->vmid_len); + pvmid = + lpfc_get_vmid_from_hastable(vport->phba->pport, hash, + vmid->host_vmid); + if (!pvmid) + vmid->un.cs_ctl_vmid = pvmid->un.cs_ctl_vmid; + else + vmid->un.cs_ctl_vmid = lpfc_vmid_get_cs_ctl(vport); + } +} + /** * lpfc_queuecommand - scsi_host_template queuecommand entry point * @shost: kernel scsi host pointer. From patchwork Wed Dec 16 05:29:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344746 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 D8C1CC2BBCF for ; Wed, 16 Dec 2020 12:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEA5B230FA for ; Wed, 16 Dec 2020 12:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725813AbgLPMYw (ORCPT ); Wed, 16 Dec 2020 07:24:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbgLPMYv (ORCPT ); Wed, 16 Dec 2020 07:24:51 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECEE5C061794 for ; Wed, 16 Dec 2020 04:23:30 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id x18so6733734pln.6 for ; Wed, 16 Dec 2020 04:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/LlhG8uClpE/XJd8YorrzIg2F9ctui/pwSr3jRbld7w=; b=bX0Wxu9bB4ySlpvmHOi07TdeeLktJ1OdevmrVeMsxiYK+8r+Z6AYO02YzJMG3zbaV/ kNTYoet+SSfZO1b8uUbOU3rOeO7RolV7m9xQ++H3RjvtbT8TImMUOxX50a3YmOP4S2TF 9NISwD2PAY01/E+J+nmv0UWZcP3FIn1KCXBU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/LlhG8uClpE/XJd8YorrzIg2F9ctui/pwSr3jRbld7w=; b=lS+FRSFSB/dK87vyQY/MrqPq3I51JjZiy+1de9U/yNLV1xJHw+5qRcjP7tXo20wGU3 1nZh4HQNHlQA1edr7QitP0Dp86XFRYn/9RogabJv6sB5LvXdiqJArU8Hz+qjIWOboU/K I6Ww9UTaeTJ6YCc2sVKt2IplFXBKGYjLxRXrIr0wkfw4nCRFIkuhE74t0rtyUrw+BWOc nHRFvZopKQCyfo7Sw+cLxevu8jibsZuahokP0LuAgVQ7io0Iqscae4IqdsV7/i2gEZ9b qB2sPKvG9Dz3CDG+/u5OTNfsWB8XCcaiICKQDgDj2yxYTME7slmMzV3V1d9MB4rQyVRt ji5g== MIME-Version: 1.0 X-Gm-Message-State: AOAM531gc1v1fxVXcMrhic0C50lbVSPwfFOLBOd3hJkLZit+1iObsra6 mfDY1KlZLzmGj3ilEz75WGoIcWWEKJW+Yopm+eYtTrjsU8FauzQTjwUff72qsoHPQwoGK4WBdBj GY2X91NFi+2MvW7eT/RRHIC8= X-Google-Smtp-Source: ABdhPJwLmFxGL4mwi2zxaBunbUBgpYo8LJvFnyoTYyE1TIeLr91bM8pjItWzGbAJ4xoZJ1pEnKNARw== X-Received: by 2002:a17:902:c584:b029:da:cc62:22f1 with SMTP id p4-20020a170902c584b02900dacc6222f1mr31228355plx.54.1608121410288; Wed, 16 Dec 2020 04:23:30 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:29 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 12/16] lpfc: vmid: Appends the vmid in the wqe before sending Date: Wed, 16 Dec 2020 10:59:42 +0530 Message-Id: <1608096586-21656-13-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch adds the vmid in wqe before sending out the request. The type of vmid depends on the configured type and is checked before being appended. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v5: Modified the comments v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_sli.c | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index f9b6e32db618..a63371e9feaa 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -3856,7 +3856,7 @@ lpfc_sli_sp_handle_rspiocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, if (irsp->ulpStatus) { /* Rsp ring error: IOCB */ - lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "0328 Rsp Ring %d error: " "IOCB Data: " "x%x x%x x%x x%x " @@ -9762,6 +9762,8 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, *pcmd == ELS_CMD_RSCN_XMT || *pcmd == ELS_CMD_FDISC || *pcmd == ELS_CMD_LOGO || + *pcmd == ELS_CMD_QFPA || + *pcmd == ELS_CMD_UVEM || *pcmd == ELS_CMD_PLOGI)) { bf_set(els_req64_sp, &wqe->els_req, 1); bf_set(els_req64_sid, &wqe->els_req, @@ -9893,6 +9895,24 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, ptr = &wqe->words[22]; memcpy(ptr, fcp_cmnd, sizeof(struct fcp_cmnd)); } + + /* add the VMID tags as per switch response */ + if (iocbq->iocb_flag & LPFC_IO_VMID) { + union lpfc_wqe128 *wqe128; + + if (phba->pport->vmid_priority_tagging) { + bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); + bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, + (iocbq->vmid_tag.cs_ctl_vmid)); + /* Bit 0 must be 0 */ + } else { + wqe128 = (union lpfc_wqe128 *)wqe; + bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1); + bf_set(wqe_wqes, &wqe128->fcp_iwrite.wqe_com, + 1); + wqe128->words[31] = iocbq->vmid_tag.app_id; + } + } break; case CMD_FCP_IREAD64_CR: /* word3 iocb=iotag wqe=payload_offset_len */ @@ -9957,6 +9977,23 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, ptr = &wqe->words[22]; memcpy(ptr, fcp_cmnd, sizeof(struct fcp_cmnd)); } + + /* add the VMID tags as per switch response */ + if (iocbq->iocb_flag & LPFC_IO_VMID) { + union lpfc_wqe128 *wqe128; + + if (phba->pport->vmid_priority_tagging) { + bf_set(wqe_ccpe, &wqe->fcp_iread.wqe_com, 1); + bf_set(wqe_ccp, &wqe->fcp_iread.wqe_com, + (iocbq->vmid_tag.cs_ctl_vmid)); + /* Bit 0 must be 0 */ + } else { + wqe128 = (union lpfc_wqe128 *)wqe; + bf_set(wqe_appid, &wqe->fcp_iread.wqe_com, 1); + bf_set(wqe_wqes, &wqe128->fcp_iread.wqe_com, 1); + wqe128->words[31] = iocbq->vmid_tag.app_id; + } + } break; case CMD_FCP_ICMND64_CR: /* word3 iocb=iotag wqe=payload_offset_len */ @@ -10014,6 +10051,23 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, ptr = &wqe->words[22]; memcpy(ptr, fcp_cmnd, sizeof(struct fcp_cmnd)); } + + /* add the VMID tags as per switch response */ + if (iocbq->iocb_flag & LPFC_IO_VMID) { + union lpfc_wqe128 *wqe128; + + if (phba->pport->vmid_priority_tagging) { + bf_set(wqe_ccpe, &wqe->fcp_icmd.wqe_com, 1); + bf_set(wqe_ccp, &wqe->fcp_icmd.wqe_com, + (iocbq->vmid_tag.cs_ctl_vmid)); + /* Bit 0 must be 0 */ + } else { + wqe128 = (union lpfc_wqe128 *)wqe; + bf_set(wqe_appid, &wqe->fcp_icmd.wqe_com, 1); + bf_set(wqe_wqes, &wqe128->fcp_icmd.wqe_com, 1); + wqe128->words[31] = iocbq->vmid_tag.app_id; + } + } break; case CMD_GEN_REQUEST64_CR: /* For this command calculate the xmit length of the From patchwork Wed Dec 16 05:29:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 344748 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=-17.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_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 C7C91C2BBCA for ; Wed, 16 Dec 2020 12:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92535233CF for ; Wed, 16 Dec 2020 12:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725835AbgLPMY3 (ORCPT ); Wed, 16 Dec 2020 07:24:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgLPMY3 (ORCPT ); Wed, 16 Dec 2020 07:24:29 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A18C0617B0 for ; Wed, 16 Dec 2020 04:23:38 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id x12so12365863plr.10 for ; Wed, 16 Dec 2020 04:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=raaiNC2aUgLI6XSppMyQ3otEOuMSUkrslKgIeCHIcwo=; b=XRjMWssNfVCsRFH4bGtfeXtqhXHKUvRwBkTZmxYZT85Yer5gOBSKVjz25KR9PuSqpx B7Df3REHjsogK1hIz7x70u50g+T5S3qxnlVSEo/d1CLyDb8GRTnsSIdrU3VzdTe/0LHL lVhSdPO9qfYEdeYlmOgLWlCI9bjbvYKU3LqhM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references; bh=raaiNC2aUgLI6XSppMyQ3otEOuMSUkrslKgIeCHIcwo=; b=YwrFuFCWAq7wtsYOd+J/K6SYi9bsh767FP2VY3x9pkRwW00RQ+VM6ssf01gnNcH536 3HnJNDNNI3xnP3jpRLLgC4lvPo1zIavv/QYbrh4gyc4eS8WnC8L/bXLMj4YIP9a5GsLD irEfY1G1QfqLAdBCixnAMs9cZ2XhXweFFdI4P6n3BDjl24JbuZCTSuBHYu2k1xVmLwaK UjQGKJc7+rZnlQqgNDITXznyWYrf8XuqBideTJOoQuPgXiCPv9WdmUl/l44wmek1KMbS O2ImviNpvpZQzOAxwb8o74cufElq8VV5DeUSN0nB+73h4y3sQD1bh89TChQQRvsLshLn ZfQw== MIME-Version: 1.0 X-Gm-Message-State: AOAM533c3HyWf+/NKUdFN1tC6WkJCgKsoDGC3Uu+F/vI7TV7NbW20SOE i7J34/EcCBVI4hVzHi+9GTocVnuXn4r9lXZaj/pgAoooifiop1qjIwI2yDiLpRvSZBEQYVVWaQC fK+pmqHH2m8lw X-Google-Smtp-Source: ABdhPJzfANd4GQ/vzf4VQAEATIz1HM1EpQEVfwXNtVWIvJvCHUOKjN8sSvxnf1GA4HcrWUVlJJeXug== X-Received: by 2002:a17:90a:72c6:: with SMTP id l6mr2865336pjk.233.1608121417454; Wed, 16 Dec 2020 04:23:37 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s7sm2477296pfh.207.2020.12.16.04.23.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 04:23:36 -0800 (PST) From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, pbonzini@redhat.com, Gaurav Srivastava Subject: [PATCH v5 14/16] lpfc: vmid: Adding qfpa and vmid timeout check in worker thread Date: Wed, 16 Dec 2020 10:59:44 +0530 Message-Id: <1608096586-21656-15-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> References: <1608096586-21656-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Gaurav Srivastava This patch add the periodic check for issuing of qfpa command and vmid timeout in the worker thread. The inactivity timeout check is added via the timer function. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reported-by: kernel test robot --- v5: No change v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_hbadisc.c | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index be71f3a47c95..3b36710cd47e 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -428,6 +428,32 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) return fcf_inuse; } +void lpfc_check_vmid_qfpa_issue(struct lpfc_hba *phba) +{ + struct lpfc_vport *vport; + struct lpfc_vport **vports; + int i, ret; + + vports = lpfc_create_vport_work_array(phba); + if (!vports) + return; + + for (i = 0; i <= phba->max_vports; i++) { + if ((!vports[i]) && (i == 0)) + vport = phba->pport; + else + vport = vports[i]; + if (!vport) + break; + + if (vport->vmid_flag & LPFC_VMID_ISSUE_QFPA) { + ret = lpfc_issue_els_qfpa(vport); + vport->vmid_flag &= ~LPFC_VMID_ISSUE_QFPA; + } + } + lpfc_destroy_vport_work_array(phba, vports); +} + /** * lpfc_sli4_post_dev_loss_tmo_handler - SLI4 post devloss timeout handler * @phba: Pointer to hba context object. @@ -748,6 +774,22 @@ lpfc_work_done(struct lpfc_hba *phba) if (ha_copy & HA_LATT) lpfc_handle_latt(phba); + /* Handle VMID Events */ + if (lpfc_is_vmid_enabled(phba)) { + if (phba->pport->work_port_events & + WORKER_CHECK_VMID_ISSUE_QFPA) { + lpfc_check_vmid_qfpa_issue(phba); + phba->pport->work_port_events &= + ~WORKER_CHECK_VMID_ISSUE_QFPA; + } + if (phba->pport->work_port_events & + WORKER_CHECK_INACTIVE_VMID) { + lpfc_check_inactive_vmid(phba); + phba->pport->work_port_events &= + ~WORKER_CHECK_INACTIVE_VMID; + } + } + /* Process SLI4 events */ if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) { if (phba->hba_flag & HBA_RRQ_ACTIVE)