On Wed, Oct 28, 2020 at 05:34:58PM +0100, 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). > > Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxx> > --- > v2: - rebase on net-next > - remove useless skb_linearize > - check error type on mhi_queue return > - rate limited errors > - Schedule RX refill only on 'low' buf level > - SET_NETDEV_DEV in probe > - reorder device remove sequence > v3: - Stop channels on net_register error > - Remove useles parentheses > - Add driver .owner > v4: - prevent potential cpu hog in rx-refill loop > - Access mtu via READ_ONCE > v5: - Fix access to u64 stats > v6: - Stop TX queue earlier if queue is full > - Preventing 'abnormal' NETDEV_TX_BUSY path > v7: - Stop dl/ul cb operations on channel resetting > v8: - remove premature comment about TX threading gain > - check rx_queued to determine queuing limits > - fix probe error path (unified goto usage) > > drivers/net/Kconfig | 7 ++ > drivers/net/Makefile | 1 + > drivers/net/mhi_net.c | 313 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 321 insertions(+) > create mode 100644 drivers/net/mhi_net.c > [...] > +static int mhi_net_probe(struct mhi_device *mhi_dev, > + const struct mhi_device_id *id) > +{ > + const char *netname = (char *)id->driver_data; > + struct mhi_net_dev *mhi_netdev; > + struct net_device *ndev; > + struct device *dev = &mhi_dev->dev; > + int err; > + > + ndev = alloc_netdev(sizeof(*mhi_netdev), netname, NET_NAME_PREDICTABLE, > + mhi_net_setup); > + if (!ndev) > + return -ENOMEM; > + > + mhi_netdev = netdev_priv(ndev); > + dev_set_drvdata(dev, mhi_netdev); > + mhi_netdev->ndev = ndev; > + mhi_netdev->mdev = mhi_dev; > + SET_NETDEV_DEV(ndev, &mhi_dev->dev); > + > + /* All MHI net channels have 128 ring elements (at least for now) */ > + mhi_netdev->rx_queue_sz = 128; > + > + INIT_DELAYED_WORK(&mhi_netdev->rx_refill, mhi_net_rx_refill_work); > + u64_stats_init(&mhi_netdev->stats.rx_syncp); > + u64_stats_init(&mhi_netdev->stats.tx_syncp); > + > + /* Start MHI channels */ > + err = mhi_prepare_for_transfer(mhi_dev); > + if (err) > + goto out_prep_err; > + > + err = register_netdev(ndev); > + if (err) > + goto out_register_err; > + > + return 0; > + > +out_register_err: > + mhi_unprepare_from_transfer(mhi_dev); Missed this one. MHI stack will do this for you incase of failure. Thanks, Mani