sched: introduce subport profile add function
authorSavinay Dharmappa <savinay.dharmappa@intel.com>
Fri, 9 Oct 2020 12:39:13 +0000 (13:39 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 15 Oct 2020 00:11:55 +0000 (02:11 +0200)
API to add new subport bandwidth profile.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
lib/librte_sched/rte_sched.c
lib/librte_sched/rte_sched.h
lib/librte_sched/rte_sched_version.map

index a44638f..895b40d 100644 (file)
@@ -1528,6 +1528,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
        return 0;
 }
 
+int
+rte_sched_port_subport_profile_add(struct rte_sched_port *port,
+       struct rte_sched_subport_profile_params *params,
+       uint32_t *subport_profile_id)
+{
+       int status;
+       uint32_t i;
+       struct rte_sched_subport_profile *dst;
+
+       /* Port */
+       if (port == NULL) {
+               RTE_LOG(ERR, SCHED, "%s: "
+               "Incorrect value for parameter port\n", __func__);
+               return -EINVAL;
+       }
+
+       if (params == NULL) {
+               RTE_LOG(ERR, SCHED, "%s: "
+               "Incorrect value for parameter profile\n", __func__);
+               return -EINVAL;
+       }
+
+       if (subport_profile_id == NULL) {
+               RTE_LOG(ERR, SCHED, "%s: "
+               "Incorrect value for parameter subport_profile_id\n",
+               __func__);
+               return -EINVAL;
+       }
+
+       dst = port->subport_profiles + port->n_subport_profiles;
+
+       /* Subport profiles exceeds the max limit */
+       if (port->n_subport_profiles >= port->n_max_subport_profiles) {
+               RTE_LOG(ERR, SCHED, "%s: "
+               "Number of subport profiles exceeds the max limit\n",
+                __func__);
+               return -EINVAL;
+       }
+
+       status = subport_profile_check(params, port->rate);
+       if (status != 0) {
+               RTE_LOG(ERR, SCHED,
+               "%s: subport profile check failed(%d)\n", __func__, status);
+               return -EINVAL;
+       }
+
+       rte_sched_subport_profile_convert(params, dst, port->rate);
+
+       /* Subport profile should not exists */
+       for (i = 0; i < port->n_subport_profiles; i++)
+               if (memcmp(port->subport_profiles + i,
+                   dst, sizeof(*dst)) == 0) {
+                       RTE_LOG(ERR, SCHED,
+                       "%s: subport profile exists\n", __func__);
+                       return -EINVAL;
+               }
+
+       /* Subport profile commit */
+       *subport_profile_id = port->n_subport_profiles;
+       port->n_subport_profiles++;
+
+       rte_sched_port_log_subport_profile(port, *subport_profile_id);
+
+       return 0;
+}
+
 static inline uint32_t
 rte_sched_port_qindex(struct rte_sched_port *port,
        uint32_t subport,
index 39339b7..aede2e9 100644 (file)
@@ -336,6 +336,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
        struct rte_sched_pipe_params *params,
        uint32_t *pipe_profile_id);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Hierarchical scheduler subport bandwidth profile add
+ * Note that this function is safe to use in runtime for adding new
+ * subport bandwidth profile as it doesn't have any impact on hiearchical
+ * structure of the scheduler.
+ * @param port
+ *   Handle to port scheduler instance
+ * @param profile
+ *   Subport bandwidth profile
+ * @param subport_profile_id
+ *   Subport profile id
+ * @return
+ *   0 upon success, error code otherwise
+ */
+__rte_experimental
+int
+rte_sched_port_subport_profile_add(struct rte_sched_port *port,
+       struct rte_sched_subport_profile_params *profile,
+       uint32_t *subport_profile_id);
+
 /**
  * Hierarchical scheduler subport configuration
  *
index 3faef6f..ace284b 100644 (file)
@@ -28,4 +28,6 @@ EXPERIMENTAL {
        global:
 
        rte_sched_subport_pipe_profile_add;
+       # added in 20.11
+       rte_sched_port_subport_profile_add;
 };