From owner-svn-src-head@FreeBSD.ORG Fri Jul 22 09:39:50 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28BF41065675; Fri, 22 Jul 2011 09:39:50 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E1AA8FC16; Fri, 22 Jul 2011 09:39:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6M9dnrY008519; Fri, 22 Jul 2011 09:39:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6M9dnsR008517; Fri, 22 Jul 2011 09:39:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201107220939.p6M9dnsR008517@svn.freebsd.org> From: Adrian Chadd Date: Fri, 22 Jul 2011 09:39:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224267 - head/sys/dev/ath/ath_dfs/null X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 09:39:50 -0000 Author: adrian Date: Fri Jul 22 09:39:49 2011 New Revision: 224267 URL: http://svn.freebsd.org/changeset/base/224267 Log: 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) Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c ============================================================================== --- head/sys/dev/ath/ath_dfs/null/dfs_null.c Fri Jul 22 09:34:31 2011 (r224266) +++ head/sys/dev/ath/ath_dfs/null/dfs_null.c Fri Jul 22 09:39:49 2011 (r224267) @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef INET -#include +#include #include #endif @@ -141,12 +141,80 @@ ath_dfs_tasklet_needed(struct ath_softc } /* - * 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; } /*