Lines Matching defs:cm
96 struct mps_command *cm);
99 static void mps_config_complete(struct mps_softc *sc, struct mps_command *cm);
102 static void mps_enqueue_request(struct mps_softc *sc, struct mps_command *cm);
121 /* Added this union to smoothly convert le64toh cm->cm_desc.Words.
738 struct mps_command *cm;
786 cm = &sc->commands[i];
787 bus_dmamap_destroy(sc->buffer_dmat, cm->cm_dmamap);
1095 mps_enqueue_request(struct mps_softc *sc, struct mps_command *cm)
1099 mps_dprint(sc, MPS_TRACE, "SMID %u cm %p ccb %p\n",
1100 cm->cm_desc.Default.SMID, cm, cm->cm_ccb);
1107 rd.u.low = cm->cm_desc.Words.Low;
1108 rd.u.high = cm->cm_desc.Words.High;
1111 KASSERT(cm->cm_state == MPS_CM_STATE_BUSY,
1112 ("command not busy, state = %u\n", cm->cm_state));
1113 cm->cm_state = MPS_CM_STATE_INQUEUE;
1424 struct mps_command *cm;
1513 cm = &sc->commands[i];
1514 cm->cm_req = sc->req_frames + i * sc->reqframesz;
1515 cm->cm_req_busaddr = sc->req_busaddr + i * sc->reqframesz;
1516 cm->cm_sense = &sc->sense_frames[i];
1517 cm->cm_sense_busaddr = sc->sense_busaddr + i * MPS_SENSE_LEN;
1518 cm->cm_desc.Default.SMID = i;
1519 cm->cm_sc = sc;
1520 cm->cm_state = MPS_CM_STATE_BUSY;
1521 TAILQ_INIT(&cm->cm_chain_list);
1522 callout_init_mtx(&cm->cm_callout, &sc->mps_mtx, 0);
1525 if (bus_dmamap_create(sc->buffer_dmat, 0, &cm->cm_dmamap) == 0)
1527 mps_free_high_priority_command(sc, cm);
1529 mps_free_command(sc, cm);
1950 struct mps_command *cm;
1978 cm = &sc->commands[i];
1979 if ((sc->dump_reqs_alltypes == 0) && (cm->cm_state != state))
1982 hdr.state = cm->cm_state;
1984 hdr.deschi = cm->cm_desc.Words.High;
1985 hdr.desclo = cm->cm_desc.Words.Low;
1986 TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link,
1990 sbuf_bcat(sb, cm->cm_req, 128);
1991 TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link,
2230 mps_complete_command(struct mps_softc *sc, struct mps_command *cm)
2234 if (cm == NULL) {
2239 KASSERT(cm->cm_state == MPS_CM_STATE_INQUEUE,
2240 ("command not inqueue, state = %u\n", cm->cm_state));
2241 cm->cm_state = MPS_CM_STATE_BUSY;
2242 if (cm->cm_flags & MPS_CM_FLAGS_POLLED)
2243 cm->cm_flags |= MPS_CM_FLAGS_COMPLETE;
2245 if (cm->cm_complete != NULL) {
2247 "%s cm %p calling cm_complete %p data %p reply %p\n",
2248 __func__, cm, cm->cm_complete, cm->cm_complete_data,
2249 cm->cm_reply);
2250 cm->cm_complete(sc, cm);
2253 if (cm->cm_flags & MPS_CM_FLAGS_WAKEUP) {
2254 mps_dprint(sc, MPS_TRACE, "waking up %p\n", cm);
2255 wakeup(cm);
2258 if (cm->cm_sc->io_cmds_active != 0) {
2259 cm->cm_sc->io_cmds_active--;
2373 struct mps_command *cm = NULL;
2386 cm = NULL;
2406 * and cm completion handlers which decide to do a diag
2417 cm = &sc->commands[le16toh(desc->SCSIIOSuccess.SMID)];
2418 cm->cm_reply = NULL;
2490 cm = &sc->commands[
2492 if (cm->cm_state == MPS_CM_STATE_INQUEUE) {
2493 cm->cm_reply = reply;
2494 cm->cm_reply_data = le32toh(
2499 " ignoring state %d cm %p\n",
2500 cm->cm_state, cm);
2512 cm = NULL;
2517 if (cm != NULL) {
2519 if (cm->cm_reply)
2520 mps_display_reply_info(sc,cm->cm_reply);
2521 mps_complete_command(sc, cm);
2562 mps_reregister_events_complete(struct mps_softc *sc, struct mps_command *cm)
2566 if (cm->cm_reply)
2568 (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply);
2570 mps_free_command(sc, cm);
2605 struct mps_command *cm;
2620 if ((cm = mps_alloc_command(sc)) == NULL)
2622 evtreq = (MPI2_EVENT_NOTIFICATION_REQUEST *)cm->cm_req;
2638 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
2639 cm->cm_data = NULL;
2641 error = mps_wait_command(sc, &cm, 60, 0);
2642 if (cm != NULL)
2643 reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply;
2653 if (cm != NULL)
2654 mps_free_command(sc, cm);
2662 struct mps_command *cm;
2678 if ((cm = mps_alloc_command(sc)) == NULL)
2680 evtreq = (MPI2_EVENT_NOTIFICATION_REQUEST *)cm->cm_req;
2696 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
2697 cm->cm_data = NULL;
2698 cm->cm_complete = mps_reregister_events_complete;
2700 error = mps_map_command(sc, cm);
2720 mps_add_chain(struct mps_command *cm)
2726 if (cm->cm_sglsize < MPS_SGC_SIZE)
2729 chain = mps_alloc_chain(cm->cm_sc);
2733 space = cm->cm_sc->reqframesz;
2739 TAILQ_INSERT_TAIL(&cm->cm_chain_list, chain, chain_link);
2741 sgc = (MPI2_SGE_CHAIN64 *)&cm->cm_sge->MpiChain;
2754 cm->cm_sge = (MPI2_SGE_IO_UNION *)&chain->chain->MpiSimple;
2755 cm->cm_sglsize = space;
2766 mps_push_sge(struct mps_command *cm, void *sgep, size_t len, int segsleft)
2816 if (cm->cm_sglsize < MPS_SGC_SIZE)
2819 if (segsleft >= 1 && cm->cm_sglsize < len + MPS_SGC_SIZE) {
2826 if ((error = mps_add_chain(cm)) != 0)
2831 cm->cm_sglsize < len + MPS_SGC_SIZE + MPS_SGE64_SIZE) {
2848 cm->cm_sglsize -= len;
2849 bcopy(sgep, cm->cm_sge, len);
2850 cm->cm_sge = (MPI2_SGE_IO_UNION *)((uintptr_t)cm->cm_sge + len);
2851 return (mps_add_chain(cm));
2856 if (segsleft == 1 && cm->cm_sglsize < len)
2858 cm->cm_sglsize, len);
2861 if (segsleft == 2 && cm->cm_sglsize < len + MPS_SGE64_SIZE)
2863 cm->cm_sglsize, len);
2875 * DMA buffer (same cm command).
2880 if (cm->cm_out_len) {
2881 sge->FlagsLength = htole32(cm->cm_out_len |
2887 cm->cm_sglsize -= len;
2888 bcopy(sgep, cm->cm_sge, len);
2889 cm->cm_sge = (MPI2_SGE_IO_UNION *)((uintptr_t)cm->cm_sge
2899 if (cm->cm_flags & MPS_CM_FLAGS_DATAIN) {
2913 cm->cm_sglsize -= len;
2914 bcopy(sgep, cm->cm_sge, len);
2915 cm->cm_sge = (MPI2_SGE_IO_UNION *)((uintptr_t)cm->cm_sge + len);
2923 mps_add_dmaseg(struct mps_command *cm, vm_paddr_t pa, size_t len, u_int flags,
2937 return (mps_push_sge(cm, &sge, sizeof sge, segsleft));
2944 struct mps_command *cm;
2947 cm = (struct mps_command *)arg;
2948 sc = cm->cm_sc;
2954 if ((cm->cm_max_segs != 0) && (nsegs > cm->cm_max_segs)) {
2958 cm->cm_max_segs);
2966 if (cm->cm_flags & MPS_CM_FLAGS_SMP_PASS) {
2988 } else if (cm->cm_flags & MPS_CM_FLAGS_DATAOUT) {
2995 if ((cm->cm_flags & MPS_CM_FLAGS_SMP_PASS) && (i != 0)) {
2998 error = mps_add_dmaseg(cm, segs[i].ds_addr, segs[i].ds_len,
3005 cm->cm_flags |= MPS_CM_FLAGS_CHAIN_FAILED;
3012 cm->cm_state = MPS_CM_STATE_INQUEUE;
3013 mps_complete_command(sc, cm);
3018 bus_dmamap_sync(sc->buffer_dmat, cm->cm_dmamap, dir);
3019 mps_enqueue_request(sc, cm);
3039 mps_map_command(struct mps_softc *sc, struct mps_command *cm)
3043 if (cm->cm_flags & MPS_CM_FLAGS_USE_UIO) {
3044 error = bus_dmamap_load_uio(sc->buffer_dmat, cm->cm_dmamap,
3045 &cm->cm_uio, mps_data_cb2, cm, 0);
3046 } else if (cm->cm_flags & MPS_CM_FLAGS_USE_CCB) {
3047 error = bus_dmamap_load_ccb(sc->buffer_dmat, cm->cm_dmamap,
3048 cm->cm_data, mps_data_cb, cm, 0);
3049 } else if ((cm->cm_data != NULL) && (cm->cm_length != 0)) {
3050 error = bus_dmamap_load(sc->buffer_dmat, cm->cm_dmamap,
3051 cm->cm_data, cm->cm_length, mps_data_cb, cm, 0);
3054 if (cm->cm_sge != NULL)
3055 mps_add_dmaseg(cm, 0, 0, 0, 1);
3056 mps_enqueue_request(sc, cm);
3073 struct mps_command *cm = *cmp;
3078 cm->cm_complete = NULL;
3079 cm->cm_flags |= MPS_CM_FLAGS_POLLED;
3080 error = mps_map_command(sc, cm);
3093 cm->cm_flags |= MPS_CM_FLAGS_WAKEUP;
3094 error = msleep(cm, &sc->mps_mtx, 0, "mpswait", timeout*hz);
3104 while ((cm->cm_flags & MPS_CM_FLAGS_COMPLETE) == 0) {
3121 if (cm->cm_timeout_handler == NULL) {
3129 cm->cm_timeout_handler(sc, cm);
3150 struct mps_command *cm;
3157 cm = mps_alloc_command(sc);
3158 if (cm == NULL) {
3162 req = (MPI2_CONFIG_REQUEST *)cm->cm_req;
3188 cm->cm_data = params->buffer;
3189 cm->cm_length = params->length;
3190 if (cm->cm_data != NULL) {
3191 cm->cm_sge = &req->PageBufferSGE;
3192 cm->cm_sglsize = sizeof(MPI2_SGE_IO_UNION);
3193 cm->cm_flags = MPS_CM_FLAGS_SGE_SIMPLE | MPS_CM_FLAGS_DATAIN;
3195 cm->cm_sge = NULL;
3196 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
3198 cm->cm_complete_data = params;
3200 cm->cm_complete = mps_config_complete;
3201 return (mps_map_command(sc, cm));
3203 error = mps_wait_command(sc, &cm, 0, CAN_SLEEP);
3207 if (cm != NULL)
3208 mps_free_command(sc, cm);
3211 mps_config_complete(sc, cm);
3224 mps_config_complete(struct mps_softc *sc, struct mps_command *cm)
3230 params = cm->cm_complete_data;
3232 if (cm->cm_data != NULL) {
3233 bus_dmamap_sync(sc->buffer_dmat, cm->cm_dmamap,
3235 bus_dmamap_unload(sc->buffer_dmat, cm->cm_dmamap);
3242 if ((cm->cm_flags & MPS_CM_FLAGS_ERROR_MASK) != 0) {
3247 reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
3267 mps_free_command(sc, cm);