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

Commit 2a04e169 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa: Enable NAPI on IPA LAN CONS pipe"

parents 37d3375f d45037d3
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3662,6 +3662,19 @@ int ipa_disable_wigig_pipe_i(enum ipa_client_type client)
}
EXPORT_SYMBOL(ipa_disable_wigig_pipe_i);

/**
 * ipa_get_lan_rx_napi() - returns if NAPI is enabled in LAN RX
 */
bool ipa_get_lan_rx_napi(void)
{
	bool ret;

	IPA_API_DISPATCH_RETURN_BOOL(ipa_get_lan_rx_napi);

	return ret;
}
EXPORT_SYMBOL(ipa_get_lan_rx_napi);

/**
 * ipa_tz_unlock_reg() - Allow AP access to memory regions controlled by TZ
 */
+2 −0
Original line number Diff line number Diff line
@@ -470,6 +470,8 @@ struct ipa_api_controller {
		bool (*teth_port_state)(void), enum ipa_client_type client);

	void (*ipa_deregister_client_callback)(enum ipa_client_type client);
	bool (*ipa_get_lan_rx_napi)(void);

};

#ifdef CONFIG_IPA3
+13 −4
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ enum ecm_ipa_operation {
 * @usb_to_ipa_client: producer client
 * @pm_hdl: handle for IPA PM
 * @is_vlan_mode: does the driver need to work in VLAN mode?
 * @netif_rx_function: holds the correct network stack API, needed for NAPI
 */
struct ecm_ipa_dev {
	struct net_device *net;
@@ -166,6 +167,7 @@ struct ecm_ipa_dev {
	enum ipa_client_type usb_to_ipa_client;
	u32 pm_hdl;
	bool is_vlan_mode;
	int (*netif_rx_function)(struct sk_buff *skb);
};

static int ecm_ipa_open(struct net_device *net);
@@ -286,6 +288,13 @@ int ecm_ipa_init(struct ecm_ipa_params *params)
	snprintf(net->name, sizeof(net->name), "%s%%d", "ecm");
	net->netdev_ops = &ecm_ipa_netdev_ops;
	net->watchdog_timeo = TX_TIMEOUT;
	if (ipa_get_lan_rx_napi()) {
		ecm_ipa_ctx->netif_rx_function = netif_receive_skb;
		ECM_IPA_DEBUG("LAN RX NAPI enabled = True");
	} else {
		ecm_ipa_ctx->netif_rx_function = netif_rx_ni;
		ECM_IPA_DEBUG("LAN RX NAPI enabled = False");
	}
	ECM_IPA_DEBUG("internal data structures were initialized\n");

	if (!params->device_ready_notify)
@@ -655,7 +664,7 @@ static void ecm_ipa_packet_receive_notify
		return;
	}

	if (evt != IPA_RECEIVE)	{
	if (unlikely(evt != IPA_RECEIVE)) {
		ECM_IPA_ERROR("A none IPA_RECEIVE event in ecm_ipa_receive\n");
		return;
	}
@@ -663,9 +672,9 @@ static void ecm_ipa_packet_receive_notify
	skb->dev = ecm_ipa_ctx->net;
	skb->protocol = eth_type_trans(skb, ecm_ipa_ctx->net);

	result = netif_rx(skb);
	if (result)
		ECM_IPA_ERROR("fail on netif_rx\n");
	result = ecm_ipa_ctx->netif_rx_function(skb);
	if (unlikely(result))
		ECM_IPA_ERROR("fail on netif_rx_function\n");
	ecm_ipa_ctx->net->stats.rx_packets++;
	ecm_ipa_ctx->net->stats.rx_bytes += packet_len;
}
+13 −3
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ enum rndis_ipa_operation {
 * @state_lock: used to protect the state variable.
 * @pm_hdl: handle for IPA PM framework
 * @is_vlan_mode: should driver work in vlan mode?
 * @netif_rx_function: holds the correct network stack API, needed for NAPI
 */
struct rndis_ipa_dev {
	struct net_device *net;
@@ -212,6 +213,7 @@ struct rndis_ipa_dev {
	spinlock_t state_lock; /* Spinlock for the state variable.*/
	u32 pm_hdl;
	bool is_vlan_mode;
	int (*netif_rx_function)(struct sk_buff *skb);
};

/**
@@ -623,6 +625,14 @@ int rndis_ipa_init(struct ipa_usb_init_params *params)
		("netdev:%s registration succeeded, index=%d\n",
		net->name, net->ifindex);

	if (ipa_get_lan_rx_napi()) {
		rndis_ipa_ctx->netif_rx_function = netif_receive_skb;
		RNDIS_IPA_DEBUG("LAN RX NAPI enabled = True");
	} else {
		rndis_ipa_ctx->netif_rx_function = netif_rx_ni;
		RNDIS_IPA_DEBUG("LAN RX NAPI enabled = False");
	}

	rndis_ipa = rndis_ipa_ctx;
	params->ipa_rx_notify = rndis_ipa_packet_receive_notify;
	params->ipa_tx_notify = rndis_ipa_tx_complete_notify;
@@ -1139,9 +1149,9 @@ static void rndis_ipa_packet_receive_notify(
	}

	trace_rndis_netif_ni(skb->protocol);
	result = netif_rx_ni(skb);
	if (result)
		RNDIS_IPA_ERROR("fail on netif_rx_ni\n");
	result = rndis_ipa_ctx->netif_rx_function(skb);
	if (unlikely(result))
		RNDIS_IPA_ERROR("fail on netif_rx_function\n");
	rndis_ipa_ctx->net->stats.rx_packets++;
	rndis_ipa_ctx->net->stats.rx_bytes += packet_len;
}
+45 −1
Original line number Diff line number Diff line
@@ -4268,6 +4268,8 @@ static int ipa3_setup_apps_pipes(void)
	sys_in.desc_fifo_sz = IPA_SYS_DESC_FIFO_SZ;
	sys_in.notify = ipa3_lan_rx_cb;
	sys_in.priv = NULL;
	if (ipa3_ctx->lan_rx_napi_enable)
		sys_in.napi_obj = &ipa3_ctx->napi_lan_rx;
	sys_in.ipa_ep_cfg.hdr.hdr_len = IPA_LAN_RX_HEADER_LENGTH;
	sys_in.ipa_ep_cfg.hdr_ext.hdr_little_endian = false;
	sys_in.ipa_ep_cfg.hdr_ext.hdr_total_len_or_pad_valid = true;
@@ -5512,6 +5514,13 @@ static int ipa3_alloc_gsi_channel(void)
	}
	return ret;
}

static inline void ipa3_enable_napi_lan_rx(void)
{
	if (ipa3_ctx->lan_rx_napi_enable)
		napi_enable(&ipa3_ctx->napi_lan_rx);
}

/**
 * ipa3_post_init() - Initialize the IPA Driver (Part II).
 * This part contains all initialization which requires interaction with
@@ -5803,7 +5812,7 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
	mutex_lock(&ipa3_ctx->lock);
	ipa3_ctx->ipa_initialization_complete = true;
	mutex_unlock(&ipa3_ctx->lock);

	ipa3_enable_napi_lan_rx();
	ipa3_trigger_ipa_ready_cbs();
	complete_all(&ipa3_ctx->init_completion_obj);
	pr_info("IPA driver initialization was successful.\n");
@@ -6196,6 +6205,24 @@ static bool ipa_is_mem_dump_allowed(void)
	return (desc.ret[0] == 1);
}

static int ipa3_lan_poll(struct napi_struct *napi, int budget)
{
	int rcvd_pkts = 0;

	rcvd_pkts = ipa3_lan_rx_poll(ipa3_ctx->clnt_hdl_data_in,
							NAPI_WEIGHT);
	return rcvd_pkts;
}

static inline void ipa3_enable_napi_netdev(void)
{
	if (ipa3_ctx->lan_rx_napi_enable) {
		init_dummy_netdev(&ipa3_ctx->lan_ndev);
		netif_napi_add(&ipa3_ctx->lan_ndev, &ipa3_ctx->napi_lan_rx,
				ipa3_lan_poll, NAPI_WEIGHT);
	}
}

/**
 * ipa3_pre_init() - Initialize the IPA Driver.
 * This part contains all initialization which doesn't require IPA HW, such
@@ -6302,6 +6329,7 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
		resource_p->secure_debug_check_action;
	ipa3_ctx->do_ram_collection_on_crash =
		resource_p->do_ram_collection_on_crash;
	ipa3_ctx->lan_rx_napi_enable = resource_p->lan_rx_napi_enable;

	if (ipa3_ctx->secure_debug_check_action == USE_SCM) {
		if (ipa_is_mem_dump_allowed())
@@ -6707,6 +6735,10 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
	/* proxy vote for modem is added in ipa3_post_init() phase */
	if (ipa3_ctx->ipa_hw_type != IPA_HW_v4_0)
		ipa3_proxy_clk_unvote();

	/* Create the dummy netdev for LAN RX NAPI*/
	ipa3_enable_napi_netdev();

	return 0;
fail_cdev_add:
fail_gsi_pre_fw_load_init:
@@ -7049,6 +7081,13 @@ static int get_ipa_dts_configuration(struct platform_device *pdev,
		ipa_drv_res->tethered_flow_control
		? "True" : "False");

	ipa_drv_res->lan_rx_napi_enable =
		of_property_read_bool(pdev->dev.of_node,
		"qcom,lan-rx-napi");
	IPADBG(": Enable LAN rx NAPI = %s\n",
		ipa_drv_res->lan_rx_napi_enable
		? "True" : "False");

	/* Get IPA wrapper address */
	resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
			"ipa-base");
@@ -7961,6 +8000,11 @@ struct ipa3_context *ipa3_get_ctx(void)
	return ipa3_ctx;
}

bool ipa3_get_lan_rx_napi(void)
{
	return ipa3_ctx->lan_rx_napi_enable;
}

static void ipa_gsi_notify_cb(struct gsi_per_notify *notify)
{
	/*
Loading