devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Sarath Babu Naidu Gaddam <sarath.babu.naidu.gaddam@amd.com>,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org
Cc: linux@armlinux.org.uk, michal.simek@amd.com,
	radhey.shyam.pandey@amd.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, anirudha.sarangi@amd.com,
	harini.katakam@amd.com, git@amd.com
Subject: Re: [PATCH net-next V3 3/3] net: axienet: Introduce dmaengine support
Date: Wed, 10 May 2023 12:10:37 +0200	[thread overview]
Message-ID: <a26c47fc-1915-bfde-2a3d-3902f153892e@linaro.org> (raw)
In-Reply-To: <20230510085031.1116327-4-sarath.babu.naidu.gaddam@amd.com>

On 10/05/2023 10:50, Sarath Babu Naidu Gaddam wrote:
> Add dmaengine framework to communicate with the xilinx DMAengine
> driver(AXIDMA).
> 
> Axi ethernet driver uses separate channels for transmit and receive.
> Add support for these channels to handle TX and RX with skb and
> appropriate callbacks. Also add axi ethernet core interrupt for



> +/**
> + * axienet_setup_dma_chan - request the dma channels.
> + * @ndev:       Pointer to net_device structure
> + *
> + * Return: 0, on success.
> + *          non-zero error value on failure
> + *
> + * This function requests the TX and RX channels. It also submits the
> + * allocated skb buffers and call back APIs to dmaengine.
> + *
> + */
> +static int axienet_setup_dma_chan(struct net_device *ndev)
> +{
> +	struct axienet_local *lp = netdev_priv(ndev);
> +	int i, ret;
> +
> +	lp->tx_chan = dma_request_chan(lp->dev, "tx_chan0");
> +	if (IS_ERR(lp->tx_chan)) {
> +		ret = PTR_ERR(lp->tx_chan);
> +		if (ret != -EPROBE_DEFER)
> +			netdev_err(ndev, "No Ethernet DMA (TX) channel found\n");

dev_err_probe seems suitable here.


> +		return ret;
> +	}
> +
> +	lp->rx_chan = dma_request_chan(lp->dev, "rx_chan0");
> +	if (IS_ERR(lp->rx_chan)) {
> +		ret = PTR_ERR(lp->rx_chan);
> +		if (ret != -EPROBE_DEFER)
> +			netdev_err(ndev, "No Ethernet DMA (RX) channel found\n");

dev_err_probe

> +		goto err_dma_request_rx;
> +	}
> +	lp->skb_cache = kmem_cache_create("ethernet", sizeof(struct axi_skbuff),
> +					  0, 0, NULL);
> +	if (!lp->skb_cache) {
> +		ret =  -ENOMEM;
> +		goto err_kmem;
> +	}
> +	/* TODO: Instead of BD_NUM_DEFAULT use runtime support*/
> +	for (i = 0; i < RX_BUF_NUM_DEFAULT; i++)
> +		axienet_rx_submit_desc(ndev);
> +	dma_async_issue_pending(lp->rx_chan);
> +
> +	return 0;
> +err_kmem:
> +	dma_release_channel(lp->rx_chan);
> +err_dma_request_rx:
> +	dma_release_channel(lp->tx_chan);
> +	return ret;
> +}
> +
> +/**
> + * axienet_init_dmaengine - init the dmaengine code.
> + * @ndev:       Pointer to net_device structure
> + *
> + * Return: 0, on success.
> + *          non-zero error value on failure
> + *
> + * This is the dmaengine initialization code.
> + */
> +static inline int axienet_init_dmaengine(struct net_device *ndev)
> +{
> +	int ret;
> +
> +	ret = axienet_setup_dma_chan(ndev);
> +
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  /**
>   * axienet_init_legacy_dma - init the dma legacy code.
>   * @ndev:       Pointer to net_device structure
> @@ -1239,7 +1520,20 @@ static int axienet_open(struct net_device *ndev)
>  
>  	phylink_start(lp->phylink);
>  
> -	if (!AXIENET_USE_DMA(lp)) {
> +	if (AXIENET_USE_DMA(lp)) {
> +		ret = axienet_init_dmaengine(ndev);
> +		if (ret < 0)
> +			goto error_code;
> +
> +		/* Enable interrupts for Axi Ethernet core (if defined) */
> +		if (lp->eth_irq > 0) {
> +			ret = request_irq(lp->eth_irq, axienet_eth_irq, IRQF_SHARED,
> +					  ndev->name, ndev);
> +			if (ret)
> +				goto error_code;
> +		}
> +
> +	} else {
>  		ret = axienet_init_legacy_dma(ndev);
>  		if (ret)
>  			goto error_code;
> @@ -1287,6 +1581,12 @@ static int axienet_stop(struct net_device *ndev)
>  		free_irq(lp->tx_irq, ndev);
>  		free_irq(lp->rx_irq, ndev);
>  		axienet_dma_bd_release(ndev);
> +	} else {
> +		dmaengine_terminate_all(lp->tx_chan);
> +		dmaengine_terminate_all(lp->rx_chan);
> +
> +		dma_release_channel(lp->rx_chan);
> +		dma_release_channel(lp->tx_chan);
>  	}
>  
>  	axienet_iow(lp, XAE_IE_OFFSET, 0);
> @@ -2136,6 +2436,33 @@ static int axienet_probe(struct platform_device *pdev)
>  		}
>  		netif_napi_add(ndev, &lp->napi_rx, axienet_rx_poll);
>  		netif_napi_add(ndev, &lp->napi_tx, axienet_tx_poll);
> +	} else {
> +		struct xilinx_vdma_config cfg;
> +		struct dma_chan *tx_chan;
> +
> +		lp->eth_irq = platform_get_irq_optional(pdev, 0);
> +		tx_chan = dma_request_chan(lp->dev, "tx_chan0");
> +
> +		if (IS_ERR(tx_chan)) {
> +			ret = PTR_ERR(tx_chan);
> +			if (ret != -EPROBE_DEFER)
> +				dev_err(&pdev->dev, "No Ethernet DMA (TX) channel found\n");

dev_err_probe

Best regards,
Krzysztof


  reply	other threads:[~2023-05-10 10:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10  8:50 [PATCH net-next V3 0/3] net: axienet: Introduce dmaengine Sarath Babu Naidu Gaddam
2023-05-10  8:50 ` [PATCH net-next V3 1/3] dt-bindings: net: xilinx_axienet: Introduce dmaengine binding support Sarath Babu Naidu Gaddam
2023-05-10 10:08   ` Krzysztof Kozlowski
2023-05-11 11:32     ` Gaddam, Sarath Babu Naidu
2023-05-12  6:27       ` Krzysztof Kozlowski
2023-05-17 12:06         ` Gaddam, Sarath Babu Naidu
2023-05-17 14:48           ` Krzysztof Kozlowski
2023-05-18  8:51             ` Gaddam, Sarath Babu Naidu
2023-05-10  8:50 ` [PATCH net-next V3 2/3] net: axienet: Preparatory changes for dmaengine support Sarath Babu Naidu Gaddam
2023-05-10 13:19   ` [EXT] " Subbaraya Sundeep Bhatta
2023-05-10  8:50 ` [PATCH net-next V3 3/3] net: axienet: Introduce " Sarath Babu Naidu Gaddam
2023-05-10 10:10   ` Krzysztof Kozlowski [this message]
2023-05-10 13:44   ` [EXT] " Subbaraya Sundeep Bhatta
2023-05-12  4:36     ` Gaddam, Sarath Babu Naidu

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=a26c47fc-1915-bfde-2a3d-3902f153892e@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=anirudha.sarangi@amd.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=git@amd.com \
    --cc=harini.katakam@amd.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=robh+dt@kernel.org \
    --cc=sarath.babu.naidu.gaddam@amd.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 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).