DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jingjing Wu <jingjing.wu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 09/15] ixgbe: implement the get info and statistic operations of flow director
Date: Thu, 29 Jan 2015 13:29:19 +0800	[thread overview]
Message-ID: <1422509365-13596-10-git-send-email-jingjing.wu@intel.com> (raw)
In-Reply-To: <1422509365-13596-1-git-send-email-jingjing.wu@intel.com>

This patch changes the get info operation to be implemented through
filter_ctrl API and RTE_ETH_FILTER_INFO/RTE_ETH_FILTER_STATS ops.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |  1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  3 --
 lib/librte_pmd_ixgbe/ixgbe_fdir.c   | 94 ++++++++++++++++++++++++++++++-------
 3 files changed, 78 insertions(+), 20 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 8bc7009..a2cdef7 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -360,7 +360,6 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
 	.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
 	.set_vf_rate_limit    = ixgbe_set_vf_rate_limit,
-	.fdir_infos_get               = ixgbe_fdir_info_get,
 	.reta_update          = ixgbe_dev_rss_reta_update,
 	.reta_query           = ixgbe_dev_rss_reta_query,
 #ifdef RTE_NIC_BYPASS
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index 7961167..e985199 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -323,9 +323,6 @@ int ixgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  */
 int ixgbe_fdir_configure(struct rte_eth_dev *dev);
 
-void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
-		struct rte_eth_fdir *fdir);
-
 void ixgbe_configure_dcb(struct rte_eth_dev *dev);
 
 /*
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index 16b0ba8..40ab342 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -130,6 +130,11 @@ static int ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 			      const struct rte_eth_fdir_filter *fdir_filter,
 			      bool del,
 			      bool update);
+static void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
+			struct rte_eth_fdir_info *fdir_info);
+static void ixgbe_fdir_stats_get(struct rte_eth_dev *dev,
+			struct rte_eth_fdir_stats *fdir_stats);
+
 /**
  * This function is based on ixgbe_fdir_enable_82599() in ixgbe/ixgbe_82599.c.
  * It adds extra configuration of fdirctrl that is common for all filter types.
@@ -959,19 +964,61 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 	return err;
 }
 
-void
-ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir *fdir)
+#define FDIRENTRIES_NUM_SHIFT 10
+static void
+ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbe_hw_fdir_info *info =
 			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
-	uint32_t reg;
+	uint32_t fdirctrl, max_num;
+	uint8_t offset;
 
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return;
+	fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+	offset = ((fdirctrl & IXGBE_FDIRCTRL_FLEX_MASK) >>
+			IXGBE_FDIRCTRL_FLEX_SHIFT) * sizeof(uint16_t);
+
+	fdir_info->mode = dev->data->dev_conf.fdir_conf.mode;
+	max_num = (1 << (FDIRENTRIES_NUM_SHIFT +
+			(fdirctrl & FDIRCTRL_PBALLOC_MASK)));
+	if (fdir_info->mode == RTE_FDIR_MODE_PERFECT)
+		fdir_info->guarant_spc = max_num;
+	else if (fdir_info->mode == RTE_FDIR_MODE_SIGNATURE)
+		fdir_info->guarant_spc = max_num * 4;
+
+	fdir_info->mask.vlan_tci_mask = info->mask.vlan_tci_mask;
+	fdir_info->mask.ipv4_mask.src_ip = info->mask.src_ipv4_mask;
+	fdir_info->mask.ipv4_mask.dst_ip = info->mask.dst_ipv4_mask;
+	IPV6_MASK_TO_ADDR(info->mask.src_ipv6_mask,
+			fdir_info->mask.ipv6_mask.src_ip);
+	IPV6_MASK_TO_ADDR(info->mask.dst_ipv6_mask,
+			fdir_info->mask.ipv6_mask.dst_ip);
+	fdir_info->mask.src_port_mask = info->mask.src_port_mask;
+	fdir_info->mask.dst_port_mask = info->mask.dst_port_mask;
+	fdir_info->max_flexpayload = IXGBE_FDIR_MAX_FLEX_LEN;
+	fdir_info->flow_types_mask[0] = IXGBE_FDIR_FLOW_TYPES;
+	fdir_info->flex_payload_unit = sizeof(uint16_t);
+	fdir_info->max_flex_payload_segment_num = 1;
+	fdir_info->flex_payload_limit = 62;
+	fdir_info->flex_conf.nb_payloads = 1;
+	fdir_info->flex_conf.flex_set[0].type = RTE_ETH_RAW_PAYLOAD;
+	fdir_info->flex_conf.flex_set[0].src_offset[0] = offset;
+	fdir_info->flex_conf.flex_set[0].src_offset[1] = offset + 1;
+	fdir_info->flex_conf.nb_flexmasks = 1;
+	fdir_info->flex_conf.flex_mask[0].flow_type = RTE_ETH_FLOW_TYPE_RAW;
+	fdir_info->flex_conf.flex_mask[0].mask[0] =
+			(uint8_t)(info->mask.flex_bytes_mask & 0x00FF);
+	fdir_info->flex_conf.flex_mask[0].mask[1] =
+			(uint8_t)((info->mask.flex_bytes_mask & 0xFF00) >> 8);
+}
+
+static void
+ixgbe_fdir_stats_get(struct rte_eth_dev *dev, struct rte_eth_fdir_stats *fdir_stats)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_hw_fdir_info *info =
+			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
+	uint32_t reg, max_num;
 
 	/* Get the information from registers */
 	reg = IXGBE_READ_REG(hw, IXGBE_FDIRFREE);
