[MERGED] osmo-pcu[master]: Simplify polling troubleshooting

2017-08-14 Thread Max
Max has submitted this change and it was merged.

Change subject: Simplify polling troubleshooting
..


Simplify polling troubleshooting

* introduce enum describing poll kind and use it in set_polling()
* move state change into set_polling()
* move logging into set_polling() and unify output
* move duplicated code into static function
* adjust tests to match unified logging output

Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Related: OS#1524
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.err
6 files changed, 100 insertions(+), 103 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.cpp b/src/bts.cpp
index 0f67536..add6ab3 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1381,7 +1381,9 @@
}
 
/* set control ts to current MS's TS, until assignment complete 
*/
-   LOGP(DRLCMAC, LOGL_DEBUG, "Change control TS to %d until 
assinment is complete.\n", ts_no);
+   LOGP(DRLCMAC, LOGL_DEBUG, "%s change control TS %d -> %d until 
assinment is complete.\n",
+tbf_name(ul_tbf), ul_tbf->control_ts, ts_no);
+
ul_tbf->control_ts = ts_no;
/* schedule uplink assignment */
ul_tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 5b28d9b..c5f4348 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -593,16 +593,50 @@
return 0;
 }
 
-void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts)
+void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t)
 {
-   LOGP(DRLCMAC, LOGL_DEBUG,
-   "%s: Scheduling polling at FN %d TS %d\n",
-   name(), new_poll_fn, ts);
+   const char *chan = "UNKNOWN";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_CCCH)))
+   chan = "CCCH";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH)))
+   chan = "PACCH";
+
+   if ((state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH))) && (state_flags & 
(1 << (GPRS_RLCMAC_FLAG_CCCH
+   LOGP(DRLCMACDL, LOGL_ERROR,
+"%s Attempt to schedule polling on %s (FN=%d, TS=%d) with 
both CCCH and PACCH flags set - FIXME!\n",
+name(), chan, poll_fn, poll_ts);
 
/* schedule polling */
poll_state = GPRS_RLCMAC_POLL_SCHED;
poll_fn = new_poll_fn;
poll_ts = ts;
+
+   switch (t) {
+   case GPRS_RLCMAC_POLL_UL_ASS:
+   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled UL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ASS:
+   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled DL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_UL_ACK:
+   ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+
+   LOGP(DRLCMACUL, LOGL_DEBUG, "%s Scheduled UL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ACK:
+   LOGP(DRLCMACDL, LOGL_DEBUG, "%s Scheduled DL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   }
 }
 
 void gprs_rlcmac_tbf::poll_timeout()
@@ -1152,11 +1186,7 @@
talloc_free(mac_control_block);
 
if (poll_ass_dl) {
-   set_polling(new_poll_fn, ts);
-   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled DL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS);
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
@@ -1253,11 +1283,7 @@
bitvec_free(ass_vec);
talloc_free(mac_control_block);
 
-   set_polling(new_poll_fn, ts);
-   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled UL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS);
 
return msg;
 }
diff --git a/src/tbf.h b/src/tbf.h
index 9cc70e6..95e1e89 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -54,6 +54,13 @@
GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 };
 
+enum gprs_rlcmac_tbf_poll_type {
+   

osmo-pcu[master]: Simplify polling troubleshooting

2017-08-09 Thread Harald Welte

Patch Set 7: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/2859
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Gerrit-PatchSet: 7
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-pcu[master]: Simplify polling troubleshooting

2017-07-11 Thread Harald Welte

Patch Set 7: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2859
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Gerrit-PatchSet: 7
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: Simplify polling troubleshooting

2017-07-11 Thread Max
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2859

to look at the new patch set (#7).

Simplify polling troubleshooting

* introduce enum describing poll kind and use it in set_polling()
* move state change into set_polling()
* move logging into set_polling() and unify output
* move duplicated code into static function
* adjust tests to match unified logging output

Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Related: OS#1524
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.err
6 files changed, 100 insertions(+), 103 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/59/2859/7

diff --git a/src/bts.cpp b/src/bts.cpp
index 5f7d9e8..302daf9 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1360,7 +1360,9 @@
}
 
/* set control ts to current MS's TS, until assignment complete 
*/
-   LOGP(DRLCMAC, LOGL_DEBUG, "Change control TS to %d until 
assinment is complete.\n", ts_no);
+   LOGP(DRLCMAC, LOGL_DEBUG, "%s change control TS %d -> %d until 
assinment is complete.\n",
+tbf_name(ul_tbf), ul_tbf->control_ts, ts_no);
+
ul_tbf->control_ts = ts_no;
/* schedule uplink assignment */
ul_tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index b2acb11..4871076 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -593,16 +593,50 @@
return 0;
 }
 
-void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts)
+void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t)
 {
-   LOGP(DRLCMAC, LOGL_DEBUG,
-   "%s: Scheduling polling at FN %d TS %d\n",
-   name(), new_poll_fn, ts);
+   const char *chan = "UNKNOWN";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_CCCH)))
+   chan = "CCCH";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH)))
+   chan = "PACCH";
+
+   if ((state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH))) && (state_flags & 
(1 << (GPRS_RLCMAC_FLAG_CCCH
+   LOGP(DRLCMACDL, LOGL_ERROR,
+"%s Attempt to schedule polling on %s (FN=%d, TS=%d) with 
both CCCH and PACCH flags set - FIXME!\n",
+name(), chan, poll_fn, poll_ts);
 
/* schedule polling */
poll_state = GPRS_RLCMAC_POLL_SCHED;
poll_fn = new_poll_fn;
poll_ts = ts;
+
+   switch (t) {
+   case GPRS_RLCMAC_POLL_UL_ASS:
+   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled UL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ASS:
+   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled DL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_UL_ACK:
+   ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+
+   LOGP(DRLCMACUL, LOGL_DEBUG, "%s Scheduled UL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ACK:
+   LOGP(DRLCMACDL, LOGL_DEBUG, "%s Scheduled DL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   }
 }
 
 void gprs_rlcmac_tbf::poll_timeout()
@@ -1133,11 +1167,7 @@
talloc_free(mac_control_block);
 
if (poll_ass_dl) {
-   set_polling(new_poll_fn, ts);
-   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled DL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS);
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
@@ -1234,11 +1264,7 @@
bitvec_free(ass_vec);
talloc_free(mac_control_block);
 
-   set_polling(new_poll_fn, ts);
-   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled UL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS);
 
return msg;
 }
diff --git a/src/tbf.h b/src/tbf.h
index cd8d694..c13e61f 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -54,6 +54,13 @@
GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 };
 
+enum gprs_rlcmac_tbf_poll_type {
+   GPRS_RLCMAC_POLL_UL_ASS,
+   

[PATCH] osmo-pcu[master]: Simplify polling troubleshooting

2017-07-10 Thread Max
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2859

to look at the new patch set (#6).

Simplify polling troubleshooting

* introduce enum describing poll kind and use it in set_polling()
* move state change into set_polling()
* move logging into set_polling() and unify output
* move duplicated code into static function
* adjust tests to match unified logging output

Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Related: OS#1524
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.err
6 files changed, 88 insertions(+), 91 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/59/2859/6

diff --git a/src/bts.cpp b/src/bts.cpp
index 5f7d9e8..302daf9 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1360,7 +1360,9 @@
}
 
/* set control ts to current MS's TS, until assignment complete 
*/
-   LOGP(DRLCMAC, LOGL_DEBUG, "Change control TS to %d until 
assinment is complete.\n", ts_no);
+   LOGP(DRLCMAC, LOGL_DEBUG, "%s change control TS %d -> %d until 
assinment is complete.\n",
+tbf_name(ul_tbf), ul_tbf->control_ts, ts_no);
+
ul_tbf->control_ts = ts_no;
/* schedule uplink assignment */
ul_tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index b2acb11..4871076 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -593,16 +593,50 @@
return 0;
 }
 
-void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts)
+void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t)
 {
-   LOGP(DRLCMAC, LOGL_DEBUG,
-   "%s: Scheduling polling at FN %d TS %d\n",
-   name(), new_poll_fn, ts);
+   const char *chan = "UNKNOWN";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_CCCH)))
+   chan = "CCCH";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH)))
+   chan = "PACCH";
+
+   if ((state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH))) && (state_flags & 
(1 << (GPRS_RLCMAC_FLAG_CCCH
+   LOGP(DRLCMACDL, LOGL_ERROR,
+"%s Attempt to schedule polling on %s (FN=%d, TS=%d) with 
both CCCH and PACCH flags set - FIXME!\n",
+name(), chan, poll_fn, poll_ts);
 
/* schedule polling */
poll_state = GPRS_RLCMAC_POLL_SCHED;
poll_fn = new_poll_fn;
poll_ts = ts;
+
+   switch (t) {
+   case GPRS_RLCMAC_POLL_UL_ASS:
+   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled UL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ASS:
+   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled DL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_UL_ACK:
+   ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+
+   LOGP(DRLCMACUL, LOGL_DEBUG, "%s Scheduled UL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ACK:
+   LOGP(DRLCMACDL, LOGL_DEBUG, "%s Scheduled DL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   }
 }
 
 void gprs_rlcmac_tbf::poll_timeout()
@@ -1133,11 +1167,7 @@
talloc_free(mac_control_block);
 
if (poll_ass_dl) {
-   set_polling(new_poll_fn, ts);
-   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled DL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS);
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
@@ -1234,11 +1264,7 @@
bitvec_free(ass_vec);
talloc_free(mac_control_block);
 
-   set_polling(new_poll_fn, ts);
-   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled UL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS);
 
return msg;
 }
diff --git a/src/tbf.h b/src/tbf.h
index cd8d694..c13e61f 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -54,6 +54,13 @@
GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 };
 
+enum gprs_rlcmac_tbf_poll_type {
+   GPRS_RLCMAC_POLL_UL_ASS,
+   

[PATCH] osmo-pcu[master]: Simplify polling troubleshooting

2017-07-10 Thread Max
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2859

to look at the new patch set (#5).

Simplify polling troubleshooting

* introduce enum describing poll kind and use it in set_polling()
* move state change into set_polling()
* move logging into set_polling() and unify output
* move duplicated code into static function
* adjust tests to match unified logging output

Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Related: OS#1524
---
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.err
5 files changed, 85 insertions(+), 90 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/59/2859/5

diff --git a/src/tbf.cpp b/src/tbf.cpp
index b2acb11..4871076 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -593,16 +593,50 @@
return 0;
 }
 
-void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts)
+void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t)
 {
-   LOGP(DRLCMAC, LOGL_DEBUG,
-   "%s: Scheduling polling at FN %d TS %d\n",
-   name(), new_poll_fn, ts);
+   const char *chan = "UNKNOWN";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_CCCH)))
+   chan = "CCCH";
+
+   if (state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH)))
+   chan = "PACCH";
+
+   if ((state_flags & (1 << (GPRS_RLCMAC_FLAG_PACCH))) && (state_flags & 
(1 << (GPRS_RLCMAC_FLAG_CCCH
+   LOGP(DRLCMACDL, LOGL_ERROR,
+"%s Attempt to schedule polling on %s (FN=%d, TS=%d) with 
both CCCH and PACCH flags set - FIXME!\n",
+name(), chan, poll_fn, poll_ts);
 
/* schedule polling */
poll_state = GPRS_RLCMAC_POLL_SCHED;
poll_fn = new_poll_fn;
poll_ts = ts;
+
+   switch (t) {
+   case GPRS_RLCMAC_POLL_UL_ASS:
+   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled UL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ASS:
+   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled DL Assignment polling 
on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_UL_ACK:
+   ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+
+   LOGP(DRLCMACUL, LOGL_DEBUG, "%s Scheduled UL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ACK:
+   LOGP(DRLCMACDL, LOGL_DEBUG, "%s Scheduled DL Acknowledgement 
polling on %s (FN=%d, TS=%d)\n",
+name(), chan, poll_fn, poll_ts);
+   break;
+   }
 }
 
 void gprs_rlcmac_tbf::poll_timeout()
@@ -1133,11 +1167,7 @@
talloc_free(mac_control_block);
 
if (poll_ass_dl) {
-   set_polling(new_poll_fn, ts);
-   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled DL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS);
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
@@ -1234,11 +1264,7 @@
bitvec_free(ass_vec);
talloc_free(mac_control_block);
 
-   set_polling(new_poll_fn, ts);
-   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled UL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS);
 
return msg;
 }
diff --git a/src/tbf.h b/src/tbf.h
index cd8d694..c13e61f 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -54,6 +54,13 @@
GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 };
 
+enum gprs_rlcmac_tbf_poll_type {
+   GPRS_RLCMAC_POLL_UL_ASS,
+   GPRS_RLCMAC_POLL_DL_ASS,
+   GPRS_RLCMAC_POLL_UL_ACK,
+   GPRS_RLCMAC_POLL_DL_ACK,
+};
+
 enum gprs_rlcmac_tbf_poll_state {
GPRS_RLCMAC_POLL_NONE = 0,
GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
@@ -173,7 +180,7 @@
 
int check_polling(uint32_t fn, uint8_t ts,
uint32_t *poll_fn, unsigned int *rrbp);
-   void set_polling(uint32_t poll_fn, uint8_t ts);
+   void set_polling(uint32_t poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t);
void poll_timeout();
 
/** tlli handling */
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 375d642..6aa17bb 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -855,10 +855,8 @@

osmo-pcu[master]: Simplify polling troubleshooting

2017-06-28 Thread Harald Welte

Patch Set 4: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2859
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Gerrit-PatchSet: 4
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: Simplify polling troubleshooting

2017-06-08 Thread Max

Review at  https://gerrit.osmocom.org/2859

Simplify polling troubleshooting

* introduce enum describing poll kind and use it in set_polling()
* move state change and logging into set_polling()

Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d
Related: OS#1524
---
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
4 files changed, 38 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/59/2859/1

diff --git a/src/tbf.cpp b/src/tbf.cpp
index 48e8289..8864198 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -593,16 +593,37 @@
return 0;
 }
 
-void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts)
+void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t)
 {
-   LOGP(DRLCMAC, LOGL_DEBUG,
-   "%s: Scheduling polling at FN %d TS %d\n",
-   name(), new_poll_fn, ts);
-
/* schedule polling */
poll_state = GPRS_RLCMAC_POLL_SCHED;
poll_fn = new_poll_fn;
poll_ts = ts;
+
+   switch (t) {
+   case GPRS_RLCMAC_POLL_UL_ASS:
+   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled UL Assignment polling 
on FN=%d, TS=%d\n",
+name(), poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ASS:
+   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+
+   LOGP(DRLCMACDL, LOGL_INFO, "%s Scheduled DL Assignment polling 
on FN=%d, TS=%d\n",
+name(), poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_UL_ACK:
+   ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+
+   LOGP(DRLCMACUL, LOGL_DEBUG, "%s Scheduled UL Acknowledgement 
polling on FN=%d, TS=%d\n",
+name(), poll_fn, poll_ts);
+   break;
+   case GPRS_RLCMAC_POLL_DL_ACK:
+   LOGP(DRLCMACDL, LOGL_DEBUG, "%s Scheduled DL Acknowledgement 
polling on FN=%d, TS=%d\n",
+name(), poll_fn, poll_ts);
+   break;
+   }
 }
 
 void gprs_rlcmac_tbf::poll_timeout()
@@ -1135,11 +1156,7 @@
talloc_free(mac_control_block);
 
if (poll_ass_dl) {
-   set_polling(new_poll_fn, ts);
-   dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled DL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ASS);
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
@@ -1236,11 +1253,7 @@
bitvec_free(ass_vec);
talloc_free(mac_control_block);
 
-   set_polling(new_poll_fn, ts);
-   ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-   LOGP(DRLCMACDL, LOGL_INFO,
-   "%s Scheduled UL Assignment polling on FN=%d, TS=%d\n",
-   name(), poll_fn, poll_ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ASS);
 
return msg;
 }
