From: zhangfei <zhangfei.gao@linaro.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"arnd@arndb.de" <arnd@arndb.de>,
"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
"sergei.shtylyov@cogentembedded.com"
<sergei.shtylyov@cogentembedded.com>,
"David.Laight@ACULAB.COM" <David.Laight@ACULAB.COM>,
"eric.dumazet@gmail.com" <eric.dumazet@gmail.com>,
"haifeng.yan@linaro.org" <haifeng.yan@linaro.org>,
"jchxue@gmail.com" <jchxue@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] net: hisilicon: add hix5hd2 mac driver
Date: Wed, 28 May 2014 14:09:04 +0800 [thread overview]
Message-ID: <53857D80.50806@linaro.org> (raw)
In-Reply-To: <20140527135727.GC6969@leverpostej>
On 05/27/2014 09:57 PM, Mark Rutland wrote:
> On Tue, May 27, 2014 at 01:44:27PM +0100, Zhangfei Gao wrote:
>> Add support for the hix5hd2 XGMAC 1Gb ethernet device.
>> The controller requires two queues for tx and two queues for rx.
>> Controller fetch buffer from free queue and then push to used queue.
>> Diver should prepare free queue and free buffer from used queue.
>>
>> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
>> ---
>> drivers/net/ethernet/Kconfig | 1 +
>> drivers/net/ethernet/Makefile | 1 +
>> drivers/net/ethernet/hisilicon/Kconfig | 27 +
>> drivers/net/ethernet/hisilicon/Makefile | 5 +
>> drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 1057 +++++++++++++++++++++++++
>> 5 files changed, 1091 insertions(+)
>> create mode 100644 drivers/net/ethernet/hisilicon/Kconfig
>> create mode 100644 drivers/net/ethernet/hisilicon/Makefile
>> create mode 100644 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
>
> [...]
>
>> +struct hix5hd2_desc {
>> + __le32 buff_addr;
>> + __le32 cmd;
>> +} __aligned(32);
>
> [...]
>
>> +static void hix5hd2_rx_refill(struct hix5hd2_priv *priv)
>> +{
>> + struct hix5hd2_desc *desc;
>> + struct sk_buff *skb;
>> + u32 start, end, num, pos, i;
>> +
>> + /* software write pointer */
>> + start = dma_cnt(readl_relaxed(priv->base + RX_FQ_WR_ADDR));
>> + /* logic read pointer */
>> + end = dma_cnt(readl_relaxed(priv->base + RX_FQ_RD_ADDR));
>> + num = CIRC_SPACE(start, end, RX_DESC_NUM);
>> +
>> + for (i = 0, pos = start; i < num; i++) {
>> + if (priv->rx_skb[pos])
>> + break;
>> + else {
>> + skb = netdev_alloc_skb_ip_align(priv->netdev,
>> + MAC_MAX_FRAME_SIZE);
>> + if (unlikely(skb == NULL))
>> + break;
>> + }
>> +
>> + desc = priv->rx_fq.desc + pos;
>> + desc->buff_addr =
>> + dma_map_single(priv->dev, skb->data,
>> + MAC_MAX_FRAME_SIZE, DMA_FROM_DEVICE);
>
> buff_addr was declared as an __le32, but here we're pasting values of
> the kernel's native endianness (which might not be little). You will
> need to carefully convert the endianness of this value when dealing with
> it.
>
>> + if (dma_mapping_error(priv->dev, desc->buff_addr)) {
>> + dev_kfree_skb_any(skb);
>> + break;
>> + }
>> +
>> + priv->rx_skb[pos] = skb;
>> + desc->cmd = (MAC_MAX_FRAME_SIZE - 1) | DESC_VLD_FREE;
>
> Likewise cmd was described as an __le32 and needs to be converted
> appropriately.
>
Got it, will use le32_to_cpu & cpu_to_le32 for the conversion.
Thanks for the info.
prev parent reply other threads:[~2014-05-28 6:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 12:44 [PATCH v2 0/2] add hix5hd2 mac driver Zhangfei Gao
2014-05-27 12:44 ` [PATCH v2 1/2] Documentation: add Device tree bindings for Hisilicon hix5hd2 ethernet Zhangfei Gao
2014-05-27 13:34 ` Mark Rutland
2014-05-28 5:41 ` zhangfei
2014-05-28 12:53 ` Mark Rutland
2014-05-28 13:25 ` zhangfei
2014-05-28 14:58 ` Mark Rutland
2014-05-29 11:52 ` zhangfei
2014-05-27 12:44 ` [PATCH v2 2/2] net: hisilicon: add hix5hd2 mac driver Zhangfei Gao
2014-05-27 13:02 ` Tobias Klauser
2014-05-28 5:48 ` zhangfei
2014-05-27 13:57 ` Mark Rutland
2014-05-28 6:09 ` zhangfei [this message]
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=53857D80.50806@linaro.org \
--to=zhangfei.gao@linaro.org \
--cc=David.Laight@ACULAB.COM \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=eric.dumazet@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=haifeng.yan@linaro.org \
--cc=jchxue@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.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 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).