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

can: dev: can_free_echo_skb(): extend to return can frame length

In order to implement byte queue limits (bql) in CAN drivers, the
length of the CAN frame needs to be passed into the networking stack
even if the transmission failed for some reason.

To avoid to calculate this length twice, extend can_free_echo_skb() to
return that value. Convert all users of this function, too.

This patch is the natural extension of commit:

| 9420e1d4 ("can: dev: can_get_echo_skb(): extend to return can
|                frame length")

Link: https://lore.kernel.org/r/20210319142700.305648-3-mkl@pengutronix.de


Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 4168d079
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -153,7 +153,8 @@ EXPORT_SYMBOL_GPL(can_get_echo_skb);
 *
 * The function is typically called when TX failed.
 */
void can_free_echo_skb(struct net_device *dev, unsigned int idx)
void can_free_echo_skb(struct net_device *dev, unsigned int idx,
		       unsigned int *frame_len_ptr)
{
	struct can_priv *priv = netdev_priv(dev);

@@ -164,7 +165,13 @@ void can_free_echo_skb(struct net_device *dev, unsigned int idx)
	}

	if (priv->echo_skb[idx]) {
		dev_kfree_skb_any(priv->echo_skb[idx]);
		struct sk_buff *skb = priv->echo_skb[idx];
		struct can_skb_priv *can_skb_priv = can_skb_prv(skb);

		if (frame_len_ptr)
			*frame_len_ptr = can_skb_priv->frame_len;

		dev_kfree_skb_any(skb);
		priv->echo_skb[idx] = NULL;
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -520,7 +520,7 @@ static int catch_up_echo_skb(struct net_device *dev, int budget, bool echo)
			can_get_echo_skb(dev, i, NULL);
		} else {
			/* For cleanup of untransmitted messages */
			can_free_echo_skb(dev, i);
			can_free_echo_skb(dev, i, NULL);
		}

		priv->eskbp = grcan_ring_add(priv->eskbp, GRCAN_MSG_SIZE,
+1 −1
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ static void m_can_clean(struct net_device *net)
			putidx = ((m_can_read(cdev, M_CAN_TXFQS) &
				   TXFQS_TFQPI_MASK) >> TXFQS_TFQPI_SHIFT);

		can_free_echo_skb(cdev->net, putidx);
		can_free_echo_skb(cdev->net, putidx, NULL);
		cdev->tx_skb = NULL;
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ static void tx_failure_cleanup(struct net_device *ndev)
	int i;

	for (i = 0; i < RCAR_CAN_FIFO_DEPTH; i++)
		can_free_echo_skb(ndev, i);
		can_free_echo_skb(ndev, i, NULL);
}

static void rcar_can_error(struct net_device *ndev)
+1 −1
Original line number Diff line number Diff line
@@ -617,7 +617,7 @@ static void rcar_canfd_tx_failure_cleanup(struct net_device *ndev)
	u32 i;

	for (i = 0; i < RCANFD_FIFO_DEPTH; i++)
		can_free_echo_skb(ndev, i);
		can_free_echo_skb(ndev, i, NULL);
}

static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
Loading