[MERGED] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Max has submitted this change and it was merged. Change subject: Simplify TS alloc: adjust function signatures .. Simplify TS alloc: adjust function signatures * document used parameters and return values * use consistent formatting * constify function parameters where appropriate (adjusting parameter types if necessary) Change-Id: I211b10b4da59c73d509b719346774515c761886a Related: OS#2282 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_ts_alloc.cpp 3 files changed, 61 insertions(+), 51 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/bts.cpp b/src/bts.cpp index e236f93..1669739 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -456,10 +456,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; diff --git a/src/bts.h b/src/bts.h index 34326b8..5679b98 100644 --- a/src/bts.h +++ b/src/bts.h @@ -364,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 0e8b785..e394a6e 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -58,7 +58,7 @@ return was_set; } -static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch) +static inline int8_t find_free_usf(const struct gprs_rlcmac_pdch *pdch) { uint8_t usf_map = 0; uint8_t usf; @@ -76,13 +76,11 @@ return -1; } -static inline int8_t find_free_tfi(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { - uint32_t tfi_map = 0; + uint32_t tfi_map = pdch->assigned_tfi(dir); int8_t tfi; - tfi_map = pdch->assigned_tfi(dir); if (tfi_map == NO_FREE_TFI) return -1; @@ -95,16 +93,15 @@ return -1; } -static int find_possible_pdchs(struct gprs_rlcmac_trx *trx, - size_t max_slots, - uint8_t mask, const char *mask_reason = NULL) +static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t max_slots, uint8_t mask, + const char *mask_reason = NULL) { unsigned ts; int valid_ts_set = 0; int8_t last_tsc = -1; /* must be signed */ for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; pdch = >pdch[ts]; if (!pdch->is_enabled()) { @@ -142,22 +139,19 @@ return valid_ts_set; } -static int compute_usage_by_num_tbfs(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_by_num_tbfs(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { return pdch->num_tbfs(dir); } -static int compute_usage_by_reservation(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction) +static int compute_usage_by_reservation(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction) { return pdch->num_reserved(GPRS_RLCMAC_DL_TBF) + pdch->num_reserved(GPRS_RLCMAC_UL_TBF); } -static int compute_usage_for_algo_a(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_for_algo_a(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { int usage = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF) + @@ -172,11 +166,19 @@ } -static int find_least_busy_pdch(struct gprs_rlcmac_trx *trx, - enum gprs_rlcmac_tbf_direction dir, - uint8_t mask, - int (*fn)(struct gprs_rlcmac_pdch *, enum gprs_rlcmac_tbf_direction dir), - int *free_tfi = 0, int *free_usf = 0) +/*! Return the TS which corresponds to least busy PDCH + * + * \param[in] trx Pointer to TRX object + * \param[in] dir TBF direction + * \param[in] mask set of available timeslots + * \param[in] fn Function pointer to function which computes number of associated TBFs + * \param[out] free_tfi Free
osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Patch Set 7: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I211b10b4da59c73d509b719346774515c761886a Gerrit-PatchSet: 7 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: MaxGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3912 to look at the new patch set (#7). Simplify TS alloc: adjust function signatures * document used parameters and return values * use consistent formatting * constify function parameters where appropriate (adjusting parameter types if necessary) Change-Id: I211b10b4da59c73d509b719346774515c761886a Related: OS#2282 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_ts_alloc.cpp 3 files changed, 61 insertions(+), 51 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/12/3912/7 diff --git a/src/bts.cpp b/src/bts.cpp index e236f93..1669739 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -456,10 +456,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; diff --git a/src/bts.h b/src/bts.h index 34326b8..5679b98 100644 --- a/src/bts.h +++ b/src/bts.h @@ -364,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 0e8b785..e394a6e 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -58,7 +58,7 @@ return was_set; } -static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch) +static inline int8_t find_free_usf(const struct gprs_rlcmac_pdch *pdch) { uint8_t usf_map = 0; uint8_t usf; @@ -76,13 +76,11 @@ return -1; } -static inline int8_t find_free_tfi(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { - uint32_t tfi_map = 0; + uint32_t tfi_map = pdch->assigned_tfi(dir); int8_t tfi; - tfi_map = pdch->assigned_tfi(dir); if (tfi_map == NO_FREE_TFI) return -1; @@ -95,16 +93,15 @@ return -1; } -static int find_possible_pdchs(struct gprs_rlcmac_trx *trx, - size_t max_slots, - uint8_t mask, const char *mask_reason = NULL) +static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t max_slots, uint8_t mask, + const char *mask_reason = NULL) { unsigned ts; int valid_ts_set = 0; int8_t last_tsc = -1; /* must be signed */ for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; pdch = >pdch[ts]; if (!pdch->is_enabled()) { @@ -142,22 +139,19 @@ return valid_ts_set; } -static int compute_usage_by_num_tbfs(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_by_num_tbfs(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { return pdch->num_tbfs(dir); } -static int compute_usage_by_reservation(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction) +static int compute_usage_by_reservation(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction) { return pdch->num_reserved(GPRS_RLCMAC_DL_TBF) + pdch->num_reserved(GPRS_RLCMAC_UL_TBF); } -static int compute_usage_for_algo_a(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_for_algo_a(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { int usage = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF) + @@ -172,11 +166,19 @@ } -static int find_least_busy_pdch(struct gprs_rlcmac_trx *trx, - enum gprs_rlcmac_tbf_direction dir, - uint8_t mask, - int (*fn)(struct gprs_rlcmac_pdch *, enum gprs_rlcmac_tbf_direction dir), - int *free_tfi = 0, int *free_usf = 0) +/*! Return the TS which corresponds to least busy PDCH + * + * \param[in] trx Pointer to TRX object + * \param[in] dir TBF direction + * \param[in] mask set of available timeslots + * \param[in] fn Function pointer to function which computes number of associated TBFs + * \param[out] free_tfi Free TFI + * \param[out] free_usf
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3912 to look at the new patch set (#6). Simplify TS alloc: adjust function signatures * document used parameters and return values * use consistent formatting * constify function parameters where appropriate (adjusting parameter types if necessary) Change-Id: I211b10b4da59c73d509b719346774515c761886a Related: OS#2282 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_ts_alloc.cpp 3 files changed, 61 insertions(+), 51 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/12/3912/6 diff --git a/src/bts.cpp b/src/bts.cpp index e236f93..1669739 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -456,10 +456,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; diff --git a/src/bts.h b/src/bts.h index 34326b8..5679b98 100644 --- a/src/bts.h +++ b/src/bts.h @@ -364,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 0e8b785..e394a6e 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -58,7 +58,7 @@ return was_set; } -static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch) +static inline int8_t find_free_usf(const struct gprs_rlcmac_pdch *pdch) { uint8_t usf_map = 0; uint8_t usf; @@ -76,13 +76,11 @@ return -1; } -static inline int8_t find_free_tfi(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { - uint32_t tfi_map = 0; + uint32_t tfi_map = pdch->assigned_tfi(dir); int8_t tfi; - tfi_map = pdch->assigned_tfi(dir); if (tfi_map == NO_FREE_TFI) return -1; @@ -95,16 +93,15 @@ return -1; } -static int find_possible_pdchs(struct gprs_rlcmac_trx *trx, - size_t max_slots, - uint8_t mask, const char *mask_reason = NULL) +static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t max_slots, uint8_t mask, + const char *mask_reason = NULL) { unsigned ts; int valid_ts_set = 0; int8_t last_tsc = -1; /* must be signed */ for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; pdch = >pdch[ts]; if (!pdch->is_enabled()) { @@ -142,22 +139,19 @@ return valid_ts_set; } -static int compute_usage_by_num_tbfs(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_by_num_tbfs(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { return pdch->num_tbfs(dir); } -static int compute_usage_by_reservation(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction) +static int compute_usage_by_reservation(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction) { return pdch->num_reserved(GPRS_RLCMAC_DL_TBF) + pdch->num_reserved(GPRS_RLCMAC_UL_TBF); } -static int compute_usage_for_algo_a(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_for_algo_a(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { int usage = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF) + @@ -172,11 +166,19 @@ } -static int find_least_busy_pdch(struct gprs_rlcmac_trx *trx, - enum gprs_rlcmac_tbf_direction dir, - uint8_t mask, - int (*fn)(struct gprs_rlcmac_pdch *, enum gprs_rlcmac_tbf_direction dir), - int *free_tfi = 0, int *free_usf = 0) +/*! Return the TS which corresponds to least busy PDCH + * + * \param[in] trx Pointer to TRX object + * \param[in] dir TBF direction + * \param[in] mask set of available timeslots + * \param[in] fn Function pointer to function which computes number of associated TBFs + * \param[out] free_tfi Free TFI + * \param[out] free_usf
osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Patch Set 2: > Did we remove the 80 chars limit? For several months already - see https://lists.osmocom.org/pipermail/openbsc/2017-April/thread.html#10522 -- To view, visit https://gerrit.osmocom.org/3912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I211b10b4da59c73d509b719346774515c761886a Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: MaxGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Patch Set 2: (1 comment) What tests are adjusted? https://gerrit.osmocom.org/#/c/3912/2/src/gprs_rlcmac_ts_alloc.cpp File src/gprs_rlcmac_ts_alloc.cpp: Line 305: static void assign_uplink_tbf_usf(struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_ul_tbf *tbf, uint8_t tfi, int8_t usf) Did we remove the 80 chars limit? -- To view, visit https://gerrit.osmocom.org/3912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I211b10b4da59c73d509b719346774515c761886a Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: MaxGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes
osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/3912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I211b10b4da59c73d509b719346774515c761886a Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: MaxGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Review at https://gerrit.osmocom.org/3912 Simplify TS alloc: adjust function signatures * document used parameters and return values * use consistent formatting * constify function parameters where appropriate (adjusting parameter types if necessary) Tests are adjusted accordingly but test results are left untouched to avoid regressions. Change-Id: I211b10b4da59c73d509b719346774515c761886a Related: OS#2282 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_ts_alloc.cpp 3 files changed, 63 insertions(+), 55 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/12/3912/1 diff --git a/src/bts.cpp b/src/bts.cpp index 1284f11..0046238 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -439,10 +439,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; diff --git a/src/bts.h b/src/bts.h index e4b1c23..611a58b 100644 --- a/src/bts.h +++ b/src/bts.h @@ -364,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 14d9e17..0cebd93 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -103,7 +103,7 @@ return was_set; } -static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch) +static inline int8_t find_free_usf(const struct gprs_rlcmac_pdch *pdch) { uint8_t usf_map = 0; uint8_t usf; @@ -121,13 +121,11 @@ return -1; } -static inline int8_t find_free_tfi(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { - uint32_t tfi_map = 0; + uint32_t tfi_map = pdch->assigned_tfi(dir); int8_t tfi; - tfi_map = pdch->assigned_tfi(dir); if (tfi_map == 0xUL) return -1; @@ -140,16 +138,15 @@ return -1; } -static int find_possible_pdchs(struct gprs_rlcmac_trx *trx, - size_t max_slots, - uint8_t mask, const char *mask_reason = NULL) +static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t max_slots, uint8_t mask, + const char *mask_reason = NULL) { unsigned ts; int valid_ts_set = 0; int8_t last_tsc = -1; /* must be signed */ for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; pdch = >pdch[ts]; if (!pdch->is_enabled()) { @@ -187,22 +184,19 @@ return valid_ts_set; } -static int compute_usage_by_num_tbfs(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_by_num_tbfs(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { return pdch->num_tbfs(dir); } -static int compute_usage_by_reservation(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction) +static int compute_usage_by_reservation(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction) { return pdch->num_reserved(GPRS_RLCMAC_DL_TBF) + pdch->num_reserved(GPRS_RLCMAC_UL_TBF); } -static int compute_usage_for_algo_a(struct gprs_rlcmac_pdch *pdch, - enum gprs_rlcmac_tbf_direction dir) +static int compute_usage_for_algo_a(const struct gprs_rlcmac_pdch *pdch, enum gprs_rlcmac_tbf_direction dir) { int usage = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF) + @@ -217,11 +211,19 @@ } -static int find_least_busy_pdch(struct gprs_rlcmac_trx *trx, - enum gprs_rlcmac_tbf_direction dir, - uint8_t mask, - int (*fn)(struct gprs_rlcmac_pdch *, enum gprs_rlcmac_tbf_direction dir), - int *free_tfi = 0, int *free_usf = 0) +/*! Return the TS which corresponds to least busy PDCH + * + * \param[in] trx Pointer to TRX object + * \param[in] dir TBF direction + * \param[in] mask set of available timeslots + * \param[in] fn Function pointer to function which computes number of associated TBFs + *
osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/3807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755 Gerrit-PatchSet: 5 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: MaxGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3807 to look at the new patch set (#5). Simplify TS alloc: adjust function signatures * drop unused parameters (from both functions and structs) * document used parameters and return values * tighten types used for parameters * use consistent formatting * constify function parameters where appropriate Tests are adjusted accordingly but test results are left untouched to avoid regressions. Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755 Related: OS#2282 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac.h M src/gprs_rlcmac_ts_alloc.cpp M src/tbf.cpp M src/tbf.h M src/tbf_dl.cpp M tests/alloc/AllocTest.cpp M tests/tbf/TbfTest.cpp 9 files changed, 147 insertions(+), 146 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/07/3807/5 diff --git a/src/bts.cpp b/src/bts.cpp index b768569..0046238 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -439,10 +439,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; @@ -652,12 +651,11 @@ /* FIXME: Copy and paste with other routines.. */ if (is_11bit) { - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, - ms_class, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, ms_class, true); } else { /* set class to 0, since we don't know the multislot * class yet */ - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, true); } if (!tbf) { diff --git a/src/bts.h b/src/bts.h index d65cd2f..b3a8027 100644 --- a/src/bts.h +++ b/src/bts.h @@ -204,11 +204,9 @@ struct gsmtap_inst *gsmtap; uint32_t gsmtap_categ_mask; struct gprs_rlcmac_trx trx[8]; - int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_tbf); - uint32_t alloc_algorithm_curst; /* options to customize algorithm */ + int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, + bool single, int8_t use_tbf); + uint8_t force_two_phase; uint8_t alpha, gamma; uint8_t egprs_enabled; @@ -366,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index be1e686..c16a954 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -21,6 +21,8 @@ #ifndef GPRS_RLCMAC_H #define GPRS_RLCMAC_H +#include + #ifdef __cplusplus #include #include @@ -98,20 +100,14 @@ extern "C" { #endif -int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); #ifdef __cplusplus } #endif diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 57197b2..47a892d 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -103,7 +103,7 @@ return
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3807 to look at the new patch set (#4). Simplify TS alloc: adjust function signatures * drop unused parameters (from both functions and structs) * document used parameters and return values * tighten types used for parameters * use consistent formatting * constify function parameters where appropriate Tests are adjusted accordingly but test results are left untouched to avoid regressions. Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755 Related: OS#2400 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac.h M src/gprs_rlcmac_ts_alloc.cpp M src/tbf.cpp M src/tbf.h M src/tbf_dl.cpp M tests/alloc/AllocTest.cpp M tests/tbf/TbfTest.cpp 9 files changed, 147 insertions(+), 146 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/07/3807/4 diff --git a/src/bts.cpp b/src/bts.cpp index b768569..0046238 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -439,10 +439,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; @@ -652,12 +651,11 @@ /* FIXME: Copy and paste with other routines.. */ if (is_11bit) { - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, - ms_class, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, ms_class, true); } else { /* set class to 0, since we don't know the multislot * class yet */ - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, true); } if (!tbf) { diff --git a/src/bts.h b/src/bts.h index d65cd2f..b3a8027 100644 --- a/src/bts.h +++ b/src/bts.h @@ -204,11 +204,9 @@ struct gsmtap_inst *gsmtap; uint32_t gsmtap_categ_mask; struct gprs_rlcmac_trx trx[8]; - int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_tbf); - uint32_t alloc_algorithm_curst; /* options to customize algorithm */ + int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, + bool single, int8_t use_tbf); + uint8_t force_two_phase; uint8_t alpha, gamma; uint8_t egprs_enabled; @@ -366,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index be1e686..c16a954 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -21,6 +21,8 @@ #ifndef GPRS_RLCMAC_H #define GPRS_RLCMAC_H +#include + #ifdef __cplusplus #include #include @@ -98,20 +100,14 @@ extern "C" { #endif -int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); #ifdef __cplusplus } #endif diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 57197b2..47a892d 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -103,7 +103,7 @@ return
[PATCH] osmo-pcu[master]: Simplify TS alloc: adjust function signatures
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3807 to look at the new patch set (#3). Simplify TS alloc: adjust function signatures * drop unused parameters (from both functions and structs) * document used parameters and return values * tighten types used for parameters * use consistent formatting * constify function parameters where appropriate Tests are adjusted accordingly but test results are left untouched to avoid regressions. Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755 Related: OS#2400 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac.h M src/gprs_rlcmac_ts_alloc.cpp M src/tbf.cpp M src/tbf.h M src/tbf_dl.cpp M tests/alloc/AllocTest.cpp M tests/tbf/TbfTest.cpp 9 files changed, 146 insertions(+), 145 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/07/3807/3 diff --git a/src/bts.cpp b/src/bts.cpp index b768569..0046238 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -439,10 +439,9 @@ * a TRX. The first TRX that contains such an TFI is returned. Negative values * indicate errors. */ -int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const { - struct gprs_rlcmac_pdch *pdch; + const struct gprs_rlcmac_pdch *pdch; uint32_t free_tfis; bool has_pdch = false; uint8_t trx_from, trx_to, trx, ts, tfi; @@ -652,12 +651,11 @@ /* FIXME: Copy and paste with other routines.. */ if (is_11bit) { - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, - ms_class, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, ms_class, true); } else { /* set class to 0, since we don't know the multislot * class yet */ - tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, 1); + tbf = tbf_alloc_ul_tbf(_bts, NULL, -1, 0, 0, true); } if (!tbf) { diff --git a/src/bts.h b/src/bts.h index d65cd2f..b3a8027 100644 --- a/src/bts.h +++ b/src/bts.h @@ -204,11 +204,9 @@ struct gsmtap_inst *gsmtap; uint32_t gsmtap_categ_mask; struct gprs_rlcmac_trx trx[8]; - int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_tbf); - uint32_t alloc_algorithm_curst; /* options to customize algorithm */ + int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, + bool single, int8_t use_tbf); + uint8_t force_two_phase; uint8_t alpha, gamma; uint8_t egprs_enabled; @@ -366,7 +364,7 @@ gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); - int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index be1e686..c16a954 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -21,6 +21,8 @@ #ifndef GPRS_RLCMAC_H #define GPRS_RLCMAC_H +#include + #ifdef __cplusplus #include #include @@ -98,20 +100,14 @@ extern "C" { #endif -int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); -int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, - struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, - int use_trx); +int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single, + int8_t use_trx); #ifdef __cplusplus } #endif diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 57197b2..ba9734f 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -103,7 +103,7 @@ return