Fixed newline characters throughout the code
[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 #include "gstypes.h"
22 #include "gsconfig.h"
23 #include "byteswap.h"
24 #include "rts_external.h"
25
26 struct gs_string;       /* forward decl. */
27
28 #ifndef NULL
29 #define NULL 0
30 #endif
31
32 #include "fta.h"
33
34
35 /*
36  * dynamic memory allocation for FTAs (so they can store state, etc.).
37  * note that the allocator keeps track of which FTA owns what blocks and
38  * can free all allocated blocks for a given FTA in one go.
39  */
40
41 void *fta_alloc(struct FTA *, gs_int32_t size);
42 void fta_free(struct FTA *, void *mem);
43 void fta_free_all(struct FTA *);
44
45 /* memory allocation for scratchpad */
46
47 #define sp_fta_alloc fta_alloc
48 #define sp_fta_free fta_free
49 #define sp_fta_free_all fta_free_all
50
51
52 /* functions used to parse packet  (list is not complete)*/
53 #include "schema_prototypes.h"
54
55 /*
56  * FTA output: FTAs output tuples to the host using the post_tuple RTS function.
57  * Before the tuple can be output a tuple memory block has to be allocated
58  * in the tuple memory space. The allocate_tuple function is used for this.
59  * If an FTA is removed before post_tuple is called all allocated memory
60  * in the FTA's tuple space is reclaimed. If the FTA is removed after
61  * post_tuple is called the tuple will be deliverd to the host.
62  * If 0 is returned at no none suspended ringbuffer has not enough memory to
63  * allocate the tuple
64  */
65
66 void * allocate_tuple(struct FTA *,  gs_int32_t size);
67
68 /* post tuple posts the tuple if the atomic reingbuffer set can not suceed -1 is returned and the tuple is not
69  posted otherwise 0 is returned*/
70
71 gs_retval_t post_tuple(void *tuple);
72
73
74 /* the following function fills in the FTAID array r with the FTAIDs of processes receiving
75  * tuplese from the FTA specified in f. The space array indicates how many tuples of tuplesz
76  * can still fit in the ringbuffer corresponding to the FTAID of the process with the same index
77  * in r. The return values indicates how many ring buffers are valid in r. szr indicates the memory
78  * length (in elements) of  r and space. The function will fill at most szr elements into these array.
79  * If the return value is larger then szr it is an indication that not enough memory in r and space
80  * were provided to hold all results. A return value of -1 indicates an error.
81  */
82
83 gs_retval_t get_ringbuf_space(struct FTA * f, FTAID * r, gs_int32_t * space,  gs_int32_t szr, gs_int32_t tuplesz);
84
85
86 /* the following function can be used to put a ringbuffer to a process identified by the FTAID
87  * process into one of the following 3 modes. ATOMIC makes the ringbuffer part of the atomic set.
88  * A post to the atomic set either succeed or fails entirely. BESTEFORT is the besteffort set
89  * posts to BESTEFORT ringbuffers might fail quitely. SUSPEND will prevent any tuples of being
90  * posted to that proccess from the specified FTA. NOTE: Calling set_ringbuf_space between
91  * allocate_tuple and post_tuple might have unpredictable results for the tuple already
92  * allocated.
93  */
94
95 #define LFTA_RINGBUF_ATOMIC 1
96 #define LFTA_RINGBUF_BESTEFFORT 2
97 #define LFTA_RINGBUF_SUSPEND 3
98
99 gs_retval_t set_ringbuf_type(struct FTA * f, FTAID process, gs_int32_t state);
100
101 /* The following function returns TRUE if there is enough room in the post tuple
102  * queue for a speedy posting of the tuple. It should be used by FTAs which could
103  * possibly delay the posting of a tuple if FALSE is returned.
104  */
105
106 gs_retval_t post_ready(void);
107
108 /*
109  * the following function gives hints to the heap for binning
110  */
111
112 void fta_add_alloc_bin_size(struct FTA *, gs_int32_t sz, gs_int32_t maxcnt);
113 void fta_remove_alloc_bin_size(struct FTA *, gs_int32_t sz, gs_int32_t maxcnt);
114
115
116 gs_retval_t print_error(char *string);  /* XXXCDC: right place? */
117
118 /* Function to get the attributes of interfaces in an lfta */
119
120 gs_sp_t get_iface_properties (const gs_sp_t iface_name, const gs_sp_t property_name);
121
122
123 #endif