malloc: deprecate unused function to set limit
[dpdk.git] / lib / librte_bbdev / rte_bbdev.c
index 8a053e3..0c35480 100644 (file)
@@ -6,6 +6,8 @@
 #include <string.h>
 #include <stdbool.h>
 
+#include <rte_string_fns.h>
+#include <rte_compat.h>
 #include <rte_common.h>
 #include <rte_errno.h>
 #include <rte_log.h>
 #define DEV_NAME "BBDEV"
 
 
+/* BBDev library logging ID */
+static int bbdev_logtype;
+
+/* Helper macro for logging */
+#define rte_bbdev_log(level, fmt, ...) \
+       rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__)
+
+#define rte_bbdev_log_debug(fmt, ...) \
+       rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
+               ##__VA_ARGS__)
+
 /* Helper macro to check dev_id is valid */
 #define VALID_DEV_OR_RET_ERR(dev, dev_id) do { \
        if (dev == NULL) { \
@@ -202,7 +215,7 @@ rte_bbdev_allocate(const char *name)
        bbdev->data->dev_id = dev_id;
        bbdev->state = RTE_BBDEV_INITIALIZED;
 
-       ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
+       ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN);
        if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
                rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
                return NULL;
@@ -483,11 +496,20 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
                                        conf->queue_size, queue_id, dev_id);
                        return -EINVAL;
                }
-               if (conf->priority > dev_info.max_queue_priority) {
+               if (conf->op_type == RTE_BBDEV_OP_TURBO_DEC &&
+                       conf->priority > dev_info.max_ul_queue_priority) {
                        rte_bbdev_log(ERR,
                                        "Priority (%u) of queue %u of bdev %u must be <= %u",
                                        conf->priority, queue_id, dev_id,
-                                       dev_info.max_queue_priority);
+                                       dev_info.max_ul_queue_priority);
+                       return -EINVAL;
+               }
+               if (conf->op_type == RTE_BBDEV_OP_TURBO_ENC &&
+                       conf->priority > dev_info.max_dl_queue_priority) {
+                       rte_bbdev_log(ERR,
+                                       "Priority (%u) of queue %u of bdev %u must be <= %u",
+                                       conf->priority, queue_id, dev_id,
+                                       dev_info.max_dl_queue_priority);
                        return -EINVAL;
                }
        }
@@ -1104,12 +1126,7 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
        return NULL;
 }
 
-
-int bbdev_logtype;
-
-RTE_INIT(rte_bbdev_init_log);
-static void
-rte_bbdev_init_log(void)
+RTE_INIT(rte_bbdev_init_log)
 {
        bbdev_logtype = rte_log_register("lib.bbdev");
        if (bbdev_logtype >= 0)