Skip to content

Commit 4671c20

Browse files
Prameela Rani GarnepudiKalle Valo
authored andcommitted
rsi: handle peer connection and disconnection in p2p mode
Parameter 'vif' is passed to inform_bss_status function to check the type of vif and to get vap_id. Signed-off-by: Prameela Rani Garnepudi <[email protected]> Signed-off-by: Amitkumar Karwar <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent df77191 commit 4671c20

File tree

7 files changed

+64
-39
lines changed

7 files changed

+64
-39
lines changed

drivers/net/wireless/rsi/rsi_91x_core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb)
361361
struct rsi_hw *adapter = common->priv;
362362
struct ieee80211_tx_info *info;
363363
struct skb_info *tx_params;
364-
struct ieee80211_hdr *wh;
365-
struct ieee80211_vif *vif = adapter->vifs[0];
364+
struct ieee80211_hdr *wh = NULL;
365+
struct ieee80211_vif *vif;
366366
u8 q_num, tid = 0;
367367
struct rsi_sta *rsta = NULL;
368368

@@ -381,6 +381,11 @@ void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb)
381381
wh = (struct ieee80211_hdr *)&skb->data[0];
382382
tx_params->sta_id = 0;
383383

384+
vif = rsi_get_vif(adapter, wh->addr2);
385+
if (!vif)
386+
goto xmit_fail;
387+
tx_params->vif = vif;
388+
tx_params->vap_id = ((struct vif_priv *)vif->drv_priv)->vap_id;
384389
if ((ieee80211_is_mgmt(wh->frame_control)) ||
385390
(ieee80211_is_ctl(wh->frame_control)) ||
386391
(ieee80211_is_qos_nullfunc(wh->frame_control))) {

drivers/net/wireless/rsi/rsi_91x_hal.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
4242
struct ieee80211_hdr *wh = NULL;
4343
struct ieee80211_tx_info *info;
4444
struct ieee80211_conf *conf = &adapter->hw->conf;
45-
struct ieee80211_vif *vif = adapter->vifs[0];
45+
struct ieee80211_vif *vif;
4646
struct rsi_mgmt_desc *mgmt_desc;
4747
struct skb_info *tx_params;
4848
struct ieee80211_bss_conf *bss = NULL;
@@ -57,6 +57,7 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
5757

5858
info = IEEE80211_SKB_CB(skb);
5959
tx_params = (struct skb_info *)info->driver_data;
60+
vif = tx_params->vif;
6061

6162
/* Update header size */
6263
header_size = FRAME_DESC_SZ + sizeof(struct xtended_desc);
@@ -78,7 +79,7 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
7879

7980
tx_params->internal_hdr_size = header_size;
8081
memset(&skb->data[0], 0, header_size);
81-
bss = &info->control.vif->bss_conf;
82+
bss = &vif->bss_conf;
8283
wh = (struct ieee80211_hdr *)&skb->data[header_size];
8384

8485
mgmt_desc = (struct rsi_mgmt_desc *)skb->data;
@@ -95,10 +96,10 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
9596

9697
mgmt_desc->seq_ctrl =
9798
cpu_to_le16(IEEE80211_SEQ_TO_SN(le16_to_cpu(wh->seq_ctrl)));
98-
if (common->band == NL80211_BAND_2GHZ)
99-
mgmt_desc->rate_info = RSI_RATE_1;
99+
if ((common->band == NL80211_BAND_2GHZ) && !common->p2p_enabled)
100+
mgmt_desc->rate_info = cpu_to_le16(RSI_RATE_1);
100101
else
101-
mgmt_desc->rate_info = RSI_RATE_6;
102+
mgmt_desc->rate_info = cpu_to_le16(RSI_RATE_6);
102103

103104
if (conf_is_ht40(conf))
104105
mgmt_desc->bbp_info = cpu_to_le16(FULL40M_ENABLE);
@@ -121,7 +122,8 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
121122
xtend_desc->retry_cnt = PROBE_RESP_RETRY_CNT;
122123
}
123124

