99#include "iavf_trace.h"
1010#include "iavf_prototype.h"
1111
12+ /**
13+ * iavf_is_descriptor_done - tests DD bit in Rx descriptor
14+ * @qw1: quad word 1 from descriptor to get Descriptor Done field from
15+ * @flex: is the descriptor flex or legacy
16+ *
17+ * This function tests the descriptor done bit in specified descriptor. Because
18+ * there are two types of descriptors (legacy and flex) the parameter rx_ring
19+ * is used to distinguish.
20+ *
21+ * Return: true or false based on the state of DD bit in Rx descriptor.
22+ */
23+ static bool iavf_is_descriptor_done (u64 qw1 , bool flex )
24+ {
25+ if (flex )
26+ return FIELD_GET (IAVF_RXD_FLEX_DD_M , qw1 );
27+ else
28+ return FIELD_GET (IAVF_RXD_LEGACY_DD_M , qw1 );
29+ }
30+
1231static __le64 build_ctob (u32 td_cmd , u32 td_offset , unsigned int size ,
1332 u32 td_tag )
1433{
@@ -1063,14 +1082,16 @@ static void iavf_flex_rx_hash(const struct iavf_ring *ring, __le64 qw1,
10631082 * @rx_desc: pointer to the EOP Rx descriptor
10641083 * @skb: pointer to current skb being populated
10651084 * @ptype: the packet type decoded by hardware
1085+ * @flex: is the descriptor flex or legacy
10661086 *
10671087 * This function checks the ring, descriptor, and packet information in
10681088 * order to populate the hash, checksum, VLAN, protocol, and
10691089 * other fields within the skb.
10701090 **/
10711091static void iavf_process_skb_fields (const struct iavf_ring * rx_ring ,
10721092 const struct iavf_rx_desc * rx_desc ,
1073- struct sk_buff * skb , u32 ptype )
1093+ struct sk_buff * skb , u32 ptype ,
1094+ bool flex )
10741095{
10751096 struct libeth_rx_csum csum_bits ;
10761097 struct libeth_rx_pt decoded_pt ;
@@ -1079,14 +1100,14 @@ static void iavf_process_skb_fields(const struct iavf_ring *rx_ring,
10791100
10801101 decoded_pt = libie_rx_pt_parse (ptype );
10811102
1082- if (rx_ring -> rxdid == VIRTCHNL_RXDID_1_32B_BASE ) {
1083- iavf_legacy_rx_hash (rx_ring , qw0 , qw1 , skb , decoded_pt );
1084- csum_bits = iavf_legacy_rx_csum (rx_ring -> vsi , le64_to_cpu (qw1 ),
1085- decoded_pt );
1086- } else {
1103+ if (flex ) {
10871104 iavf_flex_rx_hash (rx_ring , qw1 , skb , decoded_pt );
10881105 csum_bits = iavf_flex_rx_csum (rx_ring -> vsi , le64_to_cpu (qw1 ),
10891106 decoded_pt );
1107+ } else {
1108+ iavf_legacy_rx_hash (rx_ring , qw0 , qw1 , skb , decoded_pt );
1109+ csum_bits = iavf_legacy_rx_csum (rx_ring -> vsi , le64_to_cpu (qw1 ),
1110+ decoded_pt );
10901111 }
10911112 iavf_rx_csum (rx_ring -> vsi , skb , decoded_pt , csum_bits );
10921113
@@ -1296,12 +1317,13 @@ iavf_extract_flex_rx_fields(const struct iavf_ring *rx_ring,
12961317
12971318static struct libeth_rqe_info
12981319iavf_extract_rx_fields (const struct iavf_ring * rx_ring ,
1299- const struct iavf_rx_desc * rx_desc )
1320+ const struct iavf_rx_desc * rx_desc ,
1321+ bool flex )
13001322{
1301- if (rx_ring -> rxdid == VIRTCHNL_RXDID_1_32B_BASE )
1302- return iavf_extract_legacy_rx_fields (rx_ring , rx_desc );
1303- else
1323+ if (flex )
13041324 return iavf_extract_flex_rx_fields (rx_ring , rx_desc );
1325+ else
1326+ return iavf_extract_legacy_rx_fields (rx_ring , rx_desc );
13051327}
13061328
13071329/**
@@ -1318,6 +1340,7 @@ iavf_extract_rx_fields(const struct iavf_ring *rx_ring,
13181340 **/
13191341static int iavf_clean_rx_irq (struct iavf_ring * rx_ring , int budget )
13201342{
1343+ bool flex = rx_ring -> rxdid == VIRTCHNL_RXDID_2_FLEX_SQ_NIC ;
13211344 unsigned int total_rx_bytes = 0 , total_rx_packets = 0 ;
13221345 struct sk_buff * skb = rx_ring -> skb ;
13231346 u16 cleaned_count = IAVF_DESC_UNUSED (rx_ring );
@@ -1327,6 +1350,7 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget)
13271350 struct libeth_rqe_info fields ;
13281351 struct libeth_fqe * rx_buffer ;
13291352 struct iavf_rx_desc * rx_desc ;
1353+ u64 qw1 ;
13301354
13311355 /* return some buffers to hardware, one at a time is too slow */
13321356 if (cleaned_count >= IAVF_RX_BUFFER_WRITE ) {
@@ -1343,10 +1367,14 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget)
13431367 */
13441368 dma_rmb ();
13451369
1346- if (!iavf_test_staterr (rx_desc , IAVF_RXD_FLEX_DD_M ))
1370+ qw1 = le64_to_cpu (rx_desc -> qw1 );
1371+ /* If DD field (descriptor done) is unset then other fields are
1372+ * not valid
1373+ */
1374+ if (!iavf_is_descriptor_done (qw1 , flex ))
13471375 break ;
13481376
1349- fields = iavf_extract_rx_fields (rx_ring , rx_desc );
1377+ fields = iavf_extract_rx_fields (rx_ring , rx_desc , flex );
13501378
13511379 iavf_trace (clean_rx_irq , rx_ring , rx_desc , skb );
13521380
@@ -1391,7 +1419,7 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget)
13911419 total_rx_bytes += skb -> len ;
13921420
13931421 /* populate checksum, VLAN, and protocol */
1394- iavf_process_skb_fields (rx_ring , rx_desc , skb , fields .ptype );
1422+ iavf_process_skb_fields (rx_ring , rx_desc , skb , fields .ptype , flex );
13951423
13961424 iavf_trace (clean_rx_irq_rx , rx_ring , rx_desc , skb );
13971425 iavf_receive_skb (rx_ring , skb , fields .vlan );
0 commit comments