DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC PATCH 1/2] e1000: release software locked semaphores on initialization
@ 2014-02-19 11:59 Didier Pallard
  2014-02-19 11:59 ` [dpdk-dev] [RFC PATCH 2/2] ixgbe: " Didier Pallard
  0 siblings, 1 reply; 16+ messages in thread
From: Didier Pallard @ 2014-02-19 11:59 UTC (permalink / raw)
  To: thomas.monjalon

It may happen that DPDK application gets killed while having
acquired locks on the ethernet hardware, causing these locks to
be never released. On next restart of the application, DPDK
skip those ports because it can not acquire the lock,
this may cause some ports (or even complete board if SMBI is locked)
to be inaccessible from DPDK application until reboot of the
hardware.

This patch release locks that are supposed to be locked due to
an improper exit of the application.

8254x series do not have SWFW sempahores.
82571 implementation already has some kind of lock reset at the end of
e1000_init_mac_params_82571 function. Since I have no mean to test this
implementation, code is not modified for this hardware.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
---
 lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c |   29 +++++++++++++++++++++
 lib/librte_pmd_e1000/e1000/e1000_82575.c       |   33 ++++++++++++++++++++++++
 lib/librte_pmd_e1000/e1000/e1000_i210.c        |    3 +--
 lib/librte_pmd_e1000/e1000/e1000_i210.h        |    1 +
 4 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c b/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
index 60d7c2a..952e8de 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
@@ -195,6 +195,7 @@ STATIC s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
 {
 	struct e1000_mac_info *mac = &hw->mac;
+	u16 mask;
 
 	DEBUGFUNC("e1000_init_mac_params_80003es2lan");
 
@@ -267,6 +268,34 @@ STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
 	/* set lan id for port to determine which phy lock to use */
 	hw->mac.ops.set_lan_id(hw);
 
+	/* Ensure that all locks are released before first NVM or PHY access */
+
+	/*
+	 * Phy lock should not fail in this early stage. If this is the case,
+	 * it is due to an improper exit of the application.
+	 * So force the release of the faulty lock.
+	 */
+	if (e1000_acquire_phy_80003es2lan(hw) < 0) {
+		if (e1000_get_hw_semaphore_generic(hw) < 0) {
+			DEBUGOUT("SMBI lock released");
+		}
+		e1000_put_hw_semaphore_generic(hw);
+		DEBUGOUT1("SWFW phy%d lock released", hw->bus.func);
+	}
+	e1000_release_phy_80003es2lan(hw);
+
+	/*
+	 * Those one are more tricky since they are common to all ports; but
+	 * swfw_sync retries last long enough (250ms) to be almost sure that if
+	 * lock can not be taken it is due to an improper lock of the
+	 * semaphore.
+	 */
+	mask = E1000_SWFW_EEP_SM | E1000_SWFW_CSR_SM;
+	if (hw->mac.ops.acquire_swfw_sync(hw, mask) < 0) {
+		DEBUGOUT("SWFW common locks released");
+	}
+	hw->mac.ops.release_swfw_sync(hw, mask);
+
 	return E1000_SUCCESS;
 }
 
diff --git a/lib/librte_pmd_e1000/e1000/e1000_82575.c b/lib/librte_pmd_e1000/e1000/e1000_82575.c
index fd15b7b..99c4a1f 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_82575.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_82575.c
@@ -507,6 +507,39 @@ STATIC s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
 	/* set lan id for port to determine which phy lock to use */
 	hw->mac.ops.set_lan_id(hw);
 
+	/* Ensure that all locks are released before first NVM or PHY access */
+
+	/*
+	 * Phy lock should not fail in this early stage. If this is the case,
+	 * it is due to an improper exit of the application.
+	 * So force the release of the faulty lock.
+	 */
+	if (e1000_acquire_phy_82575(hw) < 0) {
+		if (mac->type >= e1000_i210) {
+			if (e1000_get_hw_semaphore_i210(hw) < 0) {
+				DEBUGOUT("SMBI lock released");
+			}
+		} else {
+			if (e1000_get_hw_semaphore_generic(hw) < 0) {
+				DEBUGOUT("SMBI lock released");
+			}
+		}
+		e1000_put_hw_semaphore_generic(hw);
+		DEBUGOUT1("SWFW phy%d lock released", hw->bus.func);
+	}
+	e1000_release_phy_82575(hw);
+
+	/*
+	 * This one is more tricky since it is common to all ports; but
+	 * swfw_sync retries last long enough (1s) to be almost sure that if
+	 * lock can not be taken it is due to an improper lock of the
+	 * semaphore.
+	 */
+	if (hw->mac.ops.acquire_swfw_sync(hw, E1000_SWFW_EEP_SM) < 0) {
+		DEBUGOUT("SWFW common locks released");
+	}
+	hw->mac.ops.release_swfw_sync(hw, E1000_SWFW_EEP_SM);
+
 	return E1000_SUCCESS;
 }
 
diff --git a/lib/librte_pmd_e1000/e1000/e1000_i210.c b/lib/librte_pmd_e1000/e1000/e1000_i210.c
index 722877a..122fe70 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_i210.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_i210.c
@@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
 
 STATIC s32 e1000_acquire_nvm_i210(struct e1000_hw *hw);
 STATIC void e1000_release_nvm_i210(struct e1000_hw *hw);
-STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
 STATIC s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
 				u16 *data);
 STATIC s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw);
@@ -158,7 +157,7 @@ void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
  *
  *  Acquire the HW semaphore to access the PHY or NVM
  **/
-STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
+s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
 {
 	u32 swsm;
 	s32 timeout = hw->nvm.word_size + 1;
diff --git a/lib/librte_pmd_e1000/e1000/e1000_i210.h b/lib/librte_pmd_e1000/e1000/e1000_i210.h
index 44de54b..a9e8a64 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_i210.h
+++ b/lib/librte_pmd_e1000/e1000/e1000_i210.h
@@ -44,6 +44,7 @@ s32 e1000_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset,
 			     u16 words, u16 *data);
 s32 e1000_read_invm_version(struct e1000_hw *hw,
 			    struct e1000_fw_version *invm_ver);
+s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
 s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 s32 e1000_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-04-09 16:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 11:59 [dpdk-dev] [RFC PATCH 1/2] e1000: release software locked semaphores on initialization Didier Pallard
2014-02-19 11:59 ` [dpdk-dev] [RFC PATCH 2/2] ixgbe: " Didier Pallard
2014-02-19 12:41   ` Ananyev, Konstantin
2014-02-19 16:52     ` Thomas Monjalon
2014-02-19 17:51       ` Ananyev, Konstantin
2014-02-21 16:30         ` Ananyev, Konstantin
2014-02-24 14:19           ` didier.pallard
2014-02-24 15:34             ` Ananyev, Konstantin
2014-02-25  0:57             ` Ananyev, Konstantin
2014-02-26 10:52               ` didier.pallard
2014-04-08 13:29                 ` [dpdk-dev] [PATCH v3 1/2] " Didier Pallard
2014-04-08 13:29                   ` [dpdk-dev] [PATCH v3 2/2] igb: " Didier Pallard
2014-04-09 15:58                     ` Ananyev, Konstantin
2014-04-09 16:39                       ` Thomas Monjalon
2014-04-09 15:49                   ` [dpdk-dev] [PATCH v3 1/2] ixgbe: " Ananyev, Konstantin
2014-04-09 16:37                     ` Thomas Monjalon

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).