diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-07-26 20:10:39 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-07-26 20:18:53 +0200 |
commit | b86bf060d334b33628e192218915526a526ebe46 (patch) | |
tree | 12f1a8e0514399fce89e89932d51b7a9ad97221b /src | |
parent | fde8e6dc0c1b493f70c2ffdb5182afe8d426bd9e (diff) |
sysmobts: Support older firmware on the RevB hardware
For the firmware used on RevB the GsmL1_Prim_t was bigger than
the femtobts control structure. Solve it by introducing a macro
that will select the biggest size and use this macro. This is a
follow up fix for 08fce19cfce84432fbf8293318486a96437a3427.
Diffstat (limited to 'src')
-rw-r--r-- | src/osmo-bts-sysmo/femtobts.h | 8 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_fwd_main.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_transp_fwd.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_transp_hw.c | 8 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/osmo-bts-sysmo/femtobts.h b/src/osmo-bts-sysmo/femtobts.h index fd5142bc..a880562d 100644 --- a/src/osmo-bts-sysmo/femtobts.h +++ b/src/osmo-bts-sysmo/femtobts.h @@ -21,6 +21,14 @@ #define SUPERFEMTO_API_VERSION SUPERFEMTO_API(2,2,0) #endif +/* + * Depending on the firmware version either GsmL1_Prim_t or SuperFemto_Prim_t + * is the bigger struct. For earlier firmware versions the GsmL1_Prim_t was the + * bigger struct. + */ +#define SYSMOBTS_PRIM_SIZE \ + (OSMO_MAX(sizeof(SuperFemto_Prim_t), sizeof(GsmL1_Prim_t)) + 128) + enum l1prim_type { L1P_T_REQ, L1P_T_CONF, diff --git a/src/osmo-bts-sysmo/l1_fwd_main.c b/src/osmo-bts-sysmo/l1_fwd_main.c index e2b0d5ec..527a559e 100644 --- a/src/osmo-bts-sysmo/l1_fwd_main.c +++ b/src/osmo-bts-sysmo/l1_fwd_main.c @@ -93,7 +93,7 @@ int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg) /* data has arrived on the udp socket */ static int udp_read_cb(struct osmo_fd *ofd) { - struct msgb *msg = msgb_alloc_headroom(sizeof(SuperFemto_Prim_t) + 128, 128, "udp_rx"); + struct msgb *msg = msgb_alloc_headroom(SYSMOBTS_PRIM_SIZE, 128, "udp_rx"); struct l1fwd_hdl *l1fh = ofd->data; struct femtol1_hdl *fl1h = l1fh->fl1h; int rc; diff --git a/src/osmo-bts-sysmo/l1_transp_fwd.c b/src/osmo-bts-sysmo/l1_transp_fwd.c index 1a1aa4f9..129afe79 100644 --- a/src/osmo-bts-sysmo/l1_transp_fwd.c +++ b/src/osmo-bts-sysmo/l1_transp_fwd.c @@ -64,7 +64,7 @@ static const uint16_t fwd_udp_ports[] = { static int fwd_read_cb(struct osmo_fd *ofd) { - struct msgb *msg = msgb_alloc_headroom(sizeof(SuperFemto_Prim_t) + 128, 128, "udp_rx"); + struct msgb *msg = msgb_alloc_headroom(SYSMOBTS_PRIM_SIZE, 128, "udp_rx"); struct femtol1_hdl *fl1h = ofd->data; int rc; diff --git a/src/osmo-bts-sysmo/l1_transp_hw.c b/src/osmo-bts-sysmo/l1_transp_hw.c index d4b99780..0bfc5089 100644 --- a/src/osmo-bts-sysmo/l1_transp_hw.c +++ b/src/osmo-bts-sysmo/l1_transp_hw.c @@ -82,11 +82,17 @@ static const char *wr_devnames[] = { #endif }; +/* + * Make sure that all structs we read fit into the SYSMOBTS_PRIM_SIZE + */ +osmo_static_assert(sizeof(GsmL1_Prim_t) + 128 <= SYSMOBTS_PRIM_SIZE, prim) +osmo_static_assert(sizeof(SuperFemto_Prim_t) + 128 <= SYSMOBTS_PRIM_SIZE, prim) + /* callback when there's something to read from the l1 msg_queue */ static int l1if_fd_cb(struct osmo_fd *ofd, unsigned int what) { //struct msgb *msg = l1p_msgb_alloc(); - struct msgb *msg = msgb_alloc_headroom(sizeof(SuperFemto_Prim_t) + 128, 128, "1l_fd"); + struct msgb *msg = msgb_alloc_headroom(SYSMOBTS_PRIM_SIZE, 128, "1l_fd"); struct femtol1_hdl *fl1h = ofd->data; int rc; |