Skip to content

Commit b7d8912

Browse files
committed
Merge tag 'linux-can-next-for-5.20-20220731' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says: ==================== pull-request: can-next 2022-07-31 this is a pull request of 36 patches for net-next/master. The 1st patch is by me and fixes a typo in the mcp251xfd driver. Vincent Mailhol contributes a series of 9 patches, which clean up the drivers to make use of KBUILD_MODNAME instead of hard coded names and remove DRV_VERSION. Followed by 3 patches by Vincent Mailhol that directly set the ethtool_ops in instead of calling a function in the slcan, c_can and flexcan driver. Vincent Mailhol contributes a KBUILD_MODNAME and pr_fmt cleanup patch for the slcan driver. Dario Binacchi contributes 6 patches to clean up the driver and remove the legacy driver infrastructure. The next 14 patches are by Vincent Mailhol and target the various drivers, they add ethtool support and reporting of timestamping capabilities. Another patch by Vincent Mailhol for the etas_es58x driver to remove useless calls to usb_fill_bulk_urb(). The last patch is by Christophe JAILLET and fixes a broken link to Documentation in the can327 driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6375722 + 7b584fb commit b7d8912

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+541
-379
lines changed

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18470,6 +18470,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git
1847018470
F: include/linux/sl?b*.h
1847118471
F: mm/sl?b*
1847218472

18473+
SLCAN CAN NETWORK DRIVER
18474+
M: Dario Binacchi <[email protected]>
18475+
18476+
S: Maintained
18477+
F: drivers/net/can/slcan/
18478+
1847318479
SLEEPABLE READ-COPY UPDATE (SRCU)
1847418480
M: Lai Jiangshan <[email protected]>
1847518481
M: "Paul E. McKenney" <[email protected]>

drivers/net/can/at91_can.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/clk.h>
1010
#include <linux/errno.h>
11+
#include <linux/ethtool.h>
1112
#include <linux/if_arp.h>
1213
#include <linux/interrupt.h>
1314
#include <linux/kernel.h>
@@ -1152,6 +1153,10 @@ static const struct net_device_ops at91_netdev_ops = {
11521153
.ndo_change_mtu = can_change_mtu,
11531154
};
11541155

1156+
static const struct ethtool_ops at91_ethtool_ops = {
1157+
.get_ts_info = ethtool_op_get_ts_info,
1158+
};
1159+
11551160
static ssize_t mb0_id_show(struct device *dev,
11561161
struct device_attribute *attr, char *buf)
11571162
{
@@ -1293,6 +1298,7 @@ static int at91_can_probe(struct platform_device *pdev)
12931298
}
12941299

12951300
dev->netdev_ops = &at91_netdev_ops;
1301+
dev->ethtool_ops = &at91_ethtool_ops;
12961302
dev->irq = irq;
12971303
dev->flags |= IFF_ECHO;
12981304

drivers/net/can/c_can/c_can.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int c_can_power_up(struct net_device *dev);
223223
int c_can_power_down(struct net_device *dev);
224224
#endif
225225

226-
void c_can_set_ethtool_ops(struct net_device *dev);
226+
extern const struct ethtool_ops c_can_ethtool_ops;
227227

