Re: [PATCH v4 4/5] net: can: flexcan: use CAN FD frames for Tx/Rx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/12/2018 06:14 PM, Pankaj Bansal wrote:
> Use can FD frames for Tx/Rx operations. This would be needed in upcoming
> SOC LX2160A, which supports CAN FD protocol
> 
> Cc: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
> Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx>
> ---
> 
> Notes:
>     V4:
>      - Based on Oliver's suggestion, used canfd_frame for both CAN 2.0 and
>        FD frames.
>      - Pass SKB to mailbox_read instead of can frame.
>      - introduced skb_overflow in rx_overload.
>     V3:
>      - introduced fd_enable in rx_offload structure. This boolean indicates if
>        the FD mode is enabled or not.
>      - Based on fd_enable, send the CAN FD or CAN 2.0 frame to mailbox_read.
>      - in mailbox_read, detect the type of frame from fd_enable and fill the
>        values accordingly.
>      - in xmit function, detect the type of SKB received. if CAN FD SKB is
>        detected, tread its data as canfd_frame otherwise can_frame. Then fill
>        the values accordingly.
>     V2:
>      - No change
> 
>  drivers/net/can/flexcan.c      | 54 +++++++++++++++++++-------------
>  drivers/net/can/rx-offload.c   | 33 ++++++++++++++-----
>  include/linux/can/rx-offload.h |  6 +++-
>  3 files changed, 62 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index 3106134f3ba4..52c643d07f87 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -540,29 +540,31 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
>  static netdev_tx_t flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  {
>  	const struct flexcan_priv *priv = netdev_priv(dev);
> -	struct can_frame *cf = (struct can_frame *)skb->data;
> +	struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
>  	u32 can_id;
> -	u32 ctrl = FLEXCAN_MB_CODE_TX_DATA | (cf->can_dlc << 16);
> -	u8 can_dlc_dword, i;
> +	u32 ctrl = FLEXCAN_MB_CODE_TX_DATA | (can_len2dlc(cfd->len) << 16);
> +	u8 can_len_dword, i;
>  
>  	if (can_dropped_invalid_skb(dev, skb))
>  		return NETDEV_TX_OK;
>  
>  	netif_stop_queue(dev);
>  
> -	if (cf->can_id & CAN_EFF_FLAG) {
> -		can_id = cf->can_id & CAN_EFF_MASK;
> +	if (cfd->can_id & CAN_EFF_FLAG) {
> +		can_id = cfd->can_id & CAN_EFF_MASK;
>  		ctrl |= FLEXCAN_MB_CNT_IDE | FLEXCAN_MB_CNT_SRR;
>  	} else {
> -		can_id = (cf->can_id & CAN_SFF_MASK) << 18;
> +		can_id = (cfd->can_id & CAN_SFF_MASK) << 18;
>  	}
>  
> -	if (cf->can_id & CAN_RTR_FLAG)
> -		ctrl |= FLEXCAN_MB_CNT_RTR;
> +	if (likely(!can_is_canfd_skb(skb))) {

Don't introduce the likely, as you'll remove it in the later patch anyways.

> +		if (cfd->can_id & CAN_RTR_FLAG)
> +			ctrl |= FLEXCAN_MB_CNT_RTR;
> +	}

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux