Skip to content

Commit

Permalink
net: ipa: determine replenish doorbell differently
Browse files Browse the repository at this point in the history
Rather than tracking the number of receive buffer transactions that
have been submitted without a doorbell, just track the total number
of transactions that have been issued.  Then ring the doorbell when
that number modulo the replenish batch size is 0.

The effect is roughly the same, but the new count is slightly more
interesting, and this approach will someday allow the replenish
batch size to be tuned at runtime.

Signed-off-by: Alex Elder <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Alex Elder authored and davem330 committed Feb 4, 2022
1 parent 5d6ac24 commit 9654d8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)

#define IPA_REPLENISH_BATCH 16
/* Hardware is told about receive buffers once a "batch" has been queued */
#define IPA_REPLENISH_BATCH 16 /* Must be non-zero */

/* The amount of RX buffer space consumed by standard skb overhead */
#define IPA_RX_BUFFER_OVERHEAD (PAGE_SIZE - SKB_MAX_ORDER(NET_SKB_PAD, 0))
Expand Down Expand Up @@ -1086,14 +1087,15 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint)
return;

while ((trans = ipa_endpoint_trans_alloc(endpoint, 1))) {
bool doorbell;

if (ipa_endpoint_replenish_one(endpoint, trans))
goto try_again_later;

if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH)
endpoint->replenish_ready = 0;

/* Ring the doorbell if we've got a full batch */
gsi_trans_commit(trans, !endpoint->replenish_ready);
doorbell = !(++endpoint->replenish_count % IPA_REPLENISH_BATCH);
gsi_trans_commit(trans, doorbell);
}

clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
Expand Down Expand Up @@ -1863,6 +1865,8 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count,
enum ipa_endpoint_name name;
u32 filter_map;

BUILD_BUG_ON(!IPA_REPLENISH_BATCH);

if (!ipa_endpoint_data_valid(ipa, count, data))
return 0; /* Error */

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ipa/ipa_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ enum ipa_replenish_flag {
* @evt_ring_id: GSI event ring used by the endpoint
* @netdev: Network device pointer, if endpoint uses one
* @replenish_flags: Replenishing state flags
* @replenish_ready: Number of replenish transactions without doorbell
* @replenish_count: Total number of replenish transactions committed
* @replenish_work: Work item used for repeated replenish failures
*/
struct ipa_endpoint {
Expand All @@ -84,7 +84,7 @@ struct ipa_endpoint {

/* Receive buffer replenishing for RX endpoints */
DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT);
u32 replenish_ready;
u64 replenish_count;
struct delayed_work replenish_work; /* global wq */
};

Expand Down

0 comments on commit 9654d8c

Please sign in to comment.