* [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option support @ 2017-02-21 14:29 Fan Zhang 2017-03-21 14:34 ` De Lara Guarch, Pablo 2017-03-31 15:30 ` [dpdk-dev] [PATCH v2] " Fan Zhang 0 siblings, 2 replies; 10+ messages in thread From: Fan Zhang @ 2017-02-21 14:29 UTC (permalink / raw) To: dev; +Cc: pablo.de.lara.guarch Some scheduling modes may need extra options to be configured, this patch adds the function prototype for setting/getting options. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> --- drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 57 ++++++++++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 27 ++++++++++ .../scheduler/rte_cryptodev_scheduler_operations.h | 5 ++ drivers/crypto/scheduler/scheduler_roundrobin.c | 10 +++- 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 11e8143..c1491ff 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -469,3 +469,60 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, return 0; } + +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (dev->data->dev_started) { + CS_LOG_ERR("Illegal operation"); + return -EBUSY; + } + + sched_ctx = dev->data->dev_private; + + return (*sched_ctx->ops.option_config)(dev, option, 1); +} + +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + sched_ctx = dev->data->dev_private; + + return (*sched_ctx->ops.option_config)(dev, option, 0); +} diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index 7ef44e7..c10867a 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -143,6 +143,33 @@ rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id, int rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id); +/** + * Set the mode specific option + * + * @param dev_id The target scheduler device ID + * option The mode specific option + * + * @return + * 0 if successful + * negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, void *option); + +/** + * Get the mode specific option + * + * @param dev_id The target scheduler device ID + * option The mode specific option to be written + * + * @return + * 0 if successful + * negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, void *option); + + typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx, struct rte_crypto_op **ops, uint16_t nb_ops); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h index 93cf123..fe36c1e 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h @@ -53,6 +53,9 @@ typedef int (*rte_cryptodev_scheduler_config_queue_pair)( typedef int (*rte_cryptodev_scheduler_create_private_ctx)( struct rte_cryptodev *dev); +typedef int (*rte_cryptodev_scheduler_config_option)( + struct rte_cryptodev *dev, void *option, uint32_t is_set); + struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_slave_attach_t slave_attach; rte_cryptodev_scheduler_slave_attach_t slave_detach; @@ -63,6 +66,8 @@ struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_config_queue_pair config_queue_pair; rte_cryptodev_scheduler_create_private_ctx create_private_ctx; + + rte_cryptodev_scheduler_config_option option_config; }; #ifdef __cplusplus diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c index 9545aa9..d262edd 100644 --- a/drivers/crypto/scheduler/scheduler_roundrobin.c +++ b/drivers/crypto/scheduler/scheduler_roundrobin.c @@ -415,13 +415,21 @@ scheduler_create_private_ctx(__rte_unused struct rte_cryptodev *dev) return 0; } +static int +scheduler_option(__rte_unused struct rte_cryptodev *dev, + __rte_unused void *option, __rte_unused uint32_t is_set) +{ + return 0; +} + struct rte_cryptodev_scheduler_ops scheduler_rr_ops = { slave_attach, slave_detach, scheduler_start, scheduler_stop, scheduler_config_qp, - scheduler_create_private_ctx + scheduler_create_private_ctx, + scheduler_option }; struct rte_cryptodev_scheduler scheduler = { -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option support 2017-02-21 14:29 [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option support Fan Zhang @ 2017-03-21 14:34 ` De Lara Guarch, Pablo 2017-03-31 15:30 ` [dpdk-dev] [PATCH v2] " Fan Zhang 1 sibling, 0 replies; 10+ messages in thread From: De Lara Guarch, Pablo @ 2017-03-21 14:34 UTC (permalink / raw) To: Zhang, Roy Fan, dev Hi Fan, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang > Sent: Tuesday, February 21, 2017 2:30 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo > Subject: [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option > support > > Some scheduling modes may need extra options to be configured, > this patch adds the function prototype for setting/getting > options. > > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> > --- > drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 57 > ++++++++++++++++++++++ > drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 27 ++++++++++ > .../scheduler/rte_cryptodev_scheduler_operations.h | 5 ++ > drivers/crypto/scheduler/scheduler_roundrobin.c | 10 +++- > 4 files changed, 98 insertions(+), 1 deletion(-) > You are adding two new functions to the API, so you should add them in the version.map file. Thanks, Pablo ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] crypto/scheduler: add mode specific option support 2017-02-21 14:29 [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option support Fan Zhang 2017-03-21 14:34 ` De Lara Guarch, Pablo @ 2017-03-31 15:30 ` Fan Zhang 2017-04-05 8:46 ` De Lara Guarch, Pablo 2017-04-05 9:02 ` [dpdk-dev] [PATCH v3] " Fan Zhang 1 sibling, 2 replies; 10+ messages in thread From: Fan Zhang @ 2017-03-31 15:30 UTC (permalink / raw) To: dev; +Cc: pablo.de.lara.guarch, sergio.gonzalez.monroy, declan.doherty Some scheduling modes may need extra options to be configured, this patch adds the function prototype for setting/getting options. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> --- v2: - Updated for option support in packet-size based mode - Updated version map file drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 63 ++++++++++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 55 +++++++++++++++++++ .../scheduler/rte_cryptodev_scheduler_operations.h | 13 +++++ .../scheduler/rte_pmd_crypto_scheduler_version.map | 2 + drivers/crypto/scheduler/scheduler_failover.c | 2 + .../crypto/scheduler/scheduler_pkt_size_distr.c | 47 ++++++++++++++++ drivers/crypto/scheduler/scheduler_roundrobin.c | 4 +- 7 files changed, 185 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 6018857..6a1ff21 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -466,6 +466,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, sched_ctx->ops.scheduler_stop = scheduler->ops->scheduler_stop; sched_ctx->ops.slave_attach = scheduler->ops->slave_attach; sched_ctx->ops.slave_detach = scheduler->ops->slave_detach; + sched_ctx->ops.option_set = scheduler->ops->option_set; + sched_ctx->ops.option_get = scheduler->ops->option_get; if (sched_ctx->private_ctx) rte_free(sched_ctx->private_ctx); @@ -515,3 +517,64 @@ rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves) return (int)nb_slaves; } + +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (option_type == CDEV_SCHED_OPTION_NOT_SET || + option_type >= CDEV_SCHED_OPTION_COUNT) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->data->dev_started) { + CS_LOG_ERR("Illegal operation"); + return -EBUSY; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_set, -ENOTSUP); + + return (*sched_ctx->ops.option_set)(dev, option_type, option); +} + +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_get, -ENOTSUP); + + return (*sched_ctx->ops.option_get)(dev, option_type, option); +} diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index 1b52261..df903b0 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -63,6 +63,23 @@ enum rte_cryptodev_scheduler_mode { #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64) #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256) +/** + * Crypto scheduler option types + */ +enum rte_cryptodev_schedule_option_type { + CDEV_SCHED_OPTION_NOT_SET = 0, + CDEV_SCHED_OPTION_THRESHOLD, + + CDEV_SCHED_OPTION_COUNT +}; + +/** + * Threshold option structure + */ +struct rte_cryptodev_scheduler_threshold_option { + uint32_t threshold; +}; + struct rte_cryptodev_scheduler; /** @@ -171,6 +188,44 @@ rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id); int rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves); +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * The specific mode's option structure + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * If successful, the function will write back the current + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx, struct rte_crypto_op **ops, uint16_t nb_ops); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h index 93cf123..42fe9e6 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h @@ -53,6 +53,16 @@ typedef int (*rte_cryptodev_scheduler_config_queue_pair)( typedef int (*rte_cryptodev_scheduler_create_private_ctx)( struct rte_cryptodev *dev); +typedef int (*rte_cryptodev_scheduler_config_option_set)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + +typedef int (*rte_cryptodev_scheduler_config_option_get)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_slave_attach_t slave_attach; rte_cryptodev_scheduler_slave_attach_t slave_detach; @@ -63,6 +73,9 @@ struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_config_queue_pair config_queue_pair; rte_cryptodev_scheduler_create_private_ctx create_private_ctx; + + rte_cryptodev_scheduler_config_option_set option_set; + rte_cryptodev_scheduler_config_option_get option_get; }; #ifdef __cplusplus diff --git a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map index 69cf0c6..7c45eaf 100644 --- a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map +++ b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map @@ -15,5 +15,7 @@ DPDK_17.05 { global: rte_cryptodev_scheduler_slaves_get; + rte_cryptodev_scheduler_option_set; + rte_cryptodev_scheduler_option_get; } DPDK_17.02; diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c index 6359f04..2471a5f 100644 --- a/drivers/crypto/scheduler/scheduler_failover.c +++ b/drivers/crypto/scheduler/scheduler_failover.c @@ -271,6 +271,8 @@ struct rte_cryptodev_scheduler_ops scheduler_fo_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler fo_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c index 1066451..94196d9 100644 --- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c +++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c @@ -399,6 +399,51 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) return 0; } +static int +scheduler_option_set(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + uint32_t threshold; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold = ((struct rte_cryptodev_scheduler_threshold_option *) + option)->threshold; + if (!rte_is_power_of_2(threshold)) { + CS_LOG_ERR("Threshold is not power of 2"); + return -EINVAL; + } + + psd_ctx->threshold = ~(threshold - 1); + + return 0; +} + +static int +scheduler_option_get(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + struct rte_cryptodev_scheduler_threshold_option *threshold_option; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold_option = option; + threshold_option->threshold = (~psd_ctx->threshold) + 1; + + return 0; +} struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { slave_attach, @@ -407,6 +452,8 @@ struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + scheduler_option_set, + scheduler_option_get }; struct rte_cryptodev_scheduler psd_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c index 1fb6ce7..f618d6c 100644 --- a/drivers/crypto/scheduler/scheduler_roundrobin.c +++ b/drivers/crypto/scheduler/scheduler_roundrobin.c @@ -265,7 +265,9 @@ struct rte_cryptodev_scheduler_ops scheduler_rr_ops = { scheduler_start, scheduler_stop, scheduler_config_qp, - scheduler_create_private_ctx + scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler scheduler = { -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] crypto/scheduler: add mode specific option support 2017-03-31 15:30 ` [dpdk-dev] [PATCH v2] " Fan Zhang @ 2017-04-05 8:46 ` De Lara Guarch, Pablo 2017-04-05 9:02 ` [dpdk-dev] [PATCH v3] " Fan Zhang 1 sibling, 0 replies; 10+ messages in thread From: De Lara Guarch, Pablo @ 2017-04-05 8:46 UTC (permalink / raw) To: Zhang, Roy Fan, dev; +Cc: Gonzalez Monroy, Sergio, Doherty, Declan Hi Fan, > -----Original Message----- > From: Zhang, Roy Fan > Sent: Friday, March 31, 2017 4:30 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo; Gonzalez Monroy, Sergio; Doherty, Declan > Subject: [PATCH v2] crypto/scheduler: add mode specific option support > > Some scheduling modes may need extra options to be configured, > this patch adds the function prototype for setting/getting > options. > > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> > --- > > v2: > - Updated for option support in packet-size based mode > - Updated version map file > > drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 63 > ++++++++++++++++++++++ > drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 55 > +++++++++++++++++++ > .../scheduler/rte_cryptodev_scheduler_operations.h | 13 +++++ > .../scheduler/rte_pmd_crypto_scheduler_version.map | 2 + > drivers/crypto/scheduler/scheduler_failover.c | 2 + > .../crypto/scheduler/scheduler_pkt_size_distr.c | 47 ++++++++++++++++ > drivers/crypto/scheduler/scheduler_roundrobin.c | 4 +- > 7 files changed, 185 insertions(+), 1 deletion(-) > ... > diff --git > a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map > b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map > index 69cf0c6..7c45eaf 100644 > --- a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map > +++ b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map > @@ -15,5 +15,7 @@ DPDK_17.05 { > global: > > rte_cryptodev_scheduler_slaves_get; > + rte_cryptodev_scheduler_option_set; > + rte_cryptodev_scheduler_option_get; This has to be in alphabetical order. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v3] crypto/scheduler: add mode specific option support 2017-03-31 15:30 ` [dpdk-dev] [PATCH v2] " Fan Zhang 2017-04-05 8:46 ` De Lara Guarch, Pablo @ 2017-04-05 9:02 ` Fan Zhang 2017-04-05 10:02 ` Declan Doherty 2017-04-05 15:54 ` [dpdk-dev] [PATCH v4] " Fan Zhang 1 sibling, 2 replies; 10+ messages in thread From: Fan Zhang @ 2017-04-05 9:02 UTC (permalink / raw) To: dev; +Cc: pablo.de.lara.guarch, stable Some scheduling modes may need extra options to be configured, this patch adds the function prototype for setting/getting options. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> --- v3: - Fixed the order of APIs in the version map file v2: - Updated for option support in packet-size based mode - Updated version map file drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 63 ++++++++++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 55 +++++++++++++++++++ .../scheduler/rte_cryptodev_scheduler_operations.h | 13 +++++ .../scheduler/rte_pmd_crypto_scheduler_version.map | 2 + drivers/crypto/scheduler/scheduler_failover.c | 2 + .../crypto/scheduler/scheduler_pkt_size_distr.c | 47 ++++++++++++++++ drivers/crypto/scheduler/scheduler_roundrobin.c | 4 +- 7 files changed, 185 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 6018857..6a1ff21 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -466,6 +466,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, sched_ctx->ops.scheduler_stop = scheduler->ops->scheduler_stop; sched_ctx->ops.slave_attach = scheduler->ops->slave_attach; sched_ctx->ops.slave_detach = scheduler->ops->slave_detach; + sched_ctx->ops.option_set = scheduler->ops->option_set; + sched_ctx->ops.option_get = scheduler->ops->option_get; if (sched_ctx->private_ctx) rte_free(sched_ctx->private_ctx); @@ -515,3 +517,64 @@ rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves) return (int)nb_slaves; } + +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (option_type == CDEV_SCHED_OPTION_NOT_SET || + option_type >= CDEV_SCHED_OPTION_COUNT) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->data->dev_started) { + CS_LOG_ERR("Illegal operation"); + return -EBUSY; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_set, -ENOTSUP); + + return (*sched_ctx->ops.option_set)(dev, option_type, option); +} + +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_get, -ENOTSUP); + + return (*sched_ctx->ops.option_get)(dev, option_type, option); +} diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index 1da096b..7b01d6f 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -70,6 +70,23 @@ enum rte_cryptodev_scheduler_mode { #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64) #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256) +/** + * Crypto scheduler option types + */ +enum rte_cryptodev_schedule_option_type { + CDEV_SCHED_OPTION_NOT_SET = 0, + CDEV_SCHED_OPTION_THRESHOLD, + + CDEV_SCHED_OPTION_COUNT +}; + +/** + * Threshold option structure + */ +struct rte_cryptodev_scheduler_threshold_option { + uint32_t threshold; +}; + struct rte_cryptodev_scheduler; /** @@ -178,6 +195,44 @@ rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id); int rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves); +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * The specific mode's option structure + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * If successful, the function will write back the current + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx, struct rte_crypto_op **ops, uint16_t nb_ops); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h index 93cf123..42fe9e6 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h @@ -53,6 +53,16 @@ typedef int (*rte_cryptodev_scheduler_config_queue_pair)( typedef int (*rte_cryptodev_scheduler_create_private_ctx)( struct rte_cryptodev *dev); +typedef int (*rte_cryptodev_scheduler_config_option_set)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + +typedef int (*rte_cryptodev_scheduler_config_option_get)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_slave_attach_t slave_attach; rte_cryptodev_scheduler_slave_attach_t slave_detach; @@ -63,6 +73,9 @@ struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_config_queue_pair config_queue_pair; rte_cryptodev_scheduler_create_private_ctx create_private_ctx; + + rte_cryptodev_scheduler_config_option_set option_set; + rte_cryptodev_scheduler_config_option_get option_get; }; #ifdef __cplusplus diff --git a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map index 69cf0c6..e7ca188 100644 --- a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map +++ b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map @@ -14,6 +14,8 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_cryptodev_scheduler_option_get; + rte_cryptodev_scheduler_option_set; rte_cryptodev_scheduler_slaves_get; } DPDK_17.02; diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c index 6359f04..2471a5f 100644 --- a/drivers/crypto/scheduler/scheduler_failover.c +++ b/drivers/crypto/scheduler/scheduler_failover.c @@ -271,6 +271,8 @@ struct rte_cryptodev_scheduler_ops scheduler_fo_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler fo_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c index 1066451..94196d9 100644 --- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c +++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c @@ -399,6 +399,51 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) return 0; } +static int +scheduler_option_set(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + uint32_t threshold; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold = ((struct rte_cryptodev_scheduler_threshold_option *) + option)->threshold; + if (!rte_is_power_of_2(threshold)) { + CS_LOG_ERR("Threshold is not power of 2"); + return -EINVAL; + } + + psd_ctx->threshold = ~(threshold - 1); + + return 0; +} + +static int +scheduler_option_get(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + struct rte_cryptodev_scheduler_threshold_option *threshold_option; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold_option = option; + threshold_option->threshold = (~psd_ctx->threshold) + 1; + + return 0; +} struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { slave_attach, @@ -407,6 +452,8 @@ struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + scheduler_option_set, + scheduler_option_get }; struct rte_cryptodev_scheduler psd_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c index 1fb6ce7..f618d6c 100644 --- a/drivers/crypto/scheduler/scheduler_roundrobin.c +++ b/drivers/crypto/scheduler/scheduler_roundrobin.c @@ -265,7 +265,9 @@ struct rte_cryptodev_scheduler_ops scheduler_rr_ops = { scheduler_start, scheduler_stop, scheduler_config_qp, - scheduler_create_private_ctx + scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler scheduler = { -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] crypto/scheduler: add mode specific option support 2017-04-05 9:02 ` [dpdk-dev] [PATCH v3] " Fan Zhang @ 2017-04-05 10:02 ` Declan Doherty 2017-04-05 11:43 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon 2017-04-05 15:54 ` [dpdk-dev] [PATCH v4] " Fan Zhang 1 sibling, 1 reply; 10+ messages in thread From: Declan Doherty @ 2017-04-05 10:02 UTC (permalink / raw) To: Fan Zhang, dev; +Cc: pablo.de.lara.guarch, stable On 05/04/2017 10:02 AM, Fan Zhang wrote: > Some scheduling modes may need extra options to be configured, > this patch adds the function prototype for setting/getting > options. > > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> > --- ... > Fan, could you send a documentation patch with a update to the scheduler documentation about the new option introduced in this patch. Acked-by: Declan Doherty <declan.doherty@intel.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH v3] crypto/scheduler: add mode specific option support 2017-04-05 10:02 ` Declan Doherty @ 2017-04-05 11:43 ` Thomas Monjalon 0 siblings, 0 replies; 10+ messages in thread From: Thomas Monjalon @ 2017-04-05 11:43 UTC (permalink / raw) To: Declan Doherty; +Cc: stable, Fan Zhang, dev, pablo.de.lara.guarch 2017-04-05 11:02, Declan Doherty: > On 05/04/2017 10:02 AM, Fan Zhang wrote: > > Some scheduling modes may need extra options to be configured, > > this patch adds the function prototype for setting/getting > > options. > > > > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> > > --- > ... > > > > Fan, could you send a documentation patch with a update to the scheduler > documentation about the new option introduced in this patch. > > Acked-by: Declan Doherty <declan.doherty@intel.com> It is always better to have this kind of documentation update within the same patch as code update. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v4] crypto/scheduler: add mode specific option support 2017-04-05 9:02 ` [dpdk-dev] [PATCH v3] " Fan Zhang 2017-04-05 10:02 ` Declan Doherty @ 2017-04-05 15:54 ` Fan Zhang 2017-04-05 16:07 ` [dpdk-dev] [PATCH v5] " Fan Zhang 1 sibling, 1 reply; 10+ messages in thread From: Fan Zhang @ 2017-04-05 15:54 UTC (permalink / raw) To: dev; +Cc: pablo.de.lara.guarch, declan.doherty Some scheduling modes may need extra options to be configured, this patch adds the function prototype for setting/getting options. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> --- v4: - Added documentation v3: - Fixed the order of APIs in the version map file v2: - Updated for option support in packet-size based mode - Updated version map file doc/guides/cryptodevs/scheduler.rst | 7 +++ doc/guides/rel_notes/release_17_05.rst | 9 +++- drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 63 ++++++++++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 55 +++++++++++++++++++ .../scheduler/rte_cryptodev_scheduler_operations.h | 13 +++++ .../scheduler/rte_pmd_crypto_scheduler_version.map | 2 + drivers/crypto/scheduler/scheduler_failover.c | 2 + .../crypto/scheduler/scheduler_pkt_size_distr.c | 47 ++++++++++++++++ drivers/crypto/scheduler/scheduler_roundrobin.c | 4 +- 9 files changed, 200 insertions(+), 2 deletions(-) diff --git a/doc/guides/cryptodevs/scheduler.rst b/doc/guides/cryptodevs/scheduler.rst index 0482331..be462aa 100644 --- a/doc/guides/cryptodevs/scheduler.rst +++ b/doc/guides/cryptodevs/scheduler.rst @@ -154,6 +154,13 @@ operation: its own, by making use of the available CPU cycles to deal with smaller crypto workloads. + The threshold is set to 128 bytes by default. It can be updated by calling + function **rte_cryptodev_scheduler_option_set**. The parameter of + **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. + * **CDEV_SCHED_MODE_FAILOVER:** *Initialization mode parameter*: **fail-over** diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst index 3a2cb12..73217c5 100644 --- a/doc/guides/rel_notes/release_17_05.rst +++ b/doc/guides/rel_notes/release_17_05.rst @@ -231,7 +231,6 @@ New Features the scheduler will enqueue the incoming crypto operation burst to the primary slave. When one or more crypto operations fail to be enqueued, then they will be enqueued to the secondary slave. - * **Updated the QAT PMD.** The QAT PMD has been updated with additional support for: @@ -252,6 +251,14 @@ New Features * DES DOCSIS BPI algorithm. +* **Added mode specific option support to Cryptodev Scheduler PMD.** + + Originally, different modes of the cryptodev scheduler have no way to be + individually configured. By introducing this feature,each scheduling mode + now can be individually configured by the newly added APIs. E.g., the + packet-size based distribution mode now can be configured the threshold + values. + Resolved Issues --------------- diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 6018857..6a1ff21 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -466,6 +466,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, sched_ctx->ops.scheduler_stop = scheduler->ops->scheduler_stop; sched_ctx->ops.slave_attach = scheduler->ops->slave_attach; sched_ctx->ops.slave_detach = scheduler->ops->slave_detach; + sched_ctx->ops.option_set = scheduler->ops->option_set; + sched_ctx->ops.option_get = scheduler->ops->option_get; if (sched_ctx->private_ctx) rte_free(sched_ctx->private_ctx); @@ -515,3 +517,64 @@ rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves) return (int)nb_slaves; } + +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (option_type == CDEV_SCHED_OPTION_NOT_SET || + option_type >= CDEV_SCHED_OPTION_COUNT) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->data->dev_started) { + CS_LOG_ERR("Illegal operation"); + return -EBUSY; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_set, -ENOTSUP); + + return (*sched_ctx->ops.option_set)(dev, option_type, option); +} + +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_get, -ENOTSUP); + + return (*sched_ctx->ops.option_get)(dev, option_type, option); +} diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index 1da096b..7b01d6f 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -70,6 +70,23 @@ enum rte_cryptodev_scheduler_mode { #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64) #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256) +/** + * Crypto scheduler option types + */ +enum rte_cryptodev_schedule_option_type { + CDEV_SCHED_OPTION_NOT_SET = 0, + CDEV_SCHED_OPTION_THRESHOLD, + + CDEV_SCHED_OPTION_COUNT +}; + +/** + * Threshold option structure + */ +struct rte_cryptodev_scheduler_threshold_option { + uint32_t threshold; +}; + struct rte_cryptodev_scheduler; /** @@ -178,6 +195,44 @@ rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id); int rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves); +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * The specific mode's option structure + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * If successful, the function will write back the current + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx, struct rte_crypto_op **ops, uint16_t nb_ops); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h index 93cf123..42fe9e6 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h @@ -53,6 +53,16 @@ typedef int (*rte_cryptodev_scheduler_config_queue_pair)( typedef int (*rte_cryptodev_scheduler_create_private_ctx)( struct rte_cryptodev *dev); +typedef int (*rte_cryptodev_scheduler_config_option_set)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + +typedef int (*rte_cryptodev_scheduler_config_option_get)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_slave_attach_t slave_attach; rte_cryptodev_scheduler_slave_attach_t slave_detach; @@ -63,6 +73,9 @@ struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_config_queue_pair config_queue_pair; rte_cryptodev_scheduler_create_private_ctx create_private_ctx; + + rte_cryptodev_scheduler_config_option_set option_set; + rte_cryptodev_scheduler_config_option_get option_get; }; #ifdef __cplusplus diff --git a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map index 69cf0c6..e7ca188 100644 --- a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map +++ b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map @@ -14,6 +14,8 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_cryptodev_scheduler_option_get; + rte_cryptodev_scheduler_option_set; rte_cryptodev_scheduler_slaves_get; } DPDK_17.02; diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c index 6359f04..2471a5f 100644 --- a/drivers/crypto/scheduler/scheduler_failover.c +++ b/drivers/crypto/scheduler/scheduler_failover.c @@ -271,6 +271,8 @@ struct rte_cryptodev_scheduler_ops scheduler_fo_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler fo_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c index 1066451..94196d9 100644 --- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c +++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c @@ -399,6 +399,51 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) return 0; } +static int +scheduler_option_set(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + uint32_t threshold; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold = ((struct rte_cryptodev_scheduler_threshold_option *) + option)->threshold; + if (!rte_is_power_of_2(threshold)) { + CS_LOG_ERR("Threshold is not power of 2"); + return -EINVAL; + } + + psd_ctx->threshold = ~(threshold - 1); + + return 0; +} + +static int +scheduler_option_get(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + struct rte_cryptodev_scheduler_threshold_option *threshold_option; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold_option = option; + threshold_option->threshold = (~psd_ctx->threshold) + 1; + + return 0; +} struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { slave_attach, @@ -407,6 +452,8 @@ struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + scheduler_option_set, + scheduler_option_get }; struct rte_cryptodev_scheduler psd_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c index 1fb6ce7..f618d6c 100644 --- a/drivers/crypto/scheduler/scheduler_roundrobin.c +++ b/drivers/crypto/scheduler/scheduler_roundrobin.c @@ -265,7 +265,9 @@ struct rte_cryptodev_scheduler_ops scheduler_rr_ops = { scheduler_start, scheduler_stop, scheduler_config_qp, - scheduler_create_private_ctx + scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler scheduler = { -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v5] crypto/scheduler: add mode specific option support 2017-04-05 15:54 ` [dpdk-dev] [PATCH v4] " Fan Zhang @ 2017-04-05 16:07 ` Fan Zhang 2017-04-17 19:46 ` De Lara Guarch, Pablo 0 siblings, 1 reply; 10+ messages in thread From: Fan Zhang @ 2017-04-05 16:07 UTC (permalink / raw) To: dev; +Cc: pablo.de.lara.guarch, declan.doherty Some scheduling modes may need extra options to be configured, this patch adds the function prototype for setting/getting options. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> --- v5: - Fixed a whitespace error v4: - Added documentation v3: - Fixed the order of APIs in the version map file v2: - Updated for option support in packet-size based mode - Updated version map file doc/guides/cryptodevs/scheduler.rst | 7 +++ doc/guides/rel_notes/release_17_05.rst | 9 +++- drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 63 ++++++++++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 55 +++++++++++++++++++ .../scheduler/rte_cryptodev_scheduler_operations.h | 13 +++++ .../scheduler/rte_pmd_crypto_scheduler_version.map | 2 + drivers/crypto/scheduler/scheduler_failover.c | 2 + .../crypto/scheduler/scheduler_pkt_size_distr.c | 47 ++++++++++++++++ drivers/crypto/scheduler/scheduler_roundrobin.c | 4 +- 9 files changed, 200 insertions(+), 2 deletions(-) diff --git a/doc/guides/cryptodevs/scheduler.rst b/doc/guides/cryptodevs/scheduler.rst index 0482331..ddc02b4 100644 --- a/doc/guides/cryptodevs/scheduler.rst +++ b/doc/guides/cryptodevs/scheduler.rst @@ -154,6 +154,13 @@ operation: its own, by making use of the available CPU cycles to deal with smaller crypto workloads. + The threshold is set to 128 bytes by default. It can be updated by calling + function **rte_cryptodev_scheduler_option_set**. The parameter of + **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. + * **CDEV_SCHED_MODE_FAILOVER:** *Initialization mode parameter*: **fail-over** diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst index 3a2cb12..73217c5 100644 --- a/doc/guides/rel_notes/release_17_05.rst +++ b/doc/guides/rel_notes/release_17_05.rst @@ -231,7 +231,6 @@ New Features the scheduler will enqueue the incoming crypto operation burst to the primary slave. When one or more crypto operations fail to be enqueued, then they will be enqueued to the secondary slave. - * **Updated the QAT PMD.** The QAT PMD has been updated with additional support for: @@ -252,6 +251,14 @@ New Features * DES DOCSIS BPI algorithm. +* **Added mode specific option support to Cryptodev Scheduler PMD.** + + Originally, different modes of the cryptodev scheduler have no way to be + individually configured. By introducing this feature,each scheduling mode + now can be individually configured by the newly added APIs. E.g., the + packet-size based distribution mode now can be configured the threshold + values. + Resolved Issues --------------- diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 6018857..6a1ff21 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -466,6 +466,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, sched_ctx->ops.scheduler_stop = scheduler->ops->scheduler_stop; sched_ctx->ops.slave_attach = scheduler->ops->slave_attach; sched_ctx->ops.slave_detach = scheduler->ops->slave_detach; + sched_ctx->ops.option_set = scheduler->ops->option_set; + sched_ctx->ops.option_get = scheduler->ops->option_get; if (sched_ctx->private_ctx) rte_free(sched_ctx->private_ctx); @@ -515,3 +517,64 @@ rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves) return (int)nb_slaves; } + +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (option_type == CDEV_SCHED_OPTION_NOT_SET || + option_type >= CDEV_SCHED_OPTION_COUNT) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->data->dev_started) { + CS_LOG_ERR("Illegal operation"); + return -EBUSY; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_set, -ENOTSUP); + + return (*sched_ctx->ops.option_set)(dev, option_type, option); +} + +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option) +{ + struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id); + struct scheduler_ctx *sched_ctx; + + if (!dev) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + if (!option) { + CS_LOG_ERR("Invalid option parameter"); + return -EINVAL; + } + + if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) { + CS_LOG_ERR("Operation not supported"); + return -ENOTSUP; + } + + sched_ctx = dev->data->dev_private; + + RTE_FUNC_PTR_OR_ERR_RET(*sched_ctx->ops.option_get, -ENOTSUP); + + return (*sched_ctx->ops.option_get)(dev, option_type, option); +} diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index 1da096b..7b01d6f 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -70,6 +70,23 @@ enum rte_cryptodev_scheduler_mode { #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64) #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256) +/** + * Crypto scheduler option types + */ +enum rte_cryptodev_schedule_option_type { + CDEV_SCHED_OPTION_NOT_SET = 0, + CDEV_SCHED_OPTION_THRESHOLD, + + CDEV_SCHED_OPTION_COUNT +}; + +/** + * Threshold option structure + */ +struct rte_cryptodev_scheduler_threshold_option { + uint32_t threshold; +}; + struct rte_cryptodev_scheduler; /** @@ -178,6 +195,44 @@ rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id); int rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves); +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * The specific mode's option structure + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + +/** + * Set the mode specific option + * + * @param dev_id + * The target scheduler device ID + * @param option_type + * The option type enumerate + * @param option + * If successful, the function will write back the current + * + * @return + * - 0 if successful + * - negative integer if otherwise. + */ +int +rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, + enum rte_cryptodev_schedule_option_type option_type, + void *option); + typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx, struct rte_crypto_op **ops, uint16_t nb_ops); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h index 93cf123..42fe9e6 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h @@ -53,6 +53,16 @@ typedef int (*rte_cryptodev_scheduler_config_queue_pair)( typedef int (*rte_cryptodev_scheduler_create_private_ctx)( struct rte_cryptodev *dev); +typedef int (*rte_cryptodev_scheduler_config_option_set)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + +typedef int (*rte_cryptodev_scheduler_config_option_get)( + struct rte_cryptodev *dev, + uint32_t option_type, + void *option); + struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_slave_attach_t slave_attach; rte_cryptodev_scheduler_slave_attach_t slave_detach; @@ -63,6 +73,9 @@ struct rte_cryptodev_scheduler_ops { rte_cryptodev_scheduler_config_queue_pair config_queue_pair; rte_cryptodev_scheduler_create_private_ctx create_private_ctx; + + rte_cryptodev_scheduler_config_option_set option_set; + rte_cryptodev_scheduler_config_option_get option_get; }; #ifdef __cplusplus diff --git a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map index 69cf0c6..e7ca188 100644 --- a/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map +++ b/drivers/crypto/scheduler/rte_pmd_crypto_scheduler_version.map @@ -14,6 +14,8 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_cryptodev_scheduler_option_get; + rte_cryptodev_scheduler_option_set; rte_cryptodev_scheduler_slaves_get; } DPDK_17.02; diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c index 6359f04..2471a5f 100644 --- a/drivers/crypto/scheduler/scheduler_failover.c +++ b/drivers/crypto/scheduler/scheduler_failover.c @@ -271,6 +271,8 @@ struct rte_cryptodev_scheduler_ops scheduler_fo_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler fo_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c index 1066451..94196d9 100644 --- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c +++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c @@ -399,6 +399,51 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) return 0; } +static int +scheduler_option_set(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + uint32_t threshold; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold = ((struct rte_cryptodev_scheduler_threshold_option *) + option)->threshold; + if (!rte_is_power_of_2(threshold)) { + CS_LOG_ERR("Threshold is not power of 2"); + return -EINVAL; + } + + psd_ctx->threshold = ~(threshold - 1); + + return 0; +} + +static int +scheduler_option_get(struct rte_cryptodev *dev, uint32_t option_type, + void *option) +{ + struct psd_scheduler_ctx *psd_ctx = ((struct scheduler_ctx *) + dev->data->dev_private)->private_ctx; + struct rte_cryptodev_scheduler_threshold_option *threshold_option; + + if ((enum rte_cryptodev_schedule_option_type)option_type != + CDEV_SCHED_OPTION_THRESHOLD) { + CS_LOG_ERR("Option not supported"); + return -EINVAL; + } + + threshold_option = option; + threshold_option->threshold = (~psd_ctx->threshold) + 1; + + return 0; +} struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { slave_attach, @@ -407,6 +452,8 @@ struct rte_cryptodev_scheduler_ops scheduler_ps_ops = { scheduler_stop, scheduler_config_qp, scheduler_create_private_ctx, + scheduler_option_set, + scheduler_option_get }; struct rte_cryptodev_scheduler psd_scheduler = { diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c index 1fb6ce7..f618d6c 100644 --- a/drivers/crypto/scheduler/scheduler_roundrobin.c +++ b/drivers/crypto/scheduler/scheduler_roundrobin.c @@ -265,7 +265,9 @@ struct rte_cryptodev_scheduler_ops scheduler_rr_ops = { scheduler_start, scheduler_stop, scheduler_config_qp, - scheduler_create_private_ctx + scheduler_create_private_ctx, + NULL, /* option_set */ + NULL /*option_get */ }; struct rte_cryptodev_scheduler scheduler = { -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v5] crypto/scheduler: add mode specific option support 2017-04-05 16:07 ` [dpdk-dev] [PATCH v5] " Fan Zhang @ 2017-04-17 19:46 ` De Lara Guarch, Pablo 0 siblings, 0 replies; 10+ messages in thread From: De Lara Guarch, Pablo @ 2017-04-17 19:46 UTC (permalink / raw) To: Zhang, Roy Fan, dev; +Cc: Doherty, Declan > -----Original Message----- > From: Zhang, Roy Fan > Sent: Wednesday, April 05, 2017 5:07 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo; Doherty, Declan > Subject: [PATCH v5] crypto/scheduler: add mode specific option support > > Some scheduling modes may need extra options to be configured, > this patch adds the function prototype for setting/getting > options. > > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> > Acked-by: Declan Doherty <declan.doherty@intel.com> Applied to dpdk-next-crypto. Thanks, Pablo ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-04-17 19:47 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-21 14:29 [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option support Fan Zhang 2017-03-21 14:34 ` De Lara Guarch, Pablo 2017-03-31 15:30 ` [dpdk-dev] [PATCH v2] " Fan Zhang 2017-04-05 8:46 ` De Lara Guarch, Pablo 2017-04-05 9:02 ` [dpdk-dev] [PATCH v3] " Fan Zhang 2017-04-05 10:02 ` Declan Doherty 2017-04-05 11:43 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon 2017-04-05 15:54 ` [dpdk-dev] [PATCH v4] " Fan Zhang 2017-04-05 16:07 ` [dpdk-dev] [PATCH v5] " Fan Zhang 2017-04-17 19:46 ` De Lara Guarch, Pablo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).