228228
static inline u8 c_can_get_tx_head(const struct c_can_tx_ring *ring)
229229
{

drivers/net/can/c_can/c_can_ethtool.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ static void c_can_get_ringparam(struct net_device *netdev,
2424
ring->tx_pending = priv->msg_obj_tx_num;
2525
}
2626

27-
static const struct ethtool_ops c_can_ethtool_ops = {
27+
const struct ethtool_ops c_can_ethtool_ops = {
2828
.get_ringparam = c_can_get_ringparam,
29+
.get_ts_info = ethtool_op_get_ts_info,
2930
};
30-
31-
void c_can_set_ethtool_ops(struct net_device *netdev)
32-
{
33-
netdev->ethtool_ops = &c_can_ethtool_ops;
34-
}

drivers/net/can/c_can/c_can_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ int register_c_can_dev(struct net_device *dev)
13641364

13651365
dev->flags |= IFF_ECHO; /* we support local echo */
13661366
dev->netdev_ops = &c_can_netdev_ops;
1367-
c_can_set_ethtool_ops(dev);
1367+
dev->ethtool_ops = &c_can_ethtool_ops;
13681368

13691369
return register_candev(dev);
13701370
}

drivers/net/can/can327.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Fred N. van Kempen <[email protected]>
1111
*/
1212

13-
#define pr_fmt(fmt) "can327: " fmt
13+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1414

1515
#include <linux/init.h>
1616
#include <linux/module.h>
@@ -827,7 +827,7 @@ static netdev_tx_t can327_netdev_start_xmit(struct sk_buff *skb,
827827
netif_stop_queue(dev);
828828

829829
/* BHs are already disabled, so no spin_lock_bh().
830-
* See Documentation/networking/netdevices.txt
830+
* See Documentation/networking/netdevices.rst
831831
*/
832832
spin_lock(&elm->lock);
833833
can327_send_frame(elm, frame);
@@ -836,6 +836,8 @@ static netdev_tx_t can327_netdev_start_xmit(struct sk_buff *skb,
836836
dev->stats.tx_packets++;
837837
dev->stats.tx_bytes += frame->can_id & CAN_RTR_FLAG ? 0 : frame->len;
838838

839+
skb_tx_timestamp(skb);
840+
839841
out:
840842
kfree_skb(skb);
841843
return NETDEV_TX_OK;
@@ -848,6 +850,10 @@ static const struct net_device_ops can327_netdev_ops = {
848850
.ndo_change_mtu = can_change_mtu,
849851
};
850852

853+
static const struct ethtool_ops can327_ethtool_ops = {
854+
.get_ts_info = ethtool_op_get_ts_info,
855+
};
856+
851857
static bool can327_is_valid_rx_char(u8 c)
852858
{
853859
static const bool lut_char_is_valid['z'] = {
@@ -1032,6 +1038,7 @@ static int can327_ldisc_open(struct tty_struct *tty)
10321038
/* Configure netdev interface */
10331039
elm->dev = dev;
10341040
dev->netdev_ops = &can327_netdev_ops;
1041+
dev->ethtool_ops = &can327_ethtool_ops;
10351042

10361043
/* Mark ldisc channel as alive */
10371044
elm->tty = tty;
@@ -1100,7 +1107,7 @@ static int can327_ldisc_ioctl(struct tty_struct *tty, unsigned int cmd,
11001107

11011108
static struct tty_ldisc_ops can327_ldisc = {
11021109
.owner = THIS_MODULE,
1103-
.name = "can327",
1110+
.name = KBUILD_MODNAME,
11041111
.num = N_CAN327,
11051112
.receive_buf = can327_ldisc_rx,
11061113
.write_wakeup = can327_ldisc_tx_wakeup,

drivers/net/can/cc770/cc770.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/ptrace.h>
1818
#include <linux/string.h>
1919
#include <linux/errno.h>
20+
#include <linux/ethtool.h>
2021
#include <linux/netdevice.h>
2122
#include <linux/if_arp.h>
2223
#include <linux/if_ether.h>
@@ -836,6 +837,10 @@ static const struct net_device_ops cc770_netdev_ops = {
836837
.ndo_change_mtu = can_change_mtu,
837838
};
838839

840+
static const struct ethtool_ops cc770_ethtool_ops = {
841+
.get_ts_info = ethtool_op_get_ts_info,
842+
};
843+
839844
int register_cc770dev(struct net_device *dev)
840845
{
841846
struct cc770_priv *priv = netdev_priv(dev);
@@ -846,6 +851,7 @@ int register_cc770dev(struct net_device *dev)
846851
return err;
847852

848853
dev->netdev_ops = &cc770_netdev_ops;
854+
dev->ethtool_ops = &cc770_ethtool_ops;
849855

850856
dev->flags |= IFF_ECHO; /* we support local echo */
851857

drivers/net/can/ctucanfd/ctucanfd_base.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <linux/clk.h>
2121
#include <linux/errno.h>
22+
#include <linux/ethtool.h>
2223
#include <linux/init.h>
2324
#include <linux/bitfield.h>
2425
#include <linux/interrupt.h>
@@ -1301,6 +1302,10 @@ static const struct net_device_ops ctucan_netdev_ops = {
13011302
.ndo_change_mtu = can_change_mtu,
13021303
};
13031304

1305+
static const struct ethtool_ops ctucan_ethtool_ops = {
1306+
.get_ts_info = ethtool_op_get_ts_info,
1307+
};
1308+
13041309
int ctucan_suspend(struct device *dev)
13051310
{
13061311
struct net_device *ndev = dev_get_drvdata(dev);
@@ -1377,6 +1382,7 @@ int ctucan_probe_common(struct device *dev, void __iomem *addr, int irq, unsigne
13771382
set_drvdata_fnc(dev, ndev);
13781383
SET_NETDEV_DEV(ndev, dev);
13791384
ndev->netdev_ops = &ctucan_netdev_ops;
1385+
ndev->ethtool_ops = &ctucan_ethtool_ops;
13801386

13811387
/* Getting the can_clk info */
13821388
if (!can_clk_rate) {

drivers/net/can/dev/dev.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,56 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
322322
}
323323
EXPORT_SYMBOL_GPL(can_change_mtu);
324324

325+
/* generic implementation of netdev_ops::ndo_eth_ioctl for CAN devices
326+
* supporting hardware timestamps
327+
*/
328+
int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd)
329+
{
330+
struct hwtstamp_config hwts_cfg = { 0 };
331+
332+
switch (cmd) {
333+
case SIOCSHWTSTAMP: /* set */
334+
if (copy_from_user(&hwts_cfg, ifr->ifr_data, sizeof(hwts_cfg)))
335+
return -EFAULT;
336+
if (hwts_cfg.tx_type == HWTSTAMP_TX_ON &&
337+
hwts_cfg.rx_filter == HWTSTAMP_FILTER_ALL)
338+
return 0;
339+
return -ERANGE;
340+
341+
case SIOCGHWTSTAMP: /* get */
342+
hwts_cfg.tx_type = HWTSTAMP_TX_ON;
343+
hwts_cfg.rx_filter = HWTSTAMP_FILTER_ALL;
344+
if (copy_to_user(ifr->ifr_data, &hwts_cfg, sizeof(hwts_cfg)))
345+
return -EFAULT;
346+
return 0;
347+
348+
default:
349+
return -EOPNOTSUPP;
350+
}
351+
}
352+
EXPORT_SYMBOL(can_eth_ioctl_hwts);
353+
354+
/* generic implementation of ethtool_ops::get_ts_info for CAN devices
355+
* supporting hardware timestamps
356+
*/
357+
int can_ethtool_op_get_ts_info_hwts(struct net_device *dev,
358+
struct ethtool_ts_info *info)
359+
{
360+
info->so_timestamping =
361+
SOF_TIMESTAMPING_TX_SOFTWARE |
362+
SOF_TIMESTAMPING_RX_SOFTWARE |
363+
SOF_TIMESTAMPING_SOFTWARE |
364+
SOF_TIMESTAMPING_TX_HARDWARE |
365+
SOF_TIMESTAMPING_RX_HARDWARE |
366+
SOF_TIMESTAMPING_RAW_HARDWARE;
367+
info->phc_index = -1;
368+
info->tx_types = BIT(HWTSTAMP_TX_ON);
369+
info->rx_filters = BIT(HWTSTAMP_FILTER_ALL);
370+
371+
return 0;
372+
}
373+
EXPORT_SYMBOL(can_ethtool_op_get_ts_info_hwts);
374+
325375
/* Common open function when the device gets opened.
326376
*
327377
* This function should be called in the open function of the device

drivers/net/can/dev/skb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
7272
/* save frame_len to reuse it when transmission is completed */
7373
can_skb_prv(skb)->frame_len = frame_len;
7474

75+
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
76+
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
77+
7578
skb_tx_timestamp(skb);
7679

7780
/* save this skb for tx interrupt echo handling */
@@ -107,6 +110,9 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr,
107110
struct can_skb_priv *can_skb_priv = can_skb_prv(skb);
108111
struct canfd_frame *cf = (struct canfd_frame *)skb->data;
109112

113+
if (skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)
114+
skb_tstamp_tx(skb, skb_hwtstamps(skb));
115+
110116
/* get the real payload length for netdev statistics */
111117
if (cf->can_id & CAN_RTR_FLAG)
112118
*len_ptr = 0;

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ static int flexcan_probe(struct platform_device *pdev)
21132113
SET_NETDEV_DEV(dev, &pdev->dev);
21142114

21152115
dev->netdev_ops = &flexcan_netdev_ops;
2116-
flexcan_set_ethtool_ops(dev);
2116+
dev->ethtool_ops = &flexcan_ethtool_ops;
21172117
dev->irq = irq;
21182118
dev->flags |= IFF_ECHO;
21192119

drivers/net/can/flexcan/flexcan-ethtool.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,11 @@ static int flexcan_get_sset_count(struct net_device *netdev, int sset)
100100
}
101101
}
102102

103-
static const struct ethtool_ops flexcan_ethtool_ops = {
103+
const struct ethtool_ops flexcan_ethtool_ops = {
104104
.get_ringparam = flexcan_get_ringparam,
105105
.get_strings = flexcan_get_strings,
106106
.get_priv_flags = flexcan_get_priv_flags,
107107
.set_priv_flags = flexcan_set_priv_flags,
108108
.get_sset_count = flexcan_get_sset_count,
109+
.get_ts_info = ethtool_op_get_ts_info,
109110
};
110-
111-
void flexcan_set_ethtool_ops(struct net_device *netdev)
112-
{
113-
netdev->ethtool_ops = &flexcan_ethtool_ops;
114-
}

drivers/net/can/flexcan/flexcan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct flexcan_priv {
114114
void (*write)(u32 val, void __iomem *addr);
115115
};
116116

117-
void flexcan_set_ethtool_ops(struct net_device *dev);
117+
extern const struct ethtool_ops flexcan_ethtool_ops;
118118

119119
static inline bool
120120
flexcan_supports_rx_mailbox(const struct flexcan_priv *priv)

drivers/net/can/grcan.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/interrupt.h>
2828
#include <linux/netdevice.h>
2929
#include <linux/delay.h>
30+
#include <linux/ethtool.h>
3031
#include <linux/io.h>
3132
#include <linux/can/dev.h>
3233
#include <linux/spinlock.h>
@@ -1561,6 +1562,10 @@ static const struct net_device_ops grcan_netdev_ops = {
15611562
.ndo_change_mtu = can_change_mtu,
15621563
};
15631564

1565+
static const struct ethtool_ops grcan_ethtool_ops = {
1566+
.get_ts_info = ethtool_op_get_ts_info,
1567+
};
1568+
15641569
static int grcan_setup_netdev(struct platform_device *ofdev,
15651570
void __iomem *base,
15661571
int irq, u32 ambafreq, bool txbug)
@@ -1577,6 +1582,7 @@ static int grcan_setup_netdev(struct platform_device *ofdev,
15771582
dev->irq = irq;
15781583
dev->flags |= IFF_ECHO;
15791584
dev->netdev_ops = &grcan_netdev_ops;
1585+
dev->ethtool_ops = &grcan_ethtool_ops;
15801586
dev->sysfs_groups[0] = &sysfs_grcan_group;
15811587

15821588
priv = netdev_priv(dev);

drivers/net/can/ifi_canfd/ifi_canfd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <linux/clk.h>
1515
#include <linux/delay.h>
16+
#include <linux/ethtool.h>
1617
#include <linux/interrupt.h>
1718
#include <linux/io.h>
1819
#include <linux/kernel.h>
@@ -925,6 +926,10 @@ static const struct net_device_ops ifi_canfd_netdev_ops = {
925926
.ndo_change_mtu = can_change_mtu,
926927
};
927928

929+
static const struct ethtool_ops ifi_canfd_ethtool_ops = {
930+
.get_ts_info = ethtool_op_get_ts_info,
931+
};
932+
928933
static int ifi_canfd_plat_probe(struct platform_device *pdev)
929934
{
930935
struct device *dev = &pdev->dev;
@@ -962,6 +967,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
962967
ndev->irq = irq;
963968
ndev->flags |= IFF_ECHO; /* we support local echo */
964969
ndev->netdev_ops = &ifi_canfd_netdev_ops;
970+
ndev->ethtool_ops = &ifi_canfd_ethtool_ops;
965971

966972
priv = netdev_priv(ndev);
967973
priv->ndev = ndev;

drivers/net/can/janz-ican3.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/module.h>
1010
#include <linux/interrupt.h>
1111
#include <linux/delay.h>
12+
#include <linux/ethtool.h>
1213
#include <linux/platform_device.h>
1314

1415
#include <linux/netdevice.h>
@@ -1277,6 +1278,8 @@ static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb)
12771278
if (!skb)
12781279
return;
12791280

1281+
skb_tx_timestamp(skb);
1282+
12801283
/* save this skb for tx interrupt echo handling */
12811284
skb_queue_tail(&mod->echoq, skb);
12821285
}
@@ -1752,6 +1755,10 @@ static const struct net_device_ops ican3_netdev_ops = {
17521755
.ndo_change_mtu = can_change_mtu,
17531756
};
17541757

1758+
static const struct ethtool_ops ican3_ethtool_ops = {
1759+
.get_ts_info = ethtool_op_get_ts_info,
1760+
};
1761+
17551762
/*
17561763
* Low-level CAN Device
17571764
*/
@@ -1923,6 +1930,7 @@ static int ican3_probe(struct platform_device *pdev)
19231930
mod->free_page = DPM_FREE_START;
19241931

19251932
ndev->netdev_ops = &ican3_netdev_ops;
1933+
ndev->ethtool_ops = &ican3_ethtool_ops;
19261934
ndev->flags |= IFF_ECHO;
19271935
SET_NETDEV_DEV(ndev, &pdev->dev);
19281936

0 commit comments

Comments
 (0)