Explorar o código

qcacmn: Add API to find IPV6 mcast packet

Propagation from qcacld-2.0 to qcacmn.

Add API to find IPV6 mcast packet to use it in wma_wow_wake_up_stats
func. This is required to know if there is a IPV6 mcast packet embedded
in a link layer unicast packet.

Change-Id: Ic2af69032262237b8751019817ae181913346818
CRs-Fixed: 1049254
Himanshu Agarwal %!s(int64=8) %!d(string=hai) anos
pai
achega
81ce26de0d
Modificáronse 3 ficheiros con 61 adicións e 10 borrados
  1. 17 0
      qdf/inc/qdf_nbuf.h
  2. 1 0
      qdf/linux/src/i_qdf_nbuf.h
  3. 43 10
      qdf/linux/src/qdf_nbuf.c

+ 17 - 0
qdf/inc/qdf_nbuf.h

@@ -66,6 +66,8 @@
 #define QDF_NBUF_TRAC_IPV6_PROTO_TYPE_OFFSET  20
 #define QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK    0xE0000000
 #define QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK    0xF0000000
+#define QDF_NBUF_TRAC_IPV6_DEST_ADDR_OFFSET   38
+#define QDF_NBUF_TRAC_IPV6_DEST_ADDR          0xFF00
 #define QDF_NBUF_TRAC_ICMP_TYPE         1
 #define QDF_NBUF_TRAC_TCP_TYPE          6
 #define QDF_NBUF_TRAC_UDP_TYPE          17
@@ -1554,6 +1556,21 @@ bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
 	return __qdf_nbuf_data_is_ipv4_mcast_pkt(data);
 }
 
+/**
+ * qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
+ * @data: Pointer to IPV6 packet data buffer
+ *
+ * This func. checks whether it is a IPV6 multicast packet or not.
+ *
+ * Return: TRUE if it is a IPV6 multicast packet
+ *         FALSE if not
+ */
+static inline
+bool qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data)
+{
+	return __qdf_nbuf_data_is_ipv6_mcast_pkt(data);
+}
+
 /**
  * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  * @buf: Pointer to IPV4 ICMP packet buffer

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

@@ -495,6 +495,7 @@ bool __qdf_nbuf_is_ipv4_wapi_pkt(struct sk_buff *skb);
 bool __qdf_nbuf_data_is_ipv4_pkt(uint8_t *data);
 bool __qdf_nbuf_data_is_ipv6_pkt(uint8_t *data);
 bool __qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data);
+bool __qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data);
 bool __qdf_nbuf_data_is_icmp_pkt(uint8_t *data);
 bool __qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data);
 bool __qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data);

+ 43 - 10
qdf/linux/src/qdf_nbuf.c

@@ -840,17 +840,50 @@ bool __qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
  */
 bool __qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
 {
-	uint32_t *dst_addr =
-		(uint32_t *)(data + QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET);
+	if (__qdf_nbuf_data_is_ipv4_pkt(data)) {
+		uint32_t *dst_addr =
+		      (uint32_t *)(data + QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET);
 
-	/*
-	 * Check first word of the IPV4 address and if it
-	 * equal to 0xE then it represents multicast IP.
-	 */
-	if ((*dst_addr & QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK) ==
-			QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK)
-		return true;
-	else
+		/*
+		 * Check first word of the IPV4 address and if it is
+		 * equal to 0xE then it represents multicast IP.
+		 */
+		if ((*dst_addr & QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK) ==
+				QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK)
+			return true;
+		else
+			return false;
+	} else
+		return false;
+}
+
+/**
+ * __qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
+ * @data: Pointer to IPV6 packet data buffer
+ *
+ * This func. checks whether it is a IPV6 multicast packet or not.
+ *
+ * Return: TRUE if it is a IPV6 multicast packet
+ *         FALSE if not
+ */
+bool __qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data)
+{
+	if (__qdf_nbuf_data_is_ipv6_pkt(data)) {
+		uint16_t *dst_addr;
+
+		dst_addr = (uint16_t *)
+			(data + QDF_NBUF_TRAC_IPV6_DEST_ADDR_OFFSET);
+
+		/*
+		 * Check first byte of the IP address and if it
+		 * 0xFF00 then it is a IPV6 mcast packet.
+		 */
+		if (*dst_addr ==
+		     QDF_SWAP_U16(QDF_NBUF_TRAC_IPV6_DEST_ADDR))
+			return true;
+		else
+			return false;
+	} else
 		return false;
 }