Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8101553

Browse files
Doug Bergerdavem330
authored andcommitted
net: bcmgenet: use CHECKSUM_COMPLETE for NETIF_F_RXCSUM
This commit updates the Rx checksum offload behavior of the driver to use the more generic CHECKSUM_COMPLETE method that supports all protocols over the CHECKSUM_UNNECESSARY method that only applies to some protocols known by the hardware. This behavior is perceived to be superior. Signed-off-by: Doug Berger <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dd8e911 commit 8101553

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static int bcmgenet_set_rx_csum(struct net_device *dev,
521521

522522
/* enable rx checksumming */
523523
if (rx_csum_en)
524-
rbuf_chk_ctrl |= RBUF_RXCHK_EN;
524+
rbuf_chk_ctrl |= RBUF_RXCHK_EN | RBUF_L3_PARSE_DIS;
525525
else
526526
rbuf_chk_ctrl &= ~RBUF_RXCHK_EN;
527527
priv->desc_rxchk_en = rx_csum_en;
@@ -1739,7 +1739,6 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
17391739
unsigned int bytes_processed = 0;
17401740
unsigned int p_index, mask;
17411741
unsigned int discards;
1742-
unsigned int chksum_ok = 0;
17431742

17441743
/* Clear status before servicing to reduce spurious interrupts */
17451744
if (ring->index == DESC_INDEX) {
@@ -1790,9 +1789,15 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
17901789
dmadesc_get_length_status(priv, cb->bd_addr);
17911790
} else {
17921791
struct status_64 *status;
1792+
__be16 rx_csum;
17931793

17941794
status = (struct status_64 *)skb->data;
17951795
dma_length_status = status->length_status;
1796+
rx_csum = (__force __be16)(status->rx_csum & 0xffff);
1797+
if (priv->desc_rxchk_en) {
1798+
skb->csum = (__force __wsum)ntohs(rx_csum);
1799+
skb->ip_summed = CHECKSUM_COMPLETE;
1800+
}
17961801
}
17971802

17981803
/* DMA flags and length are still valid no matter how
@@ -1835,18 +1840,12 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
18351840
goto next;
18361841
} /* error packet */
18371842

1838-
chksum_ok = (dma_flag & priv->dma_rx_chk_bit) &&
1839-
priv->desc_rxchk_en;
1840-
18411843
skb_put(skb, len);
18421844
if (priv->desc_64b_en) {
18431845
skb_pull(skb, 64);
18441846
len -= 64;
18451847
}
18461848

1847-
if (likely(chksum_ok))
1848-
skb->ip_summed = CHECKSUM_UNNECESSARY;
1849-
18501849
/* remove hardware 2bytes added for IP alignment */
18511850
skb_pull(skb, 2);
18521851
len -= 2;
@@ -3322,19 +3321,15 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
33223321
if (GENET_IS_V5(priv) || GENET_IS_V4(priv)) {
33233322
bcmgenet_dma_regs = bcmgenet_dma_regs_v3plus;
33243323
genet_dma_ring_regs = genet_dma_ring_regs_v4;
3325-
priv->dma_rx_chk_bit = DMA_RX_CHK_V3PLUS;
33263324
} else if (GENET_IS_V3(priv)) {
33273325
bcmgenet_dma_regs = bcmgenet_dma_regs_v3plus;
33283326
genet_dma_ring_regs = genet_dma_ring_regs_v123;
3329-
priv->dma_rx_chk_bit = DMA_RX_CHK_V3PLUS;
33303327
} else if (GENET_IS_V2(priv)) {
33313328
bcmgenet_dma_regs = bcmgenet_dma_regs_v2;
33323329
genet_dma_ring_regs = genet_dma_ring_regs_v123;
3333-
priv->dma_rx_chk_bit = DMA_RX_CHK_V12;
33343330
} else if (GENET_IS_V1(priv)) {
33353331
bcmgenet_dma_regs = bcmgenet_dma_regs_v1;
33363332
genet_dma_ring_regs = genet_dma_ring_regs_v123;
3337-
priv->dma_rx_chk_bit = DMA_RX_CHK_V12;
33383333
}
33393334

33403335
/* enum genet_version starts at 1 */

drivers/net/ethernet/broadcom/genet/bcmgenet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ struct bcmgenet_mib_counters {
251251
#define RBUF_CHK_CTRL 0x14
252252
#define RBUF_RXCHK_EN (1 << 0)
253253
#define RBUF_SKIP_FCS (1 << 4)
254+
#define RBUF_L3_PARSE_DIS (1 << 5)
254255

255256
#define RBUF_ENERGY_CTRL 0x9c
256257
#define RBUF_EEE_EN (1 << 0)
@@ -663,7 +664,6 @@ struct bcmgenet_priv {
663664
bool desc_rxchk_en;
664665
bool crc_fwd_en;
665666

666-
unsigned int dma_rx_chk_bit;
667667
u32 dma_max_burst_length;
668668

669669
u32 msg_enable;

0 commit comments

Comments
 (0)