here. Multiple cryptodevs can be attached initially by presenting this
parameter multiple times.
+* mode: Specify the scheduling mode of the PMD. The supported scheduling
+ mode parameter values are specified in the "Cryptodev Scheduler Modes
+ Overview" section.
+
+* ordering: Specify the status of the crypto operations ordering feature.
+ The value of this parameter can be "enable" or "disable". This feature
+ is disabled by default.
+
Example:
.. code-block:: console
* **CDEV_SCHED_MODE_ROUNDROBIN:**
+ *Initialization mode parameter*: **round-robin**
+
Round-robin mode, which distributes the enqueued burst of crypto ops
among its slaves in a round-robin manner. This mode may help to fill
the throughput gap between the physical core and the existing cryptodevs
* **CDEV_SCHED_MODE_PKT_SIZE_DISTR:**
+ *Initialization mode parameter*: **packet-size-distr**
+
Packet-size based distribution mode, which works with 2 slaves, the primary
slave and the secondary slave, and distributes the enqueued crypto
operations to them based on their data lengths. A crypto operation will be
* **CDEV_SCHED_MODE_FAILOVER:**
+ *Initialization mode parameter*: **fail-over**
+
Fail-over mode, which works with 2 slaves, the primary slave and the
secondary slave. In this mode, the scheduler will enqueue the incoming
crypto operation burst to the primary slave. When one or more crypto
struct rte_crypto_vdev_init_params def_p;
uint32_t nb_slaves;
uint8_t slaves[RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES];
+ enum rte_cryptodev_scheduler_mode mode;
+ uint32_t enable_ordering;
};
-#define RTE_CRYPTODEV_VDEV_NAME ("name")
-#define RTE_CRYPTODEV_VDEV_SLAVE ("slave")
+#define RTE_CRYPTODEV_VDEV_NAME ("name")
+#define RTE_CRYPTODEV_VDEV_SLAVE ("slave")
+#define RTE_CRYPTODEV_VDEV_MODE ("mode")
+#define RTE_CRYPTODEV_VDEV_ORDERING ("ordering")
#define RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG ("max_nb_queue_pairs")
#define RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG ("max_nb_sessions")
#define RTE_CRYPTODEV_VDEV_SOCKET_ID ("socket_id")
const char *scheduler_valid_params[] = {
RTE_CRYPTODEV_VDEV_NAME,
RTE_CRYPTODEV_VDEV_SLAVE,
+ RTE_CRYPTODEV_VDEV_MODE,
+ RTE_CRYPTODEV_VDEV_ORDERING,
RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG,
RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG,
RTE_CRYPTODEV_VDEV_SOCKET_ID
};
+struct scheduler_parse_map {
+ const char *name;
+ uint32_t val;
+};
+
+const struct scheduler_parse_map scheduler_mode_map[] = {
+ {RTE_STR(SCHEDULER_MODE_NAME_ROUND_ROBIN),
+ CDEV_SCHED_MODE_ROUNDROBIN},
+ {RTE_STR(SCHEDULER_MODE_NAME_PKT_SIZE_DISTR),
+ CDEV_SCHED_MODE_PKT_SIZE_DISTR},
+ {RTE_STR(SCHEDULER_MODE_NAME_FAIL_OVER),
+ CDEV_SCHED_MODE_FAILOVER}
+};
+
+const struct scheduler_parse_map scheduler_ordering_map[] = {
+ {"enable", 1},
+ {"disable", 0}
+};
+
static int
attach_init_slaves(uint8_t scheduler_id,
const uint8_t *slaves, const uint8_t nb_slaves)
return status;
}
- RTE_LOG(INFO, PMD, " Attached slave cryptodev %s\n",
- dev->data->name);
+ RTE_LOG(INFO, PMD, " Attached Slave %s\n", dev->data->name);
}
return 0;
char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN] = {0};
struct rte_cryptodev *dev;
struct scheduler_ctx *sched_ctx;
+ uint32_t i;
+ int ret;
if (init_params->def_p.name[0] == '\0') {
- int ret = rte_cryptodev_pmd_create_dev_name(
+ ret = rte_cryptodev_pmd_create_dev_name(
crypto_dev_name,
RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
sched_ctx->max_nb_queue_pairs =
init_params->def_p.max_nb_queue_pairs;
- return attach_init_slaves(dev->data->dev_id, init_params->slaves,
+ ret = attach_init_slaves(dev->data->dev_id, init_params->slaves,
init_params->nb_slaves);
+ if (ret < 0) {
+ rte_cryptodev_pmd_release_device(dev);
+ return ret;
+ }
+
+ if (init_params->mode > CDEV_SCHED_MODE_USERDEFINED &&
+ init_params->mode < CDEV_SCHED_MODE_COUNT) {
+ ret = rte_crpytodev_scheduler_mode_set(dev->data->dev_id,
+ init_params->mode);
+ if (ret < 0) {
+ rte_cryptodev_pmd_release_device(dev);
+ return ret;
+ }
+
+ for (i = 0; i < RTE_DIM(scheduler_mode_map); i++) {
+ if (scheduler_mode_map[i].val != sched_ctx->mode)
+ continue;
+
+ RTE_LOG(INFO, PMD, " Scheduling mode = %s\n",
+ scheduler_mode_map[i].name);
+ break;
+ }
+ }
+
+ sched_ctx->reordering_enabled = init_params->enable_ordering;
+
+ for (i = 0; i < RTE_DIM(scheduler_ordering_map); i++) {
+ if (scheduler_ordering_map[i].val !=
+ sched_ctx->reordering_enabled)
+ continue;
+
+ RTE_LOG(INFO, PMD, " Packet ordering = %s\n",
+ scheduler_ordering_map[i].name);
+
+ break;
+ }
+
+ return 0;
}
static int
*i = atoi(value);
if (*i < 0) {
CS_LOG_ERR("Argument has to be positive.\n");
- return -1;
+ return -EINVAL;
}
return 0;
CS_LOG_ERR("Invalid name %s, should be less than "
"%u bytes.\n", value,
RTE_CRYPTODEV_NAME_MAX_LEN - 1);
- return -1;
+ return -EINVAL;
}
strncpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
if (!dev) {
RTE_LOG(ERR, PMD, "Invalid slave name %s.\n", value);
- return -1;
+ return -EINVAL;
}
if (param->nb_slaves >= RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES - 1) {
CS_LOG_ERR("Too many slaves.\n");
- return -1;
+ return -ENOMEM;
}
param->slaves[param->nb_slaves] = dev->data->dev_id;
return 0;
}
+static int
+parse_mode_arg(const char *key __rte_unused,
+ const char *value, void *extra_args)
+{
+ struct scheduler_init_params *param = extra_args;
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(scheduler_mode_map); i++) {
+ if (strcmp(value, scheduler_mode_map[i].name) == 0) {
+ param->mode = (enum rte_cryptodev_scheduler_mode)
+ scheduler_mode_map[i].val;
+ break;
+ }
+ }
+
+ if (i == RTE_DIM(scheduler_mode_map)) {
+ CS_LOG_ERR("Unrecognized input.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+parse_ordering_arg(const char *key __rte_unused,
+ const char *value, void *extra_args)
+{
+ struct scheduler_init_params *param = extra_args;
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(scheduler_ordering_map); i++) {
+ if (strcmp(value, scheduler_ordering_map[i].name) == 0) {
+ param->enable_ordering =
+ scheduler_ordering_map[i].val;
+ break;
+ }
+ }
+
+ if (i == RTE_DIM(scheduler_ordering_map)) {
+ CS_LOG_ERR("Unrecognized input.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int
scheduler_parse_init_params(struct scheduler_init_params *params,
const char *input_args)
if (ret < 0)
goto free_kvlist;
+ ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_MODE,
+ &parse_mode_arg, params);
+ if (ret < 0)
+ goto free_kvlist;
+
+ ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_ORDERING,
+ &parse_ordering_arg, params);
+ if (ret < 0)
+ goto free_kvlist;
+
if (params->def_p.socket_id >= number_of_sockets()) {
CDEV_LOG_ERR("Invalid socket id specified to create "
"the virtual crypto device on");
""
},
.nb_slaves = 0,
- .slaves = {0}
+ .slaves = {0},
+ .mode = CDEV_SCHED_MODE_NOT_SET,
+ .enable_ordering = 0
};
scheduler_parse_init_params(&init_params, input_args);