summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2011-07-22 09:39:49 +0000
committeradrian <adrian@FreeBSD.org>2011-07-22 09:39:49 +0000
commit76a53fdd2f26c361bb6d113e5a9973d914d26562 (patch)
treefb83fc825a0cb7dfca2ab77cbc62cb85df8a40c5
parent1945b3141df1217dc03e9ba4b48651cf9a39ee83 (diff)
downloadFreeBSD-src-76a53fdd2f26c361bb6d113e5a9973d914d26562.zip
FreeBSD-src-76a53fdd2f26c361bb6d113e5a9973d914d26562.tar.gz
Implement a basic radar parameter API in the dfs_null module.
Since no actual radar data is ever handled, this won't do anything. It's mostly here as a reference for those who wish to experiment with radar detection. Approved by: re (kib)
-rw-r--r--sys/dev/ath/ath_dfs/null/dfs_null.c74
1 files changed, 71 insertions, 3 deletions
diff --git a/sys/dev/ath/ath_dfs/null/dfs_null.c b/sys/dev/ath/ath_dfs/null/dfs_null.c
index 2f050a4..b5c85bf 100644
--- a/sys/dev/ath/ath_dfs/null/dfs_null.c
+++ b/sys/dev/ath/ath_dfs/null/dfs_null.c
@@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#ifdef INET
-#include <netinet/in.h>
+#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
@@ -141,12 +141,80 @@ ath_dfs_tasklet_needed(struct ath_softc *sc, struct ieee80211_channel *chan)
}
/*
- * Handle ioctl requests from the diagnostic interface
+ * Handle ioctl requests from the diagnostic interface.
+ *
+ * The initial part of this code resembles ath_ioctl_diag();
+ * it's likely a good idea to reduce duplication between
+ * these two routines.
*/
int
ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad)
{
- return 1;
+ unsigned int id = ad->ad_id & ATH_DIAG_ID;
+ void *indata = NULL;
+ void *outdata = NULL;
+ u_int32_t insize = ad->ad_in_size;
+ u_int32_t outsize = ad->ad_out_size;
+ int error = 0;
+ HAL_PHYERR_PARAM peout;
+ HAL_PHYERR_PARAM *pe;
+
+ if (ad->ad_id & ATH_DIAG_IN) {
+ /*
+ * Copy in data.
+ */
+ indata = malloc(insize, M_TEMP, M_NOWAIT);
+ if (indata == NULL) {
+ error = ENOMEM;
+ goto bad;
+ }
+ error = copyin(ad->ad_in_data, indata, insize);
+ if (error)
+ goto bad;
+ }
+ if (ad->ad_id & ATH_DIAG_DYN) {
+ /*
+ * Allocate a buffer for the results (otherwise the HAL
+ * returns a pointer to a buffer where we can read the
+ * results). Note that we depend on the HAL leaving this
+ * pointer for us to use below in reclaiming the buffer;
+ * may want to be more defensive.
+ */
+ outdata = malloc(outsize, M_TEMP, M_NOWAIT);
+ if (outdata == NULL) {
+ error = ENOMEM;
+ goto bad;
+ }
+ }
+ switch (id) {
+ case DFS_SET_THRESH:
+ if (insize < sizeof(HAL_PHYERR_PARAM)) {
+ error = -EINVAL;
+ break;
+ }
+ pe = (HAL_PHYERR_PARAM *) indata;
+ ath_hal_enabledfs(sc->sc_ah, pe);
+ break;
+ case DFS_GET_THRESH:
+ memset(&peout, 0, sizeof(peout));
+ outsize = sizeof(HAL_PHYERR_PARAM);
+ ath_hal_getdfsthresh(sc->sc_ah, &peout);
+ pe = (HAL_PHYERR_PARAM *) outdata;
+ memcpy(pe, &peout, sizeof(*pe));
+ break;
+ default:
+ error = -EINVAL;
+ }
+ if (outsize < ad->ad_out_size)
+ ad->ad_out_size = outsize;
+ if (outdata && copyout(outdata, ad->ad_out_data, ad->ad_out_size))
+ error = -EFAULT;
+bad:
+ if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL)
+ free(indata, M_TEMP);
+ if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL)
+ free(outdata, M_TEMP);
+ return error;
}
/*
OpenPOWER on IntegriCloud