Explorar el Código

qcacmn: Parse tx packets only once in tx datapath

Classify tx packets at one place and store packet type in
skb cb structure to avoid multiple check to determine
packet type at various layers.

Change-Id: If39fb1c9741bb213c7f22e0dfe7f662a256e637c
CRs-Fixed: 1022454
Nirav Shah hace 8 años
padre
commit
9c3b3fe251
Se han modificado 4 ficheros con 76 adiciones y 66 borrados
  1. 15 0
      qdf/inc/qdf_nbuf.h
  2. 30 25
      qdf/linux/src/i_qdf_nbuf.h
  3. 22 0
      qdf/linux/src/qdf_nbuf.c
  4. 9 41
      qdf/linux/src/qdf_trace.c

+ 15 - 0
qdf/inc/qdf_nbuf.h

@@ -55,6 +55,7 @@
 #define QDF_NBUF_TRAC_DHCP_CLI_PORT		68
 #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET		12
 #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE		0x888E
+#define QDF_NBUF_TRAC_WAPI_ETH_TYPE		0x88b4
 #define QDF_NBUF_TRAC_ARP_ETH_TYPE		0x0806
 #define QDF_NBUF_DEST_MAC_OFFSET		0
 #define QDF_NBUF_SRC_MAC_OFFSET			6
@@ -1126,6 +1127,20 @@ bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
 	return __qdf_nbuf_is_ipv4_eapol_pkt(buf);
 }
 
+/**
+ * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not
+ * @buf:  buffer
+ *
+ * This api is for ipv4 packet.
+ *
+ * Return: true if packet is WAPI packet
+ */
+static inline
+bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf)
+{
+	return __qdf_nbuf_is_ipv4_wapi_pkt(buf);
+}
+
 /**
  * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  * @buf:  buffer

+ 30 - 25
qdf/linux/src/i_qdf_nbuf.h

@@ -60,6 +60,10 @@ typedef struct sk_buff *__qdf_nbuf_t;
  * The driver will always add one tx fragment (the tx descriptor)
  */
 #define QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS 2
+#define QDF_NBUF_CB_PACKET_TYPE_EAPOL  1
+#define QDF_NBUF_CB_PACKET_TYPE_ARP    2
+#define QDF_NBUF_CB_PACKET_TYPE_WAPI   3
+#define QDF_NBUF_CB_PACKET_TYPE_DHCP   4
 
 /*
  * Make sure that qdf_dma_addr_t in the cb block is always 64 bit aligned
@@ -171,24 +175,18 @@ struct qdf_nbuf_cb {
 				} win; /* 21 bytes*/
 				struct {
 					uint32_t data_attr; /* 4 bytes */
-					union {
-						struct {
-							uint8_t packet_state;
-							uint8_t packet_track:4,
-								proto_type:4;
-							uint8_t dp_trace:1,
-								htt2_frm:1,
-								rsrvd:6;
-							uint8_t vdev_id;
-						} hl;
-						struct {
-							uint8_t packet_state;
-							uint8_t packet_track:4,
-								proto_type:4;
-							uint8_t dp_trace:1,
-								rsrvd:7;
-							uint8_t vdev_id;
-						} ll; /* low latency */
+					struct{
+						uint8_t packet_state;
+						uint8_t packet_track:4,
+							proto_type:4;
+						uint8_t dp_trace:1,
+							is_bcast:1,
+							is_mcast:1,
+							packet_type:3,
+							/* used only for hl*/
+							htt2_frm:1,
+							reserved:1;
+						uint8_t vdev_id;
 					} trace; /* 4 bytes */
 					struct {
 						uint32_t owned:1,
@@ -266,23 +264,29 @@ struct qdf_nbuf_cb {
 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.data_attr)
 #define QDF_NBUF_CB_TX_PACKET_STATE(skb) \
 	(((struct qdf_nbuf_cb *) \
-		((skb)->cb))->u.tx.dev.mcl.trace.ll.packet_state)
+		((skb)->cb))->u.tx.dev.mcl.trace.packet_state)
 #define QDF_NBUF_CB_TX_PACKET_TRACK(skb) \
 	(((struct qdf_nbuf_cb *) \
-		((skb)->cb))->u.tx.dev.mcl.trace.ll.packet_track)
+		((skb)->cb))->u.tx.dev.mcl.trace.packet_track)
 #define QDF_NBUF_CB_TX_PROTO_TYPE(skb) \
 	(((struct qdf_nbuf_cb *) \
-		((skb)->cb))->u.tx.dev.mcl.trace.ll.proto_type)
+		((skb)->cb))->u.tx.dev.mcl.trace.proto_type)
 #define QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, PACKET_STATE) \
 	qdf_nbuf_set_state(skb, PACKET_STATE)
 #define QDF_NBUF_GET_PACKET_TRACK(skb) \
