From: Andrew Rybchenko Date: Thu, 12 Jan 2017 09:03:21 +0000 (+0000) Subject: net/sfc: synchronize link status with HW on start X-Git-Tag: spdx-start~4628 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f08a23778350a09ed0ff0e88fb287a3ef484304b;p=dpdk.git net/sfc: synchronize link status with HW on start Fixes: 886f8d8a05bf ("net/sfc: retrieve link info") Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee --- diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index dc6ecdf7dc..e2d85443bb 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -61,6 +61,27 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa) return 0; } +static int +sfc_port_init_dev_link(struct sfc_adapter *sa) +{ + struct rte_eth_link *dev_link = &sa->eth_dev->data->dev_link; + int rc; + efx_link_mode_t link_mode; + struct rte_eth_link current_link; + + rc = efx_port_poll(sa->nic, &link_mode); + if (rc != 0) + return rc; + + sfc_port_link_mode_to_info(link_mode, ¤t_link); + + EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); + rte_atomic64_set((rte_atomic64_t *)dev_link, + *(uint64_t *)¤t_link); + + return 0; +} + int sfc_port_start(struct sfc_adapter *sa) { @@ -129,9 +150,17 @@ sfc_port_start(struct sfc_adapter *sa) if (rc != 0) goto fail_mac_drain; + /* Synchronize link status knowledge */ + rc = sfc_port_init_dev_link(sa); + if (rc != 0) + goto fail_port_init_dev_link; + sfc_log_init(sa, "done"); return 0; +fail_port_init_dev_link: + (void)efx_mac_drain(sa->nic, B_TRUE); + fail_mac_drain: (void)efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem, 0, B_FALSE);