Skip to content

Commit

Permalink
Merge tag 'linux-can-next-for-5.20-20220731' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…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 <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 1, 2022
2 parents 6375722 + 7b584fb commit b7d8912
Show file tree
Hide file tree
Showing 53 changed files with 541 additions and 379 deletions.
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -18470,6 +18470,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git
F: include/linux/sl?b*.h
F: mm/sl?b*

SLCAN CAN NETWORK DRIVER
M: Dario Binacchi <dario.binacchi@amarulasolutions.com>
L: linux-can@vger.kernel.org
S: Maintained
F: drivers/net/can/slcan/

SLEEPABLE READ-COPY UPDATE (SRCU)
M: Lai Jiangshan <jiangshanlai@gmail.com>
M: "Paul E. McKenney" <paulmck@kernel.org>
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/at91_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/ethtool.h>
#include <linux/if_arp.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -1152,6 +1153,10 @@ static const struct net_device_ops at91_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops at91_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

static ssize_t mb0_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand Down Expand Up @@ -1293,6 +1298,7 @@ static int at91_can_probe(struct platform_device *pdev)
}

dev->netdev_ops = &at91_netdev_ops;
dev->ethtool_ops = &at91_ethtool_ops;
dev->irq = irq;
dev->flags |= IFF_ECHO;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/c_can/c_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int c_can_power_up(struct net_device *dev);
int c_can_power_down(struct net_device *dev);
#endif

void c_can_set_ethtool_ops(struct net_device *dev);
extern const struct ethtool_ops c_can_ethtool_ops;

