All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net/sfc: choose datapaths after probe and before attach
@ 2017-03-29 15:23 Andrew Rybchenko
  2017-03-29 15:23 ` [PATCH 2/2] net/sfc: do not drop TSO on device configure Andrew Rybchenko
  2017-03-29 16:59 ` [PATCH v2 1/2] net/sfc: choose datapaths after probe and before attach Andrew Rybchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Rybchenko @ 2017-03-29 15:23 UTC (permalink / raw)
  To: dev

Datapath choice requires NIC capabilities knowledge and, therefore,
should be done after probe. Whereas NIC resources estimation needs
to know chosen datapath (e.g. if Tx datapath is going to use TSO).

Fixes: 782f2b977de6 ("net/sfc: factor out libefx-based Rx datapath")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
It could be squashed into corresponding patch, but unfortunately it
happens with conflicts due to sa->state check removal from
sfc_eth_dev_set_ops() where nearby lines are added after 782f2b977de6.
I think the bug is not major, so it could wait for rc1 and applied as
fixes.

 drivers/net/sfc/sfc.c        | 107 +++++++++++++++++++++++++++----------------
 drivers/net/sfc/sfc.h        |   2 +
 drivers/net/sfc/sfc_ethdev.c |  20 ++++++--
 3 files changed, 84 insertions(+), 45 deletions(-)

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 655d667..eda426c 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -571,46 +571,14 @@ sfc_set_rss_defaults(struct sfc_adapter *sa)
 int
 sfc_attach(struct sfc_adapter *sa)
 {
-	struct rte_pci_device *pci_dev = SFC_DEV_TO_PCI(sa->eth_dev);
 	const efx_nic_cfg_t *encp;
-	efx_nic_t *enp;
+	efx_nic_t *enp = sa->nic;
 	int rc;
 
 	sfc_log_init(sa, "entry");
 
 	SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-	sa->socket_id = rte_socket_id();
-
-	sfc_log_init(sa, "init mem bar");
-	rc = sfc_mem_bar_init(sa);
-	if (rc != 0)
-		goto fail_mem_bar_init;
-
-	sfc_log_init(sa, "get family");
-	rc = efx_family(pci_dev->id.vendor_id, pci_dev->id.device_id,
-			&sa->family);
-	if (rc != 0)
-		goto fail_family;
-	sfc_log_init(sa, "family is %u", sa->family);
-
-	sfc_log_init(sa, "create nic");
-	rte_spinlock_init(&sa->nic_lock);
-	rc = efx_nic_create(sa->family, (efsys_identifier_t *)sa,
-			    &sa->mem_bar, &sa->nic_lock, &enp);
-	if (rc != 0)
-		goto fail_nic_create;
-	sa->nic = enp;
-
-	rc = sfc_mcdi_init(sa);
-	if (rc != 0)
-		goto fail_mcdi_init;
-
-	sfc_log_init(sa, "probe nic");
-	rc = efx_nic_probe(enp);
-	if (rc != 0)
-		goto fail_nic_probe;
-
 	efx_mcdi_new_epoch(enp);
 
 	sfc_log_init(sa, "reset nic");
@@ -666,8 +634,71 @@ sfc_attach(struct sfc_adapter *sa)
 
 fail_estimate_rsrc_limits:
 fail_nic_reset:
-	sfc_log_init(sa, "unprobe nic");
-	efx_nic_unprobe(enp);
+
+	sfc_log_init(sa, "failed %d", rc);
+	return rc;
+}
+
+void
+sfc_detach(struct sfc_adapter *sa)
+{
+	sfc_log_init(sa, "entry");
+
+	SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+	sfc_flow_fini(sa);
+
+	sfc_filter_detach(sa);
+
+	sfc_intr_detach(sa);
+
+	sa->state = SFC_ADAPTER_UNINITIALIZED;
+}
+
+int
+sfc_probe(struct sfc_adapter *sa)
+{
+	struct rte_pci_device *pci_dev = SFC_DEV_TO_PCI(sa->eth_dev);
+	efx_nic_t *enp;
+	int rc;
+
+	sfc_log_init(sa, "entry");
+
+	SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+	sa->socket_id = rte_socket_id();
+
+	sfc_log_init(sa, "init mem bar");
+	rc = sfc_mem_bar_init(sa);
+	if (rc != 0)
+		goto fail_mem_bar_init;
+
+	sfc_log_init(sa, "get family");
+	rc = efx_family(pci_dev->id.vendor_id, pci_dev->id.device_id,
+			&sa->family);
+	if (rc != 0)
+		goto fail_family;
+	sfc_log_init(sa, "family is %u", sa->family);
+
+	sfc_log_init(sa, "create nic");
+	rte_spinlock_init(&sa->nic_lock);
+	rc = efx_nic_create(sa->family, (efsys_identifier_t *)sa,
+			    &sa->mem_bar, &sa->nic_lock, &enp);
+	if (rc != 0)
+		goto fail_nic_create;
+	sa->nic = enp;
+
+	rc = sfc_mcdi_init(sa);
+	if (rc != 0)
+		goto fail_mcdi_init;
+
+	sfc_log_init(sa, "probe nic");
+	rc = efx_nic_probe(enp);
+	if (rc != 0)
+		goto fail_nic_probe;
+
+	sfc_log_init(sa, "done");
+	return 0;
 
 fail_nic_probe:
 	sfc_mcdi_fini(sa);
@@ -687,7 +718,7 @@ sfc_attach(struct sfc_adapter *sa)
 }
 
 void
