History

net/mlx5e: Force CHECKSUM_UNNECESSARY for short ethernet frames

When an ethernet frame is padded to meet the minimum ethernet frame size, the padding octets are not covered by the hardware checksum. Fortunately the padding octets are usually zero's, which don't affect checksum. However, we have a switch which pads non-zero octets, this causes kernel hardware checksum fault repeatedly. Prior to: commit '88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE ...")' skb checksum was forced to be CHECKSUM_NONE when padding is detected. After it, we need to keep skb->csum updated, like what we do for RXFCS. However, fixing up CHECKSUM_COMPLETE requires to verify and parse IP headers, it is not worthy the effort as the packets are so small that CHECKSUM_COMPLETE can't save anything.

Cong Wang committed 7 years ago

Commit e8c8b531 parent bfeffd11 file · +13 −0Browse files

Unified · Split

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c+13−0
@@ -732,6 +732,8 @@ static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto) · 731 unmodified lines
732732 ((struct ipv6hdr *)ip_p)->nexthdr;
733733 }
734734
735+#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
736+
735737 static inline void mlx5e_handle_csum(struct net_device *netdev,
736738 struct mlx5_cqe64 *cqe,
737739 struct mlx5e_rq *rq,
@@ -754,6 +756,17 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, · 16 unmodified lines
754756 if (unlikely(test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state)))
755757 goto csum_unnecessary;
756758
759+ /* CQE csum doesn't cover padding octets in short ethernet
760+ * frames. And the pad field is appended prior to calculating
761+ * and appending the FCS field.
762+ *
763+ * Detecting these padded frames requires to verify and parse
764+ * IP headers, so we simply force all those small frames to be
765+ * CHECKSUM_UNNECESSARY even if they are not padded.
766+ */
767+ if (short_frame(skb->len))
768+ goto csum_unnecessary;
769+
757770 if (likely(is_last_ethertype_ip(skb, &network_depth, &proto))) {
758771 if (unlikely(get_ip_proto(skb, network_depth, proto) == IPPROTO_SCTP))
759772 goto csum_unnecessary;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t