void action_exec(keyevent_t event) { if (!IS_NOEVENT(event)) { dprint("\n---- action_exec: start -----\n"); dprint("EVENT: "); debug_event(event); dprintln(); } keyrecord_t record = { .event = event }; #ifndef NO_ACTION_TAPPING action_tapping_process(record); #else process_action(&record); if (!IS_NOEVENT(record.event)) { dprint("processed: "); debug_record(record); dprintln(); } #endif }
/** * zfcp_hba_dbf_event_qdio - trace event for QDIO related failure * @adapter: adapter affected by this QDIO related event * @status: as passed by qdio module * @qdio_error: as passed by qdio module * @siga_error: as passed by qdio module * @sbal_index: first buffer with error condition, as passed by qdio module * @sbal_count: number of buffers affected, as passed by qdio module */ void zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status, unsigned int qdio_error, unsigned int siga_error, int sbal_index, int sbal_count) { struct zfcp_hba_dbf_record *r = &adapter->hba_dbf_buf; unsigned long flags; spin_lock_irqsave(&adapter->hba_dbf_lock, flags); memset(r, 0, sizeof(*r)); strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE); r->u.qdio.status = status; r->u.qdio.qdio_error = qdio_error; r->u.qdio.siga_error = siga_error; r->u.qdio.sbal_index = sbal_index; r->u.qdio.sbal_count = sbal_count; debug_event(adapter->hba_dbf, 0, r, sizeof(*r)); spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); }
/** * zfcp_dbf_hba_basic - trace event for basic adapter events * @adapter: pointer to struct zfcp_adapter */ void zfcp_dbf_hba_basic(char *tag, struct zfcp_adapter *adapter) { struct zfcp_dbf *dbf = adapter->dbf; struct zfcp_dbf_hba *rec = &dbf->hba_buf; static int const level = 1; unsigned long flags; if (unlikely(!debug_level_enabled(dbf->hba, level))) return; spin_lock_irqsave(&dbf->hba_lock, flags); memset(rec, 0, sizeof(*rec)); memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); rec->id = ZFCP_DBF_HBA_BASIC; debug_event(dbf->hba, level, rec, sizeof(*rec)); spin_unlock_irqrestore(&dbf->hba_lock, flags); }
static void zfcp_dbf_rec_target(char *id2, void *ref, struct zfcp_dbf *dbf, atomic_t *status, atomic_t *erp_count, u64 wwpn, u32 d_id, u64 fcp_lun) { struct zfcp_dbf_rec_record *r = &dbf->rec_buf; unsigned long flags; spin_lock_irqsave(&dbf->rec_lock, flags); memset(r, 0, sizeof(*r)); r->id = ZFCP_REC_DBF_ID_TARGET; memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); r->u.target.ref = (unsigned long)ref; r->u.target.status = atomic_read(status); r->u.target.wwpn = wwpn; r->u.target.d_id = d_id; r->u.target.fcp_lun = fcp_lun; r->u.target.erp_count = atomic_read(erp_count); debug_event(dbf->rec, 3, r, sizeof(*r)); spin_unlock_irqrestore(&dbf->rec_lock, flags); }
static void _zfcp_san_dbf_event_common_els(const char *tag, int level, struct zfcp_fsf_req *fsf_req, u32 s_id, u32 d_id, u8 ls_code, void *buffer, int buflen) { struct zfcp_adapter *adapter = fsf_req->adapter; struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf; struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; unsigned long flags; int offset = 0; spin_lock_irqsave(&adapter->san_dbf_lock, flags); do { memset(rec, 0, sizeof(struct zfcp_san_dbf_record)); if (offset == 0) { strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); rec->fsf_reqid = (unsigned long)fsf_req; rec->fsf_seqno = fsf_req->seq_no; rec->s_id = s_id; rec->d_id = d_id; rec->type.els.ls_code = ls_code; buflen = min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD); rec->type.els.payload_size = buflen; memcpy(rec->type.els.payload, buffer, min(buflen, ZFCP_DBF_ELS_PAYLOAD)); offset += min(buflen, ZFCP_DBF_ELS_PAYLOAD); } else { strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); dump->total_size = buflen; dump->offset = offset; dump->size = min(buflen - offset, (int)sizeof(struct zfcp_san_dbf_record) - (int)sizeof(struct zfcp_dbf_dump)); memcpy(dump->data, buffer + offset, dump->size); offset += dump->size; } debug_event(adapter->san_dbf, level, rec, sizeof(struct zfcp_san_dbf_record)); } while (offset < buflen); spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); }
/** * zfcp_dbf_hba_fsf_uss - trace event for an unsolicited status buffer * @tag: tag indicating which kind of unsolicited status has been received * @req: request providing the unsolicited status */ void zfcp_dbf_hba_fsf_uss(char *tag, struct zfcp_fsf_req *req) { struct zfcp_dbf *dbf = req->adapter->dbf; struct fsf_status_read_buffer *srb = req->data; struct zfcp_dbf_hba *rec = &dbf->hba_buf; static int const level = 2; unsigned long flags; if (unlikely(!debug_level_enabled(dbf->hba, level))) return; spin_lock_irqsave(&dbf->hba_lock, flags); memset(rec, 0, sizeof(*rec)); memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); rec->id = ZFCP_DBF_HBA_USS; rec->fsf_req_id = req->req_id; rec->fsf_req_status = req->status; rec->fsf_cmd = req->fsf_command; if (!srb) goto log; rec->u.uss.status_type = srb->status_type; rec->u.uss.status_subtype = srb->status_subtype; rec->u.uss.d_id = ntoh24(srb->d_id); rec->u.uss.lun = srb->fcp_lun; memcpy(&rec->u.uss.queue_designator, &srb->queue_designator, sizeof(rec->u.uss.queue_designator)); /* status read buffer payload length */ rec->pl_len = (!srb->length) ? 0 : srb->length - offsetof(struct fsf_status_read_buffer, payload); if (rec->pl_len) zfcp_dbf_pl_write(dbf, srb->payload.data, rec->pl_len, "fsf_uss", req->req_id); log: debug_event(dbf->hba, level, rec, sizeof(*rec)); spin_unlock_irqrestore(&dbf->hba_lock, flags); }
void action_exec(keyevent_t event) { if (!IS_NOEVENT(event)) { dprint("\n---- action_exec: start -----\n"); dprint("EVENT: "); debug_event(event); dprintln(); } #ifdef FAUXCLICKY_ENABLE if (IS_PRESSED(event)) { FAUXCLICKY_ACTION_PRESS; } if (IS_RELEASED(event)) { FAUXCLICKY_ACTION_RELEASE; } fauxclicky_check(); #endif #ifdef ONEHAND_ENABLE if (!IS_NOEVENT(event)) { process_hand_swap(&event); } #endif keyrecord_t record = { .event = event }; #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) if (has_oneshot_layer_timed_out()) { dprintf("Oneshot layer: timeout\n"); clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); } #endif #ifndef NO_ACTION_TAPPING action_tapping_process(record); #else process_record(&record); if (!IS_NOEVENT(record.event)) { dprint("processed: "); debug_record(record); dprintln(); } #endif }
static void zfcp_rec_dbf_event_target(u8 id2, void *ref, struct zfcp_adapter *adapter, atomic_t *status, atomic_t *erp_count, u64 wwpn, u32 d_id, u64 fcp_lun) { struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; unsigned long flags; spin_lock_irqsave(&adapter->rec_dbf_lock, flags); memset(r, 0, sizeof(*r)); r->id = ZFCP_REC_DBF_ID_TARGET; r->id2 = id2; r->u.target.ref = (unsigned long)ref; r->u.target.status = atomic_read(status); r->u.target.wwpn = wwpn; r->u.target.d_id = d_id; r->u.target.fcp_lun = fcp_lun; r->u.target.erp_count = atomic_read(erp_count); debug_event(adapter->rec_dbf, 3, r, sizeof(*r)); spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); }
void onEvent (ev_t ev) { debug_event(ev); switch(ev) { // starting to join network case EV_JOINING: // start blinking blinkfunc(&blinkjob); break; // network joined, session established case EV_JOINED: // cancel blink job os_clearCallback(&blinkjob); // switch on LED debug_led(1); // (don't schedule any new actions) break; } }
static inline void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, u64 req_id, u32 d_id) { struct zfcp_dbf_san *rec = &dbf->san_buf; u16 rec_len; unsigned long flags; spin_lock_irqsave(&dbf->san_lock, flags); memset(rec, 0, sizeof(*rec)); rec->id = id; rec->fsf_req_id = req_id; rec->d_id = d_id; rec_len = min(len, (u16)ZFCP_DBF_SAN_MAX_PAYLOAD); memcpy(rec->payload, data, rec_len); memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); debug_event(dbf->san, 1, rec, sizeof(*rec)); spin_unlock_irqrestore(&dbf->san_lock, flags); }
void zfcp_dbf_hba_bit_err(char *tag, struct zfcp_fsf_req *req) { struct zfcp_dbf *dbf = req->adapter->dbf; struct zfcp_dbf_hba *rec = &dbf->hba_buf; struct fsf_status_read_buffer *sr_buf = req->data; unsigned long flags; spin_lock_irqsave(&dbf->hba_lock, flags); memset(rec, 0, sizeof(*rec)); memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); rec->id = ZFCP_DBF_HBA_BIT; rec->fsf_req_id = req->req_id; rec->fsf_req_status = req->status; rec->fsf_cmd = req->fsf_command; memcpy(&rec->u.be, &sr_buf->payload.bit_error, sizeof(struct fsf_bit_error_payload)); debug_event(dbf->hba, 1, rec, sizeof(*rec)); spin_unlock_irqrestore(&dbf->hba_lock, flags); }
static void _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req, u32 s_id, u32 d_id, void *buffer, int buflen) { struct zfcp_send_ct *send_ct = (struct zfcp_send_ct *)fsf_req->data; struct zfcp_port *port = send_ct->port; struct zfcp_adapter *adapter = port->adapter; struct ct_hdr *header = (struct ct_hdr *)buffer; struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf; struct zfcp_san_dbf_record_ct *ct = &rec->type.ct; unsigned long flags; spin_lock_irqsave(&adapter->san_dbf_lock, flags); memset(rec, 0, sizeof(struct zfcp_san_dbf_record)); strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); rec->fsf_reqid = (unsigned long)fsf_req; rec->fsf_seqno = fsf_req->seq_no; rec->s_id = s_id; rec->d_id = d_id; if (strncmp(tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) { ct->type.request.cmd_req_code = header->cmd_rsp_code; ct->type.request.revision = header->revision; ct->type.request.gs_type = header->gs_type; ct->type.request.gs_subtype = header->gs_subtype; ct->type.request.options = header->options; ct->type.request.max_res_size = header->max_res_size; } else if (strncmp(tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { ct->type.response.cmd_rsp_code = header->cmd_rsp_code; ct->type.response.revision = header->revision; ct->type.response.reason_code = header->reason_code; ct->type.response.reason_code_expl = header->reason_code_expl; ct->type.response.vendor_unique = header->vendor_unique; } ct->payload_size = min(buflen - (int)sizeof(struct ct_hdr), ZFCP_DBF_CT_PAYLOAD); memcpy(ct->payload, buffer + sizeof(struct ct_hdr), ct->payload_size); debug_event(adapter->san_dbf, 3, rec, sizeof(struct zfcp_san_dbf_record)); spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); }
int event_process_end(struct event *evt) { debug_event("Processing event end %s", evt->reg->info->name); if (!(evt->flags & EVENT_FLAG_PROCESS_BEGAN)) { pomlog(POMLOG_ERR "Internal error: event %s processing hasn't begun", evt->reg->info->name); event_cleanup(evt); return POM_ERR; } if (evt->flags & EVENT_FLAG_PROCESS_DONE) { pomlog(POMLOG_ERR "Internal error: event %s has already been processed entirely", evt->reg->info->name); event_cleanup(evt); return POM_ERR; } struct event_listener *lst; for (lst = evt->reg->listeners; lst; lst = lst->next) { if (lst->process_end && lst->process_end(evt, lst->obj) != POM_OK) { pomlog(POMLOG_WARN "An error occured while processing event %s", evt->reg->info->name); } } for (lst = evt->tmp_listeners; lst; lst = lst->next) { if (lst->process_end && lst->process_end(evt, lst->obj) != POM_OK) { pomlog(POMLOG_WARN "An error occured while processing event %s", evt->reg->info->name); } registry_perf_dec(evt->reg->perf_listeners, 1); } evt->ce = NULL; evt->flags |= EVENT_FLAG_PROCESS_DONE; registry_perf_dec(evt->reg->perf_ongoing, 1); registry_perf_inc(evt->reg->perf_processed, 1); return event_refcount_dec(evt); }
static void zfcp_san_dbf_event_els(const char *tag, int level, struct zfcp_fsf_req *fsf_req, u32 s_id, u32 d_id, u8 ls_code, void *buffer, int buflen) { struct zfcp_adapter *adapter = fsf_req->adapter; struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf; unsigned long flags; spin_lock_irqsave(&adapter->san_dbf_lock, flags); memset(rec, 0, sizeof(*rec)); strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); rec->fsf_reqid = (unsigned long)fsf_req; rec->fsf_seqno = fsf_req->seq_no; rec->s_id = s_id; rec->d_id = d_id; rec->u.els.ls_code = ls_code; debug_event(adapter->san_dbf, level, rec, sizeof(*rec)); zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level, buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD)); spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); }
//----------------------------------------------------------------------------- static void process_events_and_channel_data_from_plugin(thread_param* param) { FRDP_EVENT* event; param->th_count++; while (param->th_to_finish == 0) { freerdp_chanman_check_fds(param->chan_man, param->instance); event = freerdp_chanman_pop_event(param->chan_man); if (event) { DEBUG_RAIL("UI receive %d event.", event->event_type); debug_event(event); // add to global event list freerdp_event_free(event); } usleep(1000); } param->th_count--; }
struct event *event_alloc(struct event_reg *evt_reg) { struct event *evt = malloc(sizeof(struct event)); if (!evt) { pom_oom(sizeof(struct event)); return NULL; } memset(evt, 0, sizeof(struct event)); struct event_reg_info *info = evt_reg->info; evt->reg = evt_reg; evt->data = data_alloc_table(info->data_reg); if (!evt->data) { free(evt); return NULL; } debug_event("Event %s allocated", evt_reg->info->name); return evt; }
/** * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation * @id2: identifier for event * @adapter: adapter * This function assumes that the caller is holding erp_lock. */ void zfcp_rec_dbf_event_thread(char *id2, struct zfcp_adapter *adapter) { struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; unsigned long flags = 0; struct list_head *entry; unsigned ready = 0, running = 0, total; list_for_each(entry, &adapter->erp_ready_head) ready++; list_for_each(entry, &adapter->erp_running_head) running++; total = adapter->erp_total_count; spin_lock_irqsave(&adapter->rec_dbf_lock, flags); memset(r, 0, sizeof(*r)); r->id = ZFCP_REC_DBF_ID_THREAD; memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); r->u.thread.total = total; r->u.thread.ready = ready; r->u.thread.running = running; debug_event(adapter->rec_dbf, 6, r, sizeof(*r)); spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); }
/** * zfcp_dbf_hba_fsf_res - trace event for fsf responses * @tag: tag indicating which kind of unsolicited status has been received * @req: request for which a response was received */ void zfcp_dbf_hba_fsf_res(char *tag, int level, struct zfcp_fsf_req *req) { struct zfcp_dbf *dbf = req->adapter->dbf; struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix; struct fsf_qtcb_header *q_head = &req->qtcb->header; struct zfcp_dbf_hba *rec = &dbf->hba_buf; unsigned long flags; spin_lock_irqsave(&dbf->hba_lock, flags); memset(rec, 0, sizeof(*rec)); memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); rec->id = ZFCP_DBF_HBA_RES; rec->fsf_req_id = req->req_id; rec->fsf_req_status = req->status; rec->fsf_cmd = req->fsf_command; rec->fsf_seq_no = req->seq_no; rec->u.res.req_issued = req->issued; rec->u.res.prot_status = q_pref->prot_status; rec->u.res.fsf_status = q_head->fsf_status; rec->u.res.port_handle = q_head->port_handle; rec->u.res.lun_handle = q_head->lun_handle; memcpy(rec->u.res.prot_status_qual, &q_pref->prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); memcpy(rec->u.res.fsf_status_qual, &q_head->fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); if (req->fsf_command != FSF_QTCB_FCP_CMND) { rec->pl_len = q_head->log_length; zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start, rec->pl_len, "fsf_res", req->req_id); } debug_event(dbf->hba, level, rec, sizeof(*rec)); spin_unlock_irqrestore(&dbf->hba_lock, flags); }
static inline void zfcp_dbf_pl_write(struct zfcp_dbf *dbf, void *data, u16 length, char *area, u64 req_id) { struct zfcp_dbf_pay *pl = &dbf->pay_buf; u16 offset = 0, rec_length; spin_lock(&dbf->pay_lock); memset(pl, 0, sizeof(*pl)); pl->fsf_req_id = req_id; memcpy(pl->area, area, ZFCP_DBF_TAG_LEN); while (offset < length) { rec_length = min((u16) ZFCP_DBF_PAY_MAX_REC, (u16) (length - offset)); memcpy(pl->data, data + offset, rec_length); debug_event(dbf->pay, 1, pl, zfcp_dbf_plen(rec_length)); offset += rec_length; pl->counter++; } spin_unlock(&dbf->pay_lock); }
boolean debug_program_start() { return debug_event(DBG_PROGRAM_START, null, null, 0, 0, 0, 0); }
boolean debug_program_exit() { return debug_event(DBG_PROGRAM_EXIT, null, null, 0, 0, 0, 0); }
static void _zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level, struct zfcp_adapter *adapter, struct scsi_cmnd *scsi_cmnd, struct zfcp_fsf_req *fsf_req, unsigned long old_req_id) { struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf; struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; unsigned long flags; struct fcp_rsp_iu *fcp_rsp; char *fcp_rsp_info = NULL, *fcp_sns_info = NULL; int offset = 0, buflen = 0; spin_lock_irqsave(&adapter->scsi_dbf_lock, flags); do { memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record)); if (offset == 0) { strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); if (scsi_cmnd != NULL) { if (scsi_cmnd->device) { rec->scsi_id = scsi_cmnd->device->id; rec->scsi_lun = scsi_cmnd->device->lun; } rec->scsi_result = scsi_cmnd->result; rec->scsi_cmnd = (unsigned long)scsi_cmnd; rec->scsi_serial = scsi_cmnd->serial_number; memcpy(rec->scsi_opcode, &scsi_cmnd->cmnd, min((int)scsi_cmnd->cmd_len, ZFCP_DBF_SCSI_OPCODE)); rec->scsi_retries = scsi_cmnd->retries; rec->scsi_allowed = scsi_cmnd->allowed; } if (fsf_req != NULL) { fcp_rsp = (struct fcp_rsp_iu *) &(fsf_req->qtcb->bottom.io.fcp_rsp); fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp); fcp_sns_info = zfcp_get_fcp_sns_info_ptr(fcp_rsp); rec->type.fcp.rsp_validity = fcp_rsp->validity.value; rec->type.fcp.rsp_scsi_status = fcp_rsp->scsi_status; rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid; if (fcp_rsp->validity.bits.fcp_rsp_len_valid) rec->type.fcp.rsp_code = *(fcp_rsp_info + 3); if (fcp_rsp->validity.bits.fcp_sns_len_valid) { buflen = min((int)fcp_rsp->fcp_sns_len, ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO); rec->type.fcp.sns_info_len = buflen; memcpy(rec->type.fcp.sns_info, fcp_sns_info, min(buflen, ZFCP_DBF_SCSI_FCP_SNS_INFO)); offset += min(buflen, ZFCP_DBF_SCSI_FCP_SNS_INFO); } rec->fsf_reqid = (unsigned long)fsf_req; rec->fsf_seqno = fsf_req->seq_no; rec->fsf_issued = fsf_req->issued; } rec->type.old_fsf_reqid = old_req_id; } else { strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); dump->total_size = buflen; dump->offset = offset; dump->size = min(buflen - offset, (int)sizeof(struct zfcp_scsi_dbf_record) - (int)sizeof(struct zfcp_dbf_dump)); memcpy(dump->data, fcp_sns_info + offset, dump->size); offset += dump->size; } debug_event(adapter->scsi_dbf, level, rec, sizeof(struct zfcp_scsi_dbf_record)); } while (offset < buflen); spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags); }
boolean debug_thread_stop(Thread* thread) { return debug_event(DBG_THREAD_STOP, null, thread, 0, 0, 0, 0); }
boolean debug_breakpoint(const Thread * thread, const int methodRecord, const int pc) { return debug_event(DBG_BREAKPOINT, null, thread, methodRecord, pc, 0, 0); }
boolean debug_single_step(Thread * thread, const int methodRecord, const int pc) { return debug_event(DBG_SINGLE_STEP, null, thread, methodRecord, pc, 0, 0); }
void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req) { struct zfcp_adapter *adapter = fsf_req->adapter; struct fsf_qtcb *qtcb = fsf_req->qtcb; union fsf_prot_status_qual *prot_status_qual = &qtcb->prefix.prot_status_qual; union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; struct scsi_cmnd *scsi_cmnd; struct zfcp_port *port; struct zfcp_unit *unit; struct zfcp_send_els *send_els; struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf; struct zfcp_hba_dbf_record_response *response = &rec->type.response; int level; unsigned long flags; spin_lock_irqsave(&adapter->hba_dbf_lock, flags); memset(rec, 0, sizeof(struct zfcp_hba_dbf_record)); strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE); level = 1; } else if (qtcb->header.fsf_status != FSF_GOOD) { strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE); level = 1; } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) || (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) { strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE); level = 4; } else if ((prot_status_qual->doubleword[0] != 0) || (prot_status_qual->doubleword[1] != 0) || (fsf_status_qual->doubleword[0] != 0) || (fsf_status_qual->doubleword[1] != 0)) { strncpy(rec->tag2, "qual", ZFCP_DBF_TAG_SIZE); level = 3; } else { strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE); level = 6; } response->fsf_command = fsf_req->fsf_command; response->fsf_reqid = (unsigned long)fsf_req; response->fsf_seqno = fsf_req->seq_no; response->fsf_issued = fsf_req->issued; response->fsf_prot_status = qtcb->prefix.prot_status; response->fsf_status = qtcb->header.fsf_status; memcpy(response->fsf_prot_status_qual, prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); memcpy(response->fsf_status_qual, fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); response->fsf_req_status = fsf_req->status; response->sbal_first = fsf_req->sbal_first; response->sbal_curr = fsf_req->sbal_curr; response->sbal_last = fsf_req->sbal_last; response->pool = fsf_req->pool != NULL; response->erp_action = (unsigned long)fsf_req->erp_action; switch (fsf_req->fsf_command) { case FSF_QTCB_FCP_CMND: if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) break; scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; if (scsi_cmnd != NULL) { response->data.send_fcp.scsi_cmnd = (unsigned long)scsi_cmnd; response->data.send_fcp.scsi_serial = scsi_cmnd->serial_number; } break; case FSF_QTCB_OPEN_PORT_WITH_DID: case FSF_QTCB_CLOSE_PORT: case FSF_QTCB_CLOSE_PHYSICAL_PORT: port = (struct zfcp_port *)fsf_req->data; response->data.port.wwpn = port->wwpn; response->data.port.d_id = port->d_id; response->data.port.port_handle = qtcb->header.port_handle; break; case FSF_QTCB_OPEN_LUN: case FSF_QTCB_CLOSE_LUN: unit = (struct zfcp_unit *)fsf_req->data; port = unit->port; response->data.unit.wwpn = port->wwpn; response->data.unit.fcp_lun = unit->fcp_lun; response->data.unit.port_handle = qtcb->header.port_handle; response->data.unit.lun_handle = qtcb->header.lun_handle; break; case FSF_QTCB_SEND_ELS: send_els = (struct zfcp_send_els *)fsf_req->data; response->data.send_els.d_id = qtcb->bottom.support.d_id; response->data.send_els.ls_code = send_els->ls_code >> 24; break; case FSF_QTCB_ABORT_FCP_CMND: case FSF_QTCB_SEND_GENERIC: case FSF_QTCB_EXCHANGE_CONFIG_DATA: case FSF_QTCB_EXCHANGE_PORT_DATA: case FSF_QTCB_DOWNLOAD_CONTROL_FILE: case FSF_QTCB_UPLOAD_CONTROL_FILE: break; } debug_event(adapter->hba_dbf, level, rec, sizeof(struct zfcp_hba_dbf_record)); spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); }
/** * NOTE: The technique is not the same as that used in TinyVM. * The return value indicates the impact of the call on the VM * system. EXEC_CONTINUE normal return the system should return to the return * address provided by the VM. EXEC_RUN The call has modified the value of * VM PC and this should be used to restart execution. EXEC_RETRY The call * needs to be re-tried (typically for a GC failure), all global state * should be left intact, the PC has been set appropriately. * */ int dispatch_native(TWOBYTES signature, STACKWORD * paramBase) { STACKWORD p0 = paramBase[0]; switch (signature) { case wait_4_5V: return monitor_wait((Object *) word2ptr(p0), 0); case wait_4J_5V: return monitor_wait((Object *) word2ptr(p0), ((int)paramBase[1] > 0 ? 0x7fffffff : paramBase[2])); case notify_4_5V: return monitor_notify((Object *) word2ptr(p0), false); case notifyAll_4_5V: return monitor_notify((Object *) word2ptr(p0), true); case start_4_5V: // Create thread, allow for instruction restart return init_thread((Thread *) word2ptr(p0)); case yield_4_5V: schedule_request(REQUEST_SWITCH_THREAD); break; case sleep_4J_5V: sleep_thread(((int)p0 > 0 ? 0x7fffffff : paramBase[1])); schedule_request(REQUEST_SWITCH_THREAD); break; case getPriority_4_5I: push_word(get_thread_priority((Thread *) word2ptr(p0))); break; case setPriority_4I_5V: { STACKWORD p = (STACKWORD) paramBase[1]; if (p > MAX_PRIORITY || p < MIN_PRIORITY) return throw_new_exception(JAVA_LANG_ILLEGALARGUMENTEXCEPTION); else set_thread_priority((Thread *) word2ptr(p0), p); } break; case currentThread_4_5Ljava_3lang_3Thread_2: push_ref(ptr2ref(currentThread)); break; case interrupt_4_5V: interrupt_thread((Thread *) word2ptr(p0)); break; case interrupted_4_5Z: { JBYTE i = currentThread->interruptState != INTERRUPT_CLEARED; currentThread->interruptState = INTERRUPT_CLEARED; push_word(i); } break; case isInterrupted_4_5Z: push_word(((Thread *) word2ptr(p0))->interruptState != INTERRUPT_CLEARED); break; case join_4_5V: join_thread((Thread *) word2ptr(p0), 0); break; case join_4J_5V: join_thread((Thread *) word2obj(p0), paramBase[2]); break; case halt_4I_5V: schedule_request(REQUEST_EXIT); break; case shutdown_4_5V: shutdown_program(false); break; case currentTimeMillis_4_5J: push_word(0); push_word(systick_get_ms()); break; case readSensorValue_4I_5I: push_word(sp_read(p0, SP_ANA)); break; case setPowerTypeById_4II_5V: sp_set_power(p0, paramBase[1]); break; case freeMemory_4_5J: push_word(0); push_word(getHeapFree()); break; case totalMemory_4_5J: push_word(0); push_word(getHeapSize()); break; case floatToRawIntBits_4F_5I: // Fall through case intBitsToFloat_4I_5F: push_word(p0); break; case doubleToRawLongBits_4D_5J: // Fall through case longBitsToDouble_4J_5D: push_word(p0); push_word(paramBase[1]); break; case drawString_4Ljava_3lang_3String_2II_5V: { String *p = (String *)word2obj(p0); Object *charArray; if (!p) return throw_new_exception(JAVA_LANG_NULLPOINTEREXCEPTION); charArray = (Object *) word2ptr(get_word_4_ns(fields_start(p))); if (!charArray) return throw_new_exception(JAVA_LANG_NULLPOINTEREXCEPTION); display_goto_xy(paramBase[1], paramBase[2]); display_jstring(p); } break; case drawInt_4III_5V: display_goto_xy(paramBase[1], paramBase[2]); display_int(p0, 0); break; case drawInt_4IIII_5V: display_goto_xy(paramBase[2], paramBase[3]); display_int(p0, paramBase[1]); break; case asyncRefresh_4_5V: display_update(); break; case clear_4_5V: display_clear(0); break; case getDisplay_4_5_1B: push_word(display_get_array()); break; case setAutoRefreshPeriod_4I_5I: push_word(display_set_auto_update_period(p0)); break; case getRefreshCompleteTime_4_5I: push_word(display_get_update_complete_time()); break; case bitBlt_4_1BIIII_1BIIIIIII_5V: { Object *src = word2ptr(p0); Object *dst = word2ptr(paramBase[5]); display_bitblt((byte *)(src != NULL ?jbyte_array(src):NULL), paramBase[1], paramBase[2], paramBase[3], paramBase[4], (byte *)(dst!=NULL?jbyte_array(dst):NULL), paramBase[6], paramBase[7], paramBase[8], paramBase[9], paramBase[10], paramBase[11], paramBase[12]); break; } case getSystemFont_4_5_1B: push_word(display_get_font()); break; case setContrast_4I_5V: nxt_lcd_set_pot(p0); break; case getBatteryStatus_4_5I: push_word(battery_voltage()); break; case getButtons_4_5I: push_word(buttons_get()); break; case getTachoCountById_4I_5I: push_word(nxt_motor_get_count(p0)); break; case controlMotorById_4III_5V: nxt_motor_set_speed(p0, paramBase[1], paramBase[2]); break; case resetTachoCountById_4I_5V: nxt_motor_set_count(p0, 0); break; case i2cEnableById_4II_5V: if (i2c_enable(p0, paramBase[1]) == 0) return EXEC_RETRY; else break; case i2cDisableById_4I_5V: i2c_disable(p0); break; case i2cStatusById_4I_5I: push_word(i2c_status(p0)); break; case i2cStartById_4II_1BIII_5I: { Object *p = word2obj(paramBase[2]); JBYTE *byteArray = p ? jbyte_array(p) + paramBase[3] : NULL; push_word(i2c_start(p0, paramBase[1], (U8 *)byteArray, paramBase[4], paramBase[5])); } break; case i2cCompleteById_4I_1BII_5I: { Object *p = word2ptr(paramBase[1]); JBYTE *byteArray = p ? jbyte_array(p) + paramBase[2] : NULL; push_word(i2c_complete(p0, (U8 *)byteArray, paramBase[3])); } break; case playFreq_4III_5V: sound_freq(p0,paramBase[1], paramBase[2]); break; case btGetBC4CmdMode_4_5I: push_word(bt_get_mode()); break; case btSetArmCmdMode_4I_5V: if (p0 == 0) bt_set_arm7_cmd(); else bt_clear_arm7_cmd(); break; case btSetResetLow_4_5V: bt_set_reset_low(); break; case btSetResetHigh_4_5V: bt_set_reset_high(); break; case btWrite_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(bt_write(byteArray, paramBase[1], paramBase[2])); } break; case btRead_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(bt_read(byteArray, paramBase[1], paramBase[2])); } break; case btPending_4_5I: { push_word(bt_event_check(0xffffffff)); } break; case btEnable_4_5V: if (bt_enable() == 0) return EXEC_RETRY; else break; case btDisable_4_5V: bt_disable(); break; case usbRead_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(udp_read(byteArray,paramBase[1], paramBase[2])); } break; case usbWrite_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(udp_write(byteArray,paramBase[1], paramBase[2])); } break; case usbStatus_4_5I: { push_word(udp_event_check(0xffffffff)); } break; case usbEnable_4I_5V: { udp_enable(p0); } break; case usbDisable_4_5V: { udp_disable(); } break; case usbReset_4_5V: udp_reset(); break; case usbSetSerialNo_4Ljava_3lang_3String_2_5V: { byte *p = word2ptr(p0); int len; Object *charArray = (Object *) word2ptr(get_word_4_ns(fields_start(p))); len = get_array_length(charArray); udp_set_serialno((U8 *)jchar_array(charArray), len); } break; case usbSetName_4Ljava_3lang_3String_2_5V: { byte *p = word2ptr(p0); int len; Object *charArray = (Object *) word2ptr(get_word_4_ns(fields_start(p))); len = get_array_length(charArray); udp_set_name((U8 *)jchar_array(charArray), len); } break; case flashWritePage_4_1BI_5I: { Object *p = word2ptr(p0); unsigned long *intArray = (unsigned long *) jint_array(p); push_word(flash_write_page(intArray,paramBase[1])); } break; case flashReadPage_4_1BI_5I: { Object *p = word2ptr(p0); unsigned long *intArray = (unsigned long *) jint_array(p); push_word(flash_read_page(intArray,paramBase[1])); } break; case flashExec_4II_5I: push_word(run_program((byte *)(&FLASH_BASE[(p0*FLASH_PAGE_SIZE)]), paramBase[1])); break; case playSample_4IIIII_5V: sound_play_sample(((unsigned char *) &FLASH_BASE[(p0*FLASH_PAGE_SIZE)]) + paramBase[1],paramBase[2],paramBase[3],paramBase[4]); break; case playQueuedSample_4_1BIIII_5I: push_word(sound_add_sample((U8 *)jbyte_array(word2obj(p0)) + paramBase[1],paramBase[2],paramBase[3],paramBase[4])); break; case getTime_4_5I: push_word(sound_get_time()); break; case getDataAddress_4Ljava_3lang_3Object_2_5I: if (is_array(word2obj(p0))) push_word (ptr2word ((byte *) array_start(word2ptr(p0)))); else push_word (ptr2word ((byte *) fields_start(word2ptr(p0)))); break; case getObjectAddress_4Ljava_3lang_3Object_2_5I: push_word(p0); break; case gc_4_5V: // Restartable garbage collection return garbage_collect(); case shutDown_4_5V: shutdown(); // does not return case boot_4_5V: display_clear(1); while (1) nxt_avr_firmware_update_mode(); // does not return case arraycopy_4Ljava_3lang_3Object_2ILjava_3lang_3Object_2II_5V: return arraycopy(word2ptr(p0), paramBase[1], word2ptr(paramBase[2]), paramBase[3], paramBase[4]); case executeProgram_4I_5V: // Exceute program, allow for instruction re-start return execute_program(p0); case setDebug_4_5V: set_debug(word2ptr(p0)); break; case eventOptions_4II_5I: { byte old = debugEventOptions[p0]; debugEventOptions[p0] = (byte)paramBase[1]; push_word(old); } break; case suspendThread_4Ljava_3lang_3Object_2_5V: suspend_thread(ref2ptr(p0)); break; case resumeThread_4Ljava_3lang_3Object_2_5V: resume_thread(ref2ptr(p0)); break; case getProgramExecutionsCount_4_5I: push_word(gProgramExecutions); break; case getFirmwareRevision_4_5I: push_word((STACKWORD) getRevision()); break; case getFirmwareRawVersion_4_5I: push_word((STACKWORD) VERSION_NUMBER); break; case hsEnable_4II_5V: { if (hs_enable((int)p0, (int)paramBase[1]) == 0) return EXEC_RETRY; } break; case hsDisable_4_5V: { hs_disable(); } break; case hsWrite_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(hs_write(byteArray, paramBase[1], paramBase[2])); } break; case hsRead_4_1BII_5I: { Object *p = word2ptr(p0); byte *byteArray = (byte *) jbyte_array(p); push_word(hs_read(byteArray, paramBase[1], paramBase[2])); } break; case hsPending_4_5I: { push_word(hs_pending()); } break; case hsSend_4BB_1BII_1C_5I: { Object *p = word2ptr(paramBase[2]); U8 *data = (U8 *)jbyte_array(p); p = word2ptr(paramBase[5]); U16 *crc = (U16 *)jchar_array(p); push_word(hs_send((U8) p0, (U8)paramBase[1], data, paramBase[3], paramBase[4], crc)); } break; case hsRecv_4_1BI_1CI_5I: { Object *p = word2ptr(p0); U8 *data = (U8 *)jbyte_array(p); p = word2ptr(paramBase[2]); U16 *crc = (U16 *)jchar_array(p); push_word(hs_recv(data, paramBase[1], crc, paramBase[3])); } break; case getUserPages_4_5I: push_word(FLASH_MAX_PAGES - flash_start_page); break; case setVMOptions_4I_5V: gVMOptions = p0; break; case getVMOptions_4_5I: push_word(gVMOptions); break; case isAssignable_4II_5Z: push_word(is_assignable(p0, paramBase[1])); break; case cloneObject_4Ljava_3lang_3Object_2_5Ljava_3lang_3Object_2: { Object *newObj = clone((Object *)ref2obj(p0)); if (newObj == NULL) return EXEC_RETRY; push_word(obj2ref(newObj)); } break; case memPeek_4III_5I: push_word(mem_peek(p0, paramBase[1], paramBase[2])); break; case memCopy_4Ljava_3lang_3Object_2IIII_5V: mem_copy(word2ptr(p0), paramBase[1], paramBase[2], paramBase[3], paramBase[4]); break; case memGetReference_4II_5Ljava_3lang_3Object_2: push_word(mem_get_reference(p0, paramBase[1])); break; case setSensorPin_4III_5V: sp_set(p0, paramBase[1], paramBase[2]); break; case getSensorPin_4II_5I: push_word(sp_get(p0, paramBase[1])); break; case setSensorPinMode_4III_5V: sp_set_mode(p0, paramBase[1], paramBase[2]); break; case readSensorPin_4II_5I: push_word(sp_read(p0, paramBase[1])); break; case nanoTime_4_5J: { U64 ns = systick_get_ns(); push_word(ns >> 32); push_word(ns); } break; case createStackTrace_4Ljava_3lang_3Thread_2Ljava_3lang_3Object_2_5_1I: { Object *trace = create_stack_trace((Thread *)ref2obj(p0), ref2obj(paramBase[1])); if (trace == NULL) return EXEC_RETRY; push_word(obj2ref(trace)); } break; case registerEvent_4_5I: push_word(register_event((NXTEvent *) ref2obj(p0))); break; case unregisterEvent_4_5I: push_word(unregister_event((NXTEvent *) ref2obj(p0))); break; case changeEvent_4II_5I: push_word(change_event((NXTEvent *) ref2obj(p0), paramBase[1], paramBase[2])); break; case isInitialized_4I_5Z: push_word(is_initialized_idx(p0)); break; case allocate_4II_5Ljava_3lang_3Object_2: { Object *allocated; if(paramBase[1]>0){ allocated=new_single_array(p0,paramBase[1]); }else{ allocated=new_object_for_class(p0); } if(allocated == NULL) return EXEC_RETRY; push_word(obj2ref(allocated)); } break; case memPut_4IIII_5V: store_word_ns((byte *)(memory_base[p0] + paramBase[1]), paramBase[2],paramBase[3]); break; case notifyEvent_4ILjava_3lang_3Thread_2_5Z: push_word(debug_event(paramBase[1], NULL, (Thread*) ref2obj(paramBase[2]), 0, 0, 0, 0)); break; case setThreadRequest_4Ljava_3lang_3Thread_2Llejos_3nxt_3debug_3SteppingRequest_2_5V: { Thread *th = (Thread*) ref2obj(p0); th->debugData = (REFERENCE) paramBase[1]; // currently we only get stepping requests if(paramBase[1]) th->flags |= THREAD_STEPPING; else th->flags &= ~THREAD_STEPPING; } break; case isStepping_4Ljava_3lang_3Thread_2_5Z: { Thread *th = (Thread*) ref2obj(p0); push_word(is_stepping(th)); } break; case setBreakpointList_4_1Llejos_3nxt_3debug_3Breakpoint_2I_5V: breakpoint_set_list((Breakpoint**) array_start(p0), paramBase[1]); break; case enableBreakpoint_4Llejos_3nxt_3debug_3Breakpoint_2Z_5V: breakpoint_enable((Breakpoint*) word2ptr(p0), (boolean) paramBase[1]); break; case firmwareExceptionHandler_4Ljava_3lang_3Throwable_2II_5V: firmware_exception_handler((Throwable *)p0, paramBase[1], paramBase[2]); break; case exitThread_4_5V: currentThread->state = DEAD; schedule_request(REQUEST_SWITCH_THREAD); break; case updateThreadFlags_4Ljava_3lang_3Thread_2II_5I: ((Thread *)p0)->flags |= paramBase[1]; ((Thread *)p0)->flags &= ~paramBase[2]; //printf("m %x %d\n", p0, ((Thread *)p0)->flags); push_word(((Thread *)p0)->flags); break; default: return throw_new_exception(JAVA_LANG_NOSUCHMETHODERROR); } return EXEC_CONTINUE; }
/** * zfcp_hba_dbf_event_fsf_response - trace event for request completion * @fsf_req: request that has been completed */ void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req) { struct zfcp_adapter *adapter = fsf_req->adapter; struct fsf_qtcb *qtcb = fsf_req->qtcb; union fsf_prot_status_qual *prot_status_qual = &qtcb->prefix.prot_status_qual; union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; struct scsi_cmnd *scsi_cmnd; struct zfcp_port *port; struct zfcp_unit *unit; struct zfcp_send_els *send_els; struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf; struct zfcp_hba_dbf_record_response *response = &rec->u.response; int level; unsigned long flags; spin_lock_irqsave(&adapter->hba_dbf_lock, flags); memset(rec, 0, sizeof(*rec)); strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE); level = 1; } else if (qtcb->header.fsf_status != FSF_GOOD) { strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE); level = 1; } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) || (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) { strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE); level = 4; } else if (qtcb->header.log_length) { strncpy(rec->tag2, "qtcb", ZFCP_DBF_TAG_SIZE); level = 5; } else { strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE); level = 6; } response->fsf_command = fsf_req->fsf_command; response->fsf_reqid = (unsigned long)fsf_req; response->fsf_seqno = fsf_req->seq_no; response->fsf_issued = fsf_req->issued; response->fsf_prot_status = qtcb->prefix.prot_status; response->fsf_status = qtcb->header.fsf_status; memcpy(response->fsf_prot_status_qual, prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); memcpy(response->fsf_status_qual, fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); response->fsf_req_status = fsf_req->status; response->sbal_first = fsf_req->sbal_first; response->sbal_last = fsf_req->sbal_last; response->sbal_response = fsf_req->sbal_response; response->pool = fsf_req->pool != NULL; response->erp_action = (unsigned long)fsf_req->erp_action; switch (fsf_req->fsf_command) { case FSF_QTCB_FCP_CMND: if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) break; scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; if (scsi_cmnd) { response->u.fcp.cmnd = (unsigned long)scsi_cmnd; response->u.fcp.serial = scsi_cmnd->serial_number; } break; case FSF_QTCB_OPEN_PORT_WITH_DID: case FSF_QTCB_CLOSE_PORT: case FSF_QTCB_CLOSE_PHYSICAL_PORT: port = (struct zfcp_port *)fsf_req->data; response->u.port.wwpn = port->wwpn; response->u.port.d_id = port->d_id; response->u.port.port_handle = qtcb->header.port_handle; break; case FSF_QTCB_OPEN_LUN: case FSF_QTCB_CLOSE_LUN: unit = (struct zfcp_unit *)fsf_req->data; port = unit->port; response->u.unit.wwpn = port->wwpn; response->u.unit.fcp_lun = unit->fcp_lun; response->u.unit.port_handle = qtcb->header.port_handle; response->u.unit.lun_handle = qtcb->header.lun_handle; break; case FSF_QTCB_SEND_ELS: send_els = (struct zfcp_send_els *)fsf_req->data; response->u.els.d_id = qtcb->bottom.support.d_id; response->u.els.ls_code = send_els->ls_code >> 24; break; case FSF_QTCB_ABORT_FCP_CMND: case FSF_QTCB_SEND_GENERIC: case FSF_QTCB_EXCHANGE_CONFIG_DATA: case FSF_QTCB_EXCHANGE_PORT_DATA: case FSF_QTCB_DOWNLOAD_CONTROL_FILE: case FSF_QTCB_UPLOAD_CONTROL_FILE: break; } debug_event(adapter->hba_dbf, level, rec, sizeof(*rec)); /* have fcp channel microcode fixed to use as little as possible */ if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { /* adjust length skipping trailing zeros */ char *buf = (char *)qtcb + qtcb->header.log_start; int len = qtcb->header.log_length; for (; len && !buf[len - 1]; len--); zfcp_dbf_hexdump(adapter->hba_dbf, rec, sizeof(*rec), level, buf, len); } spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); }
int event_queue_push(event_level_t level, struct connectSock * psock, event_queue_pt pt, // uint8_t cmd, // uint16_t opt_code, void * pdata, int siz) { int ret = 0; //int max_conn = 0; uint32_t weight = 0; struct cmd_event * pe; event_queue_t * peq; uint16_t * p_value; timestamp++; //printf("\ntimestamp = %u\n", timestamp); if (siz > MAX_EBUF_SIZ) { log_error(LOG_NOTICE, "MAX_EBUF_SIZ"); return -1; } weight = ++weightness; if (psock != NULL) { weight = psock->addr; p_value = &psock->event_cnt; } else { p_value = &pserial_des->event_cnt; } peq = pq + get_tindex(weight); //平衡相应的队列 EVENT_LOCK(peq); debug_event("\nstart push ok line = %d\n", __LINE__); do { pe = cmd_event_new(peq, siz); if (pe == NULL) { if (psock == NULL) { peq = pq + get_tindex(weight + 1); pe = cmd_event_new(peq, siz); } if (pe == NULL) { ret = -1; log_error(LOG_NOTICE, "cmd queue full queue.no = %d", peq->queue_no); break; } } pe->level = level; // pe->cmd = cmd; // pe->opt_code = opt_code; pe->weight_value = ++(*p_value); pe->timestamp = timestamp; pe->cb = pt; pe->psock = psock; memcpy(pe->buffer, pdata, siz); //printf("\npe->level = %d, pe->timestamp = %u\n",level, timestamp); if (min_heap_insert(peq->heap, pe) == NULL) { log_error(LOG_ERROR, "min_heap_inisert !!!!"); cmd_event_del(peq, pe); } } while (0); // printf("\nccc\n"); event_queue_wakeup(peq); debug_event("\nend push ok line = %d\n", __LINE__); EVENT_UNLOCK(peq); return ret; }
void _zfcp_dbf_hba_fsf_response(const char *tag2, int level, struct zfcp_fsf_req *fsf_req, struct zfcp_dbf *dbf) { struct fsf_qtcb *qtcb = fsf_req->qtcb; union fsf_prot_status_qual *prot_status_qual = &qtcb->prefix.prot_status_qual; union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; struct scsi_cmnd *scsi_cmnd; struct zfcp_port *port; struct zfcp_unit *unit; struct zfcp_send_els *send_els; struct zfcp_dbf_hba_record *rec = &dbf->hba_buf; struct zfcp_dbf_hba_record_response *response = &rec->u.response; unsigned long flags; spin_lock_irqsave(&dbf->hba_lock, flags); memset(rec, 0, sizeof(*rec)); strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); response->fsf_command = fsf_req->fsf_command; response->fsf_reqid = fsf_req->req_id; response->fsf_seqno = fsf_req->seq_no; response->fsf_issued = fsf_req->issued; response->fsf_prot_status = qtcb->prefix.prot_status; response->fsf_status = qtcb->header.fsf_status; memcpy(response->fsf_prot_status_qual, prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); memcpy(response->fsf_status_qual, fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); response->fsf_req_status = fsf_req->status; response->sbal_first = fsf_req->queue_req.sbal_first; response->sbal_last = fsf_req->queue_req.sbal_last; response->sbal_response = fsf_req->queue_req.sbal_response; response->pool = fsf_req->pool != NULL; response->erp_action = (unsigned long)fsf_req->erp_action; switch (fsf_req->fsf_command) { case FSF_QTCB_FCP_CMND: if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) break; scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; if (scsi_cmnd) { response->u.fcp.cmnd = (unsigned long)scsi_cmnd; response->u.fcp.serial = scsi_cmnd->serial_number; } break; case FSF_QTCB_OPEN_PORT_WITH_DID: case FSF_QTCB_CLOSE_PORT: case FSF_QTCB_CLOSE_PHYSICAL_PORT: port = (struct zfcp_port *)fsf_req->data; response->u.port.wwpn = port->wwpn; response->u.port.d_id = port->d_id; response->u.port.port_handle = qtcb->header.port_handle; break; case FSF_QTCB_OPEN_LUN: case FSF_QTCB_CLOSE_LUN: unit = (struct zfcp_unit *)fsf_req->data; port = unit->port; response->u.unit.wwpn = port->wwpn; response->u.unit.fcp_lun = unit->fcp_lun; response->u.unit.port_handle = qtcb->header.port_handle; response->u.unit.lun_handle = qtcb->header.lun_handle; break; case FSF_QTCB_SEND_ELS: send_els = (struct zfcp_send_els *)fsf_req->data; response->u.els.d_id = qtcb->bottom.support.d_id; response->u.els.ls_code = send_els->ls_code >> 24; break; case FSF_QTCB_ABORT_FCP_CMND: case FSF_QTCB_SEND_GENERIC: case FSF_QTCB_EXCHANGE_CONFIG_DATA: case FSF_QTCB_EXCHANGE_PORT_DATA: case FSF_QTCB_DOWNLOAD_CONTROL_FILE: case FSF_QTCB_UPLOAD_CONTROL_FILE: break; } debug_event(dbf->hba, level, rec, sizeof(*rec)); if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { char *buf = (char *)qtcb + qtcb->header.log_start; int len = qtcb->header.log_length; for (; len && !buf[len - 1]; len--); zfcp_dbf_hexdump(dbf->hba, rec, sizeof(*rec), level, buf, len); } spin_unlock_irqrestore(&dbf->hba_lock, flags); }