summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/handle_pf_acl.c
blob: 16ac03300c7a43a9212b79b042c4e0258ee2b7f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
// Copyright (c) 2010-2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

#include <rte_table_stub.h>	//FIXME: ACL

#include "log.h"
#include "quit.h"
#include "thread_pipeline.h"

struct task_pf_acl {
	struct task_pipe pipe;
	//TODO
};

static void init_task_pf_acl(struct task_base *tbase, struct task_args *targ)
{
	struct task_pipe *tpipe = (struct task_pipe *)tbase;
//	struct task_pf_acl *task = (struct task_pf_acl *)tpipe;
	int err;

	/* create pipeline, input ports and output ports */
	init_pipe_create_in_out(tpipe, targ);

	/* create ACL pipeline table */
	//TODO

//FIXME: this is not ACL (
	/* create pipeline tables */
	for (uint8_t i = 0; i < tpipe->n_ports_in; ++i) {
		struct rte_pipeline_table_params table_params = {
			.ops = &rte_table_stub_ops,
			.arg_create = NULL,
			.f_action_hit = NULL,
			.f_action_miss = NULL,
			.arg_ah = NULL,
			.action_data_size = 0,
		};
		err = rte_pipeline_table_create(tpipe->p, &table_params,
				&tpipe->table_id[i]);
		PROX_PANIC(err != 0, "Failed to create table %u "
				"for %s pipeline on core %u task %u: "
				"err = %d\n",
				i, targ->task_init->mode_str,
				targ->lconf->id, targ->task,
				err);
	}
	tpipe->n_tables = tpipe->n_ports_in;
	PROX_PANIC(tpipe->n_tables < 1, "No table created "
			"for %s pipeline on core %u task %u\n",
			targ->task_init->mode_str, targ->lconf->id, targ->task);

	/* add default entry to tables */
	for (uint8_t i = 0; i < tpipe->n_tables; ++i) {
		struct rte_pipeline_table_entry default_entry = {
			.action = RTE_PIPELINE_ACTION_PORT,
			{.port_id = tpipe->port_out_id[i % tpipe->n_ports_out]},
		};
		struct rte_pipeline_table_entry *default_entry_ptr;
		err = rte_pipeline_table_default_entry_add(tpipe->p, tpipe->table_id[i],
				&default_entry, &default_entry_ptr);
		PROX_PANIC(err != 0, "Failed to add default entry to table %u "
				"for %s pipeline on core %u task %u: "
				"err = %d\n",
				i, targ->task_init->mode_str,
				targ->lconf->id, targ->task,
				err);
	}
//FIXME: this is not ACL )

	/* connect pipeline input ports to ACL pipeline table */
	init_pipe_connect_one(tpipe, targ, tpipe->table_id[0]);

	/* enable pipeline input ports */
	init_pipe_enable(tpipe, targ);

	/* check pipeline consistency */
	init_pipe_check(tpipe, targ);
}

static struct task_init task_init_pf_acl = {
	.mode_str = "pf_acl",
	.init = init_task_pf_acl,
	.handle = handle_pipe,
	.thread_x = thread_pipeline,
	.size = sizeof(struct task_pf_acl),
};

__attribute__((constructor)) static void reg_task_pf_acl(void)
{
	reg_task(&task_init_pf_acl);
}