static inline u8 c_can_get_tx_head(const struct c_can_tx_ring *ring)
{
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/can/c_can/c_can_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ static void c_can_get_ringparam(struct net_device *netdev,
ring->tx_pending = priv->msg_obj_tx_num;
}

static const struct ethtool_ops c_can_ethtool_ops = {
const struct ethtool_ops c_can_ethtool_ops = {
.get_ringparam = c_can_get_ringparam,
.get_ts_info = ethtool_op_get_ts_info,
};

void c_can_set_ethtool_ops(struct net_device *netdev)
{
netdev->ethtool_ops = &c_can_ethtool_ops;
}
2 changes: 1 addition & 1 deletion drivers/net/can/c_can/c_can_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ int register_c_can_dev(struct net_device *dev)

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

return register_candev(dev);
}
Expand Down
13 changes: 10 additions & 3 deletions drivers/net/can/can327.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Fred N. van Kempen <waltje@uwalt.nl.mugnet.org>
*/

#define pr_fmt(fmt) "can327: " fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

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

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

skb_tx_timestamp(skb);

out:
kfree_skb(skb);
return NETDEV_TX_OK;
Expand All @@ -848,6 +850,10 @@ static const struct net_device_ops can327_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops can327_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

static bool can327_is_valid_rx_char(u8 c)
{
static const bool lut_char_is_valid['z'] = {
Expand Down Expand Up @@ -1032,6 +1038,7 @@ static int can327_ldisc_open(struct tty_struct *tty)
/* Configure netdev interface */
elm->dev = dev;
dev->netdev_ops = &can327_netdev_ops;
dev->ethtool_ops = &can327_ethtool_ops;

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

static struct tty_ldisc_ops can327_ldisc = {
.owner = THIS_MODULE,
.name = "can327",
.name = KBUILD_MODNAME,
.num = N_CAN327,
.receive_buf = can327_ldisc_rx,
.write_wakeup = can327_ldisc_tx_wakeup,
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/cc770/cc770.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/ptrace.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
Expand Down Expand Up @@ -836,6 +837,10 @@ static const struct net_device_ops cc770_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops cc770_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

int register_cc770dev(struct net_device *dev)
{
struct cc770_priv *priv = netdev_priv(dev);
Expand All @@ -846,6 +851,7 @@ int register_cc770dev(struct net_device *dev)
return err;

dev->netdev_ops = &cc770_netdev_ops;
dev->ethtool_ops = &cc770_ethtool_ops;

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

Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/ctucanfd/ctucanfd_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/ethtool.h>
#include <linux/init.h>
#include <linux/bitfield.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -1301,6 +1302,10 @@ static const struct net_device_ops ctucan_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops ctucan_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

int ctucan_suspend(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
Expand Down Expand Up @@ -1377,6 +1382,7 @@ int ctucan_probe_common(struct device *dev, void __iomem *addr, int irq, unsigne
set_drvdata_fnc(dev, ndev);
SET_NETDEV_DEV(ndev, dev);
ndev->netdev_ops = &ctucan_netdev_ops;
ndev->ethtool_ops = &ctucan_ethtool_ops;

/* Getting the can_clk info */
if (!can_clk_rate) {
Expand Down
50 changes: 50 additions & 0 deletions drivers/net/can/dev/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,56 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
}
EXPORT_SYMBOL_GPL(can_change_mtu);

/* generic implementation of netdev_ops::ndo_eth_ioctl for CAN devices
* supporting hardware timestamps
*/
int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd)
{
struct hwtstamp_config hwts_cfg = { 0 };

switch (cmd) {
case SIOCSHWTSTAMP: /* set */
if (copy_from_user(&hwts_cfg, ifr->ifr_data, sizeof(hwts_cfg)))
return -EFAULT;
if (hwts_cfg.tx_type == HWTSTAMP_TX_ON &&
hwts_cfg.rx_filter == HWTSTAMP_FILTER_ALL)
return 0;
return -ERANGE;

case SIOCGHWTSTAMP: /* get */
hwts_cfg.tx_type = HWTSTAMP_TX_ON;
hwts_cfg.rx_filter = HWTSTAMP_FILTER_ALL;
if (copy_to_user(ifr->ifr_data, &hwts_cfg, sizeof(hwts_cfg)))
return -EFAULT;
return 0;

default:
return -EOPNOTSUPP;
}
}
EXPORT_SYMBOL(can_eth_ioctl_hwts);

/* generic implementation of ethtool_ops::get_ts_info for CAN devices
* supporting hardware timestamps
*/
int can_ethtool_op_get_ts_info_hwts(struct net_device *dev,
struct ethtool_ts_info *info)
{
info->so_timestamping =
SOF_TIMESTAMPING_TX_SOFTWARE |
SOF_TIMESTAMPING_RX_SOFTWARE |
SOF_TIMESTAMPING_SOFTWARE |
SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
info->phc_index = -1;
info->tx_types = BIT(HWTSTAMP_TX_ON);
info->rx_filters = BIT(HWTSTAMP_FILTER_ALL);

return 0;
}
EXPORT_SYMBOL(can_ethtool_op_get_ts_info_hwts);

/* Common open function when the device gets opened.
*
* This function should be called in the open function of the device
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/dev/skb.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
/* save frame_len to reuse it when transmission is completed */
can_skb_prv(skb)->frame_len = frame_len;

if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;

skb_tx_timestamp(skb);

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

if (skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)
skb_tstamp_tx(skb, skb_hwtstamps(skb));

/* get the real payload length for netdev statistics */
if (cf->can_id & CAN_RTR_FLAG)
*len_ptr = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/flexcan/flexcan-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ static int flexcan_probe(struct platform_device *pdev)
SET_NETDEV_DEV(dev, &pdev->dev);

dev->netdev_ops = &flexcan_netdev_ops;
flexcan_set_ethtool_ops(dev);
dev->ethtool_ops = &flexcan_ethtool_ops;
dev->irq = irq;
dev->flags |= IFF_ECHO;

Expand Down
8 changes: 2 additions & 6 deletions drivers/net/can/flexcan/flexcan-ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,11 @@ static int flexcan_get_sset_count(struct net_device *netdev, int sset)
}
}

static const struct ethtool_ops flexcan_ethtool_ops = {
const struct ethtool_ops flexcan_ethtool_ops = {
.get_ringparam = flexcan_get_ringparam,
.get_strings = flexcan_get_strings,
.get_priv_flags = flexcan_get_priv_flags,
.set_priv_flags = flexcan_set_priv_flags,
.get_sset_count = flexcan_get_sset_count,
.get_ts_info = ethtool_op_get_ts_info,
};

void flexcan_set_ethtool_ops(struct net_device *netdev)
{
netdev->ethtool_ops = &flexcan_ethtool_ops;
}
2 changes: 1 addition & 1 deletion drivers/net/can/flexcan/flexcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct flexcan_priv {
void (*write)(u32 val, void __iomem *addr);
};

void flexcan_set_ethtool_ops(struct net_device *dev);
extern const struct ethtool_ops flexcan_ethtool_ops;

static inline bool
flexcan_supports_rx_mailbox(const struct flexcan_priv *priv)
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/grcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/io.h>
#include <linux/can/dev.h>
#include <linux/spinlock.h>
Expand Down Expand Up @@ -1561,6 +1562,10 @@ static const struct net_device_ops grcan_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops grcan_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

static int grcan_setup_netdev(struct platform_device *ofdev,
void __iomem *base,
int irq, u32 ambafreq, bool txbug)
Expand All @@ -1577,6 +1582,7 @@ static int grcan_setup_netdev(struct platform_device *ofdev,
dev->irq = irq;
dev->flags |= IFF_ECHO;
dev->netdev_ops = &grcan_netdev_ops;
dev->ethtool_ops = &grcan_ethtool_ops;
dev->sysfs_groups[0] = &sysfs_grcan_group;

priv = netdev_priv(dev);
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/can/ifi_canfd/ifi_canfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -925,6 +926,10 @@ static const struct net_device_ops ifi_canfd_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops ifi_canfd_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

static int ifi_canfd_plat_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Expand Down Expand Up @@ -962,6 +967,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
ndev->irq = irq;
ndev->flags |= IFF_ECHO; /* we support local echo */
ndev->netdev_ops = &ifi_canfd_netdev_ops;
ndev->ethtool_ops = &ifi_canfd_ethtool_ops;

priv = netdev_priv(ndev);
priv->ndev = ndev;
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/can/janz-ican3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/platform_device.h>

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

skb_tx_timestamp(skb);

/* save this skb for tx interrupt echo handling */
skb_queue_tail(&mod->echoq, skb);
}
Expand Down Expand Up @@ -1752,6 +1755,10 @@ static const struct net_device_ops ican3_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};

static const struct ethtool_ops ican3_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};

/*
* Low-level CAN Device
*/
Expand Down Expand Up @@ -1923,6 +1930,7 @@ static int ican3_probe(struct platform_device *pdev)
mod->free_page = DPM_FREE_START;

ndev->netdev_ops = &ican3_netdev_ops;
ndev->ethtool_ops = &ican3_ethtool_ops;
ndev->flags |= IFF_ECHO;
SET_NETDEV_DEV(ndev, &pdev->dev);

Expand Down
Loading

0 comments on commit b7d8912

Please sign in to comment.