@@ -809,7 +809,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
809
809
if (dma_mapping_error (dp -> dev , dma_addr ))
810
810
goto err_free ;
811
811
812
- wr_idx = tx_ring -> wr_p & ( tx_ring -> cnt - 1 );
812
+ wr_idx = D_IDX ( tx_ring , tx_ring -> wr_p );
813
813
814
814
/* Stash the soft descriptor of the head then initialize it */
815
815
txbuf = & tx_ring -> txbufs [wr_idx ];
@@ -852,7 +852,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
852
852
if (dma_mapping_error (dp -> dev , dma_addr ))
853
853
goto err_unmap ;
854
854
855
- wr_idx = ( wr_idx + 1 ) & ( tx_ring -> cnt - 1 );
855
+ wr_idx = D_IDX ( tx_ring , wr_idx + 1 );
856
856
tx_ring -> txbufs [wr_idx ].skb = skb ;
857
857
tx_ring -> txbufs [wr_idx ].dma_addr = dma_addr ;
858
858
tx_ring -> txbufs [wr_idx ].fidx = f ;
@@ -946,8 +946,7 @@ static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring)
946
946
todo = qcp_rd_p + tx_ring -> cnt - tx_ring -> qcp_rd_p ;
947
947
948
948
while (todo -- ) {
949
- idx = tx_ring -> rd_p & (tx_ring -> cnt - 1 );
950
- tx_ring -> rd_p ++ ;
949
+ idx = D_IDX (tx_ring , tx_ring -> rd_p ++ );
951
950
952
951
skb = tx_ring -> txbufs [idx ].skb ;
953
952
if (!skb )
@@ -1023,11 +1022,11 @@ static bool nfp_net_xdp_complete(struct nfp_net_tx_ring *tx_ring)
1023
1022
done_all = todo <= NFP_NET_XDP_MAX_COMPLETE ;
1024
1023
todo = min (todo , NFP_NET_XDP_MAX_COMPLETE );
1025
1024
1026
- tx_ring -> qcp_rd_p = (tx_ring -> qcp_rd_p + todo ) & ( tx_ring -> cnt - 1 );
1025
+ tx_ring -> qcp_rd_p = D_IDX (tx_ring , tx_ring -> qcp_rd_p + todo );
1027
1026
1028
1027
done_pkts = todo ;
1029
1028
while (todo -- ) {
1030
- idx = tx_ring -> rd_p & ( tx_ring -> cnt - 1 );
1029
+ idx = D_IDX ( tx_ring , tx_ring -> rd_p );
1031
1030
tx_ring -> rd_p ++ ;
1032
1031
1033
1032
done_bytes += tx_ring -> txbufs [idx ].real_len ;
@@ -1063,7 +1062,7 @@ nfp_net_tx_ring_reset(struct nfp_net_dp *dp, struct nfp_net_tx_ring *tx_ring)
1063
1062
struct sk_buff * skb ;
1064
1063
int idx , nr_frags ;
1065
1064
1066
- idx = tx_ring -> rd_p & ( tx_ring -> cnt - 1 );
1065
+ idx = D_IDX ( tx_ring , tx_ring -> rd_p );
1067
1066
tx_buf = & tx_ring -> txbufs [idx ];
1068
1067
1069
1068
skb = tx_ring -> txbufs [idx ].skb ;
@@ -1216,7 +1215,7 @@ static void nfp_net_rx_give_one(const struct nfp_net_dp *dp,
1216
1215
{
1217
1216
unsigned int wr_idx ;
1218
1217
1219
- wr_idx = rx_ring -> wr_p & ( rx_ring -> cnt - 1 );
1218
+ wr_idx = D_IDX ( rx_ring , rx_ring -> wr_p );
1220
1219
1221
1220
nfp_net_dma_sync_dev_rx (dp , dma_addr );
1222
1221
@@ -1254,7 +1253,7 @@ static void nfp_net_rx_ring_reset(struct nfp_net_rx_ring *rx_ring)
1254
1253
unsigned int wr_idx , last_idx ;
1255
1254
1256
1255
/* Move the empty entry to the end of the list */
1257
- wr_idx = rx_ring -> wr_p & ( rx_ring -> cnt - 1 );
1256
+ wr_idx = D_IDX ( rx_ring , rx_ring -> wr_p );
1258
1257
last_idx = rx_ring -> cnt - 1 ;
1259
1258
rx_ring -> rxbufs [wr_idx ].dma_addr = rx_ring -> rxbufs [last_idx ].dma_addr ;
1260
1259
rx_ring -> rxbufs [wr_idx ].frag = rx_ring -> rxbufs [last_idx ].frag ;
@@ -1522,7 +1521,7 @@ nfp_net_tx_xdp_buf(struct nfp_net_dp *dp, struct nfp_net_rx_ring *rx_ring,
1522
1521
}
1523
1522
}
1524
1523
1525
- wr_idx = tx_ring -> wr_p & ( tx_ring -> cnt - 1 );
1524
+ wr_idx = D_IDX ( tx_ring , tx_ring -> wr_p );
1526
1525
1527
1526
/* Stash the soft descriptor of the head then initialize it */
1528
1527
txbuf = & tx_ring -> txbufs [wr_idx ];
@@ -1610,7 +1609,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
1610
1609
dma_addr_t new_dma_addr ;
1611
1610
void * new_frag ;
1612
1611
1613
- idx = rx_ring -> rd_p & ( rx_ring -> cnt - 1 );
1612
+ idx = D_IDX ( rx_ring , rx_ring -> rd_p );
1614
1613
1615
1614
rxd = & rx_ring -> rxds [idx ];
1616
1615
if (!(rxd -> rxd .meta_len_dd & PCIE_DESC_RX_DD ))
0 commit comments