All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, sergei.shtylyov@cogentembedded.com
Subject: Re: [PATCH RFC 5/6] net/faraday: Enable NCSI interface
Date: Mon, 09 Nov 2015 11:32:07 +1100	[thread overview]
Message-ID: <1447029127.8727.29.camel@kernel.crashing.org> (raw)
In-Reply-To: <1447027806-4744-6-git-send-email-gwshan@linux.vnet.ibm.com>

On Mon, 2015-11-09 at 11:10 +1100, Gavin Shan wrote:
> 
> -	if (likely(netif_running(netdev))) {
> +	/* When running in NCSI mode, the interface should be
> +	 * ready to receive or transmit NCSI packet before it's
> +	 * opened.
> +	 */

No, that's not right. open/close is when a driver allocates it's data
structures, DMA ring descriptors, packet buffers etc... and request
it's interrupts.

You cannot expect packets to flow on a closed interface and you
shouldn't be getting any interrupts on a closed interface either.

> +	if (likely(priv->use_ncsi || netif_running(netdev))) {
>  		/* Disable interrupts for polling */
>  		iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
>  		napi_schedule(&priv->napi);
> @@ -1162,8 +1168,18 @@ static int ftgmac100_open(struct net_device
> *netdev)
>  
>  	/* enable all interrupts */
>  	iowrite32(INT_MASK_ALL_ENABLED, priv->base +
> FTGMAC100_OFFSET_IER);
> +	/* Start the NCSI device */
> +	if (priv->use_ncsi){
> +		err = ncsi_start_dev(priv->ndev);
> +		if (err)
> +			goto err_ncsi;
> +	}
>  	return 0;
>  
> +err_ncsi:
> +	napi_disable(&priv->napi);
> +	netif_stop_queue(netdev);
> +	iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
>  err_hw:
>  	free_irq(priv->irq, netdev);
>  err_irq:
> @@ -1172,7 +1188,7 @@ err_alloc:
>  	return err;
>  }
>  
> -static int ftgmac100_stop(struct net_device *netdev)
> +static int ftgmac100_stop_dev(struct net_device *netdev)
>  {
>  	struct ftgmac100 *priv = netdev_priv(netdev);
>  
> @@ -1191,6 +1207,18 @@ static int ftgmac100_stop(struct net_device
> *netdev)
>  	return 0;
>  }
>  
> +static int ftgmac100_stop(struct net_device *netdev)
> +{
> +	struct ftgmac100 *priv = netdev_priv(netdev);
> +
> +	/* Stop NCSI device */
> +	if (priv->use_ncsi) {
> +		ncsi_stop_dev(priv->ndev);
> +		return 0;
> +	}
> +
> +	return ftgmac100_stop_dev(netdev);
> +}
>  static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
>  				     struct net_device *netdev)
>  {
> @@ -1291,6 +1319,21 @@ static const struct net_device_ops
> ftgmac100_netdev_ops = {
>  	.ndo_do_ioctl		= ftgmac100_do_ioctl,
>  };
>  
> +static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
> +{
> +	struct net_device *netdev = nd->nd_dev;
> +
> +	if (nd->nd_state != ncsi_dev_state_functional)
> +		return;
> +
> +	if (nd->nd_link_up) {
> +		pr_info("NCSI dev is up\n");
> +		netif_start_queue(netdev);
> +	} else {
> +		pr_info("NCSI dev is down\n");
> +		ftgmac100_stop_dev(netdev);
> +	}
> +}
>  /*******************************************************************
> ***********
>   * struct platform_driver functions
>  
> *********************************************************************
> ********/
> @@ -1300,7 +1343,7 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  	int irq;
>  	struct net_device *netdev;
>  	struct ftgmac100 *priv;
> -	int err;
> +	int err = 0;
>  
>  	if (!pdev)
>  		return -ENODEV;
> @@ -1320,7 +1363,17 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  		goto err_alloc_etherdev;
>  	}
>  
> +	/* Check for NCSI mode */
> +	priv = netdev_priv(netdev);
>  	SET_NETDEV_DEV(netdev, &pdev->dev);
> +	if (pdev->dev.of_node &&
> +	    of_get_property(pdev->dev.of_node, "use-nc-si", NULL)) {
> +		dev_info(&pdev->dev, "Using NCSI interface\n");
> +		priv->phydev = NULL;
> +		priv->use_ncsi = true;
> +	} else {
> +		priv->use_ncsi = false;
> +	}
>  
>  	netdev->ethtool_ops = &ftgmac100_ethtool_ops;
>  	netdev->netdev_ops = &ftgmac100_netdev_ops;
> @@ -1329,7 +1382,6 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  	platform_set_drvdata(pdev, netdev);
>  
>  	/* setup private data */
> -	priv = netdev_priv(netdev);
>  	priv->netdev = netdev;
>  	priv->dev = &pdev->dev;
>  
> @@ -1356,24 +1408,14 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  
>  	priv->irq = irq;
>  
> -	/* Check for NC-SI mode */
> -	if (pdev->dev.of_node &&
> -	    of_get_property(pdev->dev.of_node, "use-nc-si", NULL))
> -		priv->use_ncsi = true;
> -	else
> -		priv->use_ncsi = false;
> +	/* Read MAC address or setup a new one */
> +	ftgmac100_setup_mac(priv);
>  
> -	/* If we use NC-SI, we need to set that up, which isn't
> implemented yet
> -	 * so we pray things were setup by the bootloader and just
> mark our link
> -	 * as up (otherwise we can't get packets through).
> -	 *
> -	 * Eventually, we'll have a proper NC-SI stack as a helper
> we can
> -	 * instanciate
> -	 */
> +	/* Register NCSI device */
>  	if (priv->use_ncsi) {
> -		/* XXX */
> -		priv->phydev = NULL;
> -		dev_info(&pdev->dev, "Using NC-SI interface\n");
> +		priv->ndev = ncsi_register_dev(netdev,
> ftgmac100_ncsi_handler);
> +		if (!priv->ndev)
> +			goto err_ncsi_dev;
>  	} else {
>  		err = ftgmac100_setup_mdio(priv);
>  
> @@ -1384,9 +1426,6 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  			dev_warn(&pdev->dev, "Error %d setting up
> MDIO\n", err);
>  	}
>  
> -	/* Read MAC address or setup a new one */
> -	ftgmac100_setup_mac(priv);
> -
>  	/* Register network device */
>  	err = register_netdev(netdev);
>  	if (err) {
> @@ -1399,7 +1438,11 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
>  	return 0;
>  
>  err_register_netdev:
> -	ftgmac100_destroy_mdio(priv);
> +	if (!priv->use_ncsi)
> +		ftgmac100_destroy_mdio(priv);
> +	else
> +		ncsi_unregister_dev(priv->ndev);
> +err_ncsi_dev:
>  	iounmap(priv->base);
>  err_ioremap:
>  	release_resource(priv->res);

  reply	other threads:[~2015-11-09  0:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  0:10 [PATCH RFC 0/6] NCSI Support Gavin Shan
2015-11-09  0:10 ` [PATCH RFC 1/6] net/ncsi: Resource management Gavin Shan
2015-11-09  0:10 ` [PATCH RFC 2/6] net/ncsi: Packet handler Gavin Shan
2015-11-09  0:41   ` Benjamin Herrenschmidt
2015-11-09  0:10 ` [PATCH RFC 3/6] net/ncsi: Manage NCSI device Gavin Shan
2015-11-09  0:10 ` [PATCH RFC 4/6] net/faraday: Replace use_nc_si with use_ncsi Gavin Shan
2015-11-09  0:30   ` Benjamin Herrenschmidt
2015-11-09  0:45     ` Gavin Shan
2015-11-09  0:10 ` [PATCH RFC 5/6] net/faraday: Enable NCSI interface Gavin Shan
2015-11-09  0:32   ` Benjamin Herrenschmidt [this message]
2015-11-09  7:30     ` Gavin Shan
2015-11-09 20:28       ` Benjamin Herrenschmidt
2015-11-10  6:12         ` Gavin Shan
2015-11-10 10:34           ` Benjamin Herrenschmidt
2015-11-09  0:10 ` [PATCH RFC 6/6] net/faraday: Enable offload checksum according to device-tree Gavin Shan
2015-11-09  0:36   ` Benjamin Herrenschmidt
2015-11-09  0:45     ` Gavin Shan
2016-02-24  2:59 ` [PATCH RFC 0/6] NCSI Support Gavin Shan
2016-02-24 14:49   ` David Miller

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=1447029127.8727.29.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=gwshan@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.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.