DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ouyang Changchun <changchun.ouyang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 03/18] ixgbe: New function to check command complete in IXGBE base code
Date: Thu, 25 Sep 2014 22:18:49 +0800	[thread overview]
Message-ID: <1411654744-9460-4-git-send-email-changchun.ouyang@intel.com> (raw)
In-Reply-To: <1411654744-9460-1-git-send-email-changchun.ouyang@intel.com>

This patch implements a function to check command complete for flow director in
IXGBE base code, and replaces related code snippet with this function.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c | 63 +++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 25 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
index 046a35e..126aa24 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
@@ -1313,11 +1313,30 @@ reset_hw_out:
 }
 
 /**
+ * ixgbe_fdir_check_cmd_complete - poll to check whether FDIRCMD is complete
+ * @hw: pointer to hardware structure
+ */
+STATIC s32 ixgbe_fdir_check_cmd_complete(struct ixgbe_hw *hw)
+{
+	int i;
+
+	for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
+		if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
+		      IXGBE_FDIRCMD_CMD_MASK))
+			return IXGBE_SUCCESS;
+		usec_delay(10);
+	}
+
+	return IXGBE_ERR_FDIR_CMD_INCOMPLETE;
+}
+
+/**
  *  ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
  *  @hw: pointer to hardware structure
  **/
 s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
 {
+	s32 err;
 	int i;
 	u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
 	fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
@@ -1328,16 +1347,10 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
 	 * Before starting reinitialization process,
 	 * FDIRCMD.CMD must be zero.
 	 */
-	for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
-		if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
-		      IXGBE_FDIRCMD_CMD_MASK))
-			break;
-		usec_delay(10);
-	}
-	if (i >= IXGBE_FDIRCMD_CMD_POLL) {
-		DEBUGOUT("Flow Director previous command isn't complete, "
-			 "aborting table re-initialization.\n");
-		return IXGBE_ERR_FDIR_REINIT_FAILED;
+	err = ixgbe_fdir_check_cmd_complete(hw);
+	if (err) {
+		DEBUGOUT("Flow Director previous command did not complete, aborting table re-initialization.\n");
+		return err;
 	}
 
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
@@ -1593,8 +1606,9 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
 					  union ixgbe_atr_hash_dword common,
 					  u8 queue)
 {
-	u64  fdirhashcmd;
-	u32  fdircmd;
+	u64 fdirhashcmd;
+	u32 fdircmd;
+	s32 err;
 
 	DEBUGFUNC("ixgbe_fdir_add_signature_filter_82599");
 
@@ -1630,6 +1644,12 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
 	fdirhashcmd |= ixgbe_atr_compute_sig_hash_82599(input, common);
 	IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
 
+	err = ixgbe_fdir_check_cmd_complete(hw);
+	if (err) {
+		DEBUGOUT("Flow Director command did not complete!\n");
+		return err;
+	}
+
 	DEBUGOUT2("Tx Queue=%x hash=%x\n", queue, (u32)fdirhashcmd);
 
 	return IXGBE_SUCCESS;
@@ -1906,8 +1926,7 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
 {
 	u32 fdirhash;
 	u32 fdircmd = 0;
-	u32 retry_count;
-	s32 err = IXGBE_SUCCESS;
+	s32 err;
 
 	/* configure FDIRHASH register */
 	fdirhash = input->formatted.bkt_hash;
@@ -1920,18 +1939,12 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
 	/* Query if filter is present */
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT);
 
-	for (retry_count = 10; retry_count; retry_count--) {
-		/* allow 10us for query to process */
-		usec_delay(10);
-		/* verify query completed successfully */
-		fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
-		if (!(fdircmd & IXGBE_FDIRCMD_CMD_MASK))
-			break;
+	err = ixgbe_fdir_check_cmd_complete(hw);
+	if (err) {
+		DEBUGOUT("Flow Director command did not complete!\n");
+		return err;
 	}
 
-	if (!retry_count)
-		err = IXGBE_ERR_FDIR_REINIT_FAILED;
-
 	/* if filter exists in hardware then remove it */
 	if (fdircmd & IXGBE_FDIRCMD_FILTER_VALID) {
 		IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
@@ -1940,7 +1953,7 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
 				IXGBE_FDIRCMD_CMD_REMOVE_FLOW);
 	}
 
-	return err;
+	return IXGBE_SUCCESS;
 }
 
 /**
-- 
1.8.4.2

  parent reply	other threads:[~2014-09-25 14:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25 14:18 [dpdk-dev] [PATCH 00/18] Update " Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 01/18] ixgbe: Update comments and fix some comments typo in " Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 02/18] ixgbe: Clean up IXGBE base codes Ouyang Changchun
2014-09-25 14:18 ` Ouyang Changchun [this message]
2014-09-25 14:18 ` [dpdk-dev] [PATCH 04/18] ixgbe: Support cloud mode in IXGBE base code Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 05/18] ixgbe: eeprom checksum calculation return new value " Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 06/18] ixgbe: New argument in host interface command function Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 07/18] ixgbe: Extend mask for SWFW semaphore Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 08/18] ixgbe: New function to read and write I2C bytes Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 09/18] ixgbe: Support new device id 82599_QSFP and 82599_LS Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 10/18] ixgbe: Modify time to wait in polling flash update Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 11/18] ixgbe: New error type Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 12/18] ixgbe: Use hardware MAC type for I2C control Ouyang Changchun
2014-09-25 14:18 ` [dpdk-dev] [PATCH 13/18] ixgbe: semaphore mask move into hardware physical information Ouyang Changchun
2014-09-25 14:19 ` [dpdk-dev] [PATCH 14/18] ixgbe: Remove unnecessary delay Ouyang Changchun
2014-09-25 14:19 ` [dpdk-dev] [PATCH 15/18] ixgbe: New function for resetting VF register Ouyang Changchun
2014-09-25 14:19 ` [dpdk-dev] [PATCH 16/18] ixgbe: New functionalities in IXGBE base code Ouyang Changchun
2014-09-25 14:19 ` [dpdk-dev] [PATCH 17/18] ixgbe: Support X550 " Ouyang Changchun
2014-09-25 14:19 ` [dpdk-dev] [PATCH 18/18] ixgbe: Support X550 in IXGBE poll mode driver Ouyang Changchun

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=1411654744-9460-4-git-send-email-changchun.ouyang@intel.com \
    --to=changchun.ouyang@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).