Received: by 10.223.185.116 with SMTP id b49csp2009467wrg; Thu, 15 Feb 2018 05:14:51 -0800 (PST) X-Google-Smtp-Source: AH8x226CZ1yQkNc61vQ+oe5n+niLf5H82SNobn5pfAeStIP+HTf5C9IEAzg9O05B7Y9kU5qWtXh/ X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2586329plb.278.1518700491634; Thu, 15 Feb 2018 05:14:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518700491; cv=none; d=google.com; s=arc-20160816; b=atTEHO2uD76fSbEOtCb1Z8L9y4mR8S7/FXiyzj/CStWg8ho9kfpHEBxpxBkEy52Ok0 pQIVmWwI9N66V38PIyAdOrPwR9hm3rScHqXrDs4cko4J+7KfI5dddzRPrpa7wQQYzbHt 7tNlxYJciAYGx1QG6n5aDN57nCNs4gYx6BD4Sc/P9PW+uDd7SuGByDjArWjnh8eO1Qdi UaOXRrDQpFj37vdbY70Mqi5kZs9JId8L5CezOQfcbQDqicXc1O8e/a6XR0p/W5ZlN/oI 8rPlcbEh4nJecxVbh0mB+65XYI84NxtwcG6xrOEtcLxKlYl8/TFF5cA6noUJan+f7XP4 0TNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Wc2OX2K470wjz0qVHFri47+oAIgKEcxinCp2/rSfIr8=; b=RuZj7q7ilSVKTliNudw3l7k1sm1OKjdwty+TE7pcATQoVvJ26UQgktDOeUpCnnSdhs RKnOHl/FKRDUfd908VY2gytT3BlyPIf4hj1udcXvBRNubVIbs9UvWgZGc1p3dW1EBces g4iEPbzKN6FaonqPy90QPfN2/678scNPpBIGJmhEzNhFHWjPUfoMqzgO6RR2teQQlVOH ven5pqawGJLQ0elpogHrOEBM2++CMpOXvhPyFg9IfQgtE1dj7ixFGiOhvXxikBNHKhPJ /aOr8Lzp7AGX4wvpQGZjNM6b/VHUTsWW28GLCxdb2Z3hYDExoHZM2HxW8hR7ggUjevd2 ByvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=BtOhKJ2V; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si9329645pgs.556.2018.02.15.05.14.33; Thu, 15 Feb 2018 05:14:51 -0800 (PST) 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=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=BtOhKJ2V; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032079AbeBONMY (ORCPT + 99 others); Thu, 15 Feb 2018 08:12:24 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:44528 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031273AbeBONMU (ORCPT ); Thu, 15 Feb 2018 08:12:20 -0500 Received: by mail-lf0-f65.google.com with SMTP id c188so18082268lfc.11 for ; Thu, 15 Feb 2018 05:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wc2OX2K470wjz0qVHFri47+oAIgKEcxinCp2/rSfIr8=; b=BtOhKJ2Vade4bTJMC68nASViJtgYSpQfrZALvh2iXGsRj0sbbtZK6khQLVIovnAN7k V6HMU4p0KPDFpnZyC8HVEXMZitw21JCSzcyDx7mxq7y5Hxyqdg5U7jXjWmAC0/zWO7YC svzzaZ6E9n+H1NPCfnYPWSgCVlvJ63QCvwyZUB6mVigWwYGcvo+JbYqSnSQsxAzHgMQz tCumwManb01f97VqYKKL9iGM5yf6h83TmbzfNGqY6JbLvNj1Flp6IFU+Rb7IGS6WjPZv 2/HcsqoeL9cZWKu509Eo/FGCTlyJnmv9UFJ6MkGZhJNmnqsj0Oofotv9Eo8abrQYkA4i ugdA== 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:mime-version:content-transfer-encoding; bh=Wc2OX2K470wjz0qVHFri47+oAIgKEcxinCp2/rSfIr8=; b=dygtwHuKM4foEzjG6w74uasuISLuEd3iO0P2tjn1+jt1VbCBE9kiKx5hvId601V3xq Liedm2evnJq5MmQ0Gc4wL0wk6aYX78+1zgRNrAD12SrPlHPdglZ0mE6c0OuEawrWGyR5 bm6eCnIw5pWzMRuV9suXKh1Byh03WP1LrqJWHUJ9EeJyBTKk9q57mmp7ZD0yiOZzUGPO 4et2ePWn3hIok9CFjTUVAiKWYAkh9+b6aOjDvZfXUaGR8hDSr4AwpNKsjnS2L+tip4tL dfBj7cmaumA9f63mbDdtgh1M4a21Qf+gJp/lqQ7dx//F5xFkivjrf52rB3jBASrn4vs2 t0fA== X-Gm-Message-State: APf1xPDOVbBEV0s2N8YqzFim5C1hmd2P9gODu9Vc6G5X1Qq7KNFm00AF u3c/KIY2ZHdqXreEwxkbe7CfNRJZ X-Received: by 10.25.56.22 with SMTP id f22mr1816904lfa.109.1518700338705; Thu, 15 Feb 2018 05:12:18 -0800 (PST) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id s7sm449295lfg.13.2018.02.15.05.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 05:12:17 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH v2 1/6] lightnvm: make 1.2 data structures explicit Date: Thu, 15 Feb 2018 14:11:55 +0100 Message-Id: <20180215131200.3354-2-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180215131200.3354-1-mb@lightnvm.io> References: <20180215131200.3354-1-mb@lightnvm.io> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the 1.2 data structures explicit, so it will be easy to identify the 2.0 data structures. Also fix the order of which the nvme_nvm_* are declared, such that they follow the nvme_nvm_command order. Signed-off-by: Matias Bjørling --- drivers/nvme/host/lightnvm.c | 82 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index dc0b1335c7c6..60db3f1b59da 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -51,6 +51,21 @@ struct nvme_nvm_ph_rw { __le64 resv; }; +struct nvme_nvm_erase_blk { + __u8 opcode; + __u8 flags; + __u16 command_id; + __le32 nsid; + __u64 rsvd[2]; + __le64 prp1; + __le64 prp2; + __le64 spba; + __le16 length; + __le16 control; + __le32 dsmgmt; + __le64 resv; +}; + struct nvme_nvm_identity { __u8 opcode; __u8 flags; @@ -89,33 +104,18 @@ struct nvme_nvm_setbbtbl { __u32 rsvd4[3]; }; -struct nvme_nvm_erase_blk { - __u8 opcode; - __u8 flags; - __u16 command_id; - __le32 nsid; - __u64 rsvd[2]; - __le64 prp1; - __le64 prp2; - __le64 spba; - __le16 length; - __le16 control; - __le32 dsmgmt; - __le64 resv; -}; - struct nvme_nvm_command { union { struct nvme_common_command common; - struct nvme_nvm_identity identity; struct nvme_nvm_ph_rw ph_rw; + struct nvme_nvm_erase_blk erase; + struct nvme_nvm_identity identity; struct nvme_nvm_getbbtbl get_bb; struct nvme_nvm_setbbtbl set_bb; - struct nvme_nvm_erase_blk erase; }; }; -struct nvme_nvm_id_group { +struct nvme_nvm_id12_grp { __u8 mtype; __u8 fmtype; __le16 res16; @@ -141,7 +141,7 @@ struct nvme_nvm_id_group { __u8 reserved[906]; } __packed; -struct nvme_nvm_addr_format { +struct nvme_nvm_id12_addrf { __u8 ch_offset; __u8 ch_len; __u8 lun_offset; @@ -157,16 +157,16 @@ struct nvme_nvm_addr_format { __u8 res[4]; } __packed; -struct nvme_nvm_id { +struct nvme_nvm_id12 { __u8 ver_id; __u8 vmnt; __u8 cgrps; __u8 res; __le32 cap; __le32 dom; - struct nvme_nvm_addr_format ppaf; + struct nvme_nvm_id12_addrf ppaf; __u8 resv[228]; - struct nvme_nvm_id_group group; + struct nvme_nvm_id12_grp grp; __u8 resv2[2880]; } __packed; @@ -191,25 +191,25 @@ static inline void _nvme_nvm_check_size(void) { BUILD_BUG_ON(sizeof(struct nvme_nvm_identity) != 64); BUILD_BUG_ON(sizeof(struct nvme_nvm_ph_rw) != 64); + BUILD_BUG_ON(sizeof(struct nvme_nvm_erase_blk) != 64); BUILD_BUG_ON(sizeof(struct nvme_nvm_getbbtbl) != 64); BUILD_BUG_ON(sizeof(struct nvme_nvm_setbbtbl) != 64); - BUILD_BUG_ON(sizeof(struct nvme_nvm_erase_blk) != 64); - BUILD_BUG_ON(sizeof(struct nvme_nvm_id_group) != 960); - BUILD_BUG_ON(sizeof(struct nvme_nvm_addr_format) != 16); - BUILD_BUG_ON(sizeof(struct nvme_nvm_id) != NVME_IDENTIFY_DATA_SIZE); + BUILD_BUG_ON(sizeof(struct nvme_nvm_id12_grp) != 960); + BUILD_BUG_ON(sizeof(struct nvme_nvm_id12_addrf) != 16); + BUILD_BUG_ON(sizeof(struct nvme_nvm_id12) != NVME_IDENTIFY_DATA_SIZE); BUILD_BUG_ON(sizeof(struct nvme_nvm_bb_tbl) != 64); } -static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id) +static int init_grp(struct nvm_id *nvm_id, struct nvme_nvm_id12 *id12) { - struct nvme_nvm_id_group *src; + struct nvme_nvm_id12_grp *src; struct nvm_id_group *grp; int sec_per_pg, sec_per_pl, pg_per_blk; - if (nvme_nvm_id->cgrps != 1) + if (id12->cgrps != 1) return -EINVAL; - src = &nvme_nvm_id->group; + src = &id12->grp; grp = &nvm_id->grp; grp->mtype = src->mtype; @@ -261,34 +261,34 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id) static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id) { struct nvme_ns *ns = nvmdev->q->queuedata; - struct nvme_nvm_id *nvme_nvm_id; + struct nvme_nvm_id12 *id; struct nvme_nvm_command c = {}; int ret; c.identity.opcode = nvme_nvm_admin_identity; c.identity.nsid = cpu_to_le32(ns->head->ns_id); - nvme_nvm_id = kmalloc(sizeof(struct nvme_nvm_id), GFP_KERNEL); - if (!nvme_nvm_id) + id = kmalloc(sizeof(struct nvme_nvm_id12), GFP_KERNEL); + if (!id) return -ENOMEM; ret = nvme_submit_sync_cmd(ns->ctrl->admin_q, (struct nvme_command *)&c, - nvme_nvm_id, sizeof(struct nvme_nvm_id)); + id, sizeof(struct nvme_nvm_id12)); if (ret) { ret = -EIO; goto out; } - nvm_id->ver_id = nvme_nvm_id->ver_id; - nvm_id->vmnt = nvme_nvm_id->vmnt; - nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap); - nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom); - memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf, + nvm_id->ver_id = id->ver_id; + nvm_id->vmnt = id->vmnt; + nvm_id->cap = le32_to_cpu(id->cap); + nvm_id->dom = le32_to_cpu(id->dom); + memcpy(&nvm_id->ppaf, &id->ppaf, sizeof(struct nvm_addr_format)); - ret = init_grps(nvm_id, nvme_nvm_id); + ret = init_grp(nvm_id, id); out: - kfree(nvme_nvm_id); + kfree(id); return ret; } -- 2.11.0