diff options
Diffstat (limited to 'drivers/net/can/rx-offload.c')
-rw-r--r-- | drivers/net/can/rx-offload.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c index c7d05027a7a0..2ce4fa8698c7 100644 --- a/drivers/net/can/rx-offload.c +++ b/drivers/net/can/rx-offload.c | |||
@@ -211,7 +211,54 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload) | |||
211 | } | 211 | } |
212 | EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo); | 212 | EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo); |
213 | 213 | ||
214 | int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_buff *skb) | 214 | int can_rx_offload_queue_sorted(struct can_rx_offload *offload, |
215 | struct sk_buff *skb, u32 timestamp) | ||
216 | { | ||
217 | struct can_rx_offload_cb *cb; | ||
218 | unsigned long flags; | ||
219 | |||
220 | if (skb_queue_len(&offload->skb_queue) > | ||
221 | offload->skb_queue_len_max) | ||
222 | return -ENOMEM; | ||
223 | |||
224 | cb = can_rx_offload_get_cb(skb); | ||
225 | cb->timestamp = timestamp; | ||
226 | |||
227 | spin_lock_irqsave(&offload->skb_queue.lock, flags); | ||
228 | __skb_queue_add_sort(&offload->skb_queue, skb, can_rx_offload_compare); | ||
229 | spin_unlock_irqrestore(&offload->skb_queue.lock, flags); | ||
230 | |||
231 | can_rx_offload_schedule(offload); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | EXPORT_SYMBOL_GPL(can_rx_offload_queue_sorted); | ||
236 | |||
237 | unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload, | ||
238 | unsigned int idx, u32 timestamp) | ||
239 | { | ||
240 | struct net_device *dev = offload->dev; | ||
241 | struct net_device_stats *stats = &dev->stats; | ||
242 | struct sk_buff *skb; | ||
243 | u8 len; | ||
244 | int err; | ||
245 | |||
246 | skb = __can_get_echo_skb(dev, idx, &len); | ||
247 | if (!skb) | ||
248 | return 0; | ||
249 | |||
250 | err = can_rx_offload_queue_sorted(offload, skb, timestamp); | ||
251 | if (err) { | ||
252 | stats->rx_errors++; | ||
253 | stats->tx_fifo_errors++; | ||
254 | } | ||
255 | |||
256 | return len; | ||
257 | } | ||
258 | EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb); | ||
259 | |||
260 | int can_rx_offload_queue_tail(struct can_rx_offload *offload, | ||
261 | struct sk_buff *skb) | ||
215 | { | 262 | { |
216 | if (skb_queue_len(&offload->skb_queue) > | 263 | if (skb_queue_len(&offload->skb_queue) > |
217 | offload->skb_queue_len_max) | 264 | offload->skb_queue_len_max) |
@@ -222,7 +269,7 @@ int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_b | |||
222 | 269 | ||
223 | return 0; | 270 | return 0; |
224 | } | 271 | } |
225 | EXPORT_SYMBOL_GPL(can_rx_offload_irq_queue_err_skb); | 272 | EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail); |
226 | 273 | ||
227 | static int can_rx_offload_init_queue(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) | 274 | static int can_rx_offload_init_queue(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) |
228 | { | 275 | { |