From patchwork Wed Jun 4 12:56:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Willmann X-Patchwork-Id: 355928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 549FE140093 for ; Wed, 4 Jun 2014 23:01:53 +1000 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WsAp0-0008Gj-UW; Wed, 04 Jun 2014 15:01:39 +0200 Received: from isonoe.totalueberwachung.de ([2a01:198:210:100::1]) by ganesha.gnumonks.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1WsAjz-0007US-2f; Wed, 04 Jun 2014 14:56:32 +0200 Received: from adrastea.totalueberwachung.de (24-134-59-157-dynip.superkabel.de [24.134.59.157]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by isonoe.totalueberwachung.de (Postfix) with ESMTPSA id A14B96005B; Wed, 4 Jun 2014 14:56:26 +0200 (CEST) Received: by adrastea.totalueberwachung.de (Postfix, from userid 1000) id EED86220EB; Wed, 4 Jun 2014 14:56:24 +0200 (CEST) From: Daniel Willmann To: OpenBSC Mailing List , Osmocom net ML Subject: [osmo-pcu 2/2] gprs_rlcmac_pdch: Get rid of ul/dl_tbf Date: Wed, 4 Jun 2014 14:56:10 +0200 Message-Id: <5ca01827caed51b54def2b7396c01e4a7737486c.1401886570.git.daniel@totalueberwachung.de> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: References: In-Reply-To: References: X-Spam-Score: -0.0 (/) Cc: Daniel Willmann X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org The current code keeps a reference to all tbfs in the bts and another reference in the pdch. This allows for the possibility of both lists to go out of sync. This patch removes the pdch-specific list of ul and dl tbfs and uses the lists in the bts to lookup tbfs everywhere. --- src/bts.cpp | 21 +++++++++++++++------ src/bts.h | 3 +-- src/gprs_rlcmac_ts_alloc.cpp | 4 +--- src/tbf.cpp | 17 ++++------------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index b383546..a9043bc 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -991,16 +991,25 @@ int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn, int8_t return rc; } +struct gprs_rlcmac_tbf *gprs_rlcmac_pdch::tbf_from_list_by_tfi(struct llist_head *tbf_list, uint8_t tfi) +{ + struct gprs_rlcmac_tbf *tbf; + + llist_for_each_entry(tbf, tbf_list, list) { + if (tbf->tfi() != tfi) + continue; + if (!tbf->pdch[this->ts_no]) + continue; + return tbf; + } + return NULL; +} struct gprs_rlcmac_tbf *gprs_rlcmac_pdch::ul_tbf_by_tfi(uint8_t tfi) { - if (tfi >= ARRAY_SIZE(this->ul_tbf)) - return NULL; - return this->ul_tbf[tfi]; + return this->tbf_from_list_by_tfi(&bts_main_data()->ul_tbfs, tfi); } struct gprs_rlcmac_tbf *gprs_rlcmac_pdch::dl_tbf_by_tfi(uint8_t tfi) { - if (tfi >= ARRAY_SIZE(this->dl_tbf)) - return NULL; - return this->dl_tbf[tfi]; + return this->tbf_from_list_by_tfi(&bts_main_data()->dl_tbfs, tfi); } diff --git a/src/bts.h b/src/bts.h index 578c63d..e5acef3 100644 --- a/src/bts.h +++ b/src/bts.h @@ -71,8 +71,6 @@ struct gprs_rlcmac_pdch { uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */ uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */ uint8_t next_ctrl_prio; /* next kind of ctrl message to schedule */ - struct gprs_rlcmac_tbf *ul_tbf[32]; /* array of UL TBF, by UL TFI */ - struct gprs_rlcmac_tbf *dl_tbf[32]; /* array of DL TBF, by DL TFI */ struct llist_head paging_list; /* list of paging messages */ uint32_t last_rts_fn; /* store last frame number of RTS */ @@ -89,6 +87,7 @@ private: void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn); void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn); void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn); + struct gprs_rlcmac_tbf *tbf_from_list_by_tfi(struct llist_head *tbf_list, uint8_t tfi); #endif }; diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 13fc636..b070c2e 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -83,7 +83,7 @@ static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch) /* make map of used USF */ for (tfi = 0; tfi < 32; tfi++) { - tbf = pdch->ul_tbf[tfi]; + tbf = pdch->ul_tbf_by_tfi(tfi); if (!tbf) continue; usf_map |= (1 << tbf->dir.ul.usf[pdch->ts_no]); @@ -121,7 +121,6 @@ static void assign_uplink_tbf_usf( struct gprs_rlcmac_tbf *tbf, int8_t usf) { tbf->trx->ul_tbf[tbf->tfi()] = tbf; - pdch->ul_tbf[tbf->tfi()] = tbf; tbf->pdch[pdch->ts_no] = pdch; tbf->dir.ul.usf[pdch->ts_no] = usf; } @@ -131,7 +130,6 @@ static void assign_dlink_tbf( struct gprs_rlcmac_tbf *tbf) { tbf->trx->dl_tbf[tbf->tfi()] = tbf; - pdch->dl_tbf[tbf->tfi()] = tbf; tbf->pdch[pdch->ts_no] = pdch; } diff --git a/src/tbf.cpp b/src/tbf.cpp index 3a2ad73..5943674 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -250,25 +250,16 @@ struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf) { - struct gprs_rlcmac_pdch *pdch; int ts; if (tbf->direction == GPRS_RLCMAC_UL_TBF) { tbf->trx->ul_tbf[tbf->tfi()] = NULL; - for (ts = 0; ts < 8; ts++) { - pdch = tbf->pdch[ts]; - if (pdch) - pdch->ul_tbf[tbf->tfi()] = NULL; + for (ts = 0; ts < 8; ts++) tbf->pdch[ts] = NULL; - } } else { tbf->trx->dl_tbf[tbf->tfi()] = NULL; - for (ts = 0; ts < 8; ts++) { - pdch = tbf->pdch[ts]; - if (pdch) - pdch->dl_tbf[tbf->tfi()] = NULL; + for (ts = 0; ts < 8; ts++) tbf->pdch[ts] = NULL; - } } } @@ -1472,10 +1463,10 @@ void gprs_rlcmac_tbf::free_all(struct gprs_rlcmac_pdch *pdch) for (uint8_t tfi = 0; tfi < 32; tfi++) { struct gprs_rlcmac_tbf *tbf; - tbf = pdch->ul_tbf[tfi]; + tbf = pdch->ul_tbf_by_tfi(tfi); if (tbf) tbf_free(tbf); - tbf = pdch->dl_tbf[tfi]; + tbf = pdch->dl_tbf_by_tfi(tfi); if (tbf) tbf_free(tbf); }