Also open + process the DSP trace messages

This patch now includes the encapsulation of sysmobts L1 dsp trace
messages in the 'standard' osmocom style logging framework (DDSP subsystem)
This commit is contained in:
Harald Welte 2011-07-05 16:41:47 +02:00
parent 547b1d1916
commit c679c2c3b7
7 changed files with 102 additions and 14 deletions

View File

@ -1,3 +1,4 @@
#define L1FWD_L1_PORT 9999
#define L1FWD_SYS_PORT 9998
#define L1FWD_DBG_PORT 9997

View File

@ -52,16 +52,24 @@
#include "l1_transp.h"
#include "l1_fwd.h"
static const uint16_t fwd_udp_ports[_NUM_MQ_WRITE] = {
static const uint16_t fwd_udp_ports[_NUM_MQ_READ] = {
[MQ_SYS_READ] = L1FWD_SYS_PORT,
[MQ_L1_READ] = L1FWD_L1_PORT,
[MQ_DBG_READ] = L1FWD_DBG_PORT,
};
static const struct value_string l1t_mq_names[] = {
{ MQ_SYS_READ, "SYS" },
{ MQ_L1_READ, "L1" },
{ MQ_DBG_READ, "DBG" },
{ 0, NULL }
};
struct l1fwd_hdl {
struct sockaddr_storage remote_sa;
socklen_t remote_sa_len;
struct osmo_wqueue udp_wq[_NUM_MQ_WRITE];
struct osmo_wqueue udp_wq[_NUM_MQ_READ];
struct femtol1_hdl *fl1h;
};
@ -73,7 +81,7 @@ int l1if_handle_l1prim(struct femtol1_hdl *fl1h, struct msgb *msg)
struct l1fwd_hdl *l1fh = fl1h->priv;
/* Enqueue message to UDP socket */
return osmo_wqueue_enqueue(&l1fh->udp_wq[MQ_L1_WRITE], msg);
return osmo_wqueue_enqueue(&l1fh->udp_wq[MQ_L1_READ], msg);
}
/* callback when there's a new SYS primitive coming in from the HW */
@ -82,9 +90,17 @@ int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg)
struct l1fwd_hdl *l1fh = fl1h->priv;
/* Enqueue message to UDP socket */
return osmo_wqueue_enqueue(&l1fh->udp_wq[MQ_SYS_WRITE], msg);
return osmo_wqueue_enqueue(&l1fh->udp_wq[MQ_SYS_READ], msg);
}
/* callback when there's a new DBG primitive coming in from the HW */
int l1if_handle_dbg(struct femtol1_hdl *fl1h, struct msgb *msg)
{
struct l1fwd_hdl *l1fh = fl1h->priv;
/* Enqueue message to UDP socket */
return osmo_wqueue_enqueue(&l1fh->udp_wq[MQ_DBG_READ], msg);
}
/* data has arrived on the udp socket */
static int udp_read_cb(struct osmo_fd *ofd)
@ -114,7 +130,7 @@ static int udp_read_cb(struct osmo_fd *ofd)
msgb_put(msg, rc);
DEBUGP(DL1C, "UDP: Received %u bytes for %s queue\n", rc,
ofd->priv_nr == MQ_SYS_WRITE ? "SYS" : "L1");
get_value_string(l1t_mq_names, ofd->priv_nr));
/* put the message into the right queue */
if (ofd->priv_nr == MQ_SYS_WRITE)
@ -132,7 +148,7 @@ static int udp_write_cb(struct osmo_fd *ofd, struct msgb *msg)
struct l1fwd_hdl *l1fh = ofd->data;
DEBUGP(DL1C, "UDP: Writing %u bytes for %s queue\n", msgb_l1len(msg),
ofd->priv_nr == MQ_SYS_WRITE ? "SYS" : "L1");
get_value_string(l1t_mq_names, ofd->priv_nr));
rc = sendto(ofd->fd, msg->l1h, msgb_l1len(msg), 0,
(const struct sockaddr *)&l1fh->remote_sa, l1fh->remote_sa_len);
@ -176,7 +192,7 @@ int main(int argc, char **argv)
fl1h->priv = l1fh;
/* Open UDP */
for (i = 0; i < 2; i++) {
for (i = 0; i < 3; i++) {
struct osmo_wqueue *wq = &l1fh->udp_wq[i];
osmo_wqueue_init(wq, 10);

View File

@ -589,6 +589,16 @@ int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg)
return l1if_handle_ind(fl1h, msg);
}
int l1if_handle_dbg(struct femtol1_hdl *fl1h, struct msgb *msg)
{
/* the msgb simply contains a zero-terminated string, print it
* to the log file */
LOGP(DDSP, LOGL_DEBUG, "%s", msg->data);
msgb_free(msg);
return 0;
}
#if 0
/* called by RSL if the BCCH SI has been modified */
int sysinfo_has_changed(struct gsm_bts *bts, int si)

View File

@ -8,6 +8,7 @@
enum {
MQ_SYS_READ,
MQ_L1_READ,
MQ_DBG_READ,
_NUM_MQ_READ
};

View File

