From: Andrew Rybchenko Date: Fri, 31 Mar 2017 10:22:18 +0000 (+0100) Subject: net/sfc: initialize port data on attach X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c577a525d2f34c5588065ae44a8e1c689e909f58;p=dpdk.git net/sfc: initialize port data on attach Port configuration should be initialized on attach to avoid reset to defaults on device reconfigure. Fixes: 03ed21195d9e ("net/sfc: minimum port control sufficient to receive traffic") Cc: stable@dpdk.org Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index a5d4736f67..8da7879916 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -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 @@ fail_tx_init: 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); diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 5fd734e635..cee1eb8492 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -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, diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 7d1005e7e5..ee96bcdebe 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -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 @@ fail_mcast_addr_list_buf_alloc: } void -sfc_port_fini(struct sfc_adapter *sa) +sfc_port_detach(struct sfc_adapter *sa) { struct sfc_port *port = &sa->port;