} else if (crp->crp_flags & CRYPTO_F_IOV) { hifnstats.hst_obytes += cmd->dst_map->dm_mapsize; dma->dstk = (dma->dstk + cmd->dst_map->dm_nsegs) % HIFN_D_DST_RSIZE; dma->dstu -= cmd->dst_map->dm_nsegs;
hifn_callback(sc, cmd, macbuf)	struct hifn_softc *sc;	struct hifn_command *cmd;	u_int8_t *macbuf;{	struct hifn_dma *dma = sc->sc_dma;	struct cryptop *crp = (struct cryptop *)cmd->private_data;	struct cryptodesc *crd;	struct mbuf *m;	int totlen;	bus_dmamap_sync(sc->sc_dmat, cmd->src_map, BUS_DMASYNC_POSTREAD);	bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, BUS_DMASYNC_POSTWRITE);	if (crp->crp_flags & CRYPTO_F_IMBUF) {		if (cmd->src_m != cmd->dst_m) {			m_freem(cmd->src_m);			crp->crp_buf = (caddr_t)cmd->dst_m;		}		if ((m = cmd->dst_m) != NULL) {			totlen = cmd->src_map->dm_mapsize;			hifnstats.hst_obytes += totlen;			while (m) {				if (totlen < m->m_len) {					m->m_len = totlen;					totlen = 0;				} else					totlen -= m->m_len;				m = m->m_next;				if (++dma->dstk == HIFN_D_DST_RSIZE)					dma->dstk = 0;				dma->dstu--;			}		} else {			hifnstats.hst_obytes += dma->dstr[dma->dstk].l & HIFN_D_LENGTH;			if (++dma->dstk == HIFN_D_DST_RSIZE)				dma->dstk = 0;			dma->dstu--;		}	}	if ((cmd->base_masks & (HIFN_BASE_CMD_CRYPT | HIFN_BASE_CMD_DECODE)) ==	    HIFN_BASE_CMD_CRYPT) {		for (crd = crp->crp_desc; crd; crd = crd->crd_next) {			if (crd->crd_alg != CRYPTO_DES_CBC &&			    crd->crd_alg != CRYPTO_3DES_CBC)				continue;			if (crp->crp_flags & CRYPTO_F_IMBUF)				m_copydata((struct mbuf *)crp->crp_buf,				    crd->crd_skip + crd->crd_len - HIFN_IV_LENGTH,				    HIFN_IV_LENGTH,				    cmd->softc->sc_sessions[cmd->session_num].hs_iv);			else if (crp->crp_flags & CRYPTO_F_IOV) {				cuio_copydata((struct uio *)crp->crp_buf,				    crd->crd_skip + crd->crd_len - HIFN_IV_LENGTH,				    HIFN_IV_LENGTH,				    cmd->softc->sc_sessions[cmd->session_num].hs_iv);			}			break;		}	}	if (macbuf != NULL) {		for (crd = crp->crp_desc; crd; crd = crd->crd_next) {			if (crd->crd_alg != CRYPTO_MD5_HMAC &&			    crd->crd_alg != CRYPTO_SHA1_HMAC)				continue;			if (crp->crp_flags & CRYPTO_F_IMBUF)				m_copyback((struct mbuf *)crp->crp_buf,				    crd->crd_inject, 12, macbuf);			else if ((crp->crp_flags & CRYPTO_F_IOV) && crp->crp_mac)				bcopy((caddr_t)macbuf, crp->crp_mac, 12);			break;		}	}	if (cmd->src_map != cmd->dst_map) {		bus_dmamap_unload(sc->sc_dmat, cmd->dst_map);		bus_dmamap_destroy(sc->sc_dmat, cmd->dst_map);	}	bus_dmamap_unload(sc->sc_dmat, cmd->src_map);	bus_dmamap_destroy(sc->sc_dmat, cmd->src_map);	free(cmd, M_DEVBUF);	crypto_done(crp);}