• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * match_table.h
3  *
4  * Files related to the matching table.
5  *
6  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef __MATCH_TABLE_H__
24 #define __MATCH_TABLE_H__
25 
26 /*****************************************************************************/
27 struct match_reg_type {
28 	int reg;
29 	int type;
30 };
31 
32 struct match_type_str {
33 	int type;
34 	const char *str;
35 };
36 
37 struct match_t {
38 	int type;
39 	int reg;
40 	void *data;
41 };
42 
43 /*****************************************************************************/
44 #define match_set_type_reg(_type, _reg)   {(_type), (_reg), (void *)0}
45 #define match_set_type_data(_type, _data) {(_type), 0, (void *)(_data)}
46 #define match_set(_type, _reg, _data)     {(_type), (_reg), (void *)(_data)}
47 
48 /*****************************************************************************/
49 int reg2type(struct match_reg_type *table, int length, int reg, int def);
50 
51 int type2reg(struct match_reg_type *table, int length, int type, int def);
52 
53 int str2type(struct match_type_str *table, int length, const char *str,
54 			 int size, int def);
55 
56 const char *type2str(struct match_type_str *table, int length, int type,
57 					 const char *def);
58 
59 int match_reg_to_type(struct match_t *table, int nr_table, int reg, int def);
60 
61 int match_type_to_reg(struct match_t *table, int nr_table, int type, int def);
62 
63 int match_data_to_type(struct match_t *table, int nr_table, const char *data,
64 					   int size, int def);
65 
66 void *match_type_to_data(struct match_t *table, int nr_table, int type,
67 						 void *def);
68 
69 /*****************************************************************************/
70 
71 #endif /* End of __MATCH_TABLE_H__ */
72