@@ -505,9 +505,9 @@ static void idpf_rx_post_buf_refill(struct idpf_sw_queue *refillq, u16 buf_id)
505
505
506
506
/* store the buffer ID and the SW maintained GEN bit to the refillq */
507
507
refillq -> ring [nta ] =
508
- (( buf_id << IDPF_RX_BI_BUFID_S ) & IDPF_RX_BI_BUFID_M ) |
509
- (!!( test_bit ( __IDPF_Q_GEN_CHK , refillq -> flags )) <<
510
- IDPF_RX_BI_GEN_S );
508
+ FIELD_PREP ( IDPF_RX_BI_BUFID_M , buf_id ) |
509
+ FIELD_PREP ( IDPF_RX_BI_GEN_M ,
510
+ test_bit ( __IDPF_Q_GEN_CHK , refillq -> flags ) );
511
511
512
512
if (unlikely (++ nta == refillq -> desc_count )) {
513
513
nta = 0 ;
@@ -1825,14 +1825,14 @@ static bool idpf_tx_clean_complq(struct idpf_queue *complq, int budget,
1825
1825
u16 gen ;
1826
1826
1827
1827
/* if the descriptor isn't done, no work yet to do */
1828
- gen = ( le16_to_cpu ( tx_desc -> qid_comptype_gen ) &
1829
- IDPF_TXD_COMPLQ_GEN_M ) >> IDPF_TXD_COMPLQ_GEN_S ;
1828
+ gen = le16_get_bits ( tx_desc -> qid_comptype_gen ,
1829
+ IDPF_TXD_COMPLQ_GEN_M );
1830
1830
if (test_bit (__IDPF_Q_GEN_CHK , complq -> flags ) != gen )
1831
1831
break ;
1832
1832
1833
1833
/* Find necessary info of TX queue to clean buffers */
1834
- rel_tx_qid = ( le16_to_cpu ( tx_desc -> qid_comptype_gen ) &
1835
- IDPF_TXD_COMPLQ_QID_M ) >> IDPF_TXD_COMPLQ_QID_S ;
1834
+ rel_tx_qid = le16_get_bits ( tx_desc -> qid_comptype_gen ,
1835
+ IDPF_TXD_COMPLQ_QID_M ) ;
1836
1836
if (rel_tx_qid >= complq -> txq_grp -> num_txq ||
1837
1837
!complq -> txq_grp -> txqs [rel_tx_qid ]) {
1838
1838
dev_err (& complq -> vport -> adapter -> pdev -> dev ,
@@ -1842,9 +1842,8 @@ static bool idpf_tx_clean_complq(struct idpf_queue *complq, int budget,
1842
1842
tx_q = complq -> txq_grp -> txqs [rel_tx_qid ];
1843
1843
1844
1844
/* Determine completion type */
1845
- ctype = (le16_to_cpu (tx_desc -> qid_comptype_gen ) &
1846
- IDPF_TXD_COMPLQ_COMPL_TYPE_M ) >>
1847
- IDPF_TXD_COMPLQ_COMPL_TYPE_S ;
1845
+ ctype = le16_get_bits (tx_desc -> qid_comptype_gen ,
1846
+ IDPF_TXD_COMPLQ_COMPL_TYPE_M );
1848
1847
switch (ctype ) {
1849
1848
case IDPF_TXD_COMPLT_RE :
1850
1849
hw_head = le16_to_cpu (tx_desc -> q_head_compl_tag .q_head );
@@ -1945,11 +1944,10 @@ void idpf_tx_splitq_build_ctb(union idpf_tx_flex_desc *desc,
1945
1944
u16 td_cmd , u16 size )
1946
1945
{
1947
1946
desc -> q .qw1 .cmd_dtype =
1948
- cpu_to_le16 (params -> dtype & IDPF_FLEX_TXD_QW1_DTYPE_M );
1947
+ le16_encode_bits (params -> dtype , IDPF_FLEX_TXD_QW1_DTYPE_M );
1949
1948
desc -> q .qw1 .cmd_dtype |=
1950
- cpu_to_le16 ((td_cmd << IDPF_FLEX_TXD_QW1_CMD_S ) &
1951
- IDPF_FLEX_TXD_QW1_CMD_M );
1952
- desc -> q .qw1 .buf_size = cpu_to_le16 ((u16 )size );
1949
+ le16_encode_bits (td_cmd , IDPF_FLEX_TXD_QW1_CMD_M );
1950
+ desc -> q .qw1 .buf_size = cpu_to_le16 (size );
1953
1951
desc -> q .qw1 .l2tags .l2tag1 = cpu_to_le16 (params -> td_tag );
1954
1952
}
1955
1953
@@ -2843,8 +2841,9 @@ static void idpf_rx_splitq_extract_csum_bits(struct virtchnl2_rx_flex_desc_adv_n
2843
2841
qword1 );
2844
2842
csum -> ipv6exadd = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_IPV6EXADD_M ,
2845
2843
qword0 );
2846
- csum -> raw_csum_inv = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_RAW_CSUM_INV_M ,
2847
- le16_to_cpu (rx_desc -> ptype_err_fflags0 ));
2844
+ csum -> raw_csum_inv =
2845
+ le16_get_bits (rx_desc -> ptype_err_fflags0 ,
2846
+ VIRTCHNL2_RX_FLEX_DESC_ADV_RAW_CSUM_INV_M );
2848
2847
csum -> raw_csum = le16_to_cpu (rx_desc -> misc .raw_cs );
2849
2848
}
2850
2849
@@ -2938,8 +2937,8 @@ static int idpf_rx_process_skb_fields(struct idpf_queue *rxq,
2938
2937
struct idpf_rx_ptype_decoded decoded ;
2939
2938
u16 rx_ptype ;
2940
2939
2941
- rx_ptype = FIELD_GET ( VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M ,
2942
- le16_to_cpu ( rx_desc -> ptype_err_fflags0 ) );
2940
+ rx_ptype = le16_get_bits ( rx_desc -> ptype_err_fflags0 ,
2941
+ VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M );
2943
2942
2944
2943
decoded = rxq -> vport -> rx_ptype_lkup [rx_ptype ];
2945
2944
/* If we don't know the ptype we can't do anything else with it. Just
@@ -2953,8 +2952,8 @@ static int idpf_rx_process_skb_fields(struct idpf_queue *rxq,
2953
2952
2954
2953
skb -> protocol = eth_type_trans (skb , rxq -> vport -> netdev );
2955
2954
2956
- if (FIELD_GET ( VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M ,
2957
- le16_to_cpu ( rx_desc -> hdrlen_flags ) ))
2955
+ if (le16_get_bits ( rx_desc -> hdrlen_flags ,
2956
+ VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M ))
2958
2957
return idpf_rx_rsc (rxq , skb , rx_desc , & decoded );
2959
2958
2960
2959
idpf_rx_splitq_extract_csum_bits (rx_desc , & csum_bits );
@@ -3148,8 +3147,8 @@ static int idpf_rx_splitq_clean(struct idpf_queue *rxq, int budget)
3148
3147
dma_rmb ();
3149
3148
3150
3149
/* if the descriptor isn't done, no work yet to do */
3151
- gen_id = le16_to_cpu (rx_desc -> pktlen_gen_bufq_id );
3152
- gen_id = FIELD_GET ( VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M , gen_id );
3150
+ gen_id = le16_get_bits (rx_desc -> pktlen_gen_bufq_id ,
3151
+ VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M );
3153
3152
3154
3153
if (test_bit (__IDPF_Q_GEN_CHK , rxq -> flags ) != gen_id )
3155
3154
break ;
@@ -3164,9 +3163,8 @@ static int idpf_rx_splitq_clean(struct idpf_queue *rxq, int budget)
3164
3163
continue ;
3165
3164
}
3166
3165
3167
- pkt_len = le16_to_cpu (rx_desc -> pktlen_gen_bufq_id );
3168
- pkt_len = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M ,
3169
- pkt_len );
3166
+ pkt_len = le16_get_bits (rx_desc -> pktlen_gen_bufq_id ,
3167
+ VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M );
3170
3168
3171
3169
hbo = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_HBO_M ,
3172
3170
rx_desc -> status_err0_qw1 );
@@ -3183,14 +3181,12 @@ static int idpf_rx_splitq_clean(struct idpf_queue *rxq, int budget)
3183
3181
goto bypass_hsplit ;
3184
3182
}
3185
3183
3186
- hdr_len = le16_to_cpu (rx_desc -> hdrlen_flags );
3187
- hdr_len = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M ,
3188
- hdr_len );
3184
+ hdr_len = le16_get_bits (rx_desc -> hdrlen_flags ,
3185
+ VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M );
3189
3186
3190
3187
bypass_hsplit :
3191
- bufq_id = le16_to_cpu (rx_desc -> pktlen_gen_bufq_id );
3192
- bufq_id = FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M ,
3193
- bufq_id );
3188
+ bufq_id = le16_get_bits (rx_desc -> pktlen_gen_bufq_id ,
3189
+ VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M );
3194
3190
3195
3191
rxq_set = container_of (rxq , struct idpf_rxq_set , rxq );
3196
3192
if (!bufq_id )
0 commit comments