Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/i40e_osdep.c
Show All 26 Lines | /****************************************************************************** | ||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
POSSIBILITY OF SUCH DAMAGE. | POSSIBILITY OF SUCH DAMAGE. | ||||
******************************************************************************/ | ******************************************************************************/ | ||||
/*$FreeBSD$*/ | /*$FreeBSD$*/ | ||||
#include <machine/stdarg.h> | #include <sys/limits.h> | ||||
#include "ixl.h" | #include "ixl.h" | ||||
/******************************************************************** | /******************************************************************** | ||||
* Manage DMA'able memory. | * Manage DMA'able memory. | ||||
*******************************************************************/ | *******************************************************************/ | ||||
static void | static void | ||||
i40e_dmamap_cb(void *arg, bus_dma_segment_t * segs, int nseg, int error) | i40e_dmamap_cb(void *arg, bus_dma_segment_t * segs, int nseg, int error) | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | i40e_free_dma_mem(struct i40e_hw *hw, struct i40e_dma_mem *mem) | ||||
bus_dma_tag_destroy(mem->tag); | bus_dma_tag_destroy(mem->tag); | ||||
return (0); | return (0); | ||||
} | } | ||||
void | void | ||||
i40e_init_spinlock(struct i40e_spinlock *lock) | i40e_init_spinlock(struct i40e_spinlock *lock) | ||||
{ | { | ||||
mtx_init(&lock->mutex, "mutex", | mtx_init(&lock->mutex, "mutex", | ||||
MTX_NETWORK_LOCK, MTX_DEF | MTX_DUPOK); | "ixl spinlock", MTX_DEF | MTX_DUPOK); | ||||
} | } | ||||
void | void | ||||
i40e_acquire_spinlock(struct i40e_spinlock *lock) | i40e_acquire_spinlock(struct i40e_spinlock *lock) | ||||
{ | { | ||||
mtx_lock(&lock->mutex); | mtx_lock(&lock->mutex); | ||||
} | } | ||||
void | void | ||||
i40e_release_spinlock(struct i40e_spinlock *lock) | i40e_release_spinlock(struct i40e_spinlock *lock) | ||||
{ | { | ||||
mtx_unlock(&lock->mutex); | mtx_unlock(&lock->mutex); | ||||
} | } | ||||
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); | ||||
} | } | ||||
void | |||||
i40e_msec_pause(int msecs) | |||||
{ | |||||
int ticks_to_pause = (msecs * hz) / 1000; | |||||
int start_ticks = ticks; | |||||
if (cold || SCHEDULER_STOPPED()) { | |||||
i40e_msec_delay(msecs); | |||||
return; | |||||
} | |||||
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_d(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; | ||||
if (!(mask & ((struct i40e_hw *)hw)->debug_mask)) | if (!(mask & ((struct i40e_hw *)hw)->debug_mask)) | ||||
return; | return; | ||||
va_start(args, fmt); | va_start(args, fmt); | ||||
device_printf(((struct i40e_osdep *)hw->back)->dev, fmt, args); | device_printf(((struct i40e_osdep *)hw->back)->dev, fmt, args); | ||||
Show All 23 Lines |