Skip to content

Commit 78d6102

Browse files
Niklas Söderlunddavem330
authored andcommitted
sh_eth: add support for changing MTU
The hardware supports the MTU to be changed and the driver it self is somewhat prepared to support this. This patch hooks up the callbacks to be able to change the MTU from user-space. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f1c9eed commit 78d6102

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,6 +2558,17 @@ static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
25582558
return phy_mii_ioctl(phydev, rq, cmd);
25592559
}
25602560

2561+
static int sh_eth_change_mtu(struct net_device *ndev, int new_mtu)
2562+
{
2563+
if (netif_running(ndev))
2564+
return -EBUSY;
2565+
2566+
ndev->mtu = new_mtu;
2567+
netdev_update_features(ndev);
2568+
2569+
return 0;
2570+
}
2571+
25612572
/* For TSU_POSTn. Please refer to the manual about this (strange) bitfields */
25622573
static void *sh_eth_tsu_get_post_reg_offset(struct sh_eth_private *mdp,
25632574
int entry)
@@ -3029,6 +3040,7 @@ static const struct net_device_ops sh_eth_netdev_ops = {
30293040
.ndo_set_rx_mode = sh_eth_set_rx_mode,
30303041
.ndo_tx_timeout = sh_eth_tx_timeout,
30313042
.ndo_do_ioctl = sh_eth_do_ioctl,
3043+
.ndo_change_mtu = sh_eth_change_mtu,
30323044
.ndo_validate_addr = eth_validate_addr,
30333045
.ndo_set_mac_address = eth_mac_addr,
30343046
};
@@ -3043,6 +3055,7 @@ static const struct net_device_ops sh_eth_netdev_ops_tsu = {
30433055
.ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid,
30443056
.ndo_tx_timeout = sh_eth_tx_timeout,
30453057
.ndo_do_ioctl = sh_eth_do_ioctl,
3058+
.ndo_change_mtu = sh_eth_change_mtu,
30463059
.ndo_validate_addr = eth_validate_addr,
30473060
.ndo_set_mac_address = eth_mac_addr,
30483061
};
@@ -3171,6 +3184,13 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
31713184
}
31723185
sh_eth_set_default_cpu_data(mdp->cd);
31733186

3187+
/* User's manual states max MTU should be 2048 but due to the
3188+
* alignment calculations in sh_eth_ring_init() the practical
3189+
* MTU is a bit less. Maybe this can be optimized some more.
3190+
*/
3191+
ndev->max_mtu = 2000 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
3192+
ndev->min_mtu = ETH_MIN_MTU;
3193+
31743194
/* set function */
31753195
if (mdp->cd->tsu)
31763196
ndev->netdev_ops = &sh_eth_netdev_ops_tsu;

0 commit comments

Comments
 (0)