Commit 30642471 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

Merge patch series "can: netlink: preparation before introduction of CAN XL"

Vincent Mailhol <mailhol.vincent@wanadoo.fr> says:

An RFC was sent last weekend to kick-off the discussion of the
introduction of CAN XL [1]. While the series received some positive
feedback, it is far from completion. Some work is still needed to:

  - adjust the nesting of the IFLA_CAN_XL_DATA_BITTIMING_CONST in the
    netlink interface

  - add the CAN XL PWM configuration

and this TODO list may grow if more feedback is received.

Regardless of this, the RFC started with a tree wide refactor followed
by a set of trivial patches to do some clean-up and some renaming in
preparation of the introduction of CAN XL.

This series just contains those preparation patch which were cherry
picked from the RFC and rebased on of top of linux-can-next/main:

  - the first patch is purely cosmetic and fixes a trivial tabulation
    mistake.

  - the last three patches do some renaming: both the CAN FD and the
    CAN XL have databittiming parameters. In order not to get confused
    once CAN XL will be introduced, many symbols are modified to
    explicitly add CAN FD in their names.

The goal is to have those merged first to remove some overhead from
the netlink CAN XL main series before tacking care of the other
comments.

[1] [RFC] can: netlink: add CAN XL
    Link: https://lore.kernel.org/linux-can/20241110155902.72807-16-mailhol.vincent@wanadoo.fr

Link: https://patch.msgid.link/20241112165118.586613-7-mailhol.vincent@wanadoo.fr


[mkl: adjusted commit message, as patch 1 of the original series is already mainline]
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents 2c7e4a26 527b99f4
Loading
Loading
Loading
Loading
+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;
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
#define CAN_BITRATE_UNSET 0
#define CAN_BITRATE_UNKNOWN (-1U)

#define CAN_CTRLMODE_TDC_MASK					\
#define CAN_CTRLMODE_FD_TDC_MASK				\
	(CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)

/*
Loading