Skip to content

Commit

Permalink
Replay r286410. Change KPI of how device drivers that provide wireless
Browse files Browse the repository at this point in the history
connectivity interact with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
  the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
  driver about any changes: number of wlan(4) interfaces, number of them
  in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
  driver experiences errors and can not attribute them to any specific
  interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
  now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.

Reviewed by:	adrian
Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
  • Loading branch information
glebius committed Aug 27, 2015
1 parent 433b167 commit 619aca8
Show file tree
Hide file tree
Showing 87 changed files with 4,016 additions and 6,201 deletions.
86 changes: 86 additions & 0 deletions etc/network.subr
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,89 @@ ifscript_down()
fi
}

# wlan_up
# Create IEEE802.11 interfaces.
#
wlan_up()
{
local _list _iflist parent child_wlans child create_args debug_flags
_list=
_iflist=$*

# Parse wlans_$parent="$child ..."
for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do
child_wlans=`get_if_var $parent wlans_IF`
for child in ${child_wlans}; do
create_args="wlandev $parent `get_if_var $child create_args_IF`"
debug_flags="`get_if_var $child wlandebug_IF`"
case $_iflist in
""|$child|$child\ *|*\ $child\ *|*\ $child) ;;
*) continue ;;
esac
# Skip if ${child} already exists.
if ${IFCONFIG_CMD} $child > /dev/null 2>&1; then
continue
fi
if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then
${IFCONFIG_CMD} $child create ${create_args} && cfg=0
if [ $? -eq 0 ]; then
_list="$_list $child"
fi
if [ -n "${debug_flags}" ]; then
wlandebug -i $child ${debug_flags}
fi
else
i=`${IFCONFIG_CMD} wlan create ${create_args}`
# XXXGL: wlandebug should accept any name
if [ -n "${debug_flags}" ]; then
wlandebug -i $i ${debug_flags}
fi
${IFCONFIG_CMD} $i name $child && cfg=0
if [ $? -eq 0 ]; then
_list="$_list $child"
fi
fi
done
done
if [ -n "${_list# }" ]; then
echo "Created wlan(4) interfaces: ${_list# }."
fi
debug "Created wlan(4)s: ${_list# }"
}

# wlan_down
# Destroy IEEE802.11 interfaces.
#
wlan_down()
{
local _list _iflist parent child_wlans child
_list=
_iflist=$*

# Parse wlans_$parent="$child ..."
for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do
child_wlans=`get_if_var $parent wlans_IF`
for child in ${child_wlans}; do
case $_iflist in
""|$child|$child\ *|*\ $child\ *|*\ $child) ;;
*) continue ;;
esac
# Skip if ${child} doesn't exists.
if ! ${IFCONFIG_CMD} $child > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} -n ${child} destroy
if [ $? -eq 0 ]; then
_list="$_list $child"
fi
done
done
if [ -n "${_list# }" ]; then
echo "Destroyed wlan(4) interfaces: ${_list# }."
fi
debug "Destroyed wlan(4)s: ${_list# }"
}

# clone_up
# Create cloneable interfaces.
#
Expand Down Expand Up @@ -1398,6 +1481,9 @@ clone_down()
# Create and configure child interfaces. Return 0 if child
# interfaces are created.
#
# XXXGL: the wlan code in this functions is superseded by wlan_up(),
# and will go away soon.
#
childif_create()
{
local cfg child child_vlans child_wlans create_args debug_flags ifn i
Expand Down
12 changes: 12 additions & 0 deletions etc/rc.d/netif
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ name="netif"
rcvar="${name}_enable"
start_cmd="netif_start"
stop_cmd="netif_stop"
wlanup_cmd="wlan_up"
wlandown_cmd="wlan_down"
cloneup_cmd="clone_up"
clonedown_cmd="clone_down"
clear_cmd="doclear"
Expand Down Expand Up @@ -65,6 +67,9 @@ netif_start()
trap : 2
fi

# Create IEEE802.11 interface
wlan_up $cmdifn

# Create cloned interfaces
clone_up $cmdifn

Expand All @@ -91,12 +96,14 @@ netif_start()
netif_stop()
{
_clone_down=1
_wlan_down=1
netif_stop0 $*
}

doclear()
{
_clone_down=
_wlan_down=
netif_stop0 $*
}

Expand All @@ -111,6 +118,11 @@ netif_stop0()
# Deconfigure the interface(s)
netif_common ifn_stop $cmdifn

# Destroy wlan interfaces
if [ -n "$_wlan_down" ]; then
wlan_down $cmdifn
fi

# Destroy cloned interfaces
if [ -n "$_clone_down" ]; then
clone_down $cmdifn
Expand Down
9 changes: 3 additions & 6 deletions sys/dev/ath/ath_rate/sample/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an,
#define RATE(ix) (DOT11RATE(ix) / 2)
struct sample_node *sn = ATH_NODE_SAMPLE(an);
struct sample_softc *ssc = ATH_SOFTC_SAMPLE(sc);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
const HAL_RATE_TABLE *rt = sc->sc_currates;
const int size_bin = size_to_bin(frameLen);
int rix, mrr, best_rix, change_rates;
Expand Down Expand Up @@ -856,8 +855,7 @@ ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an,
const struct ath_rc_series *rc, const struct ath_tx_status *ts,
int frame_size, int nframes, int nbad)
{
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
struct sample_node *sn = ATH_NODE_SAMPLE(an);
int final_rix, short_tries, long_tries;
const HAL_RATE_TABLE *rt = sc->sc_currates;
Expand Down Expand Up @@ -1303,8 +1301,7 @@ static int
ath_rate_sysctl_stats(SYSCTL_HANDLER_ARGS)
{
struct ath_softc *sc = arg1;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
int error, v;

v = 0;
Expand Down
3 changes: 1 addition & 2 deletions sys/dev/ath/ath_rate/sample/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ static unsigned calc_usecs_unicast_packet(struct ath_softc *sc,
int long_retries, int is_ht40)
{
const HAL_RATE_TABLE *rt = sc->sc_currates;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211com *ic = &sc->sc_ic;
int rts, cts;

unsigned t_slot = 20;
Expand Down
Loading

0 comments on commit 619aca8

Please sign in to comment.