[dpdk-dev,v7,01/11] ethdev: add API to query packet type filling info

Message ID 1457551895-12077-2-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Jianfeng Tan March 9, 2016, 7:31 p.m. UTC
  Add a new API rte_eth_dev_get_ptype_info to query whether/what packet
type can be filled by given already started device or its pmd rx burst
function has already been decided).

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 doc/guides/rel_notes/release_16_04.rst |  3 +++
 lib/librte_ether/rte_ethdev.c          | 26 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 27 +++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  8 ++++++++
 4 files changed, 64 insertions(+)
  

Comments

Bruce Richardson March 10, 2016, 2:28 p.m. UTC | #1
On Thu, Mar 10, 2016 at 03:31:25AM +0800, Jianfeng Tan wrote:
> Add a new API rte_eth_dev_get_ptype_info to query whether/what packet
> type can be filled by given already started device or its pmd rx burst
> function has already been decided).
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
>  doc/guides/rel_notes/release_16_04.rst |  3 +++
>  lib/librte_ether/rte_ethdev.c          | 26 ++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.h          | 27 +++++++++++++++++++++++++++
>  lib/librte_ether/rte_ether_version.map |  8 ++++++++
>  4 files changed, 64 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
> index aa9eabc..376ece5 100644
> --- a/doc/guides/rel_notes/release_16_04.rst
> +++ b/doc/guides/rel_notes/release_16_04.rst
> @@ -162,6 +162,9 @@ This section should contain API changes. Sample format:
>    handlers are updated: the pipeline parameter is added,
>    the packets mask parameter has been either removed or made input-only.
>  
> +* A new API ``rte_eth_dev_get_ptype_info`` is added to query what packet types
> +  can be filled by given already started device.
> +
>  

Do we fill in API additions into this section? No other patches add such
additions here - only changes. Therefore, I think this should be dropped from
the patch.

 <snip> 
>  /**
> + * Retrieve the packet type information of an Ethernet device.
> + *
> + * @note
> + *   Better to invoke this API after the device is already started or rx burst
> + *   function is decided, to obtain concise ptype information.

s/consise/correct/ ??

/Bruce
  
Thomas Monjalon March 14, 2016, 9:44 a.m. UTC | #2
2016-03-10 03:31, Jianfeng Tan:
> Add a new API rte_eth_dev_get_ptype_info to query whether/what packet
> type can be filled by given already started device or its pmd rx burst
> function has already been decided).
[...]
>  /**
> + * Retrieve the packet type information of an Ethernet device.
> + *
> + * @note
> + *   Better to invoke this API after the device is already started or rx burst
> + *   function is decided, to obtain concise ptype information.
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param ptype_mask
> + *   A hint of what kind of packet type which the caller is interested in.
> + * @param ptypes
> + *   An array pointer to store adequent packet types, allocated by caller.
> + * @param num
> + *  Size of the array pointed by param ptypes.
> + * @return
> + *   - (>0) Number of ptypes supported. If it exceeds param num, exceeding
> + *          packet types will not be filled in the given array.
> + *   - (0 or -ENOTSUP) if PMD does not fill the specified ptype.
> + *   - (-ENODEV) if *port_id* invalid.
> + */
> +int rte_eth_dev_get_ptype_info(uint8_t port_id, uint32_t ptype_mask,
> +			       uint32_t *ptypes, int num);

I think the word info is too vague.
What do you think of these names?
- rte_eth_dev_get_ptype_capa
- rte_eth_dev_get_supported_ptypes
  
Bruce Richardson March 14, 2016, 9:48 a.m. UTC | #3
On Mon, Mar 14, 2016 at 10:44:30AM +0100, Thomas Monjalon wrote:
> 2016-03-10 03:31, Jianfeng Tan:
> > Add a new API rte_eth_dev_get_ptype_info to query whether/what packet
> > type can be filled by given already started device or its pmd rx burst
> > function has already been decided).
> [...]
> >  /**
> > + * Retrieve the packet type information of an Ethernet device.
> > + *
> > + * @note
> > + *   Better to invoke this API after the device is already started or rx burst
> > + *   function is decided, to obtain concise ptype information.
> > + * @param port_id
> > + *   The port identifier of the Ethernet device.
> > + * @param ptype_mask
> > + *   A hint of what kind of packet type which the caller is interested in.
> > + * @param ptypes
> > + *   An array pointer to store adequent packet types, allocated by caller.
> > + * @param num
> > + *  Size of the array pointed by param ptypes.
> > + * @return
> > + *   - (>0) Number of ptypes supported. If it exceeds param num, exceeding
> > + *          packet types will not be filled in the given array.
> > + *   - (0 or -ENOTSUP) if PMD does not fill the specified ptype.
> > + *   - (-ENODEV) if *port_id* invalid.
> > + */
> > +int rte_eth_dev_get_ptype_info(uint8_t port_id, uint32_t ptype_mask,
> > +			       uint32_t *ptypes, int num);
> 
> I think the word info is too vague.
> What do you think of these names?
> - rte_eth_dev_get_ptype_capa
> - rte_eth_dev_get_supported_ptypes
> 
+1 for supported_ptypes

