summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-09-09 13:27:21 +0200
committerPatrick McHardy <kaber@trash.net>2010-09-09 13:27:21 +0200
commit9b209567739e5272649f7159666314b6efbe4ca3 (patch)
tree3abc3d9e4cbcd99db8023030f31718bbf1c37acd
parent5d36c7a302f821ccd797f8639d1bdafef664c9be (diff)
cc: periodically dump LU1 queue statistics
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/cc.h4
-rw-r--r--src/cc.c50
2 files changed, 53 insertions, 1 deletions
diff --git a/include/cc.h b/include/cc.h
index b9142c0..c5a6e34 100644
--- a/include/cc.h
+++ b/include/cc.h
@@ -332,10 +332,14 @@ struct dect_call {
enum dect_cc_states state;
struct dect_timer *setup_timer;
struct dect_fd *lu_sap;
+#ifdef DEBUG
+ struct dect_timer *qstats_timer;
+#endif
uint8_t priv[] __aligned(__alignof__(uint64_t));
};
#define DECT_CC_SETUP_TIMEOUT 20 /* seconds */
+#define DECT_CC_QUEUE_STATS_TIMER 1 /* seconds */
extern const struct dect_nwk_protocol dect_cc_protocol;
diff --git a/src/cc.c b/src/cc.c
index 2bcf4af..732bba3 100644
--- a/src/cc.c
+++ b/src/cc.c
@@ -407,7 +407,7 @@ static void dect_cc_lu_event(struct dect_handle *dh, struct dect_fd *fd,
if (mb == NULL)
return;
- len = recv(call->lu_sap->fd, mb->data, sizeof(mb->head), 0);
+ len = recv(call->lu_sap->fd, mb->data, 40, 0);
if (len < 0)
return;
mb->len = len;
@@ -416,6 +416,35 @@ static void dect_cc_lu_event(struct dect_handle *dh, struct dect_fd *fd,
dh->ops->cc_ops->dl_u_data_ind(dh, call, mb);
}
+static void dect_cc_get_queue_stats(const struct dect_call *call)
+{
+ struct dect_lu1_queue_stats qstats;
+ socklen_t optlen;
+
+ optlen = sizeof(qstats);
+ if (getsockopt(call->lu_sap->fd, SOL_DECT, DECT_LU1_QUEUE_STATS,
+ &qstats, &optlen) < 0) {
+ cc_debug(call, "Failed to get queue statistics: %s", strerror(errno));
+ return;
+ }
+
+ cc_debug(call, "LU1 Queue-Statistic:");
+ cc_debug(call, " RX-Bytes: %u", qstats.rx_bytes);
+ cc_debug(call, " RX-Underflow: %u", qstats.rx_underflow);
+ cc_debug(call, " TX-Bytes: %u", qstats.tx_bytes);
+ cc_debug(call, " TX-Underflow: %u", qstats.tx_underflow);
+}
+
+#ifdef DEBUG
+static void dect_cc_qstats_timer(struct dect_handle *dh, struct dect_timer *timer)
+{
+ struct dect_call *call = timer->data;
+
+ dect_cc_get_queue_stats(call);
+ dect_timer_start(dh, call->qstats_timer, DECT_CC_QUEUE_STATS_TIMER);
+}
+#endif
+
static int dect_call_connect_uplane(const struct dect_handle *dh,
struct dect_call *call)
{
@@ -432,9 +461,21 @@ static int dect_call_connect_uplane(const struct dect_handle *dh,
dect_fd_setup(call->lu_sap, dect_cc_lu_event, call);
if (dect_fd_register(dh, call->lu_sap, DECT_FD_READ) < 0)
goto err2;
+
+#ifdef DEBUG
+ call->qstats_timer = dect_timer_alloc(dh);
+ if (call->qstats_timer == NULL)
+ goto err3;
+ dect_timer_setup(call->qstats_timer, dect_cc_qstats_timer, call);
+ dect_timer_start(dh, call->qstats_timer, DECT_CC_QUEUE_STATS_TIMER);
+#endif
cc_debug(call, "U-Plane connected");
return 0;
+#ifdef DEBUG
+err3:
+ dect_fd_unregister(dh, call->lu_sap);
+#endif
err2:
dect_close(dh, call->lu_sap);
call->lu_sap = NULL;
@@ -448,10 +489,17 @@ static void dect_call_disconnect_uplane(const struct dect_handle *dh,
{
if (call->lu_sap == NULL)
return;
+#ifdef DEBUG
+ dect_timer_stop(dh, call->qstats_timer);
+ dect_free(dh, call->qstats_timer);
+ call->qstats_timer = NULL;
+#endif
+ dect_cc_get_queue_stats(call);
dect_fd_unregister(dh, call->lu_sap);
dect_close(dh, call->lu_sap);
call->lu_sap = NULL;
+
cc_debug(call, "U-Plane disconnected");
}