qmimodem: wds: Introduce qmi_wds_ip_family enum
PATCH 1/7 qmimodem: wds: Introduce qmi_wds_ip_family enum
--- drivers/qmimodem/gprs-context.c | 4 ++-- drivers/qmimodem/wds.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/qmimodem/gprs-context.c +2 -2
@@ -247,10 +247,10 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,switch (ctx->proto) {case OFONO_GPRS_PROTO_IP : - ip_family =4 ; + ip_family =QMI_WDS_IP_FAMILY_IPV4 ;break ;case OFONO_GPRS_PROTO_IPV6 : - ip_family =6 ; + ip_family =QMI_WDS_IP_FAMILY_IPV6 ;break ;default : goto error;
drivers/qmimodem/wds.h +7 -0
@@ -63,6 +63,13 @@ struct qmi_wds_notify_conn_status {#define QMI_WDS_PDP_TYPE_IPV6 0x02#define QMI_WDS_PDP_TYPE_IPV4V6 0x03 +enum qmi_wds_ip_family { +QMI_WDS_IP_FAMILY_UNKNOWN =0 , +QMI_WDS_IP_FAMILY_IPV4 =4 , +QMI_WDS_IP_FAMILY_IPV6 =6 , +QMI_WDS_IP_FAMILY_UNSPECIFIED =8 , +}; +enum qmi_wds_client_type {QMI_WDS_CLIENT_TYPE_TETHERED =0x01 , };
Signature · 1 line
2.44.0
PATCH 2/7 qmi: gprs-context: Do not free/alloc unnecessarily
In start_net_cb, a new cb_data object is allocated which contains the exact same information as the cb_data object being passed in as userdata. Use cb_data_ref/unref instead.
While here, also fix an erroneous invocation of CALLBACK_WITH_SUCCESS if the GET_CURRENT_SETTINGS request was not queued successfully. An error should be generated instead.
--- drivers/qmimodem/gprs-context.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/qmimodem/gprs-context.c +5 -10
@@ -166,17 +166,12 @@ static void start_net_cb(struct qmi_result *result, void *user_data) data->pkt_handle = handle; -/* Duplicate cbd, the old one will be freed when this method returns */ - cbd =cb_data_new (cb, cbd->data); - cbd->user = gc;if (qmi_service_send (data->wds,QMI_WDS_GET_CURRENT_SETTINGS ,NULL , - get_settings_cb, cbd, l_free) >0 ) + get_settings_cb, cbd, cb_data_unref) >0 ) { +cb_data_ref (cbd);return ; - -CALLBACK_WITH_SUCCESS (cb, cbd->data); - -return ; + } error: data->active_context =0 ;
@@ -205,7 +200,7 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, cbd->user = gc;if (qmi_service_send (data->wds,QMI_WDS_START_NETWORK ,NULL , - start_net_cb, cbd, l_free) >0 ) + start_net_cb, cbd, cb_data_unref) >0 )return ; data->active_context =0 ;
@@ -277,7 +272,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, strlen(ctx->password), ctx->password);if (qmi_service_send (data->wds,QMI_WDS_START_NETWORK , param, - start_net_cb, cbd, l_free) >0 ) + start_net_cb, cbd, cb_data_unref) >0 )return ;qmi_param_free (param);
Signature · 1 line
2.44.0
PATCH 3/7 qmi: gprs-context: Move singleton defines to call site
In reply to Denis KenziorThese defines are used only a single time, either as an enumeration for a parameter or result. Move them to be closer to the actual call site and do not use a QMI_WDS prefix.
--- drivers/qmimodem/gprs-context.c | 40 ++++++++++++++++++++------------- drivers/qmimodem/wds.h | 17 -------------- 2 files changed, 24 insertions(+), 33 deletions(-)
drivers/qmimodem/gprs-context.c +24 -16
@@ -44,6 +44,8 @@ struct gprs_context_data {static void pkt_status_notify (struct qmi_result *result,void *user_data) { +static const uint8_t RESULT_CONN_STATUS =0x01 ; +static const uint8_t RESULT_IP_FAMILY =0x12 ;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;
@@ -52,13 +54,13 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)DBG ("" ); - status =qmi_result_get (result,QMI_WDS_NOTIFY_CONN_STATUS , &len); + status =qmi_result_get (result,RESULT_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)) +if (qmi_result_get_uint8 (result,RESULT_IP_FAMILY , &ip_family))DBG ("ip family %d" , ip_family);switch (status->status) {
@@ -75,6 +77,14 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)static void get_settings_cb (struct qmi_result *result,void *user_data) { +static const uint8_t RESULT_PDP_TYPE =0x11 ;/* uint8 */ +static const uint8_t RESULT_APN =0x14 ;/* string */ +static const uint8_t RESULT_PRIMARY_DNS =0x15 ; +static const uint8_t RESULT_SECONDARY_DNS =0x16 ; +static const uint8_t RESULT_IP_ADDRESS =0x1e ; +static const uint8_t RESULT_GATEWAY =0x20 ; +static const uint8_t RESULT_GATEWAY_NETMASK =0x21 ; +static const uint8_t RESULT_IP_FAMILY =0x2b ;/* uint8 */ struct cb_data *cbd = user_data;ofono_gprs_context_cb_t cb = cbd->cb;struct ofono_gprs_context *gc = cbd->user;
@@ -91,49 +101,46 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)if (qmi_result_set_error (result,NULL )) goto done; - apn =qmi_result_get_string (result,QMI_WDS_RESULT_APN ); + apn =qmi_result_get_string (result,RESULT_APN );if (apn) {DBG ("APN: %s" , apn);l_free (apn); } -if (qmi_result_get_uint8 (result,QMI_WDS_RESULT_PDP_TYPE , &pdp_type)) +if (qmi_result_get_uint8 (result,RESULT_PDP_TYPE , &pdp_type))DBG ("PDP type %d" , pdp_type); -if (qmi_result_get_uint8 (result,QMI_WDS_RESULT_IP_FAMILY , &ip_family)) +if (qmi_result_get_uint8 (result,RESULT_IP_FAMILY , &ip_family))DBG ("IP family %d" , ip_family); -if (qmi_result_get_uint32 (result,QMI_WDS_RESULT_IP_ADDRESS , &ip_addr)) { +if (qmi_result_get_uint32 (result,RESULT_IP_ADDRESS , &ip_addr)) { addr.s_addr =htonl (ip_addr); straddr =inet_ntoa (addr);DBG ("IP addr: %s" , straddr);ofono_gprs_context_set_ipv4_address (gc, straddr,1 ); } -if (qmi_result_get_uint32 (result,QMI_WDS_RESULT_GATEWAY , &ip_addr)) { +if (qmi_result_get_uint32 (result,RESULT_GATEWAY , &ip_addr)) { addr.s_addr =htonl (ip_addr); straddr =inet_ntoa (addr);DBG ("Gateway: %s" , straddr);ofono_gprs_context_set_ipv4_gateway (gc, straddr); } -if (qmi_result_get_uint32 (result, -QMI_WDS_RESULT_GATEWAY_NETMASK , &ip_addr)) { +if (qmi_result_get_uint32 (result,RESULT_GATEWAY_NETMASK , &ip_addr)) { addr.s_addr =htonl (ip_addr); straddr =inet_ntoa (addr);DBG ("Gateway netmask: %s" , straddr);ofono_gprs_context_set_ipv4_netmask (gc, straddr); } -if (qmi_result_get_uint32 (result, -QMI_WDS_RESULT_PRIMARY_DNS , &ip_addr)) { +if (qmi_result_get_uint32 (result,RESULT_PRIMARY_DNS , &ip_addr)) { addr.s_addr =htonl (ip_addr); dns[0 ] =inet_ntop (AF_INET , &addr, dns_buf[0 ],sizeof (dns_buf[0 ]));DBG ("Primary DNS: %s" , dns[0 ]); } -if (qmi_result_get_uint32 (result, -QMI_WDS_RESULT_SECONDARY_DNS , &ip_addr)) { +if (qmi_result_get_uint32 (result,RESULT_SECONDARY_DNS , &ip_addr)) { addr.s_addr =htonl (ip_addr); dns[1 ] =inet_ntop (AF_INET , &addr, dns_buf[1 ],sizeof (dns_buf[1 ]));DBG ("Secondary DNS: %s" , dns[1 ]);
@@ -148,6 +155,7 @@ done:static void start_net_cb (struct qmi_result *result,void *user_data) { +static const uint8_t RESULT_PACKET_HANDLE =0x01 ;struct cb_data *cbd = user_data;ofono_gprs_context_cb_t cb = cbd->cb;struct ofono_gprs_context *gc = cbd->user;
@@ -159,7 +167,7 @@ static void start_net_cb(struct qmi_result *result, void *user_data)if (qmi_result_set_error (result,NULL )) goto error; -if (!qmi_result_get_uint32 (result,QMI_WDS_RESULT_PKT_HANDLE , &handle)) +if (!qmi_result_get_uint32 (result,RESULT_PACKET_HANDLE , &handle)) goto error;DBG ("packet handle %d" , handle);
@@ -314,6 +322,7 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc,unsigned int cid, ofono_gprs_context_cb_t cb, void *user_data) { + static const uint8_t PARAM_PACKET_HANDLE = 0x01;struct gprs_context_data *data =ofono_gprs_context_get_data (gc);struct cb_data *cbd =cb_data_new (cb, user_data);struct qmi_param *param;
@@ -322,8 +331,7 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc, cbd->user = gc; - param =qmi_param_new_uint32 (QMI_WDS_PARAM_PKT_HANDLE , - data->pkt_handle); + param =qmi_param_new_uint32 (PARAM_PACKET_HANDLE , data->pkt_handle);if (qmi_service_send (data->wds,QMI_WDS_STOP_NETWORK , param, stop_net_cb, cbd, l_free) >0 )
drivers/qmimodem/wds.h +0 -17
@@ -30,34 +30,17 @@#define QMI_WDS_AUTHENTICATION_PAP 0x1#define QMI_WDS_AUTHENTICATION_CHAP 0x2 -#define QMI_WDS_RESULT_PKT_HANDLE 0x01/* uint32 */ - -/* Stop WDS network interface */ -#define QMI_WDS_PARAM_PKT_HANDLE 0x01/* uint32 */ -/* Packet data connection status indication */ -#define QMI_WDS_NOTIFY_CONN_STATUS 0x01struct qmi_wds_notify_conn_status {uint8_t status;uint8_t reconf; } __attribute__((__packed__ )); -#define QMI_WDS_NOTIFY_IP_FAMILY 0x12/* uint8 */ #define QMI_WDS_CONN_STATUS_DISCONNECTED 0x01#define QMI_WDS_CONN_STATUS_CONNECTED 0x02#define QMI_WDS_CONN_STATUS_SUSPENDED 0x03#define QMI_WDS_CONN_STATUS_AUTHENTICATING 0x04 -/* Get the runtime data session settings */ -#define QMI_WDS_RESULT_PDP_TYPE 0x11/* uint8 */ -#define QMI_WDS_RESULT_APN 0x14/* string */ -#define QMI_WDS_RESULT_PRIMARY_DNS 0x15/* uint32 IPv4 */ -#define QMI_WDS_RESULT_SECONDARY_DNS 0x16/* uint32 IPv4 */ -#define QMI_WDS_RESULT_IP_ADDRESS 0x1e/* uint32 IPv4 */ -#define QMI_WDS_RESULT_GATEWAY 0x20/* uint32 IPv4 */ -#define QMI_WDS_RESULT_GATEWAY_NETMASK 0x21/* uint32 IPv4 */ -#define QMI_WDS_RESULT_IP_FAMILY 0x2b/* uint8 */ -#define QMI_WDS_PDP_TYPE_IPV4 0x00#define QMI_WDS_PDP_TYPE_PPP 0x01#define QMI_WDS_PDP_TYPE_IPV6 0x02
Signature · 1 line
2.44.0
PATCH 4/7 qmi: gprs-context: Convert QMI_WDS_AUTHENTICATION to an enum
In reply to Denis KenziorQMI uses authentication type as a bitmap, with both PAP and CHAP support being selectable independently. Convert QMI_WDS_AUTHENTICATION* defines to an enumeration, removing QMI_WDS_AUTHENTICATION_NONE.
--- drivers/qmimodem/gprs-context.c | 9 +++++---- drivers/qmimodem/wds.h | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/qmimodem/gprs-context.c +5 -4
@@ -220,16 +220,17 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,static uint8_t auth_method_to_qmi_auth (enum ofono_gprs_auth_method method) { +/* QMI uses a bitmap */ switch (method) {case OFONO_GPRS_AUTH_METHOD_CHAP :return QMI_WDS_AUTHENTICATION_CHAP ;case OFONO_GPRS_AUTH_METHOD_PAP :return QMI_WDS_AUTHENTICATION_PAP ;case OFONO_GPRS_AUTH_METHOD_NONE : -return QMI_WDS_AUTHENTICATION_NONE ; +return 0 ; } -return QMI_WDS_AUTHENTICATION_NONE ; +return 0 ; } static void qmi_activate_primary(struct ofono_gprs_context *gc,
@@ -271,11 +272,11 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,qmi_param_append_uint8 (param,QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE , auth); -if (auth !=QMI_WDS_AUTHENTICATION_NONE && ctx->username[0 ] !='\0' ) +if (auth && ctx->username[0 ] !='\0' )qmi_param_append (param,QMI_WDS_PARAM_USERNAME ,strlen (ctx->username), ctx->username); -if (auth !=QMI_WDS_AUTHENTICATION_NONE && ctx->password[0 ] !='\0' ) +if (auth && ctx->password[0 ] !='\0' )qmi_param_append (param,QMI_WDS_PARAM_PASSWORD ,strlen (ctx->password), ctx->password);
drivers/qmimodem/wds.h +5 -3
@@ -26,9 +26,11 @@#define QMI_WDS_PARAM_PASSWORD 0x18/* string */ #define QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE 0x16/* uint8 */ -#define QMI_WDS_AUTHENTICATION_NONE 0x0 -#define QMI_WDS_AUTHENTICATION_PAP 0x1 -#define QMI_WDS_AUTHENTICATION_CHAP 0x2 + +enum qmi_wds_authentication { +QMI_WDS_AUTHENTICATION_PAP =0x1 , +QMI_WDS_AUTHENTICATION_CHAP =0x2 , +};/* Packet data connection status indication */ struct qmi_wds_notify_conn_status {
Signature · 1 line
2.44.0
PATCH 5/7 qmi: wds: Convert defines to enums
In reply to Denis Kenzior--- drivers/qmimodem/gprs-context.c | 2 +- drivers/qmimodem/wds.h | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-)
drivers/qmimodem/gprs-context.c +1 -1
@@ -64,7 +64,7 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)DBG ("ip family %d" , ip_family);switch (status->status) { -case QMI_WDS_CONN_STATUS_DISCONNECTED : +case QMI_WDS_CONNECTION_STATUS_DISCONNECTED :if (data->pkt_handle) {/* The context has been disconnected by the network */ ofono_gprs_context_deactivated (gc, data->active_context);
drivers/qmimodem/wds.h +12 -8
@@ -38,15 +38,19 @@ struct qmi_wds_notify_conn_status {uint8_t reconf; } __attribute__((__packed__)); -#define QMI_WDS_CONN_STATUS_DISCONNECTED 0x01 -#define QMI_WDS_CONN_STATUS_CONNECTED 0x02 -#define QMI_WDS_CONN_STATUS_SUSPENDED 0x03 -#define QMI_WDS_CONN_STATUS_AUTHENTICATING 0x04 +enum qmi_wds_connection_status { +QMI_WDS_CONNECTION_STATUS_DISCONNECTED =0x01 , +QMI_WDS_CONNECTION_STATUS_CONNECTED =0x02 , +QMI_WDS_CONNECTION_STATUS_SUSPENDED =0x03 , +QMI_WDS_CONNECTION_STATUS_AUTHENTICATING =0x04 , +}; -#define QMI_WDS_PDP_TYPE_IPV4 0x00 -#define QMI_WDS_PDP_TYPE_PPP 0x01 -#define QMI_WDS_PDP_TYPE_IPV6 0x02 -#define QMI_WDS_PDP_TYPE_IPV4V6 0x03 +enum qmi_wds_pdp_type { +QMI_WDS_PDP_TYPE_IPV4 =0x00 , +QMI_WDS_PDP_TYPE_PPP =0x01 , +QMI_WDS_PDP_TYPE_IPV6 =0x02 , +QMI_WDS_PDP_TYPE_IPV4V6 =0x03 , +};enum qmi_wds_ip_family {QMI_WDS_IP_FAMILY_UNKNOWN =0 ,
Signature · 1 line
2.44.0
PATCH 6/7 qmi: gprs-context: Remove single-use structure definition
In reply to Denis KenziorThis structure is defined in wds.h but only used once inside packet_status_notify(). It is unlikely to be used elsewhere since this TLV is specific to the connection status indication. Define/declare this structure directly in the handler instead.
--- drivers/qmimodem/gprs-context.c | 5 ++++- drivers/qmimodem/wds.h | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-)
drivers/qmimodem/gprs-context.c +4 -1
@@ -48,7 +48,10 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)static const uint8_t RESULT_IP_FAMILY =0x12 ;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; +const struct { +uint8_t status; +uint8_t reconf; + } __attribute__((__packed__ )) *status;uint16_t len;uint8_t ip_family;
drivers/qmimodem/wds.h +0 -6
@@ -32,12 +32,6 @@ enum qmi_wds_authentication { QMI_WDS_AUTHENTICATION_CHAP = 0x2, }; -/* Packet data connection status indication */ -struct qmi_wds_notify_conn_status { -uint8_t status; -uint8_t reconf; -} __attribute__((__packed__ )); -enum qmi_wds_connection_status {QMI_WDS_CONNECTION_STATUS_DISCONNECTED =0x01 ,QMI_WDS_CONNECTION_STATUS_CONNECTED =0x02 ,
Signature · 1 line
2.44.0
PATCH 7/7 qmi: gprs-context: Request certain TLVs to be included
In reply to Denis KenziorExplicitly ask WDS service to include certain TLVs in its response. This is mainly needed to obtain the value of the negotiated MTU between the modem and the network. MTU is not included in the response otherwise.
--- drivers/qmimodem/gprs-context.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/qmimodem/gprs-context.c +18 -0
@@ -159,11 +159,14 @@ done:static void start_net_cb (struct qmi_result *result,void *user_data) {static const uint8_t RESULT_PACKET_HANDLE =0x01 ; +static const uint8_t PARAM_REQUESTED_SETTINGS =0x10 ;struct cb_data *cbd = user_data;ofono_gprs_context_cb_t cb = cbd->cb;struct ofono_gprs_context *gc = cbd->user;struct gprs_context_data *data =ofono_gprs_context_get_data (gc);uint32_t handle; +uint32_t requested_settings =0 ; +struct qmi_param *param;DBG ("" );
@@ -177,6 +180,19 @@ static void start_net_cb(struct qmi_result *result, void *user_data) data->pkt_handle = handle; +/* +* Explicitly request certain information to be provided. The requested +* settings is a bit field, with each bit representing whether the +* TLV is included in the GET_CURRENT_SETTINGS response. We request the +* following settings: +* 2 - PDP Type, 3 - APN Name, 4 - DNS, 5 - Granted QOS, +* 6 - Username, 7 - Auth Proto +* 8 - IP Address, 9 - Gateway, 13 - MTU, 14 - DNS List, +* 15 - IP Family, 17 - Extended Technology +*/ +L_BITS_SET (&requested_settings,3 ,4 ,6 ,7 ,8 ,9 ,13 ,14 ,15 ,17 ); + param =qmi_param_new_uint32 (PARAM_REQUESTED_SETTINGS , + requested_settings);if (qmi_service_send (data->wds,QMI_WDS_GET_CURRENT_SETTINGS ,NULL , get_settings_cb, cbd, cb_data_unref) >0 ) {
@@ -184,6 +200,8 @@ static void start_net_cb(struct qmi_result *result, void *user_data)return ; } +qmi_param_free (param); + error: data->active_context =0 ;CALLBACK_WITH_FAILURE (cb, cbd->data);
Signature · 1 line
2.44.0
This series was applied to ofono.git (master) by Denis Kenzior <[email protected]>:
Hello:
This series was applied to ofono.git (master)
by Denis Kenzior <[email protected]>:
Quoted 4 lines · On Tue, 16 Apr 2024 10:14:28 -0500 you wrote:
--- drivers/qmimodem/gprs-context.c | 4 ++-- drivers/qmimodem/wds.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
Here is the summary with links:
- [1/7] qmimodem: wds: Introduce qmi_wds_ip_family enum
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=417517a5849e - [2/7] qmi: gprs-context: Do not free/alloc unnecessarily https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=844b488b2919 - [3/7] qmi: gprs-context: Move singleton defines to call site https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=72d9244b091d - [4/7] qmi: gprs-context: Convert QMI_WDS_AUTHENTICATION to an enum https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=acb8d77ba97b - [5/7] qmi: wds: Convert defines to enums https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=ecd6933d5f32 - [6/7] qmi: gprs-context: Remove single-use structure definition https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=93395363f1cb
- [7/7] qmi: gprs-context: Request certain TLVs to be included (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html