libwd/0080-uadk-unify-wd-print-format.patch

993 lines
30 KiB
Diff
Raw Normal View History

From 61912fcfdef3b29e22731b38fbb81dff47102568 Mon Sep 17 00:00:00 2001
From: Wenkai Lin <linwenkai6@hisilicon.com>
Date: Thu, 10 Mar 2022 20:03:18 +0800
Subject: [PATCH 088/109] uadk: unify wd print format
Unify print format with following rules:
1. failed to do sth.
2. invalid: sth is NULL.
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
---
drv/hisi_qm_udrv.c | 63 ++++++++++++++++++------------------
wd.c | 6 ++--
wd_mempool.c | 61 ++++++++++++++++++++--------------
wd_sched.c | 52 ++++++++++++++---------------
wd_util.c | 81 ++++++++++++++++++++--------------------------
5 files changed, 130 insertions(+), 133 deletions(-)
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
index 906dfa3..be06570 100644
--- a/drv/hisi_qm_udrv.c
+++ b/drv/hisi_qm_udrv.c
@@ -167,14 +167,14 @@ static int hisi_qm_setup_region(handle_t h_ctx,
{
q_info->sq_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_DUS);
if (!q_info->sq_base) {
- WD_ERR("mmap dus fail\n");
+ WD_ERR("failed to mmap dus!\n");
return -WD_ENOMEM;
}
q_info->mmio_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_MMIO);
if (!q_info->mmio_base) {
wd_ctx_unmap_qfr(h_ctx, UACCE_QFRT_DUS);
- WD_ERR("mmap mmio fail\n");
+ WD_ERR("failed to mmap mmio!\n");
return -WD_ENOMEM;
}
@@ -197,14 +197,14 @@ static __u32 get_version_id(handle_t h_ctx)
api_name = wd_ctx_get_api(h_ctx);
if (!api_name || strlen(api_name) <= VERSION_ID_SHIFT) {
- WD_ERR("api name error = %s\n", api_name);
+ WD_ERR("invalid: api name is %s!\n", api_name);
return 0;
}
id = api_name + VERSION_ID_SHIFT;
ver = strtoul(id, NULL, 10);
if (!ver || ver == ULONG_MAX) {
- WD_ERR("fail to strtoul, ver = %lu\n", ver);
+ WD_ERR("failed to strtoul, ver = %lu!\n", ver);
return 0;
}
@@ -250,7 +250,7 @@ static int his_qm_set_qp_ctx(handle_t h_ctx, struct hisi_qm_priv *config,
q_info->qc_type = qp_ctx.qc_type;
ret = wd_ctx_set_io_cmd(h_ctx, UACCE_CMD_QM_SET_QP_CTX, &qp_ctx);
if (ret < 0) {
- WD_ERR("HISI QM fail to set qc_type, use default value\n");
+ WD_ERR("failed to set qc_type, use default value!\n");
return ret;
}
@@ -265,13 +265,13 @@ static int hisi_qm_get_qfrs_offs(handle_t h_ctx,
q_info->region_size[UACCE_QFRT_DUS] = wd_ctx_get_region_size(h_ctx,
UACCE_QFRT_DUS);
if (!q_info->region_size[UACCE_QFRT_DUS]) {
- WD_ERR("fail to get DUS qfrs offset.\n");
+ WD_ERR("failed to get DUS qfrs offset!\n");
return -WD_EINVAL;
}
q_info->region_size[UACCE_QFRT_MMIO] = wd_ctx_get_region_size(h_ctx,
UACCE_QFRT_MMIO);
if (!q_info->region_size[UACCE_QFRT_MMIO]) {
- WD_ERR("fail to get MMIO qfrs offset.\n");
+ WD_ERR("failed to get MMIO qfrs offset!\n");
return -WD_EINVAL;
}
@@ -286,25 +286,25 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
q_info = &qp->q_info;
ret = hisi_qm_setup_region(qp->h_ctx, q_info);
if (ret) {
- WD_ERR("setup region fail\n");
+ WD_ERR("failed to setup region!\n");
return ret;
}
ret = hisi_qm_get_qfrs_offs(qp->h_ctx, q_info);
if (ret) {
- WD_ERR("get dev qfrs offset fail.\n");
+ WD_ERR("failed to get dev qfrs offset!\n");
goto err_out;
}
ret = hisi_qm_setup_db(qp->h_ctx, q_info);
if (ret) {
- WD_ERR("setup db fail\n");
+ WD_ERR("failed to setup db!\n");
goto err_out;
}
ret = his_qm_set_qp_ctx(qp->h_ctx, config, q_info);
if (ret) {
- WD_ERR("setup io cmd fail\n");
+ WD_ERR("failed to setup io cmd!\n");
goto err_out;
}
@@ -320,7 +320,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
ret = pthread_spin_init(&q_info->lock, PTHREAD_PROCESS_SHARED);
if (ret) {
- WD_ERR("init qinfo lock fail\n");
+ WD_ERR("failed to init qinfo lock!\n");
goto err_out;
}
@@ -352,8 +352,8 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx)
if (!config)
goto out;
- if (config->sqe_size <= 0) {
- WD_ERR("invalid sqe size (%u)\n", config->sqe_size);
+ if (!config->sqe_size) {
+ WD_ERR("invalid: sqe size is zero!\n");
goto out;
}
@@ -367,7 +367,8 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx)
if (ret)
goto out_qp;
- qp->h_sgl_pool = hisi_qm_create_sglpool(HISI_SGL_NUM_IN_BD, HISI_SGE_NUM_IN_SGL);
+ qp->h_sgl_pool = hisi_qm_create_sglpool(HISI_SGL_NUM_IN_BD,
+ HISI_SGE_NUM_IN_SGL);
if (!qp->h_sgl_pool)
goto out_qp;
@@ -396,7 +397,7 @@ void hisi_qm_free_qp(handle_t h_qp)
struct hisi_qp *qp = (struct hisi_qp *)h_qp;
if (!qp) {
- WD_ERR("h_qp is NULL.\n");
+ WD_ERR("invalid: h_qp is NULL!\n");
return;
}
@@ -461,7 +462,7 @@ static int hisi_qm_recv_single(struct hisi_qm_queue_info *q_info, void *resp)
j = CQE_SQ_HEAD_INDEX(cqe);
if (j >= QM_Q_DEPTH) {
pthread_spin_unlock(&q_info->lock);
- WD_ERR("CQE_SQ_HEAD_INDEX(%u) error\n", j);
+ WD_ERR("CQE_SQ_HEAD_INDEX(%u) error!\n", j);
return -WD_EIO;
}
memcpy(resp, (void *)((uintptr_t)q_info->sq_base +
@@ -535,7 +536,7 @@ static void *hisi_qm_create_sgl(__u32 sge_num)
sge_num * (sizeof(struct hisi_sge)) + HISI_SGL_ALIGE;
sgl = calloc(1, size);
if (!sgl) {
- WD_ERR("failed to create sgl\n");
+ WD_ERR("failed to create sgl!\n");
return NULL;
}
@@ -562,36 +563,34 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
int i, ret;
if (!sgl_num || !sge_num || sge_num > HISI_SGE_NUM_IN_SGL) {
- WD_ERR("create sgl_pool failed, sgl_num=%u, sge_num=%u\n",
+ WD_ERR("failed to create sgl_pool, sgl_num=%u, sge_num=%u!\n",
sgl_num, sge_num);
return 0;
}
sgl_pool = calloc(1, sizeof(struct hisi_sgl_pool));
if (!sgl_pool) {
- WD_ERR("sgl pool alloc memory failed.\n");
+ WD_ERR("failed to alloc memory for sgl_pool!\n");
return 0;
}
sgl_pool->sgl = calloc(sgl_num, sizeof(void *));
if (!sgl_pool->sgl) {
- WD_ERR("sgl array alloc memory failed.\n");
+ WD_ERR("failed to alloc memory for sgl!\n");
goto err_out;
}
sgl_pool->sgl_align = calloc(sgl_num, sizeof(void *));
if (!sgl_pool->sgl_align) {
- WD_ERR("sgl align array alloc memory failed.\n");
+ WD_ERR("failed to alloc memory for sgl align!\n");
goto err_out;
}
/* base the sgl_num create the sgl chain */
for (i = 0; i < sgl_num; i++) {
sgl_pool->sgl[i] = hisi_qm_create_sgl(sge_num);
- if (!sgl_pool->sgl[i]) {
- WD_ERR("sgl create failed.\n");
+ if (!sgl_pool->sgl[i])
goto err_out;
- }
sgl_pool->sgl_align[i] = hisi_qm_align_sgl(sgl_pool->sgl[i], sge_num);
}
@@ -602,7 +601,7 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
sgl_pool->top = sgl_num;
ret = pthread_spin_init(&sgl_pool->lock, PTHREAD_PROCESS_SHARED);
if (ret) {
- WD_ERR("init sgl pool lock failed.\n");
+ WD_ERR("failed to init sgl pool lock!\n");
goto err_out;
}
@@ -619,7 +618,7 @@ void hisi_qm_destroy_sglpool(handle_t sgl_pool)
int i;
if (!pool) {
- WD_ERR("sgl_pool is NULL\n");
+ WD_ERR("invalid: sgl_pool is NULL!\n");
return;
}
if (pool->sgl) {
@@ -642,7 +641,7 @@ static struct hisi_sgl *hisi_qm_sgl_pop(struct hisi_sgl_pool *pool)
pthread_spin_lock(&pool->lock);
if (pool->top == 0) {
- WD_ERR("The sgl pool is empty\n");
+ WD_ERR("invalid: the sgl pool is empty!\n");
pthread_spin_unlock(&pool->lock);
return NULL;
}
@@ -657,7 +656,7 @@ static int hisi_qm_sgl_push(struct hisi_sgl_pool *pool, struct hisi_sgl *hw_sgl)
{
pthread_spin_lock(&pool->lock);
if (pool->top >= pool->depth) {
- WD_ERR("The sgl pool is full\n");
+ WD_ERR("invalid: the sgl pool is full!\n");
pthread_spin_unlock(&pool->lock);
return -WD_EINVAL;
}
@@ -705,7 +704,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
int i = 0;
if (!pool || !sgl) {
- WD_ERR("get hw sgl pool or sgl is NULL\n");
+ WD_ERR("invalid: hw sgl pool or sgl is NULL!\n");
return NULL;
}
@@ -723,7 +722,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
}
if (tmp->len > HISI_MAX_SIZE_IN_SGE) {
- WD_ERR("the data len is invalid: %u\n", tmp->len);
+ WD_ERR("invalid: the data len is %u!\n", tmp->len);
goto err_out;
}
@@ -742,7 +741,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
if (i == pool->sge_num && tmp->next) {
next = hisi_qm_sgl_pop(pool);
if (!next) {
- WD_ERR("the sgl pool is not enough\n");
+ WD_ERR("invalid: the sgl pool is not enough!\n");
goto err_out;
}
cur->next_dma = (uintptr_t)next;
diff --git a/wd.c b/wd.c
index b88ee62..0774837 100644
--- a/wd.c
+++ b/wd.c
@@ -59,14 +59,14 @@ static int get_raw_attr(const char *dev_root, const char *attr, char *buf,
fd = open(attr_path, O_RDONLY, 0);
if (fd < 0) {
- WD_ERR("open %s fail (%d)!\n", attr_path, -errno);
+ WD_ERR("failed to open %s(%d)!\n", attr_path, -errno);
return -WD_ENODEV;
}
memset(buf, 0, sz);
size = read(fd, buf, sz);
if (size <= 0) {
- WD_ERR("read nothing at %s!\n", attr_path);
+ WD_ERR("failed to read anything at %s!\n", attr_path);
size = -WD_EIO;
}
@@ -601,7 +601,7 @@ static int check_alg_name(const char *alg_name)
while (alg_name[i] != '\0') {
i++;
if (i >= MAX_ATTR_STR_SIZE) {
- WD_ERR("get list failed, alg name is too long!\n");
+ WD_ERR("failed to get list, alg name is too long!\n");
return -WD_EINVAL;
}
}
diff --git a/wd_mempool.c b/wd_mempool.c
index b6e1088..bfacd28 100644
--- a/wd_mempool.c
+++ b/wd_mempool.c
@@ -206,12 +206,17 @@ static __always_inline unsigned long wd_ffs(unsigned long word)
static struct bitmap *create_bitmap(int bits)
{
- struct bitmap *bm = calloc(1, sizeof(*bm));
- if (!bm)
+ struct bitmap *bm;
+
+ bm = calloc(1, sizeof(*bm));
+ if (!bm) {
+ WD_ERR("failed to alloc memory for bitmap!\n");
return NULL;
+ }
bm->map = calloc(BITS_TO_LONGS(bits), sizeof(unsigned long));
if (!bm->map) {
+ WD_ERR("failed to alloc memory for bitmap map!\n");
free(bm);
return NULL;
}
@@ -346,6 +351,7 @@ static int alloc_memzone(struct blkpool *bp, void *addr, size_t blk_num,
zone = calloc(1, sizeof(struct memzone));
if (!zone) {
+ WD_ERR("failed to alloc memory for memzone!\n");
return -ENOMEM;
}
@@ -389,7 +395,8 @@ static void free_mem_to_mempool(struct blkpool *bp)
static int check_mempool_real_size(struct mempool *mp, struct blkpool *bp)
{
if (bp->blk_size * bp->depth > mp->real_size) {
- WD_ERR("wd_mempool: mempool too small: %lu\n", mp->real_size);
+ WD_ERR("invalid: mempool size is too small: %lu!\n",
+ mp->real_size);
return -ENOMEM;
}
@@ -525,8 +532,10 @@ static int init_blkpool_elem(struct blkpool *bp)
int i;
bp->blk_elem = calloc(bp->depth, sizeof(void *));
- if (!bp->blk_elem)
+ if (!bp->blk_elem) {
+ WD_ERR("failed to alloc memory for blk_elem!\n");
return -ENOMEM;
+ }
TAILQ_FOREACH(iter, &bp->mz_list, node) {
for (i = 0; i < iter->blk_num; i++)
@@ -544,7 +553,7 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
int ret;
if (!mp || !block_size || !block_num) {
- WD_ERR("wd_mempool: input parameter is invalid value\n");
+ WD_ERR("invalid: mempool is NULL or block param is 0!\n");
return (handle_t)(-WD_EINVAL);
}
@@ -552,8 +561,10 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
return (handle_t)(-WD_EBUSY);
bp = calloc(1, sizeof(struct blkpool));
- if (!bp)
+ if (!bp) {
+ WD_ERR("failed to alloc memory for blkpool!\n");
return (handle_t)(-WD_ENOMEM);
+ }
bp->top = block_num;
bp->depth = block_num;
@@ -563,13 +574,13 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
ret = alloc_mem_from_mempool(mp, bp);
if (ret < 0) {
- WD_ERR("wd_mempool: failed to allocate memory from mempool\n");
+ WD_ERR("failed to allocate memory from mempool!\n");
goto err_free_bp;
}
ret = init_blkpool_elem(bp);
if (ret < 0) {
- WD_ERR("wd_mempool: failed to init blkpool\n");
+ WD_ERR("failed to init blkpool!\n");
goto err_free_mem;
}
@@ -590,7 +601,7 @@ void wd_blockpool_destroy(handle_t blkpool)
struct mempool *mp;
if (!bp) {
- WD_ERR("wd_mempool: blkpool is NULL\n");
+ WD_ERR("invalid: blkpool is NULL!\n");
return;
}
@@ -620,13 +631,13 @@ static int get_value_from_sysfs(const char *path, ssize_t path_size)
fd = open(dev_path, O_RDONLY, 0);
if (fd < 0) {
- WD_ERR("wd_mempool: failed to open %s\n", dev_path);
+ WD_ERR("failed to open %s!\n", dev_path);
goto err_open;
}
size = read(fd, buf, sizeof(buf));
if (size <= 0) {
- WD_ERR("wd_mempool: failed to read %s\n", dev_path);
+ WD_ERR("failed to read %s!\n", dev_path);
goto err_read;
}
@@ -716,7 +727,7 @@ static int get_hugepage_info(struct mempool *mp)
dir = opendir(hugepage_path);
if (!dir) {
- WD_ERR("wd_mempool: failed to open %s\n", hugepage_path);
+ WD_ERR("failed to open %s\n!", hugepage_path);
return -errno;
}
@@ -728,13 +739,13 @@ static int get_hugepage_info(struct mempool *mp)
tmp = calloc(1, sizeof(*tmp));
if (!tmp) {
- WD_ERR("wd_mempool: failed to calloc\n");
+ WD_ERR("failed to calloc for sys_hugepage_config!\n");
goto err_free_list;
}
ret = get_hugepage_info_per_type(hugepage_path, MAX_HP_STR_SIZE,
hp_dir, tmp);
if (ret < 0) {
- WD_ERR("wd_mempool: failed to get hugepage info\n");
+ WD_ERR("failed to get hugepage info!\n");
goto err_free;
}
@@ -779,7 +790,7 @@ static int mbind_memory(void *addr, size_t size, int node)
node_mask = 1U << (unsigned int)node;
ret = mbind(addr, size, MPOL_BIND, &node_mask, max_node, 0);
if (ret < 0) {
- WD_ERR("wd_mempool: failed to mbind memory, %d\n", ret);
+ WD_ERR("failed to mbind memory, ret is %d!\n", ret);
return ret;
}
@@ -805,7 +816,7 @@ static int alloc_mem_from_hugepage(struct mempool *mp)
break;
}
if (!iter) {
- WD_ERR("wd_mempool: failed to find proper hugepage\n");
+ WD_ERR("failed to find proper hugepage!\n");
ret = -ENOMEM;
goto err_put_info;
}
@@ -826,7 +837,7 @@ static int alloc_mem_from_hugepage(struct mempool *mp)
p = mmap(NULL, real_size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
MAP_ANONYMOUS | MAP_HUGETLB | flags, -1, 0);
if (p == MAP_FAILED) {
- WD_ERR("wd_mempool: failed to allocate huge page\n");
+ WD_ERR("failed to allocate huge page!\n");
ret = -ENOMEM;
goto err_put_info;
}
@@ -862,7 +873,7 @@ static int alloc_mempool_memory(struct mempool *mp)
ret = alloc_mem_from_hugepage(mp);
if (ret) {
- WD_ERR("wd_mempool: failed to alloc memory from hugepage\n");
+ WD_ERR("failed to alloc memory from hugepage!\n");
return -ENOMEM;
}
@@ -908,8 +919,10 @@ handle_t wd_mempool_create(size_t size, int node)
size += WD_MEMPOOL_BLOCK_SIZE - (WD_MEMPOOL_SIZE_MASK & size);
mp = calloc(1, sizeof(*mp));
- if (!mp)
+ if (!mp) {
+ WD_ERR("failed to alloc memory for mempool!\n");
return (handle_t)(-WD_ENOMEM);
+ }
mp->node = node;
mp->size = size;
@@ -938,7 +951,7 @@ void wd_mempool_destroy(handle_t mempool)
struct mempool *mp = (struct mempool *)mempool;
if (!mp) {
- WD_ERR("wd_mempool: mempool is NULL\n");
+ WD_ERR("invalid: mempool is NULL!\n");
return;
}
@@ -954,12 +967,12 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats)
struct mempool *mp = (struct mempool *)mempool;
if (!mp) {
- WD_ERR("wd_mempool: mempool is NULL\n");
+ WD_ERR("invalid: mempool is NULL!\n");
return;
}
if (!stats) {
- WD_ERR("wd_mempool: mempool stats is NULL\n");
+ WD_ERR("invalid: mempool stats is NULL!\n");
return;
}
@@ -984,7 +997,7 @@ void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats)
struct memzone *iter;
if (!bp || !stats) {
- WD_ERR("wd_mempool: blkpool or stats is NULL\n");
+ WD_ERR("invalid: blkpool or stats is NULL!\n");
return;
}
@@ -1001,7 +1014,7 @@ void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats)
}
if (!size) {
- WD_ERR("wd_mempool: blkpool size is zero\n");
+ WD_ERR("invalid: blkpool size is zero!\n");
wd_unspinlock(&bp->lock);
return;
}
diff --git a/wd_sched.c b/wd_sched.c
index ef90233..9b1998c 100644
--- a/wd_sched.c
+++ b/wd_sched.c
@@ -129,8 +129,8 @@ static bool sched_key_valid(struct wd_sched_ctx *ctx,
{
if (key->numa_id >= ctx->numa_num || key->mode >= SCHED_MODE_BUTT ||
key->type >= ctx->type_num) {
- WD_ERR("ERROR: %s key error - numa: %d, mode: %u, type: %u!\n",
- __FUNCTION__, key->numa_id, key->mode, key->type);
+ WD_ERR("invalid: sched key's numa: %d, mode: %u, type: %u!\n",
+ key->numa_id, key->mode, key->type);
return false;
}
@@ -207,13 +207,13 @@ static int session_sched_poll_policy(handle_t sched_ctx,
__u16 i;
int ret;
- if (!sched_ctx || !count || !ctx) {
- WD_ERR("ERROR: %s the para is NULL!\n", __FUNCTION__);
+ if (!count || !ctx) {
+ WD_ERR("invalid: sched ctx is NULL or count is zero!\n");
return -WD_EINVAL;
}
if (ctx->numa_num > NUMA_NUM_NODES) {
- WD_ERR("ERROR: %s ctx numa num is invalid!\n", __FUNCTION__);
+ WD_ERR("invalid: ctx's numa number is %d!\n", ctx->numa_num);
return -WD_EINVAL;
}
@@ -270,16 +270,14 @@ static __u32 session_sched_init_ctx(handle_t sched_ctx,
bool ret;
if (!ctx || !key) {
- WD_ERR("ERROR: %s the pointer para is NULL!\n", __FUNCTION__);
+ WD_ERR("invalid: sched ctx or key is NULL!\n");
return INVALID_POS;
}
key->mode = sched_mode;
ret = sched_key_valid(ctx, key);
- if (!ret) {
- WD_ERR("ERROR: %s the key is invalid!\n", __FUNCTION__);
+ if (!ret)
return INVALID_POS;
- }
region = sched_get_ctx_range(ctx, key);
if (!region)
@@ -295,7 +293,7 @@ handle_t session_sched_init(handle_t h_sched_ctx, void *sched_param)
skey = malloc(sizeof(struct sched_key));
if (!skey) {
- WD_ERR("fail to alloc session sched key!\n");
+ WD_ERR("failed to alloc memory for session sched key!\n");
return (handle_t)(-WD_ENOMEM);
}
@@ -328,7 +326,7 @@ static __u32 session_sched_pick_next_ctx(handle_t sched_ctx,
struct sched_key *key = (struct sched_key *)sched_key;
if (unlikely(!sched_ctx || !key)) {
- WD_ERR("ERROR: %s the pointer para is NULL!\n", __FUNCTION__);
+ WD_ERR("invalid: sched ctx or key is NULL!\n");
return INVALID_POS;
}
@@ -357,13 +355,12 @@ int wd_sched_rr_instance(const struct wd_sched *sched,
int numa_id;
if (!sched || !sched->h_sched_ctx || !param) {
- WD_ERR("ERROR: %s para err: sched of h_sched_ctx is NULL!\n",
- __FUNCTION__);
+ WD_ERR("invalid: sched or sched_params is NULL!\n");
return -WD_EINVAL;
}
if (param->begin > param->end) {
- WD_ERR("ERROR: sched_params's begin is larger than end!\n");
+ WD_ERR("invalid: sched_params's begin is larger than end!\n");
return -WD_EINVAL;
}
@@ -373,28 +370,28 @@ int wd_sched_rr_instance(const struct wd_sched *sched,
sched_ctx = (struct wd_sched_ctx *)sched->h_sched_ctx;
if (numa_id >= sched_ctx->numa_num || numa_id < 0) {
- WD_ERR("ERROR: %s para err: numa_id = %d, numa_num = %u\n",
- __FUNCTION__, numa_id, sched_ctx->numa_num);
+ WD_ERR("invalid: sched_ctx's numa_id is %d, numa_num is %u!\n",
+ numa_id, sched_ctx->numa_num);
return -WD_EINVAL;
}
if (type >= sched_ctx->type_num) {
- WD_ERR("ERROR: %s para err: type = %u, type_num = %u\n",
- __FUNCTION__, type, sched_ctx->type_num);
+ WD_ERR("invalid: sched_ctx's type is %u, type_num is %u!\n",
+ type, sched_ctx->type_num);
return -WD_EINVAL;
}
if (mode >= SCHED_MODE_BUTT) {
- WD_ERR("ERROR: %s para err: mode = %u, mode_num = %d!\n",
- __FUNCTION__, mode, SCHED_MODE_BUTT);
+ WD_ERR("invalid: sched_ctx's mode is %u, mode_num is %d!\n",
+ mode, SCHED_MODE_BUTT);
return -WD_EINVAL;
}
sched_info = sched_ctx->sched_info;
if (!sched_info[numa_id].ctx_region[mode]) {
- WD_ERR("ERROR: %s ctx_region of numa_id = %d, mode = %u is NULL!\n",
- __FUNCTION__, numa_id, mode);
+ WD_ERR("invalid: ctx_region is NULL, numa: %d, mode: %u!\n",
+ numa_id, mode);
return -WD_EINVAL;
}
@@ -454,27 +451,26 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
return NULL;
if (!numa_num || numa_num > max_node) {
- WD_ERR("Error: %s numa number = %u!\n", __FUNCTION__,
- numa_num);
+ WD_ERR("invalid: numa number is %u!\n", numa_num);
return NULL;
}
if (sched_type >= SCHED_POLICY_BUTT || !type_num) {
- WD_ERR("Error: %s sched_type = %u or type_num = %u is invalid!\n",
- __FUNCTION__, sched_type, type_num);
+ WD_ERR("invalid: sched_type is %u or type_num is %u!\n",
+ sched_type, type_num);
return NULL;
}
sched = calloc(1, sizeof(struct wd_sched));
if (!sched) {
- WD_ERR("Error: %s wd_sched alloc error!\n", __FUNCTION__);
+ WD_ERR("failed to alloc memory for wd_sched!\n");
return NULL;
}
sched_ctx = calloc(1, sizeof(struct wd_sched_ctx) +
sizeof(struct wd_sched_info) * numa_num);
if (!sched_ctx) {
- WD_ERR("Error: %s sched_ctx alloc error!\n", __FUNCTION__);
+ WD_ERR("failed to alloc memory for sched_ctx!\n");
goto err_out;
}
diff --git a/wd_util.c b/wd_util.c
index 44c8909..03316b6 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -74,7 +74,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
int i, ret;
if (!cfg->ctx_num) {
- WD_ERR("invalid parameters, ctx_num is 0!\n");
+ WD_ERR("invalid: ctx_num is 0!\n");
return -WD_EINVAL;
}
@@ -90,7 +90,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
for (i = 0; i < cfg->ctx_num; i++) {
if (!cfg->ctxs[i].ctx) {
- WD_ERR("invalid parameters, ctx is NULL!\n");
+ WD_ERR("invalid: ctx is NULL!\n");
free(ctxs);
return -WD_EINVAL;
}
@@ -98,7 +98,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
clone_ctx_to_internal(cfg->ctxs + i, ctxs + i);
ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
if (ret) {
- WD_ERR("init ctxs lock failed!\n");
+ WD_ERR("failed to init ctxs lock!\n");
free(ctxs);
return ret;
}
@@ -243,7 +243,7 @@ void *wd_find_msg_in_pool(struct wd_async_msg_pool *pool,
/* tag value start from 1 */
if (tag == 0 || tag > msg_num) {
- WD_ERR("invalid message cache tag(%u)\n", tag);
+ WD_ERR("invalid: message cache tag is %u!\n", tag);
return NULL;
}
@@ -279,7 +279,7 @@ void wd_put_msg_to_pool(struct wd_async_msg_pool *pool, int ctx_idx, __u32 tag)
/* tag value start from 1 */
if (!tag || tag > msg_num) {
- WD_ERR("invalid message cache idx(%u)\n", tag);
+ WD_ERR("invalid: message cache idx is %u!\n", tag);
return;
}
@@ -318,14 +318,11 @@ void dump_env_info(struct wd_env_config *config)
config_numa->async_ctx_num);
for (j = 0; j < CTX_MODE_MAX; j++)
for (k = 0; k < config_numa->op_type_num; k++) {
- WD_ERR("-> %s: %d: [%d][%d].begin: %u\n",
- __func__,
+ WD_ERR("-> %d: [%d][%d].begin: %u\n",
i, j, k, ctx_table[j][k].begin);
- WD_ERR("-> %s: %d: [%d][%d].end: %u\n",
- __func__,
+ WD_ERR("-> %d: [%d][%d].end: %u\n",
i, j, k, ctx_table[j][k].end);
- WD_ERR("-> %s: %d: [%d][%d].size: %u\n",
- __func__,
+ WD_ERR("-> %d: [%d][%d].size: %u\n",
i, j, k, ctx_table[j][k].size);
}
}
@@ -340,8 +337,10 @@ static void *wd_get_config_numa(struct wd_env_config *config, int node)
if (config_numa->node == node)
break;
- if (i == config->numa_num)
+ if (i == config->numa_num) {
+ WD_ERR("invalid: missing numa node is %d!\n", node);
return NULL;
+ }
return config_numa;
}
@@ -373,7 +372,7 @@ static __u16 wd_get_dev_numa(struct uacce_dev_list *head,
if (list->dev->numa_id < 0) {
list->dev->numa_id = 0;
} else if (list->dev->numa_id >= size) {
- WD_ERR("numa id is wrong(%d)\n", list->dev->numa_id);
+ WD_ERR("invalid: numa id is %d!\n", list->dev->numa_id);
return 0;
}
@@ -396,10 +395,8 @@ static void wd_set_numa_dev(struct uacce_dev_list *head,
while (list) {
config_numa = wd_get_config_numa(config, list->dev->numa_id);
- if (!config_numa) {
- WD_ERR("%s got wrong numa node!\n", __func__);
+ if (!config_numa)
break;
- }
dev = config_numa->dev + config_numa->dev_num;
memcpy(dev, list->dev, sizeof(*list->dev));
@@ -457,7 +454,7 @@ static int wd_alloc_numa(struct wd_env_config *config,
/* get uacce_dev */
head = wd_get_accel_list(ops->alg_name);
if (!head) {
- WD_ERR("no device to support %s\n", ops->alg_name);
+ WD_ERR("invalid: no device to support %s\n", ops->alg_name);
ret = -WD_ENODEV;
goto free_numa_dev_num;
}
@@ -465,7 +462,7 @@ static int wd_alloc_numa(struct wd_env_config *config,
/* get numa num and device num of each numa from uacce_dev list */
config->numa_num = wd_get_dev_numa(head, numa_dev_num, max_node);
if (config->numa_num == 0 || config->numa_num > max_node) {
- WD_ERR("numa num err(%u)!\n", config->numa_num);
+ WD_ERR("invalid: numa number is %u!\n", config->numa_num);
ret = -WD_ENODEV;
goto free_list;
}
@@ -519,13 +516,13 @@ int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
int tmp;
if (!is_number(s)) {
- WD_ERR("invalid async poll en flag: %s!\n", s);
+ WD_ERR("invalid: async poll en flag is %s!\n", s);
return -WD_EINVAL;
}
tmp = strtol(s, NULL, 10);
if (tmp != 0 && tmp != 1) {
- WD_ERR("async poll en flag is not 0 or 1!\n");
+ WD_ERR("invalid: async poll en flag is not 0 or 1!\n");
return -WD_EINVAL;
}
@@ -539,7 +536,7 @@ static int parse_num_on_numa(const char *s, int *num, int *node)
char *sep, *start, *left;
if (!strlen(s)) {
- WD_ERR("input string length is zero!\n");
+ WD_ERR("invalid: input string length is zero!\n");
return -WD_EINVAL;
}
@@ -560,7 +557,7 @@ static int parse_num_on_numa(const char *s, int *num, int *node)
}
out:
- WD_ERR("input env format is invalid:%s\n", s);
+ WD_ERR("invalid: input env format is %s!\n", s);
free(start);
return -WD_EINVAL;
}
@@ -658,7 +655,7 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
ctx_section = index(section, ':');
if (!ctx_section) {
- WD_ERR("%s got wrong format: %s!\n", __func__, section);
+ WD_ERR("invalid: ctx section got wrong format: %s!\n", section);
return -WD_EINVAL;
}
@@ -669,10 +666,8 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
return ret;
config_numa = wd_get_config_numa(config, node);
- if (!config_numa) {
- WD_ERR("%s got wrong numa node: %s!\n", __func__, section);
+ if (!config_numa)
return -WD_EINVAL;
- }
config_numa->op_type_num = config->op_type_num;
ret = wd_alloc_ctx_table_per_numa(config_numa);
@@ -681,7 +676,8 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
ret = get_and_fill_ctx_num(config_numa, section, ctx_num);
if (ret) {
- WD_ERR("%s got wrong ctx type: %s!\n", __func__, section);
+ WD_ERR("invalid: ctx section got wrong ctx type: %s!\n",
+ section);
wd_free_ctx_table_per_numa(config_numa);
return ret;
}
@@ -798,8 +794,6 @@ int wd_parse_async_poll_num(struct wd_env_config *config, const char *s)
goto out;
config_numa = wd_get_config_numa(config, node);
if (!config_numa) {
- WD_ERR("%s got wrong numa node: %s!\n",
- __func__, section);
ret = -WD_EINVAL;
goto out;
}
@@ -831,7 +825,7 @@ static int wd_parse_env(struct wd_env_config *config)
ret = var->parse_fn(config, var_s);
if (ret) {
- WD_ERR("fail to parse %s environment variable!\n",
+ WD_ERR("failed to parse %s environment variable!\n",
var->name);
return -WD_EINVAL;
}
@@ -847,10 +841,8 @@ static int wd_parse_ctx_attr(struct wd_env_config *env_config,
int ret;
config_numa = wd_get_config_numa(env_config, attr->node);
- if (!config_numa) {
- WD_ERR("%s got wrong numa node!\n", __func__);
+ if (!config_numa)
return -WD_EINVAL;
- }
config_numa->op_type_num = env_config->op_type_num;
ret = wd_alloc_ctx_table_per_numa(config_numa);
@@ -958,7 +950,7 @@ static int wd_get_wd_ctx(struct wd_env_config_per_numa *config,
h_ctx = request_ctx_on_numa(config);
if (!h_ctx) {
ret = -WD_EBUSY;
- WD_ERR("err: request too many ctxs\n");
+ WD_ERR("failed to request more ctxs!\n");
goto free_ctx;
}
@@ -1149,7 +1141,7 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
}
if (!config_numa->async_poll_num) {
- WD_ERR("invalid parameter, async_poll_num of numa is zero!\n");
+ WD_ERR("invalid: async_poll_num of numa is zero!\n");
return NULL;
}
@@ -1304,17 +1296,17 @@ static int wd_init_one_task_queue(struct async_task_queue *task_queue,
task_queue->alg_poll_ctx = alg_poll_ctx;
if (sem_init(&task_queue->empty_sem, 0, depth)) {
- WD_ERR("empty_sem init failed.\n");
+ WD_ERR("failed to init empty_sem!\n");
goto err_free_head;
}
if (sem_init(&task_queue->full_sem, 0, 0)) {
- WD_ERR("full_sem init failed.\n");
+ WD_ERR("failed to init full_sem!\n");
goto err_uninit_empty_sem;
}
if (pthread_mutex_init(&task_queue->lock, NULL)) {
- WD_ERR("mutex init failed.\n");
+ WD_ERR("failed to init task queue's mutex lock!\n");
goto err_uninit_full_sem;
}
@@ -1323,7 +1315,7 @@ static int wd_init_one_task_queue(struct async_task_queue *task_queue,
task_queue->tid = 0;
if (pthread_create(&thread_id, &attr, async_poll_process_func,
task_queue)) {
- WD_ERR("create poll thread failed.\n");
+ WD_ERR("failed to create poll thread!\n");
goto err_destory_mutex;
}
@@ -1547,18 +1539,15 @@ int wd_alg_get_env_param(struct wd_env_config *env_config,
struct wd_env_config_per_numa *config_numa;
if (!num || !is_enable) {
- WD_ERR("input parameter num or is_enable is NULL!\n");
+ WD_ERR("invalid: input pointer num or is_enable is NULL!\n");
return -WD_EINVAL;
}
*is_enable = env_config->enable_internal_poll;
config_numa = wd_get_config_numa(env_config, attr.node);
- if (!config_numa) {
- WD_ERR("%s got wrong numa node: %u!\n",
- __func__, attr.node);
+ if (!config_numa)
return -WD_EINVAL;
- }
*num = (config_numa->ctx_table) ?
config_numa->ctx_table[attr.mode][attr.type].size : 0;
@@ -1570,7 +1559,7 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
__u32 node, __u32 type, __u8 mode, __u32 num)
{
if (mode >= CTX_MODE_MAX) {
- WD_ERR("wrong ctx mode(%u))!\n", mode);
+ WD_ERR("invalid: ctx mode is %u!\n", mode);
return -WD_EINVAL;
}
@@ -1594,7 +1583,7 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx)
ctx = config->ctxs + idx;
if (ctx->ctx_mode != mode) {
- WD_ERR("ctx %u mode = %hhu error!\n", idx, ctx->ctx_mode);
+ WD_ERR("invalid: ctx(%u) mode is %hhu!\n", idx, ctx->ctx_mode);
return -WD_EINVAL;
}
--
2.27.0