Skip to content

Commit 05e592e

Browse files
okt-imalovshemminger
authored andcommitted
net/sfc: fix reporting status of autonegotiation to the user
Currently, the driver always indicates speed autonegotiation to be enabled, even when the user has disabled it. Fix the code to report the true status. Fixes: 886f8d8 ("net/sfc: retrieve link info") Cc: [email protected] Signed-off-by: Ivan Malov <[email protected]> Reviewed-by: Andy Moreton <[email protected]>
1 parent 9425569 commit 05e592e

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

drivers/net/sfc/sfc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ int sfc_port_configure(struct sfc_adapter *sa);
417417
void sfc_port_close(struct sfc_adapter *sa);
418418
int sfc_port_start(struct sfc_adapter *sa);
419419
void sfc_port_stop(struct sfc_adapter *sa);
420-
void sfc_port_link_mode_to_info(efx_link_mode_t link_mode,
420+
void sfc_port_link_mode_to_info(efx_link_mode_t link_mode, uint32_t phy_cap_req,
421421
struct rte_eth_link *link_info);
422422
int sfc_port_update_mac_stats(struct sfc_adapter *sa, boolean_t manual_update);
423423
int sfc_port_get_mac_stats(struct sfc_adapter *sa, struct rte_eth_xstat *xstats,

drivers/net/sfc/sfc_ethdev.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,14 @@ sfc_dev_get_rte_link(struct rte_eth_dev *dev, int wait_to_complete,
262262
SFC_ASSERT(link != NULL);
263263

264264
if (sa->state != SFC_ETHDEV_STARTED) {
265-
sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, link);
265+
sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, 0, link);
266266
} else if (wait_to_complete) {
267267
efx_link_mode_t link_mode;
268268

269269
if (efx_port_poll(sa->nic, &link_mode) != 0)
270270
link_mode = EFX_LINK_UNKNOWN;
271-
sfc_port_link_mode_to_info(link_mode, link);
271+
sfc_port_link_mode_to_info(link_mode, sa->port.phy_adv_cap,
272+
link);
272273
} else {
273274
sfc_ev_mgmt_qpoll(sa);
274275
rte_eth_linkstatus_get(dev, link);

drivers/net/sfc/sfc_ev.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,12 @@ sfc_ev_link_change(void *arg, efx_link_mode_t link_mode)
516516
}
517517

518518
decode_comprehensive:
519-
sfc_port_link_mode_to_info(link_mode, &new_link);
519+
/*
520+
* Reading 'sa->port.phy_adv_cap' without acquiring adaptor lock may
521+
* render autonegotiation status inaccurate, but that's not critical,
522+
* as it's unlikely to happen often and may be a practical trade-off.
523+
*/
524+
sfc_port_link_mode_to_info(link_mode, sa->port.phy_adv_cap, &new_link);
520525

521526
set:
522527
if (rte_eth_linkstatus_set(sa->eth_dev, &new_link) == 0)

drivers/net/sfc/sfc_port.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ sfc_port_init_dev_link(struct sfc_adapter *sa)
130130
if (rc != 0)
131131
return rc;
132132

133-
sfc_port_link_mode_to_info(link_mode, &current_link);
133+
sfc_port_link_mode_to_info(link_mode, sa->port.phy_adv_cap,
134+
&current_link);
134135

135136
EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
136137
rte_atomic64_set((rte_atomic64_t *)dev_link,
@@ -614,7 +615,7 @@ sfc_set_rx_mode(struct sfc_adapter *sa)
614615
}
615616

616617
void
617-
sfc_port_link_mode_to_info(efx_link_mode_t link_mode,
618+
sfc_port_link_mode_to_info(efx_link_mode_t link_mode, uint32_t phy_cap_req,
618619
struct rte_eth_link *link_info)
619620
{
620621
SFC_ASSERT(link_mode < EFX_LINK_NMODES);
@@ -684,7 +685,8 @@ sfc_port_link_mode_to_info(efx_link_mode_t link_mode,
684685
break;
685686
}
686687

687-
link_info->link_autoneg = RTE_ETH_LINK_AUTONEG;
688+
if ((phy_cap_req & (1U << EFX_PHY_CAP_AN)) != 0)
689+
link_info->link_autoneg = RTE_ETH_LINK_AUTONEG;
688690
}
689691

690692
int

drivers/net/sfc/sfc_repr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ sfc_repr_dev_link_update(struct rte_eth_dev *dev,
533533
struct rte_eth_link link;
534534

535535
if (sr->state != SFC_ETHDEV_STARTED) {
536-
sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, &link);
536+
sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, 0, &link);
537537
} else {
538538
memset(&link, 0, sizeof(link));
539539
link.link_status = RTE_ETH_LINK_UP;

0 commit comments

Comments
 (0)