From ace2b08244058560bb155eaf9512603056a0f109 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 27 Mar 2010 12:32:10 +0800 Subject: [PATCH] add L1CTL ECHO REQUEST code --- include/l1a_l23_interface.h | 2 + src/host/layer23/include/osmocom/l1ctl.h | 2 + src/host/layer23/src/l1ctl.c | 54 ++++++++++++++++-------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/include/l1a_l23_interface.h b/include/l1a_l23_interface.h index 03f80a534..64ede925f 100644 --- a/include/l1a_l23_interface.h +++ b/include/l1a_l23_interface.h @@ -32,6 +32,8 @@ #define L1CTL_DATA_REQ 7 #define L1CTL_RESET 8 #define L1CTL_PM_REQ 9 /* power measurement */ +#define L1CTL_ECHO_REQ 10 +#define L1CTL_ECHO_RESP 11 /* * NOTE: struct size. We do add manual padding out of the believe diff --git a/src/host/layer23/include/osmocom/l1ctl.h b/src/host/layer23/include/osmocom/l1ctl.h index 0d5cba683..e4e76c05b 100644 --- a/src/host/layer23/include/osmocom/l1ctl.h +++ b/src/host/layer23/include/osmocom/l1ctl.h @@ -19,6 +19,8 @@ int tx_ph_rach_req(struct osmocom_ms *ms); /* Transmit L1CTL_DM_EST_REQ */ int tx_ph_dm_est_req(struct osmocom_ms *ms, uint16_t band_arfcn, uint8_t chan_nr); +int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len); + extern int osmo_send_l1(struct osmocom_ms *ms, struct msgb *msg); diff --git a/src/host/layer23/src/l1ctl.c b/src/host/layer23/src/l1ctl.c index 2e6e8e07b..97009cb20 100644 --- a/src/host/layer23/src/l1ctl.c +++ b/src/host/layer23/src/l1ctl.c @@ -212,23 +212,6 @@ int tx_ph_data_req(struct osmocom_ms *ms, struct msgb *msg, return osmo_send_l1(ms, msg); } -/* Receive L1CTL_RESET */ -static int rx_l1_reset(struct osmocom_ms *ms) -{ - struct msgb *msg; - struct l1ctl_sync_new_ccch_req *req; - - msg = osmo_l1_alloc(L1CTL_NEW_CCCH_REQ); - if (!msg) - return -1; - - LOGP(DL1C, LOGL_INFO, "Layer1 Reset.\n"); - req = (struct l1ctl_sync_new_ccch_req *) msgb_put(msg, sizeof(*req)); - req->band_arfcn = osmo_make_band_arfcn(ms); - - return osmo_send_l1(ms, msg); -} - /* Transmit L1CTL_RACH_REQ */ int tx_ph_rach_req(struct osmocom_ms *ms) { @@ -272,6 +255,41 @@ int tx_ph_dm_est_req(struct osmocom_ms *ms, uint16_t band_arfcn, uint8_t chan_nr return osmo_send_l1(ms, msg); } +int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len) +{ + struct msgb *msg; + uint8_t *data; + unsigned int i; + + msg = osmo_l1_alloc(L1CTL_ECHO_REQ); + if (!msg) + return -1; + + data = msgb_put(msg, len); + for (i = 0; i < len; i++) + data[i] = i % 8; + + return osmo_send_l1(ms, msg); +} + +/* Receive L1CTL_RESET */ +static int rx_l1_reset(struct osmocom_ms *ms) +{ + struct msgb *msg; + struct l1ctl_sync_new_ccch_req *req; + + msg = osmo_l1_alloc(L1CTL_NEW_CCCH_REQ); + if (!msg) + return -1; + + LOGP(DL1C, LOGL_INFO, "Layer1 Reset.\n"); + req = (struct l1ctl_sync_new_ccch_req *) msgb_put(msg, sizeof(*req)); + req->band_arfcn = osmo_make_band_arfcn(ms); + + return osmo_send_l1(ms, msg); +} + + /* Receive incoming data from L1 using L1CTL format */ int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg) { @@ -285,7 +303,7 @@ int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg) return -1; } - l1h = (struct l1ctl_info_dl *) msg->l1h; + l1h = (struct l1ctl_hdr *) msg->l1h; /* move the l1 header pointer to point _BEHIND_ l1ctl_hdr, as the l1ctl header is of no interest to subsequent code */