No longer wrap assert()
assert is part of the C standard library and is available on any platform we'd consider porting to. Don't put a wrapper around it. Change-Id: I0acfdd6a8a269d6c37df38fb7ddf4f1227630223 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
888014289c
commit
0606eaad1a
@ -201,7 +201,7 @@ ioat_prep_copy(struct spdk_ioat_chan *ioat, uint64_t dst,
|
|||||||
struct ioat_descriptor *desc;
|
struct ioat_descriptor *desc;
|
||||||
union spdk_ioat_hw_desc *hw_desc;
|
union spdk_ioat_hw_desc *hw_desc;
|
||||||
|
|
||||||
ioat_assert(len <= ioat->max_xfer_size);
|
assert(len <= ioat->max_xfer_size);
|
||||||
|
|
||||||
if (ioat_get_ring_space(ioat) < 1) {
|
if (ioat_get_ring_space(ioat) < 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -232,7 +232,7 @@ ioat_prep_fill(struct spdk_ioat_chan *ioat, uint64_t dst,
|
|||||||
struct ioat_descriptor *desc;
|
struct ioat_descriptor *desc;
|
||||||
union spdk_ioat_hw_desc *hw_desc;
|
union spdk_ioat_hw_desc *hw_desc;
|
||||||
|
|
||||||
ioat_assert(len <= ioat->max_xfer_size);
|
assert(len <= ioat->max_xfer_size);
|
||||||
|
|
||||||
if (ioat_get_ring_space(ioat) < 1) {
|
if (ioat_get_ring_space(ioat) < 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef __IOAT_IMPL_H__
|
#ifndef __IOAT_IMPL_H__
|
||||||
#define __IOAT_IMPL_H__
|
#define __IOAT_IMPL_H__
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -11,6 +10,7 @@
|
|||||||
#include <rte_atomic.h>
|
#include <rte_atomic.h>
|
||||||
#include <rte_cycles.h>
|
#include <rte_cycles.h>
|
||||||
|
|
||||||
|
#include "spdk/assert.h"
|
||||||
#include "spdk/pci.h"
|
#include "spdk/pci.h"
|
||||||
#include "spdk/vtophys.h"
|
#include "spdk/vtophys.h"
|
||||||
#include "spdk/pci.h"
|
#include "spdk/pci.h"
|
||||||
@ -64,12 +64,6 @@ ioat_zmalloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
|
|||||||
*/
|
*/
|
||||||
#define ioat_delay_us(us) rte_delay_us(us)
|
#define ioat_delay_us(us) rte_delay_us(us)
|
||||||
|
|
||||||
/**
|
|
||||||
* Assert a condition and panic/abort as desired. Failures of these
|
|
||||||
* assertions indicate catastrophic failures within the driver.
|
|
||||||
*/
|
|
||||||
#define ioat_assert(check) assert(check)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log or print a message from the driver.
|
* Log or print a message from the driver.
|
||||||
*/
|
*/
|
||||||
|
@ -150,8 +150,8 @@ nvme_allocate_request_null(spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
|||||||
void
|
void
|
||||||
nvme_free_request(struct nvme_request *req)
|
nvme_free_request(struct nvme_request *req)
|
||||||
{
|
{
|
||||||
nvme_assert(req != NULL, ("nvme_free_request(NULL)\n"));
|
assert(req != NULL);
|
||||||
nvme_assert(req->num_children == 0, ("num_children != 0\n"));
|
assert(req->num_children == 0);
|
||||||
|
|
||||||
nvme_dealloc_request(req);
|
nvme_dealloc_request(req);
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
nvme_assert(0, ("unhandled ctrlr state %d\n", ctrlr->state));
|
assert(0);
|
||||||
nvme_ctrlr_fail(ctrlr);
|
nvme_ctrlr_fail(ctrlr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -104,12 +104,6 @@ nvme_malloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
|
|||||||
*/
|
*/
|
||||||
#define nvme_printf(ctrlr, fmt, args...) printf(fmt, ##args)
|
#define nvme_printf(ctrlr, fmt, args...) printf(fmt, ##args)
|
||||||
|
|
||||||
/**
|
|
||||||
* Assert a condition and panic/abort as desired. Failures of these
|
|
||||||
* assertions indicate catastrophic failures within the driver.
|
|
||||||
*/
|
|
||||||
#define nvme_assert(check, str) assert(check)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the physical address for the specified virtual address.
|
* Return the physical address for the specified virtual address.
|
||||||
*/
|
*/
|
||||||
|
@ -176,7 +176,7 @@ int nvme_ns_construct(struct spdk_nvme_ns *ns, uint16_t id,
|
|||||||
{
|
{
|
||||||
uint32_t pci_devid;
|
uint32_t pci_devid;
|
||||||
|
|
||||||
nvme_assert(id > 0, ("invalid namespace id %d", id));
|
assert(id > 0);
|
||||||
|
|
||||||
ns->ctrlr = ctrlr;
|
ns->ctrlr = ctrlr;
|
||||||
ns->id = id;
|
ns->id = id;
|
||||||
|
@ -84,10 +84,10 @@ nvme_request_add_child(struct nvme_request *parent, struct nvme_request *child)
|
|||||||
void
|
void
|
||||||
nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child)
|
nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child)
|
||||||
{
|
{
|
||||||
nvme_assert(parent != NULL, ("parent == NULL\n"));
|
assert(parent != NULL);
|
||||||
nvme_assert(child != NULL, ("child == NULL\n"));
|
assert(child != NULL);
|
||||||
nvme_assert(child->parent == parent, ("child->parent != parent\n"));
|
assert(child->parent == parent);
|
||||||
nvme_assert(parent->num_children != 0, ("num_children == 0\n"));
|
assert(parent->num_children != 0);
|
||||||
|
|
||||||
parent->num_children--;
|
parent->num_children--;
|
||||||
TAILQ_REMOVE(&parent->children, child, child_tailq);
|
TAILQ_REMOVE(&parent->children, child, child_tailq);
|
||||||
|
@ -115,8 +115,8 @@ static void
|
|||||||
nvme_io_qpair_print_command(struct spdk_nvme_qpair *qpair,
|
nvme_io_qpair_print_command(struct spdk_nvme_qpair *qpair,
|
||||||
struct spdk_nvme_cmd *cmd)
|
struct spdk_nvme_cmd *cmd)
|
||||||
{
|
{
|
||||||
nvme_assert(qpair != NULL, ("print_command: qpair == NULL\n"));
|
assert(qpair != NULL);
|
||||||
nvme_assert(cmd != NULL, ("print_command: cmd == NULL\n"));
|
assert(cmd != NULL);
|
||||||
switch ((int)cmd->opc) {
|
switch ((int)cmd->opc) {
|
||||||
case SPDK_NVME_OPC_WRITE:
|
case SPDK_NVME_OPC_WRITE:
|
||||||
case SPDK_NVME_OPC_READ:
|
case SPDK_NVME_OPC_READ:
|
||||||
@ -146,8 +146,8 @@ nvme_io_qpair_print_command(struct spdk_nvme_qpair *qpair,
|
|||||||
static void
|
static void
|
||||||
nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd)
|
nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd)
|
||||||
{
|
{
|
||||||
nvme_assert(qpair != NULL, ("qpair can not be NULL"));
|
assert(qpair != NULL);
|
||||||
nvme_assert(cmd != NULL, ("cmd can not be NULL"));
|
assert(cmd != NULL);
|
||||||
|
|
||||||
if (nvme_qpair_is_admin_queue(qpair)) {
|
if (nvme_qpair_is_admin_queue(qpair)) {
|
||||||
nvme_admin_qpair_print_command(qpair, cmd);
|
nvme_admin_qpair_print_command(qpair, cmd);
|
||||||
@ -369,7 +369,7 @@ nvme_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_tracker *
|
|||||||
|
|
||||||
req = tr->req;
|
req = tr->req;
|
||||||
|
|
||||||
nvme_assert(req != NULL, ("tr has NULL req\n"));
|
assert(req != NULL);
|
||||||
|
|
||||||
error = spdk_nvme_cpl_is_error(cpl);
|
error = spdk_nvme_cpl_is_error(cpl);
|
||||||
retry = error && nvme_completion_is_retry(cpl) &&
|
retry = error && nvme_completion_is_retry(cpl) &&
|
||||||
@ -382,7 +382,7 @@ nvme_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_tracker *
|
|||||||
|
|
||||||
qpair->tr[cpl->cid].active = false;
|
qpair->tr[cpl->cid].active = false;
|
||||||
|
|
||||||
nvme_assert(cpl->cid == req->cmd.cid, ("cpl cid does not match cmd cid\n"));
|
assert(cpl->cid == req->cmd.cid);
|
||||||
|
|
||||||
if (retry) {
|
if (retry) {
|
||||||
req->retries++;
|
req->retries++;
|
||||||
@ -506,7 +506,7 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
|
|||||||
nvme_printf(qpair->ctrlr,
|
nvme_printf(qpair->ctrlr,
|
||||||
"cpl does not map to outstanding cmd\n");
|
"cpl does not map to outstanding cmd\n");
|
||||||
nvme_qpair_print_completion(qpair, cpl);
|
nvme_qpair_print_completion(qpair, cpl);
|
||||||
nvme_assert(0, ("received completion for unknown cmd\n"));
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++qpair->cq_head == qpair->num_entries) {
|
if (++qpair->cq_head == qpair->num_entries) {
|
||||||
@ -537,8 +537,8 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
|
|||||||
uint64_t phys_addr = 0;
|
uint64_t phys_addr = 0;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
|
|
||||||
nvme_assert(num_entries != 0, ("invalid num_entries\n"));
|
assert(num_entries != 0);
|
||||||
nvme_assert(num_trackers != 0, ("invalid num_trackers\n"));
|
assert(num_trackers != 0);
|
||||||
|
|
||||||
qpair->id = id;
|
qpair->id = id;
|
||||||
qpair->num_entries = num_entries;
|
qpair->num_entries = num_entries;
|
||||||
@ -617,7 +617,7 @@ nvme_admin_qpair_abort_aers(struct spdk_nvme_qpair *qpair)
|
|||||||
|
|
||||||
tr = LIST_FIRST(&qpair->outstanding_tr);
|
tr = LIST_FIRST(&qpair->outstanding_tr);
|
||||||
while (tr != NULL) {
|
while (tr != NULL) {
|
||||||
nvme_assert(tr->req != NULL, ("tr->req == NULL in abort_aers\n"));
|
assert(tr->req != NULL);
|
||||||
if (tr->req->cmd.opc == SPDK_NVME_OPC_ASYNC_EVENT_REQUEST) {
|
if (tr->req->cmd.opc == SPDK_NVME_OPC_ASYNC_EVENT_REQUEST) {
|
||||||
nvme_qpair_manual_complete_tracker(qpair, tr,
|
nvme_qpair_manual_complete_tracker(qpair, tr,
|
||||||
SPDK_NVME_SCT_GENERIC, SPDK_NVME_SC_ABORTED_SQ_DELETION, 0,
|
SPDK_NVME_SCT_GENERIC, SPDK_NVME_SC_ABORTED_SQ_DELETION, 0,
|
||||||
@ -741,10 +741,10 @@ _nvme_qpair_build_hw_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_requ
|
|||||||
/*
|
/*
|
||||||
* Build scattered payloads.
|
* Build scattered payloads.
|
||||||
*/
|
*/
|
||||||
nvme_assert(req->payload_size != 0, ("cannot build SGL for zero-length transfer\n"));
|
assert(req->payload_size != 0);
|
||||||
nvme_assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL, ("sgl payload type required\n"));
|
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||||
nvme_assert(req->payload.u.sgl.reset_sgl_fn != NULL, ("sgl reset callback required\n"));
|
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
|
||||||
nvme_assert(req->payload.u.sgl.next_sge_fn != NULL, ("sgl callback required\n"));
|
assert(req->payload.u.sgl.next_sge_fn != NULL);
|
||||||
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
||||||
|
|
||||||
sgl = tr->u.sgl;
|
sgl = tr->u.sgl;
|
||||||
@ -814,8 +814,8 @@ _nvme_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_re
|
|||||||
/*
|
/*
|
||||||
* Build scattered payloads.
|
* Build scattered payloads.
|
||||||
*/
|
*/
|
||||||
nvme_assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL, ("sgl payload type required\n"));
|
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||||
nvme_assert(req->payload.u.sgl.reset_sgl_fn != NULL, ("sgl reset callback required\n"));
|
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
|
||||||
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
||||||
|
|
||||||
remaining_transfer_len = req->payload_size;
|
remaining_transfer_len = req->payload_size;
|
||||||
@ -823,7 +823,7 @@ _nvme_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_re
|
|||||||
last_nseg = 0;
|
last_nseg = 0;
|
||||||
|
|
||||||
while (remaining_transfer_len > 0) {
|
while (remaining_transfer_len > 0) {
|
||||||
nvme_assert(req->payload.u.sgl.next_sge_fn != NULL, ("sgl callback required\n"));
|
assert(req->payload.u.sgl.next_sge_fn != NULL);
|
||||||
rc = req->payload.u.sgl.next_sge_fn(req->payload.u.sgl.cb_arg, &phys_addr, &length);
|
rc = req->payload.u.sgl.next_sge_fn(req->payload.u.sgl.cb_arg, &phys_addr, &length);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
_nvme_fail_request_bad_vtophys(qpair, tr);
|
_nvme_fail_request_bad_vtophys(qpair, tr);
|
||||||
@ -958,7 +958,7 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nvme_assert(0, ("invalid NVMe payload type %d\n", req->payload.type));
|
assert(0);
|
||||||
_nvme_fail_request_bad_vtophys(qpair, tr);
|
_nvme_fail_request_bad_vtophys(qpair, tr);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ ioat_zmalloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
|
|||||||
#define ioat_free(buf) free(buf)
|
#define ioat_free(buf) free(buf)
|
||||||
#define ioat_vtophys(buf) (uint64_t)(buf)
|
#define ioat_vtophys(buf) (uint64_t)(buf)
|
||||||
#define ioat_delay_us(us) ioat_noop()
|
#define ioat_delay_us(us) ioat_noop()
|
||||||
#define ioat_assert(check) assert(check)
|
|
||||||
#define ioat_printf(chan, fmt, args...) printf(fmt, ##args)
|
#define ioat_printf(chan, fmt, args...) printf(fmt, ##args)
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -61,15 +61,6 @@ extern char outbuf[OUTBUF_SIZE];
|
|||||||
#define nvme_printf(ctrlr, fmt, args...) snprintf(outbuf, OUTBUF_SIZE, fmt, ##args)
|
#define nvme_printf(ctrlr, fmt, args...) snprintf(outbuf, OUTBUF_SIZE, fmt, ##args)
|
||||||
#define nvme_get_num_ioq() 8
|
#define nvme_get_num_ioq() 8
|
||||||
#define nvme_get_ioq_idx() 0
|
#define nvme_get_ioq_idx() 0
|
||||||
#define nvme_assert(check, str) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if (!(check)) { \
|
|
||||||
printf str; \
|
|
||||||
assert(check); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
while (0)
|
|
||||||
|
|
||||||
uint64_t nvme_vtophys(void *buf);
|
uint64_t nvme_vtophys(void *buf);
|
||||||
#define NVME_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL)
|
#define NVME_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user