crypto/scheduler: add mode-specific threshold parameter

This patch adds packet-size-distr mode specific parameter parser
to support different threshold packet size value other than default
128 bytes.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
This commit is contained in:
Fan Zhang 2018-07-23 14:17:15 +01:00 committed by Pablo de Lara
parent ee9586dd15
commit 6760463c9f
3 changed files with 60 additions and 1 deletions

View File

@ -137,7 +137,12 @@ operation:
**option_type** must be **CDEV_SCHED_OPTION_THRESHOLD** and **option** should
point to a rte_cryptodev_scheduler_threshold_option structure filled with
appropriate threshold value. Please NOTE this threshold has be a power-of-2
unsigned integer.
unsigned integer. It is possible to use **mode_param** initialization
parameter to achieve the same purpose. For example:
... --vdev "crypto_scheduler,mode=packet-size-distr,mode_param=threshold:512" ...
The above parameter will overwrite the threshold value to 512.
* **CDEV_SCHED_MODE_FAILOVER:**

View File

@ -76,6 +76,7 @@ enum rte_cryptodev_schedule_option_type {
/**
* Threshold option structure
*/
#define RTE_CRYPTODEV_SCHEDULER_PARAM_THRES "threshold"
struct rte_cryptodev_scheduler_threshold_option {
uint32_t threshold; /**< Threshold for packet-size mode */
};

View File

@ -71,6 +71,8 @@ const struct scheduler_parse_map scheduler_ordering_map[] = {
{"disable", 0}
};
#define CDEV_SCHED_MODE_PARAM_SEP_CHAR ':'
static int
cryptodev_scheduler_create(const char *name,
struct rte_vdev_device *vdev,
@ -110,6 +112,15 @@ cryptodev_scheduler_create(const char *name,
if (init_params->mode > CDEV_SCHED_MODE_USERDEFINED &&
init_params->mode < CDEV_SCHED_MODE_COUNT) {
union {
struct rte_cryptodev_scheduler_threshold_option
threshold_option;
} option;
enum rte_cryptodev_schedule_option_type option_type;
char param_name[RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN] = {0};
char param_val[RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN] = {0};
char *s, *end;
ret = rte_cryptodev_scheduler_mode_set(dev->data->dev_id,
init_params->mode);
if (ret < 0) {
@ -125,6 +136,48 @@ cryptodev_scheduler_create(const char *name,
scheduler_mode_map[i].name);
break;
}
if (strlen(init_params->mode_param_str) > 0) {
s = strchr(init_params->mode_param_str,
CDEV_SCHED_MODE_PARAM_SEP_CHAR);
if (s == NULL) {
CR_SCHED_LOG(ERR, "Invalid mode param");
return -EINVAL;
}
strlcpy(param_name, init_params->mode_param_str,
s - init_params->mode_param_str + 1);
s++;
strlcpy(param_val, s,
RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN);
switch (init_params->mode) {
case CDEV_SCHED_MODE_PKT_SIZE_DISTR:
if (strcmp(param_name,
RTE_CRYPTODEV_SCHEDULER_PARAM_THRES)
!= 0) {
CR_SCHED_LOG(ERR, "Invalid mode param");
return -EINVAL;
}
option_type = CDEV_SCHED_OPTION_THRESHOLD;
option.threshold_option.threshold =
strtoul(param_val, &end, 0);
break;
default:
CR_SCHED_LOG(ERR, "Invalid mode param");
return -EINVAL;
}
if (sched_ctx->ops.option_set(dev, option_type,
(void *)&option) < 0) {
CR_SCHED_LOG(ERR, "Invalid mode param");
return -EINVAL;
}
RTE_LOG(INFO, PMD, " Sched mode param (%s = %s)\n",
param_name, param_val);
}
}
sched_ctx->reordering_enabled = init_params->enable_ordering;