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