src/dpdk/drivers/net/txgbe/base/txgbe_hw.c
s32 txgbe_acquire_swfw_sync(struct txgbe_hw *hw, u32 mask)
{
	u32 mngsem = 0;
	u32 swmask = TXGBE_MNGSEM_SW(mask);
	u32 fwmask = TXGBE_MNGSEM_FW(mask);
	u32 timeout = 200;
	u32 i;

	DEBUGFUNC("txgbe_acquire_swfw_sync");

	for (i = 0; i < timeout; i++) {
		/*
		 * SW NVM semaphore bit is used for access to all
		 * SW_FW_SYNC bits (not just NVM)
		 */
		if (txgbe_get_eeprom_semaphore(hw))
			return TXGBE_ERR_SWFW_SYNC;

		mngsem = rd32(hw, TXGBE_MNGSEM);
		if (mngsem & (fwmask | swmask)) {
			/* Resource is currently in use by FW or SW */
			txgbe_release_eeprom_semaphore(hw);
			msec_delay(5);
		} else {
			mngsem |= swmask;
			wr32(hw, TXGBE_MNGSEM, mngsem);
			txgbe_release_eeprom_semaphore(hw);
			return 0;
		}
	}

	/* If time expired clear the bits holding the lock and retry */
	if (mngsem & (fwmask | swmask))
		txgbe_release_swfw_sync(hw, mngsem & (fwmask | swmask));

	msec_delay(5);
	return TXGBE_ERR_SWFW_SYNC;
}
/**
 *  txgbe_acquire_swfw_sync - Acquire SWFW semaphore
 *  @hw: pointer to hardware structure
 *  @mask: Mask to specify which semaphore to acquire
 *
 *  Acquires the SWFW semaphore through the MNGSEM register for the specified
 *  function (CSR, PHY0, PHY1, EEPROM, Flash)
 **/
Acquire SWFW semaphore
@hw: pointer to hardware structure
@mask: Mask to specify which semaphore to acquire

Acquires the SWFW semaphore through the MNGSEM register for the specified
function (CSR, PHY0, PHY1, EEPROM, Flash)
Acquire SWFW semaphore @hw : pointer to hardware structure @mask : Mask to specify which semaphore to acquire Acquires the SWFW semaphore through the MNGSEM register for the specified function ( CSR PHY0 PHY1 EEPROM Flash )
s32 txgbe_acquire_swfw_sync(struct txgbe_hw *hw, u32 mask)
{
	u32 mngsem = 0;
	u32 swmask = TXGBE_MNGSEM_SW(mask);
	u32 fwmask = TXGBE_MNGSEM_FW(mask);
	u32 timeout = 200;
	u32 i;
	DEBUGFUNC("txgbe_acquire_swfw_sync");
	for (i = 0; i < timeout; i++) {
		if (txgbe_get_eeprom_semaphore(hw))
			return TXGBE_ERR_SWFW_SYNC;
		mngsem = rd32(hw, TXGBE_MNGSEM);
		if (mngsem & (fwmask | swmask)) {
			txgbe_release_eeprom_semaphore(hw);
			msec_delay(5);
		} else {
			mngsem |= swmask;
			wr32(hw, TXGBE_MNGSEM, mngsem);
			txgbe_release_eeprom_semaphore(hw);
			return 0;
		}
	}
	if (mngsem & (fwmask | swmask))
		txgbe_release_swfw_sync(hw, mngsem & (fwmask | swmask));
	msec_delay(5);
	return TXGBE_ERR_SWFW_SYNC;
}
s32 txgbe_acquire_swfw_sync ( struct txgbe_hw * hw , u32 mask ) { u32 mngsem = 0 ; u32 swmask = TXGBE_MNGSEM_SW ( mask ) ; u32 fwmask = TXGBE_MNGSEM_FW ( mask ) ; u32 timeout = 200 ; u32 i ; DEBUGFUNC ( " " ) ; for ( i = 0 ; i < timeout ; i ++ ) { if ( txgbe_get_eeprom_semaphore ( hw ) ) return TXGBE_ERR_SWFW_SYNC ; mngsem = rd32 ( hw , TXGBE_MNGSEM ) ; if ( mngsem & ( fwmask | swmask ) ) { txgbe_release_eeprom_semaphore ( hw ) ; msec_delay ( 5 ) ; } else { mngsem |= swmask ; wr32 ( hw , TXGBE_MNGSEM , mngsem ) ; txgbe_release_eeprom_semaphore ( hw ) ; return 0 ; } } if ( mngsem & ( fwmask | swmask ) ) txgbe_release_swfw_sync ( hw , mngsem & ( fwmask | swmask ) ) ; msec_delay ( 5 ) ; return TXGBE_ERR_SWFW_SYNC ; }
txgbe_acquire_swfw_sync - Acquire SWFW semaphore
  @hw: pointer to hardware structure
  @mask: Mask to specify which semaphore to acquire
txgbe_acquire_swfw_sync - Acquire SWFW semaphore @hw : pointer to hardware structure @mask : Mask to specify which semaphore to acquire
/*
		 * SW NVM semaphore bit is used for access to all
		 * SW_FW_SYNC bits (not just NVM)
		 */ /* Resource is currently in use by FW or SW */ /* If time expired clear the bits holding the lock and retry */