@@ -809,7 +809,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
809809 if (dma_mapping_error (dp -> dev , dma_addr ))
810810 goto err_free ;
811811
812- wr_idx = tx_ring -> wr_p & ( tx_ring -> cnt - 1 );
812+ wr_idx = D_IDX ( tx_ring , tx_ring -> wr_p );
813813
814814 /* Stash the soft descriptor of the head then initialize it */
815815 txbuf = & tx_ring -> txbufs [wr_idx ];
@@ -852,7 +852,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
852852 if (dma_mapping_error (dp -> dev , dma_addr ))
853853 goto err_unmap ;
854854
855- wr_idx = ( wr_idx + 1 ) & ( tx_ring -> cnt - 1 );
855+ wr_idx = D_IDX ( tx_ring , wr_idx + 1 );
856856 tx_ring -> txbufs [wr_idx ].skb = skb ;
857857 tx_ring -> txbufs [wr_idx ].dma_addr = dma_addr ;
858858 tx_ring -> txbufs [wr_idx ].fidx = f ;
@@ -946,8 +946,7 @@ static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring)
946946 todo = qcp_rd_p + tx_ring -> cnt - tx_ring -> qcp_rd_p ;
947947
948948 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 ++ );
951950
952951 skb = tx_ring -> txbufs [idx ].skb ;
953952 if (!skb )
@@ -1023,11 +1022,11 @@ static bool nfp_net_xdp_complete(struct nfp_net_tx_ring *tx_ring)
10231022 done_all = todo <= NFP_NET_XDP_MAX_COMPLETE ;
10241023 todo = min (todo , NFP_NET_XDP_MAX_COMPLETE );
10251024
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 );
10271026
10281027 done_pkts = todo ;
10291028 while (todo -- ) {
1030- idx = tx_ring -> rd_p & ( tx_ring -> cnt - 1 );
1029+ idx = D_IDX ( tx_ring , tx_ring -> rd_p );
10311030 tx_ring -> rd_p ++ ;
10321031
10331032 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)
10631062 struct sk_buff * skb ;
10641063 int idx , nr_frags ;
10651064
1066- idx = tx_ring -> rd_p & ( tx_ring -> cnt - 1 );
1065+ idx = D_IDX ( tx_ring , tx_ring -> rd_p );
10671066 tx_buf = & tx_ring -> txbufs [idx ];
10681067
10691068 skb = tx_ring -> txbufs [idx ].skb ;
@@ -1216,7 +1215,7 @@ static void nfp_net_rx_give_one(const struct nfp_net_dp *dp,
12161215{
12171216 unsigned int wr_idx ;
12181217
1219- wr_idx = rx_ring -> wr_p & ( rx_ring -> cnt - 1 );
1218+ wr_idx = D_IDX ( rx_ring , rx_ring -> wr_p );
12201219
12211220 nfp_net_dma_sync_dev_rx (dp , dma_addr );
12221221
@@ -1254,7 +1253,7 @@ static void nfp_net_rx_ring_reset(struct nfp_net_rx_ring *rx_ring)
12541253 unsigned int wr_idx , last_idx ;
12551254
12561255 /* 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 );
12581257 last_idx = rx_ring -> cnt - 1 ;
12591258 rx_ring -> rxbufs [wr_idx ].dma_addr = rx_ring -> rxbufs [last_idx ].dma_addr ;
12601259 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,
15221521 }
15231522 }
15241523
1525- wr_idx = tx_ring -> wr_p & ( tx_ring -> cnt - 1 );
1524+ wr_idx = D_IDX ( tx_ring , tx_ring -> wr_p );
15261525
15271526 /* Stash the soft descriptor of the head then initialize it */
15281527 txbuf = & tx_ring -> txbufs [wr_idx ];
@@ -1610,7 +1609,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
16101609 dma_addr_t new_dma_addr ;
16111610 void * new_frag ;
16121611
1613- idx = rx_ring -> rd_p & ( rx_ring -> cnt - 1 );
1612+ idx = D_IDX ( rx_ring , rx_ring -> rd_p );
16141613
16151614 rxd = & rx_ring -> rxds [idx ];
16161615 if (!(rxd -> rxd .meta_len_dd & PCIE_DESC_RX_DD ))
0 commit comments