mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	chan_alloc: remove ts_alloc() and ts_free()
The idea of ts_alloc()/ts_free() dates back to the very early days of OpenBSC, where we didn't yet have a fixed PCHAN type assigned for every lchan in a BTS. However, ever since, PCHAN types (channel combinations) are configured by OML in a certain way, and we only allocate LCHANs inside PCHANs of a matching type. There should be no PCHANs with type GSM_PCHAN_NONE, unless those that you don't want to use for administraive reasons or the like.
This commit is contained in:
		@@ -24,17 +24,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct gsm_subscriber_connection;
 | 
					struct gsm_subscriber_connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Special allocator for C0 of BTS */
 | 
					 | 
				
			||||||
struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts,
 | 
					 | 
				
			||||||
				   enum gsm_phys_chan_config pchan);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Regular physical channel allocator */
 | 
					 | 
				
			||||||
struct gsm_bts_trx_ts *ts_alloc(struct gsm_bts *bts,
 | 
					 | 
				
			||||||
				enum gsm_phys_chan_config pchan);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Regular physical channel (TS) */
 | 
					 | 
				
			||||||
void ts_free(struct gsm_bts_trx_ts *ts);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Find an allocated channel for a specified subscriber */
 | 
					/* Find an allocated channel for a specified subscriber */
 | 
				
			||||||
struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr);
 | 
					struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,97 +58,6 @@ int trx_is_usable(struct gsm_bts_trx *trx)
 | 
				
			|||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts,
 | 
					 | 
				
			||||||
				   enum gsm_phys_chan_config pchan)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct gsm_bts_trx *trx = bts->c0;
 | 
					 | 
				
			||||||
	struct gsm_bts_trx_ts *ts = &trx->ts[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (pchan != GSM_PCHAN_CCCH &&
 | 
					 | 
				
			||||||
	    pchan != GSM_PCHAN_CCCH_SDCCH4 &&
 | 
					 | 
				
			||||||
	    pchan != GSM_PCHAN_CCCH_SDCCH4_CBCH)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (ts->pchan != GSM_PCHAN_NONE)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ts->pchan = pchan;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ts;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Allocate a physical channel (TS) */
 | 
					 | 
				
			||||||
struct gsm_bts_trx_ts *ts_alloc(struct gsm_bts *bts,
 | 
					 | 
				
			||||||
				enum gsm_phys_chan_config pchan)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int j;
 | 
					 | 
				
			||||||
	struct gsm_bts_trx *trx;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	llist_for_each_entry(trx, &bts->trx_list, list) {
 | 
					 | 
				
			||||||
		int from, to;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!trx_is_usable(trx))
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* the following constraints are pure policy,
 | 
					 | 
				
			||||||
		 * no requirement to put this restriction in place */
 | 
					 | 
				
			||||||
		if (trx == bts->c0) {
 | 
					 | 
				
			||||||
			/* On the first TRX we run one CCCH and one SDCCH8 */
 | 
					 | 
				
			||||||
			switch (pchan) {
 | 
					 | 
				
			||||||
			case GSM_PCHAN_CCCH:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_CCCH_SDCCH4:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_CCCH_SDCCH4_CBCH:
 | 
					 | 
				
			||||||
				from = 0; to = 0;
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case GSM_PCHAN_TCH_F:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_TCH_H:
 | 
					 | 
				
			||||||
				from = 1; to = 7;
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case GSM_PCHAN_SDCCH8_SACCH8C:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				return NULL;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			/* Every secondary TRX is configured for TCH/F
 | 
					 | 
				
			||||||
			 * and TCH/H only */
 | 
					 | 
				
			||||||
			switch (pchan) {
 | 
					 | 
				
			||||||
			case GSM_PCHAN_SDCCH8_SACCH8C:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
 | 
					 | 
				
			||||||
				from = 1; to = 1;
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case GSM_PCHAN_TCH_F:
 | 
					 | 
				
			||||||
			case GSM_PCHAN_TCH_H:
 | 
					 | 
				
			||||||
				from = 1; to = 7;
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				return NULL;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for (j = from; j <= to; j++) {
 | 
					 | 
				
			||||||
			struct gsm_bts_trx_ts *ts = &trx->ts[j];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!ts_is_usable(ts))
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (ts->pchan == GSM_PCHAN_NONE) {
 | 
					 | 
				
			||||||
				ts->pchan = pchan;
 | 
					 | 
				
			||||||
				/* set channel attribute on OML */
 | 
					 | 
				
			||||||
				abis_nm_set_channel_attr(ts, abis_nm_chcomb4pchan(pchan));
 | 
					 | 
				
			||||||
				return ts;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Free a physical channel (TS) */
 | 
					 | 
				
			||||||
void ts_free(struct gsm_bts_trx_ts *ts)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ts->pchan = GSM_PCHAN_NONE;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static const uint8_t subslots_per_pchan[] = {
 | 
					static const uint8_t subslots_per_pchan[] = {
 | 
				
			||||||
	[GSM_PCHAN_NONE] = 0,
 | 
						[GSM_PCHAN_NONE] = 0,
 | 
				
			||||||
	[GSM_PCHAN_CCCH] = 0,
 | 
						[GSM_PCHAN_CCCH] = 0,
 | 
				
			||||||
@@ -200,7 +109,6 @@ static struct gsm_lchan *
 | 
				
			|||||||
_lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
 | 
					_lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct gsm_bts_trx *trx;
 | 
						struct gsm_bts_trx *trx;
 | 
				
			||||||
	struct gsm_bts_trx_ts *ts;
 | 
					 | 
				
			||||||
	struct gsm_lchan *lc;
 | 
						struct gsm_lchan *lc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bts->chan_alloc_reverse) {
 | 
						if (bts->chan_alloc_reverse) {
 | 
				
			||||||
@@ -217,20 +125,7 @@ _lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* we cannot allocate more of these */
 | 
					 | 
				
			||||||
	if (pchan == GSM_PCHAN_CCCH_SDCCH4 ||
 | 
					 | 
				
			||||||
	    pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH ||
 | 
					 | 
				
			||||||
	    pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH)
 | 
					 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* if we've reached here, we need to allocate a new physical
 | 
					 | 
				
			||||||
	 * channel for the logical channel type requested */
 | 
					 | 
				
			||||||
	ts = ts_alloc(bts, pchan);
 | 
					 | 
				
			||||||
	if (!ts) {
 | 
					 | 
				
			||||||
		/* no more radio resources */
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return &ts->lchan[0];
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Allocate a logical channel */
 | 
					/* Allocate a logical channel */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user