OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
ftl_config.h
Go to the documentation of this file.
1
2// ftl_config.h for Cosmos+ OpenSSD
3// Copyright (c) 2017 Hanyang University ENC Lab.
4// Contributed by Yong Ho Song <yhsong@enc.hanyang.ac.kr>
5// Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
6// Sangjin Lee <sjlee@enc.hanyang.ac.kr>
7//
8// This file is part of Cosmos+ OpenSSD.
9//
10// Cosmos+ OpenSSD is free software; you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation; either version 3, or (at your option)
13// any later version.
14//
15// Cosmos+ OpenSSD is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18// See the GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Cosmos+ OpenSSD; see the file COPYING.
22// If not, see <http://www.gnu.org/licenses/>.
24
26// Company: ENC Lab. <http://enc.hanyang.ac.kr>
27// Engineer: Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
28//
29// Project Name: Cosmos+ OpenSSD
30// Design Name: Cosmos+ Firmware
31// Module Name: Flash Translation Layer Configuration Manager
32// File Name: ftl_config.h
33//
34// Version: v1.0.0
35//
36// Description:
37// - define parameters, data structure and functions of flash translation layer configuration manager
39
41// Revision History:
42//
43// * v1.0.0
44// - First draft
46
47#ifndef FTL_CONFIG_H_
48#define FTL_CONFIG_H_
49
50#include "nsc_driver.h"
51#include "xparameters.h"
52#include "nvme/nvme.h"
53
54/* -------------------------------------------------------------------------- */
55/* NAND Storage Controller Configurations */
56/* -------------------------------------------------------------------------- */
57
58#ifdef XPAR_T4NFC_HLPER_7_BASEADDR
59#define NSC_7_CONNECTED 1
60#define NSC_7_UCODEADDR XPAR_AXI_BRAM_CTRL_7_S_AXI_BASEADDR
61#define NSC_7_BASEADDR XPAR_T4NFC_HLPER_7_BASEADDR
62#else
63#define NSC_7_CONNECTED 0
64#define NSC_7_UCODEADDR 0
65#define NSC_7_BASEADDR 0
66#endif
67#ifdef XPAR_T4NFC_HLPER_6_BASEADDR
68#define NSC_6_CONNECTED 1
69#define NSC_6_UCODEADDR XPAR_AXI_BRAM_CTRL_6_S_AXI_BASEADDR
70#define NSC_6_BASEADDR XPAR_T4NFC_HLPER_6_BASEADDR
71#else
72#define NSC_6_CONNECTED 0
73#define NSC_6_UCODEADDR 0
74#define NSC_6_BASEADDR 0
75#endif
76#ifdef XPAR_T4NFC_HLPER_5_BASEADDR
77#define NSC_5_CONNECTED 1
78#define NSC_5_UCODEADDR XPAR_AXI_BRAM_CTRL_5_S_AXI_BASEADDR
79#define NSC_5_BASEADDR XPAR_T4NFC_HLPER_5_BASEADDR
80#else
81#define NSC_5_CONNECTED 0
82#define NSC_5_UCODEADDR 0
83#define NSC_5_BASEADDR 0
84#endif
85#ifdef XPAR_T4NFC_HLPER_4_BASEADDR
86#define NSC_4_CONNECTED 1
87#define NSC_4_UCODEADDR XPAR_AXI_BRAM_CTRL_4_S_AXI_BASEADDR
88#define NSC_4_BASEADDR XPAR_T4NFC_HLPER_4_BASEADDR
89#else
90#define NSC_4_CONNECTED 0
91#define NSC_4_UCODEADDR 0
92#define NSC_4_BASEADDR 0
93#endif
94#ifdef XPAR_T4NFC_HLPER_3_BASEADDR
95#define NSC_3_CONNECTED 1
96#define NSC_3_UCODEADDR XPAR_AXI_BRAM_CTRL_3_S_AXI_BASEADDR
97#define NSC_3_BASEADDR XPAR_T4NFC_HLPER_3_BASEADDR
98#else
99#define NSC_3_CONNECTED 0
100#define NSC_3_UCODEADDR 0
101#define NSC_3_BASEADDR 0
102#endif
103#ifdef XPAR_T4NFC_HLPER_2_BASEADDR
104#define NSC_2_CONNECTED 1
105#define NSC_2_UCODEADDR XPAR_AXI_BRAM_CTRL_2_S_AXI_BASEADDR
106#define NSC_2_BASEADDR XPAR_T4NFC_HLPER_2_BASEADDR
107#else
108#define NSC_2_CONNECTED 0
109#define NSC_2_UCODEADDR 0
110#define NSC_2_BASEADDR 0
111#endif
112#ifdef XPAR_T4NFC_HLPER_1_BASEADDR
113#define NSC_1_CONNECTED 1
114#define NSC_1_UCODEADDR XPAR_AXI_BRAM_CTRL_1_S_AXI_BASEADDR
115#define NSC_1_BASEADDR XPAR_T4NFC_HLPER_1_BASEADDR
116#else
117#define NSC_1_CONNECTED 0
118#define NSC_1_UCODEADDR 0
119#define NSC_1_BASEADDR 0
120#endif
121#ifdef XPAR_T4NFC_HLPER_0_BASEADDR
122#define NSC_0_CONNECTED 1
123#define NSC_0_UCODEADDR XPAR_AXI_BRAM_CTRL_0_S_AXI_BASEADDR
124#define NSC_0_BASEADDR XPAR_T4NFC_HLPER_0_BASEADDR
125#else
126#define NSC_0_CONNECTED 0
127#define NSC_0_UCODEADDR 0
128#define NSC_0_BASEADDR 0
129#endif
130
131// number of connected (=AXI mapped) NSC
132#define NUMBER_OF_CONNECTED_CHANNEL \
133 (NSC_7_CONNECTED + NSC_6_CONNECTED + NSC_5_CONNECTED + NSC_4_CONNECTED + NSC_3_CONNECTED + NSC_2_CONNECTED + \
134 NSC_1_CONNECTED + NSC_0_CONNECTED)
135
136/* -------------------------------------------------------------------------- */
137/* NAND flash memory specifications */
138/* -------------------------------------------------------------------------- */
139
140#define BYTES_PER_DATA_REGION_OF_NAND_ROW 16384 /* the size of data region of a page */
141#define BYTES_PER_SPARE_REGION_OF_NAND_ROW 1664 /* the size of spare region of a page */
142
143/* the size in bytes of a whole flash page (data + metadata + ECC). */
144#define BYTES_PER_NAND_ROW (BYTES_PER_DATA_REGION_OF_NAND_ROW + BYTES_PER_SPARE_REGION_OF_NAND_ROW)
145
150#define ROWS_PER_SLC_BLOCK 256 /* number of page in this block (SLC mode) */
151#define ROWS_PER_MLC_BLOCK 256 /* number of page in this block (MLC mode) */
152
153#define MAIN_BLOCKS_PER_LUN 2732 /* number of blocks in the main space of a die */
154#define EXTENDED_BLOCKS_PER_LUN 224 /* number of blocks in the extended space of a die */
155#define TOTAL_BLOCKS_PER_LUN (MAIN_BLOCKS_PER_LUN + EXTENDED_BLOCKS_PER_LUN)
156
157#define MAIN_ROWS_PER_SLC_LUN (ROWS_PER_SLC_BLOCK * MAIN_BLOCKS_PER_LUN)
158#define MAIN_ROWS_PER_MLC_LUN (ROWS_PER_MLC_BLOCK * MAIN_BLOCKS_PER_LUN)
159
160#define LUNS_PER_DIE 1 /* number of planes in a die (way) */
161
162#define MAIN_BLOCKS_PER_DIE (MAIN_BLOCKS_PER_LUN * LUNS_PER_DIE)
163#define TOTAL_BLOCKS_PER_DIE (TOTAL_BLOCKS_PER_LUN * LUNS_PER_DIE)
164
165#define BAD_BLOCK_MARK_PAGE0 0 // first row of a block
166#define BAD_BLOCK_MARK_PAGE1 (ROWS_PER_MLC_BLOCK - 1) // last row of a block
167#define BAD_BLOCK_MARK_BYTE0 0 // first byte of data region of the row
168#define BAD_BLOCK_MARK_BYTE1 (BYTES_PER_DATA_REGION_OF_NAND_ROW) // first byte of spare region of the row
169
170//------------------------------------
171// NAND storage controller specifications
172//------------------------------------
173
174// supported maximum channel/way structure
175#define NSC_MAX_CHANNELS (NUMBER_OF_CONNECTED_CHANNEL)
176#define NSC_MAX_WAYS 8
177
178// row -> page
179#define BYTES_PER_DATA_REGION_OF_PAGE 16384
180#define BYTES_PER_SPARE_REGION_OF_PAGE 256 // last 8 byte used by ECC engine (CRC function)
181// (BYTES_PER_SPARE_REGION_OF_NAND_ROW - BYTES_PER_SPARE_REGION_OF_PAGE) bytes are used by ECC engine (Parity data)
182#define PAGES_PER_SLC_BLOCK (ROWS_PER_SLC_BLOCK)
183#define PAGES_PER_MLC_BLOCK (ROWS_PER_MLC_BLOCK)
184
185// ECC encoder/decoder specification
186#define ECC_CHUNKS_PER_PAGE 32
187#define BIT_ERROR_THRESHOLD_PER_CHUNK 24
188#define ERROR_INFO_WORD_COUNT 11
189
190//------------------------------
191// NVMe Controller Specifications
192//------------------------------
193
194#define BYTES_PER_NVME_BLOCK 4096
195#define NVME_BLOCKS_PER_PAGE (BYTES_PER_DATA_REGION_OF_PAGE / BYTES_PER_NVME_BLOCK)
196
197//------------------
198// FTL configurations
199//------------------
200
201#define SLC_MODE 1
202#define MLC_MODE 2
203
204//************************************************************************
205#define BITS_PER_FLASH_CELL SLC_MODE // user configurable factor
206#define USER_BLOCKS_PER_LUN 2048 // user configurable factor
207#define USER_CHANNELS 8 // user configurable factor
208#define USER_WAYS 8 // user configurable factor
209//************************************************************************
210
211// slice size, the mapping unit of FTL, equal to page size
212#define BYTES_PER_DATA_REGION_OF_SLICE 16384
213#define BYTES_PER_SPARE_REGION_OF_SLICE 256
214
215#define SLICES_PER_PAGE \
216 (BYTES_PER_DATA_REGION_OF_PAGE / BYTES_PER_DATA_REGION_OF_SLICE) // a slice directs a page, full page mapping
217#define NVME_BLOCKS_PER_SLICE (BYTES_PER_DATA_REGION_OF_SLICE / BYTES_PER_NVME_BLOCK)
218
219#define USER_DIES (USER_CHANNELS * USER_WAYS)
220
221#define USER_PAGES_PER_BLOCK (PAGES_PER_SLC_BLOCK * BITS_PER_FLASH_CELL)
222#define USER_PAGES_PER_LUN (USER_PAGES_PER_BLOCK * USER_BLOCKS_PER_LUN)
223#define USER_PAGES_PER_DIE (USER_PAGES_PER_LUN * LUNS_PER_DIE)
224#define USER_PAGES_PER_CHANNEL (USER_PAGES_PER_DIE * USER_WAYS)
225#define USER_PAGES_PER_SSD (USER_PAGES_PER_CHANNEL * USER_CHANNELS)
226
227#define SLICES_PER_BLOCK (USER_PAGES_PER_BLOCK * SLICES_PER_PAGE)
228#define SLICES_PER_LUN (USER_PAGES_PER_LUN * SLICES_PER_PAGE)
229#define SLICES_PER_DIE (USER_PAGES_PER_DIE * SLICES_PER_PAGE)
230#define SLICES_PER_CHANNEL (USER_PAGES_PER_CHANNEL * SLICES_PER_PAGE)
231#define SLICES_PER_SSD (USER_PAGES_PER_SSD * SLICES_PER_PAGE)
232
233#define USER_BLOCKS_PER_DIE (USER_BLOCKS_PER_LUN * LUNS_PER_DIE)
234#define USER_BLOCKS_PER_CHANNEL (USER_BLOCKS_PER_DIE * USER_WAYS)
235#define USER_BLOCKS_PER_SSD (USER_BLOCKS_PER_CHANNEL * USER_CHANNELS)
236
237#define MB_PER_BLOCK ((BYTES_PER_DATA_REGION_OF_SLICE * SLICES_PER_BLOCK) / (1024 * 1024))
238#define MB_PER_SSD (USER_BLOCKS_PER_SSD * MB_PER_BLOCK)
239#define MB_PER_MIN_FREE_BLOCK_SPACE (USER_DIES * MB_PER_BLOCK)
240#define MB_PER_METADATA_BLOCK_SPACE (USER_DIES * MB_PER_BLOCK)
241#define MB_PER_OVER_PROVISION_BLOCK_SPACE ((USER_BLOCKS_PER_SSD / 10) * MB_PER_BLOCK)
242
243void InitFTL();
244void InitChCtlReg();
245void InitNandArray();
247
248extern unsigned int storageCapacity_L;
250
251#endif /* FTL_CONFIG_H_ */
void InitNandArray()
Send RESET and SET_FEATURE to all the flash dies.
Definition: ftl_config.c:175
#define USER_CHANNELS
Definition: ftl_config.h:207
void InitChCtlReg()
Initialize the base addresses of all channel controllers.
Definition: ftl_config.c:119
T4REGS chCtlReg[USER_CHANNELS]
Definition: ftl_config.c:57
void CheckConfigRestriction()
Check the configurations are legal before the initializations start.
Definition: ftl_config.c:242
void InitFTL()
The entry function for FTL initialization.
Definition: ftl_config.c:62
unsigned int storageCapacity_L
Definition: ftl_config.c:56