diff --git a/src/tbf.h b/src/tbf.h
index 09e3122..5621ebe 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -54,6 +54,13 @@
GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 };
 
+enum gprs_rlcmac_tbf_poll_type {
+   GPRS_RLCMAC_POLL_UL_ASS,
+   GPRS_RLCMAC_POLL_DL_ASS,
+   GPRS_RLCMAC_POLL_UL_ACK,
+   GPRS_RLCMAC_POLL_DL_ACK,
+};
+
 enum gprs_rlcmac_tbf_poll_state {
GPRS_RLCMAC_POLL_NONE = 0,
GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
@@ -173,7 +180,7 @@
 
int check_polling(uint32_t fn, uint8_t ts,
uint32_t *poll_fn, unsigned int *rrbp);
-   void set_polling(uint32_t poll_fn, uint8_t ts);
+   void set_polling(uint32_t poll_fn, uint8_t ts, enum 
gprs_rlcmac_tbf_poll_type t);
void poll_timeout();
 
/** tlli handling */
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 24c6385..d904ca5 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -798,10 +798,8 @@
 
rc = check_polling(fn, ts, _poll_fn, );
if (rc >= 0) {
-   set_polling(new_poll_fn, ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_DL_ACK);
 
-   LOGP(DRLCMACDL, LOGL_DEBUG, "Polling scheduled in this "
-   "TS %d\n", ts);
m_tx_counter = 0;
/* start timer whenever we send the final block */
if (is_final)
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 1eee41a..4801753 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -137,9 +137,8 @@
m_contention_resolution_done = 1;
 
if (final) {
-   set_polling(new_poll_fn, ts);
+   set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ACK);
/* waiting for final