DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2] rte_ethdev: add link support flag
Date: Thu, 19 Jun 2014 15:12:38 -0700	[thread overview]
Message-ID: <20140619151238.28b9bbea@nehalam.linuxnetplumber.net> (raw)

Only some devices support the link state interrupt configuration option.
Link state control does not work in virtual drivers
(virtio, vmxnet3, igbvf, and ixgbevf). Instead of having the application
try and guess whether it will work or not provide a driver flag that
can be checked instead.

Note: if device driver doesn't support link state control, what
would happen previously is that the code would never detect link
transitions. This prevents that.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
 lib/librte_eal/common/include/rte_pci.h |    2 ++
 lib/librte_ether/rte_ethdev.c           |   14 ++++++++++++++
 lib/librte_pmd_e1000/em_ethdev.c        |    2 +-
 lib/librte_pmd_e1000/igb_ethdev.c       |    2 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c     |    2 +-
 5 files changed, 19 insertions(+), 3 deletions(-)

--- a/lib/librte_eal/common/include/rte_pci.h	2014-06-19 14:56:44.188081500 -0700
+++ b/lib/librte_eal/common/include/rte_pci.h	2014-06-19 14:56:44.184081479 -0700
@@ -197,6 +197,8 @@ struct rte_pci_driver {
 #define RTE_PCI_DRV_MULTIPLE 0x0002
 /** Device needs to be unbound even if no module is provided */
 #define RTE_PCI_DRV_FORCE_UNBIND 0x0004
+/** Device driver supports link state interrupt */
+#define RTE_PCI_DRV_LSC	0x0008
 
 /**< Internal use only - Macro used by pci addr parsing functions **/
 #define GET_PCIADDR_FIELD(in, fd, lim, dlm)                   \
--- a/lib/librte_pmd_e1000/em_ethdev.c	2014-06-19 14:56:44.188081500 -0700
+++ b/lib/librte_pmd_e1000/em_ethdev.c	2014-06-19 14:57:50.460429276 -0700
@@ -286,7 +286,7 @@ static struct eth_driver rte_em_pmd = {
 	{
 		.name = "rte_em_pmd",
 		.id_table = pci_id_em_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_LSC,
 	},
 	.eth_dev_init = eth_em_dev_init,
 	.dev_private_size = sizeof(struct e1000_adapter),
--- a/lib/librte_pmd_e1000/igb_ethdev.c	2014-06-19 14:56:44.188081500 -0700
+++ b/lib/librte_pmd_e1000/igb_ethdev.c	2014-06-19 14:58:14.268554028 -0700
@@ -662,7 +662,7 @@ static struct eth_driver rte_igb_pmd = {
 	{
 		.name = "rte_igb_pmd",
 		.id_table = pci_id_igb_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_LSC,
 	},
 	.eth_dev_init = eth_igb_dev_init,
 	.dev_private_size = sizeof(struct e1000_adapter),
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c	2014-06-19 14:56:44.188081500 -0700
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c	2014-06-19 14:57:31.060327549 -0700
@@ -1049,7 +1049,7 @@ static struct eth_driver rte_ixgbe_pmd =
 	{
 		.name = "rte_ixgbe_pmd",
 		.id_table = pci_id_ixgbe_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_LSC,
 	},
 	.eth_dev_init = eth_ixgbe_dev_init,
 	.dev_private_size = sizeof(struct ixgbe_adapter),
--- a/lib/librte_ether/rte_ethdev.c	2014-06-19 14:56:44.188081500 -0700
+++ b/lib/librte_ether/rte_ethdev.c	2014-06-19 14:56:44.184081479 -0700
@@ -640,6 +640,20 @@ rte_eth_dev_configure(uint8_t port_id, u
 	memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
 
 	/*
+	 * If link state interrupt is enabled, check that the
+	 * device supports it.
+	 */
+	if (dev_conf->intr_conf.lsc == 1) {
+		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
+
+		if (!(pci_drv->drv_flags & RTE_PCI_DRV_LSC)) {
+			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
+					pci_drv->name);
+			return (-EINVAL);
+		}
+	}
+
+	/*
 	 * If jumbo frames are enabled, check that the maximum RX packet
 	 * length is supported by the configured device.
 	 */

             reply	other threads:[~2014-06-19 22:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 22:12 Stephen Hemminger [this message]
2014-06-20 13:06 ` Thomas Monjalon
2014-06-25  9:27   ` Thomas Monjalon
2014-06-27  0:23   ` Thomas Monjalon

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=20140619151238.28b9bbea@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber.org \
    --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).