Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/i40e_osdep.c
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
i40e_destroy_spinlock(struct i40e_spinlock *lock) | i40e_destroy_spinlock(struct i40e_spinlock *lock) | ||||
{ | { | ||||
if (mtx_initialized(&lock->mutex)) | if (mtx_initialized(&lock->mutex)) | ||||
mtx_destroy(&lock->mutex); | mtx_destroy(&lock->mutex); | ||||
} | } | ||||
static inline int | |||||
ixl_ms_scale(int x) | |||||
{ | |||||
if (hz == 1000) | |||||
return (x); | |||||
else if (hz > 1000) | |||||
return (x*(hz/1000)); | |||||
else | |||||
return (max(1, x/(1000/hz))); | |||||
} | |||||
void | void | ||||
i40e_msec_pause(int msecs) | i40e_msec_pause(int msecs) | ||||
{ | { | ||||
int ticks_to_pause = (msecs * hz) / 1000; | if (cold || SCHEDULER_STOPPED()) | ||||
int start_ticks = ticks; | |||||
if (cold || SCHEDULER_STOPPED()) { | |||||
i40e_msec_delay(msecs); | i40e_msec_delay(msecs); | ||||
return; | else | ||||
// ERJ: (msecs * hz) could overflow | |||||
pause("ixl", ixl_ms_scale(msecs)); | |||||
} | } | ||||
while (1) { | |||||
kern_yield(PRI_USER); | |||||
int yielded_ticks = ticks - start_ticks; | |||||
if (yielded_ticks > ticks_to_pause) | |||||
break; | |||||
else if (yielded_ticks < 0 | |||||
&& (yielded_ticks + INT_MAX + 1 > ticks_to_pause)) { | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
/* | /* | ||||
* Helper function for debug statement printing | * Helper function for debug statement printing | ||||
*/ | */ | ||||
void | void | ||||
i40e_debug_shared(struct i40e_hw *hw, enum i40e_debug_mask mask, char *fmt, ...) | i40e_debug_shared(struct i40e_hw *hw, enum i40e_debug_mask mask, char *fmt, ...) | ||||
{ | { | ||||
va_list args; | va_list args; | ||||
device_t dev; | device_t dev; | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | i40e_read_pci_cfg(struct i40e_hw *hw, u32 reg) | ||||
return (value); | return (value); | ||||
} | } | ||||
void | void | ||||
i40e_write_pci_cfg(struct i40e_hw *hw, u32 reg, u16 value) | i40e_write_pci_cfg(struct i40e_hw *hw, u32 reg, u16 value) | ||||
{ | { | ||||
pci_write_config(((struct i40e_osdep *)hw->back)->dev, | pci_write_config(((struct i40e_osdep *)hw->back)->dev, | ||||
reg, value, 2); | reg, value, 2); | ||||
return; | |||||
} | } | ||||