From 036478ff19f5df6938f2fd985d960eb66b5231ae Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Fri, 29 Aug 2008 10:05:01 +0000 Subject: add a HAL function to force disabling the hardware crypto engine --- sys/dev/ic/ar5210.c | 25 ++++++++++++++++++++++++- sys/dev/ic/ar5211.c | 25 ++++++++++++++++++++++++- sys/dev/ic/ar5212.c | 25 ++++++++++++++++++++++++- sys/dev/ic/ar5xxx.h | 3 ++- 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c index ee600939c29..2d8270a5176 100644 --- a/sys/dev/ic/ar5210.c +++ b/sys/dev/ic/ar5210.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5210.c,v 1.42 2008/08/27 09:05:03 damien Exp $ */ +/* $OpenBSD: ar5210.c,v 1.43 2008/08/29 10:05:00 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -132,6 +132,7 @@ ar5k_ar5210_fill(struct ath_hal *hal) AR5K_HAL_FUNCTION(hal, ar5210, is_key_valid); AR5K_HAL_FUNCTION(hal, ar5210, set_key); AR5K_HAL_FUNCTION(hal, ar5210, set_key_lladdr); + AR5K_HAL_FUNCTION(hal, ar5210, softcrypto); /* * Power management functions @@ -1915,6 +1916,28 @@ ar5k_ar5210_set_key_lladdr(struct ath_hal *hal, u_int16_t entry, return (AH_TRUE); } +HAL_BOOL +ar5k_ar5210_softcrypto(struct ath_hal *hal, HAL_BOOL enable) +{ + u_int32_t bits; + int i; + + bits = AR5K_AR5210_DIAG_SW_DIS_ENC | AR5K_AR5210_DIAG_SW_DIS_DEC; + if (enable == AH_TRUE) { + /* Disable the hardware crypto engine */ + AR5K_REG_ENABLE_BITS(AR5K_AR5210_DIAG_SW, bits); + } else { + /* Enable the hardware crypto engine */ + AR5K_REG_DISABLE_BITS(AR5K_AR5210_DIAG_SW, bits); + } + + /* Reset the key cache */ + for (i = 0; i < AR5K_AR5210_KEYTABLE_SIZE; i++) + ar5k_ar5210_reset_key(hal, i); + + return (AH_TRUE); +} + /* * Power management functions */ diff --git a/sys/dev/ic/ar5211.c b/sys/dev/ic/ar5211.c index e35b829cd5e..def07374ad0 100644 --- a/sys/dev/ic/ar5211.c +++ b/sys/dev/ic/ar5211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5211.c,v 1.38 2008/08/27 09:05:03 damien Exp $ */ +/* $OpenBSD: ar5211.c,v 1.39 2008/08/29 10:05:00 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -136,6 +136,7 @@ ar5k_ar5211_fill(struct ath_hal *hal) AR5K_HAL_FUNCTION(hal, ar5211, is_key_valid); AR5K_HAL_FUNCTION(hal, ar5211, set_key); AR5K_HAL_FUNCTION(hal, ar5211, set_key_lladdr); + AR5K_HAL_FUNCTION(hal, ar5211, softcrypto); /* * Power management functions @@ -2020,6 +2021,28 @@ ar5k_ar5211_set_key_lladdr(struct ath_hal *hal, u_int16_t entry, return (AH_TRUE); } +HAL_BOOL +ar5k_ar5211_softcrypto(struct ath_hal *hal, HAL_BOOL enable) +{ + u_int32_t bits; + int i; + + bits = AR5K_AR5211_DIAG_SW_DIS_ENC | AR5K_AR5211_DIAG_SW_DIS_DEC; + if (enable == AH_TRUE) { + /* Disable the hardware crypto engine */ + AR5K_REG_ENABLE_BITS(AR5K_AR5211_DIAG_SW, bits); + } else { + /* Enable the hardware crypto engine */ + AR5K_REG_DISABLE_BITS(AR5K_AR5211_DIAG_SW, bits); + } + + /* Reset the key cache */ + for (i = 0; i < AR5K_AR5211_KEYTABLE_SIZE; i++) + ar5k_ar5211_reset_key(hal, i); + + return (AH_TRUE); +} + /* * Power management functions */ diff --git a/sys/dev/ic/ar5212.c b/sys/dev/ic/ar5212.c index 5cf3bf5b666..1affee9d453 100644 --- a/sys/dev/ic/ar5212.c +++ b/sys/dev/ic/ar5212.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5212.c,v 1.46 2008/08/27 09:05:03 damien Exp $ */ +/* $OpenBSD: ar5212.c,v 1.47 2008/08/29 10:05:00 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -139,6 +139,7 @@ ar5k_ar5212_fill(struct ath_hal *hal) AR5K_HAL_FUNCTION(hal, ar5212, is_key_valid); AR5K_HAL_FUNCTION(hal, ar5212, set_key); AR5K_HAL_FUNCTION(hal, ar5212, set_key_lladdr); + AR5K_HAL_FUNCTION(hal, ar5212, softcrypto); /* * Power management functions @@ -2392,6 +2393,28 @@ ar5k_ar5212_set_key_lladdr(struct ath_hal *hal, u_int16_t entry, return (AH_TRUE); } +HAL_BOOL +ar5k_ar5212_softcrypto(struct ath_hal *hal, HAL_BOOL enable) +{ + u_int32_t bits; + int i; + + bits = AR5K_AR5212_DIAG_SW_DIS_ENC | AR5K_AR5212_DIAG_SW_DIS_DEC; + if (enable == AH_TRUE) { + /* Disable the hardware crypto engine */ + AR5K_REG_ENABLE_BITS(AR5K_AR5212_DIAG_SW, bits); + } else { + /* Enable the hardware crypto engine */ + AR5K_REG_DISABLE_BITS(AR5K_AR5212_DIAG_SW, bits); + } + + /* Reset the key cache */ + for (i = 0; i < AR5K_AR5212_KEYTABLE_SIZE; i++) + ar5k_ar5212_reset_key(hal, i); + + return (AH_TRUE); +} + /* * Power management functions */ diff --git a/sys/dev/ic/ar5xxx.h b/sys/dev/ic/ar5xxx.h index 9ddfe679253..348d64a7f05 100644 --- a/sys/dev/ic/ar5xxx.h +++ b/sys/dev/ic/ar5xxx.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5xxx.h,v 1.44 2008/07/30 07:15:39 reyk Exp $ */ +/* $OpenBSD: ar5xxx.h,v 1.45 2008/08/29 10:05:00 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -1045,6 +1045,7 @@ struct ath_desc { const HAL_KEYVAL *, const u_int8_t *, int); \ _t HAL_BOOL (_a _n##_set_key_lladdr)(struct ath_hal*, \ u_int16_t, const u_int8_t *); \ + _t HAL_BOOL (_a _n##_softcrypto)(struct ath_hal *, HAL_BOOL); \ /* Power Management Functions */ \ _t HAL_BOOL (_a _n##_set_power)(struct ath_hal*, \ HAL_POWER_MODE mode, \ -- cgit v1.2.3