netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Jamie Gloudon <jamie.gloudon@gmx.fr>,
	netdev@vger.kernel.org
Subject: Re: Broken link partner advertised reporting in ethtool
Date: Mon, 27 Jul 2020 15:15:25 -0700	[thread overview]
Message-ID: <a1b9451e-6e21-efe0-da19-0c33eb228c4e@intel.com> (raw)
In-Reply-To: <20200727220053.gg4uozlks25vorbm@lion.mk-sys.cz>



On 7/27/2020 3:00 PM, Michal Kubecek wrote:
> On Mon, Jul 27, 2020 at 02:27:56PM -0700, Jacob Keller wrote:
>>
>>
>> On 7/27/2020 2:08 PM, Michal Kubecek wrote:
>>> On Mon, Jul 27, 2020 at 11:01:41PM +0200, Andrew Lunn wrote:
>>>>>   - the exact command you ran (including arguments)
>>>>>   - expected output (or at least the relevant part)
>>>>>   - actual output (or at least the relevant part)
>>>>>   - output with dump of netlink messages, you can get it by enabling
>>>>>     debugging flags, e.g. "ethtool --debug 0x12 eth0"
>>>>  
>>>> Hi Michal
>>>>
>>>> See if this helps.
>>>>
>>>> This is a Marvel Ethernet switch port using an Marvell PHY.
>>>
>>> Thank you. I think I can see the problem. Can you try the patch below?
>>>
>>> Michal
>>>
>>
>> I think the patch below fixes part of the issue, but isn't completely
>> correct, because NOMASK bitmaps can be sent in compact form as well.
> 
> I believe this part is correct; compact NOMASK bitmap would have no
> ETHTOOL_A_BITSET_MASK and ETHTOOL_A_BITSET_BIT_VALUE would contain the
> bits in it so that the code would generate correct output.
> 
>> Also, we'll need something to check the NOMASK flag and do the correct
>> thing in all of the dump functions.
> 
> You are right, bitset_get_bit needs the same fix, updated version is
> below.
> 
> Michal
> 
> 

This is basically what I got except that I also applied the fix to
compact bitmaps.

See https://lore.kernel.org/netdev/20200727221104.GD1705504@lunn.ch/T/#t

I think we're still missing something tho.

Thanks,
Jake

> diff --git a/netlink/bitset.c b/netlink/bitset.c
> index 130bcdb5b52c..67b45778692c 100644
> --- a/netlink/bitset.c
> +++ b/netlink/bitset.c
> @@ -50,6 +50,7 @@ bool bitset_get_bit(const struct nlattr *bitset, bool mask, unsigned int idx,
>  	DECLARE_ATTR_TB_INFO(bitset_tb);
>  	const struct nlattr *bits;
>  	const struct nlattr *bit;
> +	bool nomask;
>  	int ret;
>  
>  	*retptr = 0;
> @@ -68,6 +69,7 @@ bool bitset_get_bit(const struct nlattr *bitset, bool mask, unsigned int idx,
>  		return bitmap[idx / 32] & (1U << (idx % 32));
>  	}
>  
> +	nomask = bitset_tb[ETHTOOL_A_BITSET_NOMASK];
>  	bits = bitset_tb[ETHTOOL_A_BITSET_BITS];
>  	if (!bits)
>  		goto err;
> @@ -87,7 +89,7 @@ bool bitset_get_bit(const struct nlattr *bitset, bool mask, unsigned int idx,
>  
>  		my_idx = mnl_attr_get_u32(tb[ETHTOOL_A_BITSET_BIT_INDEX]);
>  		if (my_idx == idx)
> -			return mask || tb[ETHTOOL_A_BITSET_BIT_VALUE];
> +			return mask || nomask || tb[ETHTOOL_A_BITSET_BIT_VALUE];
>  	}
>  
>  	return false;
> diff --git a/netlink/settings.c b/netlink/settings.c
> index 35ba2f5dd6d5..60523ad6edf5 100644
> --- a/netlink/settings.c
> +++ b/netlink/settings.c
> @@ -280,6 +280,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
>  	const struct nlattr *bit;
>  	bool first = true;
>  	int prev = -2;
> +	bool nomask;
>  	int ret;
>  
>  	ret = mnl_attr_parse_nested(bitset, attr_cb, &bitset_tb_info);
> @@ -338,6 +339,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
>  		goto after;
>  	}
>  
> +	nomask = bitset_tb[ETHTOOL_A_BITSET_NOMASK];
>  	printf("\t%s", before);
>  	mnl_attr_for_each_nested(bit, bits) {
>  		const struct nlattr *tb[ETHTOOL_A_BITSET_BIT_MAX + 1] = {};
> @@ -354,7 +356,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
>  		if (!tb[ETHTOOL_A_BITSET_BIT_INDEX] ||
>  		    !tb[ETHTOOL_A_BITSET_BIT_NAME])
>  			goto err;
> -		if (!mask && !tb[ETHTOOL_A_BITSET_BIT_VALUE])
> +		if (!mask && !nomask && !tb[ETHTOOL_A_BITSET_BIT_VALUE])
>  			continue;
>  
>  		idx = mnl_attr_get_u32(tb[ETHTOOL_A_BITSET_BIT_INDEX]);
> 

  reply	other threads:[~2020-07-27 22:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 15:47 Broken link partner advertised reporting in ethtool Jamie Gloudon
2020-07-27 19:19 ` Jacob Keller
2020-07-27 20:09   ` Jamie Gloudon
2020-07-27 20:42     ` Michal Kubecek
2020-07-27 21:01       ` Andrew Lunn
2020-07-27 21:08         ` Michal Kubecek
2020-07-27 21:25           ` Andrew Lunn
2020-07-27 21:30             ` Jacob Keller
2020-07-27 21:42             ` Jacob Keller
2020-07-27 21:27           ` Jacob Keller
2020-07-27 22:00             ` Michal Kubecek
2020-07-27 22:15               ` Jacob Keller [this message]
2020-07-27 21:18         ` Jacob Keller

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=a1b9451e-6e21-efe0-da19-0c33eb228c4e@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=andrew@lunn.ch \
    --cc=jamie.gloudon@gmx.fr \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.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).