From patchwork Mon Nov 9 04:23:47 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: 11891159 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 DC532C388F7 for ; Mon, 9 Nov 2020 11:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 894352068D for ; Mon, 9 Nov 2020 11:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CJOcm9Nh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729373AbgKILRb (ORCPT ); Mon, 9 Nov 2020 06:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbgKILRb (ORCPT ); Mon, 9 Nov 2020 06:17:31 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEA3BC0613D3 for ; Mon, 9 Nov 2020 03:17:30 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id f38so6892778pgm.2 for ; Mon, 09 Nov 2020 03:17:30 -0800 (PST) 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=NbtQ5+D+elnsfku10tq4TS6gWKCsBsB1EYJ+cBbq9yU=; b=CJOcm9NhovBmsmTS4vHi97h0Ar1MmnCa7CzYDahhN5req+LHl/eVPTGrVOD1uF7NRP 5msmaky33WaAmNmHN7OyKxTrpYOdwgjDjxOJNCkLcE57kfS/NBn4EKm/87Iz1HPYfgyQ PmagzzaQdsruE38DnhH0USgdfycRn52PsOO20= 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=NbtQ5+D+elnsfku10tq4TS6gWKCsBsB1EYJ+cBbq9yU=; b=L4ydePGce97OxGkZUdPVDZZcO67lI1M8555m/1tlqyHwawPo0r2y1i/Ojp6R6RYzR3 fSpOYXb3GOYz/I3Vq8RU3kLyCKt/crST3gdWt39qG12OZLDlrK7n5TajErTKIdNh4WKy DIb/R1CNnm6ZhYpVR93E3lkGIMx4b2MjM/WWfcOo3WVKQnmrwzVBVDyz4faT353GDmaA hy/m5TEl+kII3bNEl2clpyLwdRFsduxnTLQdAVY+9KLuVajRB9RuafYdDpX83I6OU+BN mQzqwOaNnIsZmPPbwc3cFAWY6dxmKBvo9yFwWyjTo9K0HlBzOb1abBqUfTdwUuA+4d0Z lDnQ== X-Gm-Message-State: AOAM530uCHP0eS6fwF0C/Nj0hZxSykRZ+lU+23IQObHEegm8xg1Ck+9M frZ91YAlxJupCQxEw/Z0rt8QpaNCFQXVhwL3YHg9WXv2Bum99W84nqY8xIi0nNMmGPxaFISxBja DaQ3r+lkB+XKYIep7s8xuMFJ9yUTdlShevlADweI7qW/dnyx1nzLYpqL0MTPRLxvR2OoK7ZyJq8 MxJtLea+xnuAAH X-Google-Smtp-Source: ABdhPJwWUEgPyCdgMOJLastt8Q8dPEQ5cCal+j3gGAoHpcak4z3S4xrigxKUtcyNFoqXHfdMNCPlzw== X-Received: by 2002:a05:6a00:88d:b029:164:5a00:29b8 with SMTP id q13-20020a056a00088db02901645a0029b8mr13935521pfj.10.1604920649995; Mon, 09 Nov 2020 03:17:29 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:29 -0800 (PST) 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, Muneendra Subject: [PATCH v4 01/19] cgroup: Added cgroup_get_from_kernfs_id Date: Mon, 9 Nov 2020 09:53:47 +0530 Message-Id: <1604895845-2587-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Added a new function cgroup_get_from_kernfs_id to retrieve the cgroup associated with cgroup id. It takes cgroupid as an argument and returns cgrp and on failure it returns NULL. Exported the same as this can be used by blk-cgorup.c Added function declaration of cgroup_get_from_kernfs_id in cgorup.h Exported the cgroup_get_e_css Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke --- 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..1741f02a41d6 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_kernfs_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_kernfs_id(u64 id) +{ + return NULL; +} #endif /* !CONFIG_CGROUPS */ #ifdef CONFIG_CGROUPS diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index dd247747ec14..53046deeb9ca 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) { @@ -5803,6 +5804,31 @@ void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) kernfs_put(kn); } +/* + * cgroup_get_from_kernfs_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_kernfs_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_kernfs_id); + /* * proc_cgroup_show() * - Print task's cgroup paths into seq_file, one line for each hierarchy From patchwork Mon Nov 9 04:23:48 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: 11891157 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 6DA94C56201 for ; Mon, 9 Nov 2020 11:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1137920679 for ; Mon, 9 Nov 2020 11:17:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="KRmiw2QG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729442AbgKILRi (ORCPT ); Mon, 9 Nov 2020 06:17:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729316AbgKILRe (ORCPT ); Mon, 9 Nov 2020 06:17:34 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716EAC0613D3 for ; Mon, 9 Nov 2020 03:17:34 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id y7so7833367pfq.11 for ; Mon, 09 Nov 2020 03:17:34 -0800 (PST) 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=UWX46yIRTY+5O66w4ttoeg+YLJ8ZvwzrYxl/LbqYu1M=; b=KRmiw2QGiOW25dGmaOC4IaBgQ5TO2I6n+gcK2cjMeObzzrpn9b03F4FtLFfBIfcaHB RtnHGSDAJPo7SaSF53XqHWel5Ov26uW24PjuQ2ShoU7rb4t/4NP5UdI9BXe7XJWWQEKJ dIdaZQ0RO+cxaP6Vj7gkbnUHUHoBydfWRCAqA= 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=UWX46yIRTY+5O66w4ttoeg+YLJ8ZvwzrYxl/LbqYu1M=; b=GlZ77EZ2OSf+oG3D/qKUgBQpRDKhJiFniyKz1ErYkDgKSB3EJKV76dfkwBgHWTqrLC /rF9PpxkwguTu6MyjxSe54wQ+d92hD0dg/2DJf3PN1kejs8RA0IvIspXr/9/Tl7xu3Ez S6WVPzXRMM51ZHpxHs8+AvINqsvQEbmdShwZBGPi+UjTcm8ctH+pnPwl9zZ9BM8gSmoY pxi/5QTMSVh5p9DMs2Pf/OvZ39dMOjEz/iakAZBXGh82EifeJ2HxO5pYJ0H8r98xoMcY LF7+KWdKrUN4KegugpM16w2BTFU2C47OGnB30DxKMwsS8n+NQukEqJtfPy4b+88sRxJu D/Yg== X-Gm-Message-State: AOAM533ICsTzKSCWyLY5Z1xJhsAVH3xHw3BtTpUPSXdlGJ8f7vKMsnJd jk9b2/pqGNSmUQZyf6E+UCVAb27Yg2K3i4gGJHBqo1+GY+3CW+LwoMj0KCQ3YiqUKcC25T7cvx7 2FOtoQHR+leu56/aIqNJ+GUh9SrisPaK5sxw1YzadKCiHnYd4QqMBj9ma+ed67qO1O2UhZ51w7p jpUljJa6+CGjxe X-Google-Smtp-Source: ABdhPJzXAJ6MkDCZuEoyQYFhqM/qPNoLHRDU7IPXCt1FTRibYCzfL7GXIV0DDA0gxcScuyDl9h5NZQ== X-Received: by 2002:a63:174b:: with SMTP id 11mr12641266pgx.57.1604920653379; Mon, 09 Nov 2020 03:17:33 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:32 -0800 (PST) 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, Muneendra Subject: [PATCH v4 02/19] blkcg: Added a app identifier support for blkcg Date: Mon, 9 Nov 2020 09:53:48 +0530 Message-Id: <1604895845-2587-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This Patch added a unique application identifier i.e app_id knob to blkcg which allows identification of traffic sources at an individual cgroup based Applications (ex:virtual machine (VM))level in both host and fabric infrastructure. Provided the interface blkcg_get_fc_appid to grab the app identifier associated with a bio. Provided the interface blkcg_set_fc_appid to set the app identifier in a blkcgrp associated with cgroup id Added a new config BLK_CGROUP_FC_APPID and moved the changes under this config Signed-off-by: Muneendra --- v4: No change v3: Renamed the functions and app_id to more specific Addressed the reference leaks in blkcg_set_app_identifier Added a new config BLK_CGROUP_FC_APPID and moved the changes under this config Added blkcg_get_fc_appid,blkcg_set_fc_appid as inline functions v2: renamed app_identifier to app_id removed the sysfs interface blkio.app_identifie under --- block/Kconfig | 9 ++++++ include/linux/blk-cgroup.h | 65 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/block/Kconfig b/block/Kconfig index bbad5e8bbffe..ed22df654ce5 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -144,6 +144,15 @@ config BLK_CGROUP_IOLATENCY Note, this is an experimental interface and could be changed someday. +config BLK_CGROUP_FC_APPID + bool "Enable support to track FC io Traffic across cgroup applications" + depends on BLK_CGROUP=y + help + Enabling this option enables the support to track FC io traffic across + cgroup applications.It enables the Fabric and the storage targets to + identify, monitor, and handle FC traffic based on vm tags by inserting + application specific identification into the FC frame. + config BLK_CGROUP_IOCOST bool "Enable support for cost model based cgroup IO controller" depends on BLK_CGROUP=y diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index c8fc9792ac77..00ea1cfa3420 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -30,6 +30,8 @@ /* Max limits for throttle policy */ #define THROTL_IOPS_MAX UINT_MAX +#define APPID_LEN 128 + #ifdef CONFIG_BLK_CGROUP @@ -55,6 +57,9 @@ struct blkcg { struct blkcg_policy_data *cpd[BLKCG_MAX_POLS]; struct list_head all_blkcgs_node; +#ifdef CONFIG_BLK_CGROUP_FC_APPID + char fc_app_id[APPID_LEN]; +#endif #ifdef CONFIG_CGROUP_WRITEBACK struct list_head cgwb_list; #endif @@ -660,4 +665,64 @@ static inline void blk_cgroup_bio_start(struct bio *bio) { } #endif /* CONFIG_BLOCK */ #endif /* CONFIG_BLK_CGROUP */ + +#ifdef CONFIG_BLK_CGROUP_FC_APPID +/* + * Sets the fc_app_id field associted to blkcg + * @buf: application identifier + * @id: cgrp id + * @len: size of appid + */ +static inline int blkcg_set_fc_appid(char *buf, u64 id, size_t len) +{ + struct cgroup *cgrp = NULL; + struct cgroup_subsys_state *css = NULL; + struct blkcg *blkcg = NULL; + int ret = 0; + + cgrp = cgroup_get_from_kernfs_id(id); + if (!cgrp) + return -ENOENT; + css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); + if (!css) { + ret = -ENOENT; + goto out_cgrp_put; + } + blkcg = css_to_blkcg(css); + if (!blkcg) { + ret = -ENOENT; + goto out_put; + } + if (len > APPID_LEN) { + ret = -EINVAL; + goto out_put; + } + strlcpy(blkcg->fc_app_id, buf, len); +out_put: + css_put(css); +out_cgrp_put: + cgroup_put(cgrp); + return ret; +} + +/** + * blkcg_get_fc_appid - grab the app identifier associated with a bio + * @bio: target bio + * + * This returns the app identifier associated with a bio, + * %NULL if not associated. + * Callers are expected to either handle %NULL or know association has been + * done prior to calling this. + */ +static inline char *blkcg_get_fc_appid(struct bio *bio) +{ + if (bio && bio->bi_blkg && + strlen(bio->bi_blkg->blkcg->fc_app_id)) + return bio->bi_blkg->blkcg->fc_app_id; + return NULL; +} +#else +static inline int blkcg_set_fc_appid(char *buf, u64 id, size_t len) { return -EINVAL; } +static inline char *blkcg_get_fc_appid(struct bio *bio) { return NULL; } +#endif /*CONFIG_BLK_CGROUP_FC_APPID*/ #endif /* _BLK_CGROUP_H */ From patchwork Mon Nov 9 04:23:49 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: 11891171 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 342C8C388F7 for ; Mon, 9 Nov 2020 11:17:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D48E6206E5 for ; Mon, 9 Nov 2020 11:17:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="g4B9SkJb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727774AbgKILRi (ORCPT ); Mon, 9 Nov 2020 06:17:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729427AbgKILRh (ORCPT ); Mon, 9 Nov 2020 06:17:37 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB5CC0613D6 for ; Mon, 9 Nov 2020 03:17:37 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id c20so7848787pfr.8 for ; Mon, 09 Nov 2020 03:17:37 -0800 (PST) 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=M29EFKGcsccLBMFCXJrq4LHYnBqYH4hfEsrCaRgmoeY=; b=g4B9SkJbx65UXGB78bcBHPLyKlEhwT2V7Ev8iQ5CC2BwyMPJa+HGdq6PTs8yPoLVBO +WWjQ9uUx3V56pumdhuXyRf4BB1G3Hg8RIarxWjZs3ESc2f2N5z8Kx5rusT85BhVpo6l 33Z+J/muUq+j38DYZsBQ1Q/wnLHFfBR7LLGwA= 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=M29EFKGcsccLBMFCXJrq4LHYnBqYH4hfEsrCaRgmoeY=; b=NkCGARQAr5WDOB9l8tZG+Y/AZLzWB6lW7SLXuqhFlIOtu7tNSkBgccGB/al1mRYM+z jFvYJvrLAzy0OAikwXblcAagOO73yJsk64gI1SDIxc5HnHFUYpheVpyth2Uf8saxrIc7 NhZS4WFUMvuarN9NPUENf13RYz86EagdjrCXQG2AEoaalzMv89Y73paY6xPtPLSezdok IlMH3ef2loah0525zWLEBFw62ccr2ZJEAnZWtCDPRtZS/wWq+OKQlqVZnr3vqYy2/Aie QK4afzdWF3vItzjEmxBEd4TDhc/HXPpztDFyXRQUsrnvNMifHLdgfq5b0ltfKZONIPdM yfsg== X-Gm-Message-State: AOAM5319nuOdycEUZIpvcwDO/bcfxOc/mCC7LF3oDLVm8aXnMggWzeep HbErFZrN4T/P94kzSPuDORSCdoC6GqvThUrqrTNAGVZM4wkhhFy2LtrzHeoZIGMIAKGxjmyZAmu TlsiN4aW5A0OLCD/xG9wsusD7MME97WAHVwohN6HUkEy4QwdpZi6utXpm1d9ud0av2ZuZqiNO2Y y9sms/9t2ceeZ6 X-Google-Smtp-Source: ABdhPJyh8DAg928IME1ogv9LTLGXxn4yHsy7/H6DeZqyEP9xtrtkiFNcJ1eANkB6APS0p2tc2IinHA== X-Received: by 2002:a17:90b:1881:: with SMTP id mn1mr12942490pjb.225.1604920656785; Mon, 09 Nov 2020 03:17:36 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:36 -0800 (PST) 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, Muneendra Subject: [PATCH v4 03/19] nvme: Added a newsysfs attribute appid_store Date: Mon, 9 Nov 2020 09:53:49 +0530 Message-Id: <1604895845-2587-4-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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 eae43bb444e0..6d6cc06fd54a 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 @@ -3768,10 +3768,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[APPID_LEN]; + int ret = 0; + + if (buf[count-1] == '\n') + count--; + + if ((count > (16+1+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 > APPID_LEN) + return -EINVAL; + + memset(app_id, 0x0, sizeof(app_id)); + memcpy(app_id, &buf[cgrpid_len+1], appid_len); + ret = blkcg_set_app_identifier(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 Mon Nov 9 04:23:50 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: 11891163 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 D4679C388F7 for ; Mon, 9 Nov 2020 11:17:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 771D52068D for ; Mon, 9 Nov 2020 11:17:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YxYKzCRt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729146AbgKILRm (ORCPT ); Mon, 9 Nov 2020 06:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729446AbgKILRl (ORCPT ); Mon, 9 Nov 2020 06:17:41 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF9CC0613CF for ; Mon, 9 Nov 2020 03:17:41 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id v12so7831076pfm.13 for ; Mon, 09 Nov 2020 03:17:41 -0800 (PST) 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=clHgL1PCamaUCH+8n7s8VAHmqE1YdZ2DcxWAGzaZK94=; b=YxYKzCRtfB6k8uH0hVRJIDaNC4XemkHSLWNeQpPy+9Np2OOihKM9nKSyEh11k4GMi5 8AY5d/KQe96eshCKBEeCZO6qIerpL2SE92Jc44UwxuUk3QAdhABIU3V80YKYBQWijbYG Y8RQeKU5Ka3ZF1cgBzouZI3HzMf36u9bWdhbQ= 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=clHgL1PCamaUCH+8n7s8VAHmqE1YdZ2DcxWAGzaZK94=; b=WkbIg5/i8mmDG/aRERMc6SBDNE6xMlMw038pTZhOWEVgOSOfEbh9pFjDIdclECcoMb WZJOk2oT2y8/VdoiGWs5l1Q4y4LlaTMsOlNltxbIXHYiJDlBZ2TtC0PMHXise59gQl+q kb0SATb5MYalhsSFy5VXdKxQTsQPBXPsk/58kKwY4FZRwmOhOkaFEr0Bmh63tFOHAI0m EKvnzSKT/SdGQN59VkyFhA1Umhv+mSvrQu1NgYS++ixGFS5a/dTAGuAaydCjXOfQL7zW 5S93VPaCasyMC391BSwyIPQwz1e4SHL54qk/kWNVF8C7yT0jCa18guv0AqfRR2dG0ZGW xG6g== X-Gm-Message-State: AOAM533ELYeSJup1kDvPbJIpRx4KH9L0BINa1fnMQI7T/3c6kJLRnBC1 za7RaUhCAEv7qXP+htboysswNISl7p4dA4nSkh84By+HEHN3ltawU8IEjYUiFN906YQG17AACLH Clo94IxotqWlnWRxoUH2cqJTC4E6Nz4/dPmjkoK3pCFAyfayY7kvxhU1bHdOb7h8iyBE9t/jCSq N6WoJfMmxQXsZs X-Google-Smtp-Source: ABdhPJz5fDBhOa5KNZVG+1hZsWWzU5v08QtIsZHrl6WOkksoR3U0r5dGmD0MkwtRO69296e14c4/qA== X-Received: by 2002:a17:90a:1992:: with SMTP id 18mr13170226pji.67.1604920660136; Mon, 09 Nov 2020 03:17:40 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:39 -0800 (PST) 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: [PATCH v4 04/19] lpfc: vmid: Add the datastructure for supporting VMID in lpfc Date: Mon, 9 Nov 2020 09:53:50 +0530 Message-Id: <1604895845-2587-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 adds the primary datastructures needed to implement VMID in lpfc driver. It maintains the capability, current state, hash table for the vmid/appid along with other information. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue Removed unused variable. --- drivers/scsi/lpfc/lpfc.h | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 549adfaa97ce..8f0062d2b891 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -303,6 +303,63 @@ struct lpfc_stats { struct lpfc_hba; +#define LPFC_VMID_TIMER 300 /* timer interval in seconds. */ + +#define LPFC_MAX_VMID_SIZE 256 +#define LPFC_COMPRESS_VMID_SIZE 16 + +union lpfc_vmid_io_tag { + u32 app_id; /* App Id vmid */ + u8 cs_ctl_vmid; /* Priority tag vmid */ +}; + +#define JIFFIES_PER_HR (HZ * 60 * 60) + +struct lpfc_vmid { + u8 flag; +#define LPFC_VMID_SLOT_FREE 0x0 +#define LPFC_VMID_SLOT_USED 0x1 +#define LPFC_VMID_REQ_REGISTER 0x2 +#define LPFC_VMID_REGISTERED 0x4 +#define LPFC_VMID_DE_REGISTER 0x8 + u8 host_vmid[LPFC_MAX_VMID_SIZE]; + union lpfc_vmid_io_tag un; + u64 io_rd_cnt; + u64 io_wr_cnt; + u8 vmid_len; + u8 delete_inactive; /* Delete if inactive flag 0 = no, 1 = yes */ + u32 hash_index; + u64 __percpu *last_io_time; +}; + +#define lpfc_vmid_is_type_priority_tag(vport)\ + (vport->vmid_priority_tagging ? 1 : 0) + +#define LPFC_VMID_HASH_SIZE 256 +#define LPFC_VMID_HASH_MASK 255 +#define LPFC_VMID_HASH_SHIFT 6 + +struct lpfc_vmid_context { + struct lpfc_vmid *vmp; + struct lpfc_nodelist *nlp; + u8 instantiated; +}; + +struct lpfc_vmid_priority_range { + u8 low; + u8 high; + u8 qos; +}; + +struct lpfc_vmid_priority_info { + u32 num_descriptors; + struct lpfc_vmid_priority_range *vmid_range; +}; + +#define QFPA_EVEN_ONLY 0x01 +#define QFPA_ODD_ONLY 0x02 +#define QFPA_EVEN_ODD 0x03 + enum discovery_state { LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */ LPFC_VPORT_FAILED = 1, /* vport has failed */ @@ -442,6 +499,9 @@ struct lpfc_vport { #define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */ #define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */ #define WORKER_SERVICE_TXQ 0x2000 /* hba: IOCBs on the txq */ +#define WORKER_CHECK_INACTIVE_VMID 0x4000 /* hba: check inactive vmids */ +#define WORKER_CHECK_VMID_ISSUE_QFPA 0x8000 /* vport: Check if qfpa need */ + /* to issue */ struct timer_list els_tmofunc; struct timer_list delayed_disc_tmo; @@ -452,6 +512,8 @@ struct lpfc_vport { #define FC_LOADING 0x1 /* HBA in process of loading drvr */ #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */ #define FC_ALLOW_FDMI 0x4 /* port is ready for FDMI requests */ +#define FC_ALLOW_VMID 0x8 /* Allow VMID IO's */ +#define FC_DEREGISTER_ALL_APP_ID 0x10 /* Deregister all vmid's */ /* Vport Config Parameters */ uint32_t cfg_scan_down; uint32_t cfg_lun_queue_depth; @@ -470,9 +532,36 @@ struct lpfc_vport { uint32_t cfg_tgt_queue_depth; uint32_t cfg_first_burst_size; uint32_t dev_loss_tmo_changed; + /* VMID parameters */ + u8 lpfc_vmid_host_uuid[LPFC_COMPRESS_VMID_SIZE]; + u32 max_vmid; /* maximum VMIDs allowed per port */ + u32 cur_vmid_cnt; /* Current VMID count */ +#define LPFC_MIN_VMID 4 +#define LPFC_MAX_VMID 255 + u32 vmid_inactivity_timeout; /* Time after which the VMID */ + /* deregisters from switch */ + u32 vmid_priority_tagging; +#define LPFC_VMID_PRIO_TAG_DISABLE 0 /* Disable */ +#define LPFC_VMID_PRIO_TAG_SUP_TARGETS 1 /* Allow supported targets only */ +#define LPFC_VMID_PRIO_TAG_ALL_TARGETS 2 /* Allow all targets */ + unsigned long *vmid_priority_range; +#define LPFC_VMID_MAX_PRIORITY_RANGE 256 +#define LPFC_VMID_PRIORITY_BITMAP_SIZE 32 + u8 vmid_flag; +#define LPFC_VMID_IN_USE 0x1 +#define LPFC_VMID_ISSUE_QFPA 0x2 +#define LPFC_VMID_QFPA_CMPL 0x4 +#define LPFC_VMID_QOS_ENABLED 0x8 +#define LPFC_VMID_TIMER_ENBLD 0x10 + struct fc_qfpa_res *qfpa_res; struct fc_vport *fc_vport; + struct lpfc_vmid *vmid; + struct lpfc_vmid *hash_table[LPFC_VMID_HASH_SIZE]; + rwlock_t vmid_lock; + struct lpfc_vmid_priority_info vmid_priority; + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct dentry *debug_disc_trc; struct dentry *debug_nodelist; @@ -925,6 +1014,13 @@ struct lpfc_hba { struct nvmet_fc_target_port *targetport; lpfc_vpd_t vpd; /* vital product data */ + u32 cfg_max_vmid; /* maximum VMIDs allowed per port */ + u32 cfg_vmid_app_header; +#define LPFC_VMID_APP_HEADER_DISABLE 0 +#define LPFC_VMID_APP_HEADER_ENABLE 1 + u32 cfg_vmid_priority_tagging; + u32 cfg_vmid_inactivity_timeout; /* Time after which the VMID */ + /* deregisters from switch */ struct pci_dev *pcidev; struct list_head work_list; uint32_t work_ha; /* Host Attention Bits for WT */ @@ -1168,6 +1264,7 @@ struct lpfc_hba { struct list_head ct_ev_waiters; struct unsol_rcv_ct_ctx ct_ctx[LPFC_CT_CTX_MAX]; uint32_t ctx_idx; + struct timer_list inactive_vmid_poll; /* RAS Support */ struct lpfc_ras_fwlog ras_fwlog; From patchwork Mon Nov 9 04:23:51 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: 11891161 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 304ECC4741F for ; Mon, 9 Nov 2020 11:17:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0AA32084C for ; Mon, 9 Nov 2020 11:17:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ckorHz3Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729399AbgKILRp (ORCPT ); Mon, 9 Nov 2020 06:17:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729446AbgKILRo (ORCPT ); Mon, 9 Nov 2020 06:17:44 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 700BFC0613D3 for ; Mon, 9 Nov 2020 03:17:44 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id r186so6898648pgr.0 for ; Mon, 09 Nov 2020 03:17:44 -0800 (PST) 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=jZxTdxrkcXGDNMAGhWx4a9cw6eoRx91QMoJpWbvLpuw=; b=ckorHz3YrkgTA8ubpo+cHQjCmzOI83GAXd4GFrrMdgyPNr7wNCQMzovFKyqnZLDZtR APceN58xAunchkzQbi+WQuy/Z/g0+bl3Fnc3/mkdO1V1XpjfV4kYcrsVM+4UcjLCekPx MPpVLoo1lUut5ut05XfAjK38+7Kzzm1Zl3RyQ= 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=jZxTdxrkcXGDNMAGhWx4a9cw6eoRx91QMoJpWbvLpuw=; b=e95Rx7s0qdmK4amMArfgyXWDM92A80bA14QARHo23IF3NX1sprgWwTR3LfGPimzb33 AuO7FGmNEn3iPwXvvOYVymRTouJQ3VghKhG1tVvYMplAJE/zFdXb013vc6EcxprA7V1/ 94uUxEEcQ9bk1RKiJn1twAgRGadJ+kHqt2PWWxlC4H5QuDoLDNrnUo9IE4jV/3/HiLFY 59zWrM//VIPrWvOsKKIy7/47b+K0q+pfm2Mmoh7FAT7irLxR+X9GNA3BhmfpctaJwXis 9gPpWtHzv92f6R8yhqrdeWel2biDsiHDkfEFZpcsMv0SPcOSvFnFSwMif6EPtPjpGcff cK5A== X-Gm-Message-State: AOAM531A4kgrDw0LrLhb+ja6c5h6Lq96/djMkIbllSM7TvQblnVxL0pF wjK6ZJW+B6rHfhcUNy/NDjD9Diz/36Fidn3/CPcYG2YtAEwxPdnI6adQ+NmYAEHE7ejiKGSCjOr B/XPfOBXYW8AxfrWmN8q/DE24SE+9aKKc7/ubL4wV61DKIQbvv7K441WkYIMl3uzy8i5IPD7j6G UuRFHR+aoheu95 X-Google-Smtp-Source: ABdhPJwsbaYBOyXJRDjnCt+vuiN1Z1qmvQUAnv6nBNiLXJDPIbNYwESQIiFxG6TmpTXfrrX2wPvwog== X-Received: by 2002:a62:63c6:0:b029:18a:8d05:5bdc with SMTP id x189-20020a6263c60000b029018a8d055bdcmr13158583pfb.37.1604920663474; Mon, 09 Nov 2020 03:17:43 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:42 -0800 (PST) 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: [PATCH v4 05/19] lpfc: vmid: API to check if VMID is enabled. Date: Mon, 9 Nov 2020 09:53:51 +0530 Message-Id: <1604895845-2587-6-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gaurav Srivastava This API will determine if VMID is enabled by the user or not. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 8f0062d2b891..a62e985aa180 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1506,3 +1506,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; +} From patchwork Mon Nov 9 04:23:52 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: 11891173 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 2F81CC4741F for ; Mon, 9 Nov 2020 11:17:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4853206E5 for ; Mon, 9 Nov 2020 11:17:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="fNrKS/ra" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729445AbgKILRu (ORCPT ); Mon, 9 Nov 2020 06:17:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729459AbgKILRr (ORCPT ); Mon, 9 Nov 2020 06:17:47 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE16BC0613CF for ; Mon, 9 Nov 2020 03:17:47 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id z24so6895213pgk.3 for ; Mon, 09 Nov 2020 03:17:47 -0800 (PST) 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=5RUze3ELSJ47d9+H6aDZpmXqnAMKt427sSdWZIBAt7E=; b=fNrKS/ra/vjMjMocHaSGR8RKAw8IMerkNSRjlfgvLKzkIDaePx9oeDZL844LYv9633 LCWwwQNlLc4GbJRy1R8klyzmnFw6QhC0YnC7FCU78uwL6WoAImRtDi4thPq1Yaepx5dL 1BB5+0bgEcFMhAfZV3MUZeddFXeId/qZHUn/0= 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=5RUze3ELSJ47d9+H6aDZpmXqnAMKt427sSdWZIBAt7E=; b=P2odhGsgEwjqgYIuBnPnTDKJ00N5kJ++sf6QVzvEVTMNBdaQhMj6ra6d+Aat+4T7YS VAeAnrh+4NJCrXc8Y1NWFxv56iyrOsBk8G4SEiv9sk5YTo7UkJ4gRW3eVeC3EMgUz0dA p6Ehv9Pm1Hsuhfs3Rg6dQr/CD77v14no8waVGDYEbVT11QtQzaK6ZFMYslY2mK4FpPCo ZvCvzXvvqR7KaIJCz7NJtPIl3G5CNXqtW9VsxXOskwzi7bU2OaFOw910LdvpBcUzD/4u RtHBLTr48c/y92gOc+FncqUKaEWBwzopp7vu5e3UvlRyt/fCcoYst3bRbzSvvlMIX2By wKhA== X-Gm-Message-State: AOAM530b0olzTJKXJel9epEmSLnWrSHo6wwUMh9v5oHKAHU86Ymdi+hT uU9hFDiQ1JZF+F1WKlLTwREO5PyqhY3j3c82yDcTKZYC1G+MEp13lBLZG51LRAUlUwJBHVUwOaV 0CIFJ6P9tPzAQmsiBJgCodW4wb0x3gTskIVKZhfIB9+N5gKLi0GEk2dApNf3rbfAEW7X2h7QLFk +RMYw8oS76m/sQ X-Google-Smtp-Source: ABdhPJzcCUTQJd4ITKN1lGrh6CMjYuJOqy9af9fgmdbB+Vu6ndNsLrmBIWRBgqocMIoDBCHHTv/RTA== X-Received: by 2002:a17:90a:4087:: with SMTP id l7mr12444752pjg.17.1604920666785; Mon, 09 Nov 2020 03:17:46 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:46 -0800 (PST) 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: [PATCH v4 06/19] lpfc: vmid: Supplementary data structures for vmid Date: Mon, 9 Nov 2020 09:53:52 +0530 Message-Id: <1604895845-2587-7-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_disc.h | 1 + drivers/scsi/lpfc/lpfc_hw.h | 124 ++++++++++++++++++++++++++++++++-- drivers/scsi/lpfc/lpfc_sli.h | 8 +++ 3 files changed, 129 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index 482e4a888dae..c38313ee17dd 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h @@ -113,6 +113,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 */ + u8 vmid_support; /* destination VMID support */ #define NLP_NVME_NSLER 0x1 /* NVME NSLER device */ uint16_t nlp_usg_map; /* ndlp management usage bitmap */ diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index c20034b3101c..c6b252fbea40 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 */ + u16 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 */ + u16 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 { + u32 tag; + u32 length; + u8 vem_id[16]; +}; + +#define LPFC_QFPA_SIZE 4 + +#define INSTANTIATED_VE_DESC_TAG 0x0001000B +struct instantiated_ve_desc { + u32 tag; + u32 length; + u8 global_vem_id[16]; + u32 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 { + u32 tag; + u32 length; + u8 global_vem_id[16]; + u32 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 { + u32 tag; + u32 length; + u8 lo_range; + u8 hi_range; + u8 qos_priority; + u8 local_ve_id; +}; + +struct fc_qfpa_res { + u32 reply_sequence; /* LS_ACC or LS_RJT */ + u32 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 { + u8 entity_id_len; + u8 entity_id[255]; /* VM UUID */ +}; + +struct app_id_object { + u32 port_id; + u32 app_id; + struct entity_id_object obj; +}; + +struct lpfc_vmid_rapp_ident_list { + u32 no_of_objects; + struct entity_id_object obj[1]; +}; + +struct lpfc_vmid_dapp_ident_list { + u32 no_of_objects; + struct entity_id_object obj[1]; +}; + +#define GALLAPPIA_ID_LAST 0x80 +struct lpfc_vmid_gallapp_ident_list { + u8 control; + u8 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 93d976ea8c5d..6dd45885df4f 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 { + u32 app_id; + u8 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 Mon Nov 9 04:23:53 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: 11891165 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 D6FBEC2D0A3 for ; Mon, 9 Nov 2020 11:17:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 826712068D for ; Mon, 9 Nov 2020 11:17:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Fnyss9Ea" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgKILRx (ORCPT ); Mon, 9 Nov 2020 06:17:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729459AbgKILRv (ORCPT ); Mon, 9 Nov 2020 06:17:51 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CDDCC0613CF for ; Mon, 9 Nov 2020 03:17:51 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id 10so7859986pfp.5 for ; Mon, 09 Nov 2020 03:17:51 -0800 (PST) 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=Ahg2C9tYof8BHus9sSOOmqTH4mBobFxvKl1wQ5jm/wQ=; b=Fnyss9EabaBjFX8XOX6tE9xg7+R3C3PRSmItIthyLdZlN+JU5YY43I5p6DgX5cz8pb bt+riFRxqbV4pg8/K8X7FJj3+UgBoH/JCaUdIjSp+RndNp9s9rAT7gHHFucNGg7keGoL WYiXSfp1yfUB7lV3QUOtqGwZ7sztJYfn2TVwE= 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=Ahg2C9tYof8BHus9sSOOmqTH4mBobFxvKl1wQ5jm/wQ=; b=nO6Vjnkjew7oLxO3WY7//WwmQ9gP8I2uhzOw6qrcJ7Mkl/ADS55jEaVaunIFzbjXdt vEEGa+B1pPEQzYr8GLp8YUVOqPxAHqkrf98pgaUvCzP2iVDkN2cIJypUXgnkKfFV7fbN 33m6h4FAiCPK+7gmROfX3rtp4taK7yA2zw1rQjFzBRDnCopLGeh1FkgEGPYeTVswkhBV X6xnadCRrx+igPwDYB9mW4Ig5Q4erxpinMbLUpcQD++U+OLTENpDYDxFcWZQAk/a0yTW LODSTpVHFzKMOXp3b7Xl720c134/pX43RuM7GIm/63AEcd5tFBXYsdoWIwAcGAJZh24R 8zJg== X-Gm-Message-State: AOAM530vNizTqdj4rDlUQy00x6hJ4ARdKNU0Wbv6YB8pGRidhjpDeeO7 rDCz5smVSlgMhFSoZbEzqI0XxMdE4S/DhAKpglPnu91EFCaJbEkCkPlZ7Tb8h7Iu0pJMohEvF7D PDYuvwWK9FkJNRc+dVzSoajOi2D/qpFeqd3odCSicjqNCHUcDiAYIYNZ5VES2JSaqrn4ExkM6jz QKV1ecAZwYeQEW X-Google-Smtp-Source: ABdhPJyDT74bePv5jN3N0v5WzkXLNo15Mi3flRDKPpwBMPOu4PX15fw/zKxwwYgxzi/UyXxrrl+E4w== X-Received: by 2002:a63:64c1:: with SMTP id y184mr11719994pgb.397.1604920670168; Mon, 09 Nov 2020 03:17:50 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:49 -0800 (PST) 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: [PATCH v4 07/19] lpfc: vmid: Forward declarations for APIs Date: Mon, 9 Nov 2020 09:53:53 +0530 Message-Id: <1604895845-2587-8-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 contains the forward declarations of commonly used APIs which are used outside the scope of the file. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_crtn.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 782f6f76f18a..74ca5860ca8e 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -600,3 +600,14 @@ extern int lpfc_enable_nvmet_cnt; extern unsigned long long lpfc_enable_nvmet[]; extern int lpfc_no_hba_reset_cnt; extern unsigned long lpfc_no_hba_reset[]; + +/* vmid interface */ +int lpfc_vmid_uvem(struct lpfc_vport *vport, struct lpfc_vmid *vmid, bool ins); +u32 lpfc_vmid_get_cs_ctl(struct lpfc_vport *vport); +int lpfc_vmid_cmd(struct lpfc_vport *vport, + int cmdcode, struct lpfc_vmid *vmid); +int lpfc_vmid_hash_fn(char *vmid, int len); +struct lpfc_vmid *lpfc_get_vmid_from_hastable(struct lpfc_vport *vport, + u32 hash, u8 *buf); +void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport); +int lpfc_issue_els_qfpa(struct lpfc_vport *vport); From patchwork Mon Nov 9 04:23:54 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: 11891169 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 39714C388F7 for ; Mon, 9 Nov 2020 11:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9A052068D for ; Mon, 9 Nov 2020 11:17:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LdlmMswY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbgKILRz (ORCPT ); Mon, 9 Nov 2020 06:17:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729486AbgKILRy (ORCPT ); Mon, 9 Nov 2020 06:17:54 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E9CC0613CF for ; Mon, 9 Nov 2020 03:17:54 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id x13so7835041pfa.9 for ; Mon, 09 Nov 2020 03:17:54 -0800 (PST) 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=HoRyCtjbElXr2my3I1qxlOexOLsy7UNwisdBa0C49XI=; b=LdlmMswYqpgjyZCFSf6RBs7I7PVHkk6RFxjWQ7gSkoGbHdE5lnYZ9dBZ7HLnuIdmIN +OwHxGLhRazAtaDqzid4DC7Gmk6ml+mOMqr7gWeqPwxSqpAqB550iapr3H2x+GP5U60n 7fhdSFzJivWW+EucX/zqfvJupO/eNiq0+wydI= 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=HoRyCtjbElXr2my3I1qxlOexOLsy7UNwisdBa0C49XI=; b=cVYKG8c53gxvaSnLEGX2YnnAMhCh/E9+Dy+ydsphLbMtsF6yfIrrdZdtIIgTFA1GfZ byW7Yh6amw9zdLbQZ5V5dOlX19zcas52wsDDbEsNNE/RJG89uebINp+LQt3uGRLm69zF l9uB5od+suKP6tYTlll2ftYH2fsE74c3JgWJP28mmeC2QAfPRrKID+jnAyC/bbcmM2US xox8HhicZzdUKYDsV4ODRf6u7cTXuOxQkNHyTjvUJJ5+++wR3Xi3Me5yi2rfBnTH4sdG bX2Aub1PsMpqu7VNANmuzfD7ZlbMeqqH5uSnD+B9xuUKkgGU97l1Y0B+kPTMbbl//zcd lQGg== X-Gm-Message-State: AOAM532A90A2BRH5FTMQyoMzXpBk1+5YX+ZDGUrY1vZWkvEM71CD9uLU Ezk3DrFtQC4Zb3hE3whPynLq55dMPXy0Qt0l6k8CF4ON6ExF8dZmkIBh2HTuHLJ6kiZ+bqhzy6V mNHy7DWDEF9iXTVTHbb7mLE0M03Bdrf0SSz2Xoc8mxSIcTUHqX0EWEE1OQG0TBa4auHezb/+4e5 wK39CjOrIm9RpN X-Google-Smtp-Source: ABdhPJxhDe1q2JvRhpcX3J7dwk2wekGzVFHGr+KIDpG3bSPqE5jGZWMHFGAX2H0lF5TFuLGWAsWVHw== X-Received: by 2002:a17:90a:a781:: with SMTP id f1mr13282701pjq.50.1604920673891; Mon, 09 Nov 2020 03:17:53 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:53 -0800 (PST) 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: [PATCH v4 08/19] lpfc: vmid: Add support for vmid in mailbox command Date: Mon, 9 Nov 2020 09:53:54 +0530 Message-Id: <1604895845-2587-9-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 adds supporting datastructures for mailbox command which helps in determining if the firmware supports appid or not. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_hw4.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h index 12e4e76233e6..76c072366a16 100644 --- a/drivers/scsi/lpfc/lpfc_hw4.h +++ b/drivers/scsi/lpfc/lpfc_hw4.h @@ -272,6 +272,9 @@ struct lpfc_sli4_flags { #define lpfc_vfi_rsrc_rdy_MASK 0x00000001 #define lpfc_vfi_rsrc_rdy_WORD word0 #define LPFC_VFI_RSRC_RDY 1 +#define lpfc_ftr_ashdr_SHIFT 4 +#define lpfc_ftr_ashdr_MASK 0x00000001 +#define lpfc_ftr_ashdr_WORD word0 }; struct sli4_bls_rsp { @@ -2943,6 +2946,9 @@ struct lpfc_mbx_request_features { #define lpfc_mbx_rq_ftr_rq_mrqp_SHIFT 16 #define lpfc_mbx_rq_ftr_rq_mrqp_MASK 0x00000001 #define lpfc_mbx_rq_ftr_rq_mrqp_WORD word2 +#define lpfc_mbx_rq_ftr_rq_ashdr_SHIFT 17 +#define lpfc_mbx_rq_ftr_rq_ashdr_MASK 0x00000001 +#define lpfc_mbx_rq_ftr_rq_ashdr_WORD word2 uint32_t word3; #define lpfc_mbx_rq_ftr_rsp_iaab_SHIFT 0 #define lpfc_mbx_rq_ftr_rsp_iaab_MASK 0x00000001 @@ -2974,6 +2980,9 @@ struct lpfc_mbx_request_features { #define lpfc_mbx_rq_ftr_rsp_mrqp_SHIFT 16 #define lpfc_mbx_rq_ftr_rsp_mrqp_MASK 0x00000001 #define lpfc_mbx_rq_ftr_rsp_mrqp_WORD word3 +#define lpfc_mbx_rq_ftr_rsp_ashdr_SHIFT 17 +#define lpfc_mbx_rq_ftr_rsp_ashdr_MASK 0x00000001 +#define lpfc_mbx_rq_ftr_rsp_ashdr_WORD word3 }; struct lpfc_mbx_supp_pages { @@ -4383,6 +4392,9 @@ struct wqe_common { #define wqe_nvme_SHIFT 4 #define wqe_nvme_MASK 0x00000001 #define wqe_nvme_WORD word10 +#define wqe_appid_SHIFT 5 +#define wqe_appid_MASK 0x00000001 +#define wqe_appid_WORD word10 #define wqe_oas_SHIFT 6 #define wqe_oas_MASK 0x00000001 #define wqe_oas_WORD word10 From patchwork Mon Nov 9 04:23:55 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: 11891167 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 B269FC388F7 for ; Mon, 9 Nov 2020 11:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56AF12068D for ; Mon, 9 Nov 2020 11:17:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LdLh3BJc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbgKILR6 (ORCPT ); Mon, 9 Nov 2020 06:17:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729496AbgKILR6 (ORCPT ); Mon, 9 Nov 2020 06:17:58 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3147BC0613CF for ; Mon, 9 Nov 2020 03:17:58 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id r186so6899078pgr.0 for ; Mon, 09 Nov 2020 03:17:58 -0800 (PST) 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=ZHTxB+XRmkGj/AJt3yR3OUAv7mEIQ77RkPMPcZSzJdY=; b=LdLh3BJcFU7h8FniGqccGy8++L6gh85CwNwkLdeaovRcXlimqnaFsLqQijjzYvdqbw 3pT4vvE/H0yWBq6HKgfPV3AaxVdo8zLeleFO8oywS+oMmcY6FZDaAAiGoNwQkMc1pa5p pGZwk2UjuCXcCPr1SYmiap7nGg79fZ/oYyLZw= 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=ZHTxB+XRmkGj/AJt3yR3OUAv7mEIQ77RkPMPcZSzJdY=; b=CPvtoi42QeiFiaDKmpVLbXUq84tflMFKOpyw6jww2WTm8t4UuDqtMEW3QsYmOO5RF3 p5ejMsA/5ffdKjIuQMEzPITnvPw6yIjyh4jMD45x+14Vy06W6HDb9yqCqxX0QFncHDSs YlT0vaxkEptPx73ZL8791uG8fEjPNf9GfDumTasnVUogLrTOW6Tcp2OQgc08hH+GOZxx hZ13fXErzc0lg3RSYGu9kH5bIBFIhIBV8fo8LbCnleztmTucaXeenB7VKOFV021b8xMr c/DVjxs8YYXLHMnMwYAFJFWK5rtYWebD6LpYwuusdjlKZEgzfQwiEgXVpxXr/0Hi/KrG FHgw== X-Gm-Message-State: AOAM53185iYGmCsSUgAdPEUkTmVRFxKvNQszM5P95IU11exVHJVsQk7D HViqDgWaGowH2/OeHkQTW3aeXw2kphRFzgJkmsaMcuIaaVMbdV4vN2nv1nuUHBcEp+I5g+0dFxV VDgNH+8BhK2OBskzEdX76K6Y/+WZQPxVOHzXfZ/1R7tLRwWj1tFMVj9VlsG6G6cpM3gh+FMaVnx DSlUBcJAoU/GC9 X-Google-Smtp-Source: ABdhPJzZchJhr58R3RQILDpyOWhUy8h5t2Xti8nSAWsoP69xQbNEogTnmQumDwGVczvz/bquHZyN/A== X-Received: by 2002:aa7:808d:0:b029:18b:571c:12fb with SMTP id v13-20020aa7808d0000b029018b571c12fbmr10078771pff.32.1604920677265; Mon, 09 Nov 2020 03:17:57 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:17:56 -0800 (PST) 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: [PATCH v4 09/19] lpfc: vmid: VMID params initialization Date: Mon, 9 Nov 2020 09:53:55 +0530 Message-Id: <1604895845-2587-10-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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 Reviewed-by: Hannes Reinecke --- 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 e94eac194676..e73997bce65c 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -6138,6 +6138,44 @@ LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); */ LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); +/* + * 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, @@ -6255,6 +6293,10 @@ struct device_attribute *lpfc_hba_attrs[] = { &dev_attr_lpfc_ras_fwlog_func, &dev_attr_lpfc_enable_bbcr, &dev_attr_lpfc_enable_dpp, + &dev_attr_lpfc_max_vmid, + &dev_attr_lpfc_vmid_inactivity_timeout, + &dev_attr_lpfc_vmid_app_header, + &dev_attr_lpfc_vmid_priority_tagging, NULL, }; @@ -7314,6 +7356,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 Mon Nov 9 04:23:56 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: 11891175 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 AF5BEC56201 for ; Mon, 9 Nov 2020 11:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 528F92084C for ; Mon, 9 Nov 2020 11:18:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IsfYK5IW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729471AbgKILSD (ORCPT ); Mon, 9 Nov 2020 06:18:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729503AbgKILSC (ORCPT ); Mon, 9 Nov 2020 06:18:02 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06E8C0613CF for ; Mon, 9 Nov 2020 03:18:01 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id x13so7835449pfa.9 for ; Mon, 09 Nov 2020 03:18:01 -0800 (PST) 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=Kx3DaRsT0aXG9tDQywA+K/vgQefxT02t1cJzNsJclpY=; b=IsfYK5IWWV/FOTYwUpfKVIQP14IhjFIG4xEUwqeAW1nKaJ54Ux6V+n3IVxmzJgm5z+ 3qEFXZ9PvvPK4WfKG3/JPKiK7kpNZv/nux2+bOO91w8A7PlXwMHZDFLouEbOQMBull1J u2K/CZ4RsKXl9zXmQ0cUefcd/G0ZXT7cSsCSc= 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=Kx3DaRsT0aXG9tDQywA+K/vgQefxT02t1cJzNsJclpY=; b=d7rx8YW6P+Te5OHXJwfY6jeSt2p88meAo0X/ANiau39lY9o7Yf1I3Mzq3ZvfjC2lun +RJLG1q3XtRCHVxido7ucxwKFc6Q1nh/KBY0iyr+OJT+EL45zG9eSNsQE+rJU/e2iTcd GzI0+K5w5bIM5TH5JH56UfRzLTrtLIwvT8k/O1LxTBbrwsOnqBfwwJqjNeuznwf7WnnL z77/BXKxUrrhmXNanVeFikQG1yZbVKaPSukQaOnI+1rPYRtrCWMCF+4Pg3VeaDLY6sU/ KZX+c9AKWbTCPSlCRoYJ9IBzYExjjSvVOlB+6AKFlxpWSGYzq7RUaFdghOg4T0/eqYx7 tsSg== X-Gm-Message-State: AOAM5318h45opJQbpkIR/YT2YyUjFUNKBlKnynMsJqpgPa5r8CVZA6Re RXGvsveLDj/d4i4sLLrSRZS1ETzZBWr4Uu68zW62Ln8492OL0biHfIfENMFfHh5t8upX/BBjbbQ h9owLW6bKZsqjQRmpSJcyUxaJOp8KvRS41ZlHnZLTY2I5FWy7GTe+F0z63sQn0V7CxJH/lBIWBc A5iJAQ+VKIwye1 X-Google-Smtp-Source: ABdhPJweUZCnsdqDXPoXK5W0ogEJgW4LRBJax3niaWT9ShBijnnB2tcmC/MhwH0NkYn6PN9H4G90xw== X-Received: by 2002:a65:6158:: with SMTP id o24mr13031977pgv.120.1604920681045; Mon, 09 Nov 2020 03:18:01 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.17.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:00 -0800 (PST) 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: [PATCH v4 10/19] lpfc: vmid: vmid resource allocation Date: Mon, 9 Nov 2020 09:53:56 +0530 Message-Id: <1604895845-2587-11-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 --- 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. From patchwork Mon Nov 9 04:23:57 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: 11891187 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 014B4C56201 for ; Mon, 9 Nov 2020 11:18:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AC602084C for ; Mon, 9 Nov 2020 11:18:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Lqr/ajAc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729506AbgKILSF (ORCPT ); Mon, 9 Nov 2020 06:18:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbgKILSF (ORCPT ); Mon, 9 Nov 2020 06:18:05 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4289FC0613CF for ; Mon, 9 Nov 2020 03:18:05 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id f27so3487512pgl.1 for ; Mon, 09 Nov 2020 03:18:05 -0800 (PST) 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=T96XxXAsPtKg3yXEcXNpSqxaKbb5SdjFmCaPGDe6eMk=; b=Lqr/ajAc4UvXnZ9TAiR8NdDKpqrGZxyK3bxKP/WR5yUxcIhcfwSSMBvsTGP786oH2p 6G/1DcOjs5VdNEdLzTAQ9v999p6ymIzHf7RK5xenNxB6jonZEfXSR5jH/X8MBUec1Yxh K3f9qwck9dWYB0mKXAOowblJC+LK1UbCaEt40= 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=T96XxXAsPtKg3yXEcXNpSqxaKbb5SdjFmCaPGDe6eMk=; b=cn1TmGhAS+3aG3YTvMYKai05XIQgYGzJ1aYZfEmLhMxmoHp3Odqf+lQbcSdp+G4+HC YTZ9lp44xszdkundmhtVkcyJ7ORGG5Elmz3egoP7RrF3pTPDaKhcq/grDYLC5QDTH3G/ TDSrMs4juLAMiuMl9uQb8Exgzkk/lVgcCq+f9Rs3Q2fUjBfOY5hHsS+JtewKfuX1CmJu A01L6ovsMGtxckH5nRKJZaTj1rauaKNtSwuoV+KNn9GLgBznbVZp/L1D70nkD8FeFW9R KIh97Hnk+oZbsovXaFWZtKqsBEs6NJ8NXjAUMCt+omJR4TNs8DhQ2ClwnfCJnQIbyDvE Xp8w== X-Gm-Message-State: AOAM533I9tMxzJt/zokS+yUYVfveC0j2CsgHbjm33i1RC8AOXe/ynfTO s36LDqmkG84d8+0wxMQ/n3SZvM+sSeHPsQ+JmQXi+TGBGg9RhlnFglFYM4W0cgAJPs5/uSvr+Ou /sfLPFD6XTTNOJGhExf8amDTnKJfYflKSUFhlycksr2WDsXE7iH90A9HwsIzaU8iuYwmAsK9ft1 gF52nSwFxnlpOX X-Google-Smtp-Source: ABdhPJz67DjUk/8ykAuAAEk5/oqxdaUSRyqIdpdgdDk/EKvGe3p3VPrO4YZljw3iTPvzQx03ydiIgw== X-Received: by 2002:a65:6086:: with SMTP id t6mr12335482pgu.146.1604920684354; Mon, 09 Nov 2020 03:18:04 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:03 -0800 (PST) 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: [PATCH v4 11/19] lpfc: vmid: cleanup vmid resources Date: Mon, 9 Nov 2020 09:53:57 +0530 Message-Id: <1604895845-2587-12-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gaurav Srivastava The patch cleans up the vmid resources and stops the timer. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_init.c | 4 ++++ drivers/scsi/lpfc/lpfc_scsi.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index e32d69515586..88777875f4b8 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -2843,6 +2843,10 @@ lpfc_cleanup(struct lpfc_vport *vport) if (phba->link_state > LPFC_LINK_DOWN) lpfc_port_link_failure(vport); + /* cleanup vmid resources */ + if (lpfc_is_vmid_enabled(phba)) + lpfc_vmid_vport_cleanup(vport); + list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { if (!NLP_CHK_NODE_ACT(ndlp)) { ndlp = lpfc_enable_node(vport, ndlp, diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 5e802c8b22a9..7bc1fd69b715 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -4711,6 +4711,27 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) return 0; } +/* + * lpfc_vmid_vport_cleanup - cleans up the resources associated with a vports + * @vport: The virtual port for which this call is being executed. + */ +void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport) +{ + /* delete the timer */ + if (vport->port_type == LPFC_PHYSICAL_PORT) + del_timer_sync(&vport->phba->inactive_vmid_poll); + + /* free the resources */ + kfree(vport->qfpa_res); + kfree(vport->vmid_priority.vmid_range); + kfree(vport->vmid); + + /* reset variables */ + vport->qfpa_res = NULL; + vport->vmid_priority.vmid_range = NULL; + vport->vmid = NULL; + vport->cur_vmid_cnt = 0; +} /** * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point From patchwork Mon Nov 9 04:23:58 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: 11891177 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=-8.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_PATCH,MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,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 C7A30C56201 for ; Mon, 9 Nov 2020 11:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64FB42068D for ; Mon, 9 Nov 2020 11:18:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="XUyaYtTU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729454AbgKILSO (ORCPT ); Mon, 9 Nov 2020 06:18:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729511AbgKILSN (ORCPT ); Mon, 9 Nov 2020 06:18:13 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0802C0613CF for ; Mon, 9 Nov 2020 03:18:13 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id e7so7833491pfn.12 for ; Mon, 09 Nov 2020 03:18:13 -0800 (PST) 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=EP1R2jpSPy5czvKeSIl1txS4Ev44+fgkrA9NFuJIt3E=; b=XUyaYtTUXvNa9dftiDjH2WKsXb6S6ZcC7Qtkbo2xPiuqDAcZ4W0Harw7dzT9rvzEzX MFRm9cfMI8HTatgrbmOzoxfLFsbvpjY6ySbcB2LJSQ7JAKl4dhXNP8ETcqLX+yRfN9aP 5wg9n0nQ3WtW0rpWeI4nTU7iOUjUk3rxquWBg= 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=EP1R2jpSPy5czvKeSIl1txS4Ev44+fgkrA9NFuJIt3E=; b=JjMw5eB6erH/okqF6K3O27CS6yh7f4AWOjHHEZrHptsWO2LDrzgBBqtta5zZeNtrlW 3vSjmuDVm2exu/jHt0/p0cBpA05ByK58gL11qJV++BLDMat7yoCADN3ZvZcxwkYdFxH/ P2L0YEpgfGdKHiZSCJfUA6aaTpDZc4X0as7QTzygd9l/Pjmx0TLxWtqwoJfxo7WWxvl8 5Qqj0jm0S5yn3S4n6eW633hfYn/yoMHmqc2ZUTMB3vyyMeSVFyH7nX8kpqv1FQvDq81L iCwjeKOs3uVel8wyR9RdIQkDbuzqBgxQtZJWmQAWcXirYGQuD1Jr4uLBrXssyLjyxmQF alQg== X-Gm-Message-State: AOAM532+tW7mtN7rLFZmdiAzljwE1xRpz95tlFe/ffdZ6eEZ3+MtMxrR oQg1kgXVjpAAxmcfV8YULzipqZij7IKeQow3ZPVu2jqMSyWjVvYwnQLI8I0/93WUAYa29ex+bgt jpsYq75x9rkmkfZFAceiMaegMUoQycbEtFV1h2elbFa3jyweHAJILItODqrKFK3y8Y90IgC7rOC YgXOQBElS7fIqU X-Google-Smtp-Source: ABdhPJzKdCjdDSnxzaedA69o9/9BBgkSZPdZz9+KGgzvHwEqZ15VeEKuU3VVvjwwPYZOOobjRwnk6A== X-Received: by 2002:a17:90b:4c10:: with SMTP id na16mr10425245pjb.38.1604920687810; Mon, 09 Nov 2020 03:18:07 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:07 -0800 (PST) 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: [PATCH v4 12/19] lpfc: vmid: Implements ELS commands for appid patch Date: Mon, 9 Nov 2020 09:53:58 +0530 Message-Id: <1604895845-2587-13-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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 --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_els.c | 356 ++++++++++++++++++++++++++++++++++- 1 file changed, 349 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index f4e274eb6c9c..4f61d2edb89b 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; @@ -316,12 +319,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, @@ -1116,12 +1119,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) { /* @@ -1302,6 +1309,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 (vport->lpfc_vmid_host_uuid[0] == 0) { + 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) { @@ -1999,6 +2018,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *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; @@ -2074,6 +2094,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); } @@ -2192,6 +2229,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); @@ -10162,3 +10207,300 @@ 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; + + prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list); + if (!prsp) + goto out; + + pcmd = prsp->virt; + data = (u32 *)pcmd; + if (*((u32 *)(pcmd)) == 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); +} + +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 && !NLP_CHK_NODE_ACT(ndlp)) + return 1; + + if (!ndlp) + return 1; + + elsiocb = lpfc_prep_els_iocb(vport, 1, LPFC_QFPA_SIZE, 2, ndlp, + ndlp->nlp_DID, ELS_CMD_QFPA); + if (!elsiocb) + return 1; + + 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; + ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 2); + if (ret != IOCB_SUCCESS) { + lpfc_els_free_iocb(phba, elsiocb); + return 1; + } + 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 && !NLP_CHK_NODE_ACT(ndlp)) + return 1; + + vmid_context = kmalloc(sizeof(*vmid_context), GFP_KERNEL); + if (!vmid_context) + return 1; + 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 (vport->lpfc_vmid_host_uuid[0] == 0) + 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; + 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 1; +} + +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 && !NLP_CHK_NODE_ACT(ndlp)) + ndlp = NULL; + + prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list); + if (!prsp) + goto out; + pcmd = prsp->virt; + data = (u32 *)pcmd; + if (*((u32 *)(pcmd)) == 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); +} From patchwork Mon Nov 9 04:23:59 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: 11891185 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 29AE0C388F7 for ; Mon, 9 Nov 2020 11:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C29022068D for ; Mon, 9 Nov 2020 11:18:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ecmFDC1/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729045AbgKILSN (ORCPT ); Mon, 9 Nov 2020 06:18:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729470AbgKILSM (ORCPT ); Mon, 9 Nov 2020 06:18:12 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25BE7C0613D3 for ; Mon, 9 Nov 2020 03:18:12 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id x23so4570677plr.6 for ; Mon, 09 Nov 2020 03:18:12 -0800 (PST) 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=+Wqw+cGAmX2MBUHddFMmFCSVkc+MU+LrRz67teKLtTY=; b=ecmFDC1/u+bKarfYaPaVErpAn/57OPajcjVZbtQj9GSuyjNIWuyJzmXfxhvFEWsE0R K6uLjbXBOm8lTU16DI/l2FnAUBd4YZUg1/kJnqMRswoZtQHtieuAzpN8+GI3nb2zY3jw SeSk1Vd3JEMG6OWL7yRCjLgh43fP999U49Lno= 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=+Wqw+cGAmX2MBUHddFMmFCSVkc+MU+LrRz67teKLtTY=; b=mYQl5NYvL0Ll6MA4UGN2ylhOBQro5aaagAvE6m29rvBdZouxK8tKufaaT0PRW9TidT tzmFmvyx1a3Zt/opl7QEinGZl3wNKFkHoR3PvB1+IR9ajzLRESpihHXUe5aY+9iGepfG qJhA8zEpdY/AxVdWvWofc8clqnctA3Z6sYZJhYLMCvH7/UxfbNB6ndjBTBc/bTNeqXTk S0xpAIFkSU927wzI/ISDxGIEGhIvaaeQUx6b06vuLPASftrp30K7PTTaiSs+hYLJcaYs qQhumZWDO0G9IT2OQ9MOGMd2FmV/jHsQEDmeT6Ogz24FnYm01cUSBzuPidGXzDPfT5xM oMnQ== X-Gm-Message-State: AOAM533FVQWcDofcSyos8NwGAEsUUAR7jAf8AUIH7RfnV18CnO5Igugi jhLjrx4G2eJkLdJLMJ0c31Q+L6E5VFQNiv3QORqB89RoeT3cExejvjuWt2iVQD+qpZJV3hIFSKL eGjNRhhPBIbHiOJlC4Fn67UjaelFoFhyAPku8pn6S4ffKiQm3lWpJe+lgfV5rWBWDZiS25kiHe0 F5Q/qwGpf3gCkA X-Google-Smtp-Source: ABdhPJyuzKRflM4/7Q8uhjIEnq1+23atRo9wADWO4qETAxLZDvBsPMvv94mmV9eXOiSCIc0WmCuQqA== X-Received: by 2002:a17:902:c281:b029:d7:ce5d:6406 with SMTP id i1-20020a170902c281b02900d7ce5d6406mr8848345pld.35.1604920691188; Mon, 09 Nov 2020 03:18:11 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:10 -0800 (PST) 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: [PATCH v4 13/19] lpfc: vmid: Functions to manage vmids Date: Mon, 9 Nov 2020 09:53:59 +0530 Message-Id: <1604895845-2587-14-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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 --- 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 7bc1fd69b715..e5a1056cc575 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 @@ -4485,6 +4486,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 1; + } + /* 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 * @cmnd: Pointer to scsi_cmnd data structure. From patchwork Mon Nov 9 04:24:00 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: 11891181 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 9527EC388F7 for ; Mon, 9 Nov 2020 11:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0282B2068D for ; Mon, 9 Nov 2020 11:18:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="P+9br5Fu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726999AbgKILSQ (ORCPT ); Mon, 9 Nov 2020 06:18:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729511AbgKILSP (ORCPT ); Mon, 9 Nov 2020 06:18:15 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF43C0613CF for ; Mon, 9 Nov 2020 03:18:15 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id q5so4873213pfk.6 for ; Mon, 09 Nov 2020 03:18:15 -0800 (PST) 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=USVZW3hdaA1coxa/Rq654YSofBf+CD3JgHoon1on6ZQ=; b=P+9br5FuiNsFdYBnHOWdGxUj3BFSG/fJHqpwFls/xvBrZHCKfWD8DKGZYIZ51D5Nps iqNhXHqiBlvX21CvY1V50oYfrQgLORcOqJdVp772K4SwE14OBxhQKWQCN/+asnapghpY M5f1wT3Q7hboB9QEitMb8ZGiaxdNn/PHvN9cM= 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=USVZW3hdaA1coxa/Rq654YSofBf+CD3JgHoon1on6ZQ=; b=PrefcOd3rRoqwVwXj5pYo7Ibhx2l8PGsAfZoECQYUQq5VCcVhDzo5hNm2URo+ec7++ 8IOUPxysAPW7+v2qGEWoa0iMOsAjFAeIA9ECSNoKWRx3CBdmtX5glyb8wjHYfoW9/uGG IxvAeSL7l8eMDdFm4mm5vwgqbj0vQ221asGJLCW4PiTG4kgkREOh3oGxh+f7fK5yECtI KUzP4sxBPwzgqo6BQnswb5NYuG+7+muNRCyLFd2tTbP7+deQ1iageKxFA99jQljsgqgk JsoBygWLjluERXWqOiaX3VWzQ5OU7goqcP+YVPVzMRCf+nW5B2ayTxdGmBTxkihBl49H v5fQ== X-Gm-Message-State: AOAM533UGsET7UqVfeukEQHtBU6dr7rHmrd024tKxRUkP8JHtiiViXpf hu2b8pHI5fQoBO/al68v/5S/5jItJI3XixeWgEBiLdJopbKelfIeZ8yFW/euIoK6omJ5zNzR2YV zSErWE1ijjBzhC4aeOobLMc7MmNeXrJ3nvgFjk6PPWZaKDYpGmqwhPFSoTaXeYD/WL4ZO8yJHTD GBlmLr5Xl1EGTD X-Google-Smtp-Source: ABdhPJyAwdCYEX8wA6cmf/jzu+U9NCfv3pEHJDk0C5LRndBHHNT2/lKG6eIwVYoFY//BulOt5a4JFg== X-Received: by 2002:a17:90a:de15:: with SMTP id m21mr12952870pjv.180.1604920694891; Mon, 09 Nov 2020 03:18:14 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:13 -0800 (PST) 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: [PATCH v4 14/19] lpfc: vmid: Implements CT commands for appid. Date: Mon, 9 Nov 2020 09:54:00 +0530 Message-Id: <1604895845-2587-15-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gaurav Srivastava The patch implements CT commands for registering and deregistering the appid for the application. Also, a small change in decrementing the ndlp ref counter has been added. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue Removed redundant code due to changes since last submit --- drivers/scsi/lpfc/lpfc_ct.c | 249 ++++++++++++++++++++++++++++++++++++ 1 file changed, 249 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index c201686d3815..691f78340f26 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -3406,3 +3406,252 @@ lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) } return; } + +void +lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + struct lpfc_iocbq *rspiocb) +{ + struct lpfc_vport *vport = cmdiocb->vport; + struct lpfc_dmabuf *inp = cmdiocb->context1; + struct lpfc_dmabuf *outp = cmdiocb->context2; + struct lpfc_sli_ct_request *ctcmd = inp->virt; + struct lpfc_sli_ct_request *ctrsp = outp->virt; + u16 rsp = ctrsp->CommandResponse.bits.CmdRsp; + struct app_id_object *app; + u32 cmd, hash; + struct lpfc_vmid *vmp; + u8 *data = outp->virt; + int i; + + cmd = be16_to_cpu(ctcmd->CommandResponse.bits.CmdRsp); + if (cmd == SLI_CTAS_DALLAPP_ID) + lpfc_ct_free_iocb(phba, cmdiocb); + + if (lpfc_els_chk_latt(vport) || rspiocb->iocb.ulpStatus) { + if (cmd != SLI_CTAS_DALLAPP_ID) + return; + } + /* Check for a CT LS_RJT response */ + if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { + if (cmd != SLI_CTAS_DALLAPP_ID) + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "3306 VMID FS_RJT Data: x%x %x %x\n", + cmd, ctrsp->ReasonCode, ctrsp->Explanation); + if ((cmd != SLI_CTAS_DALLAPP_ID) || + (ctrsp->ReasonCode != SLI_CT_UNABLE_TO_PERFORM_REQ) || + (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) { + /* If DALLAPP_ID failed retry later */ + if (cmd == SLI_CTAS_DALLAPP_ID) + vport->load_flag |= FC_DEREGISTER_ALL_APP_ID; + return; + } + } + + switch (cmd) { + case SLI_CTAS_RAPP_IDENT: + app = (struct app_id_object *)(RAPP_IDENT_OFFSET + data); + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "6712 RAPP_IDENT app id %d port id %x id\n" + "len %d\n", be32_to_cpu(app->app_id), + be32_to_cpu(app->port_id), + app->obj.entity_id_len); + + if (app->obj.entity_id_len == 0 || app->port_id == 0) + return; + + hash = lpfc_vmid_hash_fn(app->obj.entity_id, + app->obj.entity_id_len); + vmp = lpfc_get_vmid_from_hastable(vport, hash, + app->obj.entity_id); + if (vmp) { + vmp->un.app_id = be32_to_cpu(app->app_id); + vmp->flag |= LPFC_VMID_REGISTERED; + vmp->flag &= ~LPFC_VMID_REQ_REGISTER; + /* Set IN USE flag */ + vport->vmid_flag |= LPFC_VMID_IN_USE; + } else { + lpfc_printf_vlog(vport, KERN_DEBUG, + LOG_DISCOVERY, "6901 No entry found\n" + "%s hash %d\n", app->obj.entity_id, + hash); + } + break; + case SLI_CTAS_DAPP_IDENT: + app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data); + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "6713 DAPP_IDENT app id %d port id %x", + cpu_to_be32(app->app_id), + cpu_to_be32(app->port_id)); + break; + case SLI_CTAS_DALLAPP_ID: + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "8856 Deregistered all app ids"); + for (i = 0; i < phba->cfg_max_vmid; i++) { + vmp = &vport->vmid[i]; + if (vmp->flag != LPFC_VMID_SLOT_FREE) + memset(vmp, 0, sizeof(struct lpfc_vmid)); + } + for (i = 0; i < LPFC_VMID_HASH_SIZE; i++) + vport->hash_table[i] = NULL; + vport->load_flag |= FC_ALLOW_VMID; + break; + default: + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "8857 Invalid command code"); + } +} + +/** + * lpfc_vmid_cmd - Build and send a FDMI cmd to the specified NPort + * @vport: pointer to a host virtual N_Port data structure. + * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID) + * cmdcode: FDMI command to send + * mask: Mask of HBA or PORT Attributes to send + * + * Builds and sends a FDMI command using the CT subsystem. + */ +int +lpfc_vmid_cmd(struct lpfc_vport *vport, + int cmdcode, struct lpfc_vmid *vmid) +{ + struct lpfc_hba *phba = vport->phba; + struct lpfc_dmabuf *mp, *bmp; + struct lpfc_sli_ct_request *ctreq; + struct ulp_bde64 *bpl; + u32 size; + u32 rsp_size; + u8 *data; + struct lpfc_vmid_rapp_ident_list *rap; + struct lpfc_vmid_dapp_ident_list *dap; + u8 retry = 0; + struct lpfc_nodelist *ndlp; + + void (*cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + struct lpfc_iocbq *rspiocb); + + ndlp = lpfc_findnode_did(vport, FDMI_DID); + if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) + return 0; + + cmpl = lpfc_cmpl_ct_cmd_vmid; + + /* fill in BDEs for command */ + /* Allocate buffer for command payload */ + mp = kmalloc(sizeof(*mp), GFP_KERNEL); + if (!mp) + goto vmid_free_mp_exit; + + mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); + if (!mp->virt) + goto vmid_free_mp_virt_exit; + + /* Allocate buffer for Buffer ptr list */ + bmp = kmalloc(sizeof(*bmp), GFP_KERNEL); + if (!bmp) + goto vmid_free_bmp_exit; + + bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys); + if (!bmp->virt) + goto vmid_free_bmp_virt_exit; + + INIT_LIST_HEAD(&mp->list); + INIT_LIST_HEAD(&bmp->list); + + lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, + "0218 VMID Request Data: x%x x%x x%x", + vport->fc_flag, vport->port_state, cmdcode); + ctreq = (struct lpfc_sli_ct_request *)mp->virt; + data = mp->virt; + /* First populate the CT_IU preamble */ + memset(data, 0, LPFC_BPL_SIZE); + ctreq->RevisionId.bits.Revision = SLI_CT_REVISION; + ctreq->RevisionId.bits.InId = 0; + + ctreq->FsType = SLI_CT_MANAGEMENT_SERVICE; + ctreq->FsSubType = SLI_CT_APP_SEV_Subtypes; + + ctreq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode); + rsp_size = LPFC_BPL_SIZE; + size = 0; + + switch (cmdcode) { + case SLI_CTAS_RAPP_IDENT: + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "1329 RAPP_IDENT for %s", vmid->host_vmid); + ctreq->un.PortID = cpu_to_be32(vport->fc_myDID); + rap = (struct lpfc_vmid_rapp_ident_list *) + (DAPP_IDENT_OFFSET + data); + rap->no_of_objects = cpu_to_be32(1); + rap->obj[0].entity_id_len = vmid->vmid_len; + memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len); + size = RAPP_IDENT_OFFSET + + sizeof(struct lpfc_vmid_rapp_ident_list); + retry = 1; + break; + + case SLI_CTAS_GALLAPPIA_ID: + ctreq->un.PortID = cpu_to_be32(vport->fc_myDID); + size = GALLAPPIA_ID_SIZE; + break; + + case SLI_CTAS_DAPP_IDENT: + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "1469 DAPP_IDENT for %s", vmid->host_vmid); + ctreq->un.PortID = cpu_to_be32(vport->fc_myDID); + dap = (struct lpfc_vmid_dapp_ident_list *) + (DAPP_IDENT_OFFSET + data); + dap->no_of_objects = cpu_to_be32(1); + dap->obj[0].entity_id_len = vmid->vmid_len; + memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len); + size = DAPP_IDENT_OFFSET + + sizeof(struct lpfc_vmid_dapp_ident_list); + vmid->flag &= ~LPFC_VMID_REGISTERED; + retry = 1; + break; + + case SLI_CTAS_DALLAPP_ID: + ctreq->un.PortID = cpu_to_be32(vport->fc_myDID); + size = DALLAPP_ID_SIZE; + break; + + default: + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "7062 VMID cmdcode x%x not supported", + cmdcode); + goto vmid_free_all_mem; + } + + ctreq->CommandResponse.bits.Size = cpu_to_be16(rsp_size); + + bpl = (struct ulp_bde64 *)bmp->virt; + bpl->addrHigh = putPaddrHigh(mp->phys); + bpl->addrLow = putPaddrLow(mp->phys); + bpl->tus.f.bdeFlags = 0; + bpl->tus.f.bdeSize = size; + + /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count + * to hold ndlp reference for the corresponding callback function. + */ + if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) + return 0; + + /* Decrement ndlp reference count to release ndlp reference held + * for the failed command's callback function. + */ + lpfc_nlp_put(ndlp); + + vmid_free_all_mem: + lpfc_mbuf_free(phba, bmp->virt, bmp->phys); + vmid_free_bmp_virt_exit: + kfree(bmp); + vmid_free_bmp_exit: + lpfc_mbuf_free(phba, mp->virt, mp->phys); + vmid_free_mp_virt_exit: + kfree(mp); + vmid_free_mp_exit: + + /* Issue FDMI request failed */ + lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, + "0244 Issue FDMI request failed Data: x%x", cmdcode); + return 1; +} From patchwork Mon Nov 9 04:24:01 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: 11891183 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 69803C4741F for ; Mon, 9 Nov 2020 11:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18FD02068D for ; Mon, 9 Nov 2020 11:18:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CKx+ppsL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729521AbgKILST (ORCPT ); Mon, 9 Nov 2020 06:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728462AbgKILST (ORCPT ); Mon, 9 Nov 2020 06:18:19 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23223C0613CF for ; Mon, 9 Nov 2020 03:18:19 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id w11so4579734pll.8 for ; Mon, 09 Nov 2020 03:18:19 -0800 (PST) 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=Z/vBEhIXZKIKOpbTvWEe9EyNUuMiYq3vXkhj51SSlRc=; b=CKx+ppsLOGJdIUvo8prTFOgsknNqN0mMfu33PyUZFdIDOpdG9+kva54udChE/hFrQh Om9Mih1NTpyNhHdSCrSikctVz+0DWplSUqH6soIt6Ra3m7OTYaSKquQnHToGtwjPV02I XxsP9vScHO44Rl7iKw2F8NrrmXYk0E2pT+tEU= 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=Z/vBEhIXZKIKOpbTvWEe9EyNUuMiYq3vXkhj51SSlRc=; b=OSNfXmT/TbawohH8mpVpzmPdrWsbfKeB0r1PkxA/hKyeQAC4pobtAgmB+H02pZnAtf lH5IEQB+u4w3D9btO8rxYWYJ9UDzkY0pJe/TyDAL3EE98o3PU2mU1HHr1pdCShjBfNXz +3iXq5a4iYn139pOMgaZ7LRlILKSbWLLH+y2/U7xFCRoo99nFkavDu0Ap7QKRKz271pY A7DQWW7hAPgkb8Lk8im0RG7QCxnP+P6BzReyaBZhOP+SBefIyku+Ja8E75fgiO+i7eNc kTBr9KgMzzYR8oBl+W3y7AhSyKjea23YrH8p9sItlW+GJGl2SQcMJYI6W+7MacRXCktA WwpA== X-Gm-Message-State: AOAM531SJlCbe/Pr5uACSYPpBorFsXxINvLbyQJKGgJL1RFKu8D4vj6u Yp98cHtFTp8O2PzsT2XBJq2PEKv0y6VsFIJnEOjVC1jjl4GDjXAJ9T6SuEh8JjQPhT3T7lLX8Qz Gl1pKftcnatcivw2vWxJ/wpNc9e/GMM/nsDgwCyxtyHT/9cqZXw4gUhA3uk4EXLMFOQWJ4UaG8/ b42rEgAR206+Q5 X-Google-Smtp-Source: ABdhPJxcPkQeVrey5D0LUH/bkdu8avuYIvEzA/i6HmJpldjcKKraF+0u2X5cjVzMy3HiZIKRM2QwGg== X-Received: by 2002:a17:902:7487:b029:d6:c03b:bce4 with SMTP id h7-20020a1709027487b02900d6c03bbce4mr12440956pll.36.1604920698197; Mon, 09 Nov 2020 03:18:18 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:17 -0800 (PST) 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: [PATCH v4 15/19] lpfc: vmid: Appends the vmid in the wqe before sending request Date: Mon, 9 Nov 2020 09:54:01 +0530 Message-Id: <1604895845-2587-16-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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 Reviewed-by: Hannes Reinecke --- 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 51b99b7beaf9..53dbd6a3f460 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -3724,7 +3724,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 " @@ -9625,6 +9625,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, @@ -9756,6 +9758,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 the switch */ + 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 */ @@ -9820,6 +9840,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 the switch */ + 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 */ @@ -9877,6 +9914,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 the switch */ + 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 Mon Nov 9 04:24:02 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: 11891179 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 9F071C388F7 for ; Mon, 9 Nov 2020 11:18:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E0FB20679 for ; Mon, 9 Nov 2020 11:18:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="R0ot7CIB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728927AbgKILSX (ORCPT ); Mon, 9 Nov 2020 06:18:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729523AbgKILSW (ORCPT ); Mon, 9 Nov 2020 06:18:22 -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 74E74C0613CF for ; Mon, 9 Nov 2020 03:18:22 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id 10so7861535pfp.5 for ; Mon, 09 Nov 2020 03:18:22 -0800 (PST) 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=LYaWr8LhEektKhvGwZ9bn5WkJ9ZBhZZJN3RRjAfX8jo=; b=R0ot7CIB2ac8936kWre1OaWOGId+mN5UI2pw9KHX5LQ7wJEC6EAQUya0ase1C5kPwk Mc8kzbyAzeXGbEBcsk2BThyBNdoQMQWUaGdGCcMmGGmvlFWbTWKVpnfugTrYtMNF89w7 5Q/8zO4oHdPiFhcdoa0LAXYkEGm6/dQeeP5EI= 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=LYaWr8LhEektKhvGwZ9bn5WkJ9ZBhZZJN3RRjAfX8jo=; b=jUl3/lK87+yMS9irTPctwzW8W3OzQF/eSgcLxA7uigRaiqtF76ijVpWGjYmh7URxwV tydcWzwUIJXGCbgilzZlLDGrt93/Nxt9IjE171uI2YXtCvVvuoOm8w4JMedyHCSpFWHi kkrLfyM7d9yDj7PmrUNi0N122Q1pLX++W+QmbRMS4KdnauvrTCx6IEufyNu5MlzbBPuY 1qUE4rdpVJbwAyDq6LmcafddU7SDq39MATVjVFt9jUtxAYy+4a7pDGGOkH+yBC0lIMGe ov602JhJmNG738J26tSFurhHherPRdi7n2S+hzDi/2xLsrQjVV3Gf1Fxr57fgzKnxP05 B61A== X-Gm-Message-State: AOAM531aDX+0qk853Ly2sWjcoPL7LSj+FbbNLpJhV2mTcf0u2Ym74mrz XLxftfrvsFfgo58bFHNY9H31RKEf9/Xwtx6ZX8ekmGCuRit37sW6yyZHLqsKUhFIpJnwqgE7JuM Z6hqMJZsw5jxZyBotl8rkZFJI7HtcP40k/x4Rks+ToclX1OydVfXm+q7+cw/vDnX/+40/K5zCLL rdl63gJ/0+qbiK X-Google-Smtp-Source: ABdhPJyOuOfyY+Cs9FFye2mZs9WyAP2haQMBFmltSluUNnZB0/GSdSUKyr/E3xqyHXrZreHKMGuG/Q== X-Received: by 2002:a17:90a:e2d6:: with SMTP id fr22mr12411781pjb.165.1604920701496; Mon, 09 Nov 2020 03:18:21 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:20 -0800 (PST) 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: [PATCH v4 16/19] lpfc: vmid: Timeout implementation for vmid Date: Mon, 9 Nov 2020 09:54:02 +0530 Message-Id: <1604895845-2587-17-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 implements the timeout functionality for the vmid. After the set time period of inactivity, the vmid is deregistered from the switch. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- v4: No change v3: No change v2: Ported the patch on top of 5.10/scsi-queue --- drivers/scsi/lpfc/lpfc_hbadisc.c | 109 +++++++++++++++++++++++++++++++ drivers/scsi/lpfc/lpfc_init.c | 40 ++++++++++++ 2 files changed, 149 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 142a02114479..b20013866942 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -190,6 +190,115 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) return; } +/** + * lpfc_check_inactive_vmid_one - VMID inactivity checker for a vport + * @vport: Pointer to vport context object. + * + * This function checks for idle vmid entries related to a particular vport. If + * found unused/idle, it frees them accordingly. + **/ +static void lpfc_check_inactive_vmid_one(struct lpfc_vport *vport) +{ + u16 i, keep; + u32 difftime = 0, r; + u64 *lta; + int cpu; + + write_lock(&vport->vmid_lock); + + if (!vport->cur_vmid_cnt) + goto out; + + /* iterate through the table */ + for (i = 0; i < LPFC_VMID_HASH_SIZE; ++i) { + if (vport->hash_table[i] && (vport->hash_table[i]->flag & + LPFC_VMID_REGISTERED)) { + /* check if the particular vmid is in use */ + /* for all available per cpu variable */ + for_each_possible_cpu(cpu) { + /* if last access time is less than timeout */ + lta = per_cpu_ptr( + vport->hash_table[i]->last_io_time, + cpu); + if (!lta) + continue; + difftime = (jiffies) - (*lta); + if ((vport->vmid_inactivity_timeout * + JIFFIES_PER_HR) > difftime) { + keep = 1; + break; + } + } + + /* if none of the cpus have been used by the vm, */ + /* remove the entry if already registered */ + if (!keep) { + /* mark the entry for deregistration */ + vport->hash_table[i]->flag = + LPFC_VMID_DE_REGISTER; + write_unlock(&vport->vmid_lock); + if (vport->vmid_priority_tagging) + r = lpfc_vmid_uvem(vport, + vport->hash_table[i], + false); + else + r = lpfc_vmid_cmd(vport, + SLI_CTAS_DAPP_IDENT, + vport->hash_table[i]); + + /* decrement number of active vms and mark */ + /* entry in slot as free */ + write_lock(&vport->vmid_lock); + if (!r) { + struct lpfc_vmid *ht = + vport->hash_table[i]; + vport->cur_vmid_cnt--; + ht->flag = LPFC_VMID_SLOT_FREE; + free_percpu(ht->last_io_time); + ht->last_io_time = NULL; + vport->hash_table[i] = NULL; + } + } + } + keep = 0; + } + out: + write_unlock(&vport->vmid_lock); +} + +/** + * lpfc_check_inactive_vmid - VMID inactivity checker + * @phba: Pointer to hba context object. + * + * This function is called from the worker thread to determine if an entry in + * the vmid table can be released since there was no IO activity seen from that + * particular VM for the specified time. When this happens, the entry in the + * table is released and also the resources on the switch cleared. + **/ + +void lpfc_check_inactive_vmid(struct lpfc_hba *phba) +{ + struct lpfc_vport *vport; + struct lpfc_vport **vports; + int i; + + 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; + + lpfc_check_inactive_vmid_one(vport); + } + lpfc_destroy_vport_work_array(phba, vports); +} + /** * lpfc_dev_loss_tmo_handler - Remote node devloss timeout handler * @ndlp: Pointer to remote node object. diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 88777875f4b8..7e93049fba21 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -4829,6 +4829,42 @@ lpfc_sli4_fcf_redisc_wait_tmo(struct timer_list *t) lpfc_worker_wake_up(phba); } +/** + * lpfc_vmid_poll - VMID timeout detection + * @ptr: Map to lpfc_hba data structure pointer. + * + * This routine is invoked when there is no IO on by a VM for the specified + * amount of time. When this situation is detected, the VMID has to be + * deregistered from the switch and all the local resources freed. The VMID + * will be reassigned to the VM once the IO begins. + **/ +static void +lpfc_vmid_poll(struct timer_list *t) +{ + struct lpfc_hba *phba = from_timer(phba, t, inactive_vmid_poll); + u32 wake_up = 0; + + /* check if there is a need to issue QFPA */ + if (phba->pport->vmid_priority_tagging) { + wake_up = 1; + phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; + } + + /* Is the vmid inactivity timer enabled */ + if (phba->pport->vmid_inactivity_timeout || + phba->pport->load_flag & FC_DEREGISTER_ALL_APP_ID) { + wake_up = 1; + phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; + } + + if (wake_up) + lpfc_worker_wake_up(phba); + + /* restart the timer for the next iteration */ + mod_timer(&phba->inactive_vmid_poll, jiffies + msecs_to_jiffies(1000 * + LPFC_VMID_TIMER)); +} + /** * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code * @phba: pointer to lpfc hba data structure. @@ -6679,6 +6715,10 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; + /* for VMID idle timeout if VMID is enabled */ + if (lpfc_is_vmid_enabled(phba)) + timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); + /* * Initialize the SLI Layer to run with lpfc SLI4 HBAs. */ From patchwork Mon Nov 9 04:24:03 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: 11891197 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 EEA66C388F7 for ; Mon, 9 Nov 2020 11:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DD722068D for ; Mon, 9 Nov 2020 11:18:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="M1s6aPj0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729510AbgKILSZ (ORCPT ); Mon, 9 Nov 2020 06:18:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729522AbgKILSZ (ORCPT ); Mon, 9 Nov 2020 06:18:25 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A88AC0613CF for ; Mon, 9 Nov 2020 03:18:25 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id f18so2397634pgi.8 for ; Mon, 09 Nov 2020 03:18:25 -0800 (PST) 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=XS4QIie/lbjvi6RKg0aRinJmfP+1QJ9lliARaIVUx+g=; b=M1s6aPj0Z9IntskviPPC1TVRQW2XSJ2LqKsa4wQBq5RsbOol4U4C920CtpN69FIfgM HGXw/RPJWvgDDcZyirgPLUDza8CLy0JKLalK9GpBzmKqd61GNrWl8t6nxVFlOku8q+jA HWbJNlt05rcohVmShLjyR6w+fQYxoZRG8k3nY= 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=XS4QIie/lbjvi6RKg0aRinJmfP+1QJ9lliARaIVUx+g=; b=szM1Et85DpGiTOyk+X7mSLME5H33OO1UC8xmLGYtbni5+LmKqzlUszZKmMB95xR34M jdU+iYPHnpBj4bHXn5za62iHEMwpENQaU0pNDE7RMKu+q/1FjFFYYYd1N4CO+6fZnHJ0 A5DXHkZjoDGMgCZPnoJXLZAMup9kPamXnGPx2QT9RfFoNtZ3z3WS0y8JDg+UBVYk7yBR ck+yEDW2ggoAR53gCh9sjgDQYuq9yOCQGv4nwHsGxYUgsTnO9xGD4PKJ7rp77TXH+j5a d5fX76tDQA1r0zS0ozTSapDyaDsjy5C1J0fauIUMO+aDUsXwOFR3zAljPJEq2bs8fACs gIMw== X-Gm-Message-State: AOAM530tUvNa0cSN2Y+Y1ixpgKYtJmu1cFz1vyjOMBHrJ1K7XXWSA2Tp jSMhBPmFu7JNY+V9xGpD1SQLmowGPChQ+O+ZnNsyBQqn8do/fPZeNiqHzLdtepNqyFcqDZwiuo3 55PkJiyOORye8XhaA3zrK5J/jIgfhzZFuCMTfx4J5X5rddeNMz4jBjTuhzt2VzzU+wmsrk8kPhM EF8xtIQicJ4Y17 X-Google-Smtp-Source: ABdhPJxObZG9gPREZNxM5/sJNJSyL5S2bdb/IoXyJz+lYQrzm7umUcJwpf6MElVWC9M39gdCP5yRYA== X-Received: by 2002:a17:90a:4dc8:: with SMTP id r8mr12178865pjl.1.1604920704756; Mon, 09 Nov 2020 03:18:24 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:24 -0800 (PST) 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: [PATCH v4 17/19] lpfc: vmid: Adding qfpa and vmid timeout check in worker thread Date: Mon, 9 Nov 2020 09:54:03 +0530 Message-Id: <1604895845-2587-18-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-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 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 Reviewed-by: Hannes Reinecke --- 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 b20013866942..38df3c4341f9 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -433,6 +433,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. @@ -744,6 +770,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) From patchwork Mon Nov 9 04:24:04 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: 11891193 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 9561DC2D0A3 for ; Mon, 9 Nov 2020 11:18:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C2DB2068D for ; Mon, 9 Nov 2020 11:18:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="T8QfH7OZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729508AbgKILS3 (ORCPT ); Mon, 9 Nov 2020 06:18:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729522AbgKILS3 (ORCPT ); Mon, 9 Nov 2020 06:18:29 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00D98C0613CF for ; Mon, 9 Nov 2020 03:18:29 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id t6so4569391plq.11 for ; Mon, 09 Nov 2020 03:18:28 -0800 (PST) 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=KNBzIBJwSYOro1GB6bvI5fywYNqqH9oYFy2VllC95hQ=; b=T8QfH7OZghGkDt438qFu14r+R9yGdPgIBAAJCCobAOfGte4oaFH51To0aGAM36iVSU KSSGtdWl9JE9hKU9Ipd0gnzV8SjIDFjj8Fhxh/eX6aoyaKXZQjsBQ8s0quqSl9FD9zwg fHUVjMzeZykbFI8hrpJOB3aA76DswQikczzoE= 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=KNBzIBJwSYOro1GB6bvI5fywYNqqH9oYFy2VllC95hQ=; b=sHP5h3NdL2v1kmVDwn0+0rIBKgIf3zXplhXu49AnqLABiV/FhWanWtqyqv8lXpQh57 e3uXUt5JnTKn3WNRZjPt2OGarbKDGGrX3tQqSfgVkL8jdVtE05wLY0PWr5JyBi4Nl/yF W1kjUtuQJ/4Lk8eRJL44VaAlPnMp7ig5KcmcX/SIWmzdB41WsX3Ml2ObxrnzkVPXTHfz CFtEGaNHhA1GNHsWz4QbSFbmgV7xPRT0kSluGicOh8DKRT5YysqMhmIqIkJLJn7N5lqg FBm8oHR8M6o3bNnIi0IsYaDAlc2IssNSb7fXS3oL2hwgqvf7GFqqa1ZByldbjKDx4ZaI tm2g== X-Gm-Message-State: AOAM533AUfGJuTcGTE5YFGGVicsDxFiF1shblMF3SHvPnQzxcms2RJoa sQBmOO9OMEPW+Mbrw+e0bvYGdbqhM7wySYgRD5ME0OBZHlwd+5rT03P3LunJjXFLKvB4rXV068l S8MW4c4NusBv/sNWayFVnBEkCDCG3jLPGb4T5rAvTXpcnnAZnSb0XfkcWwACwDab0gPc60z+z/8 bCFcC0C+Nno3wh X-Google-Smtp-Source: ABdhPJzm+it/alUjH5Fc0fXiiQbC41nfSbfvOb+3HHgEyKVydf+W7Yco7+p1/Sqq1QQjohwL5lUw7Q== X-Received: by 2002:a17:902:760c:b029:d6:efa5:4cdd with SMTP id k12-20020a170902760cb02900d6efa54cddmr11991843pll.56.1604920708029; Mon, 09 Nov 2020 03:18:28 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:27 -0800 (PST) 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: [PATCH v4 18/19] lpfc: vmid: Introducing vmid in io path. Date: Mon, 9 Nov 2020 09:54:04 +0530 Message-Id: <1604895845-2587-19-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gaurav Srivastava The patch introduces the vmid in the io path. It checks if the vmid is enabled and if io belongs to a vm or not and acts accordingly. Other supporing APIs are also included in the patch. Signed-off-by: Gaurav Srivastava Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- v4: No change v3: Replaced blkcg_get_app_identifier with blkcg_get_fc_appid v2: Ported the patch on top of 5.10/scsi-queue Added a fix for issuing QFPA command which was not included in the last submit --- drivers/scsi/lpfc/lpfc_scsi.c | 165 ++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index e5a1056cc575..7533438fef07 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -4624,6 +4624,151 @@ void lpfc_vmid_assign_cs_ctl(struct lpfc_vport *vport, struct lpfc_vmid *vmid) } } +/* + * lpfc_vmid_get_appid- get the vmid associated with the uuid + * @vport: The virtual port for which this call is being executed. + * @uuid: uuid associated with the VE + * @cmd: address of scsi cmmd descriptor + * @tag: VMID tag + * Returns status of the function + */ +static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct + scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag) +{ + struct lpfc_vmid *vmp = NULL; + int hash, len, rc = 1, i; + u8 pending = 0; + + /* check if QFPA is complete */ + if (lpfc_vmid_is_type_priority_tag(vport) && !(vport->vmid_flag & + LPFC_VMID_QFPA_CMPL)) { + vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; + return 1; + } + + /* search if the uuid has already been mapped to the vmid */ + len = strlen(uuid); + hash = lpfc_vmid_hash_fn(uuid, len); + + /* search for the VMID in the table */ + read_lock(&vport->vmid_lock); + vmp = lpfc_get_vmid_from_hastable(vport, hash, uuid); + read_unlock(&vport->vmid_lock); + + /* if found, check if its already registered */ + if (vmp && vmp->flag & LPFC_VMID_REGISTERED) { + lpfc_vmid_update_entry(vport, cmd, vmp, tag); + rc = 0; + } else if (vmp && (vmp->flag & LPFC_VMID_REQ_REGISTER || + vmp->flag & LPFC_VMID_DE_REGISTER)) { + /* else if register or dereg request has already been sent */ + /* Hence vmid tag will not be added for this IO */ + rc = 1; + } else { + /* else, start the process to obtain one as per the */ + /* switch connected */ + write_lock(&vport->vmid_lock); + vmp = lpfc_get_vmid_from_hastable(vport, hash, uuid); + + /* while the read lock was released, in case the entry was */ + /* added by other context or is in process of being added */ + if (vmp && vmp->flag & LPFC_VMID_REGISTERED) { + lpfc_vmid_update_entry(vport, cmd, vmp, tag); + write_unlock(&vport->vmid_lock); + return 0; + } else if (vmp && vmp->flag & LPFC_VMID_REQ_REGISTER) { + write_unlock(&vport->vmid_lock); + return 1; + } + + /* else search and allocate a free slot in the hash table */ + if (vport->cur_vmid_cnt < vport->max_vmid) { + for (i = 0; i < vport->max_vmid; ++i) { + vmp = vport->vmid + i; + if (vmp->flag == LPFC_VMID_SLOT_FREE) { + vmp = vport->vmid + i; + break; + } + } + } else { + write_unlock(&vport->vmid_lock); + return 1; + } + + if (vmp && (vmp->flag == LPFC_VMID_SLOT_FREE)) { + vmp->vmid_len = len; + + /* Add the vmid and register */ + memcpy(vmp->host_vmid, uuid, vmp->vmid_len); + vmp->io_rd_cnt = 0; + vmp->io_wr_cnt = 0; + vmp->flag = LPFC_VMID_SLOT_USED; + lpfc_put_vmid_in_hashtable(vport, hash, vmp); + + vmp->delete_inactive = + vport->vmid_inactivity_timeout ? 1 : 0; + + /* if type priority tag, get next available vmid */ + if (lpfc_vmid_is_type_priority_tag(vport)) + lpfc_vmid_assign_cs_ctl(vport, vmp); + + /* allocate the per cpu variable for holding */ + /* the last access time stamp only if vmid is enabled */ + if (!vmp->last_io_time) + vmp->last_io_time = + __alloc_percpu(sizeof(u64), + __alignof__(struct + lpfc_vmid)); + + /* registration pending */ + pending = 1; + rc = 1; + } + write_unlock(&vport->vmid_lock); + + /* complete transaction with switch */ + if (pending) { + if (lpfc_vmid_is_type_priority_tag(vport)) + rc = lpfc_vmid_uvem(vport, vmp, true); + else + rc = lpfc_vmid_cmd(vport, + SLI_CTAS_RAPP_IDENT, + vmp); + if (!rc) { + write_lock(&vport->vmid_lock); + vport->cur_vmid_cnt++; + vmp->flag |= LPFC_VMID_REQ_REGISTER; + write_unlock(&vport->vmid_lock); + } + } + + /* finally, enable the idle timer once */ + if (!(vport->phba->pport->vmid_flag & LPFC_VMID_TIMER_ENBLD)) { + mod_timer(&vport->phba->inactive_vmid_poll, + jiffies + + msecs_to_jiffies(1000 * LPFC_VMID_TIMER)); + vport->phba->pport->vmid_flag |= LPFC_VMID_TIMER_ENBLD; + } + } + return rc; +} + +/* + * lpfc_is_command_vm_io - get the uuid from blk cgroup + * @cmd:Pointer to scsi_cmnd data structure + * Returns uuid if present if not null + */ +static char *lpfc_is_command_vm_io(struct scsi_cmnd *cmd) +{ + char *uuid = NULL; + + if (cmd->request) { + if (cmd->request->bio) + uuid = blkcg_get_fc_appid(cmd->request->bio); + } + return uuid; +} + /** * lpfc_queuecommand - scsi_host_template queuecommand entry point * @cmnd: Pointer to scsi_cmnd data structure. @@ -4649,6 +4794,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) int err, idx; #ifdef CONFIG_SCSI_LPFC_DEBUG_FS uint64_t start = 0L; + u8 *uuid = NULL; if (phba->ktime_on) start = ktime_get_ns(); @@ -4772,6 +4918,25 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp); + /* check the necessary and sufficient condition to support VMID */ + if (lpfc_is_vmid_enabled(phba) && + (ndlp->vmid_support || + phba->pport->vmid_priority_tagging == + LPFC_VMID_PRIO_TAG_ALL_TARGETS)) { + /* is the IO generated by a VM, get the associated virtual */ + /* entity id */ + uuid = lpfc_is_command_vm_io(cmnd); + + if (uuid) { + err = lpfc_vmid_get_appid(vport, uuid, cmnd, + (union lpfc_vmid_io_tag *) + &lpfc_cmd->cur_iocbq.vmid_tag); + if (!err) + lpfc_cmd->cur_iocbq.iocb_flag |= LPFC_IO_VMID; + } + } + + atomic_inc(&ndlp->cmd_pending); #ifdef CONFIG_SCSI_LPFC_DEBUG_FS if (unlikely(phba->hdwqstat_on & LPFC_CHECK_SCSI_IO)) this_cpu_inc(phba->sli4_hba.c_stat->xmt_io); From patchwork Mon Nov 9 04:24: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: 11891195 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 13CF1C388F7 for ; Mon, 9 Nov 2020 11:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B00262068D for ; Mon, 9 Nov 2020 11:18:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="UcvIsJgY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729541AbgKILSc (ORCPT ); Mon, 9 Nov 2020 06:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729522AbgKILSc (ORCPT ); Mon, 9 Nov 2020 06:18:32 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31703C0613CF for ; Mon, 9 Nov 2020 03:18:32 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id x13so7837022pfa.9 for ; Mon, 09 Nov 2020 03:18:32 -0800 (PST) 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=QCyc1hG7x1Zyuw/Wh8SYVW/ea14/m5+2KtbWtVuYAAI=; b=UcvIsJgYW45lgnme8fLsnftGhDdm/dwnYroCvbsuPstyMonEAg2ycxRCUzdbPb39DZ Fh0WQjbYc+d+rC0YeV+NYh0pad4A3P8ALQ49U0HolbD/wBn6EN4nh+p7yqd1qOUGHUOC e0pe7uoKaL2yxQJ07SKdF5mk/KnPj+GSCKePU= 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=QCyc1hG7x1Zyuw/Wh8SYVW/ea14/m5+2KtbWtVuYAAI=; b=XOl3fTpiLhCZFRzhLU9hklOixS2Ef+seS0L6GgeHiy3PFJDuwXRsaEM92CorIobERa fvsVBXTN9j6ibXjYttvGJTQigsO+7mc0T6ShSefBf2XQGPd9Y0CcsxD81o0QxlewX6BJ pzQzkF5GfFnrXPf3MVQslznK1zSoLV2CZS9XcYiET3aYHcI+CFbJkIGWQ00h1gw09HSU u1p+wGB4D+LhUU83dlmjnv/JZak+peA5EMgtv4lAAZdG+3P8P4w5yk8f/02V8/oGX+n1 ryiyRx3tHbM32VkTMmLEOc1/RfhcrQwC9wPwbI7mjJCdh0wrSgMKVvj/1skGNVPYO1sH 0nEA== X-Gm-Message-State: AOAM533cqX7h+iA8stMY2dZ9M+BK0Tv2L280EUDsi2gY/X6rQfLpa/9i LCXzKYdwO8vUx0JOddpu5GK2AFwNbnB/KihTs6x3mxHrstbyEGBoMPoXs5TdZcpUQ7JOba7qjKy 7RbN9/AsGKGGL7WPe/4mIG46jU/Y+EZFB3Ukxm+6kH5tuQnKKKpnBcmHBFr301Ey045PC7BTi56 JcqIKtXpJdo/cl X-Google-Smtp-Source: ABdhPJxxlMbUEEiP1Z5MxrCkEJQjfoTlMAqn72vRIaFHinTYAGJ7m/alyt6pq+qYPfciDXBfpBMUCQ== X-Received: by 2002:a62:7e14:0:b029:18a:d515:dc47 with SMTP id z20-20020a627e140000b029018ad515dc47mr13786924pfc.78.1604920711302; Mon, 09 Nov 2020 03:18:31 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k9sm10889364pfp.68.2020.11.09.03.18.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 03:18:30 -0800 (PST) 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, Muneendra Subject: [PATCH v4 19/19] scsi: Made changes in Kconfig to select BLK_CGROUP_FC_APPID Date: Mon, 9 Nov 2020 09:54:05 +0530 Message-Id: <1604895845-2587-20-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604895845-2587-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Added a new config FC_APPID to select BLK_CGROUP_FC_APPID which Enable support to track FC io Traffic. Signed-off-by: Muneendra Reported-by: kernel test robot Reviewed-by: Hannes Reinecke --- v4: Addressed the error reported by kernel test robot v3: New patch --- drivers/scsi/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 701b61ec76ee..1c73c60e398f 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -235,6 +235,19 @@ config SCSI_FC_ATTRS each attached FiberChannel device to sysfs, say Y. Otherwise, say N. +config FC_APPID + bool "Enable support to track FC io Traffic" + depends on BLOCK && BLK_CGROUP + depends on SCSI + select BLK_CGROUP_FC_APPID + default y + help + If you say Y here, it enables the support to track + FC IO traffic over fabric.It enables the Fabric and the + storage targets to identify, monitor, and handle FC traffic + based on vm tags by inserting application specific + identification into the FC frame + config SCSI_ISCSI_ATTRS tristate "iSCSI Transport Attributes" depends on SCSI && NET