Use can FD frames for Tx/Rx operations. This would be needed in upcoming SOC LX2160A, which supports CAN FD protocol Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx> --- drivers/net/can/flexcan.c | 13 +++++++------ drivers/net/can/rx-offload.c | 10 +++++----- include/linux/can/rx-offload.h | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 147405e703f0..c3507bb48f9a 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -524,10 +524,10 @@ 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 *cf = (struct canfd_frame *)skb->data; u32 can_id; u32 data, i; - u32 ctrl = FLEXCAN_MB_CODE_TX_DATA | (cf->can_dlc << 16); + u32 ctrl = FLEXCAN_MB_CODE_TX_DATA | (can_len2dlc(cf->len) << 16); u8 can_dlc_dword; if (can_dropped_invalid_skb(dev, skb)) @@ -545,7 +545,7 @@ static netdev_tx_t flexcan_start_xmit(struct sk_buff *skb, struct net_device *de if (cf->can_id & CAN_RTR_FLAG) ctrl |= FLEXCAN_MB_CNT_RTR; - can_dlc_dword = (cf->can_dlc + sizeof(u32) - 1) / sizeof(u32); + can_dlc_dword = (cf->len + sizeof(u32) - 1) / sizeof(u32); for (i = 0; i < can_dlc_dword; i++) { data = be32_to_cpup((__be32 *)&cf->data[(i * sizeof(u32))]); priv->write(data, &priv->tx_mb->data[i]); @@ -668,7 +668,7 @@ static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *off } static unsigned int flexcan_mailbox_read(struct can_rx_offload *offload, - struct can_frame *cf, + struct canfd_frame *cf, u32 *timestamp, unsigned int n) { struct flexcan_priv *priv = rx_offload_to_priv(offload); @@ -724,9 +724,10 @@ static unsigned int flexcan_mailbox_read(struct can_rx_offload *offload, if (reg_ctrl & FLEXCAN_MB_CNT_RTR) cf->can_id |= CAN_RTR_FLAG; - cf->can_dlc = get_can_dlc((reg_ctrl >> 16) & 0xf); - can_dlc_dword = (cf->can_dlc + sizeof(u32) - 1) / sizeof(u32); + cf->len = get_can_dlc((reg_ctrl >> 16) & 0xf); + + can_dlc_dword = (cf->len + sizeof(u32) - 1) / sizeof(u32); for (i = 0; i < can_dlc_dword; i++) { data = cpu_to_be32(priv->read(&mb->data[i])); *(__be32 *)(cf->data + (i * sizeof(u32))) = data; diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c index d94dae216820..cf4092d37c9e 100644 --- a/drivers/net/can/rx-offload.c +++ b/drivers/net/can/rx-offload.c @@ -55,11 +55,11 @@ static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota) while ((work_done < quota) && (skb = skb_dequeue(&offload->skb_queue))) { - struct can_frame *cf = (struct can_frame *)skb->data; + struct canfd_frame *cf = (struct canfd_frame *)skb->data; work_done++; stats->rx_packets++; - stats->rx_bytes += cf->can_dlc; + stats->rx_bytes += cf->len; netif_receive_skb(skb); } @@ -120,16 +120,16 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload { struct sk_buff *skb = NULL; struct can_rx_offload_cb *cb; - struct can_frame *cf; + struct canfd_frame *cf; int ret; /* If queue is full or skb not available, read to discard mailbox */ if (likely(skb_queue_len(&offload->skb_queue) <= offload->skb_queue_len_max)) - skb = alloc_can_skb(offload->dev, &cf); + skb = alloc_canfd_skb(offload->dev, &cf); if (!skb) { - struct can_frame cf_overflow; + struct canfd_frame cf_overflow; u32 timestamp; ret = offload->mailbox_read(offload, &cf_overflow, diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h index cb31683bbe15..47711020b058 100644 --- a/include/linux/can/rx-offload.h +++ b/include/linux/can/rx-offload.h @@ -23,7 +23,8 @@ struct can_rx_offload { struct net_device *dev; - unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf, + unsigned int (*mailbox_read)(struct can_rx_offload *offload, + struct canfd_frame *cf, u32 *timestamp, unsigned int mb); struct sk_buff_head skb_queue; -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html