[dpdk-dev,2/5] ethdev: add new ops of 'check_command_supported' and 'rx_classification_filter_ctl'

Message ID 1406184149-11531-3-git-send-email-helin.zhang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Zhang, Helin July 24, 2014, 6:42 a.m. UTC
  Two ops of 'check_command_supported' and 'rx_classification_filter_ctl'
are added.
* 'check_command_supported' is for capability discovery. In anothoer
  word, it is to check if specific feature/command is supported by
  the specific port.
* 'rx_classification_filter_ctl' is for receive classifcation filter
  configuring. e.g. hash function configuration, flow director
  configuration. It is a common API where a lot of commands can
  be implemented for different sub features.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 31 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 52 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
  

Comments

Thomas Monjalon July 24, 2014, 7:56 a.m. UTC | #1
2014-07-24 14:42, Helin Zhang:
> Two ops of 'check_command_supported' and 'rx_classification_filter_ctl'
> are added.
> * 'check_command_supported' is for capability discovery. In anothoer
>   word, it is to check if specific feature/command is supported by
>   the specific port.

This generic service is really needed to add NIC-specific functions.
I'd suggest to name it "is_supported".

> * 'rx_classification_filter_ctl' is for receive classifcation filter
>   configuring. e.g. hash function configuration, flow director
>   configuration. It is a common API where a lot of commands can
>   be implemented for different sub features.

Not sure about this one. You are hiding specific API in an opaque structure.
By the way, it should be in another patch.

> +/**
> + * Check if the command is supported by an Ethernet device.
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param cmd
> + *   The command.
> + *
> + * @return
> + *   - (> 0) The command is supported.
> + *   - (0) The command is not supported.
> + *   - (-ENOTSUP) if hardware doesn't support.
> + *   - (-ENODEV) if <port_id> is invalid.
> + */
> +int rte_eth_dev_check_command_supported(uint8_t port_id, uint32_t cmd);

What are the possible commands?
You should define enum/constants here.
  
Zhang, Helin July 24, 2014, 8:49 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, July 24, 2014 3:57 PM
> To: Zhang, Helin
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 2/5] ethdev: add new ops of
> 'check_command_supported' and 'rx_classification_filter_ctl'
> 
> 2014-07-24 14:42, Helin Zhang:
> > Two ops of 'check_command_supported' and 'rx_classification_filter_ctl'
> > are added.
> > * 'check_command_supported' is for capability discovery. In anothoer
> >   word, it is to check if specific feature/command is supported by
> >   the specific port.
> 
> This generic service is really needed to add NIC-specific functions.
> I'd suggest to name it "is_supported".
> 
I tried to name it as the same style of rte_cpu_check_supported().
As you indicated, 'is_commmand_supported' might be a better name.

> > * 'rx_classification_filter_ctl' is for receive classifcation filter
> >   configuring. e.g. hash function configuration, flow director
> >   configuration. It is a common API where a lot of commands can
> >   be implemented for different sub features.
> 
> Not sure about this one. You are hiding specific API in an opaque structure.
> By the way, it should be in another patch.
> 
We want to implement several common API for NIC specific features, to avoid creating quite a lot of ops in 'struct eth_dev_ops'.
The idea came from ioctl.

> > +/**
> > + * Check if the command is supported by an Ethernet device.
> > + *
> > + * @param port_id
> > + *   The port identifier of the Ethernet device.
> > + * @param cmd
> > + *   The command.
> > + *
> > + * @return
> > + *   - (> 0) The command is supported.
> > + *   - (0) The command is not supported.
> > + *   - (-ENOTSUP) if hardware doesn't support.
> > + *   - (-ENODEV) if <port_id> is invalid.
> > + */
> > +int rte_eth_dev_check_command_supported(uint8_t port_id, uint32_t
> cmd);
> 
> What are the possible commands?
> You should define enum/constants here.
> 
The idea came from ioctl(). Enum could be a choice. The commands was defined in rte_eth_features.h. Comments should be added here for telling that.

> --
> Thomas
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fd1010a..7afffb4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3002,3 +3002,34 @@  rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,
 	return (*dev->dev_ops->get_flex_filter)(dev, index, filter,
 						rx_queue);
 }
+
+int
+rte_eth_dev_check_command_supported(uint8_t port_id, uint32_t cmd)
+{
+	struct rte_eth_dev *dev;
+
+	if (port_id >= nb_ports) {
+		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -ENODEV;
+	}
+	dev = &rte_eth_devices[port_id];
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->check_command_supported, -ENOTSUP);
+	return (*dev->dev_ops->check_command_supported)(dev, cmd);
+}
+
+int
+rte_eth_dev_rx_classification_filter_ctl(uint8_t port_id,
+					 uint32_t cmd,
+					 void *args)
+{
+	struct rte_eth_dev *dev;
+
+	if (port_id >= nb_ports) {
+		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -ENODEV;
+	}
+	dev = &rte_eth_devices[port_id];
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_classification_filter_ctl,
+								-ENOTSUP);
+	return (*dev->dev_ops->rx_classification_filter_ctl)(dev, cmd, args);
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index a262463..482e64d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1240,6 +1240,15 @@  typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
 				  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
 
+typedef int (*eth_check_command_supported_t)(struct rte_eth_dev *dev,
+					     uint32_t cmd);
+/**< @internal check if the command is supported by the Ethernet device */
+
+typedef int (*eth_rx_classification_filter_ctl_t)(struct rte_eth_dev *dev,
+						  uint32_t cmd,
+						  void *arg);
+/**< @internal receive classification filter control operations */
+
 #ifdef RTE_NIC_BYPASS
 
 enum {
@@ -1467,6 +1476,10 @@  struct eth_dev_ops {
 	eth_add_flex_filter_t          add_flex_filter;      /**< add flex filter. */
 	eth_remove_flex_filter_t       remove_flex_filter;   /**< remove flex filter. */
 	eth_get_flex_filter_t          get_flex_filter;      /**< get flex filter. */
+	eth_check_command_supported_t  check_command_supported;
+	/**< check if a command is supported. */
+	eth_rx_classification_filter_ctl_t rx_classification_filter_ctl;
+	/**< common control function of hw hash */
 };
 
 /**
@@ -3557,6 +3570,45 @@  int rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index);
 int rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,
 			struct rte_flex_filter *filter, uint16_t *rx_queue);
 
+/**
+ * Check if the command is supported by an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param cmd
+ *   The command.
+ *
+ * @return
+ *   - (> 0) The command is supported.
+ *   - (0) The command is not supported.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if <port_id> is invalid.
+ */
+int rte_eth_dev_check_command_supported(uint8_t port_id, uint32_t cmd);
+
+/**
+ * Control the receive classification filter, including hash function
+ * selection. The commands are NIC specific in its exported public
+ * header file. Different types of NIC may have different commands.
+ * For example, the supported commands for i40e can be found in rte_i40e.h.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param cmd
+ *   The commands.
+ * @param args
+ *   A pointer to arguments defined specifically for the command.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if <port_id> is invalid.
+ *   - others depends on the specific command implementation.
+ */
+int rte_eth_dev_rx_classification_filter_ctl(uint8_t port_id,
+					     uint32_t cmd,
+					     void *args);
+
 #ifdef __cplusplus
 }
 #endif