From 699ecb89f5c16902589a5d6594de6b5b6b7b6adb Mon Sep 17 00:00:00 2001
From: Venkata krishna Sundararajan <vsundara@qti.qualcomm.com>
Date: Fri, 16 Dec 2016 19:34:11 +0530
Subject: [PATCH] [fulloffload] Adds support for 4.4 kernel.

1. Adds supports for 4.4 kernel making sure its backward compatible
with previous versions.
2. Sigma-DUT fixes for fulloffload.
3. Adds staging dir to CFLAGS in Makefile.
4. Enabling lan bypass mode with byp_cli and bypd.
5. Fixing Codenomicon issue

Change-Id: I07a204de0cedfe907ee733e74c0da11890271cbf
Signed-off-by: Venkata krishna Sundararajan <vsundara@qti.qualcomm.com>
Signed-off-by: Venkata Krishna Sundararajan <vsundara@qti.qualcomm.com>
---
 apps/acfg/include/appbr_if.h                 |  65 ++++++++++++++
 apps/acfg/include/appbr_types.h              |  36 ++++++++
 apps/acfg/include/bypass_types.h             | 122 +++++++++++++++++++++++++++
 apps/acfg/target/linux/Makefile              |   8 +-
 apps/bypass/host/linux/Makefile              |   8 +-
 apps/bypass/host/linux/byp_cli.c             |   1 +
 apps/bypass/host/linux/byp_lib.c             |   1 +
 apps/bypass/target/linux/Makefile            |   8 +-
 apps/bypass/target/linux/byp_main.c          |   1 +
 apps/bypass/target/linux/byp_rplay.c         |   1 +
 host/build/linux/adf/Makefile                |   2 +-
 host/build/linux/fw_loader/mdio/Makefile     |   2 +-
 host/build/linux/fw_loader/pcie/Makefile     |   1 +
 host/build/linux/hif/gmac/Makefile           |   1 +
 host/build/linux/hif/pcie/Makefile           |   2 +-
 host/build/linux/thin_driver/Makefile        |  13 +--
 host/hif/gmac/hif_gmac.c                     |   5 ++
 host/thin_driver/atd/atd_byp.c               |   2 +-
 host/thin_driver/atd/atd_cfg.c               |  37 ++++++++
 host/thin_driver/atd/atd_dev.c               |  84 ++++++++++++++----
 host/thin_driver/wmi/wmi.c                   |   2 +-
 target/linux/build/wasp/thin_driver/Makefile |  12 +--
 target/linux/thin_driver/atd/atd_byp.c       |   4 +-
 target/linux/thin_driver/atd/atd_cfg.c       |   5 ++
 24 files changed, 379 insertions(+), 44 deletions(-)
 create mode 100644 apps/acfg/include/appbr_if.h
 create mode 100644 apps/acfg/include/appbr_types.h
 create mode 100644 apps/acfg/include/bypass_types.h

