bssgp: Use measured leak rate for flow control

The leak rate sent to the SGSN does not reflect the current CS level,
lost frames, and control message overhead. So the SGSN cannot do
proper queue control under non-optimal conditions.

This commit computes the leak rate for the last flow control interval
by computing the maximum theoretical leak rate and basically
substracting control blocks, nacked blocks, and reduced block sizes
due to CS downgrade. By using this approach, the value will by more
stable on low load, where the value will tend to be near the value
derived from the configuration. On full load the transmitted value is
completely derived from the measurements.

Note that the MS default values are no adapted to the adapted BVC
leak rate, since a single MS which has a lower link quality would
otherwise be reducing the rate of another MS with good radio
conditions, which would not make much sense if they did not share any
PDCH.

Sponsored-by: On-Waves ehf
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index e0b8312..bb44903 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -62,6 +62,9 @@
 	struct timeval queue_delay_sum;
 	unsigned queue_delay_count;
 	uint8_t fc_tag;
+	unsigned queue_frames_sent;
+	unsigned queue_bytes_recv;
+	unsigned queue_frames_recv;
 
 	/** callbacks below */
 
@@ -86,5 +89,7 @@
 
 void gprs_bssgp_update_queue_delay(const struct timeval *tv_recv,
 		const struct timeval *tv_now);
+void gprs_bssgp_update_frames_sent();
+void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv);
 
 #endif // GPRS_BSSGP_PCU_H