Commit 34355b67 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge tag 'linux-can-next-for-6.17-20250610' of...

Merge tag 'linux-can-next-for-6.17-20250610' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2025-06-10

The first 4 patches are by Vincent Mailhol and prepare the CAN netlink
interface for the introduction of CAN XL configuration.

Geert Uytterhoeven's patch updates the CAN networking documentation.

The last 2 patched are by Davide Caratti and introduce skb drop
reasons in the receive path of several CAN protocols.

* tag 'linux-can-next-for-6.17-20250610' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  can: add drop reasons in CAN protocols receive path
  can: add drop reasons in the receive path of AF_CAN
  documentation: networking: can: Document alloc_candev_mqs()
  can: netlink: can_changelink(): rename tdc_mask into fd_tdc_flag_provided
  can: bittiming: rename can_tdc_is_enabled() into can_fd_tdc_is_enabled()
  can: bittiming: rename CAN_CTRLMODE_TDC_MASK into CAN_CTRLMODE_FD_TDC_MASK
  can: netlink: replace tabulation by space in assignment
====================

Link: https://patch.msgid.link/20250610094933.1593081-1-mkl@pengutronix.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents c4246f4c af424041
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -1104,15 +1104,12 @@ for writing CAN network device driver are described below:
General Settings
----------------

.. code-block:: C

    dev->type  = ARPHRD_CAN; /* the netdevice hardware type */
    dev->flags = IFF_NOARP;  /* CAN has no arp */
CAN network device drivers can use alloc_candev_mqs() and friends instead of
alloc_netdev_mqs(), to automatically take care of CAN-specific setup:

    dev->mtu = CAN_MTU; /* sizeof(struct can_frame) -> Classical CAN interface */
.. code-block:: C

    or alternative, when the controller supports CAN with flexible data rate:
    dev->mtu = CANFD_MTU; /* sizeof(struct canfd_frame) -> CAN FD interface */
    dev = alloc_candev_mqs(...);

The struct can_frame or struct canfd_frame is the payload of each socket
buffer (skbuff) in the protocol family PF_CAN.
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
	if (!tdc_const || !(ctrlmode_supported & CAN_CTRLMODE_TDC_AUTO))
		return;

	*ctrlmode &= ~CAN_CTRLMODE_TDC_MASK;
	*ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;

	/* As specified in ISO 11898-1 section 11.3.3 "Transmitter
	 * delay compensation" (TDC) is only applicable if data BRP is
+13 −13
Original line number Diff line number Diff line
@@ -67,12 +67,12 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[],

	if (data[IFLA_CAN_CTRLMODE]) {
		struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]);
		u32 tdc_flags = cm->flags & CAN_CTRLMODE_TDC_MASK;
		u32 tdc_flags = cm->flags & CAN_CTRLMODE_FD_TDC_MASK;

		is_can_fd = cm->flags & cm->mask & CAN_CTRLMODE_FD;

		/* CAN_CTRLMODE_TDC_{AUTO,MANUAL} are mutually exclusive */
		if (tdc_flags == CAN_CTRLMODE_TDC_MASK)
		if (tdc_flags == CAN_CTRLMODE_FD_TDC_MASK)
			return -EOPNOTSUPP;
		/* If one of the CAN_CTRLMODE_TDC_* flag is set then
		 * TDC must be set and vice-versa
@@ -144,7 +144,7 @@ static int can_tdc_changelink(struct can_priv *priv, const struct nlattr *nla,
	const struct can_tdc_const *tdc_const = priv->fd.tdc_const;
	int err;

	if (!tdc_const || !can_tdc_is_enabled(priv))
	if (!tdc_const || !can_fd_tdc_is_enabled(priv))
		return -EOPNOTSUPP;

	err = nla_parse_nested(tb_tdc, IFLA_CAN_TDC_MAX, nla,
@@ -189,7 +189,7 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
			  struct netlink_ext_ack *extack)
{
	struct can_priv *priv = netdev_priv(dev);
	u32 tdc_mask = 0;
	bool fd_tdc_flag_provided = false;
	int err;

	/* We need synchronization with dev->stop() */