diff --git a/apps/acfg/include/appbr_if.h b/apps/acfg/include/appbr_if.h
new file mode 100644
index 0000000..7e8dd14
--- /dev/null
+++ b/apps/acfg/include/appbr_if.h
@@ -0,0 +1,65 @@
+#ifndef __APPBR_IF_H__
+
+#define __APPBR_IF_H__
+
+#include <appbr_types.h>
+//#include <acfg_api_types.h>
+#include <bypass_types.h>
+
+/**
+ * @brief Open connection for downlink (send messages) communication
+ *
+ * @param app_id Application Identifier
+ *
+ * @return
+ */
+appbr_status_t
+appbr_if_open_dl_conn(uint32_t app_id);
+
+/**
+ * @brief Close downlink connection
+ */
+void
+appbr_if_close_dl_conn(void);
+
+/**
+ * @brief Open connection for uplink (recv messages) communication
+ *
+ * @param app_id Application Identifier
+ *
+ * @return
+ */
+appbr_status_t
+appbr_if_open_ul_conn(uint32_t app_id);
+
+/**
+ * @brief Close uplink connection
+ */
+void
+appbr_if_close_ul_conn(void);
+
+/**
+ * @brief Send a command to the Peer Application
+ *
+ * @param app_id Application ID
+ * @param buf    Command Buffer Pointer
+ * @param size   Command Size
+ *
+ * @return
+ */
+appbr_status_t
+appbr_if_send_cmd_remote(uint32_t app_id, void *buf, uint32_t size);
+
+/**
+ * @brief   Wait for response from Peer Application
+ *
+ * @param buf       Response Buffer Pointer
+ * @param size      Response Size
+ * @param timeout   Time to wait for Response
+ *
+ * @return
+ */
+appbr_status_t
+appbr_if_wait_for_response(void *buf, uint32_t size, uint32_t timeout);
+
+#endif
diff --git a/apps/acfg/include/appbr_types.h b/apps/acfg/include/appbr_types.h
new file mode 100644
index 0000000..83e4c34
--- /dev/null
+++ b/apps/acfg/include/appbr_types.h
@@ -0,0 +1,36 @@
+#ifndef __APPBR_TYPES_H_
+#define __APPBR_TYPES_H_
+
+#include <a_base_types.h>
+
+#define APPBR_NETLINK_NUM           18
+
+/* Application IDs */
+enum {
+    APPBR_BYP       =   1,
+    APPBR_ACFG      =   2,
+    APPBR_WSUP_BR   =   3
+};
+
+#define APPBR_MAX_APPS                          16
+
+/*
+ * Error codes defined for setting args
+ */
+enum APPBR_STAT_VAL {
+    APPBR_STAT_OK          =   A_STATUS_OK, 
+    APPBR_STAT_EARGSZ      =   A_STATUS_E2BIG,
+    APPBR_STAT_ENOSOCK     =   A_STATUS_EIO,
+    APPBR_STAT_ENOREQACK   =   A_STATUS_EINPROGRESS,
+    APPBR_STAT_ENORESPACK  =   A_STATUS_EBUSY,
+    APPBR_STAT_ERECV       =   A_STATUS_EFAULT,
+    APPBR_STAT_ESENDCMD    =   A_STATUS_FAILED,
+    APPBR_STAT_ENOMEM      =   A_STATUS_ENOMEM,
+};
+
+typedef a_status_t  appbr_status_t;
+
+#define APPBR_MSGADDR_TO_APPID(addr)            (addr)
+#define APPBR_APPID_TO_MSGADDR(addr)            (addr)
+
+#endif
diff --git a/apps/acfg/include/bypass_types.h b/apps/acfg/include/bypass_types.h
new file mode 100644
index 0000000..d523874
--- /dev/null
+++ b/apps/acfg/include/bypass_types.h
@@ -0,0 +1,122 @@
+#ifndef __BYP_TYPES_H__
+#define __BYP_TYPES_H__
+
+#include <a_base_types.h>
+
+/** Maximum Size Settings */
+#define BYP_SZ_IFNAME       32
+#define BYP_SZ_VIDNAME      4   /** Max VLAN ID = "4096" */
+#define BYP_SZ_IFADDR       6
+#define BYP_SZ_REPLAYCMD    1024
+#define BYP_SZ_CMD          1024
+
+#define BYP_RPLAYCMD_SUCCESS    1
+
+
+enum BYP_CMD_TYPE {
+    BYP_CMD_BYPEN = 0,
+    BYP_CMD_VAPCTRL,
+    BYP_CMD_ADDMAC,
+    BYP_CMD_DELMAC,
+    BYP_CMD_VLGRPCREATE,
+    BYP_CMD_VLGRPDELETE,
+    BYP_CMD_VLGRPADDVAP,
+    BYP_CMD_VLGRPDELVAP,
+    BYP_CMD_VLCREATE,
+    BYP_CMD_VLDELETE,
+    BYP_CMD_BRCREATE,
+    BYP_CMD_BRDELETE,
+    BYP_CMD_BRIFUP,
+    BYP_CMD_BRIFDOWN,
+    BYP_CMD_BRLISTMAC,
+    BYP_CMD_LAST
+};
+
+/* LAN Bypass mode definitions for command selection */
+#define     LANBYP_MODE_DISABLED    0x0
+#define     LANBYP_MODE_TUNNEL      0x1
+#define     LANBYP_MODE_VLAN        0x2
+#define     LANBYP_MODE_NOTSET      0x4
+#define     LANBYP_MODE_ALL         0x7
+
+/*
+ * @brief
+ *  Command Header
+ *  byte 0:
+ *  bits[3:0] - Reserved
+ *  bits[4:4] - Node Id (0: kernel/1: peer)
+ *  bits[5:5] - Command Type (Req/Resp)
+ *  bits[6:6] - Acknowledgement Required (0/1)
+ *  bits[7:7] - Response Required (0/1)
+ *
+ *  byte 1:
+ *  bits[7:0] - Command Identifier (0 - 247)
+ *
+ *  byte 3:
+ *  bits[7:0] - Parameters length (LSB)
+ *
+ *  byte 4:
+ *  bits[7:0] - Parameters length (MSB)
+ */
+
+/* Byte 0 Masks */
+#define BYP_CMD_APPID_MASK  0xF
+#define BYP_CMD_NODE_MASK       0x10
+#define BYP_CMD_REQ_MASK        0x20
+#define BYP_CMD_ACK_MASK        0x40
+#define BYP_CMD_RESP_MASK       0x80
+
+/* Byte 0 Values */
+#define BYP_NODE_ALL          0x00
+#define BYP_NODE_REMOTE       0x10
+
+#define BYP_CMD_REQ           0x20
+#define BYP_CMD_RESP          0x00
+
+#define BYP_ACK_REQD          0x40
+#define BYP_RESP_REQD         0x80
+
+/* ACK return values */
+#define BYP_ACK_SUCCESS       1
+#define BYP_ACK_FAILURE       0
+
+#define BYP_VAPCTRL_SETMASK       0x10
+#define BYP_VAPCTRL_SET           0x10
+#define BYP_VAPCTRL_RESET         0x0
+#define BYP_VAPCTRL_ACCMASK       0x3
+#define BYP_VAPCTRL_BR_EN         0x1
+#define BYP_VAPCTRL_LAN_EN        0x2
+
+typedef a_uint8_t   byp_vapctrl_flg_t;
+
+/* Common structures for BypassH <-> BypassT communication */
+typedef struct byp_common {
+    a_uint8_t data[4];
+} byp_common_t;
+
+typedef struct byp_br {
+    struct byp_common   common;
+    char                br_name[BYP_SZ_IFNAME];
+    char                if_name[BYP_SZ_IFNAME];
+    a_uint8_t           br_addr[BYP_SZ_IFADDR];
+} byp_br_t;
+
+typedef struct byp_vapctrl {
+    struct byp_common common;
+    char              if_name[BYP_SZ_IFNAME];
+    char              br_name[BYP_SZ_IFNAME];
+    a_uint8_t         ctrl;
+} byp_vapctrl_t;
+
+typedef struct byp_stat {
+    struct byp_common common;
+    a_uint8_t         byp_status;
+} byp_stat_t;
+
+typedef struct byp_vlan {
+    struct byp_common   common;
+    char                if_name[BYP_SZ_IFNAME];
+    char                vlan_id[BYP_SZ_VIDNAME];
+} byp_vlan_t;
+
+#endif /* __AC_COMMON_H__ */
diff --git a/apps/acfg/target/linux/Makefile b/apps/acfg/target/linux/Makefile
index f673018..e6779fc 100644
--- a/apps/acfg/target/linux/Makefile
+++ b/apps/acfg/target/linux/Makefile
@@ -12,9 +12,10 @@ ACFGD_BINARY=acfgd
 
 FILES=$(shell ls *.c)
 OBJS=$(patsubst %.c,%.o,$(FILES))
