Переглянути джерело

qcacmn: Add qdf APIs to set/get IPv4/6 TOS and TC field

Add QDF APIs to set/get IPv4/6 TOS and TC field.

Change-Id: Ie048b74bacea33e9b1c57c5561064673247ee14c
CRs-Fixed: 3207377
nakul kachhwaha 3 роки тому
батько
коміт
ef9ad9d2d2
3 змінених файлів з 176 додано та 4 видалено
  1. 78 0
      qdf/inc/qdf_nbuf.h
  2. 10 4
      qdf/linux/src/i_qdf_nbuf.h
  3. 88 0
      qdf/linux/src/qdf_nbuf.c

+ 78 - 0
qdf/inc/qdf_nbuf.h

@@ -64,6 +64,7 @@
 #define QDF_NBUF_TRAC_IPV6_ETH_TYPE     0x86dd
 #define QDF_NBUF_DEST_MAC_OFFSET		0
 #define QDF_NBUF_SRC_MAC_OFFSET			6
+#define QDF_NBUF_TRAC_IPV4_TOS_OFFSET		15
 #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET  23
 #define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET   30
 #define QDF_NBUF_TRAC_IPV4_SRC_ADDR_OFFSET    26
@@ -3156,6 +3157,52 @@ qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
 	return __qdf_nbuf_data_get_icmpv6_subtype(data);
 }
 
+/**
+ * qdf_nbuf_is_ipv4_last_fragment() - Check if IPV4 packet is last fragment
+ * @nbuf: Network buffer
+ *
+ * This function check if IPV4 packet is last fragment or not.
+ * Caller has to call this function for ipv4 packets only.
+ *
+ * Return: True if ipv4 packet is last fragment otherwise false
+ */
+static inline bool
+qdf_nbuf_is_ipv4_last_fragment(qdf_nbuf_t nbuf)
+{
+	return __qdf_nbuf_is_ipv4_last_fragment(nbuf);
+}
+
+/**
+ * qdf_nbuf_data_set_ipv4_tos() - set the TOS field of IPV4 packet.
+ *
+ * @data: Pointer to IPV4 packet data buffer
+ * @tos: TOS value to be set in IPV4 packet
+ *
+ * This func. set the TOS field of IPV4 packet.
+ *
+ * Return: None
+ */
+static inline void
+qdf_nbuf_data_set_ipv4_tos(uint8_t *data, uint8_t tos)
+{
+	__qdf_nbuf_data_set_ipv4_tos(data, tos);
+}
+
+/**
+ * qdf_nbuf_data_get_ipv4_tos() - get the TOS field of IPV4 packet.
+ *
+ * @data: Pointer to IPV4 packet data buffer
+ *
+ * This func. returns the TOS field of IPV4 packet.
+ *
+ * Return: TOS of IPV4 packet.
+ */
+static inline uint8_t
+qdf_nbuf_data_get_ipv4_tos(uint8_t *data)
+{
+	return __qdf_nbuf_data_get_ipv4_tos(data);
+}
+
 /**
  * qdf_nbuf_data_get_ipv4_proto() - get the proto type
  *            of IPV4 packet.
@@ -3171,6 +3218,37 @@ qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
 	return __qdf_nbuf_data_get_ipv4_proto(data);
 }
 
+/**
+ * qdf_nbuf_data_set_ipv6_tc() - set the TC field
+ *                               of IPV6 packet.
+ * @data: Pointer to IPV6 packet data buffer
+ * @tc: Value to IPV6 packet TC field
+ *
+ * This func. set the TC field of IPV6 packet.
+ *
+ * Return: None
+ */
+static inline void
+qdf_nbuf_data_set_ipv6_tc(uint8_t *data, uint8_t tc)
+{
+	__qdf_nbuf_data_set_ipv6_tc(data, tc);
+}
+
+/**
+ * qdf_nbuf_data_get_ipv6_tc() - get the TC field
+ *                               of IPV6 packet.
+ * @data: Pointer to IPV6 packet data buffer
+ *
+ * This func. returns the TC field of IPV6 packet.
+ *
+ * Return: Traffic classification field of IPV6 packet.
+ */
+static inline uint8_t
+qdf_nbuf_data_get_ipv6_tc(uint8_t *data)
+{
+	return __qdf_nbuf_data_get_ipv6_tc(data);
+}
+
 /**
  * qdf_nbuf_data_get_ipv6_proto() - get the proto type
  *            of IPV6 packet.

+ 10 - 4
qdf/linux/src/i_qdf_nbuf.h

@@ -71,6 +71,7 @@ typedef struct sk_buff_head __qdf_nbuf_queue_head_t;
 #define QDF_NBUF_CB_PACKET_TYPE_ICMP   5
 #define QDF_NBUF_CB_PACKET_TYPE_ICMPv6 6
 #define QDF_NBUF_CB_PACKET_TYPE_DHCPV6 7
+#define QDF_NBUF_CB_PACKET_TYPE_END_INDICATION 8
 
 #define RADIOTAP_BASE_HEADER_LEN sizeof(struct ieee80211_radiotap_header)
 
@@ -357,13 +358,13 @@ struct qdf_nbuf_cb {
 					is_packet_priv:1;
 				uint8_t packet_track:3,
 					to_fw:1,
-					proto_type:4;
+					/* used only for hl */
+					htt2_frm:1,
+					proto_type:3;
 				uint8_t dp_trace:1,
 					is_bcast:1,
 					is_mcast:1,
