nvethernet: Reduce mtu if macsec enabled

Reduce mtu size due to macsec sectag in probe and change_mtu call
instead of open call to avoid wrong update of mtu size when interface up/down
is performed.

Bug 200730979

Change-Id: I17198d25295bc40d37204f5d0603696a0071f490
Signed-off-by: Mahesh Patil <maheshp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2529412
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Mahesh Patil
2021-05-13 16:32:52 -07:00
committed by Revanth Kumar Uppala
parent d814423323
commit c804eef959

View File

@@ -2212,17 +2212,6 @@ static int ether_open(struct net_device *dev)
goto err_alloc;
}
#ifdef MACSEC_SUPPORT
/* Macsec is initialized, reduce MTU
* TODO: MTU_ADDONS also to be reduced ?
*/
osi_core->mtu -= MACSEC_TAG_ICV_LEN;
pdata->osi_dma->mtu = osi_core->mtu;
pdata->ndev->mtu = osi_core->mtu;
dev_info(&dev->dev, "Macsec: Reduced MTU: %d Max: %d\n",
pdata->ndev->mtu, pdata->ndev->max_mtu);
#endif /* MACSEC_SUPPORT */
#ifdef THERMAL_CAL
atomic_set(&pdata->therm_state, 0);
ret = ether_therm_init(pdata);
@@ -3371,6 +3360,16 @@ static int ether_change_mtu(struct net_device *ndev, int new_mtu)
osi_core->mtu = new_mtu;
osi_dma->mtu = new_mtu;
#ifdef MACSEC_SUPPORT
/* Macsec is enabled, reduce MTU
*/
osi_core->mtu -= MACSEC_TAG_ICV_LEN;
osi_dma->mtu = osi_core->mtu;
ndev->mtu = osi_core->mtu;
netdev_info(pdata->ndev, "Macsec: Reduced MTU: %d Max: %d\n",
ndev->mtu, ndev->max_mtu);
#endif /* MACSEC_SUPPORT */
netdev_update_features(ndev);
return 0;
@@ -5430,7 +5429,6 @@ static int ether_probe(struct platform_device *pdev)
osi_core->mtu = ndev->mtu;
osi_dma->mtu = ndev->mtu;
tegra_pre_si_platform(osi_core, osi_dma);
/* Parse the ethernet DT node */
@@ -5544,6 +5542,14 @@ static int ether_probe(struct platform_device *pdev)
; //Nothing to do, macsec is not supported
dev_info(&pdev->dev, "Macsec not enabled - ignore\n");
}
/* Macsec is enabled, reduce MTU
*/
osi_core->mtu -= MACSEC_TAG_ICV_LEN;
osi_dma->mtu = osi_core->mtu;
ndev->mtu = osi_core->mtu;
dev_info(&pdev->dev, "Macsec: Reduced MTU: %d Max: %d\n",
ndev->mtu, ndev->max_mtu);
#endif /* MACSEC_SUPPORT */
ret = register_netdev(ndev);