+LIB_OBJS=tgt_appbr_if.o
 
 %.o: %.c
-	$(CC) -c $(CFLAGS) $< -o $@
+	$(CC) -c $(CFLAGS) $(COPTS) $< -o $@
 
 export LIB_OUT ACFGD_BINARY
 
@@ -30,3 +31,8 @@ install:
 clean:
 	rm -rvf *.o *.a *.d
 	rm -rvf $(ACFGD_BINARY)
+
+lib: $(LIB_OBJS)
+	$(AR) $(LIB_TYPE) $(LIB_OUT) $(LIB_OBJS)
+
+
diff --git a/apps/bypass/host/linux/Makefile b/apps/bypass/host/linux/Makefile
index 4c4a89a..68f3865 100644
--- a/apps/bypass/host/linux/Makefile
+++ b/apps/bypass/host/linux/Makefile
@@ -11,21 +11,21 @@ LIB_TYPE=rcs
 BYP_BINARY=byp_cli
 BYP_LIB=libbyp.a
 ACFG_LIB=acfg
-LIBRARY_PATH=$(PWD)/../../../../../../apps/acfg/src/
+LIBRARY_PATH=../../../acfg/target/linux/
 
 FILES=$(shell ls *.c)
 OBJS=$(patsubst %.c,%.o,$(FILES))
 LIBOBJS=byp_lib.o
 
 %.o: %.c
-	$(CC) -c $(CFLAGS) $< -o $@
+	$(CC) -c $(CFLAGS) $(COPTS) $< -o $@
 
 export LIB_OUT BYP_BINARY
 
-all: clean build install
+all: clean build
 
 build: $(OBJS) lib
-	$(CC) $(CFLAGS) $(FILES) -o $(BYP_BINARY) -L$(LIBRARY_PATH) -l$(ACFG_LIB)
+	$(CC) $(CFLAGS) $(COPTS) $(FILES) -o $(BYP_BINARY) -L$(LIBRARY_PATH) -l$(ACFG_LIB)
 
 lib: $(LIBOBJS)
 	$(AR) $(LIB_TYPE) $(BYP_LIB) $(LIBOBJS)
