OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
nvme_identify.c
Go to the documentation of this file.
1
3// nvme_identify.c for Cosmos+ OpenSSD
4// Copyright (c) 2016 Hanyang University ENC Lab.
5// Contributed by Yong Ho Song <yhsong@enc.hanyang.ac.kr>
6// Youngjin Jo <yjjo@enc.hanyang.ac.kr>
7// Sangjin Lee <sjlee@enc.hanyang.ac.kr>
8//
9// This file is part of Cosmos+ OpenSSD.
10//
11// Cosmos+ OpenSSD is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 3, or (at your option)
14// any later version.
15//
16// Cosmos+ OpenSSD is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with Cosmos+ OpenSSD; see the file COPYING.
23// If not, see <http://www.gnu.org/licenses/>.
25
27// Company: ENC Lab. <http://enc.hanyang.ac.kr>
28// Engineer: Sangjin Lee <sjlee@enc.hanyang.ac.kr>
29//
30// Project Name: Cosmos+ OpenSSD
31// Design Name: Cosmos+ Firmware
32// Module Name: NVMe Identifier
33// File Name: nvme_identify.c
34//
35// Version: v1.0.1
36//
37// Description:
38// - generates data buffers that describes information about NVMe controller or namespace
40
42// Revision History:
43//
44// * v1.0.1
45// - Storage size (storageCapacity_L) is determined by FTL
46//
47// * v1.0.0
48// - First draft
50
51#include "xil_printf.h"
52#include "debug.h"
53#include "string.h"
54
55#include "nvme.h"
56#include "nvme_identify.h"
57#include "../ftl_config.h"
58
59void identify_controller(unsigned int pBuffer)
60{
61 ADMIN_IDENTIFY_CONTROLLER *identifyCNTL;
63
64 identifyCNTL = (ADMIN_IDENTIFY_CONTROLLER *)pBuffer;
65
66 memset(identifyCNTL, 0, sizeof(ADMIN_IDENTIFY_CONTROLLER));
67
68 identifyCNTL->VID = PCI_VENDOR_ID;
69 identifyCNTL->SSVID = PCI_SUBSYSTEM_VENDOR_ID;
70
71 memset(identifyCNTL->SN, 0x20, 20);
72 memcpy(identifyCNTL->SN, SERIAL_NUMBER, sizeof(SERIAL_NUMBER));
73
74 memset(identifyCNTL->MN, 0x20, 40);
75 memcpy(identifyCNTL->MN, MODEL_NUMBER, sizeof(MODEL_NUMBER));
76
77 memset(identifyCNTL->FR, 0x20, 8);
78 memcpy(identifyCNTL->FR, FIRMWARE_REVISION, sizeof(FIRMWARE_REVISION));
79
80 identifyCNTL->RAB = 0x0;
81 identifyCNTL->IEEE[0] = 0xE4;
82 identifyCNTL->IEEE[1] = 0xD2;
83 identifyCNTL->IEEE[2] = 0x5C;
84 identifyCNTL->CMIC = 0x0;
85 identifyCNTL->MDTS = 0x8;
86 identifyCNTL->CNTLID = 0x9;
87
88 identifyCNTL->OACS.supportsSecuritySendSecurityReceive = 0x0;
89 identifyCNTL->OACS.supportsFormatNVM = 0x0;
91
92 identifyCNTL->ACL = 0x3;
93 identifyCNTL->AERL = 0x3;
94
95 identifyCNTL->FRMW.firstFirmwareSlotReadOnly = 0x1;
96 identifyCNTL->FRMW.supportedNumberOfFirmwareSlots = 0x1;
97
99
100 identifyCNTL->ELPE = 0x8;
101 identifyCNTL->NPSS = 0x0;
102 identifyCNTL->AVSCC = 0x0;
103 identifyCNTL->APSTA = 0x0;
104
105 identifyCNTL->SQES.requiredSubmissionQueueEntrySize = 0x6;
106 identifyCNTL->SQES.maximumSubmissionQueueEntrySize = 0x6;
107
108 identifyCNTL->CQES.requiredCompletionQueueEntrySize = 0x4;
109 identifyCNTL->CQES.maximumCompletionQueueEntrySize = 0x4;
110
111 identifyCNTL->NN = 0x1;
112
113 identifyCNTL->ONCS.supportsCompare = 0x0;
114 identifyCNTL->ONCS.supportsWriteUncorrectable = 0x0;
115 identifyCNTL->ONCS.supportsDataSetManagement = 0x0;
116
117 identifyCNTL->FUSES.supportsCompareWrite = 0x0;
118
119 identifyCNTL->FNA.formatAppliesToAllNamespaces = 0x0;
120 identifyCNTL->FNA.secureEraseAppliesToAllNamespaces = 0x0;
121 identifyCNTL->FNA.supportsCryptographicErase = 0x0;
122
123 identifyCNTL->VWC.present = 0x1;
124
125 identifyCNTL->AWUN = 0x0;
126 identifyCNTL->AWUPF = 0x0;
127 identifyCNTL->NVSCC = 0x0;
128 identifyCNTL->ACWU = 0x0;
129
130 identifyCNTL->SGLS.supportsSGL = 0x0;
131 identifyCNTL->SGLS.supportsSGLBitBucketDescriptor = 0x0;
132
133 powerStateDesc = &identifyCNTL->PSDx[0];
134
135 powerStateDesc->MP = 0x09C4;
136 powerStateDesc->MPS = 0x0;
137 powerStateDesc->NOPS = 0x0;
138 powerStateDesc->ENLAT = 0x0;
139 powerStateDesc->EXLAT = 0x0;
140 powerStateDesc->RRT = 0x0;
141 powerStateDesc->RRL = 0x0;
142 powerStateDesc->RWT = 0x0;
143 powerStateDesc->RWL = 0x0;
144}
145
146void identify_namespace(unsigned int pBuffer)
147{
148 ADMIN_IDENTIFY_NAMESPACE *identifyNS;
149 ADMIN_IDENTIFY_FORMAT_DATA *formatData;
150 identifyNS = (ADMIN_IDENTIFY_NAMESPACE *)pBuffer;
151
152 memset(identifyNS, 0, sizeof(ADMIN_IDENTIFY_NAMESPACE));
153
154 identifyNS->NSZE[0] = storageCapacity_L;
155 identifyNS->NSZE[1] = STORAGE_CAPACITY_H;
156 identifyNS->NCAP[0] = storageCapacity_L;
157 identifyNS->NCAP[1] = STORAGE_CAPACITY_H;
158 identifyNS->NUSE[0] = storageCapacity_L;
159 identifyNS->NUSE[1] = STORAGE_CAPACITY_H;
160
161 identifyNS->NSFEAT.supportsThinProvisioning = 0x0;
162
163 identifyNS->NLBAF = 0x0;
164
165 identifyNS->FLBAS.supportedCombination = 0x0;
166 identifyNS->FLBAS.supportsMetadataAtEndOfLBA = 0x0;
167
168 identifyNS->MC.supportsMetadataAsPartOfLBA = 0x0;
169 identifyNS->MC.supportsMetadataAsSeperate = 0x0;
170
171 identifyNS->DPC.supportsProtectionType1 = 0x0;
172 identifyNS->DPC.supportsProtectionType2 = 0x0;
173 identifyNS->DPC.supportsProtectionType3 = 0x0;
174 identifyNS->DPC.supportsProtectionFirst8 = 0x0;
175 identifyNS->DPC.supportsProtectionLast8 = 0x0;
176
177 identifyNS->DPS.protectionEnabled = 0x0;
178 identifyNS->DPS.protectionInFirst8 = 0x0;
179
180 identifyNS->NMIC.supportsMultipathIOSharing = 0x0;
181
182 identifyNS->RESCAP.supportsPersistThroughPowerLoss = 0x0;
188
189 formatData = &identifyNS->LBAFx[0];
190
191 formatData->MS = 0x0;
192 formatData->LBADS = 0xC;
193 formatData->RP = 0x2;
194}
unsigned int storageCapacity_L
Definition: ftl_config.c:56
#define STORAGE_CAPACITY_H
Definition: nvme.h:60
void identify_controller(unsigned int pBuffer)
Definition: nvme_identify.c:59
void identify_namespace(unsigned int pBuffer)
#define MODEL_NUMBER
Definition: nvme_identify.h:54
#define FIRMWARE_REVISION
Definition: nvme_identify.h:55
#define SERIAL_NUMBER
Definition: nvme_identify.h:53
#define PCI_VENDOR_ID
Definition: nvme_identify.h:51
#define PCI_SUBSYSTEM_VENDOR_ID
Definition: nvme_identify.h:52
unsigned short supportsFirmwareActivateFirmwareDownload
Definition: nvme.h:582
struct _ADMIN_IDENTIFY_CONTROLLER::@129 LPA
unsigned char AERL
Definition: nvme.h:587
unsigned short CNTLID
Definition: nvme.h:575
struct _ADMIN_IDENTIFY_CONTROLLER::@128 FRMW
unsigned char NPSS
Definition: nvme.h:604
unsigned char APSTA
Definition: nvme.h:609
struct _ADMIN_IDENTIFY_CONTROLLER::@131 CQES
unsigned char NVSCC
Definition: nvme.h:660
unsigned short AWUPF
Definition: nvme.h:658
ADMIN_IDENTIFY_POWER_STATE_DESCRIPTOR PSDx[32]
Definition: nvme.h:680
unsigned char ACL
Definition: nvme.h:586
unsigned char supportsSMARTHealthInformationLogPage
Definition: nvme.h:598
unsigned int supportsSGLBitBucketDescriptor
Definition: nvme.h:673
unsigned short AWUN
Definition: nvme.h:657
unsigned char supportsCryptographicErase
Definition: nvme.h:647
unsigned short VID
Definition: nvme.h:566
struct _ADMIN_IDENTIFY_CONTROLLER::@130 SQES
struct _ADMIN_IDENTIFY_CONTROLLER::@133 FUSES
unsigned short supportsDataSetManagement
Definition: nvme.h:633
struct _ADMIN_IDENTIFY_CONTROLLER::@127 OACS
unsigned char IEEE[3]
Definition: nvme.h:572
unsigned char ELPE
Definition: nvme.h:603
unsigned char AVSCC
Definition: nvme.h:606
unsigned int supportsSGL
Definition: nvme.h:671
unsigned char supportedNumberOfFirmwareSlots
Definition: nvme.h:592
unsigned short ACWU
Definition: nvme.h:665
unsigned char maximumSubmissionQueueEntrySize
Definition: nvme.h:617
unsigned char RAB
Definition: nvme.h:571
unsigned short supportsFormatNVM
Definition: nvme.h:581
unsigned int NN
Definition: nvme.h:627
unsigned short supportsCompare
Definition: nvme.h:631
unsigned char present
Definition: nvme.h:653
unsigned char MDTS
Definition: nvme.h:574
struct _ADMIN_IDENTIFY_CONTROLLER::@135 VWC
unsigned char maximumCompletionQueueEntrySize
Definition: nvme.h:623
unsigned char firstFirmwareSlotReadOnly
Definition: nvme.h:591
unsigned char MN[40]
Definition: nvme.h:569
unsigned short supportsWriteUncorrectable
Definition: nvme.h:632
unsigned char secureEraseAppliesToAllNamespaces
Definition: nvme.h:646
unsigned char SN[20]
Definition: nvme.h:568
struct _ADMIN_IDENTIFY_CONTROLLER::@136 SGLS
unsigned short supportsSecuritySendSecurityReceive
Definition: nvme.h:580
struct _ADMIN_IDENTIFY_CONTROLLER::@132 ONCS
unsigned short supportsCompareWrite
Definition: nvme.h:639
unsigned char FR[8]
Definition: nvme.h:570
struct _ADMIN_IDENTIFY_CONTROLLER::@134 FNA
unsigned char CMIC
Definition: nvme.h:573
unsigned short SSVID
Definition: nvme.h:567
unsigned char requiredCompletionQueueEntrySize
Definition: nvme.h:622
unsigned char formatAppliesToAllNamespaces
Definition: nvme.h:645
unsigned char requiredSubmissionQueueEntrySize
Definition: nvme.h:616
unsigned char RP
Definition: nvme.h:691
unsigned char LBADS
Definition: nvme.h:690
unsigned short MS
Definition: nvme.h:689
struct _ADMIN_IDENTIFY_NAMESPACE::@141 DPS
unsigned int NSZE[2]
Definition: nvme.h:698
unsigned char supportsThinProvisioning
Definition: nvme.h:704
unsigned char supportsWriteExclusiveRegistrants
Definition: nvme.h:751
unsigned char protectionEnabled
Definition: nvme.h:736
unsigned char NLBAF
Definition: nvme.h:708
unsigned char supportsPersistThroughPowerLoss
Definition: nvme.h:749
unsigned int NUSE[2]
Definition: nvme.h:700
unsigned char supportedCombination
Definition: nvme.h:712
unsigned char supportsMetadataAtEndOfLBA
Definition: nvme.h:713
struct _ADMIN_IDENTIFY_NAMESPACE::@137 NSFEAT
unsigned char supportsWriteExclusiveReservation
Definition: nvme.h:750
unsigned char supportsExclusiveAccessAllRegistrants
Definition: nvme.h:754
unsigned int NCAP[2]
Definition: nvme.h:699
unsigned char supportsMultipathIOSharing
Definition: nvme.h:743
unsigned char supportsExclusiveAccessRegistrants
Definition: nvme.h:752
struct _ADMIN_IDENTIFY_NAMESPACE::@143 RESCAP
struct _ADMIN_IDENTIFY_NAMESPACE::@142 NMIC
unsigned char supportsProtectionType1
Definition: nvme.h:726
unsigned char supportsProtectionLast8
Definition: nvme.h:730
struct _ADMIN_IDENTIFY_NAMESPACE::@139 MC
unsigned char supportsMetadataAsSeperate
Definition: nvme.h:720
unsigned char supportsWriteExclusiveAllRegistrants
Definition: nvme.h:753
struct _ADMIN_IDENTIFY_NAMESPACE::@138 FLBAS
unsigned char protectionInFirst8
Definition: nvme.h:737
unsigned char supportsProtectionFirst8
Definition: nvme.h:729
ADMIN_IDENTIFY_FORMAT_DATA LBAFx[16]
Definition: nvme.h:761
unsigned char supportsProtectionType2
Definition: nvme.h:727
unsigned char supportsMetadataAsPartOfLBA
Definition: nvme.h:719
struct _ADMIN_IDENTIFY_NAMESPACE::@140 DPC
unsigned char supportsProtectionType3
Definition: nvme.h:728