Skip to content

Commit 1c2d358

Browse files
committed
Fix compilation issues (#150); More todo
1 parent 0326ab4 commit 1c2d358

3 files changed

Lines changed: 54 additions & 53 deletions

File tree

femu-scripts/pkgdep.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SYSTEM=`uname -s`
66

77
if [[ -f /etc/debian_version ]]; then
88
# Includes Ubuntu, Debian
9-
apt-get install -y gcc pkg-config git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev
9+
apt-get install -y gcc pkg-config git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libdw-dev
1010
apt-get install -y libaio-dev libslirp-dev
1111

1212
# Additional dependencies

hw/femu/zns/zftl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static uint64_t zns_read(struct zns_ssd *zns, NvmeRequest *req)
174174
uint64_t secs_per_pg = LOGICAL_PAGE_SIZE/zns->lbasz;
175175
uint64_t start_lpn = lba / secs_per_pg;
176176
uint64_t end_lpn = (lba + nlb - 1) / secs_per_pg;
177-
int wcidx = zns_get_wcidx(zns);
177+
//int wcidx = zns_get_wcidx(zns);
178178
struct ppa ppa;
179179
uint64_t lpn;
180180
uint64_t sublat, maxlat = 0;
@@ -201,13 +201,13 @@ static uint64_t zns_read(struct zns_ssd *zns, NvmeRequest *req)
201201

202202
static uint64_t zns_wc_flush(struct zns_ssd* zns, int wcidx, int type,uint64_t stime)
203203
{
204-
int r,i,j,p,subpage;
204+
int i,j,p,subpage;
205205
struct ppa ppa;
206206
struct ppa oldppa;
207207
uint64_t lpn;
208208
int flash_type = zns->flash_type;
209209
uint64_t sublat = 0, maxlat = 0;
210-
210+
211211
i = 0;
212212
while(i < zns->cache.write_cache[wcidx].used)
213213
{
@@ -291,20 +291,20 @@ static uint64_t zns_write(struct zns_ssd *zns, NvmeRequest *req)
291291
if(t_used) maxlat = zns_wc_flush(zns,wcidx,USER_IO,req->stime);
292292
zns->cache.write_cache[wcidx].sblk = zns->active_zone;
293293
}
294-
294+
295295
for (lpn = start_lpn; lpn <= end_lpn; lpn++) {
296296
if(zns->cache.write_cache[wcidx].used==zns->cache.write_cache[wcidx].cap)
297297
{
298-
femu_log("[W] flush wc %d (%u/%u)\n",wcidx,zns->cache.write_cache[wcidx].used,zns->cache.write_cache[wcidx].cap);
298+
femu_log("[W] flush wc %d (%u/%u)\n",wcidx,(int)zns->cache.write_cache[wcidx].used,(int)zns->cache.write_cache[wcidx].cap);
299299
sublat = zns_wc_flush(zns,wcidx,USER_IO,req->stime);
300-
femu_log("[W] flush lat: %u\n",sublat);
300+
femu_log("[W] flush lat: %u\n", (int)sublat);
301301
maxlat = (sublat > maxlat) ? sublat : maxlat;
302302
sublat = 0;
303303
}
304304
zns->cache.write_cache[wcidx].lpns[zns->cache.write_cache[wcidx].used++]=lpn;
305305
sublat += SRAM_WRITE_LATENCY_NS; //Simplified timing emulation
306306
maxlat = (sublat > maxlat) ? sublat : maxlat;
307-
femu_log("[W] lpn:\t%lu\t-->wc cache:%u, used:%u\n",lpn,wcidx,zns->cache.write_cache[wcidx].used);
307+
femu_log("[W] lpn:\t%lu\t-->wc cache:%u, used:%u\n",lpn,(int)wcidx,(int)zns->cache.write_cache[wcidx].used);
308308
}
309309
return maxlat;
310310
}

hw/femu/zns/zns.c

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,6 @@ struct zns_zone_reset_ctx {
505505
static void zns_aio_zone_reset_cb(NvmeRequest *req, NvmeZone *zone)
506506
{
507507
NvmeNamespace *ns = req->ns;
508-
FemuCtrl *n = ns->ctrl;
509-
int ch, lun;
510508

511509
/* FIXME, We always assume reset SUCCESS */
512510
switch (zns_get_zone_state(zone)) {
@@ -526,11 +524,14 @@ static void zns_aio_zone_reset_cb(NvmeRequest *req, NvmeZone *zone)
526524
break;
527525
}
528526

527+
#if 0
528+
FemuCtrl *n = ns->ctrl;
529+
int ch, lun;
529530
struct zns_ssd *zns = n->zns;
530531
uint64_t num_ch = zns->num_ch;
531532
uint64_t num_lun = zns->num_lun;
532-
struct ppa ppa;
533533

534+
struct ppa ppa;
534535
for (ch = 0; ch < num_ch; ch++) {
535536
for (lun = 0; lun < num_lun; lun++) {
536537
ppa.g.ch = ch;
@@ -539,6 +540,7 @@ static void zns_aio_zone_reset_cb(NvmeRequest *req, NvmeZone *zone)
539540
//FIXME: no erase
540541
}
541542
}
543+
#endif
542544
}
543545

544546
typedef uint16_t (*op_handler_t)(NvmeNamespace *, NvmeZone *, NvmeZoneState,
@@ -796,6 +798,38 @@ static uint16_t zns_get_mgmt_zone_slba_idx(FemuCtrl *n, NvmeCmd *c,
796798
return NVME_SUCCESS;
797799
}
798800

801+
static inline uint16_t zns_check_bounds(NvmeNamespace *ns, uint64_t slba,
802+
uint32_t nlb)
803+
{
804+
uint64_t nsze = le64_to_cpu(ns->id_ns.nsze);
805+
806+
if (unlikely(UINT64_MAX - slba < nlb || slba + nlb > nsze)) {
807+
return NVME_LBA_RANGE | NVME_DNR;
808+
}
809+
810+
return NVME_SUCCESS;
811+
}
812+
813+
static uint16_t zns_check_dulbe(NvmeNamespace *ns, uint64_t slba, uint32_t nlb)
814+
{
815+
return NVME_SUCCESS;
816+
}
817+
818+
static uint16_t zns_map_dptr(FemuCtrl *n, size_t len, NvmeRequest *req)
819+
{
820+
uint64_t prp1, prp2;
821+
822+
switch (req->cmd.psdt) {
823+
case NVME_PSDT_PRP:
824+
prp1 = le64_to_cpu(req->cmd.dptr.prp1);
825+
prp2 = le64_to_cpu(req->cmd.dptr.prp2);
826+
827+
return nvme_map_prp(&req->qsg, &req->iov, prp1, prp2, len, n);
828+
default:
829+
return NVME_INVALID_FIELD;
830+
}
831+
}
832+
799833
/*Misao: backend read/write without latency emulation*/
800834
static uint16_t zns_nvme_rw(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
801835
NvmeRequest *req,bool append)
@@ -849,15 +883,15 @@ static uint16_t zns_nvme_rw(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
849883
}
850884

851885
/* Misao
852-
Deallocated or Unwritten Logical Block Error (DULBE) is an option on NVMe drives that allows a storage array to deallocate blocks that are part of a volume. Deallocating blocks on a drive can greatly reduce the time it takes to initialize volumes. In addition, hosts can deallocate logical blocks in the volume using the NVMe Dataset Management command.
886+
Deallocated or Unwritten Logical Block Error (DULBE) is an option on
887+
NVMe drives that allows a storage array to deallocate blocks that are
888+
part of a volume. Deallocating blocks on a drive can greatly reduce
889+
the time it takes to initialize volumes. In addition, hosts can
890+
deallocate logical blocks in the volume using the NVMe Dataset
891+
Management command.
853892
*/
854-
if (NVME_ERR_REC_DULBE(n->features.err_rec)) {
855-
status = zns_check_dulbe(ns, slba, nlb);
856-
if (status) {
857-
goto err;
858-
}
859-
}
860-
}
893+
if (NVME_ERR_REC_DULBE(n->features.err_rec)) { status =
894+
zns_check_dulbe(ns, slba, nlb); if (status) { goto err; } } }
861895

862896
data_offset = zns_l2b(ns, slba);
863897
status = zns_map_dptr(n, data_size, req);
@@ -1123,34 +1157,6 @@ static inline bool nvme_csi_has_nvm_support(NvmeNamespace *ns)
11231157
return false;
11241158
}
11251159

