瀏覽代碼

qcacmn: Add API to find IPV4 mcast packet

Propagation from qcacld-2.0 to qcacmn.

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

Change-Id: Iceaf1226edbf909ca3881e049c33f7d121860ef2
CRs-fixed: 1049254
Himanshu Agarwal 8 年之前
父節點
當前提交
bf1a7c223b
共有 3 個文件被更改,包括 44 次插入0 次删除
  1. 18 0
      qdf/inc/qdf_nbuf.h
  2. 1 0
      qdf/linux/src/i_qdf_nbuf.h
  3. 25 0
      qdf/linux/src/qdf_nbuf.c

+ 18 - 0
qdf/inc/qdf_nbuf.h

@@ -62,7 +62,10 @@
 #define QDF_NBUF_DEST_MAC_OFFSET		0
 #define QDF_NBUF_SRC_MAC_OFFSET			6
 #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET  23
+#define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET   30
 #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_ICMP_TYPE         1
 #define QDF_NBUF_TRAC_TCP_TYPE          6
 #define QDF_NBUF_TRAC_UDP_TYPE          17
@@ -1536,6 +1539,21 @@ bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
 	return __qdf_nbuf_data_is_ipv6_pkt(data);
 }
 
+/**
+ * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
+ * @data: Pointer to IPV4 packet data buffer
+ *
+ * This func. checks whether it is a IPV4 multicast packet or not.
+ *
+ * Return: TRUE if it is a IPV4 multicast packet
+ *         FALSE if not
+ */
+static inline
+bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
+{
+	return __qdf_nbuf_data_is_ipv4_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

@@ -494,6 +494,7 @@ QDF_STATUS __qdf_nbuf_frag_map(
 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_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);

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

@@ -829,6 +829,31 @@ bool __qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
 		return false;
 }
 
+/**
+ * __qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
+ * @data: Pointer to IPV4 packet data buffer
+ *
+ * This func. checks whether it is a IPV4 multicast packet or not.
+ *
+ * Return: TRUE if it is a IPV4 multicast packet
+ *         FALSE if not
+ */
+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);
+
+	/*
+	 * 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
+		return false;
+}
+
 /**
  * __qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  * @data: Pointer to IPV4 ICMP packet data buffer