mirror of
https://github.com/torvalds/linux.git
synced 2026-01-12 00:42:35 +08:00
can: treewide: remove can_change_mtu()
can_change_mtu() became obsolete by commit 2304993860 ("can: populate the
minimum and maximum MTU values"). Now that net_device->min_mtu and
net_device->max_mtu are populated, all the checks are already done by
dev_validate_mtu() in net/core/dev.c.
Remove the net_device_ops->ndo_change_mtu() callback of all the physical
interfaces, then remove can_change_mtu(). Only keep the vcan_change_mtu()
and vxcan_change_mtu() because the virtual interfaces use their own
different MTU logic.
The only functional change this patch introduces is that now the user will
be able to change the MTU even if the interface is up. This does not matter
for Classical CAN and CAN FD because their MTU range is composed of only
one value, respectively CAN_MTU and CANFD_MTU. For the upcoming CAN XL, the
MTU will be configurable within the CANXL_MIN_MTU to CANXL_MAX_MTU range at
any time, even if the interface is up. This is consistent with the other
net protocols and does not contradict ISO 11898-1:2024 as having a
modifiable MTU is a kernel extension.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Link: https://patch.msgid.link/20251003-remove-can_change_mtu-v1-1-337f8bc21181@kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
9271d0ea07
commit
f968a24cad
@@ -948,7 +948,6 @@ static const struct net_device_ops at91_netdev_ops = {
|
||||
.ndo_open = at91_open,
|
||||
.ndo_stop = at91_close,
|
||||
.ndo_start_xmit = at91_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops at91_ethtool_ops = {
|
||||
|
||||
@@ -881,7 +881,6 @@ static const struct net_device_ops bxcan_netdev_ops = {
|
||||
.ndo_open = bxcan_open,
|
||||
.ndo_stop = bxcan_stop,
|
||||
.ndo_start_xmit = bxcan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops bxcan_ethtool_ops = {
|
||||
|
||||
@@ -1362,7 +1362,6 @@ static const struct net_device_ops c_can_netdev_ops = {
|
||||
.ndo_open = c_can_open,
|
||||
.ndo_stop = c_can_close,
|
||||
.ndo_start_xmit = c_can_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
int register_c_can_dev(struct net_device *dev)
|
||||
|
||||
@@ -849,7 +849,6 @@ static const struct net_device_ops can327_netdev_ops = {
|
||||
.ndo_open = can327_netdev_open,
|
||||
.ndo_stop = can327_netdev_close,
|
||||
.ndo_start_xmit = can327_netdev_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops can327_ethtool_ops = {
|
||||
|
||||
@@ -834,7 +834,6 @@ static const struct net_device_ops cc770_netdev_ops = {
|
||||
.ndo_open = cc770_open,
|
||||
.ndo_stop = cc770_close,
|
||||
.ndo_start_xmit = cc770_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops cc770_ethtool_ops = {
|
||||
|
||||
@@ -1301,7 +1301,6 @@ static const struct net_device_ops ctucan_netdev_ops = {
|
||||
.ndo_open = ctucan_open,
|
||||
.ndo_stop = ctucan_close,
|
||||
.ndo_start_xmit = ctucan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ctucan_ethtool_ops = {
|
||||
|
||||
@@ -359,44 +359,6 @@ void can_set_default_mtu(struct net_device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* changing MTU and control mode for CAN/CANFD devices */
|
||||
int can_change_mtu(struct net_device *dev, int new_mtu)
|
||||
{
|
||||
struct can_priv *priv = netdev_priv(dev);
|
||||
u32 ctrlmode_static = can_get_static_ctrlmode(priv);
|
||||
|
||||
/* Do not allow changing the MTU while running */
|
||||
if (dev->flags & IFF_UP)
|
||||
return -EBUSY;
|
||||
|
||||
/* allow change of MTU according to the CANFD ability of the device */
|
||||
switch (new_mtu) {
|
||||
case CAN_MTU:
|
||||
/* 'CANFD-only' controllers can not switch to CAN_MTU */
|
||||
if (ctrlmode_static & CAN_CTRLMODE_FD)
|
||||
return -EINVAL;
|
||||
|
||||
priv->ctrlmode &= ~CAN_CTRLMODE_FD;
|
||||
break;
|
||||
|
||||
case CANFD_MTU:
|
||||
/* check for potential CANFD ability */
|
||||
if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) &&
|
||||
!(ctrlmode_static & CAN_CTRLMODE_FD))
|
||||
return -EINVAL;
|
||||
|
||||
priv->ctrlmode |= CAN_CTRLMODE_FD;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
WRITE_ONCE(dev->mtu, new_mtu);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(can_change_mtu);
|
||||
|
||||
/* helper to define static CAN controller features at device creation time */
|
||||
int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,6 @@ static const struct net_device_ops pci402_acc_netdev_ops = {
|
||||
.ndo_open = acc_open,
|
||||
.ndo_stop = acc_close,
|
||||
.ndo_start_xmit = acc_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
.ndo_eth_ioctl = can_eth_ioctl_hwts,
|
||||
};
|
||||
|
||||
|
||||
@@ -1867,7 +1867,6 @@ static const struct net_device_ops flexcan_netdev_ops = {
|
||||
.ndo_open = flexcan_open,
|
||||
.ndo_stop = flexcan_close,
|
||||
.ndo_start_xmit = flexcan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static int register_flexcandev(struct net_device *dev)
|
||||
|
||||
@@ -1561,7 +1561,6 @@ static const struct net_device_ops grcan_netdev_ops = {
|
||||
.ndo_open = grcan_open,
|
||||
.ndo_stop = grcan_close,
|
||||
.ndo_start_xmit = grcan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops grcan_ethtool_ops = {
|
||||
|
||||
@@ -944,7 +944,6 @@ static const struct net_device_ops ifi_canfd_netdev_ops = {
|
||||
.ndo_open = ifi_canfd_open,
|
||||
.ndo_stop = ifi_canfd_close,
|
||||
.ndo_start_xmit = ifi_canfd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ifi_canfd_ethtool_ops = {
|
||||
|
||||
@@ -1752,7 +1752,6 @@ static const struct net_device_ops ican3_netdev_ops = {
|
||||
.ndo_open = ican3_open,
|
||||
.ndo_stop = ican3_stop,
|
||||
.ndo_start_xmit = ican3_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ican3_ethtool_ops = {
|
||||
|
||||
@@ -904,7 +904,6 @@ static const struct net_device_ops kvaser_pciefd_netdev_ops = {
|
||||
.ndo_stop = kvaser_pciefd_stop,
|
||||
.ndo_eth_ioctl = can_eth_ioctl_hwts,
|
||||
.ndo_start_xmit = kvaser_pciefd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static int kvaser_pciefd_set_phys_id(struct net_device *netdev,
|
||||
|
||||
@@ -2148,7 +2148,6 @@ static const struct net_device_ops m_can_netdev_ops = {
|
||||
.ndo_open = m_can_open,
|
||||
.ndo_stop = m_can_close,
|
||||
.ndo_start_xmit = m_can_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static int m_can_get_coalesce(struct net_device *dev,
|
||||
|
||||
@@ -607,7 +607,6 @@ static const struct net_device_ops mscan_netdev_ops = {
|
||||
.ndo_open = mscan_open,
|
||||
.ndo_stop = mscan_close,
|
||||
.ndo_start_xmit = mscan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops mscan_ethtool_ops = {
|
||||
|
||||
@@ -773,7 +773,6 @@ static const struct net_device_ops peak_canfd_netdev_ops = {
|
||||
.ndo_stop = peak_canfd_close,
|
||||
.ndo_eth_ioctl = peak_eth_ioctl,
|
||||
.ndo_start_xmit = peak_canfd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static int peak_get_ts_info(struct net_device *dev,
|
||||
|
||||
@@ -635,7 +635,6 @@ static const struct net_device_ops rcar_can_netdev_ops = {
|
||||
.ndo_open = rcar_can_open,
|
||||
.ndo_stop = rcar_can_close,
|
||||
.ndo_start_xmit = rcar_can_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops rcar_can_ethtool_ops = {
|
||||
|
||||
@@ -1818,7 +1818,6 @@ static const struct net_device_ops rcar_canfd_netdev_ops = {
|
||||
.ndo_open = rcar_canfd_open,
|
||||
.ndo_stop = rcar_canfd_close,
|
||||
.ndo_start_xmit = rcar_canfd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops rcar_canfd_ethtool_ops = {
|
||||
|
||||
@@ -761,7 +761,6 @@ static const struct net_device_ops rkcanfd_netdev_ops = {
|
||||
.ndo_open = rkcanfd_open,
|
||||
.ndo_stop = rkcanfd_stop,
|
||||
.ndo_start_xmit = rkcanfd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static int __maybe_unused rkcanfd_runtime_suspend(struct device *dev)
|
||||
|
||||
@@ -697,7 +697,6 @@ static const struct net_device_ops sja1000_netdev_ops = {
|
||||
.ndo_open = sja1000_open,
|
||||
.ndo_stop = sja1000_close,
|
||||
.ndo_start_xmit = sja1000_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops sja1000_ethtool_ops = {
|
||||
|
||||
@@ -774,7 +774,6 @@ static const struct net_device_ops slcan_netdev_ops = {
|
||||
.ndo_open = slcan_netdev_open,
|
||||
.ndo_stop = slcan_netdev_close,
|
||||
.ndo_start_xmit = slcan_netdev_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
/******************************************
|
||||
|
||||
@@ -609,7 +609,6 @@ static const struct net_device_ops softing_netdev_ops = {
|
||||
.ndo_open = softing_netdev_open,
|
||||
.ndo_stop = softing_netdev_stop,
|
||||
.ndo_start_xmit = softing_netdev_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops softing_ethtool_ops = {
|
||||
|
||||
@@ -799,7 +799,6 @@ static const struct net_device_ops hi3110_netdev_ops = {
|
||||
.ndo_open = hi3110_open,
|
||||
.ndo_stop = hi3110_stop,
|
||||
.ndo_start_xmit = hi3110_hard_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops hi3110_ethtool_ops = {
|
||||
|
||||
@@ -1270,7 +1270,6 @@ static const struct net_device_ops mcp251x_netdev_ops = {
|
||||
.ndo_open = mcp251x_open,
|
||||
.ndo_stop = mcp251x_stop,
|
||||
.ndo_start_xmit = mcp251x_hard_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops mcp251x_ethtool_ops = {
|
||||
|
||||
@@ -1715,7 +1715,6 @@ static const struct net_device_ops mcp251xfd_netdev_ops = {
|
||||
.ndo_stop = mcp251xfd_stop,
|
||||
.ndo_start_xmit = mcp251xfd_start_xmit,
|
||||
.ndo_eth_ioctl = can_eth_ioctl_hwts,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
@@ -768,7 +768,6 @@ static const struct net_device_ops sun4ican_netdev_ops = {
|
||||
.ndo_open = sun4ican_open,
|
||||
.ndo_stop = sun4ican_close,
|
||||
.ndo_start_xmit = sun4ican_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops sun4ican_ethtool_ops = {
|
||||
|
||||
@@ -829,7 +829,6 @@ static const struct net_device_ops ti_hecc_netdev_ops = {
|
||||
.ndo_open = ti_hecc_open,
|
||||
.ndo_stop = ti_hecc_close,
|
||||
.ndo_start_xmit = ti_hecc_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ti_hecc_ethtool_ops = {
|
||||
|
||||
@@ -885,7 +885,6 @@ static const struct net_device_ops ems_usb_netdev_ops = {
|
||||
.ndo_open = ems_usb_open,
|
||||
.ndo_stop = ems_usb_close,
|
||||
.ndo_start_xmit = ems_usb_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ems_usb_ethtool_ops = {
|
||||
|
||||
@@ -1011,7 +1011,6 @@ static const struct net_device_ops esd_usb_netdev_ops = {
|
||||
.ndo_open = esd_usb_open,
|
||||
.ndo_stop = esd_usb_close,
|
||||
.ndo_start_xmit = esd_usb_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops esd_usb_ethtool_ops = {
|
||||
|
||||
@@ -1977,7 +1977,6 @@ static const struct net_device_ops es58x_netdev_ops = {
|
||||
.ndo_stop = es58x_stop,
|
||||
.ndo_start_xmit = es58x_start_xmit,
|
||||
.ndo_eth_ioctl = can_eth_ioctl_hwts,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops es58x_ethtool_ops = {
|
||||
|
||||
@@ -1052,7 +1052,6 @@ static const struct net_device_ops f81604_netdev_ops = {
|
||||
.ndo_open = f81604_open,
|
||||
.ndo_stop = f81604_close,
|
||||
.ndo_start_xmit = f81604_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct can_bittiming_const f81604_bittiming_const = {
|
||||
|
||||
@@ -1101,7 +1101,6 @@ static const struct net_device_ops gs_usb_netdev_ops = {
|
||||
.ndo_open = gs_can_open,
|
||||
.ndo_stop = gs_can_close,
|
||||
.ndo_start_xmit = gs_can_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
.ndo_eth_ioctl = gs_can_eth_ioctl,
|
||||
};
|
||||
|
||||
|
||||
@@ -786,7 +786,6 @@ static const struct net_device_ops kvaser_usb_netdev_ops = {
|
||||
.ndo_stop = kvaser_usb_close,
|
||||
.ndo_eth_ioctl = can_eth_ioctl_hwts,
|
||||
.ndo_start_xmit = kvaser_usb_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops kvaser_usb_ethtool_ops = {
|
||||
|
||||
@@ -761,7 +761,6 @@ static const struct net_device_ops mcba_netdev_ops = {
|
||||
.ndo_open = mcba_usb_open,
|
||||
.ndo_stop = mcba_usb_close,
|
||||
.ndo_start_xmit = mcba_usb_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops mcba_ethtool_ops = {
|
||||
|
||||
@@ -690,7 +690,6 @@ static const struct net_device_ops nct6694_canfd_netdev_ops = {
|
||||
.ndo_open = nct6694_canfd_open,
|
||||
.ndo_stop = nct6694_canfd_close,
|
||||
.ndo_start_xmit = nct6694_canfd_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops nct6694_canfd_ethtool_ops = {
|
||||
|
||||
@@ -814,7 +814,6 @@ static const struct net_device_ops peak_usb_netdev_ops = {
|
||||
.ndo_stop = peak_usb_ndo_stop,
|
||||
.ndo_eth_ioctl = peak_eth_ioctl,
|
||||
.ndo_start_xmit = peak_usb_ndo_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
/* CAN-USB devices generally handle 32-bit CAN channel IDs.
|
||||
|
||||
@@ -1233,7 +1233,6 @@ static const struct net_device_ops ucan_netdev_ops = {
|
||||
.ndo_open = ucan_open,
|
||||
.ndo_stop = ucan_close,
|
||||
.ndo_start_xmit = ucan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops ucan_ethtool_ops = {
|
||||
|
||||
@@ -868,7 +868,6 @@ static const struct net_device_ops usb_8dev_netdev_ops = {
|
||||
.ndo_open = usb_8dev_open,
|
||||
.ndo_stop = usb_8dev_close,
|
||||
.ndo_start_xmit = usb_8dev_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops usb_8dev_ethtool_ops = {
|
||||
|
||||
@@ -1702,7 +1702,6 @@ static const struct net_device_ops xcan_netdev_ops = {
|
||||
.ndo_open = xcan_open,
|
||||
.ndo_stop = xcan_close,
|
||||
.ndo_start_xmit = xcan_start_xmit,
|
||||
.ndo_change_mtu = can_change_mtu,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops xcan_ethtool_ops = {
|
||||
|
||||
@@ -127,7 +127,6 @@ struct can_priv *safe_candev_priv(struct net_device *dev);
|
||||
int open_candev(struct net_device *dev);
|
||||
void close_candev(struct net_device *dev);
|
||||
void can_set_default_mtu(struct net_device *dev);
|
||||
int can_change_mtu(struct net_device *dev, int new_mtu);
|
||||
int __must_check can_set_static_ctrlmode(struct net_device *dev,
|
||||
u32 static_mode);
|
||||
int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd);
|
||||
|
||||
Reference in New Issue
Block a user