[1/3] net/sfc: split link update function

Message ID 20230601222349.28965-2-denis.pryazhennikov@arknetworks.am (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: support FEC feature |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Denis Pryazhennikov June 1, 2023, 10:23 p.m. UTC
  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

Andrew Rybchenko June 2, 2023, 8:52 a.m. UTC | #1
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>
  
Ferruh Yigit June 20, 2023, 11:25 a.m. UTC | #2
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>
  
Andrew Rybchenko June 20, 2023, 11:43 a.m. UTC | #3
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.
  

Patch

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 320043145495..6d41eb000345 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -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, &current_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, &current_link);
-
+		sfc_port_link_mode_to_info(link_mode, link);
 	} else {
 		sfc_ev_mgmt_qpoll(sa);
-		rte_eth_linkstatus_get(dev, &current_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, &current_link);
 
 	ret = rte_eth_linkstatus_set(dev, &current_link);
 	if (ret == 0)