1126-
static inline uint16_t zns_check_bounds(NvmeNamespace *ns, uint64_t slba,
1127-
uint32_t nlb)
1128-
{
1129-
uint64_t nsze = le64_to_cpu(ns->id_ns.nsze);
1130-
1131-
if (unlikely(UINT64_MAX - slba < nlb || slba + nlb > nsze)) {
1132-
return NVME_LBA_RANGE | NVME_DNR;
1133-
}
1134-
1135-
return NVME_SUCCESS;
1136-
}
1137-
1138-
static uint16_t zns_map_dptr(FemuCtrl *n, size_t len, NvmeRequest *req)
1139-
{
1140-
uint64_t prp1, prp2;
1141-
1142-
switch (req->cmd.psdt) {
1143-
case NVME_PSDT_PRP:
1144-
prp1 = le64_to_cpu(req->cmd.dptr.prp1);
1145-
prp2 = le64_to_cpu(req->cmd.dptr.prp2);
1146-
1147-
return nvme_map_prp(&req->qsg, &req->iov, prp1, prp2, len, n);
1148-
default:
1149-
return NVME_INVALID_FIELD;
1150-
}
1151-
}
1152-
1153-
11541160
static uint16_t zns_admin_cmd(FemuCtrl *n, NvmeCmd *cmd)
11551161
{
11561162
switch (cmd->opcode) {
@@ -1159,11 +1165,6 @@ static uint16_t zns_admin_cmd(FemuCtrl *n, NvmeCmd *cmd)
11591165
}
11601166
}
11611167

