#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_ath.h"
#include "opt_inet.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/errno.h>
#if defined(__DragonFly__)
#else
#include <machine/bus.h>
#include <machine/resource.h>
#endif
#include <sys/bus.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_media.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <netproto/802_11/ieee80211_var.h>
#include <net/bpf.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
#include <dev/netif/ath/ath/if_athvar.h>
#include <dev/netif/ath/ath/if_athdfs.h>
#include <dev/netif/ath/ath_hal/ah_desc.h>
int
ath_dfs_attach(struct ath_softc *sc)
{
return (1);
}
int
ath_dfs_detach(struct ath_softc *sc)
{
return (1);
}
int
ath_dfs_radar_enable(struct ath_softc *sc, struct ieee80211_channel *chan)
{
#if 0
HAL_PHYERR_PARAM pe;
if (ath_hal_getcapability(sc->sc_ah,
HAL_CAP_PHYDIAG, 0, NULL) != HAL_OK)
return (0);
if (! IEEE80211_IS_CHAN_DFS(chan))
return (0);
memset(&pe, '\0', sizeof(pe));
if (! ath_hal_getdfsdefaultthresh(sc->sc_ah, &pe))
return (0);
sc->sc_dodfs = 1;
pe.pe_enabled = 1;
if (IEEE80211_IS_CHAN_HT40(chan))
pe.pe_extchannel = 1;
else
pe.pe_extchannel = 0;
ath_hal_enabledfs(sc->sc_ah, &pe);
(void) ath_hal_setcapability(sc->sc_ah, HAL_CAP_DIVERSITY, 2, 0, NULL);
return (1);
#else
return (0);
#endif
}
int
ath_dfs_radar_disable(struct ath_softc *sc)
{
#if 0
HAL_PHYERR_PARAM pe;
(void) ath_hal_getdfsthresh(sc->sc_ah, &pe);
pe.pe_enabled = 0;
(void) ath_hal_enabledfs(sc->sc_ah, &pe);
return (0);
#else
return (0);
#endif
}
void
ath_dfs_process_phy_err(struct ath_softc *sc, struct mbuf *m,
uint64_t tsf, struct ath_rx_status *rxstat)
{
}
int
ath_dfs_process_radar_event(struct ath_softc *sc,
struct ieee80211_channel *chan)
{
return (0);
}
int
ath_dfs_tasklet_needed(struct ath_softc *sc, struct ieee80211_channel *chan)
{
return (0);
}
int
ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad)
{
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) {
indata = kmalloc(insize, M_TEMP, M_INTWAIT);
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) {
outdata = kmalloc(outsize, M_TEMP, M_INTWAIT);
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)
kfree(indata, M_TEMP);
if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL)
kfree(outdata, M_TEMP);
return (error);
}
int
ath_dfs_get_thresholds(struct ath_softc *sc, HAL_PHYERR_PARAM *param)
{
ath_hal_getdfsthresh(sc->sc_ah, param);
return (1);
}
#if defined(__DragonFly__)
static int
null_dfs_modevent(module_t mod, int type, void *unused)
{
int error;
wlan_serialize_enter();
switch (type) {
case MOD_LOAD:
if (bootverbose) {
kprintf("ath_dfs: WTF module\n");
}
error = 0;
break;
case MOD_UNLOAD:
error = 0;
break;
default:
error = EINVAL;
break;
}
wlan_serialize_exit();
return error;
}
static moduledata_t null_dfs_mod = {
"ath_dfs",
null_dfs_modevent,
0
};
DECLARE_MODULE(ath_dfs, null_dfs_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
MODULE_VERSION(ath_dfs, 1);
#endif