From a3ac440347cde512e0f06cf2d18bba7dc621faf4 Mon Sep 17 00:00:00 2001 From: Jason Wright Date: Sun, 24 Jun 2001 17:43:30 +0000 Subject: reflect reality more closely and remove more invertex stuff --- sys/dev/pci/hifn7751.c | 50 +++++++++++++++---------------- sys/dev/pci/hifn7751var.h | 75 ++++++++--------------------------------------- 2 files changed, 38 insertions(+), 87 deletions(-) (limited to 'sys') diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c index 776c4d30e61..9777e899540 100644 --- a/sys/dev/pci/hifn7751.c +++ b/sys/dev/pci/hifn7751.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751.c,v 1.79 2001/06/24 16:30:59 jason Exp $ */ +/* $OpenBSD: hifn7751.c,v 1.80 2001/06/24 17:43:28 jason Exp $ */ /* * Invertex AEON / Hi/fn 7751 driver @@ -93,7 +93,7 @@ int hifn_newsession __P((u_int32_t *, struct cryptoini *)); int hifn_freesession __P((u_int64_t)); int hifn_process __P((struct cryptop *)); void hifn_callback __P((struct hifn_softc *, struct hifn_command *, u_int8_t *)); -int hifn_crypto __P((struct hifn_softc *, hifn_command_t *, struct cryptop *)); +int hifn_crypto __P((struct hifn_softc *, struct hifn_command *, struct cryptop *)); int hifn_readramaddr __P((struct hifn_softc *, int, u_int8_t *, int)); int hifn_writeramaddr __P((struct hifn_softc *, int, u_int8_t *, int)); int hifn_dmamap_aligned __P((bus_dmamap_t)); @@ -1012,20 +1012,20 @@ hifn_crypto(sc, cmd, crp) if (crp->crp_flags & CRYPTO_F_IMBUF) { if (bus_dmamap_load_mbuf(sc->sc_dmat, cmd->src_map, - cmd->src_m, BUS_DMA_NOWAIT)) + cmd->srcu.src_m, BUS_DMA_NOWAIT)) goto err_srcmap1; } else if (crp->crp_flags & CRYPTO_F_IOV) { if (bus_dmamap_load_uio(sc->sc_dmat, cmd->src_map, - cmd->src_io, BUS_DMA_NOWAIT)) + cmd->srcu.src_io, BUS_DMA_NOWAIT)) goto err_srcmap1; } else goto err_srcmap1; if (hifn_dmamap_aligned(cmd->src_map)) { if (crp->crp_flags & CRYPTO_F_IOV) - cmd->dst_io = cmd->src_io; + cmd->dstu.dst_io = cmd->srcu.src_io; else if (crp->crp_flags & CRYPTO_F_IMBUF) - cmd->dst_m = cmd->src_m; + cmd->dstu.dst_m = cmd->srcu.src_m; cmd->dst_map = cmd->src_map; } else { if (crp->crp_flags & CRYPTO_F_IOV) @@ -1035,7 +1035,7 @@ hifn_crypto(sc, cmd, crp) struct mbuf *m, *top, **mp; totlen = cmd->src_map->dm_mapsize; - if (cmd->src_m->m_flags & M_PKTHDR) { + if (cmd->srcu.src_m->m_flags & M_PKTHDR) { len = MHLEN; MGETHDR(m, M_DONTWAIT, MT_DATA); } else { @@ -1045,7 +1045,7 @@ hifn_crypto(sc, cmd, crp) if (m == NULL) goto err_srcmap; if (len == MHLEN) - M_DUP_PKTHDR(m, cmd->src_m); + M_DUP_PKTHDR(m, cmd->srcu.src_m); if (totlen >= MINCLSIZE) { MCLGET(m, M_DONTWAIT); if (m->m_flags & M_EXT) @@ -1074,7 +1074,7 @@ hifn_crypto(sc, cmd, crp) *mp = m; mp = &m->m_next; } - cmd->dst_m = top; + cmd->dstu.dst_m = top; } } @@ -1085,11 +1085,11 @@ hifn_crypto(sc, cmd, crp) goto err_srcmap; if (crp->crp_flags & CRYPTO_F_IMBUF) { if (bus_dmamap_load_mbuf(sc->sc_dmat, cmd->dst_map, - cmd->dst_m, BUS_DMA_NOWAIT)) + cmd->dstu.dst_m, BUS_DMA_NOWAIT)) goto err_dstmap1; } else if (crp->crp_flags & CRYPTO_F_IOV) { if (bus_dmamap_load_uio(sc->sc_dmat, cmd->dst_map, - cmd->dst_io, BUS_DMA_NOWAIT)) + cmd->dstu.dst_io, BUS_DMA_NOWAIT)) goto err_dstmap1; } } @@ -1427,11 +1427,11 @@ hifn_process(crp) bzero(cmd, sizeof(struct hifn_command)); if (crp->crp_flags & CRYPTO_F_IMBUF) { - cmd->src_m = (struct mbuf *)crp->crp_buf; - cmd->dst_m = (struct mbuf *)crp->crp_buf; + cmd->srcu.src_m = (struct mbuf *)crp->crp_buf; + cmd->dstu.dst_m = (struct mbuf *)crp->crp_buf; } else if (crp->crp_flags & CRYPTO_F_IOV) { - cmd->src_io = (struct uio *)crp->crp_buf; - cmd->dst_io = (struct uio *)crp->crp_buf; + cmd->srcu.src_io = (struct uio *)crp->crp_buf; + cmd->dstu.dst_io = (struct uio *)crp->crp_buf; } else { err = EINVAL; goto errout; /* XXX we don't handle contiguous buffers! */ @@ -1497,11 +1497,11 @@ hifn_process(crp) if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback(cmd->src_m, + m_copyback(cmd->srcu.src_m, enccrd->crd_inject, HIFN_IV_LENGTH, cmd->iv); else if (crp->crp_flags & CRYPTO_F_IOV) - cuio_copyback(cmd->src_io, + cuio_copyback(cmd->srcu.src_io, enccrd->crd_inject, HIFN_IV_LENGTH, cmd->iv); } @@ -1509,10 +1509,10 @@ hifn_process(crp) if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) bcopy(enccrd->crd_iv, cmd->iv, HIFN_IV_LENGTH); else if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copydata(cmd->src_m, enccrd->crd_inject, + m_copydata(cmd->srcu.src_m, enccrd->crd_inject, HIFN_IV_LENGTH, cmd->iv); else if (crp->crp_flags & CRYPTO_F_IOV) - cuio_copydata(cmd->src_io, enccrd->crd_inject, + cuio_copydata(cmd->srcu.src_io, enccrd->crd_inject, HIFN_IV_LENGTH, cmd->iv); } @@ -1554,7 +1554,7 @@ hifn_process(crp) if (sc->sc_sessions[session].hs_flags == 1) sc->sc_sessions[session].hs_flags = 2; - cmd->private_data = (u_long)crp; + cmd->crp = crp; cmd->session_num = session; cmd->softc = sc; @@ -1582,7 +1582,7 @@ hifn_callback(sc, cmd, macbuf) u_int8_t *macbuf; { struct hifn_dma *dma = sc->sc_dma; - struct cryptop *crp = (struct cryptop *)cmd->private_data; + struct cryptop *crp = cmd->crp; struct cryptodesc *crd; struct mbuf *m; int totlen; @@ -1591,11 +1591,11 @@ hifn_callback(sc, cmd, macbuf) 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 (cmd->srcu.src_m != cmd->dstu.dst_m) { + m_freem(cmd->srcu.src_m); + crp->crp_buf = (caddr_t)cmd->dstu.dst_m; } - if ((m = cmd->dst_m) != NULL) { + if ((m = cmd->dstu.dst_m) != NULL) { totlen = cmd->src_map->dm_mapsize; hifnstats.hst_obytes += totlen; while (m) { diff --git a/sys/dev/pci/hifn7751var.h b/sys/dev/pci/hifn7751var.h index d53263a276c..ad1fd7a3fcc 100644 --- a/sys/dev/pci/hifn7751var.h +++ b/sys/dev/pci/hifn7751var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751var.h,v 1.23 2001/06/23 00:25:38 jason Exp $ */ +/* $OpenBSD: hifn7751var.h,v 1.24 2001/06/24 17:43:29 jason Exp $ */ /* * Invertex AEON / Hi/fn 7751 driver @@ -158,19 +158,6 @@ struct hifn_softc { * * HIFN_CRYPT_NEW_KEY, HIFN_MAC_NEW_KEY * - * result_flags - * ------------ - * result_flags is a bitwise "or" of result values. The result_flags - * values should not be considered valid until: - * - * callback routine NULL: hifn_crypto() returns - * callback routine set: callback routine called - * - * Right now there is only one result flag: HIFN_MAC_BAD - * It's bit is set on decode operations using authentication when a - * hash result does not match the input hash value. - * The HIFN_MAC_OK(r) macro can be used to help inspect this flag. - * * session_num * ----------- * A number between 0 and 2048 (for DRAM models) or a number between @@ -203,60 +190,30 @@ struct hifn_softc { * than the auth_header_skip (to skip over the ESP header). * *** Value ignored if cryptography not used *** * - * source_length - * ------------- - * Length of input data including all skipped headers. On decode - * operations using authentication, the length must also include the - * the appended MAC hash (12, 16, or 20 bytes depending on algorithm - * and truncation settings). - * - * If encryption is used, the encryption payload must be a non-zero - * multiple of 8. On encode operations, the encryption payload size - * is (source_length - crypt_header_skip - (MAC hash size)). On - * decode operations, the encryption payload is - * (source_length - crypt_header_skip). - * - * dest_length - * ----------- - * Length of the dest buffer. It must be at least as large as the - * source buffer when authentication is not used. When authentication - * is used on an encode operation, it must be at least as long as the - * source length plus an extra 12, 16, or 20 bytes to hold the MAC - * value (length of mac value varies with algorithm used). When - * authentication is used on decode operations, it must be at least - * as long as the source buffer minus 12, 16, or 20 bytes for the MAC - * value which is not included in the dest data. Unlike source_length, - * the dest_length does not have to be exact, values larger than required - * are fine. - * - * private_data - * ------------ - * An unsigned long quantity (i.e. large enough to hold a pointer), that - * can be used by the callback routine if desired. */ -typedef struct hifn_command { - volatile u_int result_flags; - - u_short session_num; +struct hifn_command { + u_int16_t session_num; u_int16_t base_masks, cry_masks, mac_masks; + u_int8_t iv[HIFN_IV_LENGTH], *ck, mac[HIFN_MAC_KEY_LENGTH]; - u_char iv[HIFN_IV_LENGTH], *ck, mac[HIFN_MAC_KEY_LENGTH]; - - struct mbuf *src_m; - struct uio *src_io; + union { + struct mbuf *src_m; + struct uio *src_io; + } srcu; bus_dmamap_t src_map; - struct mbuf *dst_m; - struct uio *dst_io; + union { + struct mbuf *dst_m; + struct uio *dst_io; + } dstu; bus_dmamap_t dst_map; u_int16_t crypt_header_skip, mac_header_skip; u_int32_t crypt_process_len, mac_process_len; - u_long private_data; struct hifn_softc *softc; struct cryptop *crp; -} hifn_command_t; +}; /* * Return values for hifn_crypto() @@ -265,12 +222,6 @@ typedef struct hifn_command { #define HIFN_CRYPTO_BAD_INPUT (-1) #define HIFN_CRYPTO_RINGS_FULL (-2) -/* - * Defines for the "result_flags" parameter of hifn_command_t. - */ -#define HIFN_MAC_BAD 1 -#define HIFN_MAC_OK(r) (!((r) & HIFN_MAC_BAD)) - #ifdef _KERNEL /************************************************************************** -- cgit v1.2.3