All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, ioana.ciornei@nxp.com,
	laurentiu.tudor@nxp.com, madalin.bucur@nxp.com,
	horia.geanta@nxp.com
Subject: Re: [PATCH net-next] [RFC] dpaa2-eth: Move DPAA2 Ethernet driver from staging to drivers/net
Date: Fri, 3 Aug 2018 18:42:39 +0200	[thread overview]
Message-ID: <20180803164239.GG15029@lunn.ch> (raw)
In-Reply-To: <20180803161221.6322-1-ruxandra.radulescu@nxp.com>

> +static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
> +{
> +	struct device *dev;
> +	struct net_device *net_dev = NULL;
> +	struct dpaa2_eth_priv *priv = NULL;
> +	int err = 0;
> +
> +	dev = &dpni_dev->dev;
> +
> +	/* Net device */
> +	net_dev = alloc_etherdev_mq(sizeof(*priv), DPAA2_ETH_MAX_TX_QUEUES);
> +	if (!net_dev) {
> +		dev_err(dev, "alloc_etherdev_mq() failed\n");
> +		return -ENOMEM;
> +	}
> +
> +	SET_NETDEV_DEV(net_dev, dev);
> +	dev_set_drvdata(dev, net_dev);
> +
> +	priv = netdev_priv(net_dev);
> +	priv->net_dev = net_dev;
> +
> +	priv->iommu_domain = iommu_get_domain_for_dev(dev);
> +
> +	/* Obtain a MC portal */
> +	err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
> +				     &priv->mc_io);
> +	if (err) {
> +		if (err == -ENXIO)
> +			err = -EPROBE_DEFER;
> +		else
> +			dev_err(dev, "MC portal allocation failed\n");
> +		goto err_portal_alloc;
> +	}
> +
> +	/* MC objects initialization and configuration */
> +	err = setup_dpni(dpni_dev);
> +	if (err)
> +		goto err_dpni_setup;
> +
> +	err = setup_dpio(priv);
> +	if (err)
> +		goto err_dpio_setup;
> +
> +	setup_fqs(priv);
> +
> +	err = setup_dpbp(priv);
> +	if (err)
> +		goto err_dpbp_setup;
> +
> +	err = bind_dpni(priv);
> +	if (err)
> +		goto err_bind;
> +
> +	/* Add a NAPI context for each channel */
> +	add_ch_napi(priv);
> +
> +	/* Percpu statistics */
> +	priv->percpu_stats = alloc_percpu(*priv->percpu_stats);
> +	if (!priv->percpu_stats) {
> +		dev_err(dev, "alloc_percpu(percpu_stats) failed\n");
> +		err = -ENOMEM;
> +		goto err_alloc_percpu_stats;
> +	}
> +	priv->percpu_extras = alloc_percpu(*priv->percpu_extras);
> +	if (!priv->percpu_extras) {
> +		dev_err(dev, "alloc_percpu(percpu_extras) failed\n");
> +		err = -ENOMEM;
> +		goto err_alloc_percpu_extras;
> +	}
> +
> +	err = netdev_init(net_dev);
> +	if (err)
> +		goto err_netdev_init;

At the end of netdev_init() you call netdev_register(). From that
point on, you device is live. Its .ndo's can be called....

> +
> +	/* Configure checksum offload based on current interface flags */
> +	err = set_rx_csum(priv, !!(net_dev->features & NETIF_F_RXCSUM));
> +	if (err)
> +		goto err_csum;
> +
> +	err = set_tx_csum(priv, !!(net_dev->features &
> +				   (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)));
> +	if (err)
> +		goto err_csum;
> +
> +	err = alloc_rings(priv);
> +	if (err)
> +		goto err_alloc_rings;

How well does the device work if it has not allocated the rings yet,
when it is asked to do something?

> +
> +	net_dev->ethtool_ops = &dpaa2_ethtool_ops;
> +
> +	err = setup_irqs(dpni_dev);

How well do it work without interrupts being set up?

> +	if (err) {
> +		netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
> +		priv->poll_thread = kthread_run(poll_link_state, priv,
> +						"%s_poll_link", net_dev->name);
> +		if (IS_ERR(priv->poll_thread)) {
> +			netdev_err(net_dev, "Error starting polling thread\n");
> +			goto err_poll_thread;
> +		}
> +		priv->do_link_poll = true;
> +	}

Probably the correct place to register the netdev is here.

	 Andrew

  reply	other threads:[~2018-08-03 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 16:12 [PATCH net-next] [RFC] dpaa2-eth: Move DPAA2 Ethernet driver from staging to drivers/net Ioana Radulescu
2018-08-03 16:42 ` Andrew Lunn [this message]
2018-08-07 13:59   ` Ioana Ciocoi Radulescu
2018-08-07 13:59     ` Ioana Ciocoi Radulescu

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=20180803164239.GG15029@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=horia.geanta@nxp.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=ruxandra.radulescu@nxp.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.