@@ -292,7 +292,7 @@ static int tsnep_tx_ring_init(struct tsnep_tx *tx)
292292 }
293293 for (i = 0 ; i < TSNEP_RING_SIZE ; i ++ ) {
294294 entry = & tx -> entry [i ];
295- next_entry = & tx -> entry [(i + 1 ) % TSNEP_RING_SIZE ];
295+ next_entry = & tx -> entry [(i + 1 ) & TSNEP_RING_MASK ];
296296 entry -> desc -> next = __cpu_to_le64 (next_entry -> desc_dma );
297297 }
298298
@@ -381,7 +381,7 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
381381 int i ;
382382
383383 for (i = 0 ; i < count ; i ++ ) {
384- entry = & tx -> entry [(tx -> write + i ) % TSNEP_RING_SIZE ];
384+ entry = & tx -> entry [(tx -> write + i ) & TSNEP_RING_MASK ];
385385
386386 if (!i ) {
387387 len = skb_headlen (skb );
@@ -419,7 +419,7 @@ static int tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
419419 int i ;
420420
421421 for (i = 0 ; i < count ; i ++ ) {
422- entry = & tx -> entry [(index + i ) % TSNEP_RING_SIZE ];
422+ entry = & tx -> entry [(index + i ) & TSNEP_RING_MASK ];
423423
424424 if (entry -> len ) {
425425 if (entry -> type & TSNEP_TX_TYPE_SKB )
@@ -481,9 +481,9 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
481481 skb_shinfo (skb )-> tx_flags |= SKBTX_IN_PROGRESS ;
482482
483483 for (i = 0 ; i < count ; i ++ )
484- tsnep_tx_activate (tx , (tx -> write + i ) % TSNEP_RING_SIZE , length ,
484+ tsnep_tx_activate (tx , (tx -> write + i ) & TSNEP_RING_MASK , length ,
485485 i == count - 1 );
486- tx -> write = (tx -> write + count ) % TSNEP_RING_SIZE ;
486+ tx -> write = (tx -> write + count ) & TSNEP_RING_MASK ;
487487
488488 skb_tx_timestamp (skb );
489489
@@ -516,7 +516,7 @@ static int tsnep_xdp_tx_map(struct xdp_frame *xdpf, struct tsnep_tx *tx,
516516 frag = NULL ;
517517 len = xdpf -> len ;
518518 for (i = 0 ; i < count ; i ++ ) {
519- entry = & tx -> entry [(tx -> write + i ) % TSNEP_RING_SIZE ];
519+ entry = & tx -> entry [(tx -> write + i ) & TSNEP_RING_MASK ];
520520 if (type & TSNEP_TX_TYPE_XDP_NDO ) {
521521 data = unlikely (frag ) ? skb_frag_address (frag ) :
522522 xdpf -> data ;
@@ -589,9 +589,9 @@ static bool tsnep_xdp_xmit_frame_ring(struct xdp_frame *xdpf,
589589 length = retval ;
590590
591591 for (i = 0 ; i < count ; i ++ )
592- tsnep_tx_activate (tx , (tx -> write + i ) % TSNEP_RING_SIZE , length ,
592+ tsnep_tx_activate (tx , (tx -> write + i ) & TSNEP_RING_MASK , length ,
593593 i == count - 1 );
594- tx -> write = (tx -> write + count ) % TSNEP_RING_SIZE ;
594+ tx -> write = (tx -> write + count ) & TSNEP_RING_MASK ;
595595
596596 /* descriptor properties shall be valid before hardware is notified */
597597 dma_wmb ();
@@ -691,7 +691,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
691691 /* xdpf is union with skb */
692692 entry -> skb = NULL ;
693693
694- tx -> read = (tx -> read + count ) % TSNEP_RING_SIZE ;
694+ tx -> read = (tx -> read + count ) & TSNEP_RING_MASK ;
695695
696696 tx -> packets ++ ;
697697 tx -> bytes += length + ETH_FCS_LEN ;
@@ -839,7 +839,7 @@ static int tsnep_rx_ring_init(struct tsnep_rx *rx)
839839
840840 for (i = 0 ; i < TSNEP_RING_SIZE ; i ++ ) {
841841 entry = & rx -> entry [i ];
842- next_entry = & rx -> entry [(i + 1 ) % TSNEP_RING_SIZE ];
842+ next_entry = & rx -> entry [(i + 1 ) & TSNEP_RING_MASK ];
843843 entry -> desc -> next = __cpu_to_le64 (next_entry -> desc_dma );
844844 }
845845
@@ -925,7 +925,7 @@ static int tsnep_rx_refill(struct tsnep_rx *rx, int count, bool reuse)
925925 int retval ;
926926
927927 for (i = 0 ; i < count && !alloc_failed ; i ++ ) {
928- index = (rx -> write + i ) % TSNEP_RING_SIZE ;
928+ index = (rx -> write + i ) & TSNEP_RING_MASK ;
929929
930930 retval = tsnep_rx_alloc_buffer (rx , index );
931931 if (unlikely (retval )) {
@@ -945,7 +945,7 @@ static int tsnep_rx_refill(struct tsnep_rx *rx, int count, bool reuse)
945945 }
946946
947947 if (enable ) {
948- rx -> write = (rx -> write + i ) % TSNEP_RING_SIZE ;
948+ rx -> write = (rx -> write + i ) & TSNEP_RING_MASK ;
949949
950950 /* descriptor properties shall be valid before hardware is
951951 * notified
@@ -1090,7 +1090,7 @@ static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi,
10901090 * empty RX ring, thus buffer cannot be used for
10911091 * RX processing
10921092 */
1093- rx -> read = (rx -> read + 1 ) % TSNEP_RING_SIZE ;
1093+ rx -> read = (rx -> read + 1 ) & TSNEP_RING_MASK ;
10941094 desc_available ++ ;
10951095
10961096 rx -> dropped ++ ;
@@ -1117,7 +1117,7 @@ static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi,
11171117 */
11181118 length -= TSNEP_RX_INLINE_METADATA_SIZE ;
11191119
1120- rx -> read = (rx -> read + 1 ) % TSNEP_RING_SIZE ;
1120+ rx -> read = (rx -> read + 1 ) & TSNEP_RING_MASK ;
11211121 desc_available ++ ;
11221122
11231123 if (prog ) {
0 commit comments