diff --git a/apps/bypass/host/linux/byp_cli.c b/apps/bypass/host/linux/byp_cli.c
index 0014cb1..0daf268 100644
--- a/apps/bypass/host/linux/byp_cli.c
+++ b/apps/bypass/host/linux/byp_cli.c
@@ -16,6 +16,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <a_base_types.h>
 #include <bypass_types.h>
 #include <linux/ac_shims.h>
 #include <byp_lib.h>
diff --git a/apps/bypass/host/linux/byp_lib.c b/apps/bypass/host/linux/byp_lib.c
index 3642459..b6521f6 100644
--- a/apps/bypass/host/linux/byp_lib.c
+++ b/apps/bypass/host/linux/byp_lib.c
@@ -17,6 +17,7 @@
 #include <string.h> 
 
 #include <stdlib.h>
+#include <a_base_types.h>
 #include <bypass_types.h>
 
 #include <appbr_if.h>
diff --git a/apps/bypass/target/linux/Makefile b/apps/bypass/target/linux/Makefile
index 2588422..136cd85 100644
--- a/apps/bypass/target/linux/Makefile
+++ b/apps/bypass/target/linux/Makefile
@@ -14,21 +14,21 @@ OBJ_OUT=byp.o
 LIB_OUT=byp
 LIB_TYPE=rcs
 BYP_BINARY=bypd
-ACFG_LIB_PATH=$(PWD)/../../../acfg/target/linux/
+ACFG_LIB_PATH=../../../acfg/target/linux/
 ACFG_LIB=acfg
 
 FILES=$(shell ls *.c)
 OBJS=$(patsubst %.c,%.o,$(FILES))
 
 %.o: %.c
-	$(CC) -c $(CFLAGS) $< -o $@
+	$(CC) -c $(CFLAGS) $(COPTS) $< -o $@
 
 export LIB_OUT BYP_BINARY
 
-all: clean build install
+all: clean build
 
 build: $(OBJS)
-	$(CC) -Wall $(CFLAGS) $(FILES) -L$(ACFG_LIB_PATH) -l$(ACFG_LIB) -o $(BYP_BINARY)
+	$(CC) -Wall $(CFLAGS) $(COPTS) $(FILES) -L$(ACFG_LIB_PATH)  -l$(ACFG_LIB) -o $(BYP_BINARY)
 
 install:
 	cp -f $(BYP_BINARY) $(DESTDIR)/sbin/.
diff --git a/apps/bypass/target/linux/byp_main.c b/apps/bypass/target/linux/byp_main.c
index ff95a32..5007aa5 100644
--- a/apps/bypass/target/linux/byp_main.c
+++ b/apps/bypass/target/linux/byp_main.c
@@ -15,6 +15,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <a_base_types.h>
 #include <bypass_types.h>
 #include <appbr_types.h>
 #include <appbr_if.h>
diff --git a/apps/bypass/target/linux/byp_rplay.c b/apps/bypass/target/linux/byp_rplay.c
index f051d71..844bd6f 100644
--- a/apps/bypass/target/linux/byp_rplay.c
+++ b/apps/bypass/target/linux/byp_rplay.c
@@ -24,6 +24,7 @@
 #include <linux/if.h>
 
 #include <appbr_if.h>
+#include <a_base_types.h>
 #include <bypass_types.h>
 #include <byp_rplay.h>
 
diff --git a/host/build/linux/adf/Makefile b/host/build/linux/adf/Makefile
index 30c674b..0561193 100644
--- a/host/build/linux/adf/Makefile
+++ b/host/build/linux/adf/Makefile
@@ -21,7 +21,7 @@ EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/os/linux
 EXTRA_CFLAGS	+= -I$(PWD)/$(ROOT_INC)/include
 EXTRA_CFLAGS	+= -I$(WLAN_DRIVER_PATH)/include
 EXTRA_CFLAGS	+= -I$(WLAN_DRIVER_PATH)/os/linux/include
-
+EXTRA_CFLAGS    += -I$(STAGING_DIR)/usr/include
 EXTRA_CFLAGS+=        -Wno-unused-function
 
 #
diff --git a/host/build/linux/fw_loader/mdio/Makefile b/host/build/linux/fw_loader/mdio/Makefile
index 6d4a00a..12fcde6 100755
--- a/host/build/linux/fw_loader/mdio/Makefile
+++ b/host/build/linux/fw_loader/mdio/Makefile
@@ -23,7 +23,7 @@ EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/include/os
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/nbuf/linux
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/net/linux
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/os/linux
-
+EXTRA_CFLAGS    += -I$(STAGING_DIR)/usr/include
 
 
 EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_THIN_INC)/wmi/
