From patchwork Tue Feb 13 14:06:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 10216421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D967560329 for ; Tue, 13 Feb 2018 14:08:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC692283C7 for ; Tue, 13 Feb 2018 14:08:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C13C328D06; Tue, 13 Feb 2018 14:08:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D3928CF8 for ; Tue, 13 Feb 2018 14:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965108AbeBMOG7 (ORCPT ); Tue, 13 Feb 2018 09:06:59 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39329 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965023AbeBMOGW (ORCPT ); Tue, 13 Feb 2018 09:06:22 -0500 Received: by mail-wm0-f67.google.com with SMTP id b21so16234400wme.4 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=jvuhKjSkg/vFdrPCU+keJh3cZV+6pXouSqSMU3lD8lx03iPNyUBhjkwCX9+NWoBEVT fQMtP0qoBuEymb6Hiu6Oh7VcOzjY3cVzpRktadeBDhYw5R0stYfz3s0OKcsyyoKxAwHG nmZkXfct5vFl8X3w3YvwuFgDLh2+95O6Pdyfj8H6FQ8dGVO9Fa7UMkFgY2g0Al4O32Q8 VNj7URUxr2apNWs96USNk6iXGTXu2uoSUrjpk9Z8SswSvIjRcUrGh4WxPj+9Q8vBoOQS ZhPBdKQoNK1diKqIGTMB9lm/aKwMudyj8D40Yyg8S52RdxsBt6bKXWleXHgg7Dy+VFsJ aFsA== X-Gm-Message-State: APf1xPAvpTtMJu1acI8HtNAoo9Rqz8zUdzS1AAs1/x3+vuMImDj7Pa8a e2eZPSWojfSW0y9c/A7g2dnw4Q== X-Google-Smtp-Source: AH8x224oRGpbPiSDS/30DZ/+KwtU0TFNB7HPm+FcTK2g4eiq6waZkL6T1017SzAjUZrPcK5LhWAe8Q== 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 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }