All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Eli Cohen <eli@dev.mellanox.co.il>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Eli Cohen <eli@mellanox.co.il>,
	linuxppc-dev@lists.ozlabs.org,
	Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>,
	Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Subject: Re: [PATCH] mlx4_en: fix transmit of packages when blue frame is enabled
Date: Mon, 10 Oct 2011 09:32:00 +0200	[thread overview]
Message-ID: <1318231920.29415.404.camel@pasglop> (raw)
In-Reply-To: <20111009103020.GL2681@mtldesk30>

On Sun, 2011-10-09 at 12:30 +0200, Eli Cohen wrote:

> > Ideally you want to avoid that swapping altogether and use the right
> > accessor that indicates that your register is BE to start with. IE.
> > remove the swab32 completely and then use something like 
> > iowrite32be() instead of writel().
> I agree, this looks better but does it work on memory mapped io or
> only on io pci space? All our registers are memory mapped...

The iomap functions work on both.

> > Basically, the problem you have is that writel() has an implicit "write
> > to LE register" semantic. Your register is BE. the "iomap" variants
> > provide you with more fine grained "be" variants to use in that case.
> > There's also writel_be() but that one doesn't exist on every
> > architecture afaik.
> So writel_be is the function I should use for memory mapped io? If it
> does not exist for all platforms it's a pitty :-(

Just use the iomap variant. Usually you also use pci_iomap() instead of
ioremap() but afaik, for straight MMIO, it works with normal ioremap as
well.

> > Now, once the mmio problem is out of the way, let's look back at how you
> > then use that qpn.
> > 
> > With the current code, you've generated something in memory which is
> > byte reversed, so essentially "LE" on ppc and "BE" on x86.
> > 
> > Then, this statement:
> > 
> > *(u32 *) (&tx_desc->ctrl.vlan_tag) |= ring->doorbell_qpn;
> > 
> > Will essentially write it out as-is in memory for use by the chip. The chip,
> > from what you say, expects BE, so this will be broken on PPC.
> I see. So this field is layed in le for ppc and the rest of the
> descriptor is be. so I assum that __iowrite64_copy() does not swap
> anything but we still have tx_desc->ctrl.vlan_tag in the wrong
> endianess.

Yes because you had swapped it initially. IE your original swab32 is
what busts it for you on ppc.

> > Here too, the right solution is to instead not do that swab32 to begin
> > with (ring->doorbell_qpn remains a native endian value) and instead do,
> > in addition to the above mentioned change to the writel:
> > 
> > 	*(u32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn);
> > 
> > (Also get rid of that cast and define vlan_tag as a __be32 to start
> > with).
> > 
> > Cheers,
> > Ben.
> 
> Thanks for your review. I will send another patch which should fix the
> deficiencies.

Cheers,
Ben.

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Eli Cohen <eli@dev.mellanox.co.il>
Cc: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>,
	Yevgeny Petrilin <yevgenyp@mellanox.co.il>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Eli Cohen <eli@mellanox.co.il>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] mlx4_en: fix transmit of packages when blue frame is enabled
Date: Mon, 10 Oct 2011 09:32:00 +0200	[thread overview]
Message-ID: <1318231920.29415.404.camel@pasglop> (raw)
In-Reply-To: <20111009103020.GL2681@mtldesk30>

On Sun, 2011-10-09 at 12:30 +0200, Eli Cohen wrote:

> > Ideally you want to avoid that swapping altogether and use the right
> > accessor that indicates that your register is BE to start with. IE.
> > remove the swab32 completely and then use something like 
> > iowrite32be() instead of writel().
> I agree, this looks better but does it work on memory mapped io or
> only on io pci space? All our registers are memory mapped...

The iomap functions work on both.

> > Basically, the problem you have is that writel() has an implicit "write
> > to LE register" semantic. Your register is BE. the "iomap" variants
> > provide you with more fine grained "be" variants to use in that case.
> > There's also writel_be() but that one doesn't exist on every
> > architecture afaik.
> So writel_be is the function I should use for memory mapped io? If it
> does not exist for all platforms it's a pitty :-(

Just use the iomap variant. Usually you also use pci_iomap() instead of
ioremap() but afaik, for straight MMIO, it works with normal ioremap as
well.

> > Now, once the mmio problem is out of the way, let's look back at how you
> > then use that qpn.
> > 
> > With the current code, you've generated something in memory which is
> > byte reversed, so essentially "LE" on ppc and "BE" on x86.
> > 
> > Then, this statement:
> > 
> > *(u32 *) (&tx_desc->ctrl.vlan_tag) |= ring->doorbell_qpn;
> > 
> > Will essentially write it out as-is in memory for use by the chip. The chip,
> > from what you say, expects BE, so this will be broken on PPC.
> I see. So this field is layed in le for ppc and the rest of the
> descriptor is be. so I assum that __iowrite64_copy() does not swap
> anything but we still have tx_desc->ctrl.vlan_tag in the wrong
> endianess.

Yes because you had swapped it initially. IE your original swab32 is
what busts it for you on ppc.

