From: Wenkai Lin linwenkai6@hisilicon.com
dummy is no longer use, remove it.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com Signed-off-by: Qi Tao taoqi10@huawei.com --- .gitignore | 1 - v1/drv/dummy_drv.c | 173 ---------------------------------- v1/drv/dummy_drv.h | 34 ------- v1/internal/dummy_hw_usr_if.h | 58 ------------ 4 files changed, 266 deletions(-) delete mode 100644 v1/drv/dummy_drv.c delete mode 100644 v1/drv/dummy_drv.h delete mode 100644 v1/internal/dummy_hw_usr_if.h
diff --git a/.gitignore b/.gitignore index 6a1eb49..3518081 100644 --- a/.gitignore +++ b/.gitignore @@ -160,7 +160,6 @@ m4/ missing sample/uadk_comp stamp-h1 -test/test_dummy test/test_hisi_zip test/test_hisi_zlib test/test_bind_api diff --git a/v1/drv/dummy_drv.c b/v1/drv/dummy_drv.c deleted file mode 100644 index ca0aa43..0000000 --- a/v1/drv/dummy_drv.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/mman.h> -#include <sys/ioctl.h> -#include <linux/types.h> - -#include "v1/wd_util.h" -#include "dummy_drv.h" - -#define QM_VERSION_V1 1 -#define QM_VERSION_V2 2 - -struct dummy_q_priv { - int ver; - int head; /* queue head */ - int resp_tail; /* resp tail in the queue */ - /* so in the user side: when add to queue, head++ but don't exceed resp_tail. - * when get back from the queue, resp_tail++ but don't exceed tail. - * in the kernel side: when get from queue, tail++ but don't exceed head-1 */ - - struct dummy_hw_queue_reg *reg; - uint64_t *db; -}; - -int dummy_set_queue_dio(struct wd_queue *q) -{ - int ret = 0; - struct dummy_q_priv *priv; - struct q_info *qinfo = q->qinfo; - - priv = calloc(1, sizeof(*priv)); - if (!priv) { - DUMMY_ERR("No memory for dummy queue!\n"); - ret = -ENOMEM; - goto out; - } - - qinfo->priv = priv; - priv->ver = qinfo->qfrs_offset[WD_UACCE_QFRT_DUS] == - WD_UACCE_QFRT_INVALID ? - QM_VERSION_V1 : QM_VERSION_V2; - - if (priv->ver == QM_VERSION_V2) { - priv->db = wd_drv_mmap_qfr(q, WD_UACCE_QFRT_MMIO, 0); - if (priv->db == MAP_FAILED) { - DUMMY_ERR("mmap db fail (%d)\n", errno); - goto out_with_priv; - } - } - - priv->reg = wd_drv_mmap_qfr(q, priv->ver == QM_VERSION_V1 ? - WD_UACCE_QFRT_MMIO : WD_UACCE_QFRT_DUS, 0); - if (priv->reg == MAP_FAILED) { - DUMMY_ERR("mmap bd fail (%d)\n", errno); - goto out_with_db_map; - } - - /* detect hardware for v1 (v2 can be detected only after start) */ - if (priv->ver == QM_VERSION_V1 && - memcmp(priv->reg->hw_tag, DUMMY_HW_TAG, DUMMY_HW_TAG_SZ)) { - DUMMY_ERR("hw detection fail\n"); - goto out_with_bd_map; - } - - return 0; - -out_with_bd_map: - if (priv->ver == QM_VERSION_V1) - wd_drv_unmmap_qfr(q, priv->reg, WD_UACCE_QFRT_MMIO, 0); - else - wd_drv_unmmap_qfr(q, priv->reg, WD_UACCE_QFRT_DUS, 0); -out_with_db_map: - if (priv->ver == QM_VERSION_V2) - wd_drv_unmmap_qfr(q, priv->db, WD_UACCE_QFRT_MMIO, 0); -out_with_priv: - free(priv); - qinfo->priv = NULL; -out: - if (errno) - ret = errno; - else - ret = -EIO; - return ret; -} - -void dummy_unset_queue_dio(struct wd_queue *q) -{ - struct q_info *qinfo = q->qinfo; - struct dummy_q_priv *priv = (struct dummy_q_priv *)qinfo->priv; - - ASSERT(priv); - - munmap(priv->reg, sizeof(struct dummy_hw_queue_reg)); - free(priv); - qinfo->priv = NULL; -} - -int dummy_add_to_dio_q(struct wd_queue *q, void **req, __u32 num) -{ - struct q_info *qinfo = q->qinfo; - struct dummy_q_priv *priv = (struct dummy_q_priv *)qinfo->priv; - int bd_num; - - ASSERT(priv); - - bd_num = priv->reg->ring_bd_num; - - if ((priv->head + 1) % bd_num == priv->resp_tail) - return -EBUSY; /* the queue is full */ - else { - priv->reg->ring[priv->head] = *((struct ring_bd *)(req[0])); - priv->reg->ring[priv->head].ptr = req[0]; - priv->head = (priv->head + 1) % bd_num; - wd_reg_write(&priv->reg->head, priv->head); - printf("add to queue, new head=%d, %d\n", priv->head, priv->reg->head); - - if (priv->ver == QM_VERSION_V2) - wd_reg_write(priv->db, 1); - } - - return 0; -} - -int dummy_get_from_dio_q(struct wd_queue *q, void **resp, __u32 num) -{ - struct q_info *qinfo = q->qinfo; - struct dummy_q_priv *priv = (struct dummy_q_priv *)qinfo->priv; - int bd_num = priv->reg->ring_bd_num; - int ret; - int tail; - - ASSERT(priv); - - tail = wd_reg_read(&priv->reg->tail); - printf("get queue tail=%d,%d\n", tail, priv->resp_tail); - if (priv->resp_tail == tail) { - return -EBUSY; - } else { - ret = priv->reg->ring[priv->resp_tail].ret; - *resp = priv->reg->ring[priv->resp_tail].ptr; - priv->resp_tail = (priv->resp_tail + 1) % bd_num; - printf("get resp %d, %d\n", ret, priv->resp_tail); - return ret; - } -} - -void dummy_flush(struct wd_queue *q) -{ - struct q_info *qinfo = q->qinfo; - struct dummy_q_priv *priv = (struct dummy_q_priv *)qinfo->priv; - - if (priv->ver == QM_VERSION_V1) - ioctl(qinfo->fd, DUMMY_CMD_FLUSH); - else - wd_reg_write(priv->db, 1); -} diff --git a/v1/drv/dummy_drv.h b/v1/drv/dummy_drv.h deleted file mode 100644 index 0825efd..0000000 --- a/v1/drv/dummy_drv.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DUMMY_DRV_H__ -#define __DUMMY_DRV_H__ - -#include "v1/internal/dummy_hw_usr_if.h" -#include "v1/wd.h" - -#ifndef DUMMY_ERR -#define DUMMY_ERR(format, args...) printf(format, ##args) -#endif - -int dummy_set_queue_dio(struct wd_queue *q); -void dummy_unset_queue_dio(struct wd_queue *q); -int dummy_add_to_dio_q(struct wd_queue *q, void **req, __u32 num); -int dummy_get_from_dio_q(struct wd_queue *q, void **resp, __u32 num); -void dummy_flush(struct wd_queue *q); -void *dummy_reserve_mem(struct wd_queue *q, size_t size); - -#endif diff --git a/v1/internal/dummy_hw_usr_if.h b/v1/internal/dummy_hw_usr_if.h deleted file mode 100644 index 7fb81a1..0000000 --- a/v1/internal/dummy_hw_usr_if.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file defines the dummy hardware/driver interface between the user and - * kernel space - */ - -#ifndef __DUMMY_HW_USR_IF_H -#define __DUMMY_HW_USR_IF_H - -#include <linux/types.h> -#include "v1/internal/wd_dummy_usr_if.h" - -#define DUMMY_WD "dummy_wd" - -#define Q_BDS 16 -#define DUMMY_HW_TAG_SZ 8 -#define DUMMY_HW_TAG "WDDUMMY" - -/* the format of the device ring space, which is of drv */ -#define ring_bd wd_dummy_cpy_msg - -/* the format of the device io space, which is of drv */ -struct dummy_hw_queue_reg { - char hw_tag[DUMMY_HW_TAG_SZ]; /* should be "WDDUMMY\0" */ - struct ring_bd ring[Q_BDS]; /* in real hardware, this is good to be - in memory space, and will be fast - for communication. here we keep it - in io space just to make it simple - */ - __u32 ring_bd_num; /* ring_bd_num, now it is Q_BDS until - we use a memory ring */ - __u32 head; /* assume int is atomical. it should be - fine as a dummy and test function. - head is for the writer(user) while - tail is for the reader(kernel). - head==tail means the queue is empty - */ - __u32 tail; -}; - -#define DUMMY_CMD_FLUSH _IO('d', 0) - -#endif