Procházet zdrojové kódy

qcacmn: Add nbuf count support

Add a global nbuf count variable and add support to update
this count.

Change-Id: I08a50b54cae25ab9f356cd05d7635f1ba3b6bf55
CRs-Fixed: 2008240
Chaithanya Garrepalli před 7 roky
rodič
revize
221c795fea

+ 4 - 0
qdf/Kbuild

@@ -55,6 +55,10 @@ $(HOST_CMN_CONVG_NLINK)/src/wlan_nlink_srv.o \
 $(HOST_CMN_CONVG_LOGGING)/src/wlan_logging_sock_svc.o
 endif
 
+ifeq ($(WLAN_DEBUGFS),1)
+qdf-objs += linux/src/qdf_debugfs.o
+endif
+
 ifeq ($(BUILD_ADF_NET_IOCTL),1)
 EXTRA_CFLAGS+= -DADF_NET_IOCTL_SUPPORT
 #adf-objs += os/linux/adf_os_netlink_pvt.o \

+ 53 - 0
qdf/inc/qdf_nbuf.h

@@ -2683,6 +2683,59 @@ qdf_nbuf_get_timedelta_us(struct sk_buff *skb)
 	return __qdf_nbuf_get_timedelta_us(skb);
 }
 
+/**
+ * qdf_nbuf_count_get() - get global nbuf gauge
+ *
+ * Return: global nbuf gauge
+ */
+static inline int qdf_nbuf_count_get(void)
+{
+	return __qdf_nbuf_count_get();
+}
+
+/**
+ * qdf_nbuf_count_inc() - increment nbuf global count
+ *
+ * @buf: sk buff
+ *
+ * Return: void
+ */
+static inline void qdf_nbuf_count_inc(qdf_nbuf_t buf)
+{
+	return __qdf_nbuf_count_inc(buf);
+}
+
+/**
+ * qdf_nbuf_count_dec() - decrement nbuf global count
+ *
+ * @buf: sk buff
+ *
+ * Return: void
+ */
+static inline void qdf_nbuf_count_dec(qdf_nbuf_t buf)
+{
+	return __qdf_nbuf_count_dec(buf);
+}
+
+/**
+ * qdf_nbuf_mod_init() - Intialization routine for qdf_nbuf
+ *
+ * Return void
+ */
+static inline void qdf_nbuf_mod_init(void)
+{
+	return __qdf_nbuf_mod_init();
+}
+
+/**
+ * qdf_nbuf_mod_init() - Unintialization routine for qdf_nbuf
+ *
+ * Return void
+ */
+static inline void qdf_nbuf_mod_exit(void)
+{
+	return __qdf_nbuf_mod_exit();
+}
 #ifdef CONFIG_WIN
 #include <i_qdf_nbuf_api_w.h>
 #else

+ 49 - 2
qdf/linux/src/i_qdf_nbuf.h

@@ -652,6 +652,41 @@ enum qdf_proto_subtype  __qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data);
 uint8_t __qdf_nbuf_data_get_ipv4_proto(uint8_t *data);
 uint8_t __qdf_nbuf_data_get_ipv6_proto(uint8_t *data);
 
