src/dpdk/drivers/net/bnx2x/bnx2x.c
static uint8_t bnx2x_trylock_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
{
	uint32_t lock_status;
	uint32_t resource_bit = (1 << resource);
	int func = SC_FUNC(sc);
	uint32_t hw_lock_control_reg;

	/* Validating that the resource is within range */
	if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
		PMD_DRV_LOG(INFO, sc,
			    "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)",
			    resource, HW_LOCK_MAX_RESOURCE_VALUE);
		return FALSE;
	}

	if (func <= 5) {
		hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func * 8);
	} else {
		hw_lock_control_reg =
		    (MISC_REG_DRIVER_CONTROL_7 + (func - 6) * 8);
	}

	/* try to acquire the lock */
	REG_WR(sc, hw_lock_control_reg + 4, resource_bit);
	lock_status = REG_RD(sc, hw_lock_control_reg);
	if (lock_status & resource_bit) {
		return TRUE;
	}

	PMD_DRV_LOG(NOTICE, sc, "Failed to get a resource lock 0x%x", resource);

	return FALSE;
}
/* return true if succeeded to acquire the lock */
return true if succeeded to acquire the lock
return true if succeeded to acquire the lock
static uint8_t bnx2x_trylock_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
{
	uint32_t lock_status;
	uint32_t resource_bit = (1 << resource);
	int func = SC_FUNC(sc);
	uint32_t hw_lock_control_reg;
	if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
		PMD_DRV_LOG(INFO, sc,
			    "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)",
			    resource, HW_LOCK_MAX_RESOURCE_VALUE);
		return FALSE;
	}
	if (func <= 5) {
		hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func * 8);
	} else {
		hw_lock_control_reg =
		    (MISC_REG_DRIVER_CONTROL_7 + (func - 6) * 8);
	}
	REG_WR(sc, hw_lock_control_reg + 4, resource_bit);
	lock_status = REG_RD(sc, hw_lock_control_reg);
	if (lock_status & resource_bit) {
		return TRUE;
	}
	PMD_DRV_LOG(NOTICE, sc, "Failed to get a resource lock 0x%x", resource);
	return FALSE;
}
static uint8_t bnx2x_trylock_hw_lock ( struct bnx2x_softc * sc , uint32_t resource ) { uint32_t lock_status ; uint32_t resource_bit = ( 1 << resource ) ; int func = SC_FUNC ( sc ) ; uint32_t hw_lock_control_reg ; if ( resource > HW_LOCK_MAX_RESOURCE_VALUE ) { PMD_DRV_LOG ( INFO , sc , " " , resource , HW_LOCK_MAX_RESOURCE_VALUE ) ; return FALSE ; } if ( func <= 5 ) { hw_lock_control_reg = ( MISC_REG_DRIVER_CONTROL_1 + func * 8 ) ; } else { hw_lock_control_reg = ( MISC_REG_DRIVER_CONTROL_7 + ( func - 6 ) * 8 ) ; } REG_WR ( sc , hw_lock_control_reg + 4 , resource_bit ) ; lock_status = REG_RD ( sc , hw_lock_control_reg ) ; if ( lock_status & resource_bit ) { return TRUE ; } PMD_DRV_LOG ( NOTICE , sc , " " , resource ) ; return FALSE ; }
return true if succeeded to acquire the lock
return true if succeeded to acquire the lock
/* Validating that the resource is within range */ /* try to acquire the lock */