[12/33] Add PCH/AGCH message to PH-/MPH-/TCH-SAP interface
diff mbox

Message ID 1409176492-13269-13-git-send-email-laforge@gnumonks.org
State Superseded
Headers show

Commit Message

Harald Welte Aug. 27, 2014, 9:54 p.m. UTC
From: Andreas Eversberg <jolly@eversberg.eu>

This part moves PCH and AGCH message primitives from osmo-bts-sysmo to
common part.
---
 src/common/l1sap.c         |  8 ++++++++
 src/osmo-bts-sysmo/l1_if.c | 19 ++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

Patch
diff mbox

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 2dedf02..da4cc48 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -79,6 +79,7 @@  static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx,
 	uint8_t tn;
 	uint32_t fn;
 	uint8_t *p, *si;
+	int rc;
 
 	chan_nr = rts_ind->chan_nr;
 	link_id = rts_ind->link_id;
@@ -109,6 +110,13 @@  static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx,
 			memcpy(p, si, GSM_MACBLOCK_LEN);
 		else
 			memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+	} else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) {
+		p = msgb_put(msg, GSM_MACBLOCK_LEN);
+		/* if CCCH block is 0, it is AGCH */
+		rc = bts_ccch_copy_msg(trx->bts, p, &g_time,
+			(L1SAP_FN2CCCHBLOCK(fn) < 1));
+		if (rc <= 0)
+			memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
 	}
 
 	DEBUGP(DL1P, "Tx PH-DATA.req %02u/%02u/%02u chan_nr=%d link_id=%d\n",
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index d169b27..a3fd64e 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -468,6 +468,14 @@  static int ph_data_req(struct gsm_bts_trx *trx, struct msgb *msg,
 	subCh = 0x1f;
 	if (L1SAP_IS_CHAN_BCCH(chan_nr)) {
 		sapi = GsmL1_Sapi_Bcch;
+	} else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) {
+		/* The sapi depends on DSP configuration, not
+		 * on the actual SYSTEM INFORMATION 3. */
+		u8BlockNbr = L1SAP_FN2CCCHBLOCK(u32Fn);
+		if (u8BlockNbr >= 1)
+			sapi = GsmL1_Sapi_Pch;
+		else
+			sapi = GsmL1_Sapi_Agch;
 	} else {
 		LOGP(DL1C, LOGL_NOTICE, "unknown prim %d op %d "
 			"chan_nr %d link_id %d\n", l1sap->oph.primitive,
@@ -544,6 +552,10 @@  static uint8_t chan_nr_by_sapi(enum gsm_phys_chan_config pchan,
 	case GsmL1_Sapi_Bcch:
 		cbits = 0x10;
 		break;
+	case GsmL1_Sapi_Agch:
+	case GsmL1_Sapi_Pch:
+		cbits = 0x12;
+		break;
 	default:
 		return 0;
 	}
@@ -707,13 +719,6 @@  static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1,
 			msgb_free(pp.oph.msg);
 		}
 		break;
-	case GsmL1_Sapi_Agch:
-	case GsmL1_Sapi_Pch:
-		rc = bts_ccch_copy_msg(bts, msu_param->u8Buffer, &g_time,
-				       rts_ind->sapi == GsmL1_Sapi_Agch);
-		if (rc <= 0)
-			memcpy(msu_param->u8Buffer, fill_frame, GSM_MACBLOCK_LEN);
-		break;
 	case GsmL1_Sapi_TchF:
 	case GsmL1_Sapi_TchH:
 		/* only hit in case we have a RTP underflow, as real TCH