Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c22c0e07 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa3: send usb-connect from rndis-ipa



To resolve the timing issue between usb-driver
and android framework, made the change on rndis
ipa to send the usb-connect msg when usb-driver
connect the IPA pipes.

Change-Id: I51de37bc7610cb0a94659c64146f10ed322210b2
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 541439b3
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -454,6 +454,11 @@ struct rndis_pkt_hdr rndis_template_hdr = {
	.zeroes = {0},
};

static void rndis_ipa_msg_free_cb(void *buff, u32 len, u32 type)
{
	kfree(buff);
}

/**
 * rndis_ipa_init() - create network device and initialize internal
 *  data structures
@@ -677,6 +682,8 @@ int rndis_ipa_pipe_connect_notify(
	int result;
	int ret;
	unsigned long flags;
	struct ipa_ecm_msg *rndis_msg;
	struct ipa_msg_meta msg_meta;

	RNDIS_IPA_LOG_ENTRY();

@@ -762,6 +769,26 @@ int rndis_ipa_pipe_connect_notify(
	}
	RNDIS_IPA_DEBUG("netif_carrier_on() was called\n");

	rndis_msg = kzalloc(sizeof(*rndis_msg), GFP_KERNEL);
	if (!rndis_msg) {
		result = -ENOMEM;
		goto fail;
	}

	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
	msg_meta.msg_type = ECM_CONNECT;
	msg_meta.msg_len = sizeof(struct ipa_ecm_msg);
	strlcpy(rndis_msg->name, rndis_ipa_ctx->net->name,
		IPA_RESOURCE_NAME_MAX);
	rndis_msg->ifindex = rndis_ipa_ctx->net->ifindex;

	result = ipa_send_msg(&msg_meta, rndis_msg, rndis_ipa_msg_free_cb);
	if (result) {
		RNDIS_IPA_ERROR("fail to send ECM_CONNECT for rndis\n");
		kfree(rndis_msg);
		goto fail;
	}

	spin_lock_irqsave(&rndis_ipa_ctx->state_lock, flags);
	next_state = rndis_ipa_next_state(rndis_ipa_ctx->state,
					  RNDIS_IPA_CONNECT);
@@ -1222,6 +1249,8 @@ int rndis_ipa_pipe_disconnect_notify(void *private)
	int retval;
	int ret;
	unsigned long flags;
	struct ipa_ecm_msg *rndis_msg;
	struct ipa_msg_meta msg_meta;

	RNDIS_IPA_LOG_ENTRY();

@@ -1253,6 +1282,24 @@ int rndis_ipa_pipe_disconnect_notify(void *private)
	netif_carrier_off(rndis_ipa_ctx->net);
	RNDIS_IPA_DEBUG("carrier_off notification was sent\n");

	rndis_msg = kzalloc(sizeof(*rndis_msg), GFP_KERNEL);
	if (!rndis_msg)
		return -ENOMEM;

	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
	msg_meta.msg_type = ECM_DISCONNECT;
	msg_meta.msg_len = sizeof(struct ipa_ecm_msg);
	strlcpy(rndis_msg->name, rndis_ipa_ctx->net->name,
		IPA_RESOURCE_NAME_MAX);
	rndis_msg->ifindex = rndis_ipa_ctx->net->ifindex;

	retval = ipa_send_msg(&msg_meta, rndis_msg, rndis_ipa_msg_free_cb);
	if (retval) {
		RNDIS_IPA_ERROR("fail to send ECM_DISCONNECT for rndis\n");
		kfree(rndis_msg);
		return -EPERM;
	}

	netif_stop_queue(rndis_ipa_ctx->net);
	RNDIS_IPA_DEBUG("queue stopped\n");