Click
Loading...
Searching...
No Matches
flowruleparser.hh
1// -*- c-basic-offset: 4 -*-
2/*
3 * flowruleparser.hh -- glues Click and DPDK for
4 * flow parsing and installation on DPDK-based NICs.
5 *
6 * Copyright (c) 2018 Tom Barbette, University of Liège
7 * Copyright (c) 2018 Georgios Katsikas, RISE SICS
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, subject to the conditions
12 * listed in the Click LICENSE file. These conditions include: you must
13 * preserve this copyright notice, and you cannot mention the copyright
14 * holders in advertising related to the Software without their permission.
15 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
16 * notice is a summary of the Click LICENSE file; the license in that file is
17 * legally binding.
18 */
19
20#ifndef CLICK_FLOWRULEPARSER_H
21#define CLICK_FLOWRULEPARSER_H
22
23CLICK_DECLS
24
25class ErrorHandler;
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <rte_version.h>
32
33#if HAVE_FLOW_API
34
35#include <rte_malloc.h>
36#include <rte_ethdev.h>
37#include <rte_flow.h>
38#include <cmdline.h>
39#include <cmdline_parse.h>
40extern "C" {
41#include <testpmd.h>
42}
49#define PORTID_T_DEFINED
50
58extern struct rte_port *ports;
59
63static struct rte_port *get_ports() {
64 return ports;
65}
66
70static struct rte_port *get_port(const portid_t &port_id) {
71 if (!ports) {
72 printf(
73 "DPDK Flow Parser (port %u): Unallocated DPDK ports\n",
74 port_id
75 );
76 return NULL;
77 }
78
79 if (port_id < 0) {
80 printf(
81 "DPDK Flow Parser (port %u): Invalid port identifier\n",
82 port_id
83 );
84 return NULL;
85 }
86
87 return &ports[port_id];
88}
89
96extern cmdline_parse_ctx_t main_ctx[];
97
102static cmdline_parse_ctx_t *cmdline_get_ctx() {
103 return main_ctx;
104}
105
111struct cmdline *cmdline_new(
112 cmdline_parse_ctx_t *ctx,
113 const char *prompt,
114 int s_in,
115 int s_out
116);
117
123int cmdline_parse(
124 struct cmdline *cl,
125 const char *buf
126);
127
128#endif // /* HAVE_FLOW_API */
129
130#ifdef __cplusplus
131}
132
133#define FLOWRULEPARSER_ERROR ((int)-1)
134#define FLOWRULEPARSER_SUCCESS ((int) 0)
135
144static void
145init_port(void)
146{
147 /* Configuration of Ethernet ports. */
148 ports = (struct rte_port *) rte_zmalloc("fastclick: ports",
149 sizeof(struct rte_port) * RTE_MAX_ETHPORTS,
150 RTE_CACHE_LINE_SIZE);
151 if (ports == NULL) {
152 rte_exit(EXIT_FAILURE, "rte_zmalloc(%d struct rte_port) failed\n", RTE_MAX_ETHPORTS);
153 }
154}
155
162struct cmdline *flow_rule_parser_init(
163 ErrorHandler *errh
164);
165
175struct cmdline *flow_rule_parser_alloc(
176 const char *prompt,
177 ErrorHandler *errh
178);
179
188char *flow_rule_parser_parse_new_line(char *line, int n, const char **input_cmd);
189
199int flow_rule_parser_parse(struct cmdline *cl, const char *input_cmd, ErrorHandler *errh);
200
201#endif
202
203CLICK_ENDDECLS
204
205#endif /* CLICK_FLOWRULEPARSER_H */
Error reporting class.
Definition error.hh:90