Commit f41cf246 authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman

staging: wilc1000: remove p2p related static variables to wilc_vif struct

Avoid use of static variable and move them as part of private
data(wilc_priv) struct.
Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9441402
...@@ -726,6 +726,7 @@ static int wilc_mac_open(struct net_device *ndev) ...@@ -726,6 +726,7 @@ static int wilc_mac_open(struct net_device *ndev)
{ {
struct wilc_vif *vif = netdev_priv(ndev); struct wilc_vif *vif = netdev_priv(ndev);
struct wilc *wl = vif->wilc; struct wilc *wl = vif->wilc;
struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr);
unsigned char mac_add[ETH_ALEN] = {0}; unsigned char mac_add[ETH_ALEN] = {0};
int ret = 0; int ret = 0;
int i = 0; int i = 0;
...@@ -779,6 +780,7 @@ static int wilc_mac_open(struct net_device *ndev) ...@@ -779,6 +780,7 @@ static int wilc_mac_open(struct net_device *ndev)
vif->frame_reg[1].reg); vif->frame_reg[1].reg);
netif_wake_queue(ndev); netif_wake_queue(ndev);
wl->open_ifcs++; wl->open_ifcs++;
priv->p2p.local_random = 0x01;
vif->mac_opened = 1; vif->mac_opened = 1;
return 0; return 0;
} }
......
...@@ -137,10 +137,7 @@ struct p2p_mgmt_data { ...@@ -137,10 +137,7 @@ struct p2p_mgmt_data {
static u8 wlan_channel = INVALID_CHANNEL; static u8 wlan_channel = INVALID_CHANNEL;
static u8 curr_channel; static u8 curr_channel;
static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
static u8 p2p_local_random = 0x01;
static u8 p2p_recv_random;
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
static bool wilc_ie;
static struct ieee80211_supported_band wilc_band_2ghz = { static struct ieee80211_supported_band wilc_band_2ghz = {
.channels = ieee80211_2ghz_channels, .channels = ieee80211_2ghz_channels,
...@@ -515,9 +512,9 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, ...@@ -515,9 +512,9 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
GFP_KERNEL); GFP_KERNEL);
} else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
vif->obtaining_ip = false; vif->obtaining_ip = false;
p2p_local_random = 0x01; priv->p2p.local_random = 0x01;
p2p_recv_random = 0x00; priv->p2p.recv_random = 0x00;
wilc_ie = false; priv->p2p.is_wilc_ie = false;
eth_zero_addr(priv->associated_bss); eth_zero_addr(priv->associated_bss);
wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE); wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE);
...@@ -829,9 +826,9 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, ...@@ -829,9 +826,9 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev,
wlan_channel = INVALID_CHANNEL; wlan_channel = INVALID_CHANNEL;
wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE); wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE);
p2p_local_random = 0x01; priv->p2p.local_random = 0x01;
p2p_recv_random = 0x00; priv->p2p.recv_random = 0x00;
wilc_ie = false; priv->p2p.is_wilc_ie = false;
wfi_drv->p2p_timeout = 0; wfi_drv->p2p_timeout = 0;
ret = wilc_disconnect(vif, reason_code); ret = wilc_disconnect(vif, reason_code);
...@@ -1330,20 +1327,21 @@ static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, ...@@ -1330,20 +1327,21 @@ static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff,
struct wilc_vif *vif = netdev_priv(priv->dev); struct wilc_vif *vif = netdev_priv(priv->dev);
subtype = buff[P2P_PUB_ACTION_SUBTYPE]; subtype = buff[P2P_PUB_ACTION_SUBTYPE];
if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && !wilc_ie) { if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) &&
!priv->p2p.is_wilc_ie) {
for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { if (!memcmp(p2p_vendor_spec, &buff[i], 6)) {
p2p_recv_random = buff[i + 6]; priv->p2p.recv_random = buff[i + 6];
wilc_ie = true; priv->p2p.is_wilc_ie = true;
break; break;
} }
} }
} }
if (p2p_local_random <= p2p_recv_random) { if (priv->p2p.local_random <= priv->p2p.recv_random) {
netdev_dbg(vif->ndev, netdev_dbg(vif->ndev,
"PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n",
p2p_local_random, p2p_recv_random); priv->p2p.local_random, priv->p2p.recv_random);
return; return;
} }
...@@ -1411,7 +1409,7 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) ...@@ -1411,7 +1409,7 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size)
size); size);
if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) &&
wilc_ie) priv->p2p.is_wilc_ie)
size -= 7; size -= 7;
break; break;
...@@ -1503,7 +1501,8 @@ static int cancel_remain_on_channel(struct wiphy *wiphy, ...@@ -1503,7 +1501,8 @@ static int cancel_remain_on_channel(struct wiphy *wiphy,
priv->remain_on_ch_params.listen_session_id); priv->remain_on_ch_params.listen_session_id);
} }
static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx, static void wilc_wfi_cfg_tx_vendor_spec(struct wilc_priv *priv,
struct p2p_mgmt_data *mgmt_tx,
struct cfg80211_mgmt_tx_params *params, struct cfg80211_mgmt_tx_params *params,
u8 iftype, u32 buf_len) u8 iftype, u32 buf_len)
{ {
...@@ -1513,17 +1512,16 @@ static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx, ...@@ -1513,17 +1512,16 @@ static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx,
u8 subtype = buf[P2P_PUB_ACTION_SUBTYPE]; u8 subtype = buf[P2P_PUB_ACTION_SUBTYPE];
if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) { if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) {
if (p2p_local_random == 1 && if (priv->p2p.local_random == 1 &&
p2p_recv_random < p2p_local_random) { priv->p2p.recv_random < priv->p2p.local_random) {
get_random_bytes(&p2p_local_random, 1); get_random_bytes(&priv->p2p.local_random, 1);
p2p_local_random++; priv->p2p.local_random++;
} }
} }
if (p2p_local_random <= p2p_recv_random || !(subtype == GO_NEG_REQ || if (priv->p2p.local_random <= priv->p2p.recv_random ||
subtype == GO_NEG_RSP || !(subtype == GO_NEG_REQ || subtype == GO_NEG_RSP ||
subtype == P2P_INV_REQ || subtype == P2P_INV_REQ || subtype == P2P_INV_RSP))
subtype == P2P_INV_RSP))
return; return;
for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
...@@ -1547,7 +1545,7 @@ static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx, ...@@ -1547,7 +1545,7 @@ static void wilc_wfi_cfg_tx_vendor_spec(struct p2p_mgmt_data *mgmt_tx,
memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, memcpy(&mgmt_tx->buff[len], p2p_vendor_spec,
vendor_spec_len); vendor_spec_len);
mgmt_tx->buff[len + vendor_spec_len] = p2p_local_random; mgmt_tx->buff[len + vendor_spec_len] = priv->p2p.local_random;
mgmt_tx->size = buf_len; mgmt_tx->size = buf_len;
} }
} }
...@@ -1566,7 +1564,7 @@ static int mgmt_tx(struct wiphy *wiphy, ...@@ -1566,7 +1564,7 @@ static int mgmt_tx(struct wiphy *wiphy,
struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_priv *priv = wiphy_priv(wiphy);
struct host_if_drv *wfi_drv = priv->hif_drv; struct host_if_drv *wfi_drv = priv->hif_drv;
struct wilc_vif *vif = netdev_priv(wdev->netdev); struct wilc_vif *vif = netdev_priv(wdev->netdev);
u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random); u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(priv->p2p.local_random);
int ret = 0; int ret = 0;
*cookie = (unsigned long)buf; *cookie = (unsigned long)buf;
...@@ -1614,8 +1612,8 @@ static int mgmt_tx(struct wiphy *wiphy, ...@@ -1614,8 +1612,8 @@ static int mgmt_tx(struct wiphy *wiphy,
case PUBLIC_ACT_VENDORSPEC: case PUBLIC_ACT_VENDORSPEC:
if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4))
wilc_wfi_cfg_tx_vendor_spec(mgmt_tx, params, wilc_wfi_cfg_tx_vendor_spec(priv, mgmt_tx,
vif->iftype, params, vif->iftype,
buf_len); buf_len);
else else
netdev_dbg(vif->ndev, netdev_dbg(vif->ndev,
...@@ -1743,9 +1741,9 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, ...@@ -1743,9 +1741,9 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
struct wilc_vif *vif = netdev_priv(dev); struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl = vif->wilc; struct wilc *wl = vif->wilc;
p2p_local_random = 0x01; priv->p2p.local_random = 0x01;
p2p_recv_random = 0x00; priv->p2p.recv_random = 0x00;
wilc_ie = false; priv->p2p.is_wilc_ie = false;
vif->obtaining_ip = false; vif->obtaining_ip = false;
del_timer(&vif->during_ip_timer); del_timer(&vif->during_ip_timer);
......
...@@ -69,6 +69,12 @@ struct wilc_wfi_p2p_listen_params { ...@@ -69,6 +69,12 @@ struct wilc_wfi_p2p_listen_params {
u32 listen_session_id; u32 listen_session_id;
}; };
struct wilc_p2p_var {
u8 local_random;
u8 recv_random;
bool is_wilc_ie;
};
struct wilc_priv { struct wilc_priv {
struct wireless_dev *wdev; struct wireless_dev *wdev;
struct cfg80211_scan_request *scan_req; struct cfg80211_scan_request *scan_req;
...@@ -98,6 +104,7 @@ struct wilc_priv { ...@@ -98,6 +104,7 @@ struct wilc_priv {
struct timer_list aging_timer; struct timer_list aging_timer;
struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
int scanned_cnt; int scanned_cnt;
struct wilc_p2p_var p2p;
}; };
struct frame_reg { struct frame_reg {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment