Added initial support for NDP (IPv6)
[samplevnf.git] / VNFs / DPPD-PROX / handle_pf_acl.c
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #include <rte_table_stub.h>     //FIXME: ACL
18
19 #include "log.h"
20 #include "quit.h"
21 #include "thread_pipeline.h"
22
23 struct task_pf_acl {
24         struct task_pipe pipe;
25         //TODO
26 };
27
28 static void init_task_pf_acl(struct task_base *tbase, struct task_args *targ)
29 {
30         struct task_pipe *tpipe = (struct task_pipe *)tbase;
31 //      struct task_pf_acl *task = (struct task_pf_acl *)tpipe;
32         int err;
33
34         /* create pipeline, input ports and output ports */
35         init_pipe_create_in_out(tpipe, targ);
36
37         /* create ACL pipeline table */
38         //TODO
39
40 //FIXME: this is not ACL (
41         /* create pipeline tables */
42         for (uint8_t i = 0; i < tpipe->n_ports_in; ++i) {
43                 struct rte_pipeline_table_params table_params = {
44                         .ops = &rte_table_stub_ops,
45                         .arg_create = NULL,
46                         .f_action_hit = NULL,
47                         .f_action_miss = NULL,
48                         .arg_ah = NULL,
49                         .action_data_size = 0,
50                 };
51                 err = rte_pipeline_table_create(tpipe->p, &table_params,
52                                 &tpipe->table_id[i]);
53                 PROX_PANIC(err != 0, "Failed to create table %u "
54                                 "for %s pipeline on core %u task %u: "
55                                 "err = %d\n",
56                                 i, targ->task_init->mode_str,
57                                 targ->lconf->id, targ->task,
58                                 err);
59         }
60         tpipe->n_tables = tpipe->n_ports_in;
61         PROX_PANIC(tpipe->n_tables < 1, "No table created "
62                         "for %s pipeline on core %u task %u\n",
63                         targ->task_init->mode_str, targ->lconf->id, targ->task);
64
65         /* add default entry to tables */
66         for (uint8_t i = 0; i < tpipe->n_tables; ++i) {
67                 struct rte_pipeline_table_entry default_entry = {
68                         .action = RTE_PIPELINE_ACTION_PORT,
69                         {.port_id = tpipe->port_out_id[i % tpipe->n_ports_out]},
70                 };
71                 struct rte_pipeline_table_entry *default_entry_ptr;
72                 err = rte_pipeline_table_default_entry_add(tpipe->p, tpipe->table_id[i],
73                                 &default_entry, &default_entry_ptr);
74                 PROX_PANIC(err != 0, "Failed to add default entry to table %u "
75                                 "for %s pipeline on core %u task %u: "
76                                 "err = %d\n",
77                                 i, targ->task_init->mode_str,
78                                 targ->lconf->id, targ->task,
79                                 err);
80         }
81 //FIXME: this is not ACL )
82
83         /* connect pipeline input ports to ACL pipeline table */
84         init_pipe_connect_one(tpipe, targ, tpipe->table_id[0]);
85
86         /* enable pipeline input ports */
87         init_pipe_enable(tpipe, targ);
88
89         /* check pipeline consistency */
90         init_pipe_check(tpipe, targ);
91 }
92
93 static struct task_init task_init_pf_acl = {
94         .mode_str = "pf_acl",
95         .init = init_task_pf_acl,
96         .handle = handle_pipe,
97         .thread_x = thread_pipeline,
98         .size = sizeof(struct task_pf_acl),
99 };
100
101 __attribute__((constructor)) static void reg_task_pf_acl(void)
102 {
103         reg_task(&task_init_pf_acl);
104 }