api,bearer: add 'uplink-speed' and 'downlink-speed' stats
These values show the rates that have been negotiated with the network during the PS domain attach. These are not the current ongoing data rates associated to the network usage at some given moment. Includes updates by Aleksander Morgado to fix coding style issues and add missing documentation items.
This commit is contained in:

committed by
Aleksander Morgado

parent
d71a0bcf8e
commit
511859ef0a
@@ -279,6 +279,8 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
gchar *total_duration = NULL;
|
gchar *total_duration = NULL;
|
||||||
gchar *total_bytes_rx = NULL;
|
gchar *total_bytes_rx = NULL;
|
||||||
gchar *total_bytes_tx = NULL;
|
gchar *total_bytes_tx = NULL;
|
||||||
|
gchar *uplink_speed = NULL;
|
||||||
|
gchar *downlink_speed = NULL;
|
||||||
|
|
||||||
if (stats) {
|
if (stats) {
|
||||||
guint64 val;
|
guint64 val;
|
||||||
@@ -309,6 +311,12 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
val = mm_bearer_stats_get_total_tx_bytes (stats);
|
val = mm_bearer_stats_get_total_tx_bytes (stats);
|
||||||
if (val)
|
if (val)
|
||||||
total_bytes_tx = g_strdup_printf ("%" G_GUINT64_FORMAT, val);
|
total_bytes_tx = g_strdup_printf ("%" G_GUINT64_FORMAT, val);
|
||||||
|
val = mm_bearer_stats_get_uplink_speed (stats);
|
||||||
|
if (val)
|
||||||
|
uplink_speed = g_strdup_printf ("%" G_GUINT64_FORMAT, val);
|
||||||
|
val = mm_bearer_stats_get_downlink_speed (stats);
|
||||||
|
if (val)
|
||||||
|
downlink_speed = g_strdup_printf ("%" G_GUINT64_FORMAT, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_date)
|
if (start_date)
|
||||||
@@ -321,6 +329,8 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_DURATION, total_duration);
|
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_DURATION, total_duration);
|
||||||
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_BYTES_RX, total_bytes_rx);
|
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_BYTES_RX, total_bytes_rx);
|
||||||
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_BYTES_TX, total_bytes_tx);
|
mmcli_output_string_take (MMC_F_BEARER_STATS_TOTAL_BYTES_TX, total_bytes_tx);
|
||||||
|
mmcli_output_string_take (MMC_F_BEARER_STATS_UPLINK_SPEED, uplink_speed);
|
||||||
|
mmcli_output_string_take (MMC_F_BEARER_STATS_DOWNLINK_SPEED, downlink_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
mmcli_output_dump ();
|
mmcli_output_dump ();
|
||||||
|
@@ -251,6 +251,8 @@ static FieldInfo field_infos[] = {
|
|||||||
[MMC_F_BEARER_IPV6_CONFIG_MTU] = { "bearer.ipv6-config.mtu", "mtu", MMC_S_BEARER_IPV6_CONFIG, },
|
[MMC_F_BEARER_IPV6_CONFIG_MTU] = { "bearer.ipv6-config.mtu", "mtu", MMC_S_BEARER_IPV6_CONFIG, },
|
||||||
[MMC_F_BEARER_STATS_START_DATE] = { "bearer.stats.start-date", "start date", MMC_S_BEARER_STATS, },
|
[MMC_F_BEARER_STATS_START_DATE] = { "bearer.stats.start-date", "start date", MMC_S_BEARER_STATS, },
|
||||||
[MMC_F_BEARER_STATS_DURATION] = { "bearer.stats.duration", "duration", MMC_S_BEARER_STATS, },
|
[MMC_F_BEARER_STATS_DURATION] = { "bearer.stats.duration", "duration", MMC_S_BEARER_STATS, },
|
||||||
|
[MMC_F_BEARER_STATS_UPLINK_SPEED] = { "bearer.stats.uplink-speed", "uplink-speed", MMC_S_BEARER_STATS, },
|
||||||
|
[MMC_F_BEARER_STATS_DOWNLINK_SPEED] = { "bearer.stats.downlink-speed", "downlink-speed", MMC_S_BEARER_STATS, },
|
||||||
[MMC_F_BEARER_STATS_BYTES_RX] = { "bearer.stats.bytes-rx", "bytes rx", MMC_S_BEARER_STATS, },
|
[MMC_F_BEARER_STATS_BYTES_RX] = { "bearer.stats.bytes-rx", "bytes rx", MMC_S_BEARER_STATS, },
|
||||||
[MMC_F_BEARER_STATS_BYTES_TX] = { "bearer.stats.bytes-tx", "bytes tx", MMC_S_BEARER_STATS, },
|
[MMC_F_BEARER_STATS_BYTES_TX] = { "bearer.stats.bytes-tx", "bytes tx", MMC_S_BEARER_STATS, },
|
||||||
[MMC_F_BEARER_STATS_ATTEMPTS] = { "bearer.stats.attempts", "attempts", MMC_S_BEARER_STATS, },
|
[MMC_F_BEARER_STATS_ATTEMPTS] = { "bearer.stats.attempts", "attempts", MMC_S_BEARER_STATS, },
|
||||||
|
@@ -269,6 +269,8 @@ typedef enum {
|
|||||||
MMC_F_BEARER_IPV6_CONFIG_MTU,
|
MMC_F_BEARER_IPV6_CONFIG_MTU,
|
||||||
MMC_F_BEARER_STATS_START_DATE,
|
MMC_F_BEARER_STATS_START_DATE,
|
||||||
MMC_F_BEARER_STATS_DURATION,
|
MMC_F_BEARER_STATS_DURATION,
|
||||||
|
MMC_F_BEARER_STATS_UPLINK_SPEED,
|
||||||
|
MMC_F_BEARER_STATS_DOWNLINK_SPEED,
|
||||||
MMC_F_BEARER_STATS_BYTES_RX,
|
MMC_F_BEARER_STATS_BYTES_RX,
|
||||||
MMC_F_BEARER_STATS_BYTES_TX,
|
MMC_F_BEARER_STATS_BYTES_TX,
|
||||||
MMC_F_BEARER_STATS_ATTEMPTS,
|
MMC_F_BEARER_STATS_ATTEMPTS,
|
||||||
|
@@ -1231,6 +1231,8 @@ mm_bearer_stats_get_failed_attempts
|
|||||||
mm_bearer_stats_get_total_duration
|
mm_bearer_stats_get_total_duration
|
||||||
mm_bearer_stats_get_total_rx_bytes
|
mm_bearer_stats_get_total_rx_bytes
|
||||||
mm_bearer_stats_get_total_tx_bytes
|
mm_bearer_stats_get_total_tx_bytes
|
||||||
|
mm_bearer_stats_get_uplink_speed
|
||||||
|
mm_bearer_stats_get_downlink_speed
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
mm_bearer_stats_get_dictionary
|
mm_bearer_stats_get_dictionary
|
||||||
mm_bearer_stats_new
|
mm_bearer_stats_new
|
||||||
@@ -1243,6 +1245,8 @@ mm_bearer_stats_set_failed_attempts
|
|||||||
mm_bearer_stats_set_total_duration
|
mm_bearer_stats_set_total_duration
|
||||||
mm_bearer_stats_set_total_rx_bytes
|
mm_bearer_stats_set_total_rx_bytes
|
||||||
mm_bearer_stats_set_total_tx_bytes
|
mm_bearer_stats_set_total_tx_bytes
|
||||||
|
mm_bearer_stats_set_uplink_speed
|
||||||
|
mm_bearer_stats_set_downlink_speed
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
MMBearerStatsClass
|
MMBearerStatsClass
|
||||||
MMBearerStatsPrivate
|
MMBearerStatsPrivate
|
||||||
|
@@ -358,6 +358,20 @@
|
|||||||
<literal>"u"</literal>). Since 1.14.
|
<literal>"u"</literal>). Since 1.14.
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry><term><literal>"uplink-speed"</literal></term>
|
||||||
|
<listitem>
|
||||||
|
Uplink bit rate negotiated with network, in bits per second, given
|
||||||
|
as an unsigned 64-bit integer value (signature <literal>"t"</literal>).
|
||||||
|
Since 1.20.
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry><term><literal>"downlink-speed"</literal></term>
|
||||||
|
<listitem>
|
||||||
|
Downlink bit rate negotiated with network, in bits per second, given
|
||||||
|
as an unsigned 64-bit integer value (signature <literal>"t"</literal>).
|
||||||
|
Since 1.20.
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
Since: 1.6
|
Since: 1.6
|
||||||
|
@@ -10,8 +10,9 @@
|
|||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details:
|
* GNU General Public License for more details:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Azimut Electronics
|
* Copyright (C) 2015-2021 Azimut Electronics
|
||||||
* Copyright (C) 2015-2020 Aleksander Morgado <aleksander@aleksander.es>
|
* Copyright (C) 2015-2021 Aleksander Morgado <aleksander@aleksander.es>
|
||||||
|
* Copyright (C) 2021 Intel Corporation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -42,6 +43,8 @@ G_DEFINE_TYPE (MMBearerStats, mm_bearer_stats, G_TYPE_OBJECT)
|
|||||||
#define PROPERTY_TOTAL_DURATION "total-duration"
|
#define PROPERTY_TOTAL_DURATION "total-duration"
|
||||||
#define PROPERTY_TOTAL_RX_BYTES "total-rx-bytes"
|
#define PROPERTY_TOTAL_RX_BYTES "total-rx-bytes"
|
||||||
#define PROPERTY_TOTAL_TX_BYTES "total-tx-bytes"
|
#define PROPERTY_TOTAL_TX_BYTES "total-tx-bytes"
|
||||||
|
#define PROPERTY_UPLINK_SPEED "uplink-speed"
|
||||||
|
#define PROPERTY_DOWNLINK_SPEED "downlink-speed"
|
||||||
|
|
||||||
struct _MMBearerStatsPrivate {
|
struct _MMBearerStatsPrivate {
|
||||||
guint duration;
|
guint duration;
|
||||||
@@ -53,6 +56,8 @@ struct _MMBearerStatsPrivate {
|
|||||||
guint total_duration;
|
guint total_duration;
|
||||||
guint64 total_rx_bytes;
|
guint64 total_rx_bytes;
|
||||||
guint64 total_tx_bytes;
|
guint64 total_tx_bytes;
|
||||||
|
guint64 uplink_speed;
|
||||||
|
guint64 downlink_speed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -348,6 +353,70 @@ mm_bearer_stats_set_total_tx_bytes (MMBearerStats *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_bearer_stats_get_uplink_speed:
|
||||||
|
* @self: a #MMBearerStats.
|
||||||
|
*
|
||||||
|
* Gets the speed of the uplink, in bits per second.
|
||||||
|
*
|
||||||
|
* Returns: a #guint64.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
guint64
|
||||||
|
mm_bearer_stats_get_uplink_speed (MMBearerStats *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_BEARER_STATS (self), 0);
|
||||||
|
|
||||||
|
return self->priv->uplink_speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_bearer_stats_set_uplink_speed: (skip)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mm_bearer_stats_set_uplink_speed (MMBearerStats *self,
|
||||||
|
guint64 speed)
|
||||||
|
{
|
||||||
|
g_return_if_fail (MM_IS_BEARER_STATS (self));
|
||||||
|
|
||||||
|
self->priv->uplink_speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_bearer_stats_get_downlink_speed:
|
||||||
|
* @self: a #MMBearerStats.
|
||||||
|
*
|
||||||
|
* Gets the speed of the downlink, in bits per second.
|
||||||
|
*
|
||||||
|
* Returns: a #guint64.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
guint64
|
||||||
|
mm_bearer_stats_get_downlink_speed (MMBearerStats *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_BEARER_STATS (self), 0);
|
||||||
|
|
||||||
|
return self->priv->downlink_speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_bearer_stats_set_downlink_speed: (skip)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mm_bearer_stats_set_downlink_speed (MMBearerStats *self,
|
||||||
|
guint64 speed)
|
||||||
|
{
|
||||||
|
g_return_if_fail (MM_IS_BEARER_STATS (self));
|
||||||
|
|
||||||
|
self->priv->downlink_speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mm_bearer_stats_get_dictionary: (skip)
|
* mm_bearer_stats_get_dictionary: (skip)
|
||||||
*/
|
*/
|
||||||
@@ -397,6 +466,14 @@ mm_bearer_stats_get_dictionary (MMBearerStats *self)
|
|||||||
"{sv}",
|
"{sv}",
|
||||||
PROPERTY_TOTAL_TX_BYTES,
|
PROPERTY_TOTAL_TX_BYTES,
|
||||||
g_variant_new_uint64 (self->priv->total_tx_bytes));
|
g_variant_new_uint64 (self->priv->total_tx_bytes));
|
||||||
|
g_variant_builder_add (&builder,
|
||||||
|
"{sv}",
|
||||||
|
PROPERTY_UPLINK_SPEED,
|
||||||
|
g_variant_new_uint64 (self->priv->uplink_speed));
|
||||||
|
g_variant_builder_add (&builder,
|
||||||
|
"{sv}",
|
||||||
|
PROPERTY_DOWNLINK_SPEED,
|
||||||
|
g_variant_new_uint64 (self->priv->downlink_speed));
|
||||||
return g_variant_builder_end (&builder);
|
return g_variant_builder_end (&builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,6 +543,14 @@ mm_bearer_stats_new_from_dictionary (GVariant *dictionary,
|
|||||||
mm_bearer_stats_set_total_tx_bytes (
|
mm_bearer_stats_set_total_tx_bytes (
|
||||||
self,
|
self,
|
||||||
g_variant_get_uint64 (value));
|
g_variant_get_uint64 (value));
|
||||||
|
} else if (g_str_equal (key, PROPERTY_UPLINK_SPEED)) {
|
||||||
|
mm_bearer_stats_set_uplink_speed (
|
||||||
|
self,
|
||||||
|
g_variant_get_uint64 (value));
|
||||||
|
} else if (g_str_equal (key, PROPERTY_DOWNLINK_SPEED)) {
|
||||||
|
mm_bearer_stats_set_downlink_speed (
|
||||||
|
self,
|
||||||
|
g_variant_get_uint64 (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
@@ -10,9 +10,9 @@
|
|||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details:
|
* GNU General Public License for more details:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Azimut Electronics
|
* Copyright (C) 2015-2021 Azimut Electronics
|
||||||
*
|
* Copyright (C) 2015-2021 Aleksander Morgado <aleksander@aleksander.es>
|
||||||
* Author: Aleksander Morgado <aleksander@aleksander.es>
|
* Copyright (C) 2021 Intel Corporation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MM_BEARER_STATS_H
|
#ifndef MM_BEARER_STATS_H
|
||||||
@@ -67,6 +67,8 @@ guint mm_bearer_stats_get_failed_attempts (MMBearerStats *self);
|
|||||||
guint mm_bearer_stats_get_total_duration (MMBearerStats *self);
|
guint mm_bearer_stats_get_total_duration (MMBearerStats *self);
|
||||||
guint64 mm_bearer_stats_get_total_rx_bytes (MMBearerStats *self);
|
guint64 mm_bearer_stats_get_total_rx_bytes (MMBearerStats *self);
|
||||||
guint64 mm_bearer_stats_get_total_tx_bytes (MMBearerStats *self);
|
guint64 mm_bearer_stats_get_total_tx_bytes (MMBearerStats *self);
|
||||||
|
guint64 mm_bearer_stats_get_uplink_speed (MMBearerStats *self);
|
||||||
|
guint64 mm_bearer_stats_get_downlink_speed (MMBearerStats *self);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* ModemManager/libmm-glib/mmcli specific methods */
|
/* ModemManager/libmm-glib/mmcli specific methods */
|
||||||
@@ -88,6 +90,8 @@ void mm_bearer_stats_set_failed_attempts (MMBearerStats *self, guint fail
|
|||||||
void mm_bearer_stats_set_total_duration (MMBearerStats *self, guint duration);
|
void mm_bearer_stats_set_total_duration (MMBearerStats *self, guint duration);
|
||||||
void mm_bearer_stats_set_total_rx_bytes (MMBearerStats *self, guint64 rx_bytes);
|
void mm_bearer_stats_set_total_rx_bytes (MMBearerStats *self, guint64 rx_bytes);
|
||||||
void mm_bearer_stats_set_total_tx_bytes (MMBearerStats *self, guint64 tx_bytes);
|
void mm_bearer_stats_set_total_tx_bytes (MMBearerStats *self, guint64 tx_bytes);
|
||||||
|
void mm_bearer_stats_set_uplink_speed (MMBearerStats *self, guint64 speed);
|
||||||
|
void mm_bearer_stats_set_downlink_speed (MMBearerStats *self, guint64 speed);
|
||||||
|
|
||||||
GVariant *mm_bearer_stats_get_dictionary (MMBearerStats *self);
|
GVariant *mm_bearer_stats_get_dictionary (MMBearerStats *self);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user