Skip to content

Commit

Permalink
r8169: improve rtl8169_rx_csum
Browse files Browse the repository at this point in the history
Extend the mask to include the checksum failure bits. This allows to
simplify the condition in rtl8169_rx_csum().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Heiner Kallweit authored and Jakub Kicinski committed Jan 13, 2021
1 parent 1e8636b commit 206a75e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ enum rtl_rx_desc_bit {
IPFail = (1 << 16), /* IP checksum failed */
UDPFail = (1 << 15), /* UDP/IP checksum failed */
TCPFail = (1 << 14), /* TCP/IP checksum failed */

#define RxCSFailMask (IPFail | UDPFail | TCPFail)

RxVlanTag = (1 << 16), /* VLAN tag available */
};

Expand Down Expand Up @@ -4377,10 +4380,9 @@ static inline int rtl8169_fragmented_frame(u32 status)

static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
{
u32 status = opts1 & RxProtoMask;
u32 status = opts1 & (RxProtoMask | RxCSFailMask);

if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
((status == RxProtoUDP) && !(opts1 & UDPFail)))
if (status == RxProtoTCP || status == RxProtoUDP)
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb_checksum_none_assert(skb);
Expand Down

0 comments on commit 206a75e

Please sign in to comment.