port-qmi: restore driver initial MTU for mhi-net when resetting link

Kernel driver mhi-net sets a custom MTU for the netdevice: use the
same value when resetting the netdevice to its initial state.

This is important especially when rmnet is used on top of mhi-net,
since rmnet netdevices get their initial MTU from the mhi-net one.
This commit is contained in:
Daniele Palmas
2023-08-01 14:38:24 +02:00
committed by Aleksander Morgado
parent 639900ed36
commit 65e2db75ed

View File

@@ -33,6 +33,7 @@
/* as internally defined in the kernel */ /* as internally defined in the kernel */
#define RMNET_MAX_PACKET_SIZE 16384 #define RMNET_MAX_PACKET_SIZE 16384
#define MHI_NET_MTU_DEFAULT 16384
G_DEFINE_TYPE (MMPortQmi, mm_port_qmi, MM_TYPE_PORT) G_DEFINE_TYPE (MMPortQmi, mm_port_qmi, MM_TYPE_PORT)
@@ -977,6 +978,7 @@ internal_reset (MMPortQmi *self,
{ {
GTask *task; GTask *task;
InternalResetContext *ctx; InternalResetContext *ctx;
guint mtu;
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
@@ -985,12 +987,18 @@ internal_reset (MMPortQmi *self,
ctx->device = g_object_ref (device); ctx->device = g_object_ref (device);
g_task_set_task_data (task, ctx, (GDestroyNotify) internal_reset_context_free); g_task_set_task_data (task, ctx, (GDestroyNotify) internal_reset_context_free);
/* mhi_net has a custom default MTU set by the kernel driver */
if (g_strcmp0 (self->priv->net_driver, "mhi_net") == 0)
mtu = MHI_NET_MTU_DEFAULT;
else
mtu = MM_PORT_NET_MTU_DEFAULT;
/* first, bring down main interface */ /* first, bring down main interface */
mm_obj_dbg (self, "bringing down data interface '%s'", mm_obj_dbg (self, "bringing down data interface '%s'",
mm_port_get_device (ctx->data)); mm_port_get_device (ctx->data));
mm_port_net_link_setup (MM_PORT_NET (ctx->data), mm_port_net_link_setup (MM_PORT_NET (ctx->data),
FALSE, FALSE,
MM_PORT_NET_MTU_DEFAULT, mtu,
NULL, NULL,
(GAsyncReadyCallback) net_link_down_ready, (GAsyncReadyCallback) net_link_down_ready,
task); task);