diff --git a/host/build/linux/fw_loader/pcie/Makefile b/host/build/linux/fw_loader/pcie/Makefile
index 9b58d49..6971633 100644
--- a/host/build/linux/fw_loader/pcie/Makefile
+++ b/host/build/linux/fw_loader/pcie/Makefile
@@ -27,6 +27,7 @@ EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/os/linux
 EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_THIN_INC)/wmi/
 EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_THIN_INC)/htc/
 EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_THIN_INC)/atd/
+EXTRA_CFLAGS        += -I$(STAGING_DIR)/usr/include
 
 #EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_HIF_INC)/linux
 EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_HIF_INC)
diff --git a/host/build/linux/hif/gmac/Makefile b/host/build/linux/hif/gmac/Makefile
index a6517f5..4b4be22 100644
--- a/host/build/linux/hif/gmac/Makefile
+++ b/host/build/linux/hif/gmac/Makefile
@@ -17,6 +17,7 @@ EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/linux/net
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/linux/nbuf
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_GMAC_INC)
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_GMAC_INC)/linux
+EXTRA_CFLAGS    += -I$(STAGING_DIR)/usr/include
 EXTRA_CFLAGS    += -Werror
 
 ifeq ($(strip $(GMAC_FRAGMENT_SUPPORT)),1)
diff --git a/host/build/linux/hif/pcie/Makefile b/host/build/linux/hif/pcie/Makefile
index 5c107e6..5c8d61a 100644
--- a/host/build/linux/hif/pcie/Makefile
+++ b/host/build/linux/hif/pcie/Makefile
@@ -21,7 +21,7 @@ EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/include/os
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/nbuf/linux
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/net/linux
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_ADF_INC)/os/linux
-
+EXTRA_CFLAGS    += -I$(STAGING_DIR)/usr/include
 
 EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_PCIE_INC)
 #EXTRA_CFLAGS    += -I$(PWD)/$(OFFLOAD_PCIE_INC)/linux
diff --git a/host/build/linux/thin_driver/Makefile b/host/build/linux/thin_driver/Makefile
index 8a77d49..166c389 100644
--- a/host/build/linux/thin_driver/Makefile
+++ b/host/build/linux/thin_driver/Makefile
@@ -41,6 +41,7 @@ EXTRA_CFLAGS        += -I$(PWD)/$(OFFLOAD_HIF_INC)
 
 EXTRA_CFLAGS        += -I$(PWD)/../../../../wlan_modules/include
 EXTRA_CFLAGS        += -I$(PWD)/../../../../wlan_modules/os/linux/include
+EXTRA_CFLAGS        += -I$(STAGING_DIR)/usr/include
 
 ifneq ($(strip ${ATH_SUPPORT_TxBF}),0)
 EXTRA_CFLAGS        += -DATH_SUPPORT_TxBF=1
@@ -83,15 +84,15 @@ atd$(MOD_SUFFIX)-objs			+= $(OFFLOAD_THIN)/atd/atd_profile.o
 atd$(MOD_SUFFIX)-objs			+= $(OFFLOAD_THIN)/atd/atd_dev.o
 atd$(MOD_SUFFIX)-objs			+= $(OFFLOAD_THIN)/atd/atd_wsupp.o
 
-ifeq ($(strip $(OFFLOAD_LAN_BYPASS)),1)
+#ifeq ($(strip $(OFFLOAD_LAN_BYPASS)),1)
 EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=1
 atd$(MOD_SUFFIX)-objs        += $(OFFLOAD_THIN)/atd/atd_byp.o
-else
-EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=0
-endif
+#else
+#EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=0
+#endif
 
-ifeq ($(strip $(OFFLOAD_APPBR)),1)
+#ifeq ($(strip $(OFFLOAD_APPBR)),1)
 EXTRA_CFLAGS    += -DOFFLOAD_APPBR=1
 atd$(MOD_SUFFIX)-objs        += $(OFFLOAD_THIN)/atd/atd_appbr.o
-endif
+#endif
 
diff --git a/host/hif/gmac/hif_gmac.c b/host/hif/gmac/hif_gmac.c
index 34595af..82a5980 100755
--- a/host/hif/gmac/hif_gmac.c
+++ b/host/hif/gmac/hif_gmac.c
@@ -1068,6 +1068,11 @@ void gmac_module_exit(void )
     return; 
 }
 
+int hif_sysfs_create_group(struct kobject *kobj, struct attribute_group *grp)
+{
+    return sysfs_create_group(kobj, grp);
+}
+EXPORT_SYMBOL(hif_sysfs_create_group);
 EXPORT_SYMBOL(hif_init);
 EXPORT_SYMBOL(hif_cleanup);
 EXPORT_SYMBOL(hif_start);
diff --git a/host/thin_driver/atd/atd_byp.c b/host/thin_driver/atd/atd_byp.c
index f0b0281..1b99bf4 100644
--- a/host/thin_driver/atd/atd_byp.c
+++ b/host/thin_driver/atd/atd_byp.c
@@ -78,7 +78,7 @@ atd_byp_init(void *atd_handle)
     }
 
     adf_os_mem_zero(addr_list, sizeof(struct host_br_addr_s));
-    BYPSC_HSTADDR_TBL(byp_sc)  =   addr_list; 
+    BYPSC_HSTADDR_TBL(byp_sc)  =   addr_list;
 
     return (byp_sc);
 }
diff --git a/host/thin_driver/atd/atd_cfg.c b/host/thin_driver/atd/atd_cfg.c
index 0f8eee5..a1938dc 100644
--- a/host/thin_driver/atd/atd_cfg.c
+++ b/host/thin_driver/atd/atd_cfg.c
@@ -470,6 +470,37 @@ fail:
     return status;
 }
 
+static ssize_t atd_parent_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+    struct net_device *netdev = to_net_dev(dev);
+    adf_net_handle_t parent = NULL;
+    __adf_softc_t     *sc     = netdev_to_softc(netdev);
+
+    parent = ((atd_host_vap_t*)sc->drv_hdl)->wifisc->netdev;
+    if(!parent)
+        return 0;
+
+    return sprintf(buf, "%s\n", adf_net_ifname(parent));
+}
+
+static DEVICE_ATTR(parent, S_IRUGO, atd_parent_show, NULL);
+static struct attribute *atd_device_attrs[] = {
+    &dev_attr_parent.attr,
+    NULL
+};
+
+static struct attribute_group atd_attr_group = {
+    .attrs  = atd_device_attrs,
+};
+
+int hif_sysfs_create_group(struct kobject *kobj, struct attribute_group *grp);
+void atd_create_group(adf_net_handle_t hdl) {
+
+    __adf_softc_t *sc = hdl_to_softc(hdl);
+    hif_sysfs_create_group(&sc->netdev->dev.kobj, &atd_attr_group);
+}
+
 a_status_t
 atd_cfg_create_vap(adf_drv_handle_t       hdl,
                    a_uint8_t              icp_name[ACFG_MAX_IFNAME],
@@ -613,6 +644,8 @@ atd_cfg_create_vap(adf_drv_handle_t       hdl,
     }
     vap->sys_index   = ADF_VAP_GET_IFINDEX(vap->nethandle);
 
+    atd_create_group(vap->nethandle);
+
     atd_trace(ATD_DEBUG_FUNCTRACE,("VAP created  _adf_net_ifname %s \n",
                  adf_net_ifname(vap->nethandle)));
 
@@ -5557,7 +5590,11 @@ atd_event_bsteer_send(atd_host_wifi_t *wifi,
                 adf_os_ntohl(event->type),
                 sizeof(struct ath_netlink_bsteering_event),
                 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
         NETLINK_CB(nbuf).pid = 0;        /* from kernel */
+#else
+        NETLINK_CB(nbuf).portid = 0;        /* from kernel */
+#endif
         NETLINK_CB(nbuf).dst_group = 0;  /* unicast */
         /* Its time todo ntoh conversion */
         atd_convert_bsteer_event_ntoh(NLMSG_DATA(nlh), event, vap->sys_index);
diff --git a/host/thin_driver/atd/atd_dev.c b/host/thin_driver/atd/atd_dev.c
index 06267f6..28c3dda 100644
--- a/host/thin_driver/atd/atd_dev.c
+++ b/host/thin_driver/atd/atd_dev.c
@@ -200,7 +200,6 @@ atd_host_dev_t * atd_devices[ATD_MAXDEVICES];
 a_uint32_t atd_target_devtype = WASP_TARGET;
 a_uint32_t atd_tgt_pwrdown_support = 0;
 
-
 static hif_status_t
 atd_device_detect( hif_handle_t hif_handle)
 {
@@ -430,11 +429,35 @@ ath_device_htcready_worker(void *ctx)
     }
 
     if (atd_spectral_nl_sock == NULL) {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+        extern struct net init_net;
+        struct netlink_kernel_cfg cfg = {
+            .groups = 1,
+            .input  = atd_spectral_nl_data_ready,
+        };
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+        atd_spectral_nl_sock = (struct sock *)netlink_kernel_create(&init_net, NETLINK_ATHEROS, &cfg);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+        atd_spectral_nl_sock = (struct sock *)netlink_kernel_create(&init_net, NETLINK_ATHEROS,
+                                                                THIS_MODULE, &cfg);
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
         atd_spectral_nl_sock = (struct sock *)netlink_kernel_create(NETLINK_ATHEROS, 1,&atd_spectral_nl_data_ready, THIS_MODULE);
 #else
+        extern struct net init_net;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
+        struct netlink_kernel_cfg cfg;
+        memset(&cfg, 0, sizeof(cfg));
+        cfg.groups = 1;
+        cfg.input = &spectral_nl_data_ready;
+        atd_spectral_nl_sock = (struct sock *)netlink_kernel_create(&init_net,NETLINK_ATHEROS, &cfg);
+#else
         atd_spectral_nl_sock = (struct sock *)netlink_kernel_create(&init_net,NETLINK_ATHEROS, 1,&atd_spectral_nl_data_ready, NULL, THIS_MODULE);
 #endif
+#endif
+
         if (atd_spectral_nl_sock == NULL) {
             printk("%s Netlink interface create FAILED : %d\n", __func__, NETLINK_ATHEROS);
             status = A_STATUS_FAILED;
@@ -444,19 +467,51 @@ ath_device_htcready_worker(void *ctx)
     }
 #define NETLINK_BAND_STEERING_EVENT 21
     if(atd_bsteer_nl_sock == NULL) {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
-        atd_bsteer_nl_sock = (struct sock *)netlink_kernel_create(NETLINK_BAND_STEERING_EVENT,
-                1,
-                &atd_band_steering_netlink_receive,
-                THIS_MODULE);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION (3,10,0)
+        extern struct net init_net;
+        struct netlink_kernel_cfg cfg;
+        memset(&cfg, 0, sizeof(cfg));
+        cfg.groups = 1;
+        cfg.input = &atd_band_steering_netlink_receive;
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+        extern struct net init_net;
+
+        struct netlink_kernel_cfg cfg = {
+            .groups = 1,
+            .input  = atd_band_steering_netlink_receive,
+        };
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)/* >= (3,10,0) */
+        atd_bsteer_nl_sock = (struct sock *)netlink_kernel_create(
+                                                                             &init_net,
+                                                                             NETLINK_BAND_STEERING_EVENT,
+                                                                             &cfg);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+        atd_bsteer_nl_sock = (struct sock *)netlink_kernel_create(
+                                                                             &init_net,
+                                                                             NETLINK_BAND_STEERING_EVENT,
+                                                                             THIS_MODULE, &cfg);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION (2,6,24)
+        atd_bsteer_nl_sock = (struct sock *) netlink_kernel_create(
+                                                                              &init_net,
+                                                                              NETLINK_BAND_STEERING_EVENT, 1,
+                                                                              &atd_band_steering_netlink_receive,
+                                                                              NULL, THIS_MODULE);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION (2,6,22)
+        atd_bsteer_nl_sock = (struct sock *) netlink_kernel_create(
+                                                                              NETLINK_BAND_STEERING_EVENT, 1,
+                                                                              &atd_band_steering_netlink_receive,
+                                                                              NULL, THIS_MODULE);
+
 #else
-        atd_bsteer_nl_sock = (struct sock *)netlink_kernel_create(&init_net,
-                NETLINK_BAND_STEERING_EVENT,
-                1,
-                &atd_band_steering_netlink_receive,
-                NULL,
-                THIS_MODULE);
+        atd_bsteer_nl_sock = (struct sock *)netlink_kernel_create(
+                                                                             NETLINK_BAND_STEERING_EVENT, 1,
+                                                                             &ath_band_steering_netlink_receive,
+                                                                             THIS_MODULE);
 #endif
+
         if (atd_bsteer_nl_sock == NULL) {
             printk("%s Netlink interface create FAILED : %d\n",
                     __func__,
@@ -1478,9 +1533,6 @@ atd_event_device_state_change(adf_net_handle_t nethandle,
     atd_trace(ATD_DEBUG_FUNCTRACE, (" .END "));
 }
 
-
-adf_os_virt_module_name(thin_driver);
-
 adf_os_virt_module_init(atd_device_module_init);
 adf_os_virt_module_exit(atd_device_module_exit);
 adf_os_declare_param(atd_target_devtype , ADF_OS_PARAM_TYPE_INT32);
diff --git a/host/thin_driver/wmi/wmi.c b/host/thin_driver/wmi/wmi.c
index ad512a4..559abcb 100644
--- a/host/thin_driver/wmi/wmi.c
+++ b/host/thin_driver/wmi/wmi.c
@@ -575,7 +575,7 @@ wmi_rsp_callback(void *ctx, adf_nbuf_t netbuf)
 
             /*Expected frags ID*/
 
-            if (wmip->cmd_rsp_buf != NULL && wmip->cmd_rsp_len > 0) {
+            if ((wmip->cmd_rsp_buf != NULL) && (wmip->cmd_rsp_len > 0) && (wmip->cmd_rsp_len >= netlen)) {
                 adf_os_mem_copy(wmip->cmd_rsp_buf, netdata, netlen);
                 wmip->cmd_rsp_buf += netlen;
                 wmip->cmd_rsp_len -= netlen;
diff --git a/target/linux/build/wasp/thin_driver/Makefile b/target/linux/build/wasp/thin_driver/Makefile
index f73ac6d..9afe489 100644
--- a/target/linux/build/wasp/thin_driver/Makefile
+++ b/target/linux/build/wasp/thin_driver/Makefile
@@ -121,17 +121,17 @@ atd-objs    += $(OFFLOAD_THIN_DRV)/atd/atd_netlink.o
 
 EXTRA_CFLAGS    += -DATH_SUPPORT_FLOWMAC_MODULE=0
 
-ifeq ($(strip ${OFFLOAD_LAN_BYPASS}),1)
+#ifeq ($(strip ${OFFLOAD_LAN_BYPASS}),1)
 EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=1
 atd-objs        += $(OFFLOAD_THIN_DRV)/atd/atd_byp.o
-else
-EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=0
-endif
+#else
+#EXTRA_CFLAGS    += -DOFFLOAD_LAN_BYPASS=0
+#endif
 
-ifeq ($(strip ${OFFLOAD_APPBR}),1)
+#ifeq ($(strip ${OFFLOAD_APPBR}),1)
 EXTRA_CFLAGS    += -DOFFLOAD_APPBR=1
 atd-objs        += $(OFFLOAD_THIN_DRV)/atd/atd_appbr.o
-endif
+#endif
 
 ifeq ($(strip $(OFFLOAD_GMAC_8021Q)),1)
 EXTRA_CFLAGS    += -DGMAC_8021Q_SUPPORT
diff --git a/target/linux/thin_driver/atd/atd_byp.c b/target/linux/thin_driver/atd/atd_byp.c
index 5208c49..bfbc4af 100644
--- a/target/linux/thin_driver/atd/atd_byp.c
+++ b/target/linux/thin_driver/atd/atd_byp.c
@@ -61,6 +61,7 @@ atd_byp_filter_tunnel(void *ctx, struct atd_tgt_vap *vap, struct sk_buff *skb);
 
 static struct sk_buff *
 atd_byp_filter_vlan(void *ctx, struct atd_tgt_vap *vap, struct sk_buff *skb);
+
 /** 
  * @brief 
  * 
@@ -97,7 +98,6 @@ atd_tgt_byp_init(void *atd_handle)
     BYPSC_ATDHDL(byp_sc)  =   atd_handle;
 
     BYPSC_BYPMODE(byp_sc)   =   ATD_LANBYP_DIS;
-    BYPSC_FILTER(byp_sc)    =   NULL;
 
     atd_tgt_appbr_register_cb(appbr_sc, cb, APPBR_BYP);
 
@@ -387,7 +387,7 @@ atd_tgt_byp_seten(void *ctx, byp_stat_t *buf)
  * 
  * @return 
  */
-static a_status_t 
+a_status_t
 atd_tgt_byp_addmac(void *ctx, byp_br_t *buf)
 {
 
diff --git a/target/linux/thin_driver/atd/atd_cfg.c b/target/linux/thin_driver/atd/atd_cfg.c
index dd5a6e5..a2d23bc 100644
--- a/target/linux/thin_driver/atd/atd_cfg.c
+++ b/target/linux/thin_driver/atd/atd_cfg.c
@@ -47,6 +47,8 @@
 #endif
 #include"ieee80211_external.h"
 
+a_status_t atd_tgt_byp_addmac(void *ctx, byp_br_t *buf);
+
 static int
 atd_tgt_acfg2ieee(a_uint16_t param)
 {
@@ -4092,6 +4094,9 @@ atd_tgt_dbgreq(void *ctx, a_uint16_t cmdid,
             dbgreq->data.bsteering_datarate_info.is_mu_mimo_supported =  req->data.bsteering_datarate_info.is_mu_mimo_supported;
             break;
         default:
+            atd_trace(ATD_DEBUG_CFG, ("command not supported \n"));
+            status = A_STATUS_FAILED;
+            goto fail;
             break;
     }
 
-- 
1.9.1

