net/sfc: request MAC stats upload immediately on port start
[dpdk.git] / drivers / net / sfc / sfc_port.c
index d4498fa..ba2284f 100644 (file)
@@ -1,5 +1,7 @@
 /*-
- * Copyright (c) 2016 Solarflare Communications Inc.
+ *   BSD LICENSE
+ *
+ * Copyright (c) 2016-2017 Solarflare Communications Inc.
  * All rights reserved.
  *
  * This software was jointly developed between OKTET Labs (under contract
@@ -184,26 +186,29 @@ sfc_port_start(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_mac_pdu_set;
 
-       sfc_log_init(sa, "set MAC address");
-       rc = efx_mac_addr_set(sa->nic,
-                             sa->eth_dev->data->mac_addrs[0].addr_bytes);
-       if (rc != 0)
-               goto fail_mac_addr_set;
-
-       sfc_log_init(sa, "set MAC filters");
-       port->promisc = (sa->eth_dev->data->promiscuous != 0) ?
-                       B_TRUE : B_FALSE;
-       port->allmulti = (sa->eth_dev->data->all_multicast != 0) ?
-                        B_TRUE : B_FALSE;
-       rc = sfc_set_rx_mode(sa);
-       if (rc != 0)
-               goto fail_mac_filter_set;
+       if (!port->isolated) {
+               struct ether_addr *mac_addrs = sa->eth_dev->data->mac_addrs;
 
-       sfc_log_init(sa, "set multicast address list");
-       rc = efx_mac_multicast_list_set(sa->nic, port->mcast_addrs,
-                                       port->nb_mcast_addrs);
-       if (rc != 0)
-               goto fail_mcast_address_list_set;
+               sfc_log_init(sa, "set MAC address");
+               rc = efx_mac_addr_set(sa->nic, mac_addrs[0].addr_bytes);
+               if (rc != 0)
+                       goto fail_mac_addr_set;
+
+               sfc_log_init(sa, "set MAC filters");
+               port->promisc = (sa->eth_dev->data->promiscuous != 0) ?
+                               B_TRUE : B_FALSE;
+               port->allmulti = (sa->eth_dev->data->all_multicast != 0) ?
+                                B_TRUE : B_FALSE;
+               rc = sfc_set_rx_mode(sa);
+               if (rc != 0)
+                       goto fail_mac_filter_set;
+
+               sfc_log_init(sa, "set multicast address list");
+               rc = efx_mac_multicast_list_set(sa->nic, port->mcast_addrs,
+                                               port->nb_mcast_addrs);
+               if (rc != 0)
+                       goto fail_mcast_address_list_set;
+       }
 
        if (port->mac_stats_reset_pending) {
                rc = sfc_port_reset_mac_stats(sa);
@@ -240,6 +245,18 @@ sfc_port_start(struct sfc_adapter *sa)
                }
        }
 
+       if ((port->mac_stats_update_period_ms != 0) &&
+           port->mac_stats_periodic_dma_supported) {
+               /*
+                * Request an explicit MAC stats upload immediately to
+                * preclude bogus figures readback if the user decides
+                * to read stats before periodic DMA is really started
+                */
+               rc = efx_mac_stats_upload(sa->nic, &port->mac_stats_dma_mem);
+               if (rc != 0)
+                       goto fail_mac_stats_upload;
+       }
+
        sfc_log_init(sa, "disable MAC drain");
        rc = efx_mac_drain(sa->nic, B_FALSE);
        if (rc != 0)
@@ -260,6 +277,7 @@ fail_mac_drain:
        (void)efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
                                     0, B_FALSE);
 
+fail_mac_stats_upload:
 fail_mac_stats_periodic:
 fail_mcast_address_list_set:
 fail_mac_filter_set:
@@ -294,24 +312,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",
@@ -372,7 +408,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;