memory: replace all hardcoded 0x200000 with a define
Makes the code slightly more readable. Change-Id: Iebf8fb07bceacf433d4bdad0a30419a3faab7eee Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/439370 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3edc4db7a7
commit
eecc6dc8e6
@ -617,8 +617,8 @@ spdk_ioat_submit_copy(struct spdk_ioat_chan *ioat, void *cb_arg, spdk_ioat_req_c
|
||||
pdst_page = spdk_vtophys((void *)vdst_page, NULL);
|
||||
}
|
||||
op_size = remaining;
|
||||
op_size = spdk_min(op_size, (0x200000 - _2MB_OFFSET(vsrc)));
|
||||
op_size = spdk_min(op_size, (0x200000 - _2MB_OFFSET(vdst)));
|
||||
op_size = spdk_min(op_size, (VALUE_2MB - _2MB_OFFSET(vsrc)));
|
||||
op_size = spdk_min(op_size, (VALUE_2MB - _2MB_OFFSET(vdst)));
|
||||
op_size = spdk_min(op_size, ioat->max_xfer_size);
|
||||
remaining -= op_size;
|
||||
|
||||
@ -681,7 +681,7 @@ spdk_ioat_submit_fill(struct spdk_ioat_chan *ioat, void *cb_arg, spdk_ioat_req_c
|
||||
|
||||
while (remaining) {
|
||||
op_size = remaining;
|
||||
op_size = spdk_min(op_size, (0x200000 - _2MB_OFFSET(vdst)));
|
||||
op_size = spdk_min(op_size, (VALUE_2MB - _2MB_OFFSET(vdst)));
|
||||
op_size = spdk_min(op_size, ioat->max_xfer_size);
|
||||
remaining -= op_size;
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
|
||||
#include "spdk_internal/assert.h"
|
||||
#include "spdk_internal/log.h"
|
||||
#include "spdk_internal/memory.h"
|
||||
|
||||
extern pid_t g_spdk_nvme_pid;
|
||||
|
||||
@ -137,7 +138,7 @@ extern pid_t g_spdk_nvme_pid;
|
||||
/* We want to fit submission and completion rings each in a single 2MB
|
||||
* hugepage to ensure physical address contiguity.
|
||||
*/
|
||||
#define MAX_IO_QUEUE_ENTRIES (0x200000 / spdk_max( \
|
||||
#define MAX_IO_QUEUE_ENTRIES (VALUE_2MB / spdk_max( \
|
||||
sizeof(struct spdk_nvme_cmd), \
|
||||
sizeof(struct spdk_nvme_cpl)))
|
||||
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "nvme_internal.h"
|
||||
#include "nvme_uevent.h"
|
||||
|
||||
#include "spdk_internal/memory.h"
|
||||
|
||||
/*
|
||||
* Number of completion queue entries to process before ringing the
|
||||
* completion queue doorbell.
|
||||
@ -516,9 +514,8 @@ nvme_pcie_ctrlr_map_cmb(struct nvme_pcie_ctrlr *pctrlr)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mem_register_start = (((uintptr_t)pctrlr->cmb_bar_virt_addr + offset + 0x1fffff) & ~(0x200000 - 1));
|
||||
mem_register_end = ((uintptr_t)pctrlr->cmb_bar_virt_addr + offset + pctrlr->cmb_size);
|
||||
mem_register_end &= ~(uint64_t)(0x200000 - 1);
|
||||
mem_register_start = _2MB_PAGE((uintptr_t)pctrlr->cmb_bar_virt_addr + offset + VALUE_2MB - 1);
|
||||
mem_register_end = _2MB_PAGE((uintptr_t)pctrlr->cmb_bar_virt_addr + offset + pctrlr->cmb_size);
|
||||
pctrlr->cmb_mem_register_addr = (void *)mem_register_start;
|
||||
pctrlr->cmb_mem_register_size = mem_register_end - mem_register_start;
|
||||
|
||||
@ -977,7 +974,7 @@ nvme_pcie_qpair_construct(struct spdk_nvme_qpair *qpair)
|
||||
volatile uint32_t *doorbell_base;
|
||||
uint64_t offset;
|
||||
uint16_t num_trackers;
|
||||
size_t page_align = 0x200000;
|
||||
size_t page_align = VALUE_2MB;
|
||||
uint32_t flags = SPDK_MALLOC_DMA;
|
||||
|
||||
/*
|
||||
@ -1827,7 +1824,7 @@ nvme_pcie_qpair_build_hw_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_
|
||||
return -1;
|
||||
}
|
||||
|
||||
length = spdk_min(remaining_user_sge_len, 0x200000 - _2MB_OFFSET(virt_addr));
|
||||
length = spdk_min(remaining_user_sge_len, VALUE_2MB - _2MB_OFFSET(virt_addr));
|
||||
remaining_user_sge_len -= length;
|
||||
virt_addr += length;
|
||||
|
||||
|
@ -479,7 +479,7 @@ spdk_vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *
|
||||
SPDK_ERRLOG("gpa_to_vva(%p) == NULL\n", (void *)payload);
|
||||
return -1;
|
||||
}
|
||||
to_boundary = 0x200000 - _2MB_OFFSET(payload);
|
||||
to_boundary = VALUE_2MB - _2MB_OFFSET(payload);
|
||||
if (spdk_likely(remaining <= to_boundary)) {
|
||||
len = remaining;
|
||||
} else {
|
||||
@ -496,7 +496,7 @@ spdk_vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *
|
||||
if (vva + len != (uintptr_t)rte_vhost_gpa_to_vva(vsession->mem, payload + len)) {
|
||||
break;
|
||||
}
|
||||
len += spdk_min(remaining - len, 0x200000);
|
||||
len += spdk_min(remaining - len, VALUE_2MB);
|
||||
}
|
||||
}
|
||||
iov[*iov_index].iov_base = (void *)vva;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include "spdk_internal/virtio.h"
|
||||
#include "spdk_internal/memory.h"
|
||||
|
||||
struct virtio_hw {
|
||||
uint8_t use_msix;
|
||||
@ -268,11 +269,11 @@ modern_setup_queue(struct virtio_dev *dev, struct virtqueue *vq)
|
||||
* only a single hugepage (2MB). As of Virtio 1.0, the queue size
|
||||
* always falls within this limit.
|
||||
*/
|
||||
if (vq->vq_ring_size > 0x200000) {
|
||||
if (vq->vq_ring_size > VALUE_2MB) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
queue_mem = spdk_dma_zmalloc(vq->vq_ring_size, 0x200000, &queue_mem_phys_addr);
|
||||
queue_mem = spdk_dma_zmalloc(vq->vq_ring_size, VALUE_2MB, &queue_mem_phys_addr);
|
||||
if (queue_mem == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include "spdk/crc16.h"
|
||||
#include "spdk/endian.h"
|
||||
|
||||
#include "spdk_internal/memory.h"
|
||||
|
||||
#define MAX_DEVS 64
|
||||
|
||||
#define DATA_PATTERN 0x5A
|
||||
@ -146,7 +148,7 @@ static uint32_t dp_guard_check_extended_lba_test(struct spdk_nvme_ns *ns, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->lba = 0x200000;
|
||||
req->lba = VALUE_2MB;
|
||||
req->use_extended_lba = true;
|
||||
req->use_sgl = true;
|
||||
req->buf_size = (sector_size + md_size) * req->lba_count;
|
||||
@ -232,7 +234,7 @@ static uint32_t dp_without_pract_extended_lba_test(struct spdk_nvme_ns *ns, stru
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->lba = 0x200000;
|
||||
req->lba = VALUE_2MB;
|
||||
req->use_extended_lba = true;
|
||||
req->metadata = NULL;
|
||||
pi = (struct spdk_nvme_protection_info *)(req->contig + sector_size + md_size - 8);
|
||||
|
Loading…
Reference in New Issue
Block a user