CTU CAN FD core support
Subsystems (3)
PATCH v2 2/7 hw/net/can: sja1000 ignore CAN FD frames
In reply to [email protected]From: Jan Charvat <[email protected]>
--- hw/net/can/can_sja1000.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
hw/net/can/can_sja1000.c +23 -6
@@ -323,11 +323,16 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame)static int frame2buff_pel (const qemu_can_frame *frame,uint8_t *buff) {int i; +int dlen = frame->can_dlc;if (frame->can_id &QEMU_CAN_ERR_FLAG ) {/* error frame, NOT support now. */ return -1 ; } +if (dlen >8 ) { +return -1 ; + } + buff[0 ] =0x0f & frame->can_dlc;/* DLC */ if (frame->can_id &QEMU_CAN_RTR_FLAG ) {/* RTR */ buff[0 ] |= (1 <<6 );
@@ -338,18 +343,18 @@ static int frame2buff_pel(const qemu_can_frame *frame, uint8_t *buff) buff[2 ] =extract32 (frame->can_id,13 ,8 );/* ID.20~ID.13 */ buff[3 ] =extract32 (frame->can_id,5 ,8 );/* ID.12~ID.05 */ buff[4 ] =extract32 (frame->can_id,0 ,5 ) <<3 ;/* ID.04~ID.00,xxx */ -for (i =0 ; i < frame->can_dlc; i++) { +for (i =0 ; i < dlen; i++) { buff[5 + i] = frame->data[i]; } -return frame->can_dlc +5 ; +return dlen +5 ; }else {/* SFF */ buff[1 ] =extract32 (frame->can_id,3 ,8 );/* ID.10~ID.03 */ buff[2 ] =extract32 (frame->can_id,0 ,3 ) <<5 ;/* ID.02~ID.00,xxxxx */ -for (i =0 ; i < frame->can_dlc; i++) { +for (i =0 ; i < dlen; i++) { buff[3 + i] = frame->data[i]; } -return frame->can_dlc +3 ; +return dlen +3 ; }return -1 ;
@@ -358,6 +363,7 @@ static int frame2buff_pel(const qemu_can_frame *frame, uint8_t *buff)static int frame2buff_bas (const qemu_can_frame *frame,uint8_t *buff) {int i; +int dlen = frame->can_dlc;/* * EFF, no support for BasicMode
@@ -369,17 +375,21 @@ static int frame2buff_bas(const qemu_can_frame *frame, uint8_t *buff)return -1 ; } +if (dlen >8 ) { +return -1 ; + } + buff[0 ] =extract32 (frame->can_id,3 ,8 );/* ID.10~ID.03 */ buff[1 ] =extract32 (frame->can_id,0 ,3 ) <<5 ;/* ID.02~ID.00,xxxxx */ if (frame->can_id &QEMU_CAN_RTR_FLAG ) {/* RTR */ buff[1 ] |= (1 <<4 ); } buff[1 ] |= frame->can_dlc &0x0f ; -for (i =0 ; i < frame->can_dlc; i++) { +for (i =0 ; i < dlen; i++) { buff[2 + i] = frame->data[i]; } -return frame->can_dlc +2 ; +return dlen +2 ; }static void can_sja_update_pel_irq (CanSJA1000State *s)
@@ -766,6 +776,13 @@ ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,if (frames_cnt <=0 ) {return 0 ; } +if (frame->flags &&QEMU_CAN_FRMF_TYPE_FD ) { +if (DEBUG_FILTER ) { +can_display_msg ("[cansja]: ignor fd frame " , frame); + } +return 1 ; + } +if (DEBUG_FILTER ) {can_display_msg ("[cansja]: receive " , frame); }
Signature · 1 line
2.20.1
PATCH v2 3/7 net/can: Add can_dlc2len and can_len2dlc for CAN FD.
In reply to [email protected]From: Jan Charvat <[email protected]>
--- include/net/can_emu.h | 4 ++++ net/can/can_core.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
include/net/can_emu.h +4 -0
@@ -123,4 +123,8 @@ int can_bus_client_set_filters(CanBusClientState *,const struct qemu_can_filter *filters, size_t filters_cnt); +uint8_t can_dlc2len (uint8_t can_dlc); + +uint8_t can_len2dlc (uint8_t len); +#endif
net/can/can_core.c +36 -0
@@ -33,6 +33,42 @@#include "net/can_emu.h" #include "qom/object_interfaces.h" +/* CAN DLC to real data length conversion helpers */ + +static const uint8_t dlc2len[] = { +0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 , +8 ,12 ,16 ,20 ,24 ,32 ,48 ,64 +}; + +/* get data length from can_dlc with sanitized can_dlc */ +uint8_t can_dlc2len (uint8_t can_dlc) +{ +return dlc2len[can_dlc &0x0F ]; +} + +static const uint8_t len2dlc[] = { +0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,/* 0 - 8 */ +9 ,9 ,9 ,9 ,/* 9 - 12 */ +10 ,10 ,10 ,10 ,/* 13 - 16 */ +11 ,11 ,11 ,11 ,/* 17 - 20 */ +12 ,12 ,12 ,12 ,/* 21 - 24 */ +13 ,13 ,13 ,13 ,13 ,13 ,13 ,13 ,/* 25 - 32 */ +14 ,14 ,14 ,14 ,14 ,14 ,14 ,14 ,/* 33 - 40 */ +14 ,14 ,14 ,14 ,14 ,14 ,14 ,14 ,/* 41 - 48 */ +15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 ,/* 49 - 56 */ +15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 /* 57 - 64 */ +}; + +/* map the sanitized data length to an appropriate data length code */ +uint8_t can_len2dlc (uint8_t len) +{ +if (unlikely (len >64 )) { +return 0xF ; + } + +return len2dlc[len]; +} +struct CanBusState {Object object;
Signature · 1 line
2.20.1
PATCH v2 5/7 hw/net/can: CTU CAN FD IP open hardware core emulation.
In reply to [email protected]From: Jan Charvat <[email protected]>
The implementation of the model of complete open-source/design/hardware CAN FD controller. The IP core project has been started and is maintained by Ondrej Ille at Czech Technical University in Prague.
CTU CAN FD project pages:
https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
CAN bus CTU FEE Projects Listing page:
http://canbus.pages.fel.cvut.cz/
The core is mapped to PCIe card same as on one of its real hardware adaptations. The device implementing two CTU CAN FD ip cores is instantiated after CAN bus definition
-object can-bus,id=canbus0-bus
by QEMU parameters
-device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus
--- hw/net/Kconfig | 11 + hw/net/can/ctucan_core.c | 696 +++++++++++++++++++++++++++++++++++++++ hw/net/can/ctucan_core.h | 127 +++++++ hw/net/can/ctucan_pci.c | 280 ++++++++++++++++ hw/net/can/meson.build | 2 + 5 files changed, 1116 insertions(+) create mode 100644 hw/net/can/ctucan_core.c create mode 100644 hw/net/can/ctucan_core.h create mode 100644 hw/net/can/ctucan_pci.c
hw/net/Kconfig +11 -0
@@ -143,3 +143,14 @@ config CAN_SJA1000 default y if PCI_DEVICES depends on PCI select CAN_BUS + +config CAN_CTUCANFD + bool + default y if PCI_DEVICES + select CAN_BUS + +config CAN_CTUCANFD_PCI + bool + default y if PCI_DEVICES + depends on PCI && CAN_CTUCANFD + select CAN_BUS
hw/net/can/ctucan_core.c new file +696 -0
696 lines not on this page · raw message
hw/net/can/ctucan_core.h new file +127 -0
127 lines not on this page · raw message
hw/net/can/ctucan_pci.c new file +280 -0
280 lines not on this page · raw message
hw/net/can/meson.build +2 -0
@@ -2,3 +2,5 @@ softmmu_ss.add(when: 'CONFIG_CAN_SJA1000', if_true: files('can_sja1000.c')) softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_kvaser_pci.c')) softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_pcm3680_pci.c')) softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_mioe3680_pci.c')) +softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD', if_true: files('ctucan_core.c')) +softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD_PCI', if_true: files('ctucan_pci.c'))
Signature · 1 line
2.20.1
PATCH v2 6/7 hw/net/can: Documentation for CTU CAN FD IP open hardware core emulation.
In reply to [email protected]Updated MAINTAINERS for CAN bus related emulation as well.
--- MAINTAINERS | 9 ++++ docs/can.txt | 113 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 111 insertions(+), 11 deletions(-)
MAINTAINERS +9 -0
@@ -2069,6 +2069,15 @@ F: hw/rx/ F: include/hw/intc/rx_icu.h F: include/hw/rx/ +CAN bus subsystem and hardware +M: Pavel Pisa <[email protected]> +M: Vikram Garhwal <[email protected]> +S: Maintained +W: https://canbus.pages.fel.cvut.cz/ +F: net/can/* +F: hw/net/can/* +F: include/net/can_*.h + Subsystems ---------- Audio
docs/can.txt +102 -11
141 lines not on this page · raw message
Signature · 1 line
2.20.1
v2 cover CTU CAN FD core support
From: Pavel Pisa <[email protected]>
CTU CAN FD is an open source soft core written in VHDL. It originated in 2015 as Ondrej Ille's project at the Department of Measurement of FEE at CTU.
Integration for Xilinx Zynq and Intel based SoCs is available as well as support for PCIe integration of the core.
The core sources
https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
The controller model and QEMU CAN subsystem extension to CAN FD has been implemented in frame of bachelor theses of Jan Charvat. The development branch ctu-canfd in CTU local project repository
https://gitlab.fel.cvut.cz/canbus/qemu-canbus
More CAN bus related project from Czech Technical University in Prague, Faculty of Electrical Engineering at
http://canbus.pages.fel.cvut.cz/
Patches v2 updates:
- CTU CAN FD IP core emulation tested on x86 host with big-endian MIPS MALTA target as well. This helped t correct Linux driver to support big-endian systems.
- CTU CAN FD IP core emulation updated to pass CAN frame data correctly on big-endian host systems. Big-endian host not tested, would required whole QEMU build for MIPS MALTA or big-endian POWER and run it nested emulation, because I have no access to Linux based big-endian system capable for QEMU build.
- Makefile.objs changes applied to meson.build and Kconfig.
- The common CAN support update for CAN FD tested and reviewed by Vikram Garhwal from Xilinx. They base their CAN FD controllers emulation on our work.
- Vikram Garhwal agrees to help with common QEMU CAN bus infrastructure reviews. I add him and myself into maintainers.
- Corrected SJA1000 dependencies in Kconfig after (probably) automated switch to meson build from make build.
Please, let me know if somebody from recipients list does no longer have interrest in QEMU CAN bus emulation and I would remove you from recipients list to not load you by uniteresting content in future.
Jan Charvat (5):
net/can: Initial host SocketCan support for CAN FD. hw/net/can: sja1000 ignore CAN FD frames
net/can: Add can_dlc2len and can_len2dlc for CAN FD. hw/net/can/ctucafd: Add CTU CAN FD core register definitions. hw/net/can: CTU CAN FD IP open hardware core emulation.
Pavel Pisa (2):
hw/net/can: Documentation for CTU CAN FD IP open hardware core
emulation.
hw/net/can: Correct Kconfig dependencies after switch to meson build.
MAINTAINERS | 9 + docs/can.txt | 113 +++- hw/net/Kconfig | 16 +- hw/net/can/can_sja1000.c | 31 +- hw/net/can/ctu_can_fd_frame.h | 189 +++++++ hw/net/can/ctu_can_fd_regs.h | 971 ++++++++++++++++++++++++++++++++++ hw/net/can/ctucan_core.c | 696 ++++++++++++++++++++++++ hw/net/can/ctucan_core.h | 127 +++++ hw/net/can/ctucan_pci.c | 280 ++++++++++ hw/net/can/meson.build | 2 + include/net/can_emu.h | 12 +- net/can/can_core.c | 36 ++ net/can/can_socketcan.c | 47 +- 13 files changed, 2505 insertions(+), 24 deletions(-) create mode 100644 hw/net/can/ctu_can_fd_frame.h create mode 100644 hw/net/can/ctu_can_fd_regs.h create mode 100644 hw/net/can/ctucan_core.c create mode 100644 hw/net/can/ctucan_core.h create mode 100644 hw/net/can/ctucan_pci.c
Signature · 1 line
2.20.1
PATCH v2 1/7 net/can: Initial host SocketCan support for CAN FD.
From: Jan Charvat <[email protected]>
--- hw/net/can/can_sja1000.c | 2 ++ include/net/can_emu.h | 8 ++++++- net/can/can_socketcan.c | 47 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 4 deletions(-)
hw/net/can/can_sja1000.c +2 -0
@@ -268,6 +268,7 @@ static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame) {uint8_t i; + frame->flags =0 ; frame->can_id =0 ;if (buff[0 ] &0x40 ) {/* RTR */ frame->can_id =QEMU_CAN_RTR_FLAG ;
@@ -303,6 +304,7 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame) {uint8_t i; + frame->flags =0 ; frame->can_id = ((buff[0 ] <<3 ) & (0xff <<3 )) + ((buff[1 ] >>5 ) &0x07 );if (buff[1 ] &0x10 ) {/* RTR */ frame->can_id =QEMU_CAN_RTR_FLAG ;
include/net/can_emu.h +7 -1
@@ -46,7 +46,8 @@ typedef uint32_t qemu_canid_t;typedef struct qemu_can_frame {qemu_canid_t can_id;/* 32 bit CAN_ID + EFF/RTR/ERR flags */ uint8_t can_dlc;/* data length code: 0 .. 8 */ - uint8_t data[8] QEMU_ALIGNED(8); +uint8_t flags; + uint8_t data[64] QEMU_ALIGNED(8); }qemu_can_frame ;/* Keep defines for QEMU separate from Linux ones for now */
@@ -58,6 +59,10 @@ typedef struct qemu_can_frame {#define QEMU_CAN_SFF_MASK 0x000007FFU/* standard frame format (SFF) */ #define QEMU_CAN_EFF_MASK 0x1FFFFFFFU/* extended frame format (EFF) */ +#define QEMU_CAN_FRMF_BRS 0x01/* bit rate switch (2nd bitrate for data) */ +#define QEMU_CAN_FRMF_ESI 0x02/* error state ind. of transmitting node */ +#define QEMU_CAN_FRMF_TYPE_FD 0x10/* internal bit ind. of CAN FD frame */ +/** * struct qemu_can_filter - CAN ID based filter in can_register(). * @can_id: relevant bits of CAN ID which are not masked out.
@@ -97,6 +102,7 @@ struct CanBusClientState {char *model;char *name;void (*destructor)(CanBusClientState *); +bool fd_mode; };#define TYPE_CAN_BUS "can-bus"
net/can/can_socketcan.c +44 -3
88 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 4/7 hw/net/can/ctucafd: Add CTU CAN FD core register definitions.
In reply to [email protected]From: Jan Charvat <[email protected]>
Definitions of registers and CAN FD frame message box of CTU CAN FD IP core are generated the specification in CACTUS/IP-XACT format.
CTU CAN FD IP core repository
https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
The location of the CTU CAN IP core specification within IP core design
spec/CTU/ip/CAN_FD_IP_Core/2.1/CAN_FD_IP_Core.2.1.xml
The header files are generated by pyXact_generator designed by Ondrej Ille which is based on ipyxact_parser.
The specification is source of header files for driver and emulation, documentation and VHDL registers map implementation.
--- hw/net/can/ctu_can_fd_frame.h | 189 +++++++ hw/net/can/ctu_can_fd_regs.h | 971 ++++++++++++++++++++++++++++++++++ 2 files changed, 1160 insertions(+) create mode 100644 hw/net/can/ctu_can_fd_frame.h create mode 100644 hw/net/can/ctu_can_fd_regs.h
hw/net/can/ctu_can_fd_frame.h new file +189 -0
@@ -0,0 +1,189 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/******************************************************************************* +* +* CTU CAN FD IP Core +* +* Copyright (C) 2015-2018 Ondrej Ille <[email protected]> FEE CTU +* Copyright (C) 2018-2020 Ondrej Ille <[email protected]> self-funded +* Copyright (C) 2018-2019 Martin Jerabek <[email protected]> FEE CTU +* Copyright (C) 2018-2020 Pavel Pisa <[email protected]> FEE CTU/self-funded +* +* Project advisors: +* Jiri Novak <[email protected]> +* Pavel Pisa <[email protected]> +* +* Department of Measurement (http://meas.fel.cvut.cz/) +* Faculty of Electrical Engineering (http://www.fel.cvut.cz) +* Czech Technical University (http://www.cvut.cz/) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* 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. +******************************************************************************/ + +/* This file is autogenerated, DO NOT EDIT! */ + +#ifndef __CTU_CAN_FD_CAN_FD_FRAME_FORMAT__ +#define __CTU_CAN_FD_CAN_FD_FRAME_FORMAT__ + +/* CAN_Frame_format memory map */ +enum ctu_can_fd_can_frame_format { +CTU_CAN_FD_FRAME_FORM_W =0x0 , +CTU_CAN_FD_IDENTIFIER_W =0x4 , +CTU_CAN_FD_TIMESTAMP_L_W =0x8 , +CTU_CAN_FD_TIMESTAMP_U_W =0xc , +CTU_CAN_FD_DATA_1_4_W =0x10 , +CTU_CAN_FD_DATA_5_8_W =0x14 , +CTU_CAN_FD_DATA_61_64_W =0x4c , +}; + + +/* Register descriptions: */ +union ctu_can_fd_frame_form_w { +uint32_t u32; +struct ctu_can_fd_frame_form_w_s { +#ifdef __LITTLE_ENDIAN_BITFIELD +/* FRAME_FORM_W */ +uint32_t dlc :4 ; +uint32_t reserved_4 :1 ; +uint32_t rtr :1 ; +uint32_t ide :1 ; +uint32_t fdf :1 ; +uint32_t reserved_8 :1 ; +uint32_t brs :1 ; +uint32_t esi_rsv :1 ; +uint32_t rwcnt :5 ; +uint32_t reserved_31_16 :16 ; +#else +uint32_t reserved_31_16 :16 ; +uint32_t rwcnt :5 ; +uint32_t esi_rsv :1 ; +uint32_t brs :1 ; +uint32_t reserved_8 :1 ; +uint32_t fdf :1 ; +uint32_t ide :1 ; +uint32_t rtr :1 ; +uint32_t reserved_4 :1 ; +uint32_t dlc :4 ; +#endif + } s; +}; + +enum ctu_can_fd_frame_form_w_rtr { +NO_RTR_FRAME =0x0 , +RTR_FRAME =0x1 , +}; + +enum ctu_can_fd_frame_form_w_ide { +BASE =0x0 , +EXTENDED =0x1 , +}; + +enum ctu_can_fd_frame_form_w_fdf { +NORMAL_CAN =0x0 , +FD_CAN =0x1 , +}; + +enum ctu_can_fd_frame_form_w_brs { +BR_NO_SHIFT =0x0 , +BR_SHIFT =0x1 , +}; + +enum ctu_can_fd_frame_form_w_esi_rsv { +ESI_ERR_ACTIVE =0x0 , +ESI_ERR_PASIVE =0x1 , +}; + +union ctu_can_fd_identifier_w { +uint32_t u32; +struct ctu_can_fd_identifier_w_s { +#ifdef __LITTLE_ENDIAN_BITFIELD +/* IDENTIFIER_W */ +uint32_t identifier_ext :18 ; +uint32_t identifier_base :11 ; +uint32_t reserved_31_29 :3 ; +#else +uint32_t reserved_31_29 :3 ; +uint32_t identifier_base :11 ; +uint32_t identifier_ext :18 ; +#endif + } s; +}; + +union ctu_can_fd_timestamp_l_w { +uint32_t u32; +struct ctu_can_fd_timestamp_l_w_s { +/* TIMESTAMP_L_W */ +uint32_t time_stamp_31_0 :32 ; + } s; +}; + +union ctu_can_fd_timestamp_u_w { +uint32_t u32; +struct ctu_can_fd_timestamp_u_w_s { +/* TIMESTAMP_U_W */ +uint32_t timestamp_l_w :32 ; + } s; +}; + +union ctu_can_fd_data_1_4_w { +uint32_t u32; +struct ctu_can_fd_data_1_4_w_s { +#ifdef __LITTLE_ENDIAN_BITFIELD +/* DATA_1_4_W */ +uint32_t data_1 :8 ; +uint32_t data_2 :8 ; +uint32_t data_3 :8 ; +uint32_t data_4 :8 ; +#else +uint32_t data_4 :8 ; +uint32_t data_3 :8 ; +uint32_t data_2 :8 ; +uint32_t data_1 :8 ; +#endif + } s; +}; + +union ctu_can_fd_data_5_8_w { +uint32_t u32; +struct ctu_can_fd_data_5_8_w_s { +#ifdef __LITTLE_ENDIAN_BITFIELD +/* DATA_5_8_W */ +uint32_t data_5 :8 ; +uint32_t data_6 :8 ; +uint32_t data_7 :8 ; +uint32_t data_8 :8 ; +#else +uint32_t data_8 :8 ; +uint32_t data_7 :8 ; +uint32_t data_6 :8 ; +uint32_t data_5 :8 ; +#endif + } s; +}; + +union ctu_can_fd_data_61_64_w { +uint32_t u32; +struct ctu_can_fd_data_61_64_w_s { +#ifdef __LITTLE_ENDIAN_BITFIELD +/* DATA_61_64_W */ +uint32_t data_61 :8 ; +uint32_t data_62 :8 ; +uint32_t data_63 :8 ; +uint32_t data_64 :8 ; +#else +uint32_t data_64 :8 ; +uint32_t data_63 :8 ; +uint32_t data_62 :8 ; +uint32_t data_61 :8 ; +#endif + } s; +}; + +#endif
hw/net/can/ctu_can_fd_regs.h new file +971 -0
971 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 7/7 hw/net/can: Correct Kconfig dependencies after switch to meson build.
In reply to [email protected]The original CAN_PCI config option enables multiple SJA1000 PCI boards emulation build. These boards bridge SJA1000 into I/O or memory address space of the host CPU and depend on SJA1000 emulation.
--- hw/net/Kconfig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/net/Kconfig +3 -4
@@ -132,16 +132,15 @@ config ROCKER config CAN_BUS bool -config CAN_PCI +config CAN_SJA1000 bool default y if PCI_DEVICES - depends on PCI select CAN_BUS -config CAN_SJA1000 +config CAN_PCI bool default y if PCI_DEVICES - depends on PCI + depends on PCI && CAN_SJA1000 select CAN_BUS config CAN_CTUCANFD
Signature · 1 line
2.20.1
Re: [PATCH v2 0/7] CTU CAN FD core support - patchew problem
In reply to [email protected]Hello everybody,
Quoted 5 lines · On Thursday 03 of September 2020 23:37:17 [email protected] wrote:
From: Pavel Pisa <[email protected]>
CTU CAN FD is an open source soft core written in VHDL. It originated in 2015 as Ondrej Ille's project at the Department of Measurement of FEE at CTU.
It seems that there has been problem with QEMU CI run by patchew
No space left on device
It seems it is resolved for later patches
Please, can somebody restart pipe for our CAN FD series
https://patchew.org/QEMU/[email protected]/
Please, is there somebody willing to look and apply series to mainline if it passes CI OK?
Changes are only in CAN subsystem so if there is no problem with breaking build on some system then patches can break only the subsystem which I have planned, found funding for initial CAN implementation provided by RTEMS GSoC slot and where I have tutor our university studnet to work on CAN FD support. If something is wrong then it break only this subsystem, all functionality is activated only when explicitly selected by command line option.
It seems that subsystem has users at Xilinx, Pengutronix and more.
I have some longer time plans how to implement back-pressure from SocketCAN, prioritization of the bus transfers when multiple controllers are active at one and even emulate bus tansmittion delay and blocking when message is on its way. But these are more intrusive changes and would require time or some other student work and I do not invest my time before I would know that there is no more request for series on which future work is based on.
Thanks much in advance,
Pavel
Re: [PATCH v2 0/7] CTU CAN FD core support - patchew problem
Quoted 8 lines · Pavel Pisa
Hello everybody,
Quoted 5 lines · On Thursday 03 of September 2020 23:37:17 [email protected] wrote:
From: Pavel Pisa <[email protected]>
CTU CAN FD is an open source soft core written in VHDL. It originated in 2015 as Ondrej Ille's project at the Department of Measurement of FEE at CTU.
Quoted 6 lines
It seems that there has been problem with QEMU CI
run by patchewNo space left on device
It seems it is resolved for later patches
Yes there seems to be a bug where timeouts fail to stop the container---eventually they pile up and occupy all disk space. I should really just add a cron job until I figure it out.
Paolo
Re: [PATCH v2 7/7] hw/net/can: Correct Kconfig dependencies after switch to meson build.
In reply to Pavel PisaQuoted 3 lines · Pavel Pisa
The original
CAN_PCIconfig option enables multiple SJA1000 PCI boards emulation build. These boards bridge SJA1000 into I/O or memory address space of the host CPU and depend on SJA1000 emulation.
Can you explain how the mistake is related to the meson switch?
The conversion seems good:
hw/net/can/Makefile.objs deleted +0 -4
@@ -1,4 +0,0 @@ -common-obj-$(CONFIG_CAN_SJA1000) += can_sja1000.o -common-obj-$(CONFIG_CAN_PCI) += can_kvaser_pci.o -common-obj-$(CONFIG_CAN_PCI) += can_pcm3680_pci.o -common-obj-$(CONFIG_CAN_PCI) += can_mioe3680_pci.o
hw/net/can/meson.build new file +4 -0
@@ -0,0 +1,4 @@ +softmmu_ss.add(when: 'CONFIG_CAN_SJA1000', if_true: files('can_sja1000.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_kvaser_pci.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_pcm3680_pci.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_mioe3680_pci.c'))
I queued the other six patches.
Paolo
Quoted 29 lines
Signed-off-by Pavel Pisa <[email protected]>--- hw/net/Kconfig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)hw/net/Kconfig +3
-4@@ -132,16 +132,15 @@ config ROCKER config CAN_BUS bool -config CAN_PCI +config CAN_SJA1000 bool default y if PCI_DEVICES - depends on PCI select CAN_BUS -config CAN_SJA1000 +config CAN_PCI bool default y if PCI_DEVICES - depends on PCI + depends on PCI && CAN_SJA1000 select CAN_BUS config CAN_CTUCANFD
Re: [PATCH v2 7/7] hw/net/can: Correct Kconfig dependencies after switch to meson build.
Hello Paolo,
Quoted 26 lines · On Wednesday 23 of September 2020 17:48:09 Paolo Bonzini wrote:
Quoted 3 lines · Pavel Pisa
The original
CAN_PCIconfig option enables multiple SJA1000 PCI boards emulation build. These boards bridge SJA1000 into I/O or memory address space of the host CPU and depend on SJA1000 emulation.Can you explain how the mistake is related to the meson switch?
The conversion seems good:
hw/net/can/Makefile.objs deleted +0
-4@@ -1,4 +0,0 @@ -common-obj-$(CONFIG_CAN_SJA1000) += can_sja1000.o -common-obj-$(CONFIG_CAN_PCI) += can_kvaser_pci.o -common-obj-$(CONFIG_CAN_PCI) += can_pcm3680_pci.o -common-obj-$(CONFIG_CAN_PCI) += can_mioe3680_pci.ohw/net/can/meson.build new file +1
-0@@ -0,0 +1,4 @@ +softmmu_ss.add(when: 'CONFIG_CAN_SJA1000', if_true:
Quoted 4 lines
files('can_sja1000.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI',if_true:files('can_kvaser_pci.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI',if_true:files('can_pcm3680_pci.c')) +softmmu_ss.add(when: 'CONFIG_CAN_PCI',if_true:files('can_mioe3680_pci.c'))
I have analyzed history and potential problem source is older then the switch to meson build but I did not realized it before update to the meson build between v1 and v2 patches submission.
There has not been described dependencies between options in the original QEMU code.
There has been only single list what is compiled in for targets supporting PCI
default-configs/pci.mak:
CONFIG_CAN_BUS=y
CONFIG_CAN_SJA1000=y
CONFIG_CAN_PCI=y
So good, all enabled together, so no problem with mutual dependencies. But when the QEMU switched to Kconfig
build: convert pci.mak to Kconfig 1/23/19 7:56 AM
then config looks like this
hw/net/Kconfig:
config CAN_PCI
bool
default y if PCI_DEVICES
depends on PCI
select CAN_BUS
config CAN_SJA1000
bool
default y if PCI_DEVICES
depends on PCI
select CAN_BUS
There is a problem when some tool (kconfig-fronteds) is used to manually tune configuration because if the CAN_PCI is enabled but CAN_SJA1000 stays disabled then the build fails. That is no problem for default options combinations controlled by PCI option.
So the problem existed there even before messon build switch but I have noticed it when I experienced clash of v1 patches with newer QEMU mainline. So my mistake is that I have not identified that switch to Kconfig started the problem.
But in the CTU CAN FD v1 submission we (with Jan Charvat) have not distinguished between SJA1000 and CTU CAN FD emulation enable so I have not checked where option i enabled and how
hw/net/can/Makefile.objs:
common-obj-$(CONFIG_CAN_PCI) += can_kvaser_pci.o common-obj-$(CONFIG_CAN_PCI) += can_pcm3680_pci.o common-obj-$(CONFIG_CAN_PCI) += can_mioe3680_pci.o
+
+common-obj-$(CONFIG_CAN_PCI) += ctucan_core.o +common-obj-$(CONFIG_CAN_PCI) += ctucan_pci.o
I have decided to separated SJA1000 PCI and CTU CAN FD support in the v2 when I have to reflect mainline change to meson anyway and I have found that there is potential problem with the dependencies. I have updated them.
config CAN_SJA1000
bool
default y if PCI_DEVICES
select CAN_BUS
config CAN_PCI
bool
default y if PCI_DEVICES
depends on PCI && CAN_SJA1000
select CAN_BUS
config CAN_CTUCANFD
bool
default y if PCI_DEVICES
select CAN_BUS
config CAN_CTUCANFD_PCI
bool
default y if PCI_DEVICES
depends on PCI && CAN_CTUCANFD
select CAN_BUS
The SJA1000 and CAN_CTUCANFD controller sources should build even without PCI support because there can be and exists hardware options where cores are connected to platform-bus. These systems can be emulated even without PCI enabled in future if code for connection of these controllers to platform-bus/device-tree in implemented in future.
By the way, you are replying to CTU CAN FD v2 series from 2020-09-03. But mainline moved forward and I have sent updated v3 at 2020-09-14 to reflect some bulk change to DECLARE_INSTANCE_CHECKER etc...
If you have already pushed v2 and it does not cause build problems then I will provide update patch when code reaches mainline.
If you have not pushed code to the mainline yet, consider v3 which should follow better actual mainline state. The list of updates to v3 follows.
Thanks much for your time,
Pavel
+Patches v3 updates:
+
+ - resend triggered by switch to DECLARE_INSTANCE_CHECKER
+ in mainline. I try to follow mainline as time allows.
+
+ - SJA1000, CTU CAN FD and SocketCAN support retested
+ with QEMU mainline from 9/12/20 10:17 PM
+
+ - Added Reviewed-by: Vikram Garhwal
+ to reviewed and tested patches which are used as common
+ CAN FD base at Xilinx
+
+ - Added Vikram Garhwal to MAINTAINERS file as the second person
+ who has interrest in QEMU CAN (FD) support and would
+ like to be notified about changes and help with reviews.
Re: [PATCH v2 7/7] hw/net/can: Correct Kconfig dependencies after switch to meson build.
Quoted 4 lines · Pavel Pisa
If you have not pushed code to the mainline yet, consider v3 which should follow better actual mainline state. The list of updates to v3 follows.
I actually queued v3 (I just use patchew to queue patches).
Paolo
Re: [PATCH v2 7/7] hw/net/can: Correct Kconfig dependencies after switch to meson build.
Hello Paolo,
Quoted 6 lines · On Wednesday 23 of September 2020 20:11:08 Paolo Bonzini wrote:
Quoted 3 lines · Pavel Pisa
If you have not pushed code to the mainline yet, consider v3 which should follow better actual mainline state. The list of updates to v3 follows.
I actually queued v3 (I just use patchew to queue patches).
That is great.
Thanks,
Pavel
Signature · 8 lines
Pavel Pisa
e-mail: [email protected]
Department of Control Engineering FEE CVUT
Karlovo namesti 13, 121 35, Prague 2
university: http://dce.fel.cvut.cz/
personal: http://cmp.felk.cvut.cz/~pisa
projects: https://www.openhub.net/accounts/ppisa
CAN related:http://canbus.pages.fel.cvut.cz/Re: [PATCH v2 7/7] hw/net/can: Correct Kconfig dependencies after switch to meson build.
Hello,
I have implemented support for PCI MSI capability CANbus card support; fully tested using QNX operating system guest image. How can I go about contributing this to the main repo:
Sent from my iPhone
Deniz Eren
+61 405 194 317
Quoted 28 lines · Pavel Pisa
Hello Paolo,
Quoted 7 lines · On Wednesday 23 of September 2020 20:11:08 Paolo Bonzini wrote:
Quoted 4 lines · Pavel Pisa
If you have not pushed code to the mainline yet, consider v3 which should follow better actual mainline state. The list of updates to v3 follows.
I actually queued v3 (I just use patchew to queue patches).
That is great.
Thanks,
Pavel
--
Pavel Pisa
e-mail: [email protected]
Department of Control Engineering FEE CVUT
Karlovo namesti 13, 121 35, Prague 2
university: http://dce.fel.cvut.cz/
personal: http://cmp.felk.cvut.cz/~pisa
projects: https://www.openhub.net/accounts/ppisa
CAN related:http://canbus.pages.fel.cvut.cz/
Re: hw/net/can: PCI MSI suport for SJA1000 based addon card Was: [PATCH] hw/net/can: ... to meson build.
Hello Deniz,
Quoted 6 lines · On Saturday 15 of February 2025 14:30:58 Deniz Eren wrote:
I have implemented support for PCI MSI capability CANbus card support; fully tested using QNX operating system guest image. How can I go about contributing this to the main repo:
https://github.com/Deniz-Eren/qemu/blob/feature/can-sja100-pci-msi-support/
hw/net/can/can_pcm26d2ca_pci.c
the first thanks for information and work done.
I am replying to all addressees of your e-mail but if the others do not respond, I suggest to limit and would limit the recipients list only to me, other QEMU CAN subsystem maintainers:
Francisco Iglesias <[email protected]>
Vikram Garhwal <[email protected]>
QEMU list
and some QEMU core developers who could accept the code for mainline, my previous changes have been accepted for mainline by one of the following developers
Peter Maydell <[email protected]>
Michael Tokarev<[email protected]>
Philippe Mathieu-Daudé <[email protected]>
Paolo Bonzini <[email protected]>
The patches should be send in plain text format (git format-patch) to [email protected] and me and other QEMU CAN maintainers.
As for the format and other details, look at
https://www.qemu.org/docs/master/devel/submitting-a-patch.html
Check the source formating and basic requirements by
scripts/checkpatch.pl
As for the actual changes you propose, I have looked into your repository. I would like to discuss a little changes to generic SJA1000 code
https://github.com/Deniz-Eren/qemu/commit/a2f593f21946328821f8456274c9c688d5f1c4de
Because my understanding is that the emulated board is some Advantech board PCM-26D2CA
which has PCIe MSI capable interface. The datasheet states NXP SJA-1000 used as the controller. But I do not expect that this chip allows distinguish interrupt source directly to map it to PCIe MSI signal. So one option is complete controller logic in FPGA, another is somehow read and map interrupt PeliCAN register to MSI messages. But that mapping can be specific to different boards and SJA1000 compatible controllers implementations.
I am not sure if your code is prepared to make mapping so generic.
In the fact, I am not sure if whole PCIe MSI details should be pushed to the bare SJA1000 controller implementation.
I would suggest to think about option to register callback for interrupt state update which would receive interrupt register state as argument and move actual mapping to PCIe MSI writes outside of the core SJA1000 implementation.
This way it could be mapped even to other bus technologies which allows multiple even boxes per single addon card/controller source. I can imagine VME for example even that it probably not common today but even some SoC with SJA1000 compatible CAN controller which maps it to multiple interrupts.
We should discuse this probably within smaller group, me and Francisco Iglesias and Vikram Garhwal with CC to [email protected] and when we agree on the patche series in the review process we should ask some other QEMU developers to accept result for mainline.
Best wishes,
Pavel
--
Pavel Pisa
phone: +420 603531357
e-mail: [email protected]
Department of Control Engineering FEE CVUT Karlovo namesti 13, 121 35, Prague 2
university: http://control.fel.cvut.cz/
personal: http://cmp.felk.cvut.cz/~pisa
social: https://social.kernel.org/ppisa
projects: https://www.openhub.net/accounts/ppisa
CAN related:http://canbus.pages.fel.cvut.cz/ RISC-V education: https://comparch.edu.cvut.cz/
Open Technologies Research Education and Exchange Services
https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home