Skip to content

Commit 3bdd708

Browse files
Sasha NeftinJeff Kirsher
authored andcommitted
igc: Add Rx checksum support
Extend the socket buffer field process and add Rx checksum functionality Minor: fix indentation with tab instead of spaces. Signed-off-by: Sasha Neftin <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 7f83968 commit 3bdd708

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

drivers/net/ethernet/intel/igc/igc_defines.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@
282282
#define IGC_RCTL_BAM 0x00008000 /* broadcast enable */
283283

284284
/* Receive Descriptor bit definitions */
285-
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
285+
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
286+
#define IGC_RXD_STAT_IXSM 0x04 /* Ignore checksum */
287+
#define IGC_RXD_STAT_UDPCS 0x10 /* UDP xsum calculated */
288+
#define IGC_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
286289

287290
#define IGC_RXDEXT_STATERR_CE 0x01000000
288291
#define IGC_RXDEXT_STATERR_SE 0x02000000

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,46 @@ static netdev_tx_t igc_xmit_frame(struct sk_buff *skb,
12011201
return igc_xmit_frame_ring(skb, igc_tx_queue_mapping(adapter, skb));
12021202
}
12031203

1204+
static void igc_rx_checksum(struct igc_ring *ring,
1205+
union igc_adv_rx_desc *rx_desc,
1206+
struct sk_buff *skb)
1207+
{
1208+
skb_checksum_none_assert(skb);
1209+
1210+
/* Ignore Checksum bit is set */
1211+
if (igc_test_staterr(rx_desc, IGC_RXD_STAT_IXSM))
1212+
return;
1213+
1214+
/* Rx checksum disabled via ethtool */
1215+
if (!(ring->netdev->features & NETIF_F_RXCSUM))
1216+
return;
1217+
1218+
/* TCP/UDP checksum error bit is set */
1219+
if (igc_test_staterr(rx_desc,
1220+
IGC_RXDEXT_STATERR_TCPE |
1221+
IGC_RXDEXT_STATERR_IPE)) {
1222+
/* work around errata with sctp packets where the TCPE aka
1223+
* L4E bit is set incorrectly on 64 byte (60 byte w/o crc)
1224+
* packets (aka let the stack check the crc32c)
1225+
*/
1226+
if (!(skb->len == 60 &&
1227+
test_bit(IGC_RING_FLAG_RX_SCTP_CSUM, &ring->flags))) {
1228+
u64_stats_update_begin(&ring->rx_syncp);
1229+
ring->rx_stats.csum_err++;
1230+
u64_stats_update_end(&ring->rx_syncp);
1231+
}
1232+
/* let the stack verify checksum errors */
1233+
return;
1234+
}
1235+
/* It must be a TCP or UDP packet with a valid checksum */
1236+
if (igc_test_staterr(rx_desc, IGC_RXD_STAT_TCPCS |
1237+
IGC_RXD_STAT_UDPCS))
1238+
skb->ip_summed = CHECKSUM_UNNECESSARY;
1239+
1240+
dev_dbg(ring->dev, "cksum success: bits %08X\n",
1241+
le32_to_cpu(rx_desc->wb.upper.status_error));
1242+
}
1243+
12041244
static inline void igc_rx_hash(struct igc_ring *ring,
12051245
union igc_adv_rx_desc *rx_desc,
12061246
struct sk_buff *skb)
@@ -1227,6 +1267,8 @@ static void igc_process_skb_fields(struct igc_ring *rx_ring,
12271267
{
12281268
igc_rx_hash(rx_ring, rx_desc, skb);
12291269

1270+
igc_rx_checksum(rx_ring, rx_desc, skb);
1271+
12301272
skb_record_rx_queue(skb, rx_ring->queue_index);
12311273

12321274
skb->protocol = eth_type_trans(skb, rx_ring->netdev);
@@ -4391,6 +4433,7 @@ static int igc_probe(struct pci_dev *pdev,
43914433
goto err_sw_init;
43924434

43934435
/* Add supported features to the features list*/
4436+
netdev->features |= NETIF_F_RXCSUM;
43944437
netdev->features |= NETIF_F_HW_CSUM;
43954438
netdev->features |= NETIF_F_SCTP_CRC;
43964439

0 commit comments

Comments
 (0)