#include <rte_mbuf.h>
#include <rte_ethdev.h>
#include <rte_swx_port_ethdev.h>
+#include <rte_swx_port_ring.h>
#include <rte_swx_port_source_sink.h>
#include <rte_swx_table_em.h>
#include <rte_swx_pipeline.h>
*/
TAILQ_HEAD(link_list, link);
+/*
+ * ring
+ */
+TAILQ_HEAD(ring_list, ring);
+
/*
* pipeline
*/
struct obj {
struct mempool_list mempool_list;
struct link_list link_list;
+ struct ring_list ring_list;
struct pipeline_list pipeline_list;
};
TAILQ_FIRST(&obj->link_list) : TAILQ_NEXT(link, node);
}
+/*
+ * ring
+ */
+struct ring *
+ring_create(struct obj *obj, const char *name, struct ring_params *params)
+{
+ struct ring *ring;
+ struct rte_ring *r;
+ unsigned int flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
+
+ /* Check input params */
+ if (!name || ring_find(obj, name) || !params || !params->size)
+ return NULL;
+
+ /**
+ * Resource create
+ */
+ r = rte_ring_create(
+ name,
+ params->size,
+ params->numa_node,
+ flags);
+ if (!r)
+ return NULL;
+
+ /* Node allocation */
+ ring = calloc(1, sizeof(struct ring));
+ if (!ring) {
+ rte_ring_free(r);
+ return NULL;
+ }
+
+ /* Node fill in */
+ strlcpy(ring->name, name, sizeof(ring->name));
+
+ /* Node add to list */
+ TAILQ_INSERT_TAIL(&obj->ring_list, ring, node);
+
+ return ring;
+}
+
+struct ring *
+ring_find(struct obj *obj, const char *name)
+{
+ struct ring *ring;
+
+ if (!obj || !name)
+ return NULL;
+
+ TAILQ_FOREACH(ring, &obj->ring_list, node)
+ if (strcmp(ring->name, name) == 0)
+ return ring;
+
+ return NULL;
+}
+
/*
* pipeline
*/
if (status)
goto error;
+ status = rte_swx_pipeline_port_in_type_register(p,
+ "ring",
+ &rte_swx_port_ring_reader_ops);
+ if (status)
+ goto error;
+
+ status = rte_swx_pipeline_port_out_type_register(p,
+ "ring",
+ &rte_swx_port_ring_writer_ops);
+ if (status)
+ goto error;
+
#ifdef RTE_PORT_PCAP
status = rte_swx_pipeline_port_in_type_register(p,
"source",
TAILQ_INIT(&obj->mempool_list);
TAILQ_INIT(&obj->link_list);
+ TAILQ_INIT(&obj->ring_list);
TAILQ_INIT(&obj->pipeline_list);
return obj;