From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 10/11] qmi: gprs-context: refactor deactivate_primary
Date: Thu, 11 Jul 2024 11:49:32 -0500 [thread overview]
Message-ID: <20240711164936.1688973-10-denkenz@gmail.com> (raw)
In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com>
When multiple WDS clients are used (Dual stack contexts), the
deactivate_primary path needs to send Stop Network command on any client
with an ongoing packet connection. The following strategy is now used:
1. If no packet connections are ongoing on either IPv4 or IPV6
WDS client, callback with an error
2. If IPv6 WDS client is used, attempt to stop that first,
otherwise, proceed to step 4.
3. If IPv6 WDS client is the only client used, report the
success / failure of this operation. Otherwise, proceed to
step 4.
4. Try to send a Stop Network request to the IPv4 WDS client. If
this step fails, callback with an error.
---
drivers/qmimodem/gprs-context.c | 84 ++++++++++++++++++++++++---------
1 file changed, 62 insertions(+), 22 deletions(-)
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index f4846f0299e7..6061de0a483d 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -425,57 +425,97 @@ static uint32_t send_stop_net(struct qmi_service *wds, uint32_t packet_handle,
return id;
}
-static void stop_net_cb(struct qmi_result *result, void *user_data)
+static void stop_net_ipv4_cb(struct qmi_result *result, void *user_data)
{
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);
+ uint16_t error;
- DBG("");
+ if (!qmi_result_set_error(result, &error))
+ error = 0;
- if (qmi_result_set_error(result, NULL)) {
- if (cb)
- CALLBACK_WITH_FAILURE(cb, cbd->data);
- return;
- }
+ DBG("error: %u", error);
data->packet_handle_ipv4 = 0;
+ data->active_context = 0;
- if (cb)
- CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ if (error)
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
else
- ofono_gprs_context_deactivated(gc, data->active_context);
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+}
- data->active_context = 0;
+static void stop_net_ipv6_cb(struct qmi_result *result, void *user_data)
+{
+ 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);
+ uint16_t error;
+
+ if (!qmi_result_set_error(result, &error))
+ error = 0;
+
+ DBG("error: %u", error);
+
+ data->packet_handle_ipv6 = 0;
+
+ if (data->packet_handle_ipv4) {
+ if (send_stop_net(data->ipv4, data->packet_handle_ipv4,
+ stop_net_ipv4_cb,
+ cb_data_ref(cbd), cb_data_unref))
+ return;
+
+ cb_data_unref(cbd);
+ data->active_context = 0;
+ data->packet_handle_ipv4 = 0;
+ goto error;
+ } else
+ data->active_context = 0;
+
+ if (!error) {
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ return;
+ }
+error:
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
}
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;
+ struct cb_data *cbd;
+ uint32_t id;
DBG("cid %u", cid);
+ if (!data->packet_handle_ipv4 && !data->packet_handle_ipv6)
+ goto error;
+
+ cbd = cb_data_new(cb, user_data);
cbd->user = gc;
- param = qmi_param_new_uint32(PARAM_PACKET_HANDLE,
- data->packet_handle_ipv4);
+ if (data->packet_handle_ipv6)
+ id = send_stop_net(data->ipv6, data->packet_handle_ipv6,
+ stop_net_ipv6_cb, cbd, cb_data_unref);
+ else
+ id = send_stop_net(data->ipv4, data->packet_handle_ipv4,
+ stop_net_ipv4_cb, cbd, cb_data_unref);
- if (qmi_service_send(data->ipv4, QMI_WDS_STOP_NETWORK, param,
- stop_net_cb, cbd, l_free) > 0)
+ if (id)
return;
- qmi_param_free(param);
-
- if (cb)
- CALLBACK_WITH_FAILURE(cb, user_data);
+ data->packet_handle_ipv6 = 0;
+ data->packet_handle_ipv4 = 0;
+ data->active_context = 0;
l_free(cbd);
+error:
+ CALLBACK_WITH_FAILURE(cb, user_data);
}
static void stop_net_detach_ipv4_cb(struct qmi_result *result, void *user_data)
--
2.45.2
next prev parent reply other threads:[~2024-07-11 16:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 16:49 [PATCH v2 01/11] gobi: Limit number of premultiplexed contexts to 4 Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 02/11] gobi: Request dedicated WDS services for contexts Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 03/11] qmi: Enable _auto_ use for some classes Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 04/11] qmi: gprs-context: Declare qmi_service objects using _auto_ Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 05/11] qmi: Pass two dedicated WDS services to gprs-context Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 06/11] qmi: gprs-context: Remove parsing of unused TLVs Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 07/11] qmi: gprs-context: Treat IP family TLV as mandatory Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 08/11] qmi: gprs-context: Set up WDS service for IPv6 Denis Kenzior
2024-07-11 16:49 ` [PATCH v2 09/11] qmi: gprs-context: refactor detach_shutdown path Denis Kenzior
2024-07-11 16:49 ` Denis Kenzior [this message]
2024-07-11 16:49 ` [PATCH v2 11/11] qmi: gprs-context: Dual-Stack context activation support Denis Kenzior
2024-07-11 17:53 ` [PATCH v2 01/11] gobi: Limit number of premultiplexed contexts to 4 patchwork-bot+ofono
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240711164936.1688973-10-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.