@ -6,6 +6,7 @@
/* functions a transport calls on arrival of primitive from BTS */
int l1if_handle_l1prim(struct femtol1_hdl *fl1h, struct msgb *msg);
int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg);
int l1if_handle_dbg(struct femtol1_hdl *fl1h, struct msgb *msg);
/* functions exported by a transport */
int l1if_transport_open(struct femtol1_hdl *fl1h);

View File

@ -54,8 +54,16 @@
#include "l1_fwd.h"
static const uint16_t fwd_udp_ports[] = {
[MQ_SYS_WRITE] = L1FWD_SYS_PORT,
[MQ_L1_WRITE] = L1FWD_L1_PORT,
[MQ_SYS_READ] = L1FWD_SYS_PORT,
[MQ_L1_READ] = L1FWD_L1_PORT,
[MQ_DBG_READ] = L1FWD_DBG_PORT,
};
static const struct value_string l1t_mq_names[] = {
{ MQ_SYS_READ, "SYS" },
{ MQ_L1_READ, "L1" },
{ MQ_DBG_READ, "DBG" },
{ 0, NULL }
};
static int fwd_read_cb(struct osmo_fd *ofd)
@ -80,14 +88,29 @@ static int fwd_read_cb(struct osmo_fd *ofd)
}
msgb_put(msg, rc);
if (ofd->priv_nr == MQ_SYS_WRITE)
switch (ofd->priv_nr) {
case MQ_SYS_WRITE:
rc = l1if_handle_sysprim(fl1h, msg);
else
break;
case MQ_L1_READ:
rc = l1if_handle_l1prim(fl1h, msg);
break;
case MQ_DBG_READ:
rc = l1if_handle_dbg(fl1h, msg);
break;
}
return rc;
}
static int fwd_read_cb_bfd(struct osmo_fd *ofd, unsigned int what)
{
if (what & BSC_FD_READ)
return fwd_read_cb(ofd);
return 0;
}
static int prim_write_cb(struct osmo_fd *ofd, struct msgb *msg)
{
/* write to the fd */
@ -127,6 +150,25 @@ int l1if_transport_open(struct femtol1_hdl *fl1h)
return rc;
}
}
/* special case: debug is read-only and has no write_q */
i = MQ_DBG_READ;
{
struct osmo_fd *ofd = &fl1h->read_ofd[i];
ofd->data = fl1h;
ofd->priv_nr = i;
ofd->when |= BSC_FD_READ;
ofd->cb = fwd_read_cb_bfd;
rc = osmo_sock_init_ofd(ofd, AF_UNSPEC, SOCK_DGRAM,
IPPROTO_UDP, bts_host,
fwd_udp_ports[i],
OSMO_SOCK_F_CONNECT);
if (rc < 0) {
talloc_free(fl1h);
return rc;
}
}
return 0;
}
@ -143,6 +185,14 @@ int l1if_transport_close(struct femtol1_hdl *fl1h)
osmo_fd_unregister(ofd);
close(ofd->fd);
}
/* special case: debug is read-only and has no write_q */
i = MQ_DBG_READ;
{
struct osmo_fd *ofd = &fl1h->read_ofd[i];
osmo_fd_unregister(ofd);
close(ofd->fd);
}
return 0;
}

View File

@ -48,12 +48,14 @@
#define DEV_SYS_DSP2ARM_NAME "/dev/msgq/femtobts_dsp2arm"
#define DEV_SYS_ARM2DSP_NAME "/dev/msgq/femtobts_arm2dsp"
#define DEV_DBG_DSP2ARM_NAME "/dev/rtfifo/dsp_trace"
#define DEV_L1_DSP2ARM_NAME "/dev/msgq/gsml1_dsp2arm"
#define DEV_L1_ARM2DSP_NAME "/dev/msgq/gsml1_arm2dsp"
static const char *rd_devnames[] = {
[MQ_SYS_READ] = DEV_SYS_DSP2ARM_NAME,
[MQ_L1_READ] = DEV_L1_DSP2ARM_NAME,
[MQ_DBG_READ] = DEV_DBG_DSP2ARM_NAME,
};
static const char *wr_devnames[] = {
@ -70,7 +72,7 @@ static int l1if_fd_cb(struct osmo_fd *ofd, unsigned int what)
int rc;
msg->l1h = msg->data;
rc = read(ofd->fd, msg->l1h, sizeof(GsmL1_Prim_t));
rc = read(ofd->fd, msg->l1h, msgb_tailroom(msg));
if (rc < 0) {
if (rc != -1)
LOGP(DL1C, LOGL_ERROR, "error reading from L1 msg_queue: %s\n",
@ -80,10 +82,17 @@ static int l1if_fd_cb(struct osmo_fd *ofd, unsigned int what)
}
msgb_put(msg, rc);
if (ofd->priv_nr == MQ_L1_WRITE)
switch (ofd->priv_nr) {
case MQ_L1_READ:
return l1if_handle_l1prim(fl1h, msg);
else
case MQ_SYS_READ:
return l1if_handle_sysprim(fl1h, msg);
case MQ_DBG_READ:
return l1if_handle_dbg(fl1h, msg);
default:
msgb_free(msg);
return 0;
}
};
/* callback when we can write to one of the l1 msg_queue devices */