/
tables.h
140 lines (106 loc) · 5.37 KB
/
tables.h
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* Copyright 2013-present Barefoot Networks, Inc.
*
* 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.
*/
/*
* Antonin Bas (antonin@barefootnetworks.com)
*
*/
//! @file
//! Functions to query table information in a p4info object.
#ifndef PI_INC_PI_P4INFO_TABLES_H_
#define PI_INC_PI_P4INFO_TABLES_H_
#include "PI/pi_base.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
/* The VALID match type has been deprecated from P4Runtime. However, for
backward-compatibility with the bmv2 JSON produced by the legacy compiler
(p4c-bm), we keep the VALID match type around in PI for now */
PI_P4INFO_MATCH_TYPE_VALID = 0,
PI_P4INFO_MATCH_TYPE_EXACT,
PI_P4INFO_MATCH_TYPE_LPM,
PI_P4INFO_MATCH_TYPE_TERNARY,
PI_P4INFO_MATCH_TYPE_RANGE,
PI_P4INFO_MATCH_TYPE_END
} pi_p4info_match_type_t;
typedef struct {
char *name;
pi_p4_id_t mf_id;
pi_p4info_match_type_t match_type;
size_t bitwidth;
} pi_p4info_match_field_info_t;
pi_p4_id_t pi_p4info_table_id_from_name(const pi_p4info_t *p4info,
const char *name);
const char *pi_p4info_table_name_from_id(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
size_t pi_p4info_table_num_match_fields(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
const pi_p4_id_t *pi_p4info_table_get_match_fields(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
size_t *num_match_fields);
bool pi_p4info_table_is_match_field_of(const pi_p4info_t *p4info,
pi_p4_id_t table_id, pi_p4_id_t mf_id);
pi_p4_id_t pi_p4info_table_match_field_id_from_name(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
const char *name);
const char *pi_p4info_table_match_field_name_from_id(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
pi_p4_id_t mf_id);
size_t pi_p4info_table_match_field_index(const pi_p4info_t *p4info,
pi_p4_id_t table_id, pi_p4_id_t mf_id);
size_t pi_p4info_table_match_field_offset(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
pi_p4_id_t mf_id);
size_t pi_p4info_table_match_field_bitwidth(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
pi_p4_id_t mf_id);
size_t pi_p4info_table_match_field_byte0_mask(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
pi_p4_id_t mf_id);
size_t pi_p4info_table_match_key_size(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
const pi_p4info_match_field_info_t *pi_p4info_table_match_field_info(
const pi_p4info_t *p4info, pi_p4_id_t table_id, size_t index);
size_t pi_p4info_table_num_actions(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
bool pi_p4info_table_is_action_of(const pi_p4info_t *p4info,
pi_p4_id_t table_id, pi_p4_id_t action_id);
const pi_p4_id_t *pi_p4info_table_get_actions(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
size_t *num_actions);
bool pi_p4info_table_has_const_default_action(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
pi_p4_id_t pi_p4info_table_get_const_default_action(
const pi_p4info_t *p4info, pi_p4_id_t table_id,
bool *has_mutable_action_params);
pi_p4_id_t pi_p4info_table_get_implementation(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
bool pi_p4info_table_is_direct_resource_of(const pi_p4info_t *p4info,
pi_p4_id_t table_id,
pi_p4_id_t direct_res_id);
size_t pi_p4info_table_num_direct_resources(const pi_p4info_t *p4info,
pi_p4_id_t table_id);
const pi_p4_id_t *pi_p4info_table_get_direct_resources(
const pi_p4info_t *p4info, pi_p4_id_t table_id,
size_t *num_direct_resources);
size_t pi_p4info_table_max_size(const pi_p4info_t *p4info, pi_p4_id_t table_id);
bool pi_p4info_table_is_const(const pi_p4info_t *p4info, pi_p4_id_t table_id);
pi_p4_id_t pi_p4info_table_begin(const pi_p4info_t *p4info);
pi_p4_id_t pi_p4info_table_next(const pi_p4info_t *p4info, pi_p4_id_t id);
pi_p4_id_t pi_p4info_table_end(const pi_p4info_t *p4info);
#ifdef __cplusplus
}
#endif
#endif // PI_INC_PI_P4INFO_TABLES_H_