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

Commit 9b73bf5d authored by Sujeev Dias's avatar Sujeev Dias
Browse files

mhi: mhi_rmnet: pass maximum payload size to mhi during registration



MHI host require clients to provide maximum payload size
during active transfer so MHI host can pre-allocate bounce
buffers.

CRs-Fixed: 1110280
Change-Id: I9a8fcb8dbb711cdd35dfc12b47b4381bf0985134
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 7d0efe30
Loading
Loading
Loading
Loading
+49 −21
Original line number Diff line number Diff line
MSM MHI RMNET interface device

MHI RMNET provides a network interface over PCIe
to transfer IP packets between modem and apps.

Required properties:
- compatible : "qcom,mhi-rmnet"
- At least one of MHI channel
  - qcom,mhi-rx-channel : MHI channel number for incoming data
  - qcom,mhi-tx-channel : MHI channel number for outgoing data
- Default MRU for interface
MHI RMNET provides a network interface over PCIe to transfer IP packets
between modem and apps.

==============
Node Structure
==============

Main node properties:

- compatible
  Usage: required
  Value type: <string>
  Definition: "qcom,mhi-rmnet"

- qcom,mhi-rx-channel
  Usage: optional if mhi-tx-channel is defined.
  Value type: <u32>
  Definition: MHI channel number for incoming data

- qcom,mhi-tx-channel
  Usage: optional if mhi-rx-channel is defined.
  Value type: <u32>
  Definition: MHI channel number for outgoing data

- qcom,mhi-mru
- Alias id to identify interface instance
  Usage: required
  Value type: <u32>
  Definition: Default payload size for receive path.

- qcom,mhi-max-mru
  Usage: optional
  Value type: <u32>
  Definition: Maximum payload interface support on receive path.  If
	not defined MHI_MAX_MRU is used.

- qcom,mhi-max-mtu
  Usage: optional
  Value type: <u32>
  Definition: Maximum payload interface support on transmit path.  If
	not defined MHI_MAX_MTU is used.

========
Example:
	aliases {
		mhi_rmnet0 = &mhi_rmnet_0;
	};
========
mhi_rmnet_0: qcom,mhi-rmnet@0 {
	compatible = "qcom,mhi-rmnet";
	qcom,mhi-rx-channel = <101>;
+33 −5
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -88,6 +88,8 @@ struct rmnet_mhi_private {
	struct sk_buff_head           rx_buffers;
	atomic_t		      rx_pool_len;
	u32			      mru;
	u32			      max_mru;
	u32			      max_mtu;
	struct napi_struct            napi;
	gfp_t                         allocation_flags;
	uint32_t                      tx_buffers_max;
@@ -583,7 +585,10 @@ static int rmnet_mhi_stop(struct net_device *dev)

static int rmnet_mhi_change_mtu(struct net_device *dev, int new_mtu)
{
	if (0 > new_mtu || MHI_MAX_MTU < new_mtu)
	struct rmnet_mhi_private *rmnet_mhi_ptr =
			*(struct rmnet_mhi_private **)netdev_priv(dev);

	if (0 > new_mtu || rmnet_mhi_ptr->max_mtu < new_mtu)
		return -EINVAL;

	dev->mtu = new_mtu;
@@ -666,11 +671,12 @@ static int rmnet_mhi_ioctl_extended(struct net_device *dev, struct ifreq *ifr)

	switch (ext_cmd.extended_ioctl) {
	case RMNET_IOCTL_SET_MRU:
		if ((0 == ext_cmd.u.data) || (ext_cmd.u.data > MHI_MAX_MRU)) {
		if ((0 == ext_cmd.u.data) ||
		    (ext_cmd.u.data > rmnet_mhi_ptr->max_mru)) {
			rmnet_log(rmnet_mhi_ptr,
				  MSG_CRITICAL,
				  "Can't set MRU, value %u is invalid\n",
				  ext_cmd.u.data);
				  "Can't set MRU, value:%u is invalid max:%u\n",
				  ext_cmd.u.data, rmnet_mhi_ptr->max_mru);
			return -EINVAL;
		}
		rmnet_log(rmnet_mhi_ptr,
@@ -1183,6 +1189,26 @@ static int rmnet_mhi_probe(struct platform_device *pdev)
		goto probe_fail;
	}

	rc = of_property_read_u32(pdev->dev.of_node,
				  "qcom,mhi-max-mru",
				  &rmnet_mhi_ptr->max_mru);
	if (likely(rc)) {
		rmnet_log(rmnet_mhi_ptr, MSG_INFO,
			  "max-mru not defined, setting to max %d\n",
			  MHI_MAX_MRU);
		rmnet_mhi_ptr->max_mru = MHI_MAX_MRU;
	}

	rc = of_property_read_u32(pdev->dev.of_node,
				  "qcom,mhi-max-mtu",
				  &rmnet_mhi_ptr->max_mtu);
	if (likely(rc)) {
		rmnet_log(rmnet_mhi_ptr, MSG_INFO,
			  "max-mtu not defined, setting to max %d\n",
			  MHI_MAX_MTU);
		rmnet_mhi_ptr->max_mtu = MHI_MAX_MTU;
	}

	client_info.dev = &pdev->dev;
	client_info.node_name = "qcom,mhi";
	client_info.mhi_client_cb = rmnet_mhi_cb;
@@ -1194,6 +1220,7 @@ static int rmnet_mhi_probe(struct platform_device *pdev)
	if (rc == 0) {
		rmnet_mhi_ptr->tx_channel = channel;
		client_info.chan = channel;
		client_info.max_payload = rmnet_mhi_ptr->max_mtu;

		rc = mhi_register_channel(&rmnet_mhi_ptr->tx_client_handle,
					  &client_info);
@@ -1213,6 +1240,7 @@ static int rmnet_mhi_probe(struct platform_device *pdev)
				  &channel);
	if (rc == 0) {
		rmnet_mhi_ptr->rx_channel = channel;
		client_info.max_payload = rmnet_mhi_ptr->max_mru;
		client_info.chan = channel;
		rc = mhi_register_channel(&rmnet_mhi_ptr->rx_client_handle,
					  &client_info);