static struct ale * ieee80211_alq_get(void) { struct ale *ale; ale = alq_get(ieee80211_alq, ALQ_NOWAIT); if (!ale) ieee80211_alq_lost++; else ieee80211_alq_logged++; return ale; }
/* * Copy a new entry into the queue. If the operation would block either * wait or return an error depending on the value of waitok. */ int alq_write(struct alq *alq, void *data, int waitok) { struct ale *ale; if ((ale = alq_get(alq, waitok)) == NULL) return (EWOULDBLOCK); bcopy(data, ale->ae_data, alq->aq_entlen); alq_post(alq, ale); return (0); }
static struct ale * ath_hal_alq_get(struct ath_hal *ah) { struct ale *ale; if (ath_hal_alq_emitdev) { ale = alq_get(ath_hal_alq, ALQ_NOWAIT); if (ale) { struct athregrec *r = (struct athregrec *) ale->ae_data; r->op = OP_DEVICE; r->reg = 0; r->val = ah->ah_devid; alq_post(ath_hal_alq, ale); ath_hal_alq_emitdev = 0; } else ath_hal_alq_lost++; } ale = alq_get(ath_hal_alq, ALQ_NOWAIT); if (!ale) ath_hal_alq_lost++; return ale; }
/* * Copy a new entry into the queue. If the operation would block either * wait or return an error depending on the value of waitok. */ int alq_write(struct alq *alq, void *data, int waitok) { unsigned long flags; struct ale *ale; local_irq_save(flags); if ((ale = alq_get(alq, waitok)) == NULL) { local_irq_restore(flags); return EWOULDBLOCK; } memcpy(ale->ae_data, data, alq->aq_entlen); alq_post(alq, ale); local_irq_restore(flags); return 0; }
static inline void ath_hal_logvprintf(struct ath_hal *ah, const char *fmt, va_list ap) { struct ale *ale; if (!ath_hal_alq) { ath_hal_alq_lost++; return; } ale = alq_get(ath_hal_alq, ALQ_NOWAIT); if (!ale) { ath_hal_alq_lost++; return; } memset(ale->ae_data, 0, MSG_MAXLEN); vsnprintf(ale->ae_data, MSG_MAXLEN, fmt, ap); alq_post(ath_hal_alq, ale); }
void ktr_tracepoint(u_int mask, const char *file, int line, const char *format, u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5, u_long arg6) { struct ktr_entry *entry; #ifdef KTR_ALQ struct ale *ale = NULL; #endif int newindex, saveindex; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) struct thread *td; #endif int cpu; if (panicstr) return; if ((ktr_mask & mask) == 0) return; cpu = KTR_CPU; if (((1 << cpu) & ktr_cpumask) == 0) return; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td = curthread; if (td->td_pflags & TDP_INKTR) return; td->td_pflags |= TDP_INKTR; #endif #ifdef KTR_ALQ if (ktr_alq_enabled) { if (td->td_critnest == 0 && (td->td_flags & TDF_IDLETD) == 0 && td != ald_thread) { if (ktr_alq_max && ktr_alq_cnt > ktr_alq_max) goto done; if ((ale = alq_get(ktr_alq, ALQ_NOWAIT)) == NULL) { ktr_alq_failed++; goto done; } ktr_alq_cnt++; entry = (struct ktr_entry *)ale->ae_data; } else { goto done; } } else #endif { do { saveindex = ktr_idx; newindex = (saveindex + 1) & (KTR_ENTRIES - 1); } while (atomic_cmpset_rel_int(&ktr_idx, saveindex, newindex) == 0); entry = &ktr_buf[saveindex]; } entry->ktr_timestamp = KTR_TIME; entry->ktr_cpu = cpu; entry->ktr_thread = curthread; if (file != NULL) while (strncmp(file, "../", 3) == 0) file += 3; entry->ktr_file = file; entry->ktr_line = line; #ifdef KTR_VERBOSE if (ktr_verbose) { #ifdef SMP printf("cpu%d ", cpu); #endif if (ktr_verbose > 1) { printf("%s.%d\t", entry->ktr_file, entry->ktr_line); } printf(format, arg1, arg2, arg3, arg4, arg5, arg6); printf("\n"); } #endif entry->ktr_desc = format; entry->ktr_parms[0] = arg1; entry->ktr_parms[1] = arg2; entry->ktr_parms[2] = arg3; entry->ktr_parms[3] = arg4; entry->ktr_parms[4] = arg5; entry->ktr_parms[5] = arg6; #ifdef KTR_ALQ if (ktr_alq_enabled && ale) alq_post(ktr_alq, ale); done: #endif #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td->td_pflags &= ~TDP_INKTR; #endif }