Skip to content

Commit dc9c02b

Browse files
shinas-marvelldavem330
authored andcommitted
octeon_ep: remove atomic variable usage in Tx data path
Replace atomic variable "instr_pending" which represents number of posted tx instructions pending completion, with host_write_idx and flush_index variables in the xmit and completion processing respectively. Signed-off-by: Shinas Rasheed <srasheed@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 373d9a5 commit dc9c02b

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define OCTEP_64BYTE_INSTR 64
1414

1515
/* Tx Queue: maximum descriptors per ring */
16+
/* This needs to be a power of 2 */
1617
#define OCTEP_IQ_MAX_DESCRIPTORS 1024
1718
/* Minimum input (Tx) requests to be enqueued to ring doorbell */
1819
#define OCTEP_DB_MIN 8

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ static int octep_stop(struct net_device *netdev)
777777
*/
778778
static inline int octep_iq_full_check(struct octep_iq *iq)
779779
{
780-
if (likely((iq->max_count - atomic_read(&iq->instr_pending)) >=
780+
if (likely((IQ_INSTR_SPACE(iq)) >
781781
OCTEP_WAKE_QUEUE_THRESHOLD))
782782
return 0;
783783

@@ -794,7 +794,7 @@ static inline int octep_iq_full_check(struct octep_iq *iq)
794794
/* check again and restart the queue, in case NAPI has just freed
795795
* enough Tx ring entries.
796796
*/
797-
if (unlikely((iq->max_count - atomic_read(&iq->instr_pending)) >=
797+
if (unlikely(IQ_INSTR_SPACE(iq) >
798798
OCTEP_WAKE_QUEUE_THRESHOLD)) {
799799
netif_start_subqueue(iq->netdev, iq->q_no);
800800
iq->stats.restart_cnt++;
@@ -903,12 +903,9 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb,
903903
__netdev_tx_sent_queue(iq->netdev_q, skb->len, xmit_more);
904904

905905
skb_tx_timestamp(skb);
906-
atomic_inc(&iq->instr_pending);
907906
iq->fill_cnt++;
908907
wi++;
909-
if (wi == iq->max_count)
910-
wi = 0;
911-
iq->host_write_index = wi;
908+
iq->host_write_index = wi & iq->ring_size_mask;
912909

913910
/* octep_iq_full_check stops the queue and returns
914911
* true if so, in case the queue has become full

drivers/net/ethernet/marvell/octeon_ep/octep_main.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040
#define OCTEP_OQ_INTR_RESEND_BIT 59
4141

4242
#define OCTEP_MMIO_REGIONS 3
43+
44+
#define IQ_INSTR_PENDING(iq) ({ typeof(iq) iq__ = (iq); \
45+
((iq__)->host_write_index - (iq__)->flush_index) & \
46+
(iq__)->ring_size_mask; \
47+
})
48+
#define IQ_INSTR_SPACE(iq) ({ typeof(iq) iq_ = (iq); \
49+
(iq_)->max_count - IQ_INSTR_PENDING(iq_); \
50+
})
51+
4352
/* PCI address space mapping information.
4453
* Each of the 3 address spaces given by BAR0, BAR2 and BAR4 of
4554
* Octeon gets mapped to different physical address spaces in

drivers/net/ethernet/marvell/octeon_ep/octep_tx.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ static void octep_iq_reset_indices(struct octep_iq *iq)
2121
iq->flush_index = 0;
2222
iq->pkts_processed = 0;
2323
iq->pkt_in_done = 0;
24-
atomic_set(&iq->instr_pending, 0);
2524
}
2625

2726
/**
@@ -82,7 +81,6 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget)
8281
}
8382

8483
iq->pkts_processed += compl_pkts;
85-
atomic_sub(compl_pkts, &iq->instr_pending);
8684
iq->stats.instr_completed += compl_pkts;
8785
iq->stats.bytes_sent += compl_bytes;
8886
iq->stats.sgentry_sent += compl_sg;
@@ -91,7 +89,7 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget)
9189
netdev_tx_completed_queue(iq->netdev_q, compl_pkts, compl_bytes);
9290

9391
if (unlikely(__netif_subqueue_stopped(iq->netdev, iq->q_no)) &&
94-
((iq->max_count - atomic_read(&iq->instr_pending)) >
92+
(IQ_INSTR_SPACE(iq) >
9593
OCTEP_WAKE_QUEUE_THRESHOLD))
9694
netif_wake_subqueue(iq->netdev, iq->q_no);
9795
return !budget;
@@ -144,7 +142,6 @@ static void octep_iq_free_pending(struct octep_iq *iq)
144142
dev_kfree_skb_any(skb);
145143
}
146144

147-
atomic_set(&iq->instr_pending, 0);
148145
iq->flush_index = fi;
149146
netdev_tx_reset_queue(netdev_get_tx_queue(iq->netdev, iq->q_no));
150147
}

drivers/net/ethernet/marvell/octeon_ep/octep_tx.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ struct octep_iq {
172172
/* Statistics for this input queue. */
173173
struct octep_iq_stats stats;
174174

175-
/* This field keeps track of the instructions pending in this queue. */
176-
atomic_t instr_pending;
177-
178175
/* Pointer to the Virtual Base addr of the input ring. */
179176
struct octep_tx_desc_hw *desc_ring;
180177

0 commit comments

Comments
 (0)