@@ -8,6 +8,28 @@
#include "iavf_trace.h"
#include "iavf_prototype.h"
+/**
+ * iavf_is_descriptor_done - tests DD bit in Rx descriptor
+ * @rx_ring: the ring parameter to distinguish descriptor type (flex/legacy)
+ * @rx_desc: pointer to receive descriptor
+ *
+ * This function tests the descriptor done bit in specified descriptor. Because
+ * there are two types of descriptors (legacy and flex) the parameter rx_ring
+ * is used to distinguish.
+ */
+static bool iavf_is_descriptor_done(struct iavf_ring *rx_ring,
+ union iavf_rx_desc *rx_desc)
+{
+ u64 status_error_len = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
+
+ if (rx_ring->rxdid == VIRTCHNL_RXDID_1_32B_BASE)
+ return !!(FIELD_GET(IAVF_RX_DESC_STATUS_DD_MASK,
+ status_error_len));
+
+ return !!(FIELD_GET((IAVF_RX_FLEX_DESC_STATUS_ERR0_DD_BIT),
+ le16_to_cpu(rx_desc->flex_wb.status_error0)));
+}
+
static __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
u32 td_tag)
{
@@ -1718,7 +1740,11 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget)
* verified the descriptor has been written back.
*/
dma_rmb();
- if (!iavf_test_staterr(rx_desc, IAVF_RX_DESC_STATUS_DD_MASK))
+
+ /* If DD field (descriptor done) is unset then other fields are
+ * not valid
+ */
+ if (!iavf_is_descriptor_done(rx_ring, rx_desc))
break;
iavf_extract_rx_fields(rx_ring, rx_desc, &fields);
@@ -153,23 +153,6 @@ static inline int iavf_skb_pad(void)
#define IAVF_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
#endif
-/**
- * iavf_test_staterr - tests bits in Rx descriptor status and error fields
- * @rx_desc: pointer to receive descriptor (in le64 format)
- * @stat_err_bits: value to mask
- *
- * This function does some fast chicanery in order to return the
- * value of the mask which is really only used for boolean tests.
- * The status_error_len doesn't need to be shifted because it begins
- * at offset zero.
- */
-static inline bool iavf_test_staterr(union iavf_rx_desc *rx_desc,
- const u64 stat_err_bits)
-{
- return !!(rx_desc->wb.qword1.status_error_len &
- cpu_to_le64(stat_err_bits));
-}
-
struct iavf_rx_extracted {
unsigned int size;
u16 vlan_tag;
@@ -318,6 +318,7 @@ union iavf_32byte_rx_desc {
*/
#define IAVF_RX_DESC_STATUS_INT_UDP_0_MASK BIT(18)
+#define IAVF_RX_FLEX_DESC_STATUS_ERR0_DD_BIT BIT(0)
#define IAVF_RX_FLEX_DESC_STATUS_ERR0_EOP_BIT BIT(1)
#define IAVF_RX_FLEX_DESC_STATUS_ERR0_RXE_BIT BIT(10)