sched: update subport rate dynamically
[dpdk.git] / lib / librte_sched / rte_sched.h
index 40f02f1..1506c64 100644 (file)
@@ -121,16 +121,16 @@ extern "C" {
  */
 struct rte_sched_pipe_params {
        /** Token bucket rate (measured in bytes per second) */
-       uint32_t tb_rate;
+       uint64_t tb_rate;
 
        /** Token bucket size (measured in credits) */
-       uint32_t tb_size;
+       uint64_t tb_size;
 
        /** Traffic class rates (measured in bytes per second) */
-       uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
        /** Enforcement period (measured in milliseconds) */
-       uint32_t tc_period;
+       uint64_t tc_period;
 
        /** Best-effort traffic class oversubscription weight */
        uint8_t tc_ov_weight;
@@ -150,16 +150,16 @@ struct rte_sched_pipe_params {
  */
 struct rte_sched_subport_params {
        /** Token bucket rate (measured in bytes per second) */
-       uint32_t tb_rate;
+       uint64_t tb_rate;
 
        /** Token bucket size (measured in credits) */
-       uint32_t tb_size;
+       uint64_t tb_size;
 
        /** Traffic class rates (measured in bytes per second) */
-       uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
        /** Enforcement period for rates (measured in milliseconds) */
-       uint32_t tc_period;
+       uint64_t tc_period;
 
        /** Number of subport pipes.
         * The subport can enable/allocate fewer pipes than the maximum
@@ -192,44 +192,58 @@ struct rte_sched_subport_params {
 #endif
 };
 
+struct rte_sched_subport_profile_params {
+       /** Token bucket rate (measured in bytes per second) */
+       uint64_t tb_rate;
+
+       /** Token bucket size (measured in credits) */
+       uint64_t tb_size;
+
+       /** Traffic class rates (measured in bytes per second) */
+       uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+
+       /** Enforcement period for rates (measured in milliseconds) */
+       uint64_t tc_period;
+};
+
 /** Subport statistics */
 struct rte_sched_subport_stats {
        /** Number of packets successfully written */
-       uint32_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
        /** Number of packets dropped */
-       uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
        /** Number of bytes successfully written for each traffic class */
-       uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
        /** Number of bytes dropped for each traffic class */
-       uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 #ifdef RTE_SCHED_RED
        /** Number of packets dropped by red */
-       uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 #endif
 };
 
 /** Queue statistics */
 struct rte_sched_queue_stats {
        /** Packets successfully written */
-       uint32_t n_pkts;
+       uint64_t n_pkts;
 
        /** Packets dropped */
-       uint32_t n_pkts_dropped;
+       uint64_t n_pkts_dropped;
 
 #ifdef RTE_SCHED_RED
        /** Packets dropped by RED */
-       uint32_t n_pkts_red_dropped;
+       uint64_t n_pkts_red_dropped;
 #endif
 
        /** Bytes successfully written */
-       uint32_t n_bytes;
+       uint64_t n_bytes;
 
        /** Bytes dropped */
-       uint32_t n_bytes_dropped;
+       uint64_t n_bytes_dropped;
 };
 
 /** Port configuration parameters. */
@@ -241,7 +255,7 @@ struct rte_sched_port_params {
        int socket;
 
        /** Output port rate (measured in bytes per second) */
-       uint32_t rate;
+       uint64_t rate;
 
        /** Maximum Ethernet frame size (measured in bytes).
         * Should not include the framing overhead.
@@ -254,34 +268,23 @@ struct rte_sched_port_params {
        /** Number of subports */
        uint32_t n_subports_per_port;
 
-       /** Maximum number of subport pipes.
-        * This parameter is used to reserve a fixed number of bits
-        * in struct rte_mbuf::sched.queue_id for the pipe_id for all
-        * the subports of the same port.
-        */
-       uint32_t n_pipes_per_subport;
-
-       /** Packet queue size for each traffic class.
-        * All the pipes within the same subport share the similar
-        * configuration for the queues.
-        */
-       uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-
-       /** Pipe profile table.
+       /** subport profile table.
         * Every pipe is configured using one of the profiles from this table.
         */
-       struct rte_sched_pipe_params *pipe_profiles;
+       struct rte_sched_subport_profile_params *subport_profiles;
 
        /** Profiles in the pipe profile table */
-       uint32_t n_pipe_profiles;
+       uint32_t n_subport_profiles;
 
-       /** Max profiles allowed in the pipe profile table */
-       uint32_t n_max_pipe_profiles;
+       /** Max allowed profiles in the pipe profile table */
+       uint32_t n_max_subport_profiles;
 
-#ifdef RTE_SCHED_RED
-       /** RED parameters */
-       struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
-#endif
+       /** Maximum number of subport pipes.
+        * This parameter is used to reserve a fixed number of bits
+        * in struct rte_mbuf::sched.queue_id for the pipe_id for all
+        * the subports of the same port.
+        */
+       uint32_t n_pipes_per_subport;
 };
 
 /*
@@ -334,21 +337,51 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
        uint32_t *pipe_profile_id);
 
 /**
- * Hierarchical scheduler subport configuration
+ * @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
+ * Note that this function is safe to use at runtime
+ * to configure subport bandwidth profile.
  * @param port
  *   Handle to port scheduler instance
  * @param subport_id
  *   Subport ID
  * @param params
- *   Subport configuration parameters
+ *   Subport configuration parameters. Must be non-NULL
+ *   for first invocation (i.e initialization) for a given
+ *   subport. Ignored (recommended value is NULL) for all
+ *   subsequent invocation on the same subport.
+ * @param subport_profile_id
+ *   ID of subport bandwidth profile
  * @return
  *   0 upon success, error code otherwise
  */
 int
 rte_sched_subport_config(struct rte_sched_port *port,
        uint32_t subport_id,
-       struct rte_sched_subport_params *params);
+       struct rte_sched_subport_params *params,
+       uint32_t subport_profile_id);
 
 /**
  * Hierarchical scheduler pipe configuration