Pick unreserved UL FN when allocating an SBA

Make sure an unreserved FN is picked and reserved when allocating and
scheduling an SBA.
In practice this has no change in behavior right now, since anyway using
an offset of 52 FNs ensure no USF or POLL has alredy been scheduled that
far in the future. Since it's also impossible to allocate more than 1
SBA per PDCH and RTS FN, we are also safe about multiple SBAs being
allocated, because we use a hardcoded offset of 52.
However, that could change in the future, when we dynamically tweak the
current offset of 52 FN based on information from BTS about its AGCH
queue load:
* If load is high, we may need to increase the offset since it
will take more time for the BTS to transmit the TBF and hence we must
reserve a TBF starting time further in the future (higher FN).
* If load turns low, we may schedule next SBA a bit more nearby in time
  than the previously allocated SBA, hence here there could be a
  collision.

Related: OS#5020
Change-Id: I2d4e21e2307de6c17748e8da5c7e149c947a7eb9
diff --git a/src/sba.c b/src/sba.c
index 3126893..ce44fa5 100644
--- a/src/sba.c
+++ b/src/sba.c
@@ -57,15 +57,18 @@
 struct gprs_rlcmac_sba *sba_alloc(void *ctx, struct gprs_rlcmac_pdch *pdch, uint8_t ta)
 {
 	struct gprs_rlcmac_sba *sba;
+	uint32_t start_fn;
+
 	sba = talloc_zero(ctx, struct gprs_rlcmac_sba);
 	if (!sba)
 		return NULL;
 
+	/* TODO: Increase start_fn dynamically based on AGCH queue load in the BTS: */
+	start_fn = next_fn(pdch->last_rts_fn, AGCH_START_OFFSET);
+
 	sba->pdch = pdch;
 	sba->ta = ta;
-
-	/* TODO: request ULC for next available FN instead of hardcoded AGCH_START_OFFSET */
-	sba->fn = next_fn(pdch->last_rts_fn, AGCH_START_OFFSET);
+	sba->fn = pdch_ulc_get_next_free_fn(pdch->ulc, start_fn);
 
 	pdch_ulc_reserve_sba(pdch->ulc, sba);
 	return sba;