Skip to content

Commit

Permalink
use dpdk graph framework
Browse files Browse the repository at this point in the history
use dpdk graph framework and add some basic nodes.

Signed-off-by: Guvenc Gulce <[email protected]>
  • Loading branch information
guvenc committed Nov 1, 2021
1 parent c6150f9 commit 04b90d1
Show file tree
Hide file tree
Showing 25 changed files with 1,107 additions and 324 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[*.{build,h,c}]

charset = utf-8
indent_style = tab
indent_size = 4
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Dataplane Service
=================
This is an early protoype version without proper error
and memory handling.
- Uses [DPDK Graph Framework](https://doc.dpdk.org/guides/prog_guide/graph_lib.html) for the data plane.
- Uses a private pointer in [mbuf](https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html#dynamic-fields-and-flags) structure to carry offloading rte_flow
data around.
- Basic hardcoded [rte_flow](https://doc.dpdk.org/guides/prog_guide/rte_flow.html).
- Settings are still hard-coded.

Prerequisites
-------------
Expand Down
16 changes: 16 additions & 0 deletions include/dp_mbuf_dyn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __INCLUDE_DP_MBUF_DYN_PRIV_H__
#define __INCLUDE_DP_MBUF_DYN_PRIV_H__

#include "node_api.h"

#ifdef __cplusplus
extern "C" {
#endif

int rte_mbuf_dyn_flow_register();
struct dp_mbuf_priv1 *get_dp_mbuf_priv1(struct rte_mbuf *m);
void init_dp_mbuf_priv1(struct rte_mbuf *m);
#ifdef __cplusplus
}
#endif
#endif
6 changes: 1 addition & 5 deletions include/dp_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <rte_ethdev.h>

#include "dpdk_layer.h"
#include "handler.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -34,14 +33,11 @@ struct dp_port {
int dp_allocated;
uint8_t vf_name[IFNAMSIZ];
struct dp_port_ext dp_port_ext;
struct port_handler *handlers[DP_MAX_HANDLER];
int dp_handler_cnt;
char node_name[RTE_NODE_NAMESIZE];
};

struct dp_port* get_dp_vf_port_with_id(int port_id,
struct dp_dpdk_layer *dp_layer);
void dp_port_add_handler(struct port_handler* h, int port_id,
struct dp_dpdk_layer *dp_layer);
struct dp_port* dp_port_create(struct dp_dpdk_layer *dp_layer,
dp_port_type type);
int dp_port_init(struct dp_port* port, int p_port_id, int port_id,
Expand Down
31 changes: 23 additions & 8 deletions include/dpdk_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,40 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_net.h>
#include <rte_graph.h>
#include <rte_node_eth_api.h>
#include <rte_graph_worker.h>

#include <signal.h>

#include "dp_port.h"
#include "handler.h"

#ifdef __cplusplus
extern "C" {
#endif
#define DP_MAX_PF_PORT 2
#define DP_MAX_VF_PRO_PORT 4
#define DP_MAX_PORTS DP_MAX_PF_PORT * DP_MAX_VF_PRO_PORT
#define DP_NR_RX_QUEUES 16
#define DP_NR_TX_QUEUES 5
#define DP_NR_RX_QUEUES 1
#define DP_NR_TX_QUEUES 2
#define MEMPOOL_CACHE_SIZE 256

#define NB_MBUF(nports) \
RTE_MAX((2 * 1 * 1024 + \
2 * 1 * RTE_GRAPH_BURST_SIZE + \
2 * 1 * 1024 + \
1 * MEMPOOL_CACHE_SIZE), 29184u)

struct dp_dpdk_layer {
struct rte_mempool *rte_mempool;
struct dp_port *ports[DP_MAX_PORTS];
int dp_port_cnt;
uint16_t nr_rx_queues;
uint16_t nr_tx_queues;
struct rte_mempool *rte_mempool;
struct dp_port *ports[DP_MAX_PORTS];
struct rte_node_ethdev_config ethdev_conf[DP_MAX_PORTS];
int dp_port_cnt;
uint16_t nr_rx_queues;
uint16_t nr_tx_queues;
char graph_name[RTE_GRAPH_NAMESIZE];
struct rte_graph *graph;
rte_graph_t graph_id;
};

struct dp_port_ext;
Expand Down
66 changes: 0 additions & 66 deletions include/handler.h

This file was deleted.

14 changes: 0 additions & 14 deletions include/handlers/arp_handler.h

This file was deleted.

4 changes: 3 additions & 1 deletion include/meson.build
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
install_headers('dp_service.h', 'dp_port.h', 'dpdk_layer.h', 'handlers/arp_handler.h', 'handler.h')
install_headers('dp_service.h', 'node_api.h', 'dp_port.h', 'dpdk_layer.h',
'nodes/arp_node_priv.h', 'nodes/ipv4_lookup_priv.h',
'nodes/tx_node_priv.h', 'dp_mbuf_dyn.h')
36 changes: 36 additions & 0 deletions include/node_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef __PUBLIC_API_H__
#define __PUBLIC_API_H__

#include <rte_common.h>
#include <rte_flow.h>

#ifdef __cplusplus
extern "C" {
#endif

struct dp_flow {
struct rte_flow_attr attr;
struct rte_flow_item pattern[5];
struct rte_flow_action action[5];
int pattern_cnt;
int action_cnt;
int valid;
};

struct dp_mbuf_priv1 {
struct dp_flow *flow_ptr;
};

struct rx_node_config
{
uint16_t port_id;
uint16_t queue_id;
};

int config_rx_node(struct rx_node_config* cfg);

#ifdef __cplusplus
}
#endif

#endif
30 changes: 30 additions & 0 deletions include/nodes/arp_node_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef __INCLUDE_ARP_NODE_PRIV_H__
#define __INCLUDE_ARP_NODE_PRIV_H__

#include "dpdk_layer.h"

#ifdef __cplusplus
extern "C" {
#endif

enum
{
ARP_NEXT_DROP,
ARP_NEXT_MAX
};

struct arp_node_ctx
{
uint16_t next;
};

struct arp_node_main {
uint16_t next_index[DP_MAX_PORTS];
};

struct rte_node_register *arp_node_get(void);
int arp_set_next(uint16_t port_id, uint16_t next_index);
#ifdef __cplusplus
}
#endif
#endif
30 changes: 30 additions & 0 deletions include/nodes/ipv4_lookup_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef __INCLUDE_IPV4_LOOKUP_NODE_PRIV_H__
#define __INCLUDE_IPV4_LOOKUP_NODE_PRIV_H__

#include "dpdk_layer.h"

#ifdef __cplusplus
extern "C" {
#endif

enum
{
IPV4_LOOKUP_NEXT_DROP,
IPV4_LOOKUP_NEXT_MAX
};

struct ipv4_lookup_node_ctx
{
uint16_t next;
};

struct ipv4_lookup_node_main {
uint16_t next_index[DP_MAX_PORTS];
};

struct rte_node_register *ipv4_lookup_node_get(void);
int ipv4_lookup_set_next(uint16_t port_id, uint16_t next_index);
#ifdef __cplusplus
}
#endif
#endif
32 changes: 32 additions & 0 deletions include/nodes/tx_node_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef __INCLUDE_TX_NODE_PRIV_H__
#define __INCLUDE_TX_NODE_PRIV_H__

#include "dpdk_layer.h"

#ifdef __cplusplus
extern "C" {
#endif

enum
{
TX_NEXT_DROP,
TX_NEXT_MAX
};

struct tx_node_ctx
{
uint16_t port_id;
uint16_t queue_id;
uint16_t next;
};

struct ethdev_tx_node_main {
uint32_t nodes[DP_MAX_PORTS];
};

struct ethdev_tx_node_main *tx_node_data_get(void);
struct rte_node_register *tx_node_get(void);
#ifdef __cplusplus
}
#endif
#endif
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
project('dp_service', 'c',
default_options : ['c_args=-Wno-deprecated-declarations'],
version : '0.0.1',
license : 'MIT')
add_global_arguments('-DDEBUG=true', language : 'c')
Expand Down
37 changes: 37 additions & 0 deletions src/dp_mbuf_dyn.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "rte_mbuf_dyn.h"
#include "dp_mbuf_dyn.h"

static const struct rte_mbuf_dynfield dp_mbuf_dynfield_desc = {
.name = "dp_node_dynfield_flow_ptr",
.size = sizeof(struct dp_mbuf_priv1),
.align = __alignof__(struct dp_mbuf_priv1),
};

static int priv1_offset = -1;

struct dp_mbuf_priv1* get_dp_mbuf_priv1(struct rte_mbuf *m)
{
if (priv1_offset >= 0)
return RTE_MBUF_DYNFIELD(m, priv1_offset, struct dp_mbuf_priv1 *);
else
return NULL;
}

void init_dp_mbuf_priv1(struct rte_mbuf *m)
{
if (priv1_offset >= 0) {
struct dp_mbuf_priv1 *temp;
temp = RTE_MBUF_DYNFIELD(m, priv1_offset, struct dp_mbuf_priv1 *);
temp->flow_ptr = NULL;
}
}

int rte_mbuf_dyn_flow_register(int *field_offset)
{
priv1_offset = rte_mbuf_dynfield_register(&dp_mbuf_dynfield_desc);
if (priv1_offset < 0)
return -1;

return 0;
}

Loading

0 comments on commit 04b90d1

Please sign in to comment.