@@ -999,14 +1046,23 @@ ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir *fdir)
 		IXGBE_FDIRFSTAT_FADD_SHIFT;
 
 	/*  Copy the new information in the fdir parameter */
-	fdir->collision = info->collision;
-	fdir->free = info->free;
-	fdir->maxhash = info->maxhash;
-	fdir->maxlen = info->maxlen;
-	fdir->remove = info->remove;
-	fdir->add = info->add;
-	fdir->f_remove = info->f_remove;
-	fdir->f_add = info->f_add;
+	fdir_stats->collision = info->collision;
+	fdir_stats->free = info->free;
+	fdir_stats->maxhash = info->maxhash;
+	fdir_stats->maxlen = info->maxlen;
+	fdir_stats->remove = info->remove;
+	fdir_stats->add = info->add;
+	fdir_stats->f_remove = info->f_remove;
+	fdir_stats->f_add = info->f_add;
+
+	reg = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+	max_num = (1 << (FDIRENTRIES_NUM_SHIFT +
+			(reg & FDIRCTRL_PBALLOC_MASK)));
+	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT)
+			fdir_stats->guarant_cnt = max_num - fdir_stats->free;
+	else if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_SIGNATURE)
+		fdir_stats->guarant_cnt = max_num * 4 - fdir_stats->free;
+
 }
 
 /*
@@ -1047,6 +1103,12 @@ ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev,
 		ret = ixgbe_add_del_fdir_filter(dev,
 			(struct rte_eth_fdir_filter *)arg, TRUE, FALSE);
 		break;
+	case RTE_ETH_FILTER_INFO:
+		ixgbe_fdir_info_get(dev, (struct rte_eth_fdir_info *)arg);
+		break;
+	case RTE_ETH_FILTER_STATS:
+		ixgbe_fdir_stats_get(dev, (struct rte_eth_fdir_stats *)arg);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
 		ret = -EINVAL;
-- 
1.9.3

  parent reply	other threads:[~2015-01-29  5:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 01/15] ixgbe: migrate flow director filter operations (add/delete/update) " Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 02/15] ethdev: extend flow type and flexible payload type definition for flow director Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 03/15] ixgbe: implement the flexpayload configuration of flow director filter Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 04/15] app/test: remove the flexbytes_offset setting in test_link_bonding Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 05/15] testpmd: remove the flexbytes_offset setting Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 06/15] ethdev: remove flexbytes_offset from rte_fdir_conf Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 07/15] ethdev: structures definition for flow director masks Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 08/15] ixgbe: implement the mask configuration of flow director filter Jingjing Wu
2015-01-29  5:29 ` Jingjing Wu [this message]
2015-01-29  5:29 ` [dpdk-dev] [PATCH 10/15] ixgbe: implement the flush operation of flow director Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 11/15] testpmd: add and update commands for " Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 12/15] testpmd: update function to show flow director information Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 13/15] testpmd: set the default value of flow director's mask Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 14/15] testpmd: remove old commands for flow director Jingjing Wu
2015-01-29  5:29 ` [dpdk-dev] [PATCH 15/15] doc: commands changed in testpmd_funcs.rst " Jingjing Wu
2015-02-11  8:09 ` [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Zhang, Helin
2015-02-22  1:04   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422509365-13596-10-git-send-email-jingjing.wu@intel.com \
    --to=jingjing.wu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).