Skip to content

Commit f04dd30

Browse files
Vishal Badolekuba-moo
authored andcommitted
amd-xgbe: Fix to ensure dependent features are toggled with RX checksum offload
According to the XGMAC specification, enabling features such as Layer 3 and Layer 4 Packet Filtering, Split Header and Virtualized Network support automatically selects the IPC Full Checksum Offload Engine on the receive side. When RX checksum offload is disabled, these dependent features must also be disabled to prevent abnormal behavior caused by mismatched feature dependencies. Ensure that toggling RX checksum offload (disabling or enabling) properly disables or enables all dependent features, maintaining consistent and expected behavior in the network device. Cc: [email protected] Fixes: 1a510cc ("amd-xgbe: Add support for VXLAN offload capabilities") Signed-off-by: Vishal Badole <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f73f05c commit f04dd30

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-desc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,13 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
373373
}
374374

375375
/* Set up the header page info */
376-
xgbe_set_buffer_data(&rdata->rx.hdr, &ring->rx_hdr_pa,
377-
XGBE_SKB_ALLOC_SIZE);
376+
if (pdata->netdev->features & NETIF_F_RXCSUM) {
377+
xgbe_set_buffer_data(&rdata->rx.hdr, &ring->rx_hdr_pa,
378+
XGBE_SKB_ALLOC_SIZE);
379+
} else {
380+
xgbe_set_buffer_data(&rdata->rx.hdr, &ring->rx_hdr_pa,
381+
pdata->rx_buf_size);
382+
}
378383

379384
/* Set up the buffer page info */
380385
xgbe_set_buffer_data(&rdata->rx.buf, &ring->rx_buf_pa,

drivers/net/ethernet/amd/xgbe/xgbe-dev.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ static void xgbe_config_sph_mode(struct xgbe_prv_data *pdata)
320320
XGMAC_IOWRITE_BITS(pdata, MAC_RCR, HDSMS, XGBE_SPH_HDSMS_SIZE);
321321
}
322322

323+
static void xgbe_disable_sph_mode(struct xgbe_prv_data *pdata)
324+
{
325+
unsigned int i;
326+
327+
for (i = 0; i < pdata->channel_count; i++) {
328+
if (!pdata->channel[i]->rx_ring)
329+
break;
330+
331+
XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_CR, SPH, 0);
332+
}
333+
}
334+
323335
static int xgbe_write_rss_reg(struct xgbe_prv_data *pdata, unsigned int type,
324336
unsigned int index, unsigned int val)
325337
{
@@ -3545,8 +3557,12 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
35453557
xgbe_config_tx_coalesce(pdata);
35463558
xgbe_config_rx_buffer_size(pdata);
35473559
xgbe_config_tso_mode(pdata);
3548-
xgbe_config_sph_mode(pdata);
3549-
xgbe_config_rss(pdata);
3560+
3561+
if (pdata->netdev->features & NETIF_F_RXCSUM) {
3562+
xgbe_config_sph_mode(pdata);
3563+
xgbe_config_rss(pdata);
3564+
}
3565+
35503566
desc_if->wrapper_tx_desc_init(pdata);
35513567
desc_if->wrapper_rx_desc_init(pdata);
35523568
xgbe_enable_dma_interrupts(pdata);
@@ -3702,5 +3718,9 @@ void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
37023718
hw_if->disable_vxlan = xgbe_disable_vxlan;
37033719
hw_if->set_vxlan_id = xgbe_set_vxlan_id;
37043720

3721+
/* For Split Header*/
3722+
hw_if->enable_sph = xgbe_config_sph_mode;
3723+
hw_if->disable_sph = xgbe_disable_sph_mode;
3724+
37053725
DBGPR("<--xgbe_init_function_ptrs\n");
37063726
}

drivers/net/ethernet/amd/xgbe/xgbe-drv.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,10 +2257,17 @@ static int xgbe_set_features(struct net_device *netdev,
22572257
if (ret)
22582258
return ret;
22592259

2260-
if ((features & NETIF_F_RXCSUM) && !rxcsum)
2260+
if ((features & NETIF_F_RXCSUM) && !rxcsum) {
2261+
hw_if->enable_sph(pdata);
2262+
hw_if->enable_vxlan(pdata);
22612263
hw_if->enable_rx_csum(pdata);
2262-
else if (!(features & NETIF_F_RXCSUM) && rxcsum)
2264+
schedule_work(&pdata->restart_work);
2265+
} else if (!(features & NETIF_F_RXCSUM) && rxcsum) {
2266+
hw_if->disable_sph(pdata);
2267+
hw_if->disable_vxlan(pdata);
22632268
hw_if->disable_rx_csum(pdata);
2269+
schedule_work(&pdata->restart_work);
2270+
}
22642271

22652272
if ((features & NETIF_F_HW_VLAN_CTAG_RX) && !rxvlan)
22662273
hw_if->enable_rx_vlan_stripping(pdata);

drivers/net/ethernet/amd/xgbe/xgbe.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,10 @@ struct xgbe_hw_if {
865865
void (*enable_vxlan)(struct xgbe_prv_data *);
866866
void (*disable_vxlan)(struct xgbe_prv_data *);
867867
void (*set_vxlan_id)(struct xgbe_prv_data *);
868+
869+
/* For Split Header */
870+
void (*enable_sph)(struct xgbe_prv_data *pdata);
871+
void (*disable_sph)(struct xgbe_prv_data *pdata);
868872
};
869873

870874
/* This structure represents implementation specific routines for an

0 commit comments

Comments
 (0)