test mbuf attach
[dpdk.git] / lib / librte_sched / rte_sched.h
index eac6db2..8a5a93c 100644 (file)
@@ -111,7 +111,7 @@ extern "C" {
 #endif
 
 /*
- * Subport configuration parameters. The period and credits_per_period
+ * Pipe configuration parameters. The period and credits_per_period
  * parameters are measured in bytes, with one byte meaning the time
  * duration associated with the transmission of one byte on the
  * physical medium of the output port, with pipe or pipe traffic class
@@ -119,42 +119,28 @@ extern "C" {
  * credits_per_period divided by period. One credit represents one
  * byte.
  */
-struct rte_sched_subport_params {
+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];
-
-       /** Enforcement period for rates (measured in milliseconds) */
-       uint32_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];
-
-       /** Number of packets dropped */
-       uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       uint64_t tc_rate[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];
+       /** Enforcement period (measured in milliseconds) */
+       uint64_t tc_period;
 
-       /** Number of bytes dropped for each traffic class */
-       uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+       /** Best-effort traffic class oversubscription weight */
+       uint8_t tc_ov_weight;
 
-#ifdef RTE_SCHED_RED
-       /** Number of packets dropped by red */
-       uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-#endif
+       /** WRR weights of best-effort traffic class queues */
+       uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
 };
 
 /*
- * Pipe configuration parameters. The period and credits_per_period
+ * Subport configuration parameters. The period and credits_per_period
  * parameters are measured in bytes, with one byte meaning the time
  * duration associated with the transmission of one byte on the
  * physical medium of the output port, with pipe or pipe traffic class
@@ -162,44 +148,88 @@ struct rte_sched_subport_stats {
  * credits_per_period divided by period. One credit represents one
  * byte.
  */
-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 (measured in milliseconds) */
-       uint32_t tc_period;
+       /** Enforcement period for rates (measured in milliseconds) */
+       uint64_t tc_period;
 
-       /** Best-effort traffic class oversubscription weight */
-       uint8_t tc_ov_weight;
+       /** Number of subport pipes.
+        * The subport can enable/allocate fewer pipes than the maximum
+        * number set through struct port_params::n_max_pipes_per_subport,
+        * as needed, to avoid memory allocation for the queues of the
+        * pipes that are not really needed.
+        */
+       uint32_t n_pipes_per_subport_enabled;
 
-       /** WRR weights of best-effort traffic class queues */
-       uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
+       /** 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.
+        * Every pipe is configured using one of the profiles from this table.
+        */
+       struct rte_sched_pipe_params *pipe_profiles;
+
+       /** Profiles in the pipe profile table */
+       uint32_t n_pipe_profiles;
+
+       /** Max allowed profiles in the pipe profile table */
+       uint32_t n_max_pipe_profiles;
+
+#ifdef RTE_SCHED_RED
+       /** RED parameters */
+       struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
+#endif
+};
+
+/** Subport statistics */
+struct rte_sched_subport_stats {
+       /** Number of packets successfully written */
+       uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+
+       /** Number of packets dropped */
+       uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+
+       /** Number of bytes successfully written for each traffic class */
+       uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+
+       /** Number of bytes dropped for each traffic class */
+       uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+
+#ifdef RTE_SCHED_RED
+       /** Number of packets dropped by red */
+       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. */
@@ -211,7 +241,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.
@@ -224,30 +254,12 @@ struct rte_sched_port_params {
        /** Number of subports */
        uint32_t n_subports_per_port;
 
-       /** Number of subport_pipes */
-       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.
-        * Every pipe is configured using one of the profiles from this table.
+       /** 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.
         */
-       struct rte_sched_pipe_params *pipe_profiles;
-
-       /** Profiles in the pipe profile table */
-       uint32_t n_pipe_profiles;
-
-       /** Max profiles allowed in the pipe profile table */
-       uint32_t n_max_pipe_profiles;
-
-#ifdef RTE_SCHED_RED
-       /** RED parameters */
-       struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
-#endif
+       uint32_t n_pipes_per_subport;
 };
 
 /*
@@ -283,6 +295,8 @@ rte_sched_port_free(struct rte_sched_port *port);
  *
  * @param port
  *   Handle to port scheduler instance
+ * @param subport_id
+ *   Subport ID
  * @param params
  *   Pipe profile parameters
  * @param pipe_profile_id
@@ -292,7 +306,8 @@ rte_sched_port_free(struct rte_sched_port *port);
  */
 __rte_experimental
 int
-rte_sched_port_pipe_profile_add(struct rte_sched_port *port,
+rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
+       uint32_t subport_id,
        struct rte_sched_pipe_params *params,
        uint32_t *pipe_profile_id);
 
@@ -323,7 +338,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
  * @param pipe_id
  *   Pipe ID within subport
  * @param pipe_profile
- *   ID of port-level pre-configured pipe profile
+ *   ID of subport-level pre-configured pipe profile
  * @return
  *   0 upon success, error code otherwise
  */
@@ -336,14 +351,16 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 /**
  * Hierarchical scheduler memory footprint size per port
  *
- * @param params
+ * @param port_params
  *   Port scheduler configuration parameter structure
+ * @param subport_params
+ *   Array of subport parameter structures
  * @return
  *   Memory footprint size in bytes upon success, 0 otherwise
  */
 uint32_t
-rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params);
-
+rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
+       struct rte_sched_subport_params **subport_params);
 /*
  * Statistics
  *