netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: 杨勇 <yangyong@neusoft.com>
To: 'Holger Brunck' <holger.brunck@keymile.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: netdev@vger.kernel.org,
	'Clive Stubbings' <clive.stubbings@xentech.co.uk>,
	'Vitaly Bordug' <vbordug@ru.mvista.com>
Subject: 答复: [PATCH] fs_enet: fix freescale FCC ethernet dp buffer alignment
Date: Fri, 17 Jun 2011 17:09:22 +0800	[thread overview]
Message-ID: <007701cc2cce$42342320$2804000a@yangyong> (raw)
In-Reply-To: <1308299439-5975-1-git-send-email-holger.brunck@keymile.com>

Hello,
Motioned to the memory aligned, now there is such requirement:
When the driver send an packet to hardware, the skb's address passed by
stack do a dma map into hardware, the skb's dma address must be 64-byte
aligned.
My method:
 Allocate a new skb which is 64-byte aligned, then copy the passed skb to
new one
After test, the driver can work and overcome this issue.
But I eager to get a perfect solution about that, could you offer me a nice
one? Thanks so much~~

Code:
static struct sk_buff * skb_align_copy(const struct sk_buff *skb, gfp_t
gfp_mask)
{
    if((skb->len + LEN_INFO_BYTES) > 2000 ){
        atomic_inc(&proc_stat[PROC_STAT_JUMBO_CNT]);
        return NULL;
    }    

    struct sk_buff *n;
    n = alloc_skb(2048, gfp_mask);  //0 headroom
    if(!n)
        return NULL;

    atomic_inc(&proc_stat[PROC_STAT_SKB_ALLOC]);
    skb_put(n, skb->len + LEN_INFO_BYTES);

    if((skb->data - LEN_INFO_BYTES) == NULL){
        c_err("skb->data - LEN_INFO_BYTES is NULL!\n");
        return NULL;
    }    
    memcpy(n->data, skb->data - LEN_INFO_BYTES, skb->len + LEN_INFO_BYTES);
    return n;
}
static int ne_pcie_tx_map(struct ne_pcie_ring* tx_ring, struct sk_buff* skb)
{
    struct ne_pcie_buff* buff;
    struct sk_buff* align_skb;
    int i = tx_ring->next_to_use;
    int len = skb->len;
    int count = 0;

    align_skb = skb_align_copy(skb, GFP_ATOMIC);
    if(!align_skb){
        goto dma_map_error;
    }

    buff = &tx_ring->buffer[i];
    buff->length = len+LEN_INFO_BYTES;
    buff->dma = pci_map_single(tx_ring->pci_dev, align_skb->data,
            len+LEN_INFO_BYTES, PCI_DMA_TODEVICE);
    if (pci_dma_mapping_error(tx_ring->pci_dev, buff->dma)) {
        goto dma_map_error;
    }



-----邮件原件-----
发件人: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
代表 Holger Brunck
发送时间: 2011年6月17日 16:31
收件人: linuxppc-dev@lists.ozlabs.org
抄送: Clive Stubbings; Holger Brunck; Pantelis Antoniou; Vitaly Bordug;
netdev@vger.kernel.org
主题: [PATCH] fs_enet: fix freescale FCC ethernet dp buffer alignment

From: Clive Stubbings <clive.stubbings@xentech.co.uk>

The RIPTR and TIPTR  (receive/transmit internal temporary data pointer),
used by microcode as a temporary buffer for data, must be 32-byte aligned
according to the RM for MPC8247.

Tested on mgcoge.

Signed-off-by: Clive Stubbings <clive.stubbings@xentech.co.uk>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
cc: Pantelis Antoniou <pantelis.antoniou@gmail.com>
cc: Vitaly Bordug <vbordug@ru.mvista.com>
cc: netdev@vger.kernel.org
---
This fixes a kernel crash on mgcoge when using SPI on CPM2 and
ethernet over FCC. Now fixed because the fcc driver now allocates
the space he really needs.

 drivers/net/fs_enet/mac-fcc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 7a84e45..7583a95 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -105,7 +105,7 @@ static int do_pd_setup(struct fs_enet_private *fep)
 		goto out_ep;
 
 	fep->fcc.mem = (void __iomem *)cpm2_immr;
-	fpi->dpram_offset = cpm_dpalloc(128, 8);
+	fpi->dpram_offset = cpm_dpalloc(128, 32);
 	if (IS_ERR_VALUE(fpi->dpram_offset)) {
 		ret = fpi->dpram_offset;
 		goto out_fcccp;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

  reply	other threads:[~2011-06-17  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17  8:30 [PATCH] fs_enet: fix freescale FCC ethernet dp buffer alignment Holger Brunck
2011-06-17  9:09 ` 杨勇 [this message]
2011-06-17 10:16   ` David Laight
2011-06-20  4:01     ` ??: " ??
2011-06-17 19:21 ` 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='007701cc2cce$42342320$2804000a@yangyong' \
    --to=yangyong@neusoft.com \
    --cc=clive.stubbings@xentech.co.uk \
    --cc=holger.brunck@keymile.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=vbordug@ru.mvista.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).