1162-
static uint16_t zns_check_dulbe(NvmeNamespace *ns, uint64_t slba, uint32_t nlb)
1163-
{
1164-
return NVME_SUCCESS;
1165-
}
1166-
11671168
static uint16_t zns_io_cmd(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
11681169
NvmeRequest *req)
11691170
{
@@ -1283,7 +1284,7 @@ static void zns_init_params(FemuCtrl *n)
12831284
femu_log("| ZMS HW Configuration() |\n");
12841285
femu_log("===========================================\n");
12851286
femu_log("|\tnchnl\t: %lu\t|\tchips per chnl\t: %lu\t|\tplanes per chip\t: %lu\t|\tblks per plane\t: %lu\t|\tpages per blk\t: %lu\t|\n",id_zns->num_ch,id_zns->num_lun,id_zns->num_plane,id_zns->num_blk,id_zns->num_page);
1286-
femu_log("|\tl2p sz\t: %lu\t|\tl2p cache sz\t: %u\t|\n",id_zns->l2p_sz,id_zns->cache.num_l2p_ent);
1287+
//femu_log("|\tl2p sz\t: %lu\t|\tl2p cache sz\t: %u\t|\n",id_zns->l2p_sz,id_zns->cache.num_l2p_ent);
12871288
femu_log("|\tprogram unit\t: %lu KiB\t|\tstripe unit\t: %lu KiB\t|\t# of write caches\t: %u\t|\t size of write caches (4KiB)\t: %lu\t|\n",id_zns->program_unit/(KiB),id_zns->stripe_uint/(KiB),id_zns->cache.num_wc,(id_zns->stripe_uint/LOGICAL_PAGE_SIZE));
12881289
femu_log("===========================================\n");
12891290

0 commit comments

Comments
 (0)