|
| 1 | +/* |
| 2 | + * Copyright (c) 2019, Arm Limited and affiliates. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#ifndef _NS_CONF_H_ |
| 19 | +#define _NS_CONF_H_ |
| 20 | + |
| 21 | +#ifdef __cplusplus |
| 22 | +extern "C" { |
| 23 | +#endif |
| 24 | + |
| 25 | +/** |
| 26 | + * \file ns_conf.h |
| 27 | + * \brief Nanostack configuration API. |
| 28 | + */ |
| 29 | + |
| 30 | +/** |
| 31 | + * \brief Set threshold for memory garbage collection. |
| 32 | + * |
| 33 | + * Nanostack heap usage is monitored in regular intervals. If too much memory has been used then garbage collection (GC) |
| 34 | + * is triggered. GC has two adjustable thresholds: HIGH and CRITICAL. HIGH threshold is lower one and once exceeded |
| 35 | + * a GC will try to release memory that is used for caching. When CRITTICAL threshold is exceeded them GC will try to release |
| 36 | + * memory more aggressiveliy. |
| 37 | + * |
| 38 | + * Nanostack memory monitoring can only work if memory statistics are enabled in nsdynmemLIB. |
| 39 | +
|
| 40 | + * |
| 41 | + * \param percentage_high Percentage of total heap when garbage collection is first time triggered |
| 42 | + * \param percentage_critical Percentage of total heap when critical garbage collection is triggered |
| 43 | + * |
| 44 | + * \return 0 in success, negative value in case of error. |
| 45 | + * |
| 46 | + */ |
| 47 | +int ns_conf_gc_threshold_set(uint8_t percentage_high, uint8_t percentage_critical); |
| 48 | + |
| 49 | +/** |
| 50 | + * \brief Limit amount of incoming packets if system does not have enough free memory. |
| 51 | + * Memory statistics must been initialized in nsdynmemLIB to get this feature working. |
| 52 | + * |
| 53 | + * \param free_heap_percentage Percentage of free heap that must be available when packet arrives to MAC layer. |
| 54 | + * \return 0 in case of success, <0 otherwise. |
| 55 | + */ |
| 56 | +int ns_conf_packet_ingress_rate_limit_by_mem(uint8_t free_heap_percentage); |
| 57 | + |
| 58 | +#ifdef __cplusplus |
| 59 | +} |
| 60 | +#endif |
| 61 | + |
| 62 | +#endif /* _NS_CONF_H_ */ |
0 commit comments