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

Commit b5f8ff31 authored by Bojun Pan's avatar Bojun Pan Committed by Amir Levy
Browse files

msm: ipa: Enable NAPI on IPA LAN CONS pipe



LAN RX optimization, change LAN RX data path bottom half
to run in softirq using NAPI. Also added an API for other
clients to see if we are using NAPI.

Change-Id: Iecd47f7412975b58786d81a5df3460de9aeffa21
Acked-by: default avatarTal Gelbard <tgelbard@qti.qualcomm.com>
Signed-off-by: default avatarBojun Pan <bojunp@codeaurora.org>
Signed-off-by: default avatarAmir Levy <alevy@codeaurora.org>
parent 757c4610
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3658,6 +3658,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
@@ -476,6 +476,8 @@ struct ipa_api_controller {

	int (*ipa_uc_debug_stats_dealloc)(uint32_t prot_id);

	bool (*ipa_get_lan_rx_napi)(void);

	void (*ipa_get_gsi_stats)(int prot_id,
		struct ipa_uc_dbg_ring_stats *stats);

+12 −3
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)
@@ -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);
	result = ecm_ipa_ctx->netif_rx_function(skb);
	if (unlikely(result))
		ECM_IPA_ERROR("fail on netif_rx\n");
		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;
}
+12 −2
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);
	result = rndis_ipa_ctx->netif_rx_function(skb);
	if (unlikely(result))
		RNDIS_IPA_ERROR("fail on netif_rx_ni\n");
		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;
}
+34 −1
Original line number Diff line number Diff line
@@ -4427,6 +4427,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;
@@ -5954,7 +5956,8 @@ 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);

	if (ipa3_ctx->lan_rx_napi_enable)
		napi_enable(&ipa3_ctx->napi_lan_rx);
	ipa3_trigger_ipa_ready_cbs();
	complete_all(&ipa3_ctx->init_completion_obj);
	pr_info("IPA driver initialization was successful.\n");
@@ -6347,6 +6350,15 @@ 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;
}

/**
 * ipa3_pre_init() - Initialize the IPA Driver.
 * This part contains all initialization which doesn't require IPA HW, such
@@ -6453,6 +6465,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())
@@ -6861,6 +6874,14 @@ 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*/
	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);
	}

	return 0;
fail_cdev_add:
fail_gsi_pre_fw_load_init:
@@ -7206,6 +7227,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");
@@ -8118,6 +8146,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