freebsd-skq/sys/net80211/ieee80211_tdma.h

106 lines
4.0 KiB
C
Raw Normal View History

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
* Copyright (c) 2007-2009 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _NET80211_IEEE80211_TDMA_H_
#define _NET80211_IEEE80211_TDMA_H_
/*
* TDMA-mode implementation definitions.
*/
#define TDMA_SUBTYPE_PARAM 0x01
#define TDMA_VERSION_V2 2
#define TDMA_VERSION TDMA_VERSION_V2
/* NB: we only support 2 right now but protocol handles up to 8 */
#define TDMA_MAXSLOTS 2 /* max slots/sta's */
#define TDMA_PARAM_LEN_V2 sizeof(struct ieee80211_tdma_param)
/*
* TDMA information element.
*/
struct ieee80211_tdma_param {
u_int8_t tdma_id; /* IEEE80211_ELEMID_VENDOR */
u_int8_t tdma_len;
u_int8_t tdma_oui[3]; /* TDMA_OUI */
u_int8_t tdma_type; /* TDMA_OUI_TYPE */
u_int8_t tdma_subtype; /* TDMA_SUBTYPE_PARAM */
u_int8_t tdma_version; /* spec revision */
u_int8_t tdma_slot; /* station slot # [0..7] */
u_int8_t tdma_slotcnt; /* bss slot count [1..8] */
u_int16_t tdma_slotlen; /* bss slot len (100us) */
u_int8_t tdma_bintval; /* beacon interval (superframes) */
u_int8_t tdma_inuse[1]; /* slot occupancy map */
u_int8_t tdma_pad[2];
u_int8_t tdma_tstamp[8]; /* timestamp from last beacon */
} __packed;
#ifdef _KERNEL
/*
* Implementation state.
*/
struct ieee80211_tdma_state {
u_int tdma_slotlen; /* bss slot length (us) */
uint8_t tdma_version; /* protocol version to use */
uint8_t tdma_slotcnt; /* bss slot count */
uint8_t tdma_bintval; /* beacon interval (slots) */
uint8_t tdma_slot; /* station slot # */
uint8_t tdma_inuse[1]; /* mask of slots in use */
uint8_t tdma_active[1]; /* mask of active slots */
int tdma_count; /* active/inuse countdown */
void *tdma_peer; /* peer station cookie */
struct timeval tdma_lastprint; /* time of last rate-limited printf */
int tdma_fails; /* fail count for rate-limiting */
/* parent method pointers */
int (*tdma_newstate)(struct ieee80211vap *, enum ieee80211_state,
int arg);
void (*tdma_recv_mgmt)(struct ieee80211_node *,
Begin plumbing ieee80211_rx_stats through the receive path. Smart NICs with firmware (eg wpi, iwn, the new atheros parts, the intel 7260 series, etc) support doing a lot of things in firmware. This includes but isn't limited to things like scanning, sending probe requests and receiving probe responses. However, net80211 doesn't know about any of this - it still drives the whole scan/probe infrastructure itself. In order to move towards suppoting smart NICs, the receive path needs to know about the channel/details for each received packet. In at least the iwn and 7260 firmware (and I believe wpi, but I haven't tried it yet) it will do the scanning, power-save and off-channel buffering for you - all you need to do is handle receiving beacons and probe responses on channels that aren't what you're currently on. However the whole receive path is peppered with ic->ic_curchan and manual scan/powersave handling. The beacon parsing code also checks ic->ic_curchan to determine if the received beacon is on the correct channel or not.[1] So: * add freq/ieee values to ieee80211_rx_stats; * change ieee80211_parse_beacon() to accept the 'current' channel as an argument; * modify the iv_input() and iv_recv_mgmt() methods to include the rx_stats; * add a new method - ieee80211_lookup_channel_rxstats() - that looks up a channel based on the contents of ieee80211_rx_stats; * if it exists, use it in the mgmt path to switch the current channel (which still defaults to ic->ic_curchan) over to something determined by rx_stats. This is enough to kick-start scan offload support in the Intel 7260 driver that Rui/I are working on. It also is a good start for scan offload support for a handful of existing NICs (wpi, iwn, some USB parts) and it'll very likely dramatically improve stability/performance there. It's not the whole thing - notably, we don't need to do powersave, we should not scan all channels, and we should leave probe request sending to the firmware and not do it ourselves. But, this allows for continued development on the above features whilst actually having a somewhat working NIC. TODO: * Finish tidying up how the net80211 input path works. Right now ieee80211_input / ieee80211_input_all act as the top-level that everything feeds into; it should change so the MIMO input routines are those and the legacy routines are phased out. * The band selection should be done by the driver, not by the net80211 layer. * ieee80211_lookup_channel_rxstats() only determines 11b or 11g channels for now - this is enough for scanning, but not 100% true in all cases. If we ever need to handle off-channel scan support for things like static-40MHz or static-80MHz, or turbo-G, or half/quarter rates, then we should extend this. [1] This is a side effect of frequency-hopping and CCK modes - you can receive beacons when you think you're on a different channel. In particular, CCK (which is used by the low 11b rates, eg beacons!) is decodable from adjacent channels - just at a low SNR. FH is a side effect of having the hardware/firmware do the frequency hopping - it may pick up beacons transmitted from other FH networks that are in a different phase of hopping frequencies.
2015-05-25 16:37:41 +00:00
struct mbuf *, int,
const struct ieee80211_rx_stats *rxs, int, int);
void (*tdma_opdetach)(struct ieee80211vap *);
};
#define TDMA_UPDATE_SLOT 0x0001 /* tdma_slot changed */
#define TDMA_UPDATE_SLOTCNT 0x0002 /* tdma_slotcnt changed */
#define TDMA_UPDATE_SLOTLEN 0x0004 /* tdma_slotlen changed */
#define TDMA_UPDATE_BINTVAL 0x0008 /* tdma_bintval changed */
void ieee80211_tdma_vattach(struct ieee80211vap *);
int ieee80211_tdma_getslot(struct ieee80211vap *vap);
void ieee80211_parse_tdma(struct ieee80211_node *ni, const uint8_t *ie);
uint8_t *ieee80211_add_tdma(uint8_t *frm, struct ieee80211vap *vap);
struct ieee80211_beacon_offsets;
void ieee80211_tdma_update_beacon(struct ieee80211vap *vap,
struct ieee80211_beacon_offsets *bo);
#endif /* _KERNEL */
#endif /* !_NET80211_IEEE80211_TDMA_H_ */