[dpdk-dev,v2,4/6] i40e: support of 'is_command_supported'
diff mbox

Message ID 1406535955-31070-5-git-send-email-helin.zhang@intel.com
State Superseded, archived
Headers show

Commit Message

Helin Zhang July 28, 2014, 8:25 a.m. UTC
'is_command_supported' is defined for the capability discovery.
Actually it is to check if a command (feature) is supported on
a specific type of NIC port. Now i40e supports below eight
commands. Of cause, more commands can be supported later.
 - RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE
 - RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE
 - RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT
 - RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT
 - RTE_CMD_GET_FILTER_SWAP
 - RTE_CMD_SET_FILTER_SWAP
 - RTE_CMD_GET_HASH_FUNCTION
 - RTE_CMD_SET_HASH_FUNCTION

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Patch
diff mbox

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c
index 4403af4..87a4999 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -204,6 +204,8 @@  static int i40e_dev_rss_hash_update(struct rte_eth_dev *dev,
 				    struct rte_eth_rss_conf *rss_conf);
 static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 				      struct rte_eth_rss_conf *rss_conf);
+static int i40e_dev_is_command_supported(struct rte_eth_dev *dev __rte_unused,
+					 enum rte_eth_command cmd);
 static int i40e_rx_classification_filter_ctl(struct rte_eth_dev *dev,
 					     enum rte_eth_command cmd,
 					     void *args);
@@ -252,6 +254,7 @@  static struct eth_dev_ops i40e_eth_dev_ops = {
 	.reta_query                   = i40e_dev_rss_reta_query,
 	.rss_hash_update              = i40e_dev_rss_hash_update,
 	.rss_hash_conf_get            = i40e_dev_rss_hash_conf_get,
+	.is_command_supported         = i40e_dev_is_command_supported,
 	.rx_classification_filter_ctl = i40e_rx_classification_filter_ctl,
 };
 
@@ -4292,6 +4295,31 @@  i40e_get_hash_function(struct i40e_hw *hw, enum rte_i40e_hash_function *hf)
 }
 
 static int
+i40e_dev_is_command_supported(struct rte_eth_dev *dev __rte_unused,
+			      enum rte_eth_command cmd)
+{
+	uint32_t i;
+	/* Below commands defined in rte_eth_features.h are for i40e only */
+	static const enum rte_eth_command i40e_commands[] = {
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE,
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT,
+		RTE_CMD_GET_FILTER_SWAP,
+		RTE_CMD_SET_FILTER_SWAP,
+		RTE_CMD_GET_HASH_FUNCTION,
+		RTE_CMD_SET_HASH_FUNCTION,
+	};
+
+	for (i = 0; i < RTE_DIM(i40e_commands); i++) {
+		if (i40e_commands[i] == cmd)
+			return 1;
+	}
+
+	return 0;
+}
+
+static int
 i40e_rx_classification_filter_ctl(struct rte_eth_dev *dev,
 				  enum rte_eth_command cmd,
 				  void *args)