DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: Re: [PATCH v2] ethdev: add Linux ethtool link mode conversion
Date: Fri, 1 Mar 2024 15:08:14 +0000	[thread overview]
Message-ID: <14dcf7c4-2e9d-459e-b701-5f26ab4174a1@amd.com> (raw)
In-Reply-To: <3271586.N7aMVyhfb1@thomas>

On 3/1/2024 1:37 PM, Thomas Monjalon wrote:
> 01/03/2024 14:12, Ferruh Yigit:
>> On 2/29/2024 3:42 PM, Thomas Monjalon wrote:
>>> Speed capabilities of a NIC may be discovered through its Linux
>>> kernel driver. It is especially useful for bifurcated drivers,
>>> so they don't have to duplicate the same logic in the DPDK driver.
>>>
>>> Parsing ethtool speed capabilities is made easy thanks to
>>> the functions added in ethdev for internal usage only.
>>> Of course these functions work only on Linux,
>>> so they are not compiled in other environments.
>>>
>>> In order to ease parsing, the ethtool macro names are parsed
>>> externally in a shell command which generates a C array
>>> included in this patch.
>>> It also avoids to depend on a kernel version.
>>> This C array should be updated in future to get latest ethtool bits.
>>> Note it is easier to update this array than adding new cases
>>> in a parsing code.
>>>
>>> The types in the functions are following the ethtool type:
>>> uint32_t for bitmaps, and int8_t for the number of 32-bitmaps.
>>>
>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
>>> ---
>>>
>>> A follow-up patch will be sent to use these functions in mlx5.
>>> I suspect mana could use this parsing as well.
>>>
>>
>> Is the usecase driver get link info via ibverbs and convert it to DPDK
>> link info?
> 
> The use case is to get capabilities from the kernel driver via ethtool ioctl.
> 

Sure, as it is adding kernel ethtool conversion, DPDK driver will get
link from kernel driver, thanks for clarification.

>> How complex or duplicated effort to get link info directly via DPDK
>> functions?
> 
> This is done by the driver.
> This is how mlx5 driver is getting speed capabilities.
> 
>> Because this approach is can be applied to only limited devices in DPDK
>> and solving an issue DPDK already has a solution, does it worth to the
>> code it adds?
> 
> It is going to replace code in mlx5 driver.
> I could add this code in mlx5 driver,
> but it could help other drivers in future like mana.
> 

Why replace, is there anything to fix in the DPDK link get code?


>>> +	speed = link_modes[bit];
>>> +	if (speed == 0)
>>> +		return RTE_ETH_LINK_SPEED_AUTONEG;
>>> +	RTE_BUILD_BUG_ON(RTE_ETH_LINK_SPEED_AUTONEG != 0);
>>>
>>
>> I think for above two checks, we can't really get the speed from
>> provided ethtool enum, and intention is to return something ineffective,
>> intention is not really return AUTONEG, right? If so why not directly
>> return 0?
> 
> Yes it could return 0 directly, but the namespace of the returned value
> is RTE_ETH_LINK_SPEED_.
> Also it is semantically correct: if no other capability found,
> there is no other choice than autoneg.
> 
>>> +
>>> +	/* duplex is LSB */
>>> +	duplex = (speed & 1) ?
>>> +			RTE_ETH_LINK_HALF_DUPLEX :
>>> +			RTE_ETH_LINK_FULL_DUPLEX;
>>> +	speed &= RTE_GENMASK32(31, 1);
>>
>> As trying to zero the LSB, following also work,
>>
>> speed &= ~UINT32_C(1)
> 
> Indeed, this is what RTE_GENMASK32 is doing.
> But I think using RTE_GENMASK32 better convey the intent.
> 
> [...]
>>> +	for (word = 0; word < nwords; word++) {
>>> +		for (bit = 0; bit < 32; bit++) {
>>
>> May be (sizeof(bitmap) * CHAR_BIT) instead of hardcoded 32, although not
>> sure if it is required.
> 
> Anyway we are using RTE_BIT32 below, so we must know it is 32 bits.
> 
>>> +			if ((bitmap[word] & RTE_BIT32(bit)) == 0)
>>> +				continue;
>>> +			ethdev_bitmap |= rte_eth_link_speed_ethtool(word * 32 + bit);
> 
> [...]
>>> --- a/lib/ethdev/meson.build
>>> +++ b/lib/ethdev/meson.build
>>> +if is_linux
>>> +    driver_sdk_headers += files(
>>> +            'ethdev_linux_ethtool.h',
>>> +    )
>>> +    sources += files(
>>> +            'ethdev_linux_ethtool.c',
>>> +    )
>>> +endif
>>
>> Should meson check if 'linux/ethtool.h' exists, for anycase?
> 
> It is an old API header file. Why would not be there?
>

Just to be cautious, but I just recognized this dependency already
exists in some drivers, and they don't check for the header. It seems it
is OK to not check the header.

> If we make it conditional here, we'll need to make it conditional in the caller.
> 
> 


  reply	other threads:[~2024-03-01 15:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 12:34 [PATCH v1] " Thomas Monjalon
2024-02-29 15:42 ` [PATCH v2] " Thomas Monjalon
2024-02-29 16:45   ` Stephen Hemminger
2024-02-29 16:58     ` Morten Brørup
2024-02-29 17:38       ` Stephen Hemminger
2024-03-01 10:27         ` Thomas Monjalon
2024-03-01 13:12   ` Ferruh Yigit
2024-03-01 13:37     ` Thomas Monjalon
2024-03-01 15:08       ` Ferruh Yigit [this message]
2024-03-01 15:20         ` Thomas Monjalon
2024-03-01 17:16           ` Ferruh Yigit
2024-03-01 18:00           ` Stephen Hemminger
2024-03-03  9:36             ` Thomas Monjalon
2024-03-03  9:56 ` [PATCH v3] " Thomas Monjalon
2024-03-04 15:58   ` Ferruh Yigit

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=14dcf7c4-2e9d-459e-b701-5f26ab4174a1@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).