X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_sched%2Frte_sched.h;h=e6bba22eed11dfbfb2c37950f9e7aa7bd3554f24;hb=ea672a8b1655bbb44876d2550ff56f384968a43b;hp=3b25b749f404e99031f330d37956e6e33dc3f738;hpb=a91c3cadb8c33804d4b5f194a47837f699fd9af0;p=dpdk.git diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index 3b25b749f4..e6bba22eed 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -1,35 +1,34 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #ifndef __INCLUDE_RTE_SCHED_H__ @@ -48,7 +47,7 @@ extern "C" { * for the current network node. * * The scheduler supports thousands of packet queues grouped under a 5-level hierarchy: - * 1. Port: + * 1. Port: * - Typical usage: output Ethernet port; * - Multiple ports are scheduled in round robin order with equal priority; * 2. Subport: @@ -57,11 +56,11 @@ extern "C" { * - Upper limit enforced per traffic class at subport level; * - Lower priority traffic classes able to reuse subport bandwidth currently * unused by higher priority traffic classes of the same subport; - * - When any subport traffic class is oversubscribed (configuration time - * event), the usage of subport member pipes with high demand for that - * traffic class pipes is truncated to a dynamically adjusted value with no + * - When any subport traffic class is oversubscribed (configuration time + * event), the usage of subport member pipes with high demand for that + * traffic class pipes is truncated to a dynamically adjusted value with no * impact to low demand pipes; - * 3. Pipe: + * 3. Pipe: * - Typical usage: individual user/subscriber; * - Traffic shaping using the token bucket algorithm (one bucket per pipe); * 4. Traffic class: @@ -70,9 +69,9 @@ extern "C" { * - Lower priority traffic classes able to reuse pipe bandwidth currently * unused by higher priority traffic classes of the same pipe; * 5. Queue: - * - Typical usage: queue hosting packets from one or multiple connections + * - Typical usage: queue hosting packets from one or multiple connections * of same traffic class belonging to the same user; - * - Weighted Round Robin (WRR) is used to service the queues within same + * - Weighted Round Robin (WRR) is used to service the queues within same * pipe traffic class. * ***/ @@ -107,28 +106,25 @@ extern "C" { 2. Start of Frame Delimiter (SFD): 1 byte; 3. Frame Check Sequence (FCS): 4 bytes; 4. Inter Frame Gap (IFG): 12 bytes. -The FCS is considered overhead only if not included in the packet length (field pkt.pkt_len +The FCS is considered overhead only if not included in the packet length (field pkt_len of struct rte_mbuf). */ #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24 #endif /** 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 rate (measured as +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 rate (measured as percentage of output port rate) determined as credits_per_period divided by period. One credit represents one byte. */ struct rte_sched_subport_params { /* Subport token bucket */ uint32_t tb_rate; /**< Subport token bucket rate (measured in bytes per second) */ uint32_t tb_size; /**< Subport token bucket size (measured in credits) */ - + /* Subport traffic classes */ uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Subport traffic class rates (measured in bytes per second) */ uint32_t tc_period; /**< Enforcement period for traffic class rates (measured in milliseconds) */ -#ifdef RTE_SCHED_SUBPORT_TC_OV - uint32_t tc_ov_period; /**< Enforcement period for traffic class oversubscription (measured in milliseconds) */ -#endif }; /** Subport statistics */ @@ -138,32 +134,31 @@ struct rte_sched_subport_stats { subport for each traffic class */ uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of packets dropped by the current subport for each traffic class due to subport queues being full or congested*/ - + /* Bytes */ - uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of bytes successfully written to current + uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of bytes successfully written to current subport for each traffic class*/ - uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of bytes dropped by the current + uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of bytes dropped by the current subport for each traffic class due to subport queues being full or congested */ }; /** 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 rate (measured as +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 rate (measured as percentage of output port rate) determined as credits_per_period divided by period. One credit represents one byte. */ struct rte_sched_pipe_params { /* Pipe token bucket */ uint32_t tb_rate; /**< Pipe token bucket rate (measured in bytes per second) */ uint32_t tb_size; /**< Pipe token bucket size (measured in credits) */ - + /* Pipe traffic classes */ uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Pipe traffic class rates (measured in bytes per second) */ uint32_t tc_period; /**< Enforcement period for pipe traffic class rates (measured in milliseconds) */ #ifdef RTE_SCHED_SUBPORT_TC_OV - uint8_t tc_ov_weight[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Traffic class weights to be used for the - current pipe in the event of subport traffic class oversubscription */ + uint8_t tc_ov_weight; /**< Weight for the current pipe in the event of subport traffic class 3 oversubscription */ #endif - + /* Pipe queues */ uint8_t wrr_weights[RTE_SCHED_QUEUES_PER_PIPE]; /**< WRR weights for the queues of the current pipe */ }; @@ -173,10 +168,10 @@ struct rte_sched_queue_stats { /* Packets */ uint32_t n_pkts; /**< Number of packets successfully written to current queue */ uint32_t n_pkts_dropped; /**< Number of packets dropped due to current queue being full or congested */ - + /* Bytes */ uint32_t n_bytes; /**< Number of bytes successfully written to current queue */ - uint32_t n_bytes_dropped; /**< Number of bytes dropped due to current queue being full or congested */ + uint32_t n_bytes_dropped; /**< Number of bytes dropped due to current queue being full or congested */ }; /** Port configuration parameters. */ @@ -188,8 +183,8 @@ struct rte_sched_port_params { uint32_t frame_overhead; /**< Framing overhead per packet (measured in bytes) */ uint32_t n_subports_per_port; /**< Number of subports for the current port scheduler instance*/ uint32_t n_pipes_per_subport; /**< Number of pipes for each port scheduler subport */ - uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Packet queue size for each traffic class. All queues - within the same pipe traffic class have the same size. Queues from + uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Packet queue size for each traffic class. All queues + within the same pipe traffic class have the same size. Queues from different pipes serving the same traffic class have the same size. */ struct rte_sched_pipe_params *pipe_profiles; /**< Pipe profile table defined for current port scheduler instance. Every pipe of the current port scheduler is configured using one of the @@ -201,8 +196,8 @@ struct rte_sched_port_params { }; /** Path through the scheduler hierarchy used by the scheduler enqueue operation to -identify the destination queue for the current packet. Stored in the field pkt.hash.sched -of struct rte_mbuf of each packet, typically written by the classification stage and read by +identify the destination queue for the current packet. Stored in the field hash.sched +of struct rte_mbuf of each packet, typically written by the classification stage and read by scheduler enqueue.*/ struct rte_sched_port_hierarchy { uint32_t queue:2; /**< Queue ID (0 .. 3) */ @@ -225,7 +220,7 @@ struct rte_sched_port_hierarchy { * @return * Handle to port scheduler instance upon success or NULL otherwise. */ -struct rte_sched_port * +struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params); /** @@ -250,7 +245,7 @@ rte_sched_port_free(struct rte_sched_port *port); * 0 upon success, error code otherwise */ int -rte_sched_subport_config(struct rte_sched_port *port, +rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params); @@ -270,7 +265,7 @@ rte_sched_subport_config(struct rte_sched_port *port, */ int rte_sched_pipe_config(struct rte_sched_port *port, - uint32_t subport_id, + uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile); @@ -286,7 +281,7 @@ uint32_t rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params); /* - * Statistics + * Statistics * ***/ @@ -298,7 +293,7 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params); * @param subport_id * Subport ID * @param stats - * Pointer to pre-allocated subport statistics structure where the statistics + * Pointer to pre-allocated subport statistics structure where the statistics * counters should be stored * @param tc_ov * Pointer to pre-allocated 4-entry array where the oversubscription status for @@ -320,7 +315,7 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, * @param queue_id * Queue ID within port scheduler * @param stats - * Pointer to pre-allocated subport statistics structure where the statistics + * Pointer to pre-allocated subport statistics structure where the statistics * counters should be stored * @param qlen * Pointer to pre-allocated variable where the current queue length should be stored. @@ -333,15 +328,15 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, struct rte_sched_queue_stats *stats, uint16_t *qlen); -/* - * Run-time +/* + * Run-time * ***/ /** - * Scheduler hierarchy path write to packet descriptor. Typically called by the + * Scheduler hierarchy path write to packet descriptor. Typically called by the * packet classification stage. - * + * * @param pkt * Packet descriptor handle * @param subport @@ -354,11 +349,11 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, * Queue ID within pipe traffic class (0 .. 3) */ static inline void -rte_sched_port_pkt_write(struct rte_mbuf *pkt, +rte_sched_port_pkt_write(struct rte_mbuf *pkt, uint32_t subport, uint32_t pipe, uint32_t traffic_class, uint32_t queue, enum rte_meter_color color) { - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->pkt.hash.sched; - + struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; + sched->color = (uint32_t) color; sched->subport = subport; sched->pipe = pipe; @@ -368,7 +363,7 @@ rte_sched_port_pkt_write(struct rte_mbuf *pkt, /** * Scheduler hierarchy path read from packet descriptor (struct rte_mbuf). Typically - * called as part of the hierarchical scheduler enqueue operation. The subport, + * called as part of the hierarchical scheduler enqueue operation. The subport, * pipe, traffic class and queue parameters need to be pre-allocated by the caller. * * @param pkt @@ -381,13 +376,13 @@ rte_sched_port_pkt_write(struct rte_mbuf *pkt, * Traffic class ID within pipe (0 .. 3) * @param queue * Queue ID within pipe traffic class (0 .. 3) - * + * */ static inline void rte_sched_port_pkt_read_tree_path(struct rte_mbuf *pkt, uint32_t *subport, uint32_t *pipe, uint32_t *traffic_class, uint32_t *queue) { - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->pkt.hash.sched; - + struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; + *subport = sched->subport; *pipe = sched->pipe; *traffic_class = sched->traffic_class; @@ -397,17 +392,17 @@ rte_sched_port_pkt_read_tree_path(struct rte_mbuf *pkt, uint32_t *subport, uint3 static inline enum rte_meter_color rte_sched_port_pkt_read_color(struct rte_mbuf *pkt) { - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->pkt.hash.sched; + struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; return (enum rte_meter_color) sched->color; } /** - * Hierarchical scheduler port enqueue. Writes up to n_pkts to port scheduler and + * Hierarchical scheduler port enqueue. Writes up to n_pkts to port scheduler and * returns the number of packets actually written. For each packet, the port scheduler - * queue to write the packet to is identified by reading the hierarchy path from the - * packet descriptor; if the queue is full or congested and the packet is not written - * to the queue, then the packet is automatically dropped without any action required + * queue to write the packet to is identified by reading the hierarchy path from the + * packet descriptor; if the queue is full or congested and the packet is not written + * to the queue, then the packet is automatically dropped without any action required * from the caller. * * @param port @@ -423,14 +418,14 @@ int rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts); /** - * Hierarchical scheduler port dequeue. Reads up to n_pkts from the port scheduler - * and stores them in the pkts array and returns the number of packets actually read. + * Hierarchical scheduler port dequeue. Reads up to n_pkts from the port scheduler + * and stores them in the pkts array and returns the number of packets actually read. * The pkts array needs to be pre-allocated by the caller with at least n_pkts entries. * * @param port * Handle to port scheduler instance * @param pkts - * Pre-allocated packet descriptor array where the packets dequeued from the port + * Pre-allocated packet descriptor array where the packets dequeued from the port * scheduler should be stored * @param n_pkts * Number of packets to dequeue from the port scheduler