Re: [PATCH v2 3/3] staging: wilc1000: refactor p2p action frames handling API's

2020-02-12 Thread Ajay.Kathat
Hi Greg,

On 12/02/20 12:48 am, Greg KH wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Tue, Feb 11, 2020 at 09:57:10AM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> Refactor handling of P2P specific action frames. Make use of 'struct' to
>> handle the P2P frames instead of manipulating using 'buf' pointer.
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>  v2: corrected 'while' condition by adding 'struct' size as suggested by Dan.
> 
> This patch doesn't apply to my tree :(
> 

Ok. Please ignore this patch. I will rebase and send this patch again.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] staging: wilc1000: refactor p2p action frames handling API's

2020-02-11 Thread Greg KH
On Tue, Feb 11, 2020 at 09:57:10AM +, ajay.kat...@microchip.com wrote:
> From: Ajay Singh 
> 
> Refactor handling of P2P specific action frames. Make use of 'struct' to
> handle the P2P frames instead of manipulating using 'buf' pointer.
> 
> Signed-off-by: Ajay Singh 
> ---
>  v2: corrected 'while' condition by adding 'struct' size as suggested by Dan.

This patch doesn't apply to my tree :(

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/3] staging: wilc1000: refactor p2p action frames handling API's

2020-02-11 Thread Ajay.Kathat
From: Ajay Singh 

Refactor handling of P2P specific action frames. Make use of 'struct' to
handle the P2P frames instead of manipulating using 'buf' pointer.

Signed-off-by: Ajay Singh 
---
 v2: corrected 'while' condition by adding 'struct' size as suggested by Dan.

 drivers/staging/wilc1000/cfg80211.c | 300 
 1 file changed, 128 insertions(+), 172 deletions(-)

diff --git a/drivers/staging/wilc1000/cfg80211.c 
b/drivers/staging/wilc1000/cfg80211.c
index 7afbc475b3ea..d9c7bed2e6fb 100644
--- a/drivers/staging/wilc1000/cfg80211.c
+++ b/drivers/staging/wilc1000/cfg80211.c
@@ -6,29 +6,17 @@
 
 #include "cfg80211.h"
 
-#define FRAME_TYPE_ID  0
-#define ACTION_CAT_ID  24
-#define ACTION_SUBTYPE_ID  25
-#define P2P_PUB_ACTION_SUBTYPE 30
-
-#define ACTION_FRAME   0xd0
-#define GO_INTENT_ATTR_ID  0x04
-#define CHANLIST_ATTR_ID   0x0b
-#define OPERCHAN_ATTR_ID   0x11
-#define PUB_ACTION_ATTR_ID 0x04
-#define P2PELEM_ATTR_ID0xdd
-
 #define GO_NEG_REQ 0x00
 #define GO_NEG_RSP 0x01
 #define GO_NEG_CONF0x02
 #define P2P_INV_REQ0x03
 #define P2P_INV_RSP0x04
-#define PUBLIC_ACT_VENDORSPEC  0x09
-#define GAS_INITIAL_REQ0x0a
-#define GAS_INITIAL_RSP0x0b
 
 #define WILC_INVALID_CHANNEL   0
 
+/* Operation at 2.4 GHz with channels 1-13 */
+#define WILC_WLAN_OPERATING_CLASS_2_4GHZ   0x51
+
 static const struct ieee80211_txrx_stypes
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_STATION] = {
@@ -67,7 +55,50 @@ struct wilc_p2p_mgmt_data {
u8 *buff;
 };
 
-static const u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
+struct wilc_p2p_pub_act_frame {
+   u8 category;
+   u8 action;
+   u8 oui[3];
+   u8 oui_type;
+   u8 oui_subtype;
+   u8 dialog_token;
+   u8 elem[0];
+} __packed;
+
+struct wilc_vendor_specific_ie {
+   u8 tag_number;
+   u8 tag_len;
+   u8 oui[3];
+   u8 oui_type;
+   u8 attr[0];
+} __packed;
+
+struct wilc_attr_entry {
+   u8  attr_type;
+   __le16 attr_len;
+   u8 val[0];
+} __packed;
+
+struct wilc_attr_oper_ch {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 op_class;
+   u8 op_channel;
+} __packed;
+
+struct wilc_attr_ch_list {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 elem[0];
+} __packed;
+
+struct wilc_ch_list_elem {
+   u8 op_class;
+   u8 no_of_channels;
+   u8 ch_list[0];
+} __packed;
 
 static void cfg_scan_result(enum scan_event scan_event,
struct wilc_rcvd_net_info *info, void *user_void)
@@ -896,87 +927,51 @@ static int flush_pmksa(struct wiphy *wiphy, struct 
net_device *netdev)
return 0;
 }
 
-static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u8 ch_list_attr_idx,
- u8 op_ch_attr_idx, u8 sta_ch)
+static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u32 len, u8 sta_ch)
 {
-   int i = 0;
-   int j = 0;
-
-   if (ch_list_attr_idx) {
-   u8 limit = ch_list_attr_idx + 3 + buf[ch_list_attr_idx + 1];
+   struct wilc_attr_entry *e;
+   struct wilc_attr_ch_list *ch_list;
+   struct wilc_attr_oper_ch *op_ch;
+   u32 index = 0;
+   u8 ch_list_idx = 0;
+   u8 op_ch_idx = 0;
 
-   for (i = ch_list_attr_idx + 3; i < limit; i++) {
-   if (buf[i] == 0x51) {
-   for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++)
-   buf[j] = sta_ch;
-   break;
-   }
-   }
-   }
+   if (sta_ch == WILC_INVALID_CHANNEL)
+   return;
 
-   if (op_ch_attr_idx) {
-   buf[op_ch_attr_idx + 6] = 0x51;
-   buf[op_ch_attr_idx + 7] = sta_ch;
+   while (index + sizeof(*e) <= len) {
+   e = (struct wilc_attr_entry *)[index];
+   if (e->attr_type == IEEE80211_P2P_ATTR_CHANNEL_LIST)
+   ch_list_idx = index;
+   else if (e->attr_type == IEEE80211_P2P_ATTR_OPER_CHANNEL)
+   op_ch_idx = index;
+   if (ch_list_idx && op_ch_idx)
+   break;
+   index += le16_to_cpu(e->attr_len) + sizeof(*e);
}
-}
 
-static void wilc_wfi_cfg_parse_rx_action(u8 *buf, u32 len, u8 sta_ch)
-{
-   u32 index = 0;
-   u8 op_channel_attr_index = 0;
-   u8 channel_list_attr_index = 0;
-
-   while (index < len) {
-   if (buf[index] ==  CHANLIST_ATTR_ID)
-   channel_list_attr_index =