-					packet_type:3,
-					/* used only for hl*/
-					htt2_frm:1,
+					packet_type:4,
 					print:1;
 			} trace;
 			unsigned char *vaddr;
@@ -906,6 +907,11 @@ enum qdf_proto_subtype  __qdf_nbuf_data_get_icmp_subtype(uint8_t *data);
 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);
+uint8_t __qdf_nbuf_data_get_ipv4_tos(uint8_t *data);
+uint8_t __qdf_nbuf_data_get_ipv6_tc(uint8_t *data);
+void __qdf_nbuf_data_set_ipv4_tos(uint8_t *data, uint8_t tos);
+void __qdf_nbuf_data_set_ipv6_tc(uint8_t *data, uint8_t tc);
+bool __qdf_nbuf_is_ipv4_last_fragment(struct sk_buff *skb);
 
 #ifdef QDF_NBUF_GLOBAL_COUNT
 int __qdf_nbuf_count_get(void);

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

@@ -1472,6 +1472,57 @@ __qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
 	return proto_subtype;
 }
 
+/**
+ * __qdf_nbuf_is_ipv4_last_fragment() - Check if IPv4 packet is last fragment
+ * @skb: Buffer
+ *
+ * This function checks IPv4 packet is last fragment or not.
+ * Caller has to call this function for IPv4 packets only.
+ *
+ * Return: True if IPv4 packet is last fragment otherwise false
+ */
+bool
+__qdf_nbuf_is_ipv4_last_fragment(struct sk_buff *skb)
+{
+	if (((ntohs(ip_hdr(skb)->frag_off) & ~IP_OFFSET) & IP_MF) == 0)
+		return true;
+
+	return false;
+}
+
+/**
+ * __qdf_nbuf_data_set_ipv4_tos() - set the TOS for IPv4 packet
+ * @data: pointer to skb payload
+ * @tos: value of TOS to be set
+ *
+ * This func. set the TOS field of IPv4 packet.
+ *
+ * Return: None
+ */
+void
+__qdf_nbuf_data_set_ipv4_tos(uint8_t *data, uint8_t tos)
+{
+	*(uint8_t *)(data + QDF_NBUF_TRAC_IPV4_TOS_OFFSET) = tos;
+}
+
+/**
+ * __qdf_nbuf_data_get_ipv4_tos() - get the TOS type of IPv4 packet
+ * @data: Pointer to skb payload
+ *
+ * This func. returns the TOS type of IPv4 packet.
+ *
+ * Return: TOS type of IPv4 packet.
+ */
+uint8_t
+__qdf_nbuf_data_get_ipv4_tos(uint8_t *data)
+{
+	uint8_t tos;
+
+	tos = (uint8_t)(*(uint8_t *)(data +
+			QDF_NBUF_TRAC_IPV4_TOS_OFFSET));
+	return tos;
+}
+
 /**
  * __qdf_nbuf_data_get_ipv4_proto() - get the proto type
  *            of IPV4 packet.
@@ -1491,6 +1542,43 @@ __qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
 	return proto_type;
 }
 
+/**
+ * __qdf_nbuf_data_get_ipv6_tc() - get the TC field
+ *                                 of IPv6 packet.
+ * @data: Pointer to IPv6 packet data buffer
+ *
+ * This func. returns the TC field of IPv6 packet.
+ *
+ * Return: traffic classification of IPv6 packet.
+ */
+uint8_t
+__qdf_nbuf_data_get_ipv6_tc(uint8_t *data)
+{
+	struct ipv6hdr *hdr;
+
+	hdr =  (struct ipv6hdr *)(data + QDF_NBUF_TRAC_IPV6_OFFSET);
+	return ip6_tclass(ip6_flowinfo(hdr));
+}
+
+/**
+ * __qdf_nbuf_data_set_ipv6_tc() - set the TC field
+ *                                 of IPv6 packet.
+ * @data: Pointer to skb payload
+ * @tc: value to set to IPv6 header TC field
+ *
+ * This func. set the TC field of IPv6 header.
+ *
+ * Return: None
+ */
+void
+__qdf_nbuf_data_set_ipv6_tc(uint8_t *data, uint8_t tc)
+{
+	struct ipv6hdr *hdr;
+
+	hdr =  (struct ipv6hdr *)(data + QDF_NBUF_TRAC_IPV6_OFFSET);
+	ip6_flow_hdr(hdr, tc, ip6_flowlabel(hdr));
+}
+
 /**
  * __qdf_nbuf_data_get_ipv6_proto() - get the proto type
  *            of IPV6 packet.