netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Fugang Duan <b38611@freescale.com>
Cc: b20596@freescale.com, davem@davemloft.net,
	ezequiel.garcia@free-electrons.com, netdev@vger.kernel.org,
	shawn.guo@linaro.org, bhutchings@solarflare.com,
	stephen@networkplumber.org
Subject: Re: [PATCH v1 5/6] net: fec: Add Scatter/gather support
Date: Thu, 29 May 2014 21:37:52 -0700	[thread overview]
Message-ID: <1401424672.3645.68.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <1401415552-2263-6-git-send-email-b38611@freescale.com>

On Fri, 2014-05-30 at 10:05 +0800, Fugang Duan wrote:
> Add Scatter/gather support for FEC.
> This feature allows to improve outbound throughput performance.
> Running iperf tests shows a 55.4% improvement, tested on imx6dl sabresd
> board.


> +			bufaddr = fep->tx_bounce[index];
> +		}
> +		if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
> +			swap_buffer(bufaddr, frag_len);


bufaddr is a page fragment and can be shared (using sendfile() for
example), we cannot modify the content using swap_buffer().

In order to do the swap, you need to force the copy to tx_bounce buffer.



> +		bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr,
> +						frag_len, DMA_TO_DEVICE);
> +		if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
> +			dev_kfree_skb_any(skb);
> +			if (net_ratelimit())
> +				netdev_err(ndev, "Tx DMA memory map failed\n");
> +			goto dma_mapping_error;
> +		}
> +
> +		bdp->cbd_datlen = frag_len;
> +		bdp->cbd_sc = status;
> +	}
> +
> +	fep->cur_tx = bdp;
> +
> +	return 0;
> +
> +dma_mapping_error:
>  	bdp = fep->cur_tx;
> +	for (i = 0; i < frag; i++) {
> +		bdp = fec_enet_get_nextdesc(bdp, fep);
> +		dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr,
> +				bdp->cbd_datlen, DMA_TO_DEVICE);
> +	}
> +	return NETDEV_TX_OK;
> +}
>  
> -	status = bdp->cbd_sc;
> +static int fec_enet_txq_submit_skb(struct sk_buff *skb, struct net_device *ndev)
> +{
> +	struct fec_enet_private *fep = netdev_priv(ndev);
> +	const struct platform_device_id *id_entry =
> +				platform_get_device_id(fep->pdev);
> +	int nr_frags = skb_shinfo(skb)->nr_frags;
> +	struct bufdesc *bdp, *last_bdp;
> +	void *bufaddr;
> +	unsigned short status;
> +	unsigned short buflen;
> +	unsigned int estatus = 0;
> +	unsigned int index;
> +	int ret;
>  
>  	/* Protocol checksum off-load for TCP and UDP. */
>  	if (fec_enet_clear_csum(skb, ndev)) {
> @@ -349,17 +462,18 @@ static int txq_submit_skb(struct sk_buff *skb, struct net_device *ndev)
>  		return NETDEV_TX_OK;
>  	}
>  
> -	/* Clear all of the status flags */
> +	/* Fill in a Tx ring entry */
> +	bdp = fep->cur_tx;
> +	status = bdp->cbd_sc;
>  	status &= ~BD_ENET_TX_STATS;
>  
>  	/* Set buffer length and buffer pointer */
>  	bufaddr = skb->data;
> -	bdp->cbd_datlen = skb->len;
> +	buflen = skb_headlen(skb);
>  
>  	index = fec_enet_get_bd_index(bdp, fep);
> -
>  	if (((unsigned long) bufaddr) & FEC_ALIGNMENT) {
> -		memcpy(fep->tx_bounce[index], skb->data, skb->len);
> +		memcpy(fep->tx_bounce[index], skb->data, buflen);
>  		bufaddr = fep->tx_bounce[index];
>  	}
>  
> @@ -369,62 +483,66 @@ static int txq_submit_skb(struct sk_buff *skb, struct net_device *ndev)
>  	 * swap every frame going to and coming from the controller.
>  	 */
>  	if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
> -		swap_buffer(bufaddr, skb->len);
> -
> -	/* Save skb pointer */
> -	fep->tx_skbuff[index] = skb;
> +		swap_buffer(bufaddr, buflen);

Same problem here, a driver is certainly not allowed to mess with
skb->data.

  reply	other threads:[~2014-05-30  4:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30  2:05 [PATCH v1 0/6] *** net: fec: Enable Software TSO to improve the tx performance *** Fugang Duan
2014-05-30  2:05 ` [PATCH v1 1/6] net: fec: Factorize the .xmit transmit function Fugang Duan
2014-05-30  2:05 ` [PATCH v1 2/6] net: fec: Enable IP header hardware checksum Fugang Duan
2014-05-30  2:05 ` [PATCH v1 3/6] net: fec: Factorize feature setting Fugang Duan
2014-05-30  2:05 ` [PATCH v1 4/6] net: fec: Increase buffer descriptor entry number Fugang Duan
2014-05-30  9:10   ` David Laight
2014-05-30  9:42     ` fugang.duan
2014-05-30 13:13       ` Eric Dumazet
2014-05-30 14:01         ` ezequiel.garcia
2014-05-30 14:54           ` Eric Dumazet
2014-05-30 15:08             ` fugang.duan
2014-05-30 15:34               ` David Laight
2014-05-30 15:52                 ` fugang.duan
2014-05-30 15:58                 ` Eric Dumazet
2014-05-30 16:35                   ` ezequiel.garcia
2014-05-30 15:40               ` Eric Dumazet
2014-05-30 15:46                 ` fugang.duan
2014-05-30  2:05 ` [PATCH v1 5/6] net: fec: Add Scatter/gather support Fugang Duan
2014-05-30  4:37   ` Eric Dumazet [this message]
2014-05-30  4:48     ` fugang.duan
2014-05-30 14:26   ` Frank.Li
2014-05-30  2:05 ` [PATCH v1 6/6] net: fec: Add software TSO support Fugang Duan
2014-05-30  6:30   ` Eric Dumazet
2014-05-30  7:16     ` fugang.duan
2014-05-30 16:21       ` Eric Dumazet
2014-06-01  0:55         ` fugang.duan
2014-06-01  1:39           ` Eric Dumazet
2014-06-01  2:25             ` fugang.duan

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=1401424672.3645.68.camel@edumazet-glaptop2.roam.corp.google.com \
    --to=eric.dumazet@gmail.com \
    --cc=b20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=stephen@networkplumber.org \
    /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).