Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3921002yba; Sun, 12 May 2019 00:36:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+FsdSxlwjZjfB3FY3Cz5QpXKzoiRzQtwPj+I17M854Wzi3sYeO91f+OHIgJbvEiGnuhOy X-Received: by 2002:a17:902:bd91:: with SMTP id q17mr24078046pls.13.1557646587911; Sun, 12 May 2019 00:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557646587; cv=none; d=google.com; s=arc-20160816; b=scSPAFW5eK5EDxBBblyJH4LhuFJVdEhDwD+HdBgIojHjdVB2zpV+P5dW+Cf0YDYSfZ Jsd/5TyHiF6mM/DedQbMnEn8e2csySzkKlaZixhzoPxVFv2WKYT+T7hUsmJqSWV/71l3 +KUY47TjktZ+weo8CmgEVwGg8IcYJFAqIVKckClssZ/oV6oAnppW/rz/TRHVc7ierTR4 MTJ6DHGn+Z7t/7Olr/qmWKBuJRNGbYPlx+8HS09eSVZjFwgnDEJD89bnsQxFTeOZrBpe OAzB2UxeAD9oap1vI7gw1ubqXD3RbZ+xCiteHAgPtqucAigCooTkni7ThbjIwZyZg9VI VOFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LxI7s+V++JAUvOzarfFiJnaM3JwJCysE+CC40eBNLc8=; b=gAZoTc+iwdlwDU4rF7NADJDvKAQRwsDdXdzjRT2gHY9qnOl7C6qcctFEAn3w8lubw5 kMxNkQxT4YkQCo+bvOkniPx2EemSvWDw7ipKuWpaGXRYb9uhTk8JIMMdaM/sDT+NQLLI jEu7gYWuEJqAErSN0W21/41MyTFSkMzk1QBmtXBV82yKp4w2tFE5PQw3K32I6cFNZ6U7 N5CnAFSNnLtw2Thg9S+02PzexwfTmZiREvl5ocF/owDWrPQleJC4KEyAhHJhFj3fL0f0 qBKslcZc03RMwLSzLymbGTwxXXS6ciNx72MBB1+DTOOeqiGVQR8bbiUBQBVS72eVVQN3 kn9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lQE4Ueoi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i23si12887104pgb.102.2019.05.12.00.36.11; Sun, 12 May 2019 00:36:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lQE4Ueoi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbfELHex (ORCPT + 99 others); Sun, 12 May 2019 03:34:53 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43023 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbfELHeu (ORCPT ); Sun, 12 May 2019 03:34:50 -0400 Received: by mail-pf1-f194.google.com with SMTP id c6so5462141pfa.10 for ; Sun, 12 May 2019 00:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LxI7s+V++JAUvOzarfFiJnaM3JwJCysE+CC40eBNLc8=; b=lQE4UeoirsFtysm0qU3i7hjaUNULmUhDM8+GN4GaJCnSNFV/I4gcr7o8MONqDNUXs6 xdNgoVJFyO0QO7TYLgKlFJAMJ2w1p3WomIUuELCgaPoCdj+uBxECJqi1NQmAb2hZWedR GSeNV+SzqlQNEfzmc+aLsEK7WsVf4PJQgUd4IuYa8xI5Vml78AzcmkLcznD1byN3Oql8 Rn/UQgEVu0CXyMDsE8ifKKgrPSufRDTyhMVYx/MUmErijcWDOcjFUg0jXwvUs5/XW1Z4 sevIJXcJtDOcW8JYp1MgircTI2pBub7AW+a3jCtOj/vzR2E5O0wmxvLr3jzGay/qDH/j gk5Q== 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=LxI7s+V++JAUvOzarfFiJnaM3JwJCysE+CC40eBNLc8=; b=BRsvwjrT5xoCPmFkSK6r8gcq65yTTWivtm3Ws+c7AasU8IoZpGKgp+Z26oUgrVYtoj LWo4tB5V+Wl12xxKLJBOIGsOsOmz8+C+DN7rTUGKhGtibj2VlEXbRsDlRTVck4Iy1jpf Lhstj8HaQkWEecvGs2qpL3SAVCykPnVM/73MdnRdEg8Db09WyUdEz5BTZDqX1i+UhPZb nnsg68fdO5qAhwwYa++9C3ZHgvhDlUwqHFaEttWWy3kR4k6bYSyci15WPcxtMvRLmca4 69Drpi1BWcZYZzp0Jt2OD9vwcaiiniiOX+EM2jNYEr4CXxqFl7dJKEwE5NfMJK6K/pvu gCGw== X-Gm-Message-State: APjAAAXwxNXk0N3Av5EB6CEDiFd1MuUcZZ1vTCvJfcXoKtA2ra8WFy3N zpD9HMkI7WkwEGCrMvDd2cQpvw0sk/g= X-Received: by 2002:a63:e550:: with SMTP id z16mr24771296pgj.329.1557646489304; Sun, 12 May 2019 00:34:49 -0700 (PDT) Received: from localhost.localdomain ([123.213.206.190]) by smtp.gmail.com with ESMTPSA id e123sm5492242pgc.29.2019.05.12.00.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 00:34:48 -0700 (PDT) From: Minwoo Im To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Minwoo Im , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , James Smart Subject: [PATCH V3 3/5] nvme: Introduce nvme_is_fabrics to check fabrics cmd Date: Sun, 12 May 2019 16:34:11 +0900 Message-Id: <20190512073413.32050-4-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190512073413.32050-1-minwoo.im.dev@gmail.com> References: <20190512073413.32050-1-minwoo.im.dev@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduce a nvme_is_fabrics() inline function to check whether or not the given command structure is for fabrics. Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: James Smart Signed-off-by: Minwoo Im --- drivers/nvme/host/fabrics.c | 2 +- drivers/nvme/target/core.c | 2 +- drivers/nvme/target/fabrics-cmd.c | 2 +- drivers/nvme/target/fc.c | 2 +- include/linux/nvme.h | 7 ++++++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 592d1e61ef7e..931995f2dbc3 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -578,7 +578,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, switch (ctrl->state) { case NVME_CTRL_NEW: case NVME_CTRL_CONNECTING: - if (req->cmd->common.opcode == nvme_fabrics_command && + if (nvme_is_fabrics(req->cmd) && req->cmd->fabrics.fctype == nvme_fabrics_type_connect) return true; break; diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 7734a6acff85..da2ea97042af 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -871,7 +871,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, status = nvmet_parse_connect_cmd(req); else if (likely(req->sq->qid != 0)) status = nvmet_parse_io_cmd(req); - else if (req->cmd->common.opcode == nvme_fabrics_command) + else if (nvme_is_fabrics(req->cmd)) status = nvmet_parse_fabrics_cmd(req); else if (req->sq->ctrl->subsys->type == NVME_NQN_DISC) status = nvmet_parse_discovery_cmd(req); diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c index 3b9f79aba98f..d16b55ffe79f 100644 --- a/drivers/nvme/target/fabrics-cmd.c +++ b/drivers/nvme/target/fabrics-cmd.c @@ -268,7 +268,7 @@ u16 nvmet_parse_connect_cmd(struct nvmet_req *req) { struct nvme_command *cmd = req->cmd; - if (cmd->common.opcode != nvme_fabrics_command) { + if (!nvme_is_fabrics(cmd)) { pr_err("invalid command 0x%x on unconnected queue.\n", cmd->fabrics.opcode); req->error_loc = offsetof(struct nvme_common_command, opcode); diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 508661af0f50..a59c5a013a5c 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1806,7 +1806,7 @@ nvmet_fc_prep_fcp_rsp(struct nvmet_fc_tgtport *tgtport, */ rspcnt = atomic_inc_return(&fod->queue->zrspcnt); if (!(rspcnt % fod->queue->ersp_ratio) || - sqe->opcode == nvme_fabrics_command || + nvme_is_fabrics((struct nvme_command *) sqe) || xfr_length != fod->req.transfer_len || (le16_to_cpu(cqe->status) & 0xFFFE) || cqewd[0] || cqewd[1] || (sqe->flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND)) || diff --git a/include/linux/nvme.h b/include/linux/nvme.h index c40720cb59ac..ab5e9392b42d 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -1165,6 +1165,11 @@ struct nvme_command { }; }; +static inline bool nvme_is_fabrics(struct nvme_command *cmd) +{ + return cmd->common.opcode == nvme_fabrics_command; +} + struct nvme_error_slot { __le64 error_count; __le16 sqid; @@ -1186,7 +1191,7 @@ static inline bool nvme_is_write(struct nvme_command *cmd) * * Why can't we simply have a Fabrics In and Fabrics out command? */ - if (unlikely(cmd->common.opcode == nvme_fabrics_command)) + if (unlikely(nvme_is_fabrics(cmd))) return cmd->fabrics.fctype & 1; return cmd->common.opcode & 1; } -- 2.17.1