From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 16/37] ixgbe/base: add wait helper for IOSF accesses
Date: Wed, 24 Jun 2015 11:26:05 +0800 [thread overview]
Message-ID: <1435116386-12010-17-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1435116386-12010-1-git-send-email-wenzhuo.lu@intel.com>
Add a helper function to wait for IOSF accesses to complete. Also
perform this wait before each access, as specified in the datasheet.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/ixgbe/base/ixgbe_x550.c | 85 ++++++++++++++++++++++---------------
1 file changed, 50 insertions(+), 35 deletions(-)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c b/drivers/net/ixgbe/base/ixgbe_x550.c
index 4d36ea7..0109938 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -723,6 +723,39 @@ void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
}
/**
+ * ixgbe_iosf_wait - Wait for IOSF command completion
+ * @hw: pointer to hardware structure
+ * @ctrl: pointer to location to receive final IOSF control value
+ *
+ * Returns failing status on timeout
+ *
+ * Note: ctrl can be NULL if the IOSF control register value is not needed
+ **/
+STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
+{
+ u32 i, command = 0;
+
+ /* Check every 10 usec to see if the address cycle completed.
+ * The SB IOSF BUSY bit will clear when the operation is
+ * complete
+ */
+ for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+ command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
+ if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
+ break;
+ usec_delay(10);
+ }
+ if (ctrl)
+ *ctrl = command;
+ if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
+ ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
+ return IXGBE_ERR_PHY;
+ }
+
+ return IXGBE_SUCCESS;
+}
+
+/**
* ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
* device
* @hw: pointer to hardware structure
@@ -733,7 +766,12 @@ void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
u32 device_type, u32 data)
{
- u32 i, command, error;
+ u32 command, error;
+ s32 ret;
+
+ ret = ixgbe_iosf_wait(hw, NULL);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
(device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
@@ -743,18 +781,8 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
/* Write IOSF data register */
IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
- /*
- * Check every 10 usec to see if the address cycle completed.
- * The SB IOSF BUSY bit will clear when the operation is
- * complete
- */
- for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
- usec_delay(10);
- command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
- if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
- break;
- }
+ ret = ixgbe_iosf_wait(hw, &command);
if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
@@ -764,12 +792,7 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
return IXGBE_ERR_PHY;
}
- if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
- ERROR_REPORT1(IXGBE_ERROR_POLLING, "Write timed out\n");
- return IXGBE_ERR_PHY;
- }
-
- return IXGBE_SUCCESS;
+ return ret;
}
/**
@@ -783,7 +806,12 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
u32 device_type, u32 *data)
{
- u32 i, command, error;
+ u32 command, error;
+ s32 ret;
+
+ ret = ixgbe_iosf_wait(hw, NULL);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
(device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
@@ -791,18 +819,7 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
/* Write IOSF control register */
IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
- /*
- * Check every 10 usec to see if the address cycle completed.
- * The SB IOSF BUSY bit will clear when the operation is
- * complete
- */
- for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
- usec_delay(10);
-
- command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
- if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
- break;
- }
+ ret = ixgbe_iosf_wait(hw, &command);
if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
@@ -812,10 +829,8 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
return IXGBE_ERR_PHY;
}
- if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
- ERROR_REPORT1(IXGBE_ERROR_POLLING, "Read timed out\n");
- return IXGBE_ERR_PHY;
- }
+ if (ret != IXGBE_SUCCESS)
+ return ret;
*data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
--
1.9.3
next prev parent reply other threads:[~2015-06-24 3:27 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 3:25 [dpdk-dev] [PATCH 00/37] update ixgbe base driver Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 01/37] ixgbe/base: update readme Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 02/37] ixgbe/base: update Low Power Link Up to use MAC ops link Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 03/37] ixgbe/base: fix 1G and 10G link stability for x550em SFP+ Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 04/37] ixgbe/base: update x550em SFP link setup Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 05/37] ixgbe/base: add shift define for EEE_SU.TEEE_DLY Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 06/37] ixgbe/base: add x550em identify SFP module support Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 07/37] ixgbe/base: fix potential warning Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 08/37] ixgbe/base: return err when SFP module is not present Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 09/37] ixgbe/base: power down the x550em PHY on overtemp events Wenzhuo Lu
2015-06-24 3:25 ` [dpdk-dev] [PATCH 10/37] ixgbe/base: restore advertised autoneg after setting LPLU Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 11/37] ixgbe/base: fix UniPHY link configuration Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 12/37] ixgbe/base: add macro for x550em bus speed fuse Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 13/37] ixgbe/base: add a new 82599 device ID Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 14/37] ixgbe/base: enable FEC when EEE is disabled Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 15/37] ixgbe/base: release semaphores in proper order Wenzhuo Lu
2015-06-24 3:26 ` Wenzhuo Lu [this message]
2015-06-24 3:26 ` [dpdk-dev] [PATCH 17/37] ixgbe/base: use a semaphore to serialize IOSF accesses Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 18/37] ixgbe/base: check for functional ucode Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 19/37] ixgbe/base: add KR/iXFI internal link mode support Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 20/37] ixgbe/base: check link again after getting speed Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 21/37] ixgbe/base: config MDIO clock for x550em Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 22/37] ixgbe/base: add support for led_on and led_off for X557 PHY LEDs Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 23/37] ixgbe/base: update EEE/FEC support for device X550EM_X_KR Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 24/37] ixgbe/base: introduce array of mac-type-dependent values Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 25/37] ixgbe/base: use mvals array for I2C_*_BY_MAC values Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 26/37] ixgbe/base: use mvals array for *_GPI*_BY_MAC values Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 27/37] ixgbe/base: use mvals array for CIA*_BY_MAC values Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 28/37] ixgbe/base: add new mac-dependent values for x540, x550 Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 29/37] ixgbe/base: disable SW LPLU implementation for x557 V2 Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 30/37] ixgbe/base: remove FEC disablement for x550em Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 31/37] ixgbe/base: modify register definition code style Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 32/37] ixgbe/base: specific process for X550 and X550em when disabling PCIe master Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 33/37] ixgbe/base: fix flow control to be KR only Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 34/37] ixgbe/base: fix 5G and 2.5G speed description Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 35/37] ixgbe/base: force cs4227 LINE side to 10G SR mode Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 36/37] ixgbe/base: a minor optimization for max link up time Wenzhuo Lu
2015-06-24 3:26 ` [dpdk-dev] [PATCH 37/37] ixgbe/base: add support for new x550 PHY IDs Wenzhuo Lu
2015-06-25 1:24 ` [dpdk-dev] [PATCH 00/37] update ixgbe base driver Zhang, Helin
2015-06-26 11:27 ` 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=1435116386-12010-17-git-send-email-wenzhuo.lu@intel.com \
--to=wenzhuo.lu@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).