@@ -230,16 +230,16 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
			dev->mtu = CAN_MTU;
			memset(&priv->fd.data_bittiming, 0,
			       sizeof(priv->fd.data_bittiming));
			priv->ctrlmode &= ~CAN_CTRLMODE_TDC_MASK;
			priv->ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
			memset(&priv->fd.tdc, 0, sizeof(priv->fd.tdc));
		}

		tdc_mask = cm->mask & CAN_CTRLMODE_TDC_MASK;
		fd_tdc_flag_provided = cm->mask & CAN_CTRLMODE_FD_TDC_MASK;
		/* CAN_CTRLMODE_TDC_{AUTO,MANUAL} are mutually
		 * exclusive: make sure to turn the other one off
		 */
		if (tdc_mask)
			priv->ctrlmode &= cm->flags | ~CAN_CTRLMODE_TDC_MASK;
		if (fd_tdc_flag_provided)
			priv->ctrlmode &= cm->flags | ~CAN_CTRLMODE_FD_TDC_MASK;
	}

	if (data[IFLA_CAN_BITTIMING]) {
@@ -339,10 +339,10 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
			err = can_tdc_changelink(priv, data[IFLA_CAN_TDC],
						 extack);
			if (err) {
				priv->ctrlmode &= ~CAN_CTRLMODE_TDC_MASK;
				priv->ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
				return err;
			}
		} else if (!tdc_mask) {
		} else if (!fd_tdc_flag_provided) {
			/* Neither of TDC parameters nor TDC flags are
			 * provided: do calculation
			 */
@@ -409,7 +409,7 @@ static size_t can_tdc_get_size(const struct net_device *dev)
		size += nla_total_size(sizeof(u32));	/* IFLA_CAN_TDCF_MAX */
	}

	if (can_tdc_is_enabled(priv)) {
	if (can_fd_tdc_is_enabled(priv)) {
		if (priv->ctrlmode & CAN_CTRLMODE_TDC_MANUAL ||
		    priv->fd.do_get_auto_tdcv)
			size += nla_total_size(sizeof(u32));	/* IFLA_CAN_TDCV */
@@ -490,7 +490,7 @@ static int can_tdc_fill_info(struct sk_buff *skb, const struct net_device *dev)
	     nla_put_u32(skb, IFLA_CAN_TDC_TDCF_MAX, tdc_const->tdcf_max)))
		goto err_cancel;

	if (can_tdc_is_enabled(priv)) {
	if (can_fd_tdc_is_enabled(priv)) {
		u32 tdcv;
		int err = -EINVAL;

+1 −1
Original line number Diff line number Diff line
@@ -429,7 +429,7 @@ static int es58x_fd_enable_channel(struct es58x_priv *priv)
		es58x_fd_convert_bittiming(&tx_conf_msg.data_bittiming,
					   &priv->can.fd.data_bittiming);

		if (can_tdc_is_enabled(&priv->can)) {
		if (can_fd_tdc_is_enabled(&priv->can)) {
			tx_conf_msg.tdc_enabled = 1;
			tx_conf_msg.tdco = cpu_to_le16(priv->can.fd.tdc.tdco);
			tx_conf_msg.tdcf = cpu_to_le16(priv->can.fd.tdc.tdcf);
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ static int xcan_set_bittiming(struct net_device *ndev)
	    priv->devtype.cantype == XAXI_CANFD_2_0) {
		/* Setting Baud Rate prescaler value in F_BRPR Register */
		btr0 = dbt->brp - 1;
		if (can_tdc_is_enabled(&priv->can)) {
		if (can_fd_tdc_is_enabled(&priv->can)) {
			if (priv->devtype.cantype == XAXI_CANFD)
				btr0 |= FIELD_PREP(XCAN_BRPR_TDCO_MASK, priv->can.fd.tdc.tdco) |
					XCAN_BRPR_TDC_ENABLE;
Loading