Lines Matching +full:y +full:- +full:rc

1 /*-
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
128 #define OCS_MAX(x, y) ((x) > (y) ? (x) : (y)) argument
129 #define OCS_MIN(x, y) ((x) < (y) ? (x) : (y)) argument
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"
385 static inline uint32_t ocs_roundup(uint32_t x, uint32_t y) in ocs_roundup() argument
387 return (((x + y - 1) / y) * y); in ocs_roundup()
390 static inline uint32_t ocs_rounddown(uint32_t x, uint32_t y) in ocs_rounddown() argument
392 return ((x / y) * y); in ocs_rounddown()
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
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()
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()
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()
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()
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()
650 int rc = mtx_trylock(&(lock)->lock); in ocs_rlock_try() local
652 return rc != 0; in ocs_rlock_try()
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()
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)
735 int32_t rc = 0; in ocs_sem_p() local
738 rc = sema_trywait(&sem->sem); in ocs_sem_p()
739 if (rc == 0) { in ocs_sem_p()
740 rc = -1; in ocs_sem_p()
752 rc = sema_timedwait(&sem->sem, ticks); in ocs_sem_p()
753 if (rc != 0) { in ocs_sem_p()
754 rc = -1; in ocs_sem_p()
757 sema_wait(&sem->sem); in ocs_sem_p()
759 if (rc) in ocs_sem_p()
760 rc = -1; in ocs_sem_p()
762 return rc; 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
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) */
1177 * @param val 32-bit value to write
1188 * @param val 16-bit value to write
1199 * @param val 8-bit value to write
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
1328 uint32_t rc = 0; in ocs_ref_get_unless_zero() local
1329 rc = ocs_atomic_read(&ref->count); in ocs_ref_get_unless_zero()
1330 if (rc != 0) { in ocs_ref_get_unless_zero()
1331 ocs_atomic_add_return(&ref->count, 1); in ocs_ref_get_unless_zero()
1333 return rc; in ocs_ref_get_unless_zero()
1347 * @return non-zero if release function was called; zero
1353 uint32_t rc = 0; in ocs_ref_put() local
1354 if (ocs_atomic_sub_return(&ref->count, 1) == 1) { in ocs_ref_put()
1355 ref->release(ref->arg); in ocs_ref_put()
1356 rc = 1; in ocs_ref_put()
1358 return rc; in ocs_ref_put()