QMI LTE series
v3 cover QMI LTE series
Changes since v2:
* Revert callback data setup changes; the original model was fine so this amounted mostly to churn and, unfortunately, ended up introducing memory leaks
* Use ofono_gprs_context_deactivated in the detach_shutdown path instead of modifying release_active_contexts()
* Add support for roaming registration state
Original cover letter follows:
LTE is different from other 'GPRS' technologies in that a default bearer always gets set up when the modem registers to the network. Ofono has some support for this and this series tries to set this up for QMI modems.
The key to understanding this series is to understand that QMI modems do not automatically enable the network interface when connecting to an LTE network, even though the default bearer is already set up. A call to "start network" needs to be made in order to allow packets to flow. So the jist of this series is:
i) detect network registration to LTE network ii) call ofono_gprs_cid_activated
iii) in read_settings, start by calling "start network"
...and then there are some other adjustments in the series to make this all work.
I've tested this with my EC21, both on LTE and UMTS networks. It all seems to work, including moving out of network connectivity and bringing the modem repeatedly online/offline.
One open question at this point:
* What happens if the connection manager calls deactivate_context on the default bearer context? I don't see that any other drivers guard against this, and the QMI driver will happily stop the network interface even though the default bearer is still up in the background.
Jonas Bonn (6):
qmi: free cb_data on error
qmi: implement detach_shutdown method
qmi: activate default bearer context for LTE networks
qim: use named status value
qmi: stop listening to packet service notifications
qmi: consolidate ss_info handling functions
drivers/qmimodem/gprs-context.c | 58 ++++++-------- drivers/qmimodem/gprs.c | 135 ++++++++++++++++++++++++-------- drivers/qmimodem/network-registration.c | 53 ++++++------- 3 files changed, 146 insertions(+), 100 deletions(-)
Signature · 1 line
2.9.3
v3 cover QMI LTE series
Changes since v2:
* Revert callback data setup changes; the original model was fine so this amounted mostly to churn and, unfortunately, ended up introducing memory leaks
* Use ofono_gprs_context_deactivated in the detach_shutdown path instead of modifying release_active_contexts()
* Add support for roaming registration state
Original cover letter follows:
LTE is different from other 'GPRS' technologies in that a default bearer always gets set up when the modem registers to the network. Ofono has some support for this and this series tries to set this up for QMI modems.
The key to understanding this series is to understand that QMI modems do not automatically enable the network interface when connecting to an LTE network, even though the default bearer is already set up. A call to "start network" needs to be made in order to allow packets to flow. So the jist of this series is:
i) detect network registration to LTE network ii) call ofono_gprs_cid_activated
iii) in read_settings, start by calling "start network"
...and then there are some other adjustments in the series to make this all work.
I've tested this with my EC21, both on LTE and UMTS networks. It all seems to work, including moving out of network connectivity and bringing the modem repeatedly online/offline.
One open question at this point:
* What happens if the connection manager calls deactivate_context on the default bearer context? I don't see that any other drivers guard against this, and the QMI driver will happily stop the network interface even though the default bearer is still up in the background.
Jonas Bonn (7):
qmi: free cb_data on error
qmi: implement detach_shutdown method
qmi: activate default bearer context for LTE networks
qim: use named status value
qmi: use destroy callback for activate_primary
qmi: stop listening to packet service notifications
qmi: consolidate ss_info handling functions
drivers/qmimodem/gprs-context.c | 69 +++++++--------- drivers/qmimodem/gprs.c | 135 ++++++++++++++++++++++++-------- drivers/qmimodem/network-registration.c | 53 ++++++------- 3 files changed, 151 insertions(+), 106 deletions(-)
Signature · 1 line
2.9.3
PATCH v3 1/6 qmi: free cb_data on error
In reply to Jonas Bonn...and move allocation of structure up to variable declarations to match the pattern used elsewhere in the code.
--- drivers/qmimodem/gprs-context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/qmimodem/gprs-context.c +3 -2
@@ -207,13 +207,12 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, void *user_data) {struct gprs_context_data *data =ofono_gprs_context_get_data (gc); -struct cb_data *cbd; +struct cb_data *cbd =cb_data_new (cb, user_data);DBG ("cid %u" , cid); data->active_context = cid; - cbd =cb_data_new (cb, user_data); cbd->user = gc; if (qmi_service_send(data->wds, QMI_WDS_START_NET, NULL,
@@ -223,6 +222,8 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, data->active_context =0 ;CALLBACK_WITH_FAILURE (cb, cbd->data); + +g_free (cbd); } static void qmi_activate_primary(struct ofono_gprs_context *gc,
Signature · 1 line
2.9.3
Denis Kenzior
AppliedRe: [PATCH qmi lte v3 1/6] qmi: free cb_data on error
Hi Jonas,
Quoted 6 lines · Jonas Bonn
...and move allocation of structure up to variable declarations to match the pattern used elsewhere in the code.
--- drivers/qmimodem/gprs-context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.
Regards,
-Denis
PATCH v3 2/6 qmi: implement detach_shutdown method
In reply to Jonas BonnThe detach_shutdown method is invoked to unconditionally release an active context. For QMI, this is equivalent to a call to deactivate_primary.
This patch makes the callback to deactivate_primary optional and implements detach_shutdown to simply call it. When there is no callback, the stop_net callback notifies ofono about the context release via an asynchronous ofono_gprs_context_deactivated() call.
--- drivers/qmimodem/gprs-context.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/qmimodem/gprs-context.c +19 -4
@@ -309,14 +309,19 @@ static void stop_net_cb(struct qmi_result *result, void *user_data)DBG ("" );if (qmi_result_set_error (result,NULL )) { -CALLBACK_WITH_FAILURE (cb, cbd->data); +if (cb) +CALLBACK_WITH_FAILURE (cb, cbd->data);return ; } - data->active_context =0 ; data->pkt_handle =0 ; -CALLBACK_WITH_SUCCESS (cb, cbd->data); +if (cb) +CALLBACK_WITH_SUCCESS (cb, cbd->data); +else +ofono_gprs_context_deactivated (gc, data->active_context); + + data->active_context =0 ; } static void qmi_deactivate_primary(struct ofono_gprs_context *gc,
@@ -343,11 +348,20 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc,qmi_param_free (param); error: -CALLBACK_WITH_FAILURE (cb, cbd->data); +if (cb) +CALLBACK_WITH_FAILURE (cb, user_data);g_free (cbd); } +static void qmi_gprs_context_detach_shutdown (struct ofono_gprs_context *gc, +unsigned int cid) +{ +DBG ("" ); + +qmi_deactivate_primary (gc, cid,NULL ,NULL ); +} +static void create_wds_cb (struct qmi_service *service,void *user_data) {struct ofono_gprs_context *gc = user_data;
@@ -476,6 +490,7 @@ static struct ofono_gprs_context_driver driver = { .activate_primary = qmi_activate_primary, .deactivate_primary = qmi_deactivate_primary, .read_settings = qmi_gprs_read_settings, + .detach_shutdown = qmi_gprs_context_detach_shutdown, };void qmi_gprs_context_init (void )
Signature · 1 line
2.9.3
Denis Kenzior
AppliedRe: [PATCH qmi lte v3 2/6] qmi: implement detach_shutdown method
Hi Jonas,
Quoted 4 lines · Jonas Bonn
The
detach_shutdownmethod is invoked to unconditionally release an active context. For QMI, this is equivalent to a call todeactivate_primary.
Quoted 8 lines
This patch makes the callback to
deactivate_primaryoptional and implementsdetach_shutdownto simply call it. When there is no callback, thestop_netcallback notifies ofono about the context release via an asynchronousofono_gprs_context_deactivated()call.--- drivers/qmimodem/gprs-context.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
Applied, thanks.
Regards,
-Denis
PATCH v3 3/6 qmi: activate default bearer context for LTE networks
In reply to Jonas BonnWhen the modem attaches to an LTE network, a default bearer is automatically negotiated using the "defalt profile" settings. The QMI modem, however, does not given any explicit indication that the bearer exists; instead, we must assume its existence based on the network registration state.
This patch extends the GPRS atom to signal the presence of a default bearer when it detects network connectivity on an LTE network.
The GPRS atom gets a new 'attached' property based on whether it has been manually attached or automatically "attached" by virtue of connecting to an LTE network. Here we abuse the word "attach" since attach'ing isn't really an LTE concept, but it fits with the model that Ofono wants.
--- drivers/qmimodem/gprs.c | 135 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 34 deletions(-)
drivers/qmimodem/gprs.c +101 -34
@@ -23,6 +23,8 @@#include <config.h> #endif +#include <glib.h> /* this include belongs in common.h */ +#include <ofono/log.h> #include <ofono/modem.h> #include <ofono/gprs.h>
@@ -30,16 +32,34 @@#include "qmi.h" #include "nas.h" +#include "src/common.h" #include "qmimodem.h" struct gprs_data {struct qmi_service *nas; +int attached; }; -static bool extract_ss_info (struct qmi_result *result,int *status) +static int rat_to_tech (uint8_t rat) +{ +switch (rat) { +case QMI_NAS_NETWORK_RAT_GSM : +return ACCESS_TECHNOLOGY_GSM ; +case QMI_NAS_NETWORK_RAT_UMTS : +return ACCESS_TECHNOLOGY_UTRAN ; +case QMI_NAS_NETWORK_RAT_LTE : +return ACCESS_TECHNOLOGY_EUTRAN ; + } + +return -1 ; +} + +static bool extract_ss_info (struct qmi_result *result,int *status,int *tech) {const struct qmi_nas_serving_system *ss; +uint8_t roaming;uint16_t len; +int i;DBG ("" );
@@ -47,25 +67,80 @@ static bool extract_ss_info(struct qmi_result *result, int *status)if (!ss)return false; -if (ss->ps_state ==QMI_NAS_ATTACH_STATE_ATTACHED ) - *status =0x01 ; -else - *status =0x00 ; + *status = ss->status; + + *tech =-1 ; +for (i =0 ; i < ss->radio_if_count; i++) { +DBG ("radio in use %d" , ss->radio_if[i]); + + *tech =rat_to_tech (ss->radio_if[i]); + } + +if (qmi_result_get_uint8 (result,QMI_NAS_RESULT_ROAMING_STATUS , + &roaming)) { +if (ss->status ==1 && roaming ==0 ) + *status =NETWORK_REGISTRATION_STATUS_ROAMING ; + }return true; } -static void ss_info_notify (struct qmi_result *result,void *user_data) +/* +* This method handles both Serving System Info requests and +* notifications. The presence of a callback differentiates between +* the two and the result is handled slightly differently accordingly. +* If there's a callback, we invoke it; otherwise we send a notification +* to ofono about relevant state changes. +*/ +static void handle_ss_info (struct qmi_result * result,void *user_data) { -struct ofono_gprs *gprs = user_data; +struct cb_data *cbd = user_data; +struct ofono_gprs * gprs = cbd->user; +struct gprs_data *data =ofono_gprs_get_data (gprs); +ofono_gprs_status_cb_t cb = cbd->cb;int status; +int tech;DBG ("" ); -if (!extract_ss_info (result, &status)) -return ; +if (cb &&qmi_result_set_error (result,NULL )) + goto error; + +if (!extract_ss_info (result, &status, &tech)) + goto error; + +switch (status) { +case NETWORK_REGISTRATION_STATUS_REGISTERED : +case NETWORK_REGISTRATION_STATUS_ROAMING : +if (tech ==ACCESS_TECHNOLOGY_EUTRAN && !data->attached) { +/* On LTE we are effectively always attached; and +* the default bearer is established as soon as the +* network is joined. +*/ + data->attached =1 ; +/* FIXME: query default profile number and APN +* instead of assuming profile 1 +*/ +ofono_gprs_cid_activated (gprs,1 ,"" ); + } +break ; +default : +break ; + } + +if (!data->attached) + status =NETWORK_REGISTRATION_STATUS_NOT_REGISTERED ; -ofono_gprs_status_notify (gprs, status); +if (cb) +CALLBACK_WITH_SUCCESS (cb, status, cbd->data); +else +ofono_gprs_status_notify (gprs, status); + +return ; + +error: +if (cb) +CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); }static void attach_detach_cb (struct qmi_result *result,void *user_data)
@@ -100,6 +175,8 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,DBG ("attached %d" , attached); + data->attached = attached; +if (attached) action =QMI_NAS_ATTACH_ACTION_ATTACH ;else
@@ -121,27 +198,6 @@ error:g_free (cbd); } -static void get_ss_info_cb (struct qmi_result *result,void *user_data) -{ -struct cb_data *cbd = user_data; -ofono_gprs_status_cb_t cb = cbd->cb; -int status; - -DBG ("" ); - -if (qmi_result_set_error (result,NULL )) { -CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); -return ; - } - -if (!extract_ss_info (result, &status)) { -CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); -return ; - } - -CALLBACK_WITH_SUCCESS (cb, status, cbd->data); -} -static void qmi_attached_status (struct ofono_gprs *gprs,ofono_gprs_status_cb_t cb,void *user_data) {
@@ -150,8 +206,14 @@ static void qmi_attached_status(struct ofono_gprs *gprs,DBG ("" ); +if (!data->attached) { +CALLBACK_WITH_SUCCESS (cb, +NETWORK_REGISTRATION_STATUS_NOT_REGISTERED , user_data); + } + + cbd->user = gprs;if (qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - get_ss_info_cb, cbd, g_free) >0 ) + handle_ss_info, cbd, g_free) >0 )return ;CALLBACK_WITH_FAILURE (cb,-1 , cbd->data);
@@ -163,6 +225,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data) {struct ofono_gprs *gprs = user_data;struct gprs_data *data =ofono_gprs_get_data (gprs); +struct cb_data *cbd;DBG ("" );
@@ -178,11 +241,15 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)* First get the SS info - the modem may already be connected, * and the state-change notification may never arrive */ + cbd =cb_data_new (NULL ,NULL ); + cbd->user = gprs;qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free); + cbd =cb_data_new (NULL ,NULL ); + cbd->user = gprs;qmi_service_register (data->nas,QMI_NAS_SS_INFO_IND , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free);ofono_gprs_set_cid_range (gprs,1 ,1 );
Signature · 1 line
2.9.3
Re: [PATCH qmi lte v3 3/6] qmi: activate default bearer context for LTE networks
Hi Jonas,
Quoted 49 lines · Jonas Bonn
When the modem attaches to an LTE network, a default bearer is automatically negotiated using the "defalt profile" settings. The QMI modem, however, does not given any explicit indication that the bearer exists; instead, we must assume its existence based on the network registration state.
This patch extends the GPRS atom to signal the presence of a default bearer when it detects network connectivity on an LTE network.
The GPRS atom gets a new 'attached' property based on whether it has been manually attached or automatically "attached" by virtue of connecting to an LTE network. Here we abuse the word "attach" since attach'ing isn't really an LTE concept, but it fits with the model that Ofono wants.
--- drivers/qmimodem/gprs.c | 135 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 34 deletions(-)drivers/qmimodem/gprs.c +8
-1@@ -23,6 +23,8 @@#include <config.h> #endif +#include <glib.h> /* this include belongs in common.h */ +#include <ofono/log.h> #include <ofono/modem.h> #include <ofono/gprs.h> @@ -30,16 +32,34 @@#include "qmi.h" #include "nas.h" +#include "src/common.h" #include "qmimodem.h" struct gprs_data {struct qmi_service *nas; +int attached; }; -static bool extract_ss_info (struct qmi_result *result,int *status) +static int rat_to_tech (uint8_t rat) +{ +switch (rat) { +case QMI_NAS_NETWORK_RAT_GSM :
drivers/qmimodem/gprs.c line 56
Quoted 10 lines
drivers/qmimodem/gprs.c +10
-0+return ACCESS_TECHNOLOGY_GSM ; +case QMI_NAS_NETWORK_RAT_UMTS : +return ACCESS_TECHNOLOGY_UTRAN ; +case QMI_NAS_NETWORK_RAT_LTE : +return ACCESS_TECHNOLOGY_EUTRAN ; + } + +return -1 ; +} +
You might want to put this into drivers/qmimodem/nas.c as:
qmi_nas_rat_to_tech() and use it from both the netreg and gprs drivers
Quoted 33 lines
drivers/qmimodem/gprs.c +17
-4+static bool extract_ss_info (struct qmi_result *result,int *status,int *tech) {const struct qmi_nas_serving_system *ss; +uint8_t roaming;uint16_t len; +int i;DBG ("" );@@ -47,25 +67,80 @@ static bool extract_ss_info(struct qmi_result *result, int *status)if (!ss)return false; -if (ss->ps_state ==QMI_NAS_ATTACH_STATE_ATTACHED ) - *status =0x01 ; -else - *status =0x00 ; + *status = ss->status; + + *tech =-1 ; +for (i =0 ; i < ss->radio_if_count; i++) { +DBG ("radio in use %d" , ss->radio_if[i]); + + *tech =rat_to_tech (ss->radio_if[i]); + } + +if (qmi_result_get_uint8 (result,QMI_NAS_RESULT_ROAMING_STATUS , + &roaming)) { +if (ss->status ==1 && roaming ==0 ) + *status =NETWORK_REGISTRATION_STATUS_ROAMING ; + }return true;
drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status) · line 94
Quoted 10 lines
drivers/qmimodem/gprs.c +7
-1} -static void ss_info_notify (struct qmi_result *result,void *user_data) +/* +* This method handles both Serving System Info requests and +* notifications. The presence of a callback differentiates between +* the two and the result is handled slightly differently accordingly. +* If there's a callback, we invoke it; otherwise we send a notification +* to ofono about relevant state changes. +*/
No, please don't do this, the notification callback and the query callback should be different functions. If you need to perform some common operations, then just extract those into a common function and call it from both.
Quoted 122 lines
drivers/qmimodem/gprs.c +54
-26+static void handle_ss_info (struct qmi_result * result,void *user_data) { -struct ofono_gprs *gprs = user_data; +struct cb_data *cbd = user_data; +struct ofono_gprs * gprs = cbd->user; +struct gprs_data *data =ofono_gprs_get_data (gprs); +ofono_gprs_status_cb_t cb = cbd->cb;int status; +int tech;DBG ("" ); -if (!extract_ss_info (result, &status)) -return ; +if (cb &&qmi_result_set_error (result,NULL )) + goto error; + +if (!extract_ss_info (result, &status, &tech)) + goto error; + +switch (status) { +case NETWORK_REGISTRATION_STATUS_REGISTERED : +case NETWORK_REGISTRATION_STATUS_ROAMING : +if (tech ==ACCESS_TECHNOLOGY_EUTRAN && !data->attached) { +/* On LTE we are effectively always attached; and +* the default bearer is established as soon as the +* network is joined. +*/ + data->attached =1 ; +/* FIXME: query default profile number and APN +* instead of assuming profile 1 +*/ +ofono_gprs_cid_activated (gprs,1 ,"" ); + } +break ; +default : +break ; + } + +if (!data->attached) + status =NETWORK_REGISTRATION_STATUS_NOT_REGISTERED ; -ofono_gprs_status_notify (gprs, status); +if (cb) +CALLBACK_WITH_SUCCESS (cb, status, cbd->data); +else +ofono_gprs_status_notify (gprs, status); + +return ; + +error: +if (cb) +CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); }static void attach_detach_cb (struct qmi_result *result,void *user_data)@@ -100,6 +175,8 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,DBG ("attached %d" , attached); + data->attached = attached; +if (attached) action =QMI_NAS_ATTACH_ACTION_ATTACH ;else @@ -121,27 +198,6 @@ error:g_free (cbd); } -static void get_ss_info_cb (struct qmi_result *result,void *user_data) -{ -struct cb_data *cbd = user_data; -ofono_gprs_status_cb_t cb = cbd->cb; -int status; - -DBG ("" ); - -if (qmi_result_set_error (result,NULL )) { -CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); -return ; - } - -if (!extract_ss_info (result, &status)) { -CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); -return ; - } - -CALLBACK_WITH_SUCCESS (cb, status, cbd->data); -} -static void qmi_attached_status (struct ofono_gprs *gprs,ofono_gprs_status_cb_t cb,void *user_data) {@@ -150,8 +206,14 @@ static void qmi_attached_status(struct ofono_gprs *gprs,DBG ("" ); +if (!data->attached) { +CALLBACK_WITH_SUCCESS (cb, +NETWORK_REGISTRATION_STATUS_NOT_REGISTERED , user_data); + } + + cbd->user = gprs;if (qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - get_ss_info_cb, cbd, g_free) >0 ) + handle_ss_info, cbd, g_free) >0 )return ;CALLBACK_WITH_FAILURE (cb,-1 , cbd->data);@@ -163,6 +225,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data) {struct ofono_gprs *gprs = user_data;struct gprs_data *data =ofono_gprs_get_data (gprs); +struct cb_data *cbd;DBG ("" );@@ -178,11 +241,15 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)* First get the SS info - the modem may already be connected, * and the state-change notification may never arrive */ + cbd =cb_data_new (NULL ,NULL );
drivers/qmimodem/gprs.c static void create_nas_cb(struct qmi_service *service, void *user_data) · line 252
Quoted 10 lines
drivers/qmimodem/gprs.c +5
-2+ cbd->user = gprs;qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free); + cbd =cb_data_new (NULL ,NULL ); + cbd->user = gprs;qmi_service_register (data->nas,QMI_NAS_SS_INFO_IND , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free);
No, the original form was completely fine.
drivers/qmimodem/gprs.c static void create_nas_cb(struct qmi_service *service, void *user_data)
Quoted 4 lines
drivers/qmimodem/gprs.c +0
-0ofono_gprs_set_cid_range (gprs,1 ,1 );
Regards,
-Denis
Re: [PATCH qmi lte v3 3/6] qmi: activate default bearer context for LTE networks
Hi Denis,
Quoted 19 lines · Denis Kenzior
Hi Jonas,
-static boolextract_ss_info(struct qmi_result *result, int *status)Quoted 4 lines
drivers/qmimodem/gprs.c +4
-0+static int rat_to_tech (uint8_t rat) +{ +switch (rat) { +case QMI_NAS_NETWORK_RAT_GSM :drivers/qmimodem/gprs.c line 56
Quoted 10 lines
drivers/qmimodem/gprs.c +10
-0+return ACCESS_TECHNOLOGY_GSM ; +case QMI_NAS_NETWORK_RAT_UMTS : +return ACCESS_TECHNOLOGY_UTRAN ; +case QMI_NAS_NETWORK_RAT_LTE : +return ACCESS_TECHNOLOGY_EUTRAN ; + } + +return -1 ; +} +You might want to put this into
drivers/qmimodem/nas.cas:
Quoted 1 line
qmi_nas_rat_to_tech()and use it from both the netreg and gprs drivers
Good idea... will do!
Quoted 15 lines
Quoted 10 lines
drivers/qmimodem/gprs.c +5
-1-static void ss_info_notify (struct qmi_result *result,void *user_data) +/* +* This method handles both Serving System Info requests and +* notifications. The presence of a callback differentiates between +* the two and the result is handled slightly differently accordingly. +* If there's a callback, we invoke it; otherwise we send a notification
+ * to ofono about relevant state changes.
+ */No, please don't do this, the notification callback and the query callback should be different functions. If you need to perform some common operations, then just extract those into a common function and call it from both.
drivers/rilmodem/gprs-context.c, as one example, uses this pattern. Personally, I find it rather elegant!
Quoted 21 lines
Quoted 21 lines
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);drivers/qmimodem/gprs.c +4
-1@@ -163,6 +225,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data) {struct ofono_gprs *gprs = user_data;struct gprs_data *data =ofono_gprs_get_data (gprs); +struct cb_data *cbd;DBG ("" );@@ -178,11 +241,15 @@ static void create_nas_cb(struct qmi_service*service, void *user_data) * First get the SS info - the modem may already be connected, * and the state-change notification may never arrive */ + cbd =cb_data_new (NULL ,NULL ); + cbd->user = gprs;qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free);
Quoted 7 lines
drivers/qmimodem/gprs.c static void create_nas_cb(struct qmi_service *service, void *user_data) · line 252
Quoted 5 lines
drivers/qmimodem/gprs.c +3
-1+ cbd =cb_data_new (NULL ,NULL ); + cbd->user = gprs;qmi_service_register (data->nas,QMI_NAS_SS_INFO_IND , - ss_info_notify, gprs,NULL ); + handle_ss_info, cbd, g_free);No, the original form was completely fine.
handle_ss_info takes a cbd user_data argument, not a gprs argument. But if handle_ss_info is not acceptable, then I guess the above is fine.
/Jonas
Re: [PATCH qmi lte v3 3/6] qmi: activate default bearer context for LTE networks
Hi Jonas,
Quoted 7 lines
Quoted 4 lines
No, please don't do this, the notification callback and the query callback should be different functions. If you need to perform some common operations, then just extract those into a common function and call it from both.
drivers/rilmodem/gprs-context.c, as one example, uses this pattern. Personally, I find it rather elegant!
I don't see an example of such in there, but I didn't look hard enough. Do you mean the use of ril_gprs_context_deactivate_primary inside ril_gprs_context_deactivate_primary?
Regardless, we really prefer unsolicited notification and command execution result callbacks to be different. Generally because the callback data is different and there's no nice way to hide the differences besides a bunch of if statements. We prefer the code to be easier to read, even if longer. Lots of if-else statements make the code harder to read.
Regards,
-Denis
Re: [PATCH qmi lte v3 3/6] qmi: activate default bearer context for LTE networks
Quoted 7 lines · Denis Kenzior
Hi Jonas,
Quoted 5 lines
Quoted 4 lines
No, please don't do this, the notification callback and the query callback should be different functions. If you need to perform some common operations, then just extract those into a common function and call it from both.
Quoted 6 lines
Quoted 2 lines
drivers/rilmodem/gprs-context.c, as one example, uses this pattern. Personally, I find it rather elegant!I don't see an example of such in there, but I didn't look hard enough. Do you mean the use of
ril_gprs_context_deactivate_primaryinsideril_gprs_context_deactivate_primary?
Line 706... but no worries, I'll expand to separate functions since that's the preference.
/Jonas
Quoted 10 lines
Regardless, we really prefer unsolicited notification and command execution result callbacks to be different. Generally because the callback data is different and there's no nice way to hide the differences besides a bunch of if statements. We prefer the code to be easier to read, even if longer. Lots of if-else statements make the code harder to read.
Regards,
-Denis
PATCH v3 4/6 qim: use named status value
In reply to Jonas Bonn--- drivers/qmimodem/network-registration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/qmimodem/network-registration.c +1 -1
@@ -88,7 +88,7 @@ static bool extract_ss_info(struct qmi_result *result, int *status,if (qmi_result_get_uint8 (result,QMI_NAS_RESULT_ROAMING_STATUS , &roaming)) {if (ss->status ==1 && roaming ==0 ) - *status =5 ; + *status =NETWORK_REGISTRATION_STATUS_ROAMING ; }if (!operator)
Signature · 1 line
2.9.3
Denis Kenzior
AppliedRe: [PATCH qmi lte v3 4/6] qim: use named status value
Hi Jonas,
Quoted 4 lines · Jonas Bonn
--- drivers/qmimodem/network-registration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Regards,
-Denis
PATCH v3 5/6 qmi: stop listening to packet service notifications
In reply to Jonas BonnThe packet service status notification tells whether there is _any_ active and enabled context. Using this to decide whether to release any given context makes no sense.
It might make sense to monitor this status in the GPRS atom, but not here in the gprs-context atom.
--- drivers/qmimodem/gprs-context.c | 30 ------------------------------ 1 file changed, 30 deletions(-)
drivers/qmimodem/gprs-context.c +0 -30
@@ -44,33 +44,6 @@ struct gprs_context_data {uint32_t pkt_handle; }; -static void pkt_status_notify (struct qmi_result *result,void *user_data) -{ -struct ofono_gprs_context *gc = user_data; -struct gprs_context_data *data =ofono_gprs_context_get_data (gc); -const struct qmi_wds_notify_conn_status *status; -uint16_t len; -uint8_t ip_family; - -DBG ("" ); - - status =qmi_result_get (result,QMI_WDS_NOTIFY_CONN_STATUS , &len); -if (!status) -return ; - -DBG ("conn status %d" , status->status); - -if (qmi_result_get_uint8 (result,QMI_WDS_NOTIFY_IP_FAMILY , &ip_family)) -DBG ("ip family %d" , ip_family); - -switch (status->status) { -case QMI_WDS_CONN_STATUS_DISCONNECTED : -ofono_gprs_context_deactivated (gc, data->active_context); - data->active_context =0 ; -break ; - } -} -static void get_settings_cb (struct qmi_result *result,void *user_data) {struct cb_data *cbd = user_data;
@@ -376,9 +349,6 @@ static void create_wds_cb(struct qmi_service *service, void *user_data) } data->wds =qmi_service_ref (service); - -qmi_service_register (data->wds,QMI_WDS_PKT_STATUS_IND , - pkt_status_notify, gc,NULL ); }static void get_data_format_cb (struct qmi_result *result,void *user_data)
Signature · 1 line
2.9.3
Re: [PATCH qmi lte v3 5/6] qmi: stop listening to packet service notifications
Hi Jonas,
Quoted 3 lines · Jonas Bonn
The packet service status notification tells whether there is _any_ active and enabled context. Using this to decide whether to release any given context makes no sense.
The gobi driver only supports a single context and afaik only a single network interface is available. Do you have hardware with support for multiple active contexts?
Otherwise I think it would be safe to assume that in a single-context case, this code is doing the right thing.
Quoted 7 lines
It might make sense to monitor this status in the GPRS atom, but not here in the gprs-context atom.
--- drivers/qmimodem/gprs-context.c | 30 ------------------------------ 1 file changed, 30 deletions(-)
Regards,
-Denis
Re: [PATCH qmi lte v3 5/6] qmi: stop listening to packet service notifications
Quoted 10 lines · Denis Kenzior
Hi Jonas,
Quoted 3 lines · Jonas Bonn
The packet service status notification tells whether there is _any_ active and enabled context. Using this to decide whether to release any given context makes no sense.
The gobi driver only supports a single context and afaik only a single network interface is available. Do you have hardware with support for multiple active contexts?
On an LTE network you can start a "dedicated" bearer. As far as I understand it, the way this is done is to call "start network" specifying a profile ID other than the default. In the ofono context, I presume this would be done by creating a new context and activating it:
it just needs the same APN as the default bearer, and normally one would specify other QoS settings. Given that, then yes, I presume my hardware support multiple active contexts; if the Gobi driver only supports one context it's presumably because it doesn't support LTE.
Quoted 3 lines
Otherwise I think it would be safe to assume that in a single-context case, this code is doing the right thing.
I think, for LTE, that the netreg atom gives you everything you need and that this notification is superflous. I'm thinking now that for non-LTE this code might be relevant: can the context detach spontaneously without unregistering from the network? If yes, then we probably need this, still.
/Jonas
Quoted 12 lines
Quoted 8 lines
It might make sense to monitor this status in the GPRS atom, but not here in the gprs-context atom.
--- drivers/qmimodem/gprs-context.c | 30 ------------------------------ 1 file changed, 30 deletions(-)Regards,
-Denis
Re: [PATCH qmi lte v3 5/6] qmi: stop listening to packet service notifications
Hi Jonas,
Quoted 12 lines · Jonas Bonn
Quoted 10 lines · Denis Kenzior
Hi Jonas,
Quoted 3 lines · Jonas Bonn
The packet service status notification tells whether there is _any_ active and enabled context. Using this to decide whether to release any given context makes no sense.
The gobi driver only supports a single context and afaik only a single network interface is available. Do you have hardware with support for multiple active contexts?
Quoted 8 lines
On an LTE network you can start a "dedicated" bearer. As far as I understand it, the way this is done is to call "start network" specifying a profile ID other than the default. In the ofono context, I presume this would be done by creating a new context and activating it:
it just needs the same APN as the default bearer, and normally one would specify other QoS settings. Given that, then yes, I presume my hardware support multiple active contexts; if the Gobi driver only supports one context it's presumably because it doesn't support LTE.
Okay, so now you're opening a whole new can of worms. Dedicated bearers are similar to secondary PDP contexts in 2G/3G. Their handling is even more special than primary PDP contexts / default bearers.
I wouldn't presume that your hardware supports this. You need to check.
How many physical network interfaces are exposed? If its just one
like the gobi has, then you have your answer.
Quoted 11 lines
Quoted 4 lines
Otherwise I think it would be safe to assume that in a single-context case, this code is doing the right thing.
I think, for LTE, that the netreg atom gives you everything you need and that this notification is superflous. I'm thinking now that for non-LTE this code might be relevant: can the context detach spontaneously without unregistering from the network? If yes, then we probably need this, still.
A context can be forcefully deactivated by the network operator at any time. So yes, this is actually needed.
Regards,
-Denis
Re: [PATCH qmi lte v3 5/6] qmi: stop listening to packet service notifications
Quoted 24 lines · Denis Kenzior
Hi Jonas,
Quoted 12 lines · Jonas Bonn
Quoted 10 lines · Denis Kenzior
Hi Jonas,
Quoted 3 lines · Jonas Bonn
The packet service status notification tells whether there is _any_ active and enabled context. Using this to decide whether to release any given context makes no sense.
The gobi driver only supports a single context and afaik only a single network interface is available. Do you have hardware with support for multiple active contexts?
Quoted 8 lines
On an LTE network you can start a "dedicated" bearer. As far as I understand it, the way this is done is to call "start network" specifying a profile ID other than the default. In the ofono context, I presume this would be done by creating a new context and activating it:
it just needs the same APN as the default bearer, and normally one would specify other QoS settings. Given that, then yes, I presume my hardware support multiple active contexts; if the Gobi driver only supports one context it's presumably because it doesn't support LTE.
Quoted 8 lines
Okay, so now you're opening a whole new can of worms. Dedicated bearers are similar to secondary PDP contexts in 2G/3G. Their handling is even more special than primary PDP contexts / default bearers.
I wouldn't presume that your hardware supports this. You need to check. How many physical network interfaces are exposed? If its just one like the gobi has, then you have your answer.
Don't all LTE modems that support voice support dedicated bearers?
I think I was assuming you'd just get another IP address to set on the network interface... packets from that source would be handled with a different QoS setting. Poking around the libqmi archive it seems that there is some activity around dedicated bearers, but all the modems in question only one have network interface. But I really don't know enough about this... :(
My hardware has only network interface in any case.
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
Otherwise I think it would be safe to assume that in a single-context case, this code is doing the right thing.
I think, for LTE, that the netreg atom gives you everything you need and that this notification is superflous. I'm thinking now that for non-LTE this code might be relevant: can the context detach spontaneously without unregistering from the network? If yes, then we probably need this, still.
Quoted 2 lines
A context can be forcefully deactivated by the network operator at any time. So yes, this is actually needed.
OK, this patch is then plainly wrong. I'll drop it.
/Jonas
Quoted 4 lines
Regards,
-Denis
Re: [PATCH qmi lte v3 5/6] qmi: stop listening to packet service notifications
Hi Jonas,
Quoted 10 lines
Quoted 8 lines
Okay, so now you're opening a whole new can of worms. Dedicated bearers are similar to secondary PDP contexts in 2G/3G. Their handling is even more special than primary PDP contexts / default bearers.
I wouldn't presume that your hardware supports this. You need to check. How many physical network interfaces are exposed? If its just one like the gobi has, then you have your answer.
Don't all LTE modems that support voice support dedicated bearers?
The answer is it depends. Even if they do, you still need an IMS VoLTE stack to do anything useful with them. Most modems have an IMS stack internal to the firmware, but not all will ship with one for your typical broadband connectivity stick.
Quoted 7 lines
I think I was assuming you'd just get another IP address to set on the network interface... packets from that source would be handled with a different QoS setting. Poking around the libqmi archive it seems that there is some activity around dedicated bearers, but all the modems in question only one have network interface. But I really don't know enough about this... :(
The IP address will be the same. All the dedicated bearer does is apply QoS to a particular service.
Maybe with QMI the packets will flow on the original network interface, even if a dedicated bearer was setup. But then volte/ims usually uses a separate APN/bearer anyway.
Quoted 3 lines
My hardware has only network interface in any case.
There you go. I think QMI is mostly meant for data-only cards.
Regards,
-Denis
PATCH v3 6/6 qmi: consolidate ss_info handling functions
In reply to Jonas Bonn--- drivers/qmimodem/network-registration.c | 51 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
drivers/qmimodem/network-registration.c +22 -29
@@ -135,42 +135,32 @@ static bool extract_ss_info(struct qmi_result *result, int *status,return true; } -static void ss_info_notify (struct qmi_result *result,void *user_data) +static void handle_ss_info (struct qmi_result *result,void *user_data) { -struct ofono_netreg *netreg = user_data; +struct cb_data *cbd = user_data; +struct ofono_netreg *netreg = cbd->user;struct netreg_data *data =ofono_netreg_get_data (netreg); +ofono_netreg_status_cb_t cb = cbd->cb;int status, lac, cellid, tech;DBG ("" ); -if (!extract_ss_info (result, &status, &lac, &cellid, &tech, - &data->operator)) -return ; - -ofono_netreg_status_notify (netreg, status, lac, cellid, tech); -} - -static void get_ss_info_cb (struct qmi_result *result,void *user_data) -{ -struct cb_data *cbd = user_data; -ofono_netreg_status_cb_t cb = cbd->cb; -struct netreg_data *data = cbd->user; -int status, lac, cellid, tech; +if (cb &&qmi_result_set_error (result,NULL )) + goto error; -DBG ("" ); +if (!extract_ss_info (result, &status, &lac, + &cellid, &tech, &data->operator)) + goto error; -if (qmi_result_set_error (result,NULL )) { -CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data); -return ; - } +if (cb) +CALLBACK_WITH_SUCCESS (cb, status, + lac, cellid, tech, cbd->data); +else +ofono_netreg_status_notify (netreg, status, lac, cellid, tech); -if (!extract_ss_info (result, &status, &lac, &cellid, &tech, - &data->operator)) { +error: +if (cb)CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data); -return ; - } - -CALLBACK_WITH_SUCCESS (cb, status, lac, cellid, tech, cbd->data); } static void qmi_registration_status(struct ofono_netreg *netreg,
@@ -181,10 +171,10 @@ static void qmi_registration_status(struct ofono_netreg *netreg,DBG ("" ); - cbd->user = data; + cbd->user = netreg;if (qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - get_ss_info_cb, cbd, g_free) >0 ) + handle_ss_info, cbd, g_free) >0 )return ;CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data);
@@ -498,6 +488,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)struct ofono_netreg *netreg = user_data;struct netreg_data *data =ofono_netreg_get_data (netreg);struct qmi_param *param; +struct cb_data *cbd;struct qmi_nas_param_event_signal_strength ss = { .report =0x01 , .count =5 , .dbm[0 ] =-55 , .dbm[1 ] =-65 , .dbm[2 ] =-75 , .dbm[3 ] =-85 , .dbm[4 ] =-95 };
@@ -515,8 +506,10 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)qmi_service_register (data->nas,QMI_NAS_EVENT , event_notify, netreg,NULL ); + cbd =cb_data_new (NULL ,NULL ); + cbd->user = netreg;qmi_service_register (data->nas,QMI_NAS_SS_INFO_IND , - ss_info_notify, netreg,NULL ); + handle_ss_info, cbd, g_free); param =qmi_param_new ();if (!param)
Signature · 1 line
2.9.3
Re: [PATCH qmi lte v3 6/6] qmi: consolidate ss_info handling functions
Hi Jonas,
Quoted 21 lines · Jonas Bonn
--- drivers/qmimodem/network-registration.c | 51 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-)drivers/qmimodem/network-registration.c +4
-2@@ -135,42 +135,32 @@ static bool extract_ss_info(struct qmi_result *result, int *status,return true; } -static void ss_info_notify (struct qmi_result *result,void *user_data) +static void handle_ss_info (struct qmi_result *result,void *user_data) { -struct ofono_netreg *netreg = user_data; +struct cb_data *cbd = user_data; +struct ofono_netreg *netreg = cbd->user;struct netreg_data *data =ofono_netreg_get_data (netreg); +ofono_netreg_status_cb_t cb = cbd->cb;int status, lac, cellid, tech;
drivers/qmimodem/network-registration.c static bool extract_ss_info(struct qmi_result *result, int *status, · line 152
Quoted 10 lines
drivers/qmimodem/network-registration.c +0
-7DBG ("" ); -if (!extract_ss_info (result, &status, &lac, &cellid, &tech, - &data->operator)) -return ; - -ofono_netreg_status_notify (netreg, status, lac, cellid, tech); -} -
Actually I prefer to have two separate callbacks.
Quoted 23 lines
drivers/qmimodem/network-registration.c +10
-11-static void get_ss_info_cb (struct qmi_result *result,void *user_data) -{ -struct cb_data *cbd = user_data; -ofono_netreg_status_cb_t cb = cbd->cb; -struct netreg_data *data = cbd->user; -int status, lac, cellid, tech; +if (cb &&qmi_result_set_error (result,NULL )) + goto error; -DBG ("" ); +if (!extract_ss_info (result, &status, &lac, + &cellid, &tech, &data->operator)) + goto error; -if (qmi_result_set_error (result,NULL )) { -CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data); -return ; - } +if (cb) +CALLBACK_WITH_SUCCESS (cb, status, + lac, cellid, tech, cbd->data); +else +ofono_netreg_status_notify (netreg, status, lac, cellid, tech);
drivers/qmimodem/network-registration.c static bool extract_ss_info(struct qmi_result *result, int *status, · line 173
Quoted 10 lines
drivers/qmimodem/network-registration.c +2
-6-if (!extract_ss_info (result, &status, &lac, &cellid, &tech, - &data->operator)) { +error: +if (cb)CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data); -return ; - } - -CALLBACK_WITH_SUCCESS (cb, status, lac, cellid, tech, cbd->data);
The if (cb) stuff is just harder to read.
Quoted 25 lines
drivers/qmimodem/network-registration.c +3
-2} static void qmi_registration_status(struct ofono_netreg *netreg,@@ -181,10 +171,10 @@ static void qmi_registration_status(struct ofono_netreg *netreg,DBG ("" ); - cbd->user = data; + cbd->user = netreg;if (qmi_service_send (data->nas,QMI_NAS_GET_SS_INFO ,NULL , - get_ss_info_cb, cbd, g_free) >0 ) + handle_ss_info, cbd, g_free) >0 )return ;CALLBACK_WITH_FAILURE (cb,-1 ,-1 ,-1 ,-1 , cbd->data);@@ -498,6 +488,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)struct ofono_netreg *netreg = user_data;struct netreg_data *data =ofono_netreg_get_data (netreg);struct qmi_param *param; +struct cb_data *cbd;struct qmi_nas_param_event_signal_strength ss = { .report =0x01 , .count =5 , .dbm[0 ] =-55 , .dbm[1 ] =-65 , .dbm[2 ] =-75 , .dbm[3 ] =-85 , .dbm[4 ] =-95 };
drivers/qmimodem/network-registration.c static void create_nas_cb(struct qmi_service *service, void *user_data) · line 510
Quoted 5 lines
drivers/qmimodem/network-registration.c +2
-0@@ -515,8 +506,10 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)qmi_service_register (data->nas,QMI_NAS_EVENT , event_notify, netreg,NULL ); + cbd =cb_data_new (NULL ,NULL ); + cbd->user = netreg;
Please don't ever do this, it just looks weird and tells the reader you're abusing the system (e.g. its a crude hack).
drivers/qmimodem/network-registration.c static void create_nas_cb(struct qmi_service *service, void *user_data) · line 515
Quoted 7 lines
drivers/qmimodem/network-registration.c +1
-1qmi_service_register (data->nas,QMI_NAS_SS_INFO_IND , - ss_info_notify, netreg,NULL ); + handle_ss_info, cbd, g_free); param =qmi_param_new ();if (!param)
Regards,
-Denis