[v1,6/8] net/i40e: add mirror rule config and export add/del rule APIs
diff mbox series

Message ID 20201014084131.72035-7-simonx.lu@intel.com
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • use generic flow command to re-realize mirror rule
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

SimonX Lu Oct. 14, 2020, 8:41 a.m. UTC
From: Simon Lu <simonx.lu@intel.com>

define i40e_mirror_rule_conf structure that is used for set mirror flow
rule to i40e register, and export add/del mirror rule APIs.

Signed-off-by: Simon Lu <simonx.lu@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 13 +++++--------
 drivers/net/i40e/i40e_ethdev.h | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 943cfe71d..472a642b9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -332,12 +332,6 @@  static int i40e_dev_sync_phy_type(struct i40e_hw *hw);
 static void i40e_configure_registers(struct i40e_hw *hw);
 static void i40e_hw_init(struct rte_eth_dev *dev);
 static int i40e_config_qinq(struct i40e_hw *hw, struct i40e_vsi *vsi);
-static enum i40e_status_code i40e_aq_del_mirror_rule(struct i40e_hw *hw,
-						     uint16_t seid,
-						     uint16_t rule_type,
-						     uint16_t *entries,
-						     uint16_t count,
-						     uint16_t rule_id);
 static int i40e_mirror_rule_set(struct rte_eth_dev *dev,
 			struct rte_eth_mirror_conf *mirror_conf,
 			uint8_t sw_id, uint8_t on);
@@ -1744,6 +1738,9 @@  eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
 	/* initialize RSS rule list */
 	TAILQ_INIT(&pf->rss_config_list);
 
+	/* initialize mirror filter list */
+	TAILQ_INIT(&pf->mirror_filter_list);
+
 	/* initialize Traffic Manager configuration */
 	i40e_tm_conf_init(dev);
 
@@ -10993,7 +10990,7 @@  i40e_config_qinq(struct i40e_hw *hw, struct i40e_vsi *vsi)
  * Add a mirror rule for a given veb.
  *
  **/
-static enum i40e_status_code
+enum i40e_status_code
 i40e_aq_add_mirror_rule(struct i40e_hw *hw,
 			uint16_t seid, uint16_t dst_id,
 			uint16_t rule_type, uint16_t *entries,
@@ -11044,7 +11041,7 @@  i40e_aq_add_mirror_rule(struct i40e_hw *hw,
  * Delete a mirror rule for a given veb.
  *
  **/
-static enum i40e_status_code
+enum i40e_status_code
 i40e_aq_del_mirror_rule(struct i40e_hw *hw,
 		uint16_t seid, uint16_t rule_type, uint16_t *entries,
 		uint16_t count, uint16_t rule_id)
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1466998aa..95c2b4e2c 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1065,6 +1065,30 @@  struct i40e_rss_filter {
 	struct i40e_rte_flow_rss_conf rss_filter_info;
 };
 
+/**
+ * Mirror rule configuration
+ */
+struct i40e_mirror_rule_conf {
+	uint8_t  rule_type;
+	uint16_t rule_id;       /* the rule id assigned by firmware */
+	uint16_t dst_vsi_seid;  /* destination vsi for this mirror rule. */
+	uint16_t num_entries;
+	/**
+	 * the info stores depend on the rule type.
+	 * If type is I40E_MIRROR_TYPE_VLAN, vlan ids are stored here.
+	 *  If type is I40E_MIRROR_TYPE_VPORT_*, vsi's seid are stored.
+	 */
+	uint16_t entries[I40E_MIRROR_MAX_ENTRIES_PER_RULE];
+};
+
+TAILQ_HEAD(i40e_mirror_filter_list, i40e_mirror_filter);
+
+/* Mirror rule list structure */
+struct i40e_mirror_filter {
+	TAILQ_ENTRY(i40e_mirror_filter) next;
+	struct i40e_mirror_rule_conf conf;
+};
+
 struct i40e_vf_msg_cfg {
 	/* maximal VF message during a statistic period */
 	uint32_t max_msg;
@@ -1135,6 +1159,7 @@  struct i40e_pf {
 	struct i40e_tunnel_rule tunnel; /* Tunnel filter rule */
 	struct i40e_rte_flow_rss_conf rss_info; /* RSS info */
 	struct i40e_rss_conf_list rss_config_list; /* RSS rule list */
+	struct i40e_mirror_filter_list mirror_filter_list;
 	struct i40e_queue_regions queue_region; /* queue region info */
 	struct i40e_fc_conf fc_conf; /* Flow control conf */
 	struct i40e_mirror_rule_list mirror_list;
@@ -1299,6 +1324,7 @@  union i40e_filter_t {
 	struct rte_eth_tunnel_filter_conf tunnel_filter;
 	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
 	struct i40e_rte_flow_rss_conf rss_conf;
+	struct i40e_mirror_rule_conf mirror_conf;
 };
 
 typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -1457,6 +1483,14 @@  int i40e_config_rss_filter(struct i40e_pf *pf,
 int i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params);
 int i40e_vf_representor_uninit(struct rte_eth_dev *ethdev);
 
+enum i40e_status_code i40e_aq_add_mirror_rule(struct i40e_hw *hw,
+		uint16_t seid, uint16_t dst_id,
+		uint16_t rule_type, uint16_t *entries,
+		uint16_t count, uint16_t *rule_id);
+enum i40e_status_code i40e_aq_del_mirror_rule(struct i40e_hw *hw,
+		uint16_t seid, uint16_t rule_type, uint16_t *entries,
+		uint16_t count, uint16_t rule_id);
+
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)