Merge "[qca-nss-drv] cleanup in NSS CAPWAP"
diff --git a/exports/nss_capwap.h b/exports/nss_capwap.h
index 0ad6dd6..f94b52f 100644
--- a/exports/nss_capwap.h
+++ b/exports/nss_capwap.h
@@ -175,8 +175,8 @@
uint32_t stats_timer; /**< Stats interval timer in mill-seconds */
int8_t rps; /**< Core to choose for receiving packets. Set to -1 for NSS FW to decide */
uint8_t type_flags; /**< VLAN and/or PPPOE configured */
- uint8_t l3_proto; /**< 0=IPv4 or 1=IPv6 */
- uint8_t which_udp; /**< 0=UDP or 1=UDPLite */
+ uint8_t l3_proto; /**< NSS_CAPWAP_TUNNEL_IPV4 or NSS_CAPWAP_TUNNEL_IPV6 */
+ uint8_t which_udp; /**< NSS_CAPWAP_TUNNEL_UDP or NSS_CAPWAP_TUNNEL_UDPLite */
};
/**
diff --git a/nss_capwap.c b/nss_capwap.c
index 8f27ed4..e2c0ff1 100644
--- a/nss_capwap.c
+++ b/nss_capwap.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -37,7 +37,7 @@
*/
struct nss_capwap_handle {
atomic_t refcnt; /**< Reference count on the tunnel */
- uint32_t interface_num; /**< Interface number */
+ uint32_t if_num; /**< Interface number */
uint32_t tunnel_status; /**< 0=disable, 1=enabled */
struct nss_ctx_instance *ctx; /**< Pointer to context */
nss_capwap_msg_callback_t msg_callback; /**< Msg callback */
@@ -91,10 +91,10 @@
}
/*
- * nss_capwap_get_refcnt()
+ * nss_capwap_refcnt()
* Get refcnt on the tunnel.
*/
-static uint32_t nss_capwap_get_refcnt(int32_t if_num)
+static uint32_t nss_capwap_refcnt(int32_t if_num)
{
if_num = if_num - NSS_DYNAMIC_IF_START;
return atomic_read(&nss_capwap_hdl[if_num]->refcnt);
@@ -118,10 +118,10 @@
}
/*
- * nss_capwap_get_msg_callback()
+ * nss_capwap_msg_callback()
* This gets the message callback handler and its associated context
*/
-static nss_capwap_msg_callback_t nss_capwap_get_msg_callback(int32_t if_num, void **app_data)
+static nss_capwap_msg_callback_t nss_capwap_msg_callback(int32_t if_num, void **app_data)
{
struct nss_capwap_handle *h;
@@ -175,7 +175,7 @@
* nss_capwap_handler()
* Handle NSS -> HLOS messages for CAPWAP
*/
-static void nss_capwap_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data)
+static void nss_capwap_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data)
{
struct nss_capwap_msg *ntm = (struct nss_capwap_msg *)ncm;
nss_capwap_msg_callback_t cb;
@@ -212,8 +212,9 @@
if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
void *app_data;
- ncm->cb = (uint32_t)nss_capwap_get_msg_callback(ncm->interface, &app_data);
- ncm->app_data = (uint32_t)app_data;
+ ncm->cb = (uint32_t)nss_capwap_msg_callback(ncm->interface, &app_data);
+ } else {
+ app_data = (void *)ncm->app_data;
}
/*
@@ -225,7 +226,7 @@
}
cb = (nss_capwap_msg_callback_t)ncm->cb;
- cb((void *)ncm->app_data, ntm);
+ cb(app_data, ntm);
}
/*
@@ -244,10 +245,9 @@
nss_warning("%p: no memory for allocating CAPWAP instance for interface : %d", nss_ctx, if_num);
return false;
}
- memset(h, 0, sizeof (struct nss_capwap_handle));
- atomic_set(&h->refcnt, 0);
- memset(&h->stats, 0, sizeof (struct nss_capwap_tunnel_stats));
- h->interface_num = if_num;
+
+ memset(h, 0, sizeof(struct nss_capwap_handle));
+ h->if_num = if_num;
spin_lock(&nss_capwap_spinlock);
if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) {
@@ -443,7 +443,7 @@
* It's the responsibility of caller to wait and call us again. We return failure saying
* that we can't remove msg handler now.
*/
- if (nss_capwap_get_refcnt(if_num) != 0) {
+ if (nss_capwap_refcnt(if_num) != 0) {
spin_unlock(&nss_capwap_spinlock);
nss_warning("%p: notify unregister tunnel %d: has reference", nss_ctx, if_num);
return NSS_TX_FAILURE_QUEUE;
@@ -517,7 +517,7 @@
/*
* It's the responsibility of caller to wait and call us again.
*/
- if (nss_capwap_get_refcnt(if_num) != 0) {
+ if (nss_capwap_refcnt(if_num) != 0) {
spin_unlock(&nss_capwap_spinlock);
nss_warning("%p: notify unregister tunnel %d: has reference", nss_ctx, if_num);
return false;