summaryrefslogtreecommitdiff
path: root/drivers/net/can/dev/skb.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2021-01-11 15:19:26 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-01-14 08:43:42 +0100
commitf0ef72febc9a6a569d92cdf6c7996015dfa8e8bb (patch)
tree40fbc46bccc61acf0bee154a2ad645a52451fa9c /drivers/net/can/dev/skb.c
parent85d99c3e2a13d542445342a1383a686dadeaac3d (diff)
can: dev: extend struct can_skb_priv to hold 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 after queueing and after transmission completion. To avoid to calculate this length twice, extend the struct can_skb_priv to hold the length of the CAN frame and extend __can_get_echo_skb() to return that value. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-12-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/dev/skb.c')
-rw-r--r--drivers/net/can/dev/skb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
index 26cd597ff771..24f782a23409 100644
--- a/drivers/net/can/dev/skb.c
+++ b/drivers/net/can/dev/skb.c
@@ -76,7 +76,8 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
EXPORT_SYMBOL_GPL(can_put_echo_skb);
struct sk_buff *
-__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
+__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr,
+ unsigned int *frame_len_ptr)
{
struct can_priv *priv = netdev_priv(dev);
@@ -91,6 +92,7 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
* length is supported on both CAN and CANFD frames.
*/
struct sk_buff *skb = priv->echo_skb[idx];
+ struct can_skb_priv *can_skb_priv = can_skb_prv(skb);
struct canfd_frame *cf = (struct canfd_frame *)skb->data;
/* get the real payload length for netdev statistics */
@@ -99,6 +101,9 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
else
*len_ptr = cf->len;
+ if (frame_len_ptr)
+ *frame_len_ptr = can_skb_priv->frame_len;
+
priv->echo_skb[idx] = NULL;
return skb;
@@ -118,7 +123,7 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
struct sk_buff *skb;
u8 len;
- skb = __can_get_echo_skb(dev, idx, &len);
+ skb = __can_get_echo_skb(dev, idx, &len, NULL);
if (!skb)
return 0;