Lines Matching +full:lock +full:- +full:offset
1 /*-
54 #include <sys/lock.h>
81 /* OCS_OS_MAX_ISR_TIME_MSEC - maximum time driver code should spend in an interrupt
112 #define B32_NEXT_POWER_OF_2(x) (B32((x)-1) + 1)
115 * likely/unlikely - branch prediction hint
138 * - OCS_INCLUDE_DEBUG include low-level SLI debug support
170 * @brief return the lower 32-bits of a bus address
173 * @return lower 32-bits of a bus address
188 * @brief return the upper 32-bits of a bus address
191 * @return upper 32-bits of a bus address
221 return 31 - __builtin_clz(val); in ocs_lg2()
223 #error You need to provide a non-GCC version of this function in ocs_lg2()
231 * Optimization barrier. Prevents compiler re-ordering
274 * @brief Delay execution by the given number of micro-seconds
276 * @param usec number of micro-seconds to "busy-wait"
284 * @brief Delay execution by the given number of milli-seconds
286 * @param msec number of milli-seconds to "busy-wait"
387 return (((x + y - 1) / y) * y); in ocs_roundup()
411 * - OCS_M_ZERO zero memory after allocating
412 * - OCS_M_NOWAIT do not block/sleep waiting for an allocation request
482 * @return 0 on success, non-zero otherwise
493 * @return 0 if memory is de-allocated, non-zero otherwise
501 return (dma->size != 0); in ocs_dma_valid()
512 * - OCS_DMASYNC_PREREAD sync needed before hardware updates host memory
513 * - OCS_DMASYNC_PREWRITE sync needed after CPU updates host memory but before hardware can access
514 * - OCS_DMASYNC_POSTREAD sync needed after hardware updates host memory but before CPU can access
515 * - OCS_DMASYNC_POSTWRITE sync needed after hardware updates host memory
533 struct mtx lock; member
539 * @brief Initialize a lock
541 * @param lock lock to initialize
542 * @param name string identifier for the lock
544 extern void ocs_lock_init(void *os, ocs_lock_t *lock, const char *name, ...);
548 * @brief Free a previously allocated lock
550 * @param lock lock to free
553 ocs_lock_free(ocs_lock_t *lock) in ocs_lock_free() argument
556 if (mtx_initialized(&(lock)->lock)) { in ocs_lock_free()
557 mtx_assert(&(lock)->lock, MA_NOTOWNED); in ocs_lock_free()
558 mtx_destroy(&(lock)->lock); in ocs_lock_free()
560 panic("XXX trying to free with un-initialized mtx!?!?\n"); in ocs_lock_free()
566 * @brief Acquire a lock
568 * @param lock lock to obtain
571 ocs_lock(ocs_lock_t *lock) in ocs_lock() argument
574 if (mtx_initialized(&(lock)->lock)) { in ocs_lock()
575 mtx_assert(&(lock)->lock, MA_NOTOWNED); in ocs_lock()
576 mtx_lock(&(lock)->lock); in ocs_lock()
578 panic("XXX trying to lock with un-initialized mtx!?!?\n"); in ocs_lock()
584 * @brief Release a lock
586 * @param lock lock to release
589 ocs_unlock(ocs_lock_t *lock) in ocs_unlock() argument
592 if (mtx_initialized(&(lock)->lock)) { in ocs_unlock()
593 mtx_assert(&(lock)->lock, MA_OWNED | MA_NOTRECURSED); in ocs_unlock()
594 mtx_unlock(&(lock)->lock); in ocs_unlock()
596 panic("XXX trying to unlock with un-initialized mtx!?!?\n"); in ocs_unlock()
609 * @brief Initialize a recursive lock
612 * @param lock lock to initialize
613 * @param name string identifier for the lock
616 ocs_rlock_init(ocs_t *ocs, ocs_rlock_t *lock, const char *name) in ocs_rlock_init() argument
618 ocs_strncpy(lock->name, name, MAX_LOCK_DESC_LEN); in ocs_rlock_init()
619 mtx_init(&(lock)->lock, lock->name, NULL, MTX_DEF | MTX_RECURSE | MTX_DUPOK); in ocs_rlock_init()
624 * @brief Free a previously allocated recursive lock
626 * @param lock lock to free
629 ocs_rlock_free(ocs_rlock_t *lock) in ocs_rlock_free() argument
631 if (mtx_initialized(&(lock)->lock)) { in ocs_rlock_free()
632 mtx_destroy(&(lock)->lock); in ocs_rlock_free()
634 panic("XXX trying to free with un-initialized mtx!?!?\n"); in ocs_rlock_free()
639 * @brief try to acquire a recursive lock
641 * Attempt to acquire a recursive lock, return TRUE if successful
643 * @param lock pointer to recursive lock
645 * @return TRUE if lock was acquired, FALSE if not
648 ocs_rlock_try(ocs_rlock_t *lock) in ocs_rlock_try() argument
650 int rc = mtx_trylock(&(lock)->lock); in ocs_rlock_try()
657 * @brief Acquire a recursive lock
659 * @param lock lock to obtain
662 ocs_rlock_acquire(ocs_rlock_t *lock) in ocs_rlock_acquire() argument
664 if (mtx_initialized(&(lock)->lock)) { in ocs_rlock_acquire()
665 mtx_lock(&(lock)->lock); in ocs_rlock_acquire()
667 panic("XXX trying to lock with un-initialized mtx!?!?\n"); in ocs_rlock_acquire()
673 * @brief Release a recursive lock
675 * @param lock lock to release
678 ocs_rlock_release(ocs_rlock_t *lock) in ocs_rlock_release() argument
680 if (mtx_initialized(&(lock)->lock)) { in ocs_rlock_release()
681 mtx_assert(&(lock)->lock, MA_OWNED); in ocs_rlock_release()
682 mtx_unlock(&(lock)->lock); in ocs_rlock_release()
684 panic("XXX trying to unlock with un-initialized mtx!?!?\n"); in ocs_rlock_release()
699 #define OCS_SEM_FOREVER (-1)
738 rc = sema_trywait(&sem->sem); in ocs_sem_p()
740 rc = -1; in ocs_sem_p()
752 rc = sema_timedwait(&sem->sem, ticks); in ocs_sem_p()
754 rc = -1; in ocs_sem_p()
757 sema_wait(&sem->sem); in ocs_sem_p()
760 rc = -1; in ocs_sem_p()
779 sema_post(&sem->sem); in ocs_sem_v()
789 * @brief Define the type used implement bit-maps
797 * @param n_bits Minimum number of entries in the bit-map
799 * @return pointer to the bit-map or NULL on error
805 * @brief Free a bit-map
807 * @param bitmap Bit-map to free
818 * @return bit position or -1 if map is full
830 * @return bit position or -1
852 struct mtx lock; member
887 * @return non-zero if the timer is pending
938 #define ocs_atomic_sub_return(a, v) atomic_fetchadd_32(a, (-(v)))
1036 #define PCI_PRODUCT_EMULEX_LPE31004 0xe300 /* LightPulse 16Gb x 4 FC (lancer-g6) */
1037 #define PCI_PRODUCT_EMULEX_LPE32002 0xe300 /* LightPulse 32Gb x 2 FC (lancer-g6) */
1038 #define PCI_PRODUCT_EMULEX_LANCER_G7 0xf400 /* LightPulse 32Gb x 4 FC (lancer-g7) */
1065 * @param reg register offset
1077 * @param reg register offset
1089 * @param reg register offset
1101 * @param reg register offset
1114 * @param reg register offset
1127 * @param reg register offset
1140 * @param off Register offset
1152 * @param off Register offset
1164 * @param off Register offset
1176 * @param off Register offset
1177 * @param val 32-bit value to write
1187 * @param off Register offset
1188 * @param val 16-bit value to write
1198 * @param off Register offset
1199 * @param val 8-bit value to write
1244 uint32_t count; /* ref count; no need to be atomic if we have a lock */
1258 ref->release = release; in ocs_ref_init()
1259 ref->arg = arg; in ocs_ref_init()
1260 ocs_atomic_init(&ref->count, 1); in ocs_ref_init()
1274 return ocs_atomic_read(&ref->count); in ocs_ref_read_count()
1287 ocs_atomic_set(&ref->count, i); in ocs_ref_set()
1309 ocs_atomic_add_return(&ref->count, 1); in ocs_ref_get()
1322 * @return non-zero if "get" succeeded; Return zero if ref count
1329 rc = ocs_atomic_read(&ref->count); in ocs_ref_get_unless_zero()
1331 ocs_atomic_add_return(&ref->count, 1); in ocs_ref_get_unless_zero()
1347 * @return non-zero if release function was called; zero
1354 if (ocs_atomic_sub_return(&ref->count, 1) == 1) { in ocs_ref_put()
1355 ref->release(ref->arg); in ocs_ref_put()