mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
3abbac0b5d
Some CAN controllers don't implement a FIFO in hardware, but fill their mailboxes in a particular order (from lowest to highest or highest to lowest). This makes problems to read the frames in the correct order from the hardware, as new frames might be filled into just read (low) mailboxes. This gets worse, when following new frames are received into not read (higher) mailboxes. On the bright side some these CAN controllers put a timestamp on each received CAN frame. This patch adds support to offload CAN frames in interrupt context, order them by timestamp and then transmitted in a NAPI context. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
60 lines
1.9 KiB
C
60 lines
1.9 KiB
C
/*
|
|
* linux/can/rx-offload.h
|
|
*
|
|
* Copyright (c) 2014 David Jander, Protonic Holland
|
|
* Copyright (c) 2014-2017 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the version 2 of the GNU General Public License
|
|
* as published by the Free Software Foundation
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _CAN_RX_OFFLOAD_H
|
|
#define _CAN_RX_OFFLOAD_H
|
|
|
|
#include <linux/netdevice.h>
|
|
#include <linux/can.h>
|
|
|
|
struct can_rx_offload {
|
|
struct net_device *dev;
|
|
|
|
unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf,
|
|
u32 *timestamp, unsigned int mb);
|
|
|
|
struct sk_buff_head skb_queue;
|
|
u32 skb_queue_len_max;
|
|
|
|
unsigned int mb_first;
|
|
unsigned int mb_last;
|
|
|
|
struct napi_struct napi;
|
|
|
|
bool inc;
|
|
};
|
|
|
|
int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
|
|
int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight);
|
|
int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg);
|
|
int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
|
|
int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_buff *skb);
|
|
void can_rx_offload_reset(struct can_rx_offload *offload);
|
|
void can_rx_offload_del(struct can_rx_offload *offload);
|
|
void can_rx_offload_enable(struct can_rx_offload *offload);
|
|
|
|
static inline void can_rx_offload_schedule(struct can_rx_offload *offload)
|
|
{
|
|
napi_schedule(&offload->napi);
|
|
}
|
|
|
|
static inline void can_rx_offload_disable(struct can_rx_offload *offload)
|
|
{
|
|
napi_disable(&offload->napi);
|
|
}
|
|
|
|
#endif /* !_CAN_RX_OFFLOAD_H */
|