From: Ido Schimmel <idosch@mellanox.com>
To: Colin Ian King <colin.king@canonical.com>
Cc: Jiri Pirko <jiri@mellanox.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Petr Machata <petrm@mellanox.com>,
netdev@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: mlxsw: spectrum: Adjust headroom buffers for 8x ports
Date: Wed, 17 Jun 2020 20:52:19 +0300 [thread overview]
Message-ID: <20200617175219.GB296888@splinter> (raw)
In-Reply-To: <bae3b4f6-3e9b-bdde-72b0-b8f1e7575fd4@canonical.com>
On Wed, Jun 17, 2020 at 06:15:35PM +0100, Colin Ian King wrote:
> Hi
>
> Static analysis with Coverity has detected an issue that relies on the
> machine endianness to work. The commit in question is:
>
> commit 60833d54d56c21e7538296eb2e00e104768fd047
> Author: Ido Schimmel <idosch@mellanox.com>
> Date: Tue Jun 16 10:14:58 2020 +0300
>
> mlxsw: spectrum: Adjust headroom buffers for 8x ports
>
> in line:
> mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, (u16 *) &buffsize);
>
>
> The cast of the u32 buffsize to (u16 *) to scale buffsize in the call to
> to mlxsw_sp_port_headroom_8x_adjust() will behave differently on big
> endian architectures to that of little endian architectures. I'm not
> sure if this is intentional or not.
Not intentional. The hardware interface is quite weird. The buffer size
can be configured via two registers. One takes size as 24 bits and the
second as 16 bits. Either way, the max size is much lower than 2^16-1.
> One solution is to either make buffsize a u16, but I am concerned this
> may be incorrect as the buffsize is assigned from the call
> mlxsw_sp_span_buffsize_get() and this returns a u32 so we may have
> overflow issues. Probably better to make
> mlxsw_sp_port_headroom_8x_adjust handle u32 integers and to return the
> adjusted value rather than modifying it by pass-by-reference.
Thanks for the report, will fix.
>
> Colin
>
prev parent reply other threads:[~2020-06-17 17:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 17:15 mlxsw: spectrum: Adjust headroom buffers for 8x ports Colin Ian King
2020-06-17 17:52 ` Ido Schimmel [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=20200617175219.GB296888@splinter \
--to=idosch@mellanox.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=petrm@mellanox.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).