summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2001-08-22 16:34:48 +0000
committerJason Wright <jason@cvs.openbsd.org>2001-08-22 16:34:48 +0000
commit529d5c12e2ac18c2871eeaea7390212056d15792 (patch)
tree6693f2d25f0b4e82a49753b75f7e8d1b8beea5eb /sys/dev
parent5d869c442f00dd7b31686edec3b386aed3d54376 (diff)
rename hs_flags -> hs_state and use #defines for the state names.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/hifn7751.c21
-rw-r--r--sys/dev/pci/hifn7751var.h9
2 files changed, 18 insertions, 12 deletions
diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c
index b9e68f0107c..0fffdaebd90 100644
--- a/sys/dev/pci/hifn7751.c
+++ b/sys/dev/pci/hifn7751.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hifn7751.c,v 1.96 2001/08/22 16:11:31 jason Exp $ */
+/* $OpenBSD: hifn7751.c,v 1.97 2001/08/22 16:34:47 jason Exp $ */
/*
* Invertex AEON / Hifn 7751 driver
@@ -1535,7 +1535,7 @@ hifn_newsession(sidp, cri)
return (EINVAL);
for (i = 0; i < sc->sc_maxses; i++)
- if (sc->sc_sessions[i].hs_flags == 0)
+ if (sc->sc_sessions[i].hs_state == HS_STATE_FREE)
break;
if (i == sc->sc_maxses)
return (ENOMEM);
@@ -1566,7 +1566,7 @@ hifn_newsession(sidp, cri)
return (EINVAL);
*sidp = HIFN_SID(sc->sc_dv.dv_unit, i);
- sc->sc_sessions[i].hs_flags = 1;
+ sc->sc_sessions[i].hs_state = HS_STATE_USED;
return (0);
}
@@ -1701,7 +1701,8 @@ hifn_process(crp)
cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_RC4;
if ((enccrd->crd_flags & CRD_F_ENCRYPT)
!= sc->sc_sessions[session].hs_prev_op)
- sc->sc_sessions[session].hs_flags=1;
+ sc->sc_sessions[session].hs_state =
+ HS_STATE_USED;
break;
case CRYPTO_DES_CBC:
cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_DES |
@@ -1755,7 +1756,7 @@ hifn_process(crp)
cmd->ck = enccrd->crd_key;
cmd->cklen = enccrd->crd_klen >> 3;
- if (sc->sc_sessions[session].hs_flags == 1)
+ if (sc->sc_sessions[session].hs_state == HS_STATE_USED)
cmd->cry_masks |= HIFN_CRYPT_CMD_NEW_KEY;
}
@@ -1771,7 +1772,7 @@ hifn_process(crp)
else
cmd->mac_masks |= HIFN_MAC_CMD_ALG_SHA1;
- if (sc->sc_sessions[session].hs_flags == 1) {
+ if (sc->sc_sessions[session].hs_state == HS_STATE_USED) {
cmd->mac_masks |= HIFN_MAC_CMD_NEW_KEY;
bcopy(maccrd->crd_key, cmd->mac, maccrd->crd_klen >> 3);
bzero(cmd->mac + (maccrd->crd_klen >> 3),
@@ -1787,8 +1788,8 @@ hifn_process(crp)
if (!err) {
sc->sc_sessions[session].hs_prev_op=enccrd->crd_flags
& CRD_F_ENCRYPT;
- if (sc->sc_sessions[session].hs_flags == 1)
- sc->sc_sessions[session].hs_flags = 2;
+ if (sc->sc_sessions[session].hs_state == HS_STATE_USED)
+ sc->sc_sessions[session].hs_state = HS_STATE_KEY;
return 0;
}
@@ -1868,8 +1869,8 @@ hifn_abort(sc)
/* Force upload of key next time */
for (i = 0; i < sc->sc_maxses; i++)
- if (sc->sc_sessions[i].hs_flags == 2)
- sc->sc_sessions[i].hs_flags = 1;
+ if (sc->sc_sessions[i].hs_state == HS_STATE_KEY)
+ sc->sc_sessions[i].hs_state = HS_STATE_USED;
hifn_reset_board(sc, 1);
hifn_init_dma(sc);
diff --git a/sys/dev/pci/hifn7751var.h b/sys/dev/pci/hifn7751var.h
index 264b81d4a6b..c1e718b2e78 100644
--- a/sys/dev/pci/hifn7751var.h
+++ b/sys/dev/pci/hifn7751var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hifn7751var.h,v 1.33 2001/08/17 17:37:12 ben Exp $ */
+/* $OpenBSD: hifn7751var.h,v 1.34 2001/08/22 16:34:47 jason Exp $ */
/*
* Invertex AEON / Hifn 7751 driver
@@ -97,11 +97,16 @@ struct hifn_dma {
};
struct hifn_session {
- int hs_flags;
+ int hs_state;
int hs_prev_op; /* XXX collapse into hs_flags? */
u_int8_t hs_iv[HIFN_IV_LENGTH];
};
+/* We use a state machine to on sessions */
+#define HS_STATE_FREE 0 /* unused session entry */
+#define HS_STATE_USED 1 /* allocated, but key not on card */
+#define HS_STATE_KEY 2 /* allocated and key is on card */
+
/*
* Holds data specific to a single HIFN board.
*/