File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ static void mac_pd_data_confirm_failure_handle(protocol_interface_rf_mac_setup_s
74
74
75
75
static int8_t mac_tasklet_event_handler = -1 ;
76
76
77
- static ns_mem_heap_size_t ns_dyn_mem_rate_limiting_threshold = 0xFFFFFFFF ;
77
+ static uint8_t ns_dyn_mem_rate_limiting_threshold_percentage = 0 ;
78
78
79
79
/**
80
80
* Get PHY time stamp.
@@ -2127,8 +2127,12 @@ mac_pre_parsed_frame_t *mcps_sap_pre_parsed_frame_buffer_get(const uint8_t *data
2127
2127
{
2128
2128
// check that system has enough space to handle the new packet
2129
2129
const mem_stat_t * ns_dyn_mem_stat = ns_dyn_mem_get_mem_stat ();
2130
- if (ns_dyn_mem_stat && ns_dyn_mem_stat -> heap_sector_allocated_bytes > ns_dyn_mem_rate_limiting_threshold ) {
2131
- return NULL ;
2130
+
2131
+ if (ns_dyn_mem_stat && ns_dyn_mem_rate_limiting_threshold_percentage ) {
2132
+ if (ns_dyn_mem_stat -> heap_sector_allocated_bytes > ns_dyn_mem_stat -> heap_sector_size / 100 * (100 - ns_dyn_mem_rate_limiting_threshold_percentage )) {
2133
+ // Packet is dropped from radio interface because there is not enough memory to handle incoming packets.
2134
+ return NULL ;
2135
+ }
2132
2136
}
2133
2137
2134
2138
mac_pre_parsed_frame_t * buffer = ns_dyn_mem_temporary_alloc (sizeof (mac_pre_parsed_frame_t ) + frame_length );
@@ -2365,10 +2369,8 @@ uint8_t mcps_sap_purge_reg_handler(protocol_interface_rf_mac_setup_s *rf_mac_set
2365
2369
2366
2370
int mcps_packet_ingress_rate_limit_by_memory (uint8_t free_heap_percentage )
2367
2371
{
2368
- const mem_stat_t * ns_dyn_mem_stat = ns_dyn_mem_get_mem_stat ();
2369
-
2370
- if (ns_dyn_mem_stat && free_heap_percentage < 100 ) {
2371
- ns_dyn_mem_rate_limiting_threshold = ns_dyn_mem_stat -> heap_sector_size / 100 * (100 - free_heap_percentage );
2372
+ if (free_heap_percentage < 100 ) {
2373
+ ns_dyn_mem_rate_limiting_threshold_percentage = free_heap_percentage ;
2372
2374
return 0 ;
2373
2375
}
2374
2376
You can’t perform that action at this time.
0 commit comments