Skip to content

Commit

Permalink
net: ipa: minor update to handling of packet with status
Browse files Browse the repository at this point in the history
Rearrange some comments and assignments made when handling a packet
that is received with status, aiming to improve understandability.

Use DIV_ROUND_CLOSEST() to get a better per-packet true size estimate.

Signed-off-by: Alex Elder <elder@linaro.org>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Alex Elder authored and Jakub Kicinski committed Jan 29, 2021
1 parent aa56e3e commit 162fbc6
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,29 +1213,33 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
continue;
}

/* Compute the amount of buffer space consumed by the
* packet, including the status element. If the hardware
* is configured to pad packet data to an aligned boundary,
* account for that. And if checksum offload is is enabled
* a trailer containing computed checksum information will
* be appended.
/* Compute the amount of buffer space consumed by the packet,
* including the status element. If the hardware is configured
* to pad packet data to an aligned boundary, account for that.
* And if checksum offload is enabled a trailer containing
* computed checksum information will be appended.
*/
align = endpoint->data->rx.pad_align ? : 1;
len = le16_to_cpu(status->pkt_len);
len = sizeof(*status) + ALIGN(len, align);
if (endpoint->data->checksum)
len += sizeof(struct rmnet_map_dl_csum_trailer);

/* Charge the new packet with a proportional fraction of
* the unused space in the original receive buffer.
* XXX Charge a proportion of the *whole* receive buffer?
*/
if (!ipa_status_drop_packet(status)) {
u32 extra = unused * len / total_len;
void *data2 = data + sizeof(*status);
u32 len2 = le16_to_cpu(status->pkt_len);
void *data2;
u32 extra;
u32 len2;

/* Client receives only packet data (no status) */
data2 = data + sizeof(*status);
len2 = le16_to_cpu(status->pkt_len);

/* Have the true size reflect the extra unused space in
* the original receive buffer. Distribute the "cost"
* proportionately across all aggregated packets in the
* buffer.
*/
extra = DIV_ROUND_CLOSEST(unused * len, total_len);
ipa_endpoint_skb_copy(endpoint, data2, len2, extra);
}

Expand Down

0 comments on commit 162fbc6

Please sign in to comment.