-sfc_detach(struct sfc_adapter *sa)
+sfc_unprobe(struct sfc_adapter *sa)
 {
 	efx_nic_t *enp = sa->nic;
 
@@ -695,10 +726,6 @@ sfc_detach(struct sfc_adapter *sa)
 
 	SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-	sfc_filter_detach(sa);
-
-	sfc_intr_detach(sa);
-
 	sfc_log_init(sa, "unprobe nic");
 	efx_nic_unprobe(enp);
 
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index c2961ea..a7a9868 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -283,6 +283,8 @@ int sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
 		  size_t len, int socket_id, efsys_mem_t *esmp);
 void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp);
 
+int sfc_probe(struct sfc_adapter *sa);
+void sfc_unprobe(struct sfc_adapter *sa);
 int sfc_attach(struct sfc_adapter *sa);
 void sfc_detach(struct sfc_adapter *sa);
 int sfc_start(struct sfc_adapter *sa);
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index b745714..77d6208 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1368,9 +1368,6 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
 	const char *tx_name = NULL;
 	int rc;
 
-	if (sa == NULL || sa->state == SFC_ADAPTER_UNINITIALIZED)
-		return -E_RTE_SECONDARY;
-
 	switch (sa->family) {
 	case EFX_FAMILY_HUNTINGTON:
 	case EFX_FAMILY_MEDFORD:
@@ -1509,6 +1506,16 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 	sfc_adapter_lock_init(sa);
 	sfc_adapter_lock(sa);
 
+	sfc_log_init(sa, "probing");
+	rc = sfc_probe(sa);
+	if (rc != 0)
+		goto fail_probe;
+
+	sfc_log_init(sa, "set device ops");
+	rc = sfc_eth_dev_set_ops(dev);
+	if (rc != 0)
+		goto fail_set_ops;
+
 	sfc_log_init(sa, "attaching");
 	rc = sfc_attach(sa);
 	if (rc != 0)
@@ -1525,12 +1532,14 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 
 	sfc_adapter_unlock(sa);
 
-	sfc_eth_dev_set_ops(dev);
-
 	sfc_log_init(sa, "done");
 	return 0;
 
 fail_attach:
+fail_set_ops:
+	sfc_unprobe(sa);
+
+fail_probe:
 	sfc_adapter_unlock(sa);
 	sfc_adapter_lock_fini(sa);
 	rte_free(dev->data->mac_addrs);
@@ -1556,6 +1565,7 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
 	sfc_adapter_lock(sa);
 
 	sfc_detach(sa);
+	sfc_unprobe(sa);
 
 	rte_free(dev->data->mac_addrs);
 	dev->data->mac_addrs = NULL;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-03-31 15:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 15:23 [PATCH 1/2] net/sfc: choose datapaths after probe and before attach Andrew Rybchenko
2017-03-29 15:23 ` [PATCH 2/2] net/sfc: do not drop TSO on device configure Andrew Rybchenko
2017-03-29 16:59 ` [PATCH v2 1/2] net/sfc: choose datapaths after probe and before attach Andrew Rybchenko
2017-03-29 16:59   ` [PATCH v2 2/2] net/sfc: do not drop TSO on device configure Andrew Rybchenko
2017-03-31 15:17     ` Ferruh Yigit
2017-03-31 15:14   ` [PATCH v2 1/2] net/sfc: choose datapaths after probe and before attach Ferruh Yigit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.