From patchwork Tue Jun 21 21:53:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1646237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=j4J8eGaW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LSKz20MNNz9sGD for ; Wed, 22 Jun 2022 07:53:49 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1o3lob-00007c-Kj; Tue, 21 Jun 2022 21:53:41 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1o3loZ-00007E-BV for kernel-team@lists.ubuntu.com; Tue, 21 Jun 2022 21:53:39 +0000 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id EDFA13F194 for ; Tue, 21 Jun 2022 21:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1655848418; bh=KHNfRcAwGN27h373HfvvlJRgJRr+T1vpdAeoLAqso0U=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j4J8eGaWi52TvEtSeRW7ygD+kY9ldKIrxis+QsirMFsfABoB0dtHBaoz+Sr+P6DJM ZPE2b25SaSC0BmZMmEP6lo2pTa9BGxbRY/xGZDA3SjRBvelecPPIFCwMdpP2W0b79k c1IiunJ4wO4eyoIxu9o2LKDO/d0R07HxWbrKY0hLMhqAs/4mJGOM5oDWJ+SgMEbmXG qjHhuHtKhKgALeoH3w/FvYcnzmS4pVn0h9d+bihg4o8f1EXC+vOj5lf6z4xPCfX/VS JGNueZUG/x4KQhB/P8r2/Y6dSbJCgm4jpNzXZwmc+MOX4WuM+gmKnR5v8MfhdHCGe6 7keCyctKoDnEQ== Received: by mail-oi1-f199.google.com with SMTP id q126-20020aca5c84000000b0032ebb50e698so8395652oib.11 for ; Tue, 21 Jun 2022 14:53:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KHNfRcAwGN27h373HfvvlJRgJRr+T1vpdAeoLAqso0U=; b=GDM/I+yEbpVGiUbvyj+IA7hwhjX1Bm/9XEm5aJxL+/7gWKhF6KA12sqN1lEU6LGMuK ln75YtJdCm64zvMEFc3kfhPll/Pzo7cnbRp+B/W72jwgHlN3h0wZoObSm2qjGY+mlhGo YdySVsL8EvNa0iRseKlj3S+YyfbFxRFE7ZWUDmliBgye1wXVBHHWcJjjBDvqzxCkiDrf HWRfqP7056ZeOFwZc8z8j08Ufz3PHkVR8kQvc00X263i1+npVab2lsfgnaK+pASX43m0 JUc+JUlmW2XjaRzTSjwZ4oVv5nTYpO86U4fUeWuLe13+WBgzDHjlOK+MnBLMqw/YmfDR 0TGA== X-Gm-Message-State: AJIora/GhN2Dttizb42DW+SdDfg+NcpqNyPBk3MZ/Va+ykKrt8EOZoF4 QbFfHIUDTs7NmxZUZdGm/YkNS+NyXa/8qq4rMFWaLmQObK3VwpfgaYLuKt9sV++R1drXwTfrPJi HqP9rP39weeMLngBqni/NRqz9dPNriL8H8iNJPkBayQ== X-Received: by 2002:a05:6870:f2a0:b0:fe:29a0:4b48 with SMTP id u32-20020a056870f2a000b000fe29a04b48mr114215oap.183.1655848417543; Tue, 21 Jun 2022 14:53:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vboFuXYGnA/moKDJX7AewdhQKq86thjAbducq2XxvXRicm21Mi8Zt50GD8O5YXrpyAc4tr1Q== X-Received: by 2002:a05:6870:f2a0:b0:fe:29a0:4b48 with SMTP id u32-20020a056870f2a000b000fe29a04b48mr114195oap.183.1655848417073; Tue, 21 Jun 2022 14:53:37 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:1e02:1914:1444:eac5]) by smtp.gmail.com with ESMTPSA id bd31-20020a056808221f00b0032e7bd6557fsm9921769oib.50.2022.06.21.14.53.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 14:53:36 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/3] nvme: add CNTRLTYPE definitions for 'identify controller' Date: Tue, 21 Jun 2022 16:53:30 -0500 Message-Id: <20220621215332.23492-2-michael.reed@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621215332.23492-1-michael.reed@canonical.com> References: <20220621215332.23492-1-michael.reed@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hannes Reinecke Update the 'identify controller' structure to define the newly added CNTRLTYPE field. BugLink: https://bugs.launchpad.net/bugs/1948626 Signed-off-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani Signed-off-by: Christoph Hellwig (cherry picked from commit e15a8a9755659ff5972f30de4dd64867c97f242d linux-next) Signed-off-by: Michael Reed --- include/linux/nvme.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/nvme.h b/include/linux/nvme.h index b7c4c4130b65..ed2428918bca 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -31,6 +31,12 @@ enum nvme_subsys_type { NVME_NQN_NVME = 2, /* NVME type target subsystem */ }; +enum nvme_ctrl_type { + NVME_CTRL_IO = 1, /* I/O controller */ + NVME_CTRL_DISC = 2, /* Discovery controller */ + NVME_CTRL_ADMIN = 3, /* Administrative controller */ +}; + /* Address Family codes for Discovery Log Page entry ADRFAM field */ enum { NVMF_ADDR_FAMILY_PCI = 0, /* PCIe */ @@ -244,7 +250,9 @@ struct nvme_id_ctrl { __le32 rtd3e; __le32 oaes; __le32 ctratt; - __u8 rsvd100[28]; + __u8 rsvd100[11]; + __u8 cntrltype; + __u8 fguid[16]; __le16 crdt1; __le16 crdt2; __le16 crdt3; From patchwork Tue Jun 21 21:53:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1646240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=R7I1xgLo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LSKz35v5vz9sFw for ; Wed, 22 Jun 2022 07:53:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1o3log-0000AI-1i; Tue, 21 Jun 2022 21:53:46 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1o3lod-00007Z-3d for kernel-team@lists.ubuntu.com; Tue, 21 Jun 2022 21:53:43 +0000 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4EA6E3F1FF for ; Tue, 21 Jun 2022 21:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1655848420; bh=jqY4ZfaCJPOAvAOiboHFj0rjgb2j43u5liVgGxDeuPA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R7I1xgLoY1WtteHZ1WOkwasN4Wy12H7Uu9dj9w+AoFi2exw4/hlBV4WogmqHoa81R VLVJgHZ+GR6RNSo4fQ4a7zHRyzzOJetwkm8IsNEJd4wpA7H6GIc2awAgflS76RR3YN 31djSjl+BBCUZaQIn99EH1EjZYvS4Xp4YgVF+Dkk9IdbQOQs3Q+PLq1IItH31fLGNv u1Oz9xfqcF2qzg47k50y53yks2ahvRZv2y5Z6O02cU4K/d1WX4ROiDLHziNKgDKDXI H2+C04elB0aXjy7obhFUr4F2gwpFjGIjwKIYaSzlR/CZ5xV/1j3h0eydRkRxacSpia zkJOd0uB2CXOQ== Received: by mail-oi1-f200.google.com with SMTP id bf2-20020a056808190200b0032ea485bb7dso8378185oib.8 for ; Tue, 21 Jun 2022 14:53:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jqY4ZfaCJPOAvAOiboHFj0rjgb2j43u5liVgGxDeuPA=; b=33tGUFi5vm0CovS7NMCS6yWbfa5s86UUxPvhEHlQrini7MLO9R/YHYjpGxnaTZZrd1 i/FWFqbwpOPf85i/V6zAnoQEd/v6T7LcxBODKHmShYNgrkd9PAVFsvs2d845F2a+9Fum 4kmUqVkhUGDuwquNyUYOJQ523/aIO58B/hzS9uofCFEQYgMqHNx/DjkQnDEChH6nM38y geT4XavEWr/+TgMQYVBXVMMfVDcgaTK7c9TLUaJk/xXLb47kR0lYVDD5qHzM2wXQ508x WlWMvnlRBFC1VWWFqVW//o8zYhCu4fmGuS4lGsf7mZufD6/wkm7vBAc3nBYmJ9mtaaiR J2Vw== X-Gm-Message-State: AJIora/7jzqg95p+PlR9imnmkomWeWRfE4tZwxIj7orwPIrbDqG94W2e uZgk2FYD0/8hjYGuZaeS/FLvANKN6Rv8zqnar0j8kxRc1MkkzJ+y/46rqxOHhaMtPRstAnJ24dD LdfIhl04Oc5CbwocB0E3lVq5Ju9Bc+EkOErxKypN1lg== X-Received: by 2002:a9d:6314:0:b0:614:d56f:c7a with SMTP id q20-20020a9d6314000000b00614d56f0c7amr151612otk.281.1655848418885; Tue, 21 Jun 2022 14:53:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIfQd1GzqYcjSs/vXUaCPZWTFLu17hq4d19IhmORtiA2oYxZPsUVVCdrgvvJgF8mHJwmv/5Q== X-Received: by 2002:a9d:6314:0:b0:614:d56f:c7a with SMTP id q20-20020a9d6314000000b00614d56f0c7amr151601otk.281.1655848418485; Tue, 21 Jun 2022 14:53:38 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:1e02:1914:1444:eac5]) by smtp.gmail.com with ESMTPSA id i3-20020a9d53c3000000b0060c78975ef6sm9868879oth.7.2022.06.21.14.53.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 14:53:37 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3] nvme: send uevent on connection up Date: Tue, 21 Jun 2022 16:53:31 -0500 Message-Id: <20220621215332.23492-3-michael.reed@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621215332.23492-1-michael.reed@canonical.com> References: <20220621215332.23492-1-michael.reed@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Martin Belanger When connectivity with a controller is lost, the driver will keep trying to reconnect once every 10 sec. When connection is restored, user-space apps need to be informed so that they can take proper action. For example, TP8010 introduces the DIM PDU, which is used to register with a discovery controller (DC). The DIM PDU is sent from user-space. The DIM PDU must be sent every time a connection is established with a DC. Therefore, the kernel must tell user-space apps when connection is restored so that registration can happen. The uevent sent is a "change" uevent with environmental data set to: "NVME_EVENT=connected". BugLink: https://bugs.launchpad.net/bugs/1948626 Signed-off-by: Martin Belanger Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Reviewed-by: John Meneghini Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig (cherry picked from commit 20d64911e7580f7e29c0086d67860c18307377d7 linux-next) Signed-off-by: Michael Reed --- drivers/nvme/host/core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d5d5d035d677..e3ad1ddcbdea 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -4165,6 +4165,13 @@ static int nvme_class_uevent(struct device *dev, struct kobj_uevent_env *env) return ret; } +static void nvme_change_uevent(struct nvme_ctrl *ctrl, char *envdata) +{ + char *envp[2] = { envdata, NULL }; + + kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp); +} + static void nvme_aen_uevent(struct nvme_ctrl *ctrl) { char *envp[2] = { NULL, NULL }; @@ -4339,6 +4346,8 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl) nvme_queue_scan(ctrl); nvme_start_queues(ctrl); } + + nvme_change_uevent(ctrl, "NVME_EVENT=connected"); } EXPORT_SYMBOL_GPL(nvme_start_ctrl); From patchwork Tue Jun 21 21:53:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1646239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=cjTGo/gc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LSKz21Bjgz9sGJ for ; Wed, 22 Jun 2022 07:53:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1o3loe-000099-Qh; Tue, 21 Jun 2022 21:53:44 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1o3lob-00007s-UY for kernel-team@lists.ubuntu.com; Tue, 21 Jun 2022 21:53:41 +0000 Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id BC0193FBF5 for ; Tue, 21 Jun 2022 21:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1655848421; bh=MQcb+/1joyuvBAHCbRfI5+be9GwBKi/ydCLlgNk9zac=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cjTGo/gcrWlTOSiv7vtlNZeCVjjQbJHjd9KyWe37wCeV5DomcdMJzIvj/C0OWR/Pw ZSaImcec9deSSP9wtYJIXeokdgRnQ/2yVjHFgNq1X8b6eLi501JV/6wYNlSQkNc5EB h4zt+jqhCN6kVbl8d9QYkjMvt04ygBVb3p4+UnSexUO5+e5Re4wYwjsKbrq0pQf3gR EmoB3oOQI7EiCsUmrN0MiEf9YmZuUNP1DntvQtfFYUm75GLY5Sap+So13jFS5aqBb5 XKeYxtjYa5hMkTo5UR9s1pH0beT50lqzArYJRm7swK2liMfyIRa7DCJ6y4nYRHYh8W qMWjhXgFBHVtw== Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-101b3601c5dso7752368fac.19 for ; Tue, 21 Jun 2022 14:53:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MQcb+/1joyuvBAHCbRfI5+be9GwBKi/ydCLlgNk9zac=; b=kjs3TbQH/TlxqUBzIUJq3QktuP32ho6UppKX/IxEoOP9Yqk3vI+lLgG3ibLXcio1rH jIA7zfKjAJyuadsKiiGRAn1qa+UPcqHSS36mU4lmBUHDyevGe/AUWopsfDoffyOTFuBv CtFqA0k7T9otiFqMIHfhMG83emyiAXZSSJzOP73k4Anxx/Txvqxayqs3HdUmbj8G+sMY UIGQn6QjM5KBmv/teBCPkUuMa7zuRIiJXSI3uSatKMiDwmGQZMwVeP/n8b9/OmAPgZYt BtnVWh6XCvT/60JB4G9fAZ+U68ofn+yuHzmxrwahCKzVXxkbLh52G+NAvfdilm6xpyhW uNvg== X-Gm-Message-State: AJIora/sGtPtn88SVu8uHhm1qeeT95uoTVlBQTmrZL1vaOjki5QMV2/X fpzPdrtOiQaTvq0wt2XGRypWI5navPbqLUKV6zW617+cHIxfV3KHzy1N5XfWudI+P6CSpkooUff VX3SBJRpwkZiEVIW/RZy9E6owSciAQoWkKPqlPxuDzQ== X-Received: by 2002:a05:6808:1454:b0:32f:231b:a879 with SMTP id x20-20020a056808145400b0032f231ba879mr108237oiv.27.1655848420187; Tue, 21 Jun 2022 14:53:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1su/pWg5JIoZXWIla5DJPkgxZSkaeYnxX/R39gWNHNv4SYsYs2JpTv8PG1VdxaP6moZl8ENPA== X-Received: by 2002:a05:6808:1454:b0:32f:231b:a879 with SMTP id x20-20020a056808145400b0032f231ba879mr108219oiv.27.1655848419844; Tue, 21 Jun 2022 14:53:39 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:1e02:1914:1444:eac5]) by smtp.gmail.com with ESMTPSA id el40-20020a056870f6a800b000f32c6b6871sm10348822oab.10.2022.06.21.14.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 14:53:39 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/3] nvme: expose cntrltype and dctype through sysfs Date: Tue, 21 Jun 2022 16:53:32 -0500 Message-Id: <20220621215332.23492-4-michael.reed@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621215332.23492-1-michael.reed@canonical.com> References: <20220621215332.23492-1-michael.reed@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Martin Belanger TP8010 introduces the Discovery Controller Type attribute (dctype). The dctype is returned in the response to the Identify command. This patch exposes the dctype through the sysfs. Since the dctype depends on the Controller Type (cntrltype), another attribute of the Identify response, the patch also exposes the cntrltype as well. The dctype will only be displayed for discovery controllers. A note about the naming of this attribute: Although TP8010 calls this attribute the Discovery Controller Type, note that the dctype is now part of the response to the Identify command for all controller types. I/O, Discovery, and Admin controllers all share the same Identify response PDU structure. Non-discovery controllers as well as pre-TP8010 discovery controllers will continue to set this field to 0 (which has always been the default for reserved bytes). Per TP8010, the value 0 now means "Discovery controller type is not reported" instead of "Reserved". One could argue that this definition is correct even for non-discovery controllers, and by extension, exposing it in the sysfs for non-discovery controllers is appropriate. BugLink: https://bugs.launchpad.net/bugs/1948626 Signed-off-by: Martin Belanger Reviewed-by: Chaitanya Kulkarni Reviewed-by: John Meneghini Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig (cherry picked from commit 86c2457a8e8112f16af8fd10a3e1dd7a302c3c3e linux-next) Signed-off-by: Michael Reed --- drivers/nvme/host/core.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 3 +++ include/linux/nvme.h | 10 +++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e3ad1ddcbdea..ce8300890889 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2926,6 +2926,9 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl) ctrl->max_namespaces = le32_to_cpu(id->mnan); ctrl->ctratt = le32_to_cpu(id->ctratt); + ctrl->cntrltype = id->cntrltype; + ctrl->dctype = id->dctype; + if (id->rtd3e) { /* us -> s */ u32 transition_time = le32_to_cpu(id->rtd3e) / USEC_PER_SEC; @@ -3459,6 +3462,40 @@ static ssize_t nvme_ctrl_fast_io_fail_tmo_store(struct device *dev, static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); +static ssize_t cntrltype_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + static const char * const type[] = { + [NVME_CTRL_IO] = "io\n", + [NVME_CTRL_DISC] = "discovery\n", + [NVME_CTRL_ADMIN] = "admin\n", + }; + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + if (ctrl->cntrltype > NVME_CTRL_ADMIN || !type[ctrl->cntrltype]) + return sysfs_emit(buf, "reserved\n"); + + return sysfs_emit(buf, type[ctrl->cntrltype]); +} +static DEVICE_ATTR_RO(cntrltype); + +static ssize_t dctype_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + static const char * const type[] = { + [NVME_DCTYPE_NOT_REPORTED] = "none\n", + [NVME_DCTYPE_DDC] = "ddc\n", + [NVME_DCTYPE_CDC] = "cdc\n", + }; + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + if (ctrl->dctype > NVME_DCTYPE_CDC || !type[ctrl->dctype]) + return sysfs_emit(buf, "reserved\n"); + + return sysfs_emit(buf, type[ctrl->dctype]); +} +static DEVICE_ATTR_RO(dctype); + static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr, @@ -3480,6 +3517,8 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_reconnect_delay.attr, &dev_attr_fast_io_fail_tmo.attr, &dev_attr_kato.attr, + &dev_attr_cntrltype.attr, + &dev_attr_dctype.attr, NULL }; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index ed79a6c7e804..02233ca24570 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -348,6 +348,9 @@ struct nvme_ctrl { unsigned long discard_page_busy; struct nvme_fault_inject fault_inject; + + enum nvme_ctrl_type cntrltype; + enum nvme_dctype dctype; }; enum nvme_iopolicy { diff --git a/include/linux/nvme.h b/include/linux/nvme.h index ed2428918bca..03126ab80f06 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -37,6 +37,12 @@ enum nvme_ctrl_type { NVME_CTRL_ADMIN = 3, /* Administrative controller */ }; +enum nvme_dctype { + NVME_DCTYPE_NOT_REPORTED = 0, + NVME_DCTYPE_DDC = 1, /* Direct Discovery Controller */ + NVME_DCTYPE_CDC = 2, /* Central Discovery Controller */ +}; + /* Address Family codes for Discovery Log Page entry ADRFAM field */ enum { NVMF_ADDR_FAMILY_PCI = 0, /* PCIe */ @@ -314,7 +320,9 @@ struct nvme_id_ctrl { __le16 icdoff; __u8 ctrattr; __u8 msdbd; - __u8 rsvd1804[244]; + __u8 rsvd1804[2]; + __u8 dctype; + __u8 rsvd1807[241]; struct nvme_id_power_state psd[32]; __u8 vs[1024]; };