Added quantiling UDAFs
[com/gs-lite.git] / include / lfta / rts.h
1 /* ------------------------------------------------\r
2  Copyright 2014 AT&T Intellectual Property\r
3  Licensed under the Apache License, Version 2.0 (the "License");\r
4  you may not use this file except in compliance with the License.\r
5  You may obtain a copy of the License at\r
6  \r
7  http://www.apache.org/licenses/LICENSE-2.0\r
8  \r
9  Unless required by applicable law or agreed to in writing, software\r
10  distributed under the License is distributed on an "AS IS" BASIS,\r
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12  See the License for the specific language governing permissions and\r
13  limitations under the License.\r
14  ------------------------------------------- */\r
15 \r
16 /*\r
17  * rts.h: ethernet card run-time system dfns\r
18  */\r
19 #ifndef RTS_H\r
20 #define RTS_H\r
21 #include "gstypes.h"\r
22 #include "gsconfig.h"\r
23 #include "byteswap.h"\r
24 #include "rts_external.h"\r
25 \r
26 struct gs_string;       /* forward decl. */\r
27 \r
28 #ifndef NULL\r
29 #define NULL 0\r
30 #endif\r
31 \r
32 #include "fta.h"\r
33 \r
34 \r
35 /*\r
36  * dynamic memory allocation for FTAs (so they can store state, etc.).\r
37  * note that the allocator keeps track of which FTA owns what blocks and\r
38  * can free all allocated blocks for a given FTA in one go.\r
39  */\r
40 \r
41 void *fta_alloc(struct FTA *, gs_int32_t size);\r
42 void fta_free(struct FTA *, void *mem);\r
43 void fta_free_all(struct FTA *);\r
44 \r
45 /* memory allocation for scratchpad */\r
46 \r
47 #define sp_fta_alloc fta_alloc\r
48 #define sp_fta_free fta_free\r
49 #define sp_fta_free_all fta_free_all\r
50 \r
51 \r
52 /* functions used to parse packet  (list is not complete)*/\r
53 #include "schema_prototypes.h"\r
54 \r
55 /*\r
56  * FTA output: FTAs output tuples to the host using the post_tuple RTS function.\r
57  * Before the tuple can be output a tuple memory block has to be allocated\r
58  * in the tuple memory space. The allocate_tuple function is used for this.\r
59  * If an FTA is removed before post_tuple is called all allocated memory\r
60  * in the FTA's tuple space is reclaimed. If the FTA is removed after\r
61  * post_tuple is called the tuple will be deliverd to the host.\r
62  * If 0 is returned at no none suspended ringbuffer has not enough memory to\r
63  * allocate the tuple\r
64  */\r
65 \r
66 void * allocate_tuple(struct FTA *,  gs_int32_t size);\r
67 \r
68 /* post tuple posts the tuple if the atomic reingbuffer set can not suceed -1 is returned and the tuple is not\r
69  posted otherwise 0 is returned*/\r
70 \r
71 gs_retval_t post_tuple(void *tuple);\r
72 \r
73 \r
74 /* the following function fills in the FTAID array r with the FTAIDs of processes receiving\r
75  * tuplese from the FTA specified in f. The space array indicates how many tuples of tuplesz\r
76  * can still fit in the ringbuffer corresponding to the FTAID of the process with the same index\r
77  * in r. The return values indicates how many ring buffers are valid in r. szr indicates the memory\r
78  * length (in elements) of  r and space. The function will fill at most szr elements into these array.\r
79  * If the return value is larger then szr it is an indication that not enough memory in r and space\r
80  * were provided to hold all results. A return value of -1 indicates an error.\r
81  */\r
82 \r
83 gs_retval_t get_ringbuf_space(struct FTA * f, FTAID * r, gs_int32_t * space,  gs_int32_t szr, gs_int32_t tuplesz);\r
84 \r
85 \r
86 /* the following function can be used to put a ringbuffer to a process identified by the FTAID\r
87  * process into one of the following 3 modes. ATOMIC makes the ringbuffer part of the atomic set.\r
88  * A post to the atomic set either succeed or fails entirely. BESTEFORT is the besteffort set\r
89  * posts to BESTEFORT ringbuffers might fail quitely. SUSPEND will prevent any tuples of being\r
90  * posted to that proccess from the specified FTA. NOTE: Calling set_ringbuf_space between\r
91  * allocate_tuple and post_tuple might have unpredictable results for the tuple already\r
92  * allocated.\r
93  */\r
94 \r
95 #define LFTA_RINGBUF_ATOMIC 1\r
96 #define LFTA_RINGBUF_BESTEFFORT 2\r
97 #define LFTA_RINGBUF_SUSPEND 3\r
98 \r
99 gs_retval_t set_ringbuf_type(struct FTA * f, FTAID process, gs_int32_t state);\r
100 \r
101 /* The following function returns TRUE if there is enough room in the post tuple\r
102  * queue for a speedy posting of the tuple. It should be used by FTAs which could\r
103  * possibly delay the posting of a tuple if FALSE is returned.\r
104  */\r
105 \r
106 gs_retval_t post_ready(void);\r
107 \r
108 /*\r
109  * the following function gives hints to the heap for binning\r
110  */\r
111 \r
112 void fta_add_alloc_bin_size(struct FTA *, gs_int32_t sz, gs_int32_t maxcnt);\r
113 void fta_remove_alloc_bin_size(struct FTA *, gs_int32_t sz, gs_int32_t maxcnt);\r
114 \r
115 \r
116 gs_retval_t print_error(char *string);  /* XXXCDC: right place? */\r
117 \r
118 /* Function to get the attributes of interfaces in an lfta */\r
119 \r
120 gs_sp_t get_iface_properties (const gs_sp_t iface_name, const gs_sp_t property_name);\r
121 \r
122 \r
123 #endif\r