/Bruce
  

Patch

diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index aa9eabc..376ece5 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -162,6 +162,9 @@  This section should contain API changes. Sample format:
   handlers are updated: the pipeline parameter is added,
   the packets mask parameter has been either removed or made input-only.
 
+* A new API ``rte_eth_dev_get_ptype_info`` is added to query what packet types
+  can be filled by given already started device.
+
 
 ABI Changes
 -----------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 5c2b416..d828dcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1576,6 +1576,32 @@  rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 	dev_info->driver_name = dev->data->drv_name;
 }
 
+int
+rte_eth_dev_get_ptype_info(uint8_t port_id, uint32_t ptype_mask,
+			   uint32_t *ptypes, int num)
+{
+	int i, j;
+	struct rte_eth_dev *dev;
+	const uint32_t *all_ptypes;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_ptype_info_get, -ENOTSUP);
+	all_ptypes = (*dev->dev_ops->dev_ptype_info_get)(dev);
+
+	if (!all_ptypes)
+		return 0;
+
+	for (i = 0, j = 0; all_ptypes[i] != RTE_PTYPE_UNKNOWN; ++i)
+		if (all_ptypes[i] & ptype_mask) {
+			if (j < num)
+				ptypes[j] = all_ptypes[i];
+			j++;
+		}
+
+	return j;
+}
+
 void
 rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d53e362..e0d2232 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1021,6 +1021,9 @@  typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
 				    struct rte_eth_dev_info *dev_info);
 /**< @internal Get specific informations of an Ethernet device. */
 
+typedef const uint32_t *(*eth_dev_ptype_info_get_t)(struct rte_eth_dev *dev);
+/**< @internal Get ptype info of an Ethernet device. */
+
 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
 				    uint16_t queue_id);
 /**< @internal Start rx and tx of a queue of an Ethernet device. */
@@ -1347,6 +1350,7 @@  struct eth_dev_ops {
 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
 	/**< Configure per queue stat counter mapping. */
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
+	eth_dev_ptype_info_get_t   dev_ptype_info_get; /** Get ptype info */
 	mtu_set_t                  mtu_set; /**< Set MTU. */
 	vlan_filter_set_t          vlan_filter_set;  /**< Filter VLAN Setup. */
 	vlan_tpid_set_t            vlan_tpid_set;      /**< Outer VLAN TPID Setup. */
@@ -2268,6 +2272,29 @@  void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the packet type information of an Ethernet device.
+ *
+ * @note
+ *   Better to invoke this API after the device is already started or rx burst
+ *   function is decided, to obtain concise ptype information.
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param ptype_mask
+ *   A hint of what kind of packet type which the caller is interested in.
+ * @param ptypes
+ *   An array pointer to store adequent packet types, allocated by caller.
+ * @param num
+ *  Size of the array pointed by param ptypes.
+ * @return
+ *   - (>0) Number of ptypes supported. If it exceeds param num, exceeding
+ *          packet types will not be filled in the given array.
+ *   - (0 or -ENOTSUP) if PMD does not fill the specified ptype.
+ *   - (-ENODEV) if *port_id* invalid.
+ */
+int rte_eth_dev_get_ptype_info(uint8_t port_id, uint32_t ptype_mask,
+			       uint32_t *ptypes, int num);
+
+/**
  * Retrieve the MTU of an Ethernet device.
  *
  * @param port_id
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index d8db24d..a12784c 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -117,3 +117,11 @@  DPDK_2.2 {
 
 	local: *;
 };
+
+DPDK_16.04 {
+	global:
+
+	rte_eth_dev_get_ptype_info;
+
+	local: *;
+} DPDK_2.2;