-	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.ll.packet_track)
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.packet_track)
 #define QDF_NBUF_CB_TX_DP_TRACE(skb) \
-	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.ll.dp_trace)
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.dp_trace)
 #define QDF_NBUF_CB_TX_HL_HTT2_FRM(skb) \
-	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.hl.htt2_frm)
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.htt2_frm)
 #define QDF_NBUF_CB_TX_VDEV_ID(skb) \
-	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.ll.vdev_id)
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.vdev_id)
+#define QDF_NBUF_CB_GET_IS_BCAST(skb) \
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.is_bcast)
+#define QDF_NBUF_CB_GET_IS_MCAST(skb) \
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.is_mcast)
+#define QDF_NBUF_CB_GET_PACKET_TYPE(skb) \
+	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.trace.packet_type)
 #define QDF_NBUF_CB_TX_IPA_OWNED(skb) \
 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.mcl.ipa.owned)
 #define QDF_NBUF_CB_TX_IPA_PRIV(skb) \
@@ -490,6 +494,7 @@ bool __qdf_nbuf_is_ipv4_pkt(struct sk_buff *skb);
 bool __qdf_nbuf_is_ipv4_dhcp_pkt(struct sk_buff *skb);
 bool __qdf_nbuf_is_ipv4_eapol_pkt(struct sk_buff *skb);
 bool __qdf_nbuf_is_ipv4_arp_pkt(struct sk_buff *skb);
+bool __qdf_nbuf_is_ipv4_wapi_pkt(struct sk_buff *skb);
 
 /**
  * __qdf_to_status() - OS to QDF status conversion

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

@@ -533,6 +533,28 @@ bool __qdf_nbuf_is_ipv4_eapol_pkt(struct sk_buff *skb)
 		return false;
 }
 
+/**
+ * __qdf_nbuf_is_ipv4_wapi_pkt() - check if skb data is a wapi packet
+ * @skb: Pointer to network buffer
+ *
+ * This api is for ipv4 packet.
+ *
+ * Return: true if packet is WAPI packet
+ *	   false otherwise.
+ */
+bool __qdf_nbuf_is_ipv4_wapi_pkt(struct sk_buff *skb)
+{
+	uint16_t ether_type;
+
+	ether_type = (uint16_t)(*(uint16_t *)(skb->data +
+				QDF_NBUF_TRAC_ETH_TYPE_OFFSET));
+
+	if (ether_type == QDF_SWAP_U16(QDF_NBUF_TRAC_WAPI_ETH_TYPE))
+		return true;
+	else
+		return false;
+}
+
 /**
  * __qdf_nbuf_is_ipv4_arp_pkt() - check if skb data is a eapol packet
  * @skb: Pointer to network buffer

+ 9 - 41
qdf/linux/src/qdf_trace.c

@@ -1114,43 +1114,6 @@ void qdf_dp_add_record(enum QDF_DP_TRACE_ID code,
 }
 EXPORT_SYMBOL(qdf_dp_add_record);
 
-/**
- * qdf_event_eapol_log() - send event to wlan diag
- * @skb: skb ptr
- * @dir: direction
- * @eapol_key_info: eapol key info
- *
- * Return: None
- */
-#ifdef FEATURE_WLAN_DIAG_SUPPORT
-static void qdf_event_eapol_log(struct sk_buff *skb, enum qdf_proto_dir dir,
-				int16_t eapol_key_info)
-{
-	WLAN_HOST_DIAG_EVENT_DEF(wlan_diag_event, struct host_event_wlan_eapol);
-
-	wlan_diag_event.event_sub_type =
-		(dir == QDF_TX ?
-		 WIFI_EVENT_DRIVER_EAPOL_FRAME_TRANSMIT_REQUESTED :
-		 WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED);
-	wlan_diag_event.eapol_packet_type = (uint8_t)(*(uint8_t *)
-				(skb->data + EAPOL_PACKET_TYPE_OFFSET));
-	wlan_diag_event.eapol_key_info = eapol_key_info;
-	wlan_diag_event.eapol_rate = 0;
-	qdf_mem_copy(wlan_diag_event.dest_addr,
-			(skb->data + QDF_NBUF_DEST_MAC_OFFSET),
-			sizeof(wlan_diag_event.dest_addr));
-	qdf_mem_copy(wlan_diag_event.src_addr,
-			(skb->data + QDF_NBUF_SRC_MAC_OFFSET),
-			sizeof(wlan_diag_event.src_addr));
-
-	WLAN_HOST_DIAG_EVENT_REPORT(&wlan_diag_event, EVENT_WLAN_EAPOL);
-}
-#else
-static void qdf_event_eapol_log(struct sk_buff *skb, enum qdf_proto_dir dir,
-				int16_t eapol_key_info)
-{
-}
-#endif
 
 /**
  * qdf_log_eapol_pkt() - log EAPOL packet
@@ -1168,7 +1131,9 @@ bool qdf_log_eapol_pkt(uint8_t session_id, struct sk_buff *skb,
 	enum qdf_proto_subtype subtype;
 
 	if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_EAPOL) &&
-		qdf_nbuf_is_ipv4_eapol_pkt(skb) == true) {
+		((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_EAPOL ==
+			QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
+		 (dir == QDF_RX && qdf_nbuf_is_ipv4_eapol_pkt(skb) == true))) {
 
 		eapol_key_info = (uint16_t)(*(uint16_t *)
 					(skb->data + EAPOL_KEY_INFO_OFFSET));
@@ -1194,7 +1159,6 @@ bool qdf_log_eapol_pkt(uint8_t session_id, struct sk_buff *skb,
 			session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET),
 			(skb->data + QDF_NBUF_DEST_MAC_OFFSET),
 			QDF_PROTO_TYPE_EAPOL, subtype, dir));
-		qdf_event_eapol_log(skb, dir, eapol_key_info);
 		if (QDF_TX == dir)
 			QDF_NBUF_CB_TX_DP_TRACE(skb) = 1;
 		else if (QDF_RX == dir)
@@ -1219,7 +1183,9 @@ bool qdf_log_dhcp_pkt(uint8_t session_id, struct sk_buff *skb,
 	enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
 
 	if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_DHCP) &&
-		qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true) {
+		((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP ==
+				QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
+		 (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) {
 
 		if ((skb->data[QDF_DHCP_OPTION53_OFFSET] == QDF_DHCP_OPTION53) &&
 		    (skb->data[QDF_DHCP_OPTION53_LENGTH_OFFSET] ==
@@ -1283,7 +1249,9 @@ bool qdf_log_arp_pkt(uint8_t session_id, struct sk_buff *skb,
 	enum qdf_proto_subtype proto_subtype;
 
 	if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ARP) &&
-	     qdf_nbuf_is_ipv4_arp_pkt(skb) == true) {
+		((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_ARP ==
+			QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
+		 (dir == QDF_RX && qdf_nbuf_is_ipv4_arp_pkt(skb) == true))) {
 
 		subtype = (uint16_t)(*(uint16_t *)
 			(skb->data + ARP_SUB_TYPE_OFFSET));