[dpdk-dev] [PATCH v2 05/28] sched: update port free API
Jasvinder Singh
jasvinder.singh at intel.com
Tue Jun 25 17:31:54 CEST 2019
Update port free api implementation to allow configuration
flexiblity for pipe traffic classes and queues, and subport level
configuration of the pipe parameters.
Signed-off-by: Jasvinder Singh <jasvinder.singh at intel.com>
Signed-off-by: Abraham Tovar <abrahamx.tovar at intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak at intel.com>
---
lib/librte_sched/rte_sched.c | 71 ++++++++++++++++++++++++++++--------
1 file changed, 55 insertions(+), 16 deletions(-)
diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index aea938899..22db212ed 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -294,6 +294,29 @@ rte_sched_port_queues_per_subport(struct rte_sched_port *port)
#endif
+static inline uint32_t
+rte_sched_subport_queues(struct rte_sched_subport *subport)
+{
+ return RTE_SCHED_QUEUES_PER_PIPE * subport->n_subport_pipes;
+}
+
+static inline struct rte_mbuf **
+rte_sched_subport_qbase(struct rte_sched_subport *subport, uint32_t qindex)
+{
+ uint32_t pindex = qindex >> 4;
+ uint32_t qpos = qindex & 0xF;
+
+ return (subport->queue_array + pindex *
+ subport->qsize_sum + subport->qsize_add[qpos]);
+}
+
+static inline uint16_t
+rte_sched_subport_qsize(struct rte_sched_subport *subport, uint32_t qindex)
+{
+ uint32_t qpos = qindex & 0xF;
+ return subport->qsize[qpos];
+}
+
static inline uint32_t
rte_sched_port_queues_per_port(struct rte_sched_port *port)
{
@@ -640,31 +663,47 @@ rte_sched_port_config(struct rte_sched_port_params *params)
return port;
}
-void
-rte_sched_port_free(struct rte_sched_port *port)
+static inline void
+rte_sched_subport_free(struct rte_sched_subport *subport)
{
+ uint32_t n_subport_queues;
uint32_t qindex;
- uint32_t n_queues_per_port;
- /* Check user parameters */
- if (port == NULL)
+ if (subport == NULL)
return;
- n_queues_per_port = rte_sched_port_queues_per_port(port);
+ n_subport_queues = rte_sched_subport_queues(subport);
/* Free enqueued mbufs */
- 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]);
+ for (qindex = 0; qindex < n_subport_queues; qindex++) {
+ struct rte_mbuf **mbufs =
+ rte_sched_subport_qbase(subport, qindex);
+ uint16_t qsize = rte_sched_subport_qsize(subport, qindex);
+ if (qsize != 0) {
+ struct rte_sched_queue *queue = subport->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);
+ rte_bitmap_free(subport->bmp);
+}
+
+void
+rte_sched_port_free(struct rte_sched_port *port)
+{
+ uint32_t i;
+
+ /* Check user parameters */
+ if (port == NULL)
+ return;
+
+ for (i = 0; i < port->n_subports_per_port; i++)
+ rte_sched_subport_free(port->subports[i]);
+
rte_free(port);
}
--
2.21.0
More information about the dev
mailing list