> > Here too, the right solution is to instead not do that swab32 to begin
> > with (ring->doorbell_qpn remains a native endian value) and instead do,
> > in addition to the above mentioned change to the writel:
> > 
> > 	*(u32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn);
> > 
> > (Also get rid of that cast and define vlan_tag as a __be32 to start
> > with).
> > 
> > Cheers,
> > Ben.
> 
> Thanks for your review. I will send another patch which should fix the
> deficiencies.

Cheers,
Ben.

  reply	other threads:[~2011-10-10  7:32 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-30 13:23 [PATCH] mlx4_en: fix transmit of packages when blue frame is enabled Thadeu Lima de Souza Cascardo
2011-10-02  8:58 ` Yevgeny Petrilin
2011-10-03 14:37   ` Thadeu Lima de Souza Cascardo
2011-10-03 14:56     ` Yevgeny Petrilin
2011-10-03 20:53       ` Thadeu Lima de Souza Cascardo
2011-10-03 20:53         ` Thadeu Lima de Souza Cascardo
2011-10-04  6:02         ` Benjamin Herrenschmidt
2011-10-04  6:02           ` Benjamin Herrenschmidt
2011-10-04 20:26           ` Thadeu Lima de Souza Cascardo
2011-10-04 20:26             ` Thadeu Lima de Souza Cascardo
2011-10-05  8:15             ` Eli Cohen
2011-10-05  8:15               ` Eli Cohen
2011-10-06 13:57               ` Eli Cohen
2011-10-06 13:57                 ` Eli Cohen
2011-10-06 14:10                 ` [PATCH] mlx4_en: fix transmit of packages when blue frame isenabled David Laight
2011-10-06 14:10                   ` David Laight
2011-10-07 22:29                   ` Thadeu Lima de Souza Cascardo
2011-10-07 22:29                     ` Thadeu Lima de Souza Cascardo
2011-10-09  7:28                   ` Benjamin Herrenschmidt
2011-10-09  7:28                     ` Benjamin Herrenschmidt
2011-10-09  7:25                 ` [PATCH] mlx4_en: fix transmit of packages when blue frame is enabled Benjamin Herrenschmidt
2011-10-09  7:25                   ` Benjamin Herrenschmidt
2011-10-09  7:35                   ` Eli Cohen
2011-10-09  7:35                     ` Eli Cohen
2011-10-09  8:00                     ` Benjamin Herrenschmidt
2011-10-09  8:07                       ` Eli Cohen
2011-10-09  8:07                         ` Eli Cohen
2011-10-09  8:38                         ` Benjamin Herrenschmidt
2011-10-09  8:38                           ` Benjamin Herrenschmidt
2011-10-09  9:21                           ` Eli Cohen
2011-10-09  9:21                             ` Eli Cohen
2011-10-09  9:52                             ` Benjamin Herrenschmidt
2011-10-09  9:52                               ` Benjamin Herrenschmidt
2011-10-09 10:30                               ` Eli Cohen
2011-10-09 10:30                                 ` Eli Cohen
2011-10-10  7:32                                 ` Benjamin Herrenschmidt [this message]
2011-10-10  7:32                                   ` Benjamin Herrenschmidt
2011-10-10 16:42                                   ` [PATCH] mlx4_en: fix endianness with blue frame support Thadeu Lima de Souza Cascardo
2011-10-10 16:42                                     ` Thadeu Lima de Souza Cascardo
2011-10-10 16:46                                     ` Thadeu Lima de Souza Cascardo
2011-10-10 16:46                                       ` Thadeu Lima de Souza Cascardo
2011-10-10 18:10                                       ` David Miller
2011-10-10 18:10                                         ` David Miller
2011-10-10  8:20                               ` [PATCH] mlx4_en: fix transmit of packages when blue frame is enabled David Laight
2011-10-10  8:20                                 ` David Laight
2011-10-10  8:29                                 ` Benjamin Herrenschmidt
2011-10-10  8:29                                   ` Benjamin Herrenschmidt
2011-10-10  8:40                   ` David Laight
2011-10-10  8:40                     ` David Laight
2011-10-10  8:47                     ` Eli Cohen
2011-10-10  9:01                       ` Benjamin Herrenschmidt
2011-10-10  9:01                         ` Benjamin Herrenschmidt
2011-10-10  9:16                         ` Eli Cohen
2011-10-10  9:16                           ` Eli Cohen
2011-10-10  9:24                           ` Benjamin Herrenschmidt
2011-10-10  9:24                             ` Benjamin Herrenschmidt
2011-10-10  9:29                             ` Eli Cohen
2011-10-10  9:29                               ` Eli Cohen
2011-10-10 10:18                               ` Benjamin Herrenschmidt
2011-10-10 10:18                                 ` Benjamin Herrenschmidt
2011-10-10  8:53                     ` Benjamin Herrenschmidt
2011-10-10  8:53                       ` Benjamin Herrenschmidt
2011-10-09  7:21               ` Benjamin Herrenschmidt
2011-10-09  7:21                 ` Benjamin Herrenschmidt
2011-10-09  7:19             ` Benjamin Herrenschmidt

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=1318231920.29415.404.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=cascardo@linux.vnet.ibm.com \
    --cc=eli@dev.mellanox.co.il \
    --cc=eli@mellanox.co.il \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=yevgenyp@mellanox.co.il \
    /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.