Received: by 10.223.185.116 with SMTP id b49csp3677565wrg; Tue, 13 Feb 2018 06:09:00 -0800 (PST) X-Google-Smtp-Source: AH8x225TqH98hetBRHG7TamXV8NfVFDAQWLZM38GSG/ddiXoVx8gu0q5TAdooghnBf3l94RBjNLU X-Received: by 2002:a17:902:3a1:: with SMTP id d30-v6mr1220359pld.409.1518530940103; Tue, 13 Feb 2018 06:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518530940; cv=none; d=google.com; s=arc-20160816; b=yPjO60baEDPE2wdTDX9tnRq0m8uWRRU2O1Diuar8m9/nFGSyLUqcTQzg80bTTzOdvF x9IP0S37534ozM3fEClvsDkzzh0GF+eU+cuVmWOu7P9XaB2KG04ghcXr4Pk8HM28u83t FroY274q+ybLxVhnJukCxXsubuor8Mz6Ausvz3tjFKDnFVSR28I8uuOp9MKtLJox6EcH lkL/B/CGyHlwmU0Q3Z2047pPdSpBsTSj6XDAw+YvZja3uWhFlS7t8N669aWWyFOJWFMZ qaZppK1Mj9o4RoZRFQjZMcIV7Wql15W0xdScHZvnJDRne5lLW/9UPV+z2HKhAtlRM8v8 wuGg== 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=9BgLp9tQsBlJPAw59hxYXOgq3L/Su1cXkBLEcKuqD1U=; b=iWWc6KwaWOyesLEdUG3fXpLRzcGJVICpww05g9uJ71tdjVgYX/TLWMdI+rnTADbPNE 51YZkIpYTmxIrrBP8FjcnyeDJ+EbIWxgb6Q0sJfH0aom2eBeShtJLbJN8TH4MlxIZEWh JM7a4VBpdju2Ae/0BdIvXIAM5VeHROhlt++9qfhSZ6lCR9dT52VTtSrlewMtVNFM9Izk ri2t8mbyQUXnswwAvKqUGGDf4I5jNLiDiuHHJbebGszzv/k0+JDGlVcVQnwcLF96nA8W dwcrHrBptJpWwOxmCzfp1VaUZGSEIsNUVLCQ9f97j2kMo3Db/mByzYIULhakatOTIQlJ xW6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=J5HsUWmn; 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 l6si1264697pgs.367.2018.02.13.06.08.42; Tue, 13 Feb 2018 06:09:00 -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=J5HsUWmn; 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 S965145AbeBMOHE (ORCPT + 99 others); Tue, 13 Feb 2018 09:07:04 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37443 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965024AbeBMOGW (ORCPT ); Tue, 13 Feb 2018 09:06:22 -0500 Received: by mail-wm0-f66.google.com with SMTP id v71so16261490wmv.2 for ; Tue, 13 Feb 2018 06:06:21 -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=9BgLp9tQsBlJPAw59hxYXOgq3L/Su1cXkBLEcKuqD1U=; b=J5HsUWmnDXu3m6IfklGplbNW69TF7Pp/iVLQdXOYps4ttK5vpRuGpmR/AHdGWSHTJX /29cicDcKdajWDFzmWqZotvuHb0/Iyn+fbqXnFMa76B+WgTHS5xN7Od5KY0/ZrPBc/uk P/xstrgjk65N12HQSEN3NZJhjX48S37eAbYtZFay/n67jmghGkFE0q3/gBAE6vmfG4Yj +mtXTu2ty5tOWGnlgo2Xzlwe9Wt3bEUucnBwKHD/NoQBwIn/srYWDUsMspIxs2fihRYx KVc4Zaada7xdTDyk2NuilTMuT23hEC9py8DSo+yGTSjfInCkC+E/GuUrVwV0Oo5UQ8MY CrwQ== 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=9BgLp9tQsBlJPAw59hxYXOgq3L/Su1cXkBLEcKuqD1U=; b=sB4yiWLHt4rDQRP9PD3V8N2XmhBqWek9L4LyVzhSulLQoHNOXW/KldTprYWS6rMo5U eL8HnH9c8N0NfLd0ZjixRkmGxQhWnw3FleOAnjb+L2Y9c1q/umDmx5Jidk/9yyWQDc/P ZVi8PIDVNxo9KYEJ0YveBYlPmqtCgJZJzt+JqC7HrppkOwLERhfWGGdKx9sEJfr6IZC1 pIB39vc3JrLXGWR6QRQfAs26cNK9Wkdzzkl+/rfZmT/v+Ly2HqASnVCBqPj9e/pgcqte 29ymvEkd0beeW0NGpIK9OCyVSp5IMiYhMrhSZeTsiGP+fws5pyPDS1P6y/oKw+vsyR/2 Lh6g== X-Gm-Message-State: APf1xPDGH05ospfA+s10Ed9yuKX0XXIFS1xw/35aqFw3kDvf6yZzPyBk tryzpLyqXYp1Y/rJon/b1KROZg== X-Received: by 10.80.186.142 with SMTP id x14mr2402802ede.210.1518530781198; Tue, 13 Feb 2018 06:06:21 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id k11sm6658850eda.22.2018.02.13.06.06.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 06:06:20 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 4/8] lightnvm: convert address based on spec. version Date: Tue, 13 Feb 2018 15:06:04 +0100 Message-Id: <1518530768-20956-5-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518530768-20956-1-git-send-email-javier@cnexlabs.com> References: <1518530768-20956-1-git-send-email-javier@cnexlabs.com> 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 Create the device ppa for both 1.2 and 2.0. Signed-off-by: Javier González --- include/linux/lightnvm.h | 52 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index e035ae4c9acc..1148b3f22b27 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -412,16 +412,26 @@ static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev, struct ppa_addr r) { struct nvm_geo *geo = &tgt_dev->geo; - struct nvm_addr_format_12 *ppaf = - (struct nvm_addr_format_12 *)&geo->c.addrf; struct ppa_addr l; - l.ppa = ((u64)r.g.ch) << ppaf->ch_offset; - l.ppa |= ((u64)r.g.lun) << ppaf->lun_offset; - l.ppa |= ((u64)r.g.blk) << ppaf->blk_offset; - l.ppa |= ((u64)r.g.pg) << ppaf->pg_offset; - l.ppa |= ((u64)r.g.pl) << ppaf->pln_offset; - l.ppa |= ((u64)r.g.sec) << ppaf->sec_offset; + if (geo->c.version == NVM_OCSSD_SPEC_12) { + struct nvm_addr_format_12 *ppaf = + (struct nvm_addr_format_12 *)&geo->c.addrf; + + l.ppa = ((u64)r.g.ch) << ppaf->ch_offset; + l.ppa |= ((u64)r.g.lun) << ppaf->lun_offset; + l.ppa |= ((u64)r.g.blk) << ppaf->blk_offset; + l.ppa |= ((u64)r.g.pg) << ppaf->pg_offset; + l.ppa |= ((u64)r.g.pl) << ppaf->pln_offset; + l.ppa |= ((u64)r.g.sec) << ppaf->sec_offset; + } else { + struct nvm_addr_format *lbaf = &geo->c.addrf; + + l.ppa = ((u64)r.m.ch) << lbaf->ch_offset; + l.ppa |= ((u64)r.m.lun) << lbaf->lun_offset; + l.ppa |= ((u64)r.m.chk) << lbaf->chk_offset; + l.ppa |= ((u64)r.m.sec) << lbaf->sec_offset; + } return l; } @@ -430,18 +440,28 @@ static inline struct ppa_addr dev_to_generic_addr(struct nvm_tgt_dev *tgt_dev, struct ppa_addr r) { struct nvm_geo *geo = &tgt_dev->geo; - struct nvm_addr_format_12 *ppaf = - (struct nvm_addr_format_12 *)&geo->c.addrf; struct ppa_addr l; l.ppa = 0; - l.g.ch = (r.ppa & ppaf->ch_mask) >> ppaf->ch_offset; - l.g.lun = (r.ppa & ppaf->lun_mask) >> ppaf->lun_offset; - l.g.blk = (r.ppa & ppaf->blk_mask) >> ppaf->blk_offset; - l.g.pg = (r.ppa & ppaf->pg_mask) >> ppaf->pg_offset; - l.g.pl = (r.ppa & ppaf->pln_mask) >> ppaf->pln_offset; - l.g.sec = (r.ppa & ppaf->sec_mask) >> ppaf->sec_offset; + if (geo->c.version == NVM_OCSSD_SPEC_12) { + struct nvm_addr_format_12 *ppaf = + (struct nvm_addr_format_12 *)&geo->c.addrf; + + l.g.ch = (r.ppa & ppaf->ch_mask) >> ppaf->ch_offset; + l.g.lun = (r.ppa & ppaf->lun_mask) >> ppaf->lun_offset; + l.g.blk = (r.ppa & ppaf->blk_mask) >> ppaf->blk_offset; + l.g.pg = (r.ppa & ppaf->pg_mask) >> ppaf->pg_offset; + l.g.pl = (r.ppa & ppaf->pln_mask) >> ppaf->pln_offset; + l.g.sec = (r.ppa & ppaf->sec_mask) >> ppaf->sec_offset; + } else { + struct nvm_addr_format *lbaf = &geo->c.addrf; + + l.m.ch = (r.ppa & lbaf->ch_mask) >> lbaf->ch_offset; + l.m.lun = (r.ppa & lbaf->lun_mask) >> lbaf->lun_offset; + l.m.chk = (r.ppa & lbaf->chk_mask) >> lbaf->chk_offset; + l.m.sec = (r.ppa & lbaf->sec_mask) >> lbaf->sec_offset; + } return l; } -- 2.7.4