提交 24e10fc2 编写于 作者: M Marc Kleine-Budde 提交者: Greg Kroah-Hartman

can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails

[ Upstream commit 758124335a9dd649ab820bfb5b328170919ee7dc ]

The call to can_rx_offload_queue_sorted() may fail and return an error
(in the current implementation due to resource shortage). The passed skb
is consumed.

This patch adds incrementing of the appropriate error counters to let
the device statistics reflect that there's a problem.
Reported-by: NMartin Hundebøll <martin@geanix.com>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 ee798153
...@@ -566,6 +566,7 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) ...@@ -566,6 +566,7 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
struct can_frame *cf; struct can_frame *cf;
bool rx_errors = false, tx_errors = false; bool rx_errors = false, tx_errors = false;
u32 timestamp; u32 timestamp;
int err;
timestamp = priv->read(&regs->timer) << 16; timestamp = priv->read(&regs->timer) << 16;
...@@ -614,7 +615,9 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) ...@@ -614,7 +615,9 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
if (tx_errors) if (tx_errors)
dev->stats.tx_errors++; dev->stats.tx_errors++;
can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
if (err)
dev->stats.rx_fifo_errors++;
} }
static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
...@@ -627,6 +630,7 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) ...@@ -627,6 +630,7 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
int flt; int flt;
struct can_berr_counter bec; struct can_berr_counter bec;
u32 timestamp; u32 timestamp;
int err;
timestamp = priv->read(&regs->timer) << 16; timestamp = priv->read(&regs->timer) << 16;
...@@ -658,7 +662,9 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) ...@@ -658,7 +662,9 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
if (unlikely(new_state == CAN_STATE_BUS_OFF)) if (unlikely(new_state == CAN_STATE_BUS_OFF))
can_bus_off(dev); can_bus_off(dev);
can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
if (err)
dev->stats.rx_fifo_errors++;
} }
static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload) static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册