OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
data_buffer.h
Go to the documentation of this file.
1
2// data_buffer.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//
7// This file is part of Cosmos+ OpenSSD.
8//
9// Cosmos+ OpenSSD is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 3, or (at your option)
12// any later version.
13//
14// Cosmos+ OpenSSD is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17// See the GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with Cosmos+ OpenSSD; see the file COPYING.
21// If not, see <http://www.gnu.org/licenses/>.
23
25// Company: ENC Lab. <http://enc.hanyang.ac.kr>
26// Engineer: Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
27//
28// Project Name: Cosmos+ OpenSSD
29// Design Name: Cosmos+ Firmware
30// Module Name: Data Buffer Manager
31// File Name: data_buffer.h
32//
33// Version: v1.0.0
34//
35// Description:
36// - define parameters, data structure and functions of data buffer manager
38
40// Revision History:
41//
42// * v1.0.0
43// - First draft
45
46#ifndef DATA_BUFFER_H_
47#define DATA_BUFFER_H_
48
49#include "stdint.h"
50#include "ftl_config.h"
51#include "memory_map.h"
52
53// the data buffer entries for each die, default 16
54#define AVAILABLE_DATA_BUFFER_ENTRY_COUNT (16 * USER_DIES)
55#define AVAILABLE_TEMPORARY_DATA_BUFFER_ENTRY_COUNT (USER_DIES)
56
57#define DATA_BUF_NONE 0xffff
58#define DATA_BUF_FAIL 0xffff
59#define DATA_BUF_DIRTY 1 // the buffer entry is not clean
60#define DATA_BUF_CLEAN 0 // the buffer entry is not dirty
61
62#define FindDataBufHashTableEntry(logicalSliceAddr) ((logicalSliceAddr) % AVAILABLE_DATA_BUFFER_ENTRY_COUNT)
63
102typedef struct _DATA_BUF_ENTRY
103{
104 unsigned int logicalSliceAddr; // the LSA of the request that owns this buffer
105 unsigned int prevEntry : 16; // the index of pref entry in the dataBuf
106 unsigned int nextEntry : 16; // the index of next entry in the dataBuf
107 unsigned int blockingReqTail : 16; // the request pool entry index of the last blocking request
108 unsigned int hashPrevEntry : 16; // the index of the prev data buffer entry in the bucket
109 unsigned int hashNextEntry : 16; // the index of the next data buffer entry in the bucket
110 unsigned int dirty : 1; // whether this data buffer entry is dirty or not (clean)
111 unsigned int reserved0 : 15;
113
120typedef struct _DATA_BUF_MAP
121{
124
133typedef struct _DATA_BUF_LRU_LIST
134{
135 unsigned int headEntry : 16; // the index of MRU data buffer entry
136 unsigned int tailEntry : 16; // the index of LRU data buffer entry
138
148{
149 unsigned int headEntry : 16; // the first data buffer entry in this bucket
150 unsigned int tailEntry : 16; // the last data buffer entry in this bucket
152
160{
163
165{
166 unsigned int blockingReqTail : 16;
167 unsigned int reserved0 : 16;
169
178{
181
182void InitDataBuf();
183unsigned int CheckDataBufHit(unsigned int reqSlotTag);
184unsigned int AllocateDataBuf();
185void UpdateDataBufEntryInfoBlockingReq(unsigned int bufEntry, unsigned int reqSlotTag);
186
187unsigned int AllocateTempDataBuf(unsigned int dieNo);
188void UpdateTempDataBufEntryInfoBlockingReq(unsigned int bufEntry, unsigned int reqSlotTag);
189
190void PutToDataBufHashList(unsigned int bufEntry);
191void SelectiveGetFromDataBufHashList(unsigned int bufEntry);
192
197
198/* -------------------------------------------------------------------------- */
199/* util macros for data buffer related ops */
200/* -------------------------------------------------------------------------- */
201
202#define BUF_ENTRY(iEntry) (&dataBufMapPtr->dataBuf[(iEntry)])
203#define BUF_HEAD_IDX() (dataBufLruList.headEntry)
204#define BUF_TAIL_IDX() (dataBufLruList.tailEntry)
205#define BUF_HEAD_ENTRY() (BUF_ENTRY(BUF_HEAD_IDX()))
206#define BUF_TAIL_ENTRY() (BUF_ENTRY(BUF_TAIL_IDX()))
207#define BUF_PREV_IDX(iEntry) (BUF_ENTRY((iEntry))->prevEntry)
208#define BUF_NEXT_IDX(iEntry) (BUF_ENTRY((iEntry))->nextEntry)
209#define BUF_PREV_ENTRY(iEntry) (BUF_ENTRY(BUF_PREV_IDX((iEntry))))
210#define BUF_NEXT_ENTRY(iEntry) (BUF_ENTRY(BUF_NEXT_IDX((iEntry))))
211
212#define BUF_ENTRY_IS_HEAD(iEntry) (BUF_PREV_IDX((iEntry)) == DATA_BUF_NONE)
213#define BUF_ENTRY_IS_TAIL(iEntry) (BUF_NEXT_IDX((iEntry)) == DATA_BUF_NONE)
214
215#define H_BUF_ENTRY(iEntry) (&dataBufHashTablePtr->dataBufHash[(iEntry)])
216#define H_BUF_HEAD_ENTRY(iEntry) (BUF_ENTRY(H_BUF_ENTRY((iEntry))->headEntry))
217#define H_BUF_HEAD_IDX(iEntry) (H_BUF_ENTRY((iEntry))->headEntry)
218
219#define BUF_LSA(iEntry) (BUF_ENTRY((iEntry))->logicalSliceAddr)
220
221#define BUF_DATA_ENTRY2ADDR(iEntry) (DATA_BUFFER_BASE_ADDR + ((iEntry)*BYTES_PER_DATA_REGION_OF_SLICE))
222#define BUF_SPARE_ENTRY2ADDR(iEntry) (SPARE_DATA_BUFFER_BASE_ADDR + ((iEntry)*BYTES_PER_SPARE_REGION_OF_SLICE))
223
224#endif /* DATA_BUFFER_H_ */
struct _DATA_BUF_HASH_ENTRY * P_DATA_BUF_HASH_ENTRY
struct _DATA_BUF_ENTRY DATA_BUF_ENTRY
The structure of the data buffer entry.
struct _DATA_BUF_LRU_LIST DATA_BUF_LRU_LIST
The structure of LRU list that records the head and tail data buffer entry index of the LRU list.
void UpdateTempDataBufEntryInfoBlockingReq(unsigned int bufEntry, unsigned int reqSlotTag)
Append the request to the blocking queue specified by given temp buffer entry.
Definition: data_buffer.c:298
struct _TEMPORARY_DATA_BUF_MAP TEMPORARY_DATA_BUF_MAP
The structure of the temp data buffer table.
void PutToDataBufHashList(unsigned int bufEntry)
Insert the given data buffer entry into the hash table.
Definition: data_buffer.c:319
P_DATA_BUF_HASH_TABLE dataBufHashTable
struct _TEMPORARY_DATA_BUF_ENTRY TEMPORARY_DATA_BUF_ENTRY
struct _DATA_BUF_HASH_TABLE * P_DATA_BUF_HASH_TABLE
void UpdateDataBufEntryInfoBlockingReq(unsigned int bufEntry, unsigned int reqSlotTag)
Append the request to the blocking queue of the specified data buffer entry.
Definition: data_buffer.c:268
void InitDataBuf()
Initialization process of the Data buffer.
Definition: data_buffer.c:85
unsigned int AllocateTempDataBuf(unsigned int dieNo)
Retrieve the index of temp buffer entry of the target die.
Definition: data_buffer.c:288
struct _DATA_BUF_LRU_LIST * P_DATA_BUF_LRU_LIST
struct _DATA_BUF_MAP * P_DATA_BUF_MAP
struct _DATA_BUF_HASH_TABLE DATA_BUF_HASH_TABLE
The structure of data buffer hash table.
#define AVAILABLE_DATA_BUFFER_ENTRY_COUNT
Definition: data_buffer.h:54
void SelectiveGetFromDataBufHashList(unsigned int bufEntry)
Remove the given data buffer entry from the hash table.
Definition: data_buffer.c:349
struct _DATA_BUF_ENTRY * P_DATA_BUF_ENTRY
struct _TEMPORARY_DATA_BUF_ENTRY * P_TEMPORARY_DATA_BUF_ENTRY
P_TEMPORARY_DATA_BUF_MAP tempDataBufMapPtr
Definition: data_buffer.c:53
unsigned int CheckDataBufHit(unsigned int reqSlotTag)
Get the data buffer entry index of the given request.
Definition: data_buffer.c:127
struct _DATA_BUF_HASH_ENTRY DATA_BUF_HASH_ENTRY
The structure of data buffer bucket that records the head and tail data buffer entry index in the buc...
P_DATA_BUF_MAP dataBufMapPtr
Definition: data_buffer.c:50
struct _TEMPORARY_DATA_BUF_MAP * P_TEMPORARY_DATA_BUF_MAP
struct _DATA_BUF_MAP DATA_BUF_MAP
The structure of data buffer table.
DATA_BUF_LRU_LIST dataBufLruList
Definition: data_buffer.c:51
unsigned int AllocateDataBuf()
Retrieve a LRU data buffer entry from the LRU list.
Definition: data_buffer.c:220
#define AVAILABLE_TEMPORARY_DATA_BUFFER_ENTRY_COUNT
Definition: data_buffer.h:55
The structure of the data buffer entry.
Definition: data_buffer.h:103
unsigned int nextEntry
Definition: data_buffer.h:106
unsigned int dirty
Definition: data_buffer.h:110
unsigned int hashNextEntry
Definition: data_buffer.h:109
unsigned int prevEntry
Definition: data_buffer.h:105
unsigned int reserved0
Definition: data_buffer.h:111
unsigned int hashPrevEntry
Definition: data_buffer.h:108
unsigned int blockingReqTail
Definition: data_buffer.h:107
unsigned int logicalSliceAddr
Definition: data_buffer.h:104
The structure of data buffer bucket that records the head and tail data buffer entry index in the buc...
Definition: data_buffer.h:148
unsigned int headEntry
Definition: data_buffer.h:149
unsigned int tailEntry
Definition: data_buffer.h:150
The structure of data buffer hash table.
Definition: data_buffer.h:160
DATA_BUF_HASH_ENTRY dataBufHash[AVAILABLE_DATA_BUFFER_ENTRY_COUNT]
Definition: data_buffer.h:161
The structure of LRU list that records the head and tail data buffer entry index of the LRU list.
Definition: data_buffer.h:134
unsigned int headEntry
Definition: data_buffer.h:135
unsigned int tailEntry
Definition: data_buffer.h:136
The structure of data buffer table.
Definition: data_buffer.h:121
DATA_BUF_ENTRY dataBuf[AVAILABLE_DATA_BUFFER_ENTRY_COUNT]
Definition: data_buffer.h:122
Definition: data_buffer.h:165
unsigned int blockingReqTail
Definition: data_buffer.h:166
unsigned int reserved0
Definition: data_buffer.h:167
The structure of the temp data buffer table.
Definition: data_buffer.h:178
TEMPORARY_DATA_BUF_ENTRY tempDataBuf[AVAILABLE_TEMPORARY_DATA_BUFFER_ENTRY_COUNT]
Definition: data_buffer.h:179