From: Simon Kagstrom Date: Tue, 17 Nov 2015 08:14:48 +0000 (+0100) Subject: sched: release enqueued mbufs when freeing port X-Git-Tag: spdx-start~7963 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=61383240;p=dpdk.git sched: release enqueued mbufs when freeing port Otherwise mbufs will leak when the port is destroyed. The rte_sched_port_qbase() and rte_sched_port_qsize() functions are used in free now, so move them up. Signed-off-by: Simon Kagstrom --- diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 15cd297bbd..9f0b4589fc 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -273,6 +273,24 @@ rte_sched_port_queues_per_port(struct rte_sched_port *port) return RTE_SCHED_QUEUES_PER_PIPE * port->n_pipes_per_subport * port->n_subports_per_port; } +static inline struct rte_mbuf ** +rte_sched_port_qbase(struct rte_sched_port *port, uint32_t qindex) +{ + uint32_t pindex = qindex >> 4; + uint32_t qpos = qindex & 0xF; + + return (port->queue_array + pindex * + port->qsize_sum + port->qsize_add[qpos]); +} + +static inline uint16_t +rte_sched_port_qsize(struct rte_sched_port *port, uint32_t qindex) +{ + uint32_t tc = (qindex >> 2) & 0x3; + + return port->qsize[tc]; +} + static int rte_sched_port_check_params(struct rte_sched_port_params *params) { @@ -702,10 +720,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) void rte_sched_port_free(struct rte_sched_port *port) { + unsigned int queue; + /* 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]); + } + rte_bitmap_free(port->bmp); rte_free(port); } @@ -1016,23 +1045,6 @@ rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport, uint32_t pi return result; } -static inline struct rte_mbuf ** -rte_sched_port_qbase(struct rte_sched_port *port, uint32_t qindex) -{ - uint32_t pindex = qindex >> 4; - uint32_t qpos = qindex & 0xF; - - return (port->queue_array + pindex * port->qsize_sum + port->qsize_add[qpos]); -} - -static inline uint16_t -rte_sched_port_qsize(struct rte_sched_port *port, uint32_t qindex) -{ - uint32_t tc = (qindex >> 2) & 0x3; - - return port->qsize[tc]; -} - #ifdef RTE_SCHED_DEBUG static inline int