summaryrefslogtreecommitdiff
path: root/lib/librte_sched
diff options
context:
space:
mode:
authorHiroyuki Mikita <h.mikita89@gmail.com>2016-09-06 00:15:14 +0900
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-09-23 21:14:54 +0200
commit7b3c4f351708a4bf5d311266d9f8c32e5704701f (patch)
tree6802b3e855815f645bfe2ec202a6896bea02ba38 /lib/librte_sched
parentaf2c6fffe6bdea4dd55c5faf731fbaec27275d0b (diff)
downloaddpdk-7b3c4f351708a4bf5d311266d9f8c32e5704701f.zip
dpdk-7b3c4f351708a4bf5d311266d9f8c32e5704701f.tar.gz
dpdk-7b3c4f351708a4bf5d311266d9f8c32e5704701f.tar.xz
sched: fix releasing enqueued packets
rte_sched_port_free should release only enqueued packets of all queues. Previous behavior is that enqueued and already dequeued packets of only first 4 queues are released. Fixes: 61383240 ("sched: release enqueued mbufs when freeing port") Signed-off-by: Hiroyuki Mikita <h.mikita89@gmail.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Diffstat (limited to 'lib/librte_sched')
-rw-r--r--lib/librte_sched/rte_sched.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 8696423..e6dace2 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -734,19 +734,23 @@ rte_sched_port_config(struct rte_sched_port_params *params)
void
rte_sched_port_free(struct rte_sched_port *port)
{
- unsigned int queue;
+ uint32_t qindex;
+ uint32_t n_queues_per_port = rte_sched_port_queues_per_port(port);
/* Check user parameters */
if (port == NULL)
return;
/* Free enqueued mbufs */
- for (queue = 0; queue < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; queue++) {
- struct rte_mbuf **mbufs = rte_sched_port_qbase(port, queue);
- unsigned int i;
-
- for (i = 0; i < rte_sched_port_qsize(port, queue); i++)
- rte_pktmbuf_free(mbufs[i]);
+ for (qindex = 0; qindex < n_queues_per_port; qindex++) {
+ struct rte_mbuf **mbufs = rte_sched_port_qbase(port, qindex);
+ uint16_t qsize = rte_sched_port_qsize(port, qindex);
+ struct rte_sched_queue *queue = port->queue + qindex;
+ uint16_t qr = queue->qr & (qsize - 1);
+ uint16_t qw = queue->qw & (qsize - 1);
+
+ for (; qr != qw; qr = (qr + 1) & (qsize - 1))
+ rte_pktmbuf_free(mbufs[qr]);
}
rte_bitmap_free(port->bmp);