[1/3] net/sfc: split link update function
Checks
Commit Message
Separate the original link update function into
two functions: state retrieval and update.
This improves code clarity and maintainability.
Signed-off-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
drivers/net/sfc/sfc_ethdev.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
Comments
On 6/2/23 01:23, Denis Pryazhennikov wrote:
> Separate the original link update function into
> two functions: state retrieval and update.
> This improves code clarity and maintainability.
>
> Signed-off-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Acked-by: Andrew Rybchenko <arybchenko@oktetlabs.ru>
On 6/2/2023 9:52 AM, Andrew Rybchenko wrote:
> On 6/2/23 01:23, Denis Pryazhennikov wrote:
>> Separate the original link update function into
>> two functions: state retrieval and update.
>> This improves code clarity and maintainability.
>>
>> Signed-off-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
>> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
>> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
>
> Acked-by: Andrew Rybchenko <arybchenko@oktetlabs.ru>
>
>
Hi Andrew,
You have other email address [1] recorded in .mailmap, I will keep using
it, if this is new preferred address please update .mailmap
[1]
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
On 6/20/23 14:25, Ferruh Yigit wrote:
> On 6/2/2023 9:52 AM, Andrew Rybchenko wrote:
>> On 6/2/23 01:23, Denis Pryazhennikov wrote:
>>> Separate the original link update function into
>>> two functions: state retrieval and update.
>>> This improves code clarity and maintainability.
>>>
>>> Signed-off-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
>>> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
>>> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
>>
>> Acked-by: Andrew Rybchenko <arybchenko@oktetlabs.ru>
>>
>>
>
> Hi Andrew,
>
> You have other email address [1] recorded in .mailmap, I will keep using
> it, if this is new preferred address please update .mailmap
>
> [1]
> Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>
Thanks Ferruh, it was some kind of typo. [1] is the right one.
@@ -248,28 +248,38 @@ sfc_dev_start(struct rte_eth_dev *dev)
return -rc;
}
-static int
-sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+static void
+sfc_dev_get_rte_link(struct rte_eth_dev *dev, int wait_to_complete,
+ struct rte_eth_link *link)
{
struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
- struct rte_eth_link current_link;
- int ret;
- sfc_log_init(sa, "entry");
+ SFC_ASSERT(link != NULL);
if (sa->state != SFC_ETHDEV_STARTED) {
- sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, ¤t_link);
+ sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, link);
} else if (wait_to_complete) {
efx_link_mode_t link_mode;
if (efx_port_poll(sa->nic, &link_mode) != 0)
link_mode = EFX_LINK_UNKNOWN;
- sfc_port_link_mode_to_info(link_mode, ¤t_link);
-
+ sfc_port_link_mode_to_info(link_mode, link);
} else {
sfc_ev_mgmt_qpoll(sa);
- rte_eth_linkstatus_get(dev, ¤t_link);
+ rte_eth_linkstatus_get(dev, link);
}
+}
+
+static int
+sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
+ struct rte_eth_link current_link;
+ int ret;
+
+ sfc_log_init(sa, "entry");
+
+ sfc_dev_get_rte_link(dev, wait_to_complete, ¤t_link);
ret = rte_eth_linkstatus_set(dev, ¤t_link);
if (ret == 0)