Received: by 10.223.185.116 with SMTP id b49csp6425825wrg; Wed, 28 Feb 2018 09:11:46 -0800 (PST) X-Google-Smtp-Source: AG47ELtnfLM6HVH6f9+VHPtieC5uDK5W7yXuwZ/mL62yjSvAOGOw15t4aBYhdEMJoUSwZt2F0O6L X-Received: by 10.99.56.11 with SMTP id f11mr10864644pga.63.1519837906682; Wed, 28 Feb 2018 09:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519837906; cv=none; d=google.com; s=arc-20160816; b=MuVqmywUSGzpEIEh46IKXJVtG6jptje04zGFRtsaUaBcKXSkYTpDgs4Qy3Fs9QxZmr Uey5pY3jVaWTIj9V7tCfaumi325ahgTpiAYVoaq/wH/dSa5h78UEsBlSdsgiav2uBq6i q0NhHpUDu21j6qtgBo5p/5OslqOwLL6/ISnZDKdn9fBvWZiujovqSMr1M+Zt2X5A2kIb x5/JGNp4yo8gaTA1H+9M94JcolN8YF+LTKnZRxt9VdJatH1hyM8XT9j4Sav9fGaiBj8R cLEZ+QwQSCPgNhW+HNiBMI/kyukJht4ErlNoWczWVrUEC8/woRHCLQRoG3+bd4RezZXL qlgw== 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=uzoiKXBR1pLJ5fThYIinnY1iKs94O5M2K43ybaJApTA=; b=G7Msqf0aRuRxoIxUncDnsqiODEZhzRJytUVI7laH76U6WheXZq/pRCcN2pZoTUJOOz MYMBrtQOhHE4Anj2GYRyz7K5lh3mu8BE0oQmKl3Ouqs0ditrvs+sj19wVX7+ivoJdYfF Rwh2D3b0Zm0MONITd5I9t6bj9SRissfiZiY0lxCLk0U9fyZvTtkvIlXWuZKiI4UpNr/g rR77w2+o7akqZaapUOdyZRbKN3LBMwzIIv2L8+LP++fexX4h1ZmBReJXzQ0Y5wlV8PZd UDk9b+9gnFbuT1ZxhelDCRiHz9Fm/CynjYxH1mKg7YPz3TzU3V6iEkp+cokckZTNB7Te 0Eiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=TlZSkfOv; 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 m72si1481774pfj.159.2018.02.28.09.11.30; Wed, 28 Feb 2018 09:11:46 -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=TlZSkfOv; 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 S933788AbeB1RKx (ORCPT + 99 others); Wed, 28 Feb 2018 12:10:53 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40029 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933231AbeB1Pt5 (ORCPT ); Wed, 28 Feb 2018 10:49:57 -0500 Received: by mail-wm0-f66.google.com with SMTP id t6so5957414wmt.5 for ; Wed, 28 Feb 2018 07:49:56 -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=uzoiKXBR1pLJ5fThYIinnY1iKs94O5M2K43ybaJApTA=; b=TlZSkfOvq8uZgkNY9MMCd7oeIJtAq7gBGqXiYx7bd4w57+wZJQGlCk0k//uvhj4BnI o1Sa2L2heJQ9X3EWQ3tNdoS+V4wP5Ugs12s4hc6Du59eOcsXolWi6MZOWbHqjqynyz53 cKIDCQeYJHA8VFr8vyefAoN5MKrJhkOVeXN3YHKVEQdVLxoAmSyvPs073zMbI+af84wa Ly0fVgYj3uOnz+xYqKzHzNOlRb4I+QNv1iu4tao86hG6ohGcPXOdaF2PWsm9OyhBLIPl urgmjSICCsD0PjLvJRj9d44G++ZYkJHmRP9LLisPJH2ljU5fMqVhffjcyYBklfdv3hgE KbGA== 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=uzoiKXBR1pLJ5fThYIinnY1iKs94O5M2K43ybaJApTA=; b=dfMGmwOMwISVav8rsM7Zh4Ux9emO29gF4vGCmeJNcGrNg0rNDOL6NQ8Q9Csvga8lmj +poiX1DWiPp92qYQi68qKPGfU+Exs1XGip6kbRy6KFFrKMrK8FlZu/9b4m5UaTyZsU2x 8cQGZTAWqLj1yJDvQslOb4Vn7RNrcGQyBjVwi9DumXSik4C6RoNFI75kAq8YhK0y4TV1 YEd/GDCeqsQLPq/Gpfbm2D+sTRnrAdbZ13IjZeKZY/wtwKnULFvvU9GkT3MfBQQO619A AAgVSCvsr7Y/RArm5MmpRA9fR+WDzGm9je6Hv0bZg0JbINX+Ai3gJyf+hX2/XVGPQaw8 Z5mA== X-Gm-Message-State: APf1xPAsYjTU7DIByT+ZNigsypfvkh5ER0fj718KI3GswHNNWznCvAJe /QSRI94McluQoUWiYfV8ZCnVrg== X-Received: by 10.80.149.68 with SMTP id v4mr15944067eda.236.1519832995518; Wed, 28 Feb 2018 07:49:55 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id n2sm1953056edb.62.2018.02.28.07.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 07:49:54 -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 07/15] lightnvm: add support for 2.0 address format Date: Wed, 28 Feb 2018 16:49:27 +0100 Message-Id: <1519832975-25432-8-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519832975-25432-1-git-send-email-javier@cnexlabs.com> References: <1519832975-25432-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 Add support for 2.0 address format. Also, align address bits for 1.2 and 2.0 to be able to operate on channel and luns without requiring a format conversion. Use a generic address format for this purpose. Signed-off-by: Javier González --- drivers/lightnvm/core.c | 20 ++++----- include/linux/lightnvm.h | 105 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 86 insertions(+), 39 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index b869e3051265..36d76de22dfc 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -194,8 +194,8 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev, for (j = 0; j < luns_in_chnl; j++) { luns[lunid].ppa = 0; - luns[lunid].g.ch = i; - luns[lunid++].g.lun = j; + luns[lunid].a.ch = i; + luns[lunid++].a.lun = j; lun_offs[j] = blun; lun_roffs[j + blun] = blun; @@ -556,22 +556,22 @@ static void nvm_unregister_map(struct nvm_dev *dev) static void nvm_map_to_dev(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) { struct nvm_dev_map *dev_map = tgt_dev->map; - struct nvm_ch_map *ch_map = &dev_map->chnls[p->g.ch]; - int lun_off = ch_map->lun_offs[p->g.lun]; + struct nvm_ch_map *ch_map = &dev_map->chnls[p->a.ch]; + int lun_off = ch_map->lun_offs[p->a.lun]; - p->g.ch += ch_map->ch_off; - p->g.lun += lun_off; + p->a.ch += ch_map->ch_off; + p->a.lun += lun_off; } static void nvm_map_to_tgt(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) { struct nvm_dev *dev = tgt_dev->parent; struct nvm_dev_map *dev_rmap = dev->rmap; - struct nvm_ch_map *ch_rmap = &dev_rmap->chnls[p->g.ch]; - int lun_roff = ch_rmap->lun_offs[p->g.lun]; + struct nvm_ch_map *ch_rmap = &dev_rmap->chnls[p->a.ch]; + int lun_roff = ch_rmap->lun_offs[p->a.lun]; - p->g.ch -= ch_rmap->ch_off; - p->g.lun -= lun_roff; + p->a.ch -= ch_rmap->ch_off; + p->a.lun -= lun_roff; } static void nvm_ppa_tgt_to_dev(struct nvm_tgt_dev *tgt_dev, diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 4f88e3dc4d8c..73110adf27ad 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -16,12 +16,21 @@ enum { NVM_IOTYPE_GC = 1, }; -#define NVM_BLK_BITS (16) -#define NVM_PG_BITS (16) -#define NVM_SEC_BITS (8) -#define NVM_PL_BITS (8) -#define NVM_LUN_BITS (8) -#define NVM_CH_BITS (7) +/* common format */ +#define NVM_GEN_CH_BITS (8) +#define NVM_GEN_LUN_BITS (8) +#define NVM_GEN_BLK_BITS (16) +#define NVM_GEN_RESERVED (32) + +/* 1.2 format */ +#define NVM_12_PG_BITS (16) +#define NVM_12_PL_BITS (4) +#define NVM_12_SEC_BITS (4) +#define NVM_12_RESERVED (8) + +/* 2.0 format */ +#define NVM_20_SEC_BITS (24) +#define NVM_20_RESERVED (8) enum { NVM_OCSSD_SPEC_12 = 12, @@ -31,16 +40,34 @@ enum { struct ppa_addr { /* Generic structure for all addresses */ union { + /* generic device format */ struct { - u64 blk : NVM_BLK_BITS; - u64 pg : NVM_PG_BITS; - u64 sec : NVM_SEC_BITS; - u64 pl : NVM_PL_BITS; - u64 lun : NVM_LUN_BITS; - u64 ch : NVM_CH_BITS; - u64 reserved : 1; + u64 ch : NVM_GEN_CH_BITS; + u64 lun : NVM_GEN_LUN_BITS; + u64 blk : NVM_GEN_BLK_BITS; + u64 reserved : NVM_GEN_RESERVED; + } a; + + /* 1.2 device format */ + struct { + u64 ch : NVM_GEN_CH_BITS; + u64 lun : NVM_GEN_LUN_BITS; + u64 blk : NVM_GEN_BLK_BITS; + u64 pg : NVM_12_PG_BITS; + u64 pl : NVM_12_PL_BITS; + u64 sec : NVM_12_SEC_BITS; + u64 reserved : NVM_12_RESERVED; } g; + /* 2.0 device format */ + struct { + u64 grp : NVM_GEN_CH_BITS; + u64 pu : NVM_GEN_LUN_BITS; + u64 chk : NVM_GEN_BLK_BITS; + u64 sec : NVM_20_SEC_BITS; + u64 reserved : NVM_20_RESERVED; + } m; + struct { u64 line : 63; u64 is_cached : 1; @@ -376,16 +403,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->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->version == NVM_OCSSD_SPEC_12) { + struct nvm_addr_format_12 *ppaf = + (struct nvm_addr_format_12 *)&geo->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->addrf; + + l.ppa = ((u64)r.m.grp) << lbaf->ch_offset; + l.ppa |= ((u64)r.m.pu) << lbaf->lun_offset; + l.ppa |= ((u64)r.m.chk) << lbaf->chk_offset; + l.ppa |= ((u64)r.m.sec) << lbaf->sec_offset; + } return l; } @@ -394,18 +431,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->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->version == NVM_OCSSD_SPEC_12) { + struct nvm_addr_format_12 *ppaf = + (struct nvm_addr_format_12 *)&geo->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->addrf; + + l.m.grp = (r.ppa & lbaf->ch_mask) >> lbaf->ch_offset; + l.m.pu = (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