net/sfc: initialize port data on attach

Port configuration should be initialized on attach to avoid reset to
defaults on device reconfigure.

Fixes: 03ed21195d ("net/sfc: minimum port control sufficient to receive traffic")
Cc: stable@dpdk.org

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
This commit is contained in:
Andrew Rybchenko 2017-03-31 11:22:18 +01:00 committed by Ferruh Yigit
parent 47995190cf
commit c577a525d2
3 changed files with 41 additions and 16 deletions

View File

@ -409,9 +409,9 @@ sfc_configure(struct sfc_adapter *sa)
if (rc != 0)
goto fail_intr_configure;
rc = sfc_port_init(sa);
rc = sfc_port_configure(sa);
if (rc != 0)
goto fail_port_init;
goto fail_port_configure;
rc = sfc_rx_init(sa);
if (rc != 0)
@ -429,9 +429,9 @@ sfc_configure(struct sfc_adapter *sa)
sfc_rx_fini(sa);
fail_rx_init:
sfc_port_fini(sa);
sfc_port_close(sa);
fail_port_init:
fail_port_configure:
sfc_intr_close(sa);
fail_intr_configure:
@ -453,7 +453,7 @@ sfc_close(struct sfc_adapter *sa)
sfc_tx_fini(sa);
sfc_rx_fini(sa);
sfc_port_fini(sa);
sfc_port_close(sa);
sfc_intr_close(sa);
sa->state = SFC_ADAPTER_INITIALIZED;
@ -603,8 +603,9 @@ sfc_attach(struct sfc_adapter *sa)
if (rc != 0)
goto fail_ev_attach;
efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_PERM,
&sa->port.phy_adv_cap_mask);
rc = sfc_port_attach(sa);
if (rc != 0)
goto fail_port_attach;
rc = sfc_set_rss_defaults(sa);
if (rc != 0)
@ -626,6 +627,9 @@ sfc_attach(struct sfc_adapter *sa)
fail_filter_attach:
fail_set_rss_defaults:
sfc_port_detach(sa);
fail_port_attach:
sfc_ev_detach(sa);
fail_ev_attach:
@ -651,6 +655,7 @@ sfc_detach(struct sfc_adapter *sa)
sfc_flow_fini(sa);
sfc_filter_detach(sa);
sfc_port_detach(sa);
sfc_ev_detach(sa);
sfc_intr_detach(sa);

View File

@ -302,8 +302,10 @@ void sfc_intr_close(struct sfc_adapter *sa);
int sfc_intr_start(struct sfc_adapter *sa);
void sfc_intr_stop(struct sfc_adapter *sa);
int sfc_port_init(struct sfc_adapter *sa);
void sfc_port_fini(struct sfc_adapter *sa);
int sfc_port_attach(struct sfc_adapter *sa);
void sfc_port_detach(struct sfc_adapter *sa);
int sfc_port_configure(struct sfc_adapter *sa);
void sfc_port_close(struct sfc_adapter *sa);
int sfc_port_start(struct sfc_adapter *sa);
void sfc_port_stop(struct sfc_adapter *sa);
void sfc_port_link_mode_to_info(efx_link_mode_t link_mode,

View File

@ -296,24 +296,42 @@ sfc_port_stop(struct sfc_adapter *sa)
}
int
sfc_port_init(struct sfc_adapter *sa)
sfc_port_configure(struct sfc_adapter *sa)
{
const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
struct sfc_port *port = &sa->port;
sfc_log_init(sa, "entry");
if (dev_data->dev_conf.rxmode.jumbo_frame)
port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
else
port->pdu = EFX_MAC_PDU(dev_data->mtu);
return 0;
}
void
sfc_port_close(struct sfc_adapter *sa)
{
sfc_log_init(sa, "entry");
}
int
sfc_port_attach(struct sfc_adapter *sa)
{
struct sfc_port *port = &sa->port;
long kvarg_stats_update_period_ms;
int rc;
sfc_log_init(sa, "entry");
efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_PERM, &port->phy_adv_cap_mask);
/* Enable flow control by default */
port->flow_ctrl = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE;
port->flow_ctrl_autoneg = B_TRUE;
if (dev_data->dev_conf.rxmode.jumbo_frame)
port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
else
port->pdu = EFX_MAC_PDU(dev_data->mtu);
port->max_mcast_addrs = EFX_MAC_MULTICAST_LIST_MAX;
port->nb_mcast_addrs = 0;
port->mcast_addrs = rte_calloc_socket("mcast_addr_list_buf",
@ -374,7 +392,7 @@ sfc_port_init(struct sfc_adapter *sa)
}
void
sfc_port_fini(struct sfc_adapter *sa)
sfc_port_detach(struct sfc_adapter *sa)
{
struct sfc_port *port = &sa->port;