Skip to contentSkip to conversation

rte_ethdev: add link support flag

PATCH In review Stephen Hemminger 2 participants 4 messages Jun 19, 2014 – Jun 27, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rte_ethdev: add link support flag

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.

---
 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(-)
lib/librte_eal/common/include/rte_pci.h +2 -0
@@ -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)                   \
lib/librte_pmd_e1000/em_ethdev.c +1 -1
@@ -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),
lib/librte_pmd_e1000/igb_ethdev.c +1 -1
@@ -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),
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +1 -1
@@ -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),
lib/librte_ether/rte_ethdev.c +14 -0
@@ -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.
 	 */

A message that is not in the archive (sent off-list or not yet received): 20140619151238.28b9bbea-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org

#2 lore raw

Hi Stephen,

2014-06-19 15:12, Stephen Hemminger:

Quoted 10 lines

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.

[...]

lib/librte_eal/common/include/rte_pci.h struct rte_pci_driver { · line 201

Quoted 6 lines
lib/librte_eal/common/include/rte_pci.h +2 -0
@@ -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

I feel RTE_PCI_DRV_INTR_LSC would be easier to understand. Do you agree?

Note that related event is RTE_ETH_EVENT_INTR_LSC
and configuration is intr_conf.lsc.

Title should be "ethdev: add link state interrupt flag".

Thanks

Signature · 1 line
Thomas
#3 lore raw

Hi Stephen,

I had no answer to this comment.
Please check.

2014-06-20 15:06, Thomas Monjalon:

Quoted 25 lines

2014-06-19 15:12, Stephen Hemminger:

Quoted 9 lines

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.

[...]

lib/librte_eal/common/include/rte_pci.h struct rte_pci_driver { · line 203

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +2 -0
@@ -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

I feel RTE_PCI_DRV_INTR_LSC would be easier to understand. Do you agree?

Quoted 4 lines

Note that related event is RTE_ETH_EVENT_INTR_LSC
and configuration is intr_conf.lsc.

Title should be "ethdev: add link state interrupt flag".

A v3 would be nice.

Thanks

Signature · 1 line
Thomas
#4 lore raw
In reply to Thomas Monjalon

2014-06-20 15:06, Thomas Monjalon:

Quoted 19 lines

2014-06-19 15:12, Stephen Hemminger:

Quoted 9 lines

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.

[...]

Quoted 6 lines
lib/librte_eal/common/include/rte_pci.h +0 -0
@@ -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
 
Quoted 8 lines

lib/librte_eal/common/include/rte_pci.h struct rte_pci_driver { · line 201

Quoted 2 lines
lib/librte_eal/common/include/rte_pci.h +2 -0
+/** Device driver supports link state interrupt */
+#define RTE_PCI_DRV_LSC	0x0008

I feel RTE_PCI_DRV_INTR_LSC would be easier to understand. Do you agree?

Note that related event is RTE_ETH_EVENT_INTR_LSC
and configuration is intr_conf.lsc.

Applied with flag renamed.

Thanks

Signature · 1 line
Thomas