[dpdk-dev,v7,4/9] ethdev: Add port representor device flag

Message ID 20180416130605.6509-5-declan.doherty@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Doherty, Declan April 16, 2018, 1:06 p.m. UTC
  Add new device flag to specify that an ethdev port is a port representor.
Extend rte_eth_dev_info structure to expose device flags to the user which
enables applications to discover if a port is a representor port.

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 2 ++
 lib/librte_ether/rte_ethdev.h | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon April 24, 2018, 7:37 p.m. UTC | #1
16/04/2018 15:06, Declan Doherty:
> Add new device flag to specify that an ethdev port is a port representor.
> Extend rte_eth_dev_info structure to expose device flags to the user which
> enables applications to discover if a port is a representor port.
[...]
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -2431,6 +2431,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
>  	dev_info->driver_name = dev->device->driver->name;
>  	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
>  	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
> +
> +	dev_info->dev_flags = dev->data->dev_flags;
>  }
[...]
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1032,6 +1032,7 @@ struct rte_eth_dev_info {
>  	const char *driver_name; /**< Device Driver name. */
>  	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
>  		Use if_indextoname() to translate into an interface name. */
> +	uint32_t dev_flags; /**< Device flags */

A similar field has been added recently:

	http://dpdk.org/browse/next/dpdk-next-net/tree/lib/librte_ether/rte_ethdev.h#n1074

	/** Generic device capabilities */
	uint64_t dev_capa;

It is for flags DEV_CAPA_*
Note that the prefix should be fixed to RTE_ETH_DEV,
and the doxygen comment should mention the flags prefix.
Qi, please fix.

I think dev_capa and dev_flags are the same thing.
They could be merged.

>  /** Device supports link state interrupt */
> -#define RTE_ETH_DEV_INTR_LSC     0x0002
> +#define RTE_ETH_DEV_INTR_LSC		0x0002
>  /** Device is a bonded slave */
> -#define RTE_ETH_DEV_BONDED_SLAVE 0x0004
> +#define RTE_ETH_DEV_BONDED_SLAVE	0x0004
>  /** Device supports device removal interrupt */
> -#define RTE_ETH_DEV_INTR_RMV     0x0008
> +#define RTE_ETH_DEV_INTR_RMV		0x0008
> +/** Device is port representor */
> +#define RTE_ETH_DEV_REPRESENTOR		0x0010

It seems you tried to re-align but it fails.
Better to use spaces for alignment.
  
Doherty, Declan April 25, 2018, 12:17 p.m. UTC | #2
On 24/04/2018 8:37 PM, Thomas Monjalon wrote:
> 16/04/2018 15:06, Declan Doherty:
>> Add new device flag to specify that an ethdev port is a port representor.
>> Extend rte_eth_dev_info structure to expose device flags to the user which
>> enables applications to discover if a port is a representor port.
> [...]
>> --- a/lib/librte_ether/rte_ethdev.c
>> +++ b/lib/librte_ether/rte_ethdev.c
>> @@ -2431,6 +2431,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
>>   	dev_info->driver_name = dev->device->driver->name;
>>   	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
>>   	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
>> +
>> +	dev_info->dev_flags = dev->data->dev_flags;
>>   }
> [...]
>> --- a/lib/librte_ether/rte_ethdev.h
>> +++ b/lib/librte_ether/rte_ethdev.h
>> @@ -1032,6 +1032,7 @@ struct rte_eth_dev_info {
>>   	const char *driver_name; /**< Device Driver name. */
>>   	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
>>   		Use if_indextoname() to translate into an interface name. */
>> +	uint32_t dev_flags; /**< Device flags */
> 
> A similar field has been added recently:
> 
> 	http://dpdk.org/browse/next/dpdk-next-net/tree/lib/librte_ether/rte_ethdev.h#n1074
> 
> 	/** Generic device capabilities */
> 	uint64_t dev_capa;
> 
> It is for flags DEV_CAPA_*
> Note that the prefix should be fixed to RTE_ETH_DEV,
> and the doxygen comment should mention the flags prefix.
> Qi, please fix.
> 
> I think dev_capa and dev_flags are the same thing.
> They could be merged.

Do you have a preference for which one to keep, as dev_flags within
rte_eth_dev_data is widely used by PMDs and passing this same 
information out through rte_eth_dev_info makes sense to me?

> 
>>   /** Device supports link state interrupt */
>> -#define RTE_ETH_DEV_INTR_LSC     0x0002
>> +#define RTE_ETH_DEV_INTR_LSC		0x0002
>>   /** Device is a bonded slave */
>> -#define RTE_ETH_DEV_BONDED_SLAVE 0x0004
>> +#define RTE_ETH_DEV_BONDED_SLAVE	0x0004
>>   /** Device supports device removal interrupt */
>> -#define RTE_ETH_DEV_INTR_RMV     0x0008
>> +#define RTE_ETH_DEV_INTR_RMV		0x0008
>> +/** Device is port representor */
>> +#define RTE_ETH_DEV_REPRESENTOR		0x0010
> 
> It seems you tried to re-align but it fails.
> Better to use spaces for alignment.
> 
sure will fix.
> 
>
  
Thomas Monjalon April 25, 2018, 12:23 p.m. UTC | #3
25/04/2018 14:17, Doherty, Declan:
> On 24/04/2018 8:37 PM, Thomas Monjalon wrote:
> > I think dev_capa and dev_flags are the same thing.
> > They could be merged.
> 
> Do you have a preference for which one to keep, as dev_flags within
> rte_eth_dev_data is widely used by PMDs and passing this same 
> information out through rte_eth_dev_info makes sense to me?

I think a big cleanup in ethdev structures is required.
We could avoid copying fields from one struct to the other.
But I don't want to block this patch, so go ahead and we will clean
this mess later.
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b16d23b9a..1d38d8e75 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2431,6 +2431,8 @@  rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
 	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
+
+	dev_info->dev_flags = dev->data->dev_flags;
 }
 
 int
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b5e5fc52a..0a52067d3 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1032,6 +1032,7 @@  struct rte_eth_dev_info {
 	const char *driver_name; /**< Device Driver name. */
 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
 		Use if_indextoname() to translate into an interface name. */
+	uint32_t dev_flags; /**< Device flags */
 	uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */
 	uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */
 	uint16_t max_rx_queues; /**< Maximum number of RX queues. */
@@ -1268,11 +1269,13 @@  struct rte_eth_dev_owner {
 };
 
 /** Device supports link state interrupt */
-#define RTE_ETH_DEV_INTR_LSC     0x0002
+#define RTE_ETH_DEV_INTR_LSC		0x0002
 /** Device is a bonded slave */
-#define RTE_ETH_DEV_BONDED_SLAVE 0x0004
+#define RTE_ETH_DEV_BONDED_SLAVE	0x0004
 /** Device supports device removal interrupt */
-#define RTE_ETH_DEV_INTR_RMV     0x0008
+#define RTE_ETH_DEV_INTR_RMV		0x0008
+/** Device is port representor */
+#define RTE_ETH_DEV_REPRESENTOR		0x0010
 
 /**
  * @warning