summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-01-29 16:29:19 +0100
committerThomas Haller <thaller@redhat.com>2022-01-29 16:29:19 +0100
commit34dd9d1f1cbf84a1f186a5e27ca927eb5de62660 (patch)
treef8fbf1af571d91a2b2e0d5e8a6fd0c284a512008
parentead18781ad60cd58a5c9b62abd4b9b36ef5f6ce9 (diff)
parent068f8dc49651cd7cb82215538f27ded8e41c0463 (diff)
wwan: merge branch 'th/wwan-5gnr-capability'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1076
-rw-r--r--src/core/devices/wwan/nm-device-modem.c4
-rw-r--r--src/core/devices/wwan/nm-modem-broadband.c42
-rw-r--r--src/libnm-client-impl/nm-device-modem.c12
-rw-r--r--src/libnm-core-public/nm-dbus-interface.h4
4 files changed, 30 insertions, 32 deletions
diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c
index 4a0d9e4435..ef802a44f2 100644
--- a/src/core/devices/wwan/nm-device-modem.c
+++ b/src/core/devices/wwan/nm-device-modem.c
@@ -762,9 +762,9 @@ nm_device_modem_new(NMModem *modem)
NM_DEVICE_MODEM_MODEM,
modem,
NM_DEVICE_MODEM_CAPABILITIES,
- caps,
+ (guint) ((guint32) caps),
NM_DEVICE_MODEM_CURRENT_CAPABILITIES,
- current_caps,
+ (guint) ((guint32) current_caps),
NM_DEVICE_MODEM_DEVICE_ID,
nm_modem_get_device_id(modem),
NULL);
diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c
index 319d77a9b8..c1d8b1ee0d 100644
--- a/src/core/devices/wwan/nm-modem-broadband.c
+++ b/src/core/devices/wwan/nm-modem-broadband.c
@@ -20,24 +20,12 @@
#define NM_MODEM_BROADBAND_MODEM "modem"
-static gboolean
-MODEM_CAPS_3GPP(MMModemCapability caps)
-{
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* MM_MODEM_CAPABILITY_LTE_ADVANCED is marked as deprecated since ModemManager 1.14.0.
- *
- * The flag probably was never used, it certainly isn't used since 1.14.0.
- *
- * Still, just to be sure, there is no harm in checking it here. Suppress the
- * warning, it should have no bad effect.
- */
- return NM_FLAGS_ANY(caps,
- (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_LTE
- | MM_MODEM_CAPABILITY_LTE_ADVANCED));
- G_GNUC_END_IGNORE_DEPRECATIONS
-}
+#define MODEM_CAPS_3GPP(caps) \
+ NM_FLAGS_ANY( \
+ caps, \
+ (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_LTE | MM_MODEM_CAPABILITY_5GNR))
-#define MODEM_CAPS_3GPP2(caps) (caps & (MM_MODEM_CAPABILITY_CDMA_EVDO))
+#define MODEM_CAPS_3GPP2(caps) NM_FLAGS_ANY((caps), MM_MODEM_CAPABILITY_CDMA_EVDO)
/* Maximum time to keep the DBus call waiting for a connection result.
* This value is greater than the default timeout in ModemManager (180s since
@@ -199,20 +187,24 @@ get_capabilities(NMModem *_self,
NMDeviceModemCapabilities *modem_caps,
NMDeviceModemCapabilities *current_caps)
{
- NMModemBroadband *self = NM_MODEM_BROADBAND(_self);
- MMModemCapability all_supported = MM_MODEM_CAPABILITY_NONE;
- MMModemCapability *supported;
- guint n_supported;
+ NMModemBroadband *self = NM_MODEM_BROADBAND(_self);
+ MMModemCapability all_supported = MM_MODEM_CAPABILITY_NONE;
+ gs_free MMModemCapability *supported = NULL;
+ guint n_supported;
+ guint i;
+
+ G_STATIC_ASSERT(MM_MODEM_CAPABILITY_POTS == (guint64) NM_DEVICE_MODEM_CAPABILITY_POTS);
+ G_STATIC_ASSERT(MM_MODEM_CAPABILITY_CDMA_EVDO
+ == (guint64) NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO);
+ G_STATIC_ASSERT(MM_MODEM_CAPABILITY_GSM_UMTS == (guint64) NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS);
+ G_STATIC_ASSERT(MM_MODEM_CAPABILITY_LTE == (guint64) NM_DEVICE_MODEM_CAPABILITY_LTE);
+ G_STATIC_ASSERT(MM_MODEM_CAPABILITY_5GNR == (guint64) NM_DEVICE_MODEM_CAPABILITY_5GNR);
/* For now, we don't care about the capability combinations, just merge all
* combinations in a single mask */
if (mm_modem_get_supported_capabilities(self->_priv.modem_iface, &supported, &n_supported)) {
- guint i;
-
for (i = 0; i < n_supported; i++)
all_supported |= supported[i];
-
- g_free(supported);
}
*modem_caps = (NMDeviceModemCapabilities) all_supported;
diff --git a/src/libnm-client-impl/nm-device-modem.c b/src/libnm-client-impl/nm-device-modem.c
index 73b38d3e0a..a1edfb049e 100644
--- a/src/libnm-client-impl/nm-device-modem.c
+++ b/src/libnm-client-impl/nm-device-modem.c
@@ -153,10 +153,12 @@ get_type_description(NMDevice *device)
return NULL;
}
-#define MODEM_CAPS_3GPP(caps) \
- (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE))
+#define MODEM_CAPS_3GPP(caps) \
+ NM_FLAGS_ANY((caps), \
+ (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE \
+ | NM_DEVICE_MODEM_CAPABILITY_5GNR))
-#define MODEM_CAPS_3GPP2(caps) (caps & (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))
+#define MODEM_CAPS_3GPP2(caps) NM_FLAGS_ANY((caps), NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
static gboolean
connection_compatible(NMDevice *device, NMConnection *connection, GError **error)
@@ -206,9 +208,9 @@ get_setting_type(NMDevice *device)
NMDeviceModemCapabilities caps;
caps = nm_device_modem_get_current_capabilities(NM_DEVICE_MODEM(device));
- if (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE))
+ if (MODEM_CAPS_3GPP(caps))
return NM_TYPE_SETTING_GSM;
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
+ else if (MODEM_CAPS_3GPP2(caps))
return NM_TYPE_SETTING_CDMA;
else
return G_TYPE_INVALID;
diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h
index 7fd228ca46..fe2a6c09db 100644
--- a/src/libnm-core-public/nm-dbus-interface.h
+++ b/src/libnm-core-public/nm-dbus-interface.h
@@ -428,6 +428,7 @@ typedef enum { /*< flags >*/
* @NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: modem supports at least one of GSM,
* GPRS, EDGE, UMTS, HSDPA, HSUPA, or HSPA+ packet switched data capability
* @NM_DEVICE_MODEM_CAPABILITY_LTE: modem has LTE data capability
+ * @NM_DEVICE_MODEM_CAPABILITY_5GNR: modem has 5GNR data capability (Since: 1.36)
*
* #NMDeviceModemCapabilities values indicate the generic radio access
* technology families a modem device supports. For more information on the
@@ -440,7 +441,10 @@ typedef enum { /*< flags >*/
NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002,
NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004,
NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008,
+ NM_DEVICE_MODEM_CAPABILITY_5GNR = 0x00000040,
} NMDeviceModemCapabilities;
+/* Note: the numeric values of NMDeviceModemCapabilities must be identical to the values
+ * in MMModemCapability. See the G_STATIC_ASSERT() in nm-modem-broadband.c's get_capabilities(). */
/**
* NMWimaxNspNetworkType: