DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v2 1/2] net/sfc: choose datapaths after probe and before attach
Date: Wed, 29 Mar 2017 17:59:18 +0100	[thread overview]
Message-ID: <1490806759-17457-1-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1490801039-4723-1-git-send-email-arybchenko@solarflare.com>

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: 8221da743f58 ("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 8221da743f58.
I think the bug is not major, so it could wait for rc1 and applied as
fixes.

v2:
 - update fixes lines

 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

  parent reply	other threads:[~2017-03-29 16:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 15:23 [dpdk-dev] [PATCH " Andrew Rybchenko
2017-03-29 15:23 ` [dpdk-dev] [PATCH 2/2] net/sfc: do not drop TSO on device configure Andrew Rybchenko
2017-03-29 16:59 ` Andrew Rybchenko [this message]
2017-03-29 16:59   ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
2017-03-31 15:17     ` Ferruh Yigit
2017-03-31 15:14   ` [dpdk-dev] [PATCH v2 1/2] net/sfc: choose datapaths after probe and before attach Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490806759-17457-1-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).