Эх сурвалжийг харах

qcacmn: Add QDF APIs for dev_scratch in network buffer

Kernel 4.14 and later supports dev_scratch for network
buffer which can be used to store data in a nbuf in the
format unsigned long.

Add APIs:
 1) qdf_nbuf_is_dev_scratch_supported
 2) qdf_nbuf_get_dev_scratch
 3) qdf_nbuf_set_dev_scratch

Change-Id: I2a72d369bb53f8f86d4bcee3cf6d13f5e4aff57f
CRs-Fixed: 2313270
Rakshith Suresh Patkar 6 жил өмнө
parent
commit
ecd7d60c6a

+ 36 - 0
qdf/inc/qdf_nbuf.h

@@ -1588,6 +1588,42 @@ static inline void qdf_nbuf_reset(qdf_nbuf_t buf, int reserve, int align)
 	__qdf_nbuf_reset(buf, reserve, align);
 }
 
+/**
+ * qdf_nbuf_dev_scratch_is_supported() - dev_scratch support for network buffer
+ *                                       in kernel
+ *
+ * Return: true if dev_scratch is supported
+ *         false if dev_scratch is not supported
+ */
+static inline bool qdf_nbuf_is_dev_scratch_supported(void)
+{
+	return __qdf_nbuf_is_dev_scratch_supported();
+}
+
+/**
+ * qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer
+ * @buf: Pointer to network buffer
+ *
+ * Return: dev_scratch if dev_scratch supported
+ *         0 if dev_scratch not supported
+ */
+static inline unsigned long qdf_nbuf_get_dev_scratch(qdf_nbuf_t buf)
+{
+	return __qdf_nbuf_get_dev_scratch(buf);
+}
+
+/**
+ * qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer
+ * @buf: Pointer to network buffer
+ * @value: value to be set in dev_scratch of network buffer
+ *
+ * Return: void
+ */
+static inline void qdf_nbuf_set_dev_scratch(qdf_nbuf_t buf, unsigned long value)
+{
+	__qdf_nbuf_set_dev_scratch(buf, value);
+}
+
 /**
  * qdf_nbuf_peek_header() - return the data pointer & length of the header
  * @buf: Network nbuf

+ 55 - 0
qdf/linux/src/i_qdf_nbuf.h

@@ -28,6 +28,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/dma-mapping.h>
+#include <linux/version.h>
 #include <asm/cacheflush.h>
 #include <qdf_types.h>
 #include <qdf_net_types.h>
@@ -961,6 +962,60 @@ __qdf_nbuf_reset(struct sk_buff *skb, int reserve, int align)
 	skb_reserve(skb, reserve);
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
+/**
+ * qdf_nbuf_dev_scratch_is_supported() - dev_scratch support for network buffer
+ *                                       in kernel
+ *
+ * Return: true if dev_scratch is supported
+ *         false if dev_scratch is not supported
+ */
+static inline bool __qdf_nbuf_is_dev_scratch_supported(void)
+{
+	return true;
+}
+
+/**
+ * qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer
+ * @skb: Pointer to network buffer
+ *
+ * Return: dev_scratch if dev_scratch supported
+ *         0 if dev_scratch not supported
+ */
+static inline unsigned long __qdf_nbuf_get_dev_scratch(struct sk_buff *skb)
+{
+	return skb->dev_scratch;
+}
+
+/**
+ * qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer
+ * @skb: Pointer to network buffer
+ * @value: value to be set in dev_scratch of network buffer
+ *
+ * Return: void
+ */
+static inline void
+__qdf_nbuf_set_dev_scratch(struct sk_buff *skb, unsigned long value)
+{
+	skb->dev_scratch = value;
+}
+#else
+static inline bool __qdf_nbuf_is_dev_scratch_supported(void)
+{
+	return false;
+}
+
+static inline unsigned long __qdf_nbuf_get_dev_scratch(struct sk_buff *skb)
+{
+	return 0;
+}
+
+static inline void
+__qdf_nbuf_set_dev_scratch(struct sk_buff *skb, unsigned long value)
+{
+}
+#endif /* KERNEL_VERSION(4, 14, 0) */
+
 /**
  * __qdf_nbuf_head() - return the pointer the skb's head pointer
  * @skb: Pointer to network buffer