[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ec2a1d76-d51f-7ec5-e2c1-5ed0eaf9a537@gmail.com>
Date: Thu, 15 Oct 2020 14:41:43 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Loic Poulain <loic.poulain@...aro.org>, davem@...emloft.net,
kuba@...nel.org
Cc: netdev@...r.kernel.org, hemantk@...eaurora.org,
manivannan.sadhasivam@...aro.org, eric.dumazet@...il.com
Subject: Re: [PATCH v4 1/2] net: Add mhi-net driver
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.
Powered by blists - more mailing lists