124-
if ((vif->type == NL80211_IFTYPE_AP) &&
125+
if (((vif->type == NL80211_IFTYPE_AP) ||
126+
(vif->type == NL80211_IFTYPE_P2P_GO)) &&
125127
(ieee80211_is_action(wh->frame_control))) {
126128
struct rsi_sta *rsta = rsi_find_sta(common, wh->addr1);
127129

@@ -130,6 +132,10 @@ static int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb)
130132
else
131133
return -EINVAL;
132134
}
135+
mgmt_desc->rate_info |=
136+
cpu_to_le16((tx_params->vap_id << RSI_DESC_VAP_ID_OFST) &
137+
RSI_DESC_VAP_ID_MASK);
138+
133139
return 0;
134140
}
135141

@@ -306,21 +312,11 @@ int rsi_send_mgmt_pkt(struct rsi_common *common,
306312
struct ieee80211_tx_info *info;
307313
struct skb_info *tx_params;
308314
int status = -E2BIG;
309-
u8 extnd_size;
310315

311316
info = IEEE80211_SKB_CB(skb);
312317
tx_params = (struct skb_info *)info->driver_data;
313-
extnd_size = ((uintptr_t)skb->data & 0x3);
314318

315319
if (tx_params->flags & INTERNAL_MGMT_PKT) {
316-
skb->data[1] |= BIT(7); /* Immediate Wakeup bit*/
317-
if ((extnd_size) > skb_headroom(skb)) {
318-
rsi_dbg(ERR_ZONE, "%s: Unable to send pkt\n", __func__);
319-
dev_kfree_skb(skb);
320-
return -ENOSPC;
321-
}
322-
skb_push(skb, extnd_size);
323-
skb->data[extnd_size + 4] = extnd_size;
324320
status = adapter->host_intf_ops->write_pkt(common->priv,
325321
(u8 *)skb->data,
326322
skb->len);
@@ -352,12 +348,23 @@ int rsi_prepare_beacon(struct rsi_common *common, struct sk_buff *skb)
352348
struct rsi_data_desc *bcn_frm;
353349
struct ieee80211_hw *hw = common->priv->hw;
354350
struct ieee80211_conf *conf = &hw->conf;
351+
struct ieee80211_vif *vif;
355352
struct sk_buff *mac_bcn;
356-
u8 vap_id = 0;
357-
u16 tim_offset;
358-
353+
u8 vap_id = 0, i;
354+
u16 tim_offset = 0;
355+
356+
for (i = 0; i < RSI_MAX_VIFS; i++) {
357+
vif = adapter->vifs[i];
358+
if (!vif)
359+
continue;
360+
if ((vif->type == NL80211_IFTYPE_AP) ||
361+
(vif->type == NL80211_IFTYPE_P2P_GO))
362+
break;
363+
}
364+
if (!vif)
365+
return -EINVAL;
359366
mac_bcn = ieee80211_beacon_get_tim(adapter->hw,
360-
adapter->vifs[adapter->sc_nvifs - 1],
367+
vif,
361368
&tim_offset, NULL);
362369
if (!mac_bcn) {
363370
rsi_dbg(ERR_ZONE, "Failed to get beacon from mac80211\n");

drivers/net/wireless/rsi/rsi_91x_mac80211.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ static void rsi_mac80211_bss_info_changed(struct ieee80211_hw *hw,
718718
bss_conf->bssid,
719719
bss_conf->qos,
720720
bss_conf->aid,
721-
NULL, 0);
721+
NULL, 0, vif);
722722
adapter->ps_info.dtim_interval_duration = bss->dtim_period;
723723
adapter->ps_info.listen_interval = conf->listen_interval;
724724

@@ -862,7 +862,8 @@ static int rsi_hal_key_config(struct ieee80211_hw *hw,
862862
rsi_dbg(ERR_ZONE, "%s: Cipher 0x%x key_type: %d key_len: %d\n",
863863
__func__, key->cipher, key_type, key->keylen);
864864

865-
if (vif->type == NL80211_IFTYPE_AP) {
865+
if ((vif->type == NL80211_IFTYPE_AP) ||
866+
(vif->type == NL80211_IFTYPE_P2P_GO)) {
866867
if (sta) {
867868
rsta = rsi_find_sta(adapter->priv, sta->addr);
868869
if (rsta)
@@ -1297,7 +1298,8 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw,
12971298

12981299
mutex_lock(&common->mutex);
12991300

1300-
if (vif->type == NL80211_IFTYPE_AP) {
1301+
if ((vif->type == NL80211_IFTYPE_AP) ||
1302+
(vif->type == NL80211_IFTYPE_P2P_GO)) {
13011303
u8 cnt;
13021304
int sta_idx = -1;
13031305
int free_index = -1;
@@ -1348,7 +1350,7 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw,
13481350
rsi_dbg(INFO_ZONE, "Indicate bss status to device\n");
13491351
rsi_inform_bss_status(common, RSI_OPMODE_AP, 1,
13501352
sta->addr, sta->wme, sta->aid,
1351-
sta, sta_idx);
1353+
sta, sta_idx, vif);
13521354

13531355
if (common->key) {
13541356
struct ieee80211_key_conf *key = common->key;
@@ -1368,7 +1370,8 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw,
13681370
}
13691371
}
13701372

1371-
if (vif->type == NL80211_IFTYPE_STATION) {
1373+
if ((vif->type == NL80211_IFTYPE_STATION) ||
1374+
(vif->type == NL80211_IFTYPE_P2P_CLIENT)) {
13721375
rsi_set_min_rate(hw, sta, common);
13731376
if (sta->ht_cap.ht_supported) {
13741377
common->vif_info[0].is_ht = true;
@@ -1409,7 +1412,8 @@ static int rsi_mac80211_sta_remove(struct ieee80211_hw *hw,
14091412

14101413
mutex_lock(&common->mutex);
14111414

1412-
if (vif->type == NL80211_IFTYPE_AP) {
1415+
if ((vif->type == NL80211_IFTYPE_AP) ||
1416+
(vif->type == NL80211_IFTYPE_P2P_GO)) {
14131417
u8 sta_idx, cnt;
14141418

14151419
/* Send peer notify to device */
@@ -1422,7 +1426,8 @@ static int rsi_mac80211_sta_remove(struct ieee80211_hw *hw,
14221426
if (!memcmp(rsta->sta->addr, sta->addr, ETH_ALEN)) {
14231427
rsi_inform_bss_status(common, RSI_OPMODE_AP, 0,
14241428
sta->addr, sta->wme,
1425-
sta->aid, sta, sta_idx);
1429+
sta->aid, sta, sta_idx,
1430+
vif);
14261431
rsta->sta = NULL;
14271432
rsta->sta_id = -1;
14281433
for (cnt = 0; cnt < IEEE80211_NUM_TIDS; cnt++)
@@ -1436,7 +1441,8 @@ static int rsi_mac80211_sta_remove(struct ieee80211_hw *hw,
14361441
rsi_dbg(ERR_ZONE, "%s: No station found\n", __func__);
14371442
}
14381443

1439-
if (vif->type == NL80211_IFTYPE_STATION) {
1444+
if ((vif->type == NL80211_IFTYPE_STATION) ||
1445+
(vif->type == NL80211_IFTYPE_P2P_CLIENT)) {
14401446
/* Resetting all the fields to default values */
14411447
memcpy((u8 *)bss->bssid, (u8 *)sta->addr, ETH_ALEN);
14421448
bss->qos = sta->wme;

drivers/net/wireless/rsi/rsi_91x_mgmt.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,12 @@ static int rsi_hal_send_sta_notify_frame(struct rsi_common *common,
460460
const unsigned char *bssid,
461461
u8 qos_enable,
462462
u16 aid,
463-
u16 sta_id)
463+
u16 sta_id,
464+
struct ieee80211_vif *vif)
464465
{
465-
struct ieee80211_vif *vif = common->priv->vifs[0];
466466
struct sk_buff *skb = NULL;
467467
struct rsi_peer_notify *peer_notify;
468-
u16 vap_id = 0;
468+
u16 vap_id = ((struct vif_priv *)vif->drv_priv)->vap_id;
469469
int status;
470470
u16 frame_len = sizeof(struct rsi_peer_notify);
471471

@@ -1318,7 +1318,8 @@ void rsi_inform_bss_status(struct rsi_common *common,
13181318
u8 qos_enable,
13191319
u16 aid,
13201320
struct ieee80211_sta *sta,
1321-
u16 sta_id)
1321+
u16 sta_id,
1322+
struct ieee80211_vif *vif)
13221323
{
13231324
if (status) {
13241325
if (opmode == RSI_OPMODE_STA)
@@ -1328,7 +1329,8 @@ void rsi_inform_bss_status(struct rsi_common *common,
13281329
STA_CONNECTED,
13291330
addr,
13301331
qos_enable,
1331-
aid, sta_id);
1332+
aid, sta_id,
1333+
vif);
13321334
if (common->min_rate == 0xffff)
13331335
rsi_send_auto_rate_request(common, sta, sta_id);
13341336
if (opmode == RSI_OPMODE_STA) {
@@ -1343,7 +1345,8 @@ void rsi_inform_bss_status(struct rsi_common *common,
13431345
STA_DISCONNECTED,
13441346
addr,
13451347
qos_enable,
1346-
aid, sta_id);
1348+
aid, sta_id,
1349+
vif);
13471350
if (opmode == RSI_OPMODE_STA)
13481351
rsi_send_block_unblock_frame(common, true);
13491352
}

drivers/net/wireless/rsi/rsi_hal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ struct rsi_mgmt_desc {
121121
u8 xtend_desc_size;
122122
u8 header_len;
123123
__le16 frame_info;
124-
u8 rate_info;
125-
u8 reserved1;
124+
__le16 rate_info;
126125
__le16 bbp_info;
127126
__le16 seq_ctrl;
128127
u8 reserved2;

drivers/net/wireless/rsi/rsi_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ struct skb_info {
124124
s8 tid;
125125
s8 sta_id;
126126
u8 internal_hdr_size;
127+
struct ieee80211_vif *vif;
128+
u8 vap_id;
127129
};
128130

129131
enum edca_queue {

drivers/net/wireless/rsi/rsi_mgmt.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@
189189
IEEE80211_WMM_IE_STA_QOSINFO_AC_BE | \
190190
IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
191191

192+
#define RSI_DESC_VAP_ID_MASK 0xC000
193+
#define RSI_DESC_VAP_ID_OFST 14
192194
#define RSI_DATA_DESC_MAC_BBP_INFO BIT(0)
193195
#define RSI_DATA_DESC_NO_ACK_IND BIT(9)
194196
#define RSI_DATA_DESC_QOS_EN BIT(12)
@@ -623,7 +625,8 @@ int rsi_send_vap_dynamic_update(struct rsi_common *common);
623625
int rsi_send_block_unblock_frame(struct rsi_common *common, bool event);
624626
void rsi_inform_bss_status(struct rsi_common *common, enum opmode opmode,
625627
u8 status, const u8 *addr, u8 qos_enable, u16 aid,
626-
struct ieee80211_sta *sta, u16 sta_id);
628+
struct ieee80211_sta *sta, u16 sta_id,
629+
struct ieee80211_vif *vif);
627630
void rsi_indicate_pkt_to_os(struct rsi_common *common, struct sk_buff *skb);
628631
int rsi_mac80211_attach(struct rsi_common *common);
629632
void rsi_indicate_tx_status(struct rsi_hw *common, struct sk_buff *skb,

0 commit comments

Comments
 (0)