[dpdk-dev] [PATCH v3 09/20] i40e: report flow director match info to mbuf

Jingjing Wu jingjing.wu at intel.com
Fri Sep 26 08:03:27 CEST 2014


support to set the FDIR flag and report FD_ID in mbuf if match

Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
Acked-by: Chen Jing D(Mark) <jing.d.chen at intel.com>
Acked-by: Helin Zhang <helin.zhang at intel.com>
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 48 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 4435367..c067cdd 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -105,6 +105,10 @@ i40e_rxd_status_to_pkt_flags(uint64_t qword)
 					I40E_RX_DESC_FLTSTAT_RSS_HASH) ==
 			I40E_RX_DESC_FLTSTAT_RSS_HASH) ? PKT_RX_RSS_HASH : 0;
 
+	/* Check if FDIR Match */
+	flags |= (uint16_t)(qword & (1 << I40E_RX_DESC_STATUS_FLM_SHIFT) ?
+							PKT_RX_FDIR : 0);
+
 	return flags;
 }
 
@@ -641,6 +645,22 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq)
 			if (pkt_flags & PKT_RX_RSS_HASH)
 				mb->hash.rss = rte_le_to_cpu_32(\
 					rxdp->wb.qword0.hi_dword.rss);
+
+			if (pkt_flags & PKT_RX_FDIR) {
+#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+				if (((qword1 >> I40E_RX_DESC_STATUS_FLTSTAT_SHIFT) &
+						I40E_RX_DESC_FLTSTAT_RSS_HASH) ==
+						I40E_RX_DESC_FLTSTAT_RSV_FD_ID)
+					mb->hash.fdir.id = (uint16_t)
+						rte_le_to_cpu_32(rxdp[j].wb.qword0.hi_dword.fd);
+#else
+				if (((rxdp[j].wb.qword2.ext_status >>
+					I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
+					0x03) == 0x01)
+					mb->hash.fdir.id = (uint16_t)
+						rte_le_to_cpu_32(rxdp[j].wb.qword3.hi_dword.fd_id);
+#endif
+			}
 		}
 
 		for (j = 0; j < I40E_LOOK_AHEAD; j++)
@@ -877,6 +897,20 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		if (pkt_flags & PKT_RX_RSS_HASH)
 			rxm->hash.rss =
 				rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
+		if (pkt_flags & PKT_RX_FDIR) {
+#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+			if (((qword1 >> I40E_RX_DESC_STATUS_FLTSTAT_SHIFT) &
+					I40E_RX_DESC_FLTSTAT_RSS_HASH) ==
+					I40E_RX_DESC_FLTSTAT_RSV_FD_ID)
+				rxm->hash.fdir.id = (uint16_t)
+					rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.fd);
+#else
+			if (((rxd.wb.qword2.ext_status >> I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
+				0x03) == 0x01)
+				rxm->hash.fdir.id = (uint16_t)
+					rte_le_to_cpu_32(rxd.wb.qword3.hi_dword.fd_id);
+#endif
+		}
 
 		rx_pkts[nb_rx++] = rxm;
 	}
@@ -1031,6 +1065,20 @@ i40e_recv_scattered_pkts(void *rx_queue,
 		if (pkt_flags & PKT_RX_RSS_HASH)
 			rxm->hash.rss =
 				rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
+		if (pkt_flags & PKT_RX_FDIR) {
+#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+			if (((qword1 >> I40E_RX_DESC_STATUS_FLTSTAT_SHIFT) &
+					I40E_RX_DESC_FLTSTAT_RSS_HASH) ==
+					I40E_RX_DESC_FLTSTAT_RSV_FD_ID)
+				rxm->hash.fdir.id = (uint16_t)
+					rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.fd);
+#else
+			if (((rxd.wb.qword2.ext_status >> I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
+				0x03) == 0x01)
+				rxm->hash.fdir.id = (uint16_t)
+					rte_le_to_cpu_32(rxd.wb.qword3.hi_dword.fd_id);
+#endif
+		}
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
-- 
1.8.1.4



More information about the dev mailing list