netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Loic Poulain <loic.poulain@linaro.org>,
	davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, hemantk@codeaurora.org,
	manivannan.sadhasivam@linaro.org, eric.dumazet@gmail.com
Subject: Re: [PATCH v4 1/2] net: Add mhi-net driver
Date: Thu, 15 Oct 2020 14:41:43 +0200	[thread overview]
Message-ID: <ec2a1d76-d51f-7ec5-e2c1-5ed0eaf9a537@gmail.com> (raw)
In-Reply-To: <1602757888-3507-1-git-send-email-loic.poulain@linaro.org>



On 10/15/20 12:31 PM, Loic Poulain wrote:
> This patch adds a new network driver implementing MHI transport for
> network packets. Packets can be in any format, though QMAP (rmnet)
> is the usual protocol (flow control + PDN mux).
> 
> It support two MHI devices, IP_HW0 which is, the path to the IPA
> (IP accelerator) on qcom modem, And IP_SW0 which is the software
> driven IP path (to modem CPU).
> 
>
> +static int mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev)
> +{
> +	struct mhi_net_dev *mhi_netdev = netdev_priv(ndev);
> +	struct mhi_device *mdev = mhi_netdev->mdev;
> +	int err;
> +
> +	skb_tx_timestamp(skb);
> +
> +	/* mhi_queue_skb is not thread-safe, but xmit is serialized by the
> +	 * network core. Once MHI core will be thread save, migrate to
> +	 * NETIF_F_LLTX support.
> +	 */
> +	err = mhi_queue_skb(mdev, DMA_TO_DEVICE, skb, skb->len, MHI_EOT);
> +	if (err == -ENOMEM) {
> +		netif_stop_queue(ndev);

If you return NETDEV_TX_BUSY, this means this skb will be requeues,
then sent again right away, and this will potentially loop forever.

Also skb_tx_timestamp() would be called multiple times.

I suggest you drop the packet instead.

> +		return NETDEV_TX_BUSY;
> +	} else if (unlikely(err)) {
> +		net_err_ratelimited("%s: Failed to queue TX buf (%d)\n",
> +				    ndev->name, err);
> +		mhi_netdev->stats.tx_dropped++;
> +		kfree_skb(skb);
> +	}
> +
> +	return NETDEV_TX_OK;
> +}
> +
> +static void mhi_ndo_get_stats64(struct net_device *ndev,
> +				struct rtnl_link_stats64 *stats)
> +{
> +	struct mhi_net_dev *mhi_netdev = netdev_priv(ndev);
> +
> +	stats->rx_packets = mhi_netdev->stats.rx_packets;
> +	stats->rx_bytes = mhi_netdev->stats.rx_bytes;
> +	stats->rx_errors = mhi_netdev->stats.rx_errors;
> +	stats->rx_dropped = mhi_netdev->stats.rx_dropped;
> +	stats->tx_packets = mhi_netdev->stats.tx_packets;
> +	stats->tx_bytes = mhi_netdev->stats.tx_bytes;
> +	stats->tx_errors = mhi_netdev->stats.tx_errors;
> +	stats->tx_dropped = mhi_netdev->stats.tx_dropped;
> +}

This code is not correct on a 32bit kernel, since u64 values
can not be safely be read without extra care.



  parent reply	other threads:[~2020-10-15 12:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 10:31 [PATCH v4 1/2] net: Add mhi-net driver Loic Poulain
2020-10-15 10:33 ` Loic Poulain
2020-10-15 12:41 ` Eric Dumazet [this message]
2020-10-15 13:29   ` Loic Poulain
2020-10-15 18:56     ` Eric Dumazet
2020-10-16  8:27       ` Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec2a1d76-d51f-7ec5-e2c1-5ed0eaf9a537@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hemantk@codeaurora.org \
    --cc=kuba@kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).