+#ifdef QDF_NBUF_GLOBAL_COUNT
+int __qdf_nbuf_count_get(void);
+void __qdf_nbuf_count_inc(struct sk_buff *skb);
+void __qdf_nbuf_count_dec(struct sk_buff *skb);
+void __qdf_nbuf_mod_init(void);
+void __qdf_nbuf_mod_exit(void);
+
+#else
+
+static inline int __qdf_nbuf_count_get(void)
+{
+	return 0;
+}
+
+static inline void __qdf_nbuf_count_inc(struct sk_buff *skb)
+{
+	return;
+}
+
+static inline void __qdf_nbuf_count_dec(struct sk_buff *skb)
+{
+	return;
+}
+
+static inline void __qdf_nbuf_mod_init(void)
+{
+	return;
+}
+
+static inline void __qdf_nbuf_mod_exit(void)
+{
+	return;
+}
+#endif
+
 /**
  * __qdf_to_status() - OS to QDF status conversion
  * @error : OS error
@@ -814,7 +849,13 @@ int __qdf_nbuf_shared(struct sk_buff *skb);
  */
 static inline struct sk_buff *__qdf_nbuf_clone(struct sk_buff *skb)
 {
-	return skb_clone(skb, GFP_ATOMIC);
+	struct sk_buff *skb_new = NULL;
+
+	skb_new = skb_clone(skb, GFP_ATOMIC);
+	if (skb_new)
+		__qdf_nbuf_count_inc(skb_new);
+
+	return skb_new;
 }
 
 /**
@@ -828,7 +869,13 @@ static inline struct sk_buff *__qdf_nbuf_clone(struct sk_buff *skb)
  */
 static inline struct sk_buff *__qdf_nbuf_copy(struct sk_buff *skb)
 {
-	return skb_copy(skb, GFP_ATOMIC);
+	struct sk_buff *skb_new = NULL;
+
+	skb_new = skb_copy(skb, GFP_ATOMIC);
+	if (skb_new)
+		__qdf_nbuf_count_inc(skb_new);
+
+	return skb_new;
 }
 
 #define __qdf_nbuf_reserve      skb_reserve

+ 1 - 0
qdf/linux/src/qdf_debugfs.c

@@ -59,6 +59,7 @@ qdf_dentry_t qdf_debugfs_get_root(void)
 {
 	return qdf_debugfs_root;
 }
+qdf_export_symbol(qdf_debugfs_get_root);
 
 umode_t qdf_debugfs_get_filemode(uint16_t mode)
 {

+ 4 - 1
qdf/linux/src/qdf_module.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <qdf_perf.h>
 #include <qdf_trace.h>
+#include <qdf_nbuf.h>
 
 MODULE_AUTHOR("Qualcomm Atheros Inc.");
 MODULE_DESCRIPTION("Qualcomm Atheros Device Framework Module");
@@ -53,6 +54,7 @@ qdf_mod_init(void)
 	qdf_shared_print_ctrl_init();
 	qdf_logging_init();
 	qdf_perfmod_init();
+	qdf_nbuf_mod_init();
 	return 0;
 }
 module_init(qdf_mod_init);
@@ -65,6 +67,7 @@ module_init(qdf_mod_init);
 static void __exit
 qdf_mod_exit(void)
 {
+	qdf_nbuf_mod_exit();
 	qdf_perfmod_exit();
 	qdf_logging_exit();
 	qdf_shared_print_ctrl_cleanup();

+ 90 - 0
qdf/linux/src/qdf_nbuf.c

@@ -35,12 +35,15 @@
 #include <linux/version.h>
 #include <linux/skbuff.h>
 #include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <qdf_atomic.h>
 #include <qdf_types.h>
 #include <qdf_nbuf.h>
 #include <qdf_mem.h>
 #include <qdf_status.h>
 #include <qdf_lock.h>
 #include <qdf_trace.h>
+#include <qdf_debugfs.h>
 #include <net/ieee80211_radiotap.h>
 #include <qdf_module.h>
 #include <qdf_atomic.h>
@@ -94,6 +97,10 @@ static struct qdf_track_timer alloc_track_timer;
 /* Packet Counter */
 static uint32_t nbuf_tx_mgmt[QDF_NBUF_TX_PKT_STATE_MAX];
 static uint32_t nbuf_tx_data[QDF_NBUF_TX_PKT_STATE_MAX];
+#ifdef QDF_NBUF_GLOBAL_COUNT
+#define NBUF_DEBUGFS_NAME      "nbuf_counters"
+static qdf_atomic_t nbuf_count;
+#endif
 
 /**
  * qdf_nbuf_tx_desc_count_display() - Displays the packet counter
@@ -294,6 +301,47 @@ static inline void __qdf_nbuf_stop_replenish_timer(void) {}
 qdf_nbuf_trace_update_t qdf_trace_update_cb;
 qdf_nbuf_free_t nbuf_free_cb;
 
+#ifdef QDF_NBUF_GLOBAL_COUNT
+
+/**
+ * __qdf_nbuf_count_get() - get nbuf global count
+ *
+ * Return: nbuf global count
+ */
+int __qdf_nbuf_count_get(void)
+{
+	return qdf_atomic_read(&nbuf_count);
+}
+EXPORT_SYMBOL(__qdf_nbuf_count_get);
+
+/**
+ * __qdf_nbuf_count_inc() - increment nbuf global count
+ *
+ * @buf: sk buff
+ *
+ * Return: void
+ */
+void __qdf_nbuf_count_inc(qdf_nbuf_t nbuf)
+{
+	qdf_atomic_inc(&nbuf_count);
+}
+EXPORT_SYMBOL(__qdf_nbuf_count_inc);
+
+/**
+ * __qdf_nbuf_count_dec() - decrement nbuf global count
+ *
+ * @buf: sk buff
+ *
+ * Return: void
+ */
+void __qdf_nbuf_count_dec(__qdf_nbuf_t nbuf)
+{
+	qdf_atomic_dec(&nbuf_count);
+}
+EXPORT_SYMBOL(__qdf_nbuf_count_dec);
+#endif
+
+
 /**
  * __qdf_nbuf_alloc() - Allocate nbuf
  * @hdl: Device handle
@@ -374,6 +422,7 @@ skb_alloc:
 	 * pointer
 	 */
 	skb_reserve(skb, reserve);
+	qdf_nbuf_count_inc(skb);
 
 	return skb;
 }
@@ -433,6 +482,7 @@ skb_alloc:
 	 * pointer
 	 */
 	skb_reserve(skb, reserve);
+	qdf_nbuf_count_inc(skb);
 
 	return skb;
 }
@@ -452,6 +502,7 @@ void __qdf_nbuf_free(struct sk_buff *skb)
 	if (pld_nbuf_pre_alloc_free(skb))
 		return;
 
+	qdf_nbuf_count_dec(skb);
 	if (nbuf_free_cb)
 		nbuf_free_cb(skb);
 	else
@@ -463,6 +514,7 @@ void __qdf_nbuf_free(struct sk_buff *skb)
 	if (pld_nbuf_pre_alloc_free(skb))
 		return;
 
+	qdf_nbuf_count_dec(skb);
 	dev_kfree_skb_any(skb);
 }
 #endif
@@ -3682,3 +3734,41 @@ void qdf_nbuf_init_fast(qdf_nbuf_t nbuf)
 EXPORT_SYMBOL(qdf_nbuf_init_fast);
 #endif /* WLAN_FEATURE_FASTPATH */
 
+
+#ifdef QDF_NBUF_GLOBAL_COUNT
+#ifdef WLAN_DEBUGFS
+/**
+ * __qdf_nbuf_mod_init() - Intialization routine for qdf_nuf
+ *
+ * Return void
+ */
+void __qdf_nbuf_mod_init(void)
+{
+	qdf_atomic_init(&nbuf_count);
+	qdf_debugfs_init();
+	qdf_debugfs_create_atomic(NBUF_DEBUGFS_NAME, S_IRUSR, NULL, &nbuf_count);
+}
+
+/**
+ * __qdf_nbuf_mod_init() - Unintialization routine for qdf_nuf
+ *
+ * Return void
+ */
+void __qdf_nbuf_mod_exit(void)
+{
+	qdf_debugfs_exit();
+}
+
+#else
+
+void __qdf_nbuf_mod_init(void)
+{
+	qdf_atomic_init(&nbuf_count);
+}
+
+void __qdf_nbuf_mod_exit(void)
+{
+}
+
+#endif
+#endif