Skip to content
Permalink
Browse files

ath9k: Add OCB mode support

This is quick-and-dirty work in progress

Signed-off-by: Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz>
  • Loading branch information...
lisovy committed Dec 18, 2014
1 parent 44e8967 commit bf45e0160af428dac8893e48d506ac428fed16b2
@@ -331,6 +331,7 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)

if (is_scanning ||
(ah->opmode != NL80211_IFTYPE_STATION &&
ah->opmode != NL80211_IFTYPE_OCB &&
ah->opmode != NL80211_IFTYPE_ADHOC)) {
/*
* If we're scanning or in AP mode, the defaults (ini)
@@ -637,6 +637,7 @@ struct ath9k_vif_iter_data {
int nstations; /* number of station vifs */
int nwds; /* number of WDS vifs */
int nadhocs; /* number of adhoc vifs */
int nocbs; /* number of OCB vifs */
struct ieee80211_vif *primary_sta;
};

@@ -86,6 +86,26 @@ static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
CHAN5G(5785, 35), /* Channel 157 */
CHAN5G(5805, 36), /* Channel 161 */
CHAN5G(5825, 37), /* Channel 165 */

CHAN5G(5850, 38), /* Channel 170 */
/* ITA-G5B */
CHAN5G(5855, 39), /* Channel 171 */
CHAN5G(5860, 40), /* Channel 172 */
CHAN5G(5865, 41), /* Channel 173 */
CHAN5G(5870, 42), /* Channel 174 */
/* ITS-G5A */
CHAN5G(5875, 43), /* Channel 175 */
CHAN5G(5880, 44), /* Channel 176 */
CHAN5G(5885, 45), /* Channel 177 */
CHAN5G(5890, 46), /* Channel 178 */
CHAN5G(5895, 47), /* Channel 179 */
CHAN5G(5900, 48), /* Channel 180 */
CHAN5G(5905, 49), /* Channel 181 */
/* ITS-G5D */
CHAN5G(5910, 50), /* Channel 182 */
CHAN5G(5915, 51), /* Channel 183 */
CHAN5G(5920, 52), /* Channel 184 */
CHAN5G(5925, 53), /* Channel 185 */
};

/* Atheros hardware rate code addition for short premble */
@@ -763,8 +763,8 @@ static int read_file_misc(struct seq_file *file, void *data)
i++, (int)(ctx->assigned), iter_data.naps,
iter_data.nstations,
iter_data.nmeshes, iter_data.nwds);
seq_printf(file, " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
iter_data.nadhocs, sc->cur_chan->nvifs,
seq_printf(file, " ADHOC: %i OCB: %i TOTAL: %hi BEACON-VIF: %hi\n",
iter_data.nadhocs, iter_data.nocbs, sc->cur_chan->nvifs,
sc->nbcnvifs);
}

@@ -608,7 +608,8 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_P2P_GO) |
BIT(NL80211_IFTYPE_P2P_CLIENT) |
BIT(NL80211_IFTYPE_MESH_POINT);
BIT(NL80211_IFTYPE_MESH_POINT) |
BIT(NL80211_IFTYPE_OCB);

hw->wiphy->iface_combinations = &if_comb;
hw->wiphy->n_iface_combinations = 1;
@@ -1187,6 +1187,7 @@ static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode)
u32 set = AR_STA_ID1_KSRCH_MODE;

switch (opmode) {
case NL80211_IFTYPE_OCB:
case NL80211_IFTYPE_ADHOC:
if (!AR_SREV_9340_13(ah)) {
set |= AR_STA_ID1_ADHOC;
@@ -71,7 +71,7 @@

#define ATH9K_RSSI_BAD -128

#define ATH9K_NUM_CHANNELS 38
#define ATH9K_NUM_CHANNELS 54

/* Register read/write primitives */
#define REG_WRITE(_ah, _reg, _val) \
@@ -834,7 +834,8 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_MESH_POINT) |
BIT(NL80211_IFTYPE_WDS);
BIT(NL80211_IFTYPE_WDS) |
BIT(NL80211_IFTYPE_OCB);

hw->wiphy->iface_combinations = if_comb;
hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
@@ -946,6 +946,7 @@ static void ath9k_vif_iter(struct ath9k_vif_iter_data *iter_data,
if (avp->assoc && !iter_data->primary_sta)
iter_data->primary_sta = vif;
break;
case NL80211_IFTYPE_OCB:
case NL80211_IFTYPE_ADHOC:
iter_data->nadhocs++;
if (vif->bss_conf.enable_beacon)
@@ -1119,6 +1120,8 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,

if (iter_data.nmeshes)
ah->opmode = NL80211_IFTYPE_MESH_POINT;
else if (iter_data.nocbs)
ah->opmode = NL80211_IFTYPE_OCB;
else if (iter_data.nwds)
ah->opmode = NL80211_IFTYPE_AP;
else if (iter_data.nadhocs)
@@ -1130,7 +1133,8 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,
ath9k_hw_setopmode(ah);

ctx->switch_after_beacon = false;
if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
if ((iter_data.nstations + iter_data.nadhocs +
iter_data.nmeshes + iter_data.nocbs) > 0)
ah->imask |= ATH9K_INT_TSFOOR;
else {
ah->imask &= ~ATH9K_INT_TSFOOR;
@@ -1740,6 +1744,15 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
ath9k_hw_write_associd(sc->sc_ah);
}

/* FIXME -- fix the functionality
* this is just copied from BSS_CHANGED_IBSS as a placeholder
*/
if (changed & BSS_CHANGED_OCB) {
memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
common->curaid = bss_conf->aid;
ath9k_hw_write_associd(sc->sc_ah);
}

if ((changed & BSS_CHANGED_BEACON_ENABLED) ||
(changed & BSS_CHANGED_BEACON_INT) ||
(changed & BSS_CHANGED_BEACON_INFO)) {
@@ -408,7 +408,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
(sc->cur_chan->nvifs <= 1) &&
!(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC))
rfilt |= ATH9K_RX_FILTER_MYBEACON;
else
else if (sc->sc_ah->opmode != NL80211_IFTYPE_OCB)
rfilt |= ATH9K_RX_FILTER_BEACON;

if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
@@ -45,21 +45,21 @@ static int __ath_regd_init(struct ath_regulatory *reg);
/* We allow IBSS on these on a case by case basis by regulatory domain */
#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 80, 0, 30,\
NL80211_RRF_NO_IR)
#define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 80, 0, 30,\
#define ATH9K_5GHZ_5470_5925 REG_RULE(5470-10, 5925+10, 80, 0, 30,\
NL80211_RRF_NO_IR)
#define ATH9K_5GHZ_5725_5850 REG_RULE(5725-10, 5850+10, 80, 0, 30,\
#define ATH9K_5GHZ_5725_5925 REG_RULE(5725-10, 5925+10, 80, 0, 30,\
NL80211_RRF_NO_IR)

#define ATH9K_2GHZ_ALL ATH9K_2GHZ_CH01_11, \
ATH9K_2GHZ_CH12_13, \
ATH9K_2GHZ_CH14

#define ATH9K_5GHZ_ALL ATH9K_5GHZ_5150_5350, \
ATH9K_5GHZ_5470_5850
ATH9K_5GHZ_5470_5925

/* This one skips what we call "mid band" */
#define ATH9K_5GHZ_NO_MIDBAND ATH9K_5GHZ_5150_5350, \
ATH9K_5GHZ_5725_5850
ATH9K_5GHZ_5725_5925

/* Can be used for:
* 0x60, 0x61, 0x62 */

4 comments on commit bf45e01

@rahularora19911

This comment has been minimized.

Copy link

rahularora19911 replied Oct 22, 2018

Hello Rostislav Lisovy,

Could you please share the commands on how to test this functionality after building the image with these patches successfully?

Thanks & Regards,

Rahul ARORA

@wentasah

This comment has been minimized.

Copy link
Member

wentasah replied Oct 22, 2018

Hi, does this help?

@rahularora19911

This comment has been minimized.

Copy link

rahularora19911 replied Oct 22, 2018

Hello MIchal,

Thanks for the reply.

I am aware about these commands. I was seeking help on AP/STA setup? How do i make my devices as an AP/STA and test whether i am able to ping between boht? I am able to run the below script on my device. That is not a issue.

#!/bin/sh
set -x
WLAN=wlp1s0
DIR_IP=192.168.1.2
MASK=255.255.255.0
GW=192.168.1.1
#Setting down the wireless interface
ip link set $WLAN down
#Setting OCB mode
iw dev $WLAN set type ocb
#Setting down OCB interface
ip link set $WLAN down
#Setting wireless regulatory domain to AA
iw reg set AA
#Is it change?
iw reg get
#Raising OCB interface
ip link set $WLAN up
#Joining interface to Control Channel and 10MHz of bandwidth
iw dev $WLAN ocb join 5890 10MHZ
#Leaving the Control Channel
iw dev $WLAN ocb leave
#Joining interface to Service Control Channel 1
iw dev $WLAN ocb join 5880 10MHZ

Below are the logs.

./script.sh

  • WLAN=wlp1s0

  • DIR_IP=192.168.1.2

  • MASK=255.255.255.0

  • GW=192.168.1.1

  • ip link set wlp1s0 down

  • iw dev wlp1s0 set type ocb

  • ip link set wlp1s0 down

  • iw reg set AA

  • iw reg get
    global
    country 00: DFS-UNSET
    (2402 - 2472 @ 40), (N/A, 20), (N/A)
    (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR
    (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFIPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
    DM, NO-IR
    (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR
    (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR
    (5490 - 5730 @ 160), (N/A, 20), (IPv6: ADDRCONF(NETDEV_CHANGE): wlp1s0: link becomes ready
    0 ms), DFS, NO-IR
    (5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR
    (57240 - 63720 @ 2160), (N/A, 0), (N/A)

  • ip link set wlp1s0 up

  • iw dev wlp1s0 ocb join 5890 10MHZ

  • iw dev wlp1s0 ocb leave

  • iw dev wlp1s0 ocb join 5880 10MHZ

cfg80211: World regulatory domain updated:

cfg80211: DFS Master region: unset
cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)
cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)

ip link show dev wlp1s0

5: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
link/ether 24:fd:52:4f:69:3e brd ff:ff:ff:ff:ff:ff

Thanks & Regards,

Rahul ARORA

@rahularora19911

This comment has been minimized.

Copy link

rahularora19911 replied Oct 22, 2018

This is the output of iwconfig after running the above commads:

wlp1s0 IEEE 802.11abgn Mode:Auto Tx-Power=17 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off

Please sign in to comment.
You can’t perform that action at this time.