drivers/can: add support for Bosch C_CAN controller
v4 cover drivers/can: add support for Bosch C_CAN controller
The series was created to optimize the use of the C_CAN controller (maximum number of message objects, use of FIFO, ...) to get the best possible RX/TX throughput from hardware.
To emphasize the purpose of the series I also added the patch which adds multi-message support to `sendmsg ', rather than' submitting it separately. In fact, it too has contributed to increasing transmission throughput.
The patches prior to the one adding the BOSCH C_CAN controller driver, are a backporting of commits from the linux kernel that also impacted on the driver itself and I found it necessary to add to the series.
The latest patch, as described in its commit, modified Stephen Battazzo's patch [1] with bug fixes, backporting of commits from the linux kernel, extension of message objects to 64 and improvements in FIFO handling. This series was in fact preceded by the creation of patches which I sent to the Linux kernel and which were then accepted:
387da6bc7a82 ("can: c_can: cache frames to operate as a true FIFO") 28e86e9ab522 ("can: c_can: support tx ring algorithm")a54cdbba9dee ("can: c_can: exit c_can_do_tx() early if no frames have been sent") 5064e40596f4 ("can: c_can: remove struct c_can_priv::priv field") 06fc143b2ede dt-bindings: net: can: c_can: convert to json-schema 132f2d45fb23 ("can: c_can: add support to 64 message objects") 13831ce69c77 ("can: c_can: prepare to up the message objects number") fcbded019855 ("can: c_can: use 32-bit write to set arbitration register") eddf67115040 ("can: c_can: add a comment about IF_RX interface's use") c8a6b44388cb ("can: c_can: fix indentation")f65735c203d5 ("can: c_can: remove unused code")
The patch was tested on a custom board mounting an AM335x SOC.
PCI support has not been developed.
[1] http://xenomai.org/pipermail/xenomai/2015-July/034690.html
Changes in v4:
- Add the patch to the series.
- Load/unload the CAN drivers modules before/after running the test.
- Add setup/teardown function
Changes in v3:
- Add the patch to the series.
- Add virtual CAN testsuite
Changes in v2:
- Expand the commit message to better describe the added API.
- Drop 'default n' Kconfig
- Enable the driver for Xenomai CI builds
- Drop commented code
- Drop power managemet (pm) code
Dario Binacchi (8):
lib/smokey: add smokey_{modprobe,rmmod} helpers testsuite/smokey: add virtual CAN testsuite drivers/can: add multi message support to sendmsg drivers/can: add CAN_ERR_CRTL_ACTIVE info status drivers/can: add len field to can frame structures drivers/can: add a minimal support to ethtool API drivers/can: fix updating of tx_count statistics drivers/can: add support for Bosch C_CAN controller
.gitlab-ci.yml | 2 + configure.ac | 1 + include/rtdm/uapi/can.h | 6 +- include/smokey/smokey.h | 6 +- kernel/drivers/can/Kconfig | 1 + kernel/drivers/can/Makefile | 4 +- kernel/drivers/can/README | 1 + kernel/drivers/can/c_can/Kconfig | 15 + kernel/drivers/can/c_can/Makefile | 8 + kernel/drivers/can/c_can/rtcan_c_can.c | 1298 +++++++++++++++++ kernel/drivers/can/c_can/rtcan_c_can.h | 255 ++++ .../drivers/can/c_can/rtcan_c_can_ethtool.c | 47 + .../drivers/can/c_can/rtcan_c_can_platform.c | 461 ++++++ kernel/drivers/can/mscan/rtcan_mscan.c | 1 + kernel/drivers/can/rtcan_dev.h | 4 +- kernel/drivers/can/rtcan_ethtool.c | 75 + kernel/drivers/can/rtcan_ethtool.h | 24 + kernel/drivers/can/rtcan_flexcan.c | 1 + kernel/drivers/can/rtcan_raw.c | 240 +-- kernel/drivers/can/rtcan_raw_dev.c | 20 + kernel/drivers/can/rtcan_socket.h | 5 +- kernel/drivers/can/rtcan_virt.c | 1 + kernel/drivers/can/sja1000/rtcan_sja1000.c | 1 + lib/smokey/helpers.c | 99 ++ testsuite/smokey/Makefile.am | 2 + testsuite/smokey/can-virt/Makefile.am | 8 + testsuite/smokey/can-virt/virt.c | 356 +++++ testsuite/smokey/net_common/setup.c | 68 +- 28 files changed, 2826 insertions(+), 184 deletions(-) create mode 100644 kernel/drivers/can/c_can/Kconfig create mode 100644 kernel/drivers/can/c_can/Makefile create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.h create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_ethtool.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_platform.c create mode 100644 kernel/drivers/can/rtcan_ethtool.c create mode 100644 kernel/drivers/can/rtcan_ethtool.h create mode 100644 testsuite/smokey/can-virt/Makefile.am create mode 100644 testsuite/smokey/can-virt/virt.c
Signature · 1 line
2.17.1
PATCH v4 1/8 lib/smokey: add smokey_{modprobe,rmmod} helpers
Both functions, implemented and used for the net, are general purpose and therefore can be useful in other parts of the application with the application of minimal changes.
---
Changes in v4:
- Add the patch to the series.
include/smokey/smokey.h | 6 +- lib/smokey/helpers.c | 99 +++++++++++++++++++++++++++++ testsuite/smokey/net_common/setup.c | 68 +------------------- 3 files changed, 106 insertions(+), 67 deletions(-)
include/smokey/smokey.h +5 -1
@@ -254,7 +254,11 @@ int smokey_barrier_timedwait(struct smokey_barrier *b,void smokey_barrier_release (struct smokey_barrier *b);int smokey_fork_exec (const char *path,const char *arg); - + +int smokey_modprobe (const char *name,bool silent); + +int smokey_rmmod (const char *name); + #ifdef __cplusplus }#endif
lib/smokey/helpers.c +99 -0
102 lines not on this page · raw message
testsuite/smokey/net_common/setup.c +2 -66
90 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v4 1/8] lib/smokey: add smokey_{modprobe,rmmod} helpers
Quoted 204 lines · Dario Binacchi
Both functions, implemented and used for the net, are general purpose and therefore can be useful in other parts of the application with the application of minimal changes.
Signed-off-by Dario Binacchi <[email protected]>---
Changes in v4:
- Add the patch to the series.include/smokey/smokey.h | 6 +- lib/smokey/helpers.c | 99 +++++++++++++++++++++++++++++ testsuite/smokey/net_common/setup.c | 68 +------------------- 3 files changed, 106 insertions(+), 67 deletions(-)include/smokey/smokey.h +5
-1@@ -254,7 +254,11 @@ int smokey_barrier_timedwait(struct smokey_barrier *b,void smokey_barrier_release (struct smokey_barrier *b);int smokey_fork_exec (const char *path,const char *arg); - + +int smokey_modprobe (const char *name,bool silent); + +int smokey_rmmod (const char *name); + #ifdef __cplusplus }#endif lib/smokey/helpers.c +99
-0@@ -292,3 +292,102 @@ int smokey_fork_exec(const char *path, const char *arg)return 1 ; } + +#define SMOKEY_MOD_NUM 32 +static char *smokey_modules[SMOKEY_MOD_NUM ]; + +int smokey_modprobe (const char *name,bool silent) +{ +char buffer[128 ]; +int err, len, i, midx =-1 ; +FILE *fp; + + fp =fopen ("/proc/modules" ,"r" ); +if (fp ==NULL ) +return -errno; + + len =strlen (name); + +while (fgets (buffer,sizeof (buffer), fp)) { +if (strncmp (buffer, name, len) ==0 && + len <sizeof (buffer) && buffer[len] ==' ' ) { +smokey_trace ("%s module already loaded" , name); +fclose (fp); +return 0 ; + } + } + +fclose (fp); + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (!smokey_modules[i]) { + midx = i; +break ; + } + } + +if (midx <0 ) +return -EFAULT ; + +smokey_trace ("%s module not there: modprobing" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"modprobe %s %s" , name, + silent ?"2>/dev/null" :"" )); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +if (!silent) +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + + smokey_modules[midx] =strdup (name); +return 0 ; +} + +int smokey_rmmod (const char *name) +{ +char buffer[128 ]; +int i, midx =-1 , err; + +if (!name) +return -EINVAL ; + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (smokey_modules[i] && !strcmp (smokey_modules[i], name)) { + midx = i; +break ; + } + } + +if (midx <0 ) { +smokey_trace ("%s module was there on entry, keeping it" , name); +return 0 ; + } + +smokey_trace ("unloading %s module" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"rmmod %s" , name)); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + +free (smokey_modules[midx]); + +return err; +}testsuite/smokey/net_common/setup.c +1
-42@@ -28,7 +28,6 @@struct module {int option;const char *name; -bool loaded; };#define TIMEOUT 10@@ -141,81 +140,18 @@ static int do_down(const char *intf)static int smokey_net_modprobe (int modid,bool silent) {struct module *m = modules + modid; -char buffer[128 ]; -int err, len; -FILE *fp;if (modid <0 )return -EINVAL ; - fp =fopen ("/proc/modules" ,"r" ); -if (fp ==NULL ) -return -errno; - - len =strlen (m->name); - -while (fgets (buffer,sizeof (buffer), fp)) { -if (strncmp (buffer, m->name, len) ==0 && - len <sizeof (buffer) && buffer[len] ==' ' ) { -smokey_trace ("%s module already loaded" , m->name); -fclose (fp); -return 0 ; - } - } - -fclose (fp); - -smokey_trace ("%s module not there: modprobing" , m->name); - - err =smokey_check_errno ( -snprintf (buffer,sizeof (buffer),"modprobe %s %s" , m->name, - silent ?"2>/dev/null" :"" )); -if (err <0 ) -return err; - - err =smokey_check_errno (system (buffer)); -if (err <0 ) -return err; - -if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { -if (!silent) -smokey_warning ("%s: abnormal exit" , buffer); -return -EINVAL ; - } - - m->loaded = true; - -return err; +return smokey_modprobe (m->name, silent); }
testsuite/smokey/net_common/setup.c static int do_down(const char *intf) · line 200
Quoted 10 lines
testsuite/smokey/net_common/setup.c +0
-7static int smokey_net_rmmod (int modid) {struct module *m = modules + modid; -char buffer[128 ]; -int err; - -if (!m->loaded) { -smokey_trace ("%s module was there on entry, keeping it" , m->name); -return 0 ; - }
Reverting the series again: You broke the handling of already loaded (or built-in) modules, also for the rtnet tests.
With CAN, you now get e.g.
2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can_virt is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can_virt: abnormal exit 2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can: abnormal exit
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: [PATCH v4 1/8] lib/smokey: add smokey_{modprobe,rmmod} helpers
Quoted 219 lines · Jan Kiszka via Xenomai
Quoted 204 lines · Dario Binacchi
Both functions, implemented and used for the net, are general purpose and therefore can be useful in other parts of the application with the application of minimal changes.
Signed-off-by Dario Binacchi <[email protected]>---
Changes in v4:
- Add the patch to the series.include/smokey/smokey.h | 6 +- lib/smokey/helpers.c | 99 +++++++++++++++++++++++++++++ testsuite/smokey/net_common/setup.c | 68 +------------------- 3 files changed, 106 insertions(+), 67 deletions(-)include/smokey/smokey.h +5
-1@@ -254,7 +254,11 @@ int smokey_barrier_timedwait(struct smokey_barrier *b,void smokey_barrier_release (struct smokey_barrier *b);int smokey_fork_exec (const char *path,const char *arg); - + +int smokey_modprobe (const char *name,bool silent); + +int smokey_rmmod (const char *name); + #ifdef __cplusplus }#endif lib/smokey/helpers.c +99
-0@@ -292,3 +292,102 @@ int smokey_fork_exec(const char *path, const char *arg)return 1 ; } + +#define SMOKEY_MOD_NUM 32 +static char *smokey_modules[SMOKEY_MOD_NUM ]; + +int smokey_modprobe (const char *name,bool silent) +{ +char buffer[128 ]; +int err, len, i, midx =-1 ; +FILE *fp; + + fp =fopen ("/proc/modules" ,"r" ); +if (fp ==NULL ) +return -errno; + + len =strlen (name); + +while (fgets (buffer,sizeof (buffer), fp)) { +if (strncmp (buffer, name, len) ==0 && + len <sizeof (buffer) && buffer[len] ==' ' ) { +smokey_trace ("%s module already loaded" , name); +fclose (fp); +return 0 ; + } + } + +fclose (fp); + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (!smokey_modules[i]) { + midx = i; +break ; + } + } + +if (midx <0 ) +return -EFAULT ; + +smokey_trace ("%s module not there: modprobing" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"modprobe %s %s" , name, + silent ?"2>/dev/null" :"" )); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +if (!silent) +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + + smokey_modules[midx] =strdup (name); +return 0 ; +} + +int smokey_rmmod (const char *name) +{ +char buffer[128 ]; +int i, midx =-1 , err; + +if (!name) +return -EINVAL ; + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (smokey_modules[i] && !strcmp (smokey_modules[i], name)) { + midx = i; +break ; + } + } + +if (midx <0 ) { +smokey_trace ("%s module was there on entry, keeping it" , name); +return 0 ; + } + +smokey_trace ("unloading %s module" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"rmmod %s" , name)); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + +free (smokey_modules[midx]); + +return err; +}testsuite/smokey/net_common/setup.c +1
-42@@ -28,7 +28,6 @@struct module {int option;const char *name; -bool loaded; };#define TIMEOUT 10@@ -141,81 +140,18 @@ static int do_down(const char *intf)static int smokey_net_modprobe (int modid,bool silent) {struct module *m = modules + modid; -char buffer[128 ]; -int err, len; -FILE *fp;if (modid <0 )return -EINVAL ; - fp =fopen ("/proc/modules" ,"r" ); -if (fp ==NULL ) -return -errno; - - len =strlen (m->name); - -while (fgets (buffer,sizeof (buffer), fp)) { -if (strncmp (buffer, m->name, len) ==0 && - len <sizeof (buffer) && buffer[len] ==' ' ) { -smokey_trace ("%s module already loaded" , m->name); -fclose (fp); -return 0 ; - } - } - -fclose (fp); - -smokey_trace ("%s module not there: modprobing" , m->name); - - err =smokey_check_errno ( -snprintf (buffer,sizeof (buffer),"modprobe %s %s" , m->name, - silent ?"2>/dev/null" :"" )); -if (err <0 ) -return err; - - err =smokey_check_errno (system (buffer)); -if (err <0 ) -return err; - -if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { -if (!silent) -smokey_warning ("%s: abnormal exit" , buffer); -return -EINVAL ; - } - - m->loaded = true; - -return err; +return smokey_modprobe (m->name, silent); }testsuite/smokey/net_common/setup.c static int do_down(const char *intf) · line 200
Quoted 10 lines
testsuite/smokey/net_common/setup.c +0
-7static int smokey_net_rmmod (int modid) {struct module *m = modules + modid; -char buffer[128 ]; -int err; - -if (!m->loaded) { -smokey_trace ("%s module was there on entry, keeping it" , m->name); -return 0 ; - }Reverting the series again: You broke the handling of already loaded (or built-in) modules, also for the rtnet tests.
Quoted 7 lines
With CAN, you now get e.g.
2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can_virt is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can_virt: abnormal exit 2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can: abnormal exit
Strangely, I'm getting the error that already modprobe fails in another setup (qemu-arm64 of xenomai-images) if those things are built-in.
And please make sure we simply skip the test if the feature is not configured. Might require some _CC_COBALT_GET_CAN_CONFIG (analogously to _CC_COBALT_GET_NET_CONFIG and kernel/drivers/net/stack/corectl.c).
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: [PATCH v4 1/8] lib/smokey: add smokey_{modprobe,rmmod} helpers
Hi Jan,
Quoted 225 lines
Il 13/12/2021 13:11 Jan Kiszka <[email protected]> ha scritto:
Quoted 221 lines · Jan Kiszka via Xenomai
Quoted 204 lines · Dario Binacchi
Both functions, implemented and used for the net, are general purpose and therefore can be useful in other parts of the application with the application of minimal changes.
Signed-off-by Dario Binacchi <[email protected]>---
Changes in v4:
- Add the patch to the series.include/smokey/smokey.h | 6 +- lib/smokey/helpers.c | 99 +++++++++++++++++++++++++++++ testsuite/smokey/net_common/setup.c | 68 +------------------- 3 files changed, 106 insertions(+), 67 deletions(-)include/smokey/smokey.h +5
-1@@ -254,7 +254,11 @@ int smokey_barrier_timedwait(struct smokey_barrier *b,void smokey_barrier_release (struct smokey_barrier *b);int smokey_fork_exec (const char *path,const char *arg); - + +int smokey_modprobe (const char *name,bool silent); + +int smokey_rmmod (const char *name); + #ifdef __cplusplus }#endif lib/smokey/helpers.c +99
-0@@ -292,3 +292,102 @@ int smokey_fork_exec(const char *path, const char *arg)return 1 ; } + +#define SMOKEY_MOD_NUM 32 +static char *smokey_modules[SMOKEY_MOD_NUM ]; + +int smokey_modprobe (const char *name,bool silent) +{ +char buffer[128 ]; +int err, len, i, midx =-1 ; +FILE *fp; + + fp =fopen ("/proc/modules" ,"r" ); +if (fp ==NULL ) +return -errno; + + len =strlen (name); + +while (fgets (buffer,sizeof (buffer), fp)) { +if (strncmp (buffer, name, len) ==0 && + len <sizeof (buffer) && buffer[len] ==' ' ) { +smokey_trace ("%s module already loaded" , name); +fclose (fp); +return 0 ; + } + } + +fclose (fp); + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (!smokey_modules[i]) { + midx = i; +break ; + } + } + +if (midx <0 ) +return -EFAULT ; + +smokey_trace ("%s module not there: modprobing" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"modprobe %s %s" , name, + silent ?"2>/dev/null" :"" )); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +if (!silent) +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + + smokey_modules[midx] =strdup (name); +return 0 ; +} + +int smokey_rmmod (const char *name) +{ +char buffer[128 ]; +int i, midx =-1 , err; + +if (!name) +return -EINVAL ; + +for (i =0 ; i <SMOKEY_MOD_NUM ; i++) { +if (smokey_modules[i] && !strcmp (smokey_modules[i], name)) { + midx = i; +break ; + } + } + +if (midx <0 ) { +smokey_trace ("%s module was there on entry, keeping it" , name); +return 0 ; + } + +smokey_trace ("unloading %s module" , name); + + err =smokey_check_errno ( +snprintf (buffer,sizeof (buffer),"rmmod %s" , name)); +if (err <0 ) +return err; + + err =smokey_check_errno (system (buffer)); +if (err <0 ) +return err; + +if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { +smokey_warning ("%s: abnormal exit" , buffer); +return -EINVAL ; + } + +free (smokey_modules[midx]); + +return err; +}testsuite/smokey/net_common/setup.c +1
-42@@ -28,7 +28,6 @@struct module {int option;const char *name; -bool loaded; };#define TIMEOUT 10@@ -141,81 +140,18 @@ static int do_down(const char *intf)static int smokey_net_modprobe (int modid,bool silent) {struct module *m = modules + modid; -char buffer[128 ]; -int err, len; -FILE *fp;if (modid <0 )return -EINVAL ; - fp =fopen ("/proc/modules" ,"r" ); -if (fp ==NULL ) -return -errno; - - len =strlen (m->name); - -while (fgets (buffer,sizeof (buffer), fp)) { -if (strncmp (buffer, m->name, len) ==0 && - len <sizeof (buffer) && buffer[len] ==' ' ) { -smokey_trace ("%s module already loaded" , m->name); -fclose (fp); -return 0 ; - } - } - -fclose (fp); - -smokey_trace ("%s module not there: modprobing" , m->name); - - err =smokey_check_errno ( -snprintf (buffer,sizeof (buffer),"modprobe %s %s" , m->name, - silent ?"2>/dev/null" :"" )); -if (err <0 ) -return err; - - err =smokey_check_errno (system (buffer)); -if (err <0 ) -return err; - -if (!WIFEXITED (err) ||WEXITSTATUS (err) !=0 ) { -if (!silent) -smokey_warning ("%s: abnormal exit" , buffer); -return -EINVAL ; - } - - m->loaded = true; - -return err; +return smokey_modprobe (m->name, silent); }testsuite/smokey/net_common/setup.c static int do_down(const char *intf) · line 200
Quoted 10 lines
testsuite/smokey/net_common/setup.c +0
-7static int smokey_net_rmmod (int modid) {struct module *m = modules + modid; -char buffer[128 ]; -int err; - -if (!m->loaded) { -smokey_trace ("%s module was there on entry, keeping it" , m->name); -return 0 ; - }Reverting the series again: You broke the handling of already loaded (or built-in) modules, also for the rtnet tests.
With CAN, you now get e.g.
Quoted 9 lines
Quoted 5 lines
2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can_virt is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can_virt: abnormal exit 2021-12-13T09:36:48 rmmod: ERROR: Module xeno_can is builtin. 2021-12-13T09:36:48 helpers.c:386, rmmod xeno_can: abnormal exitStrangely, I'm getting the error that already modprobe fails in another setup (qemu-arm64 of xenomai-images) if those things are built-in.
The smokey_net_modprobe() will not call the modprobe command if it finds the module in /proc/modules, but in case of a builtin mnodule, the modprobe will be called and it will fail (this was the behaviour even before my change). In fact, the return value of smokey_net_modprobe(MODID_RTNET, true); in testsuite/smokey/net_common/setup.c is not checked.
IMHO I can call smokey_modprobe(CAN_MOD, true); and smokey_modprobe(CAN_VIRT_MOD, true); without checking the return value.
Quoted 3 lines
And please make sure we simply skip the test if the feature is not configured. Might require some
_CC_COBALT_GET_CAN_CONFIG(analogously to_CC_COBALT_GET_NET_CONFIGandkernel/drivers/net/stack/corectl.c).
Ok, I'll do it.
Thanks and regards,
Dario
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
PATCH v4 2/8 testsuite/smokey: add virtual CAN testsuite
In reply to Dario BinacchiAdd a minimal test for the virtual CAN driver, checking that sent messages are received correctly.
The timeout on read operations has been wired to 1 s in order not to fail the test in case the verbose option is enabled.
---
Changes in v4:
- Load/unload the CAN drivers modules before/after running the test.
- Add setup/teardown function
Changes in v3:
- Add the patch to the series.
configure.ac | 1 + testsuite/smokey/Makefile.am | 2 + testsuite/smokey/can-virt/Makefile.am | 8 + testsuite/smokey/can-virt/virt.c | 356 ++++++++++++++++++++++++++ 4 files changed, 367 insertions(+) create mode 100644 testsuite/smokey/can-virt/Makefile.am create mode 100644 testsuite/smokey/can-virt/virt.c
configure.ac +1 -0
@@ -1005,6 +1005,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/cpu-affinity/Makefile \ testsuite/smokey/gdb/Makefile \ testsuite/smokey/y2038/Makefile \ + testsuite/smokey/can-virt/Makefile testsuite/clocktest/Makefile \ testsuite/xeno-test/Makefile \ utils/Makefile \
testsuite/smokey/Makefile.am +2 -0
@@ -12,6 +12,7 @@ smokey_SOURCES = main.c COBALT_SUBDIRS = \ arith \ bufp \ + can-virt \ cpu-affinity \ fpu-stress \ gdb \
@@ -49,6 +50,7 @@ MERCURY_SUBDIRS = \ DIST_SUBDIRS = \ arith \ bufp \ + can-virt \ cpu-affinity \ dlopen \ fpu-stress \
testsuite/smokey/can-virt/Makefile.am new file +8 -0
@@ -0,0 +1,8 @@ +noinst_LIBRARIES = libcan-virt.a + +libcan_virt_a_SOURCES = \ + virt.c + +libcan_virt_a_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include
testsuite/smokey/can-virt/virt.c new file +356 -0
356 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 3/8 drivers/can: add multi message support to sendmsg
In reply to Dario BinacchiThe `user_msghdr' structure is designed to send multiple messages as well, so rtcan_raw_sendmsg() can also send multiple messages. This avoids having to add the sendmmsg system call which requires more extensive Xenomai changes.
---
(no changes since v1)
kernel/drivers/can/rtcan_raw.c | 239 ++++++++++++++++++--------------- 1 file changed, 128 insertions(+), 111 deletions(-)
kernel/drivers/can/rtcan_raw.c +128 -111
@@ -762,113 +762,13 @@ ssize_t rtcan_raw_recvmsg(struct rtdm_fd *fd, } -ssize_t rtcan_raw_sendmsg (struct rtdm_fd *fd, -const struct user_msghdr *msg,int flags) +static ssize_t __rtcan_raw_sendmsg (struct rtcan_device *dev,struct rtcan_socket *sock, +can_frame_t *frame,nanosecs_rel_t timeout) { -struct rtcan_socket *sock =rtdm_fd_to_private (fd); -struct sockaddr_can *scan = (struct sockaddr_can *)msg->msg_name; -struct sockaddr_can scan_buf; -struct iovec *iov = (struct iovec *)msg->msg_iov; -struct iovec iov_buf; -can_frame_t *frame; -can_frame_t frame_buf; -rtdm_lockctx_t lock_ctx; -nanosecs_rel_t timeout =0 ;struct tx_wait_queue tx_wait; -struct rtcan_device *dev; -int ifindex =0 ; -int ret =0 ; +rtdm_lockctx_t lock_ctx;spl_t s; - - -if (flags &MSG_OOB )/* Mirror BSD error message compatibility */ -return -EOPNOTSUPP ; - -/* Only MSG_DONTWAIT is a valid flag. */ -if (flags & ~MSG_DONTWAIT ) -return -EINVAL ; - -/* Check msg_iovlen, only one buffer allowed */ -if (msg->msg_iovlen !=1 ) -return -EMSGSIZE ; - -if (scan ==NULL ) { -/* No socket address. Will use bound interface for sending */ - -if (msg->msg_namelen !=0 ) -return -EINVAL ; - - -/* We only want a consistent value here, a spin lock would be -* overkill. Nevertheless, the binding could change till we have -* the chance to send. Blame the user, though. */ - ifindex =atomic_read (&sock->ifindex); - -if (!ifindex) -/* Socket isn't bound or bound to all interfaces. Go out. */ -return -ENXIO ; - }else { -/* Socket address given */ -if (msg->msg_namelen <sizeof (struct sockaddr_can )) -return -EINVAL ; - -if (rtdm_fd_is_user (fd)) { -/* Copy socket address from userspace */ -if (!rtdm_read_user_ok (fd, msg->msg_name, -sizeof (struct sockaddr_can )) || -rtdm_copy_from_user (fd, &scan_buf, msg->msg_name, -sizeof (struct sockaddr_can ))) -return -EFAULT ; - - scan = &scan_buf; - } - -/* Check address family */ -if (scan->can_family !=AF_CAN ) -return -EINVAL ; - - ifindex = scan->can_ifindex; - } - -if (rtdm_fd_is_user (fd)) { -/* Copy IO vector from userspace */ -if (!rtdm_rw_user_ok (fd, msg->msg_iov, -sizeof (struct iovec )) || -rtdm_copy_from_user (fd, &iov_buf, msg->msg_iov, -sizeof (struct iovec ))) -return -EFAULT ; - - iov = &iov_buf; - } - -/* Check size of buffer */ -if (iov->iov_len !=sizeof (can_frame_t)) -return -EMSGSIZE ; - - frame = (can_frame_t *)iov->iov_base; - -if (rtdm_fd_is_user (fd)) { -/* Copy CAN frame from userspace */ -if (!rtdm_read_user_ok (fd, iov->iov_base, -sizeof (can_frame_t)) || -rtdm_copy_from_user (fd, &frame_buf, iov->iov_base, -sizeof (can_frame_t))) -return -EFAULT ; - - frame = &frame_buf; - } - -/* Adjust iovec in the common way */ - iov->iov_base +=sizeof (can_frame_t); - iov->iov_len -=sizeof (can_frame_t); -/* ... and copy it back to userspace if necessary */ -if (rtdm_fd_is_user (fd)) { -if (rtdm_copy_to_user (fd, msg->msg_iov, iov, -sizeof (struct iovec ))) -return -EFAULT ; - } - -/* At last, we've got the frame ... */ +int ret =0 ;/* Check if DLC between 0 and 15 */ if (frame->can_dlc >15 )
@@ -881,11 +781,6 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_fd *fd,return -EINVAL ; } -if ((dev =rtcan_dev_get_by_index (ifindex)) ==NULL ) -return -ENXIO ; - - timeout = (flags &MSG_DONTWAIT ) ?RTDM_TIMEOUT_NONE : sock->tx_timeout; - tx_wait.rt_task =rtdm_task_current ();/* Register the task at the socket's TX wait queue and decrement
@@ -931,7 +826,6 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_fd *fd,/* We got access */ -/* Push message onto stack for loopback when TX done */ if (rtcan_loopback_enabled (sock))rtcan_tx_push (dev, sock, frame);
@@ -960,10 +854,133 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_fd *fd, send_out2:rtdm_lock_put_irqrestore (&dev->device_lock, lock_ctx); send_out1: -rtcan_dev_dereference (dev);return ret; } +ssize_t rtcan_raw_sendmsg (struct rtdm_fd *fd, +const struct user_msghdr *msg,int flags) +{ +struct rtcan_socket *sock =rtdm_fd_to_private (fd); +struct sockaddr_can *scan = (struct sockaddr_can *)msg->msg_name; +struct sockaddr_can scan_buf; +struct iovec *iov = (struct iovec *)msg->msg_iov; +struct iovec iov_buf; +can_frame_t *frame; +can_frame_t frame_buf; +nanosecs_rel_t timeout; +struct rtcan_device *dev; +int ret =0 , ifindex =0 , i =0 , n, sent =0 ; + +if (flags &MSG_OOB )/* Mirror BSD error message compatibility */ +return -EOPNOTSUPP ; + +/* Only MSG_DONTWAIT is a valid flag. */ +if (flags & ~MSG_DONTWAIT ) +return -EINVAL ; + + timeout = (flags &MSG_DONTWAIT ) ?RTDM_TIMEOUT_NONE : sock->tx_timeout; + +if (scan ==NULL ) { +/* No socket address. Will use bound interface for sending */ +if (msg->msg_namelen !=0 ) +return -EINVAL ; + + +/* We only want a consistent value here, a spin lock would be +* overkill. Nevertheless, the binding could change till we have +* the chance to send. Blame the user, though. */ + ifindex =atomic_read (&sock->ifindex); +if (!ifindex) +/* Socket isn't bound or bound to all interfaces. Go out. */ +return -ENXIO ; + }else { +/* Socket address given */ +if (msg->msg_namelen <sizeof (struct sockaddr_can )) +return -EINVAL ; + +if (rtdm_fd_is_user (fd)) { +/* Copy socket address from userspace */ +if (!rtdm_read_user_ok (fd, msg->msg_name, +sizeof (struct sockaddr_can )) || +rtdm_copy_from_user (fd, &scan_buf, msg->msg_name, +sizeof (struct sockaddr_can ))) +return -EFAULT ; + + scan = &scan_buf; + } + +/* Check address family */ +if (scan->can_family !=AF_CAN ) +return -EINVAL ; + + ifindex = scan->can_ifindex; + } + + dev =rtcan_dev_get_by_index (ifindex); +if (!dev) +return -ENXIO ; + +if (rtdm_fd_is_user (fd)) { + +/* Copy IO vector from userspace */ +if (!rtdm_rw_user_ok (fd, msg->msg_iov, +sizeof (struct iovec )) || +rtdm_copy_from_user (fd, &iov_buf, msg->msg_iov, +sizeof (struct iovec ))) { + ret = -EFAULT ; + goto finally; + } + + iov = &iov_buf; + } + + n = msg->msg_iovlen; +while (i < n) { +if (iov->iov_len <sizeof (can_frame_t)) { + ret = -EMSGSIZE ; + goto finally; + } + + frame = (can_frame_t *)iov->iov_base; + +if (rtdm_fd_is_user (fd)) { +/* Copy CAN frame from userspace */ +if (!rtdm_read_user_ok (fd, iov->iov_base,sizeof (can_frame_t)) || +rtdm_copy_from_user (fd, &frame_buf, iov->iov_base, +sizeof (can_frame_t))) { + ret = -EFAULT ; + goto finally; + } + + frame = &frame_buf; + } + + iov->iov_base +=sizeof (can_frame_t); + iov->iov_len -=sizeof (can_frame_t); + + ret =__rtcan_raw_sendmsg (dev, sock, frame, timeout); +if (ret <0 ) + goto finally; + + sent += ret; + } + +/* copy it back to userspace if necessary */ +if (rtdm_fd_is_user (fd)) { +if (rtdm_copy_to_user (fd, msg->msg_iov, iov,sizeof (struct iovec ))) { + ret = -EFAULT ; + goto finally; + } + } + +finally: +rtcan_dev_dereference (dev); + +if (sent >0 ) +return sent; + +return ret; +}static struct rtdm_driver rtcan_driver = { .profile_info = RTDM_PROFILE_INFO(rtcan,
Signature · 1 line
2.17.1
PATCH v4 4/8 drivers/can: add CAN_ERR_CRTL_ACTIVE info status
In reply to Dario BinacchiTo be used in case of recovered to error active state.
---
(no changes since v1)
include/rtdm/uapi/can.h | 1 + 1 file changed, 1 insertion(+)
include/rtdm/uapi/can.h +1 -0
@@ -837,6 +837,7 @@ struct can_ifreq {#define CAN_ERR_CRTL_TX_WARNING 0x08/**< reached warning level for TX errors */ #define CAN_ERR_CRTL_RX_PASSIVE 0x10/**< reached passive level for RX errors */ #define CAN_ERR_CRTL_TX_PASSIVE 0x20/**< reached passive level for TX errors */ +#define CAN_ERR_CRTL_ACTIVE 0x40/**< recovered to error active state */ /** @} */ /*!
Signature · 1 line
2.17.1
PATCH v4 5/8 drivers/can: add len field to can frame structures
In reply to Dario BinacchiAs mentioned in Linux, can_dlc is a misleading name that suggests a code instead of a length. Adding the len field can_dlc becomes deprecated too.
---
(no changes since v1)
include/rtdm/uapi/can.h | 5 ++++- kernel/drivers/can/rtcan_socket.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
include/rtdm/uapi/can.h +4 -1
@@ -318,7 +318,10 @@ typedef struct can_frame {can_id_t can_id;/** Size of the payload in bytes */ -uint8_t can_dlc; +union { +uint8_t can_dlc; +uint8_t len; + };/** Payload data bytes */ uint8_t data[8] __attribute__ ((aligned(8)));
kernel/drivers/can/rtcan_socket.h +4 -1
@@ -76,7 +76,10 @@ struct rtcan_rb_frame {/* DLC (between 0 and 15) and mark if frame has got a timestamp. The * existence of a timestamp is indicated by the RTCAN_HAS_TIMESTAMP * bit. */ -unsigned char can_dlc; +union { +unsigned char can_dlc; +unsigned char len; + };/* Data bytes */ uint8_t data[8 ];
Signature · 1 line
2.17.1
PATCH v4 6/8 drivers/can: add a minimal support to ethtool API
In reply to Dario BinacchiLike in the Linux kernel, the API allows to get/set device controller parameters.
For now it only supports:
- ETHTOOL_GDRVINFO: get general driver and device information
- ETHTOOL_GRINGPARAM: get RX/TX ring parameters
It allows the userspace to know the number of messages managed by the controller and how many of them are used for reception/transmission. This information allows you to know the maximum number of messages that sendmsg() can transmit without returning a full FIFO error.
Application programs are expected to use the new API directly via IOCTL, since, unlike the Linux Kernel, there is currently no userspace application like ethtool in Xenomai.
---
(no changes since v2)
Changes in v2:
- Expand the commit message to better describe the added API.
kernel/drivers/can/Makefile | 2 +- kernel/drivers/can/rtcan_dev.h | 4 +- kernel/drivers/can/rtcan_ethtool.c | 75 ++++++++++++++++++++++++++++++ kernel/drivers/can/rtcan_ethtool.h | 24 ++++++++++ kernel/drivers/can/rtcan_raw_dev.c | 20 ++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 kernel/drivers/can/rtcan_ethtool.c create mode 100644 kernel/drivers/can/rtcan_ethtool.h
kernel/drivers/can/Makefile +1 -1
@@ -5,6 +5,6 @@ obj-$(CONFIG_XENO_DRIVERS_CAN) += xeno_can.o mscan/ sja1000/ peak_canfd/ obj-$(CONFIG_XENO_DRIVERS_CAN_FLEXCAN) += xeno_can_flexcan.o obj-$(CONFIG_XENO_DRIVERS_CAN_VIRT) += xeno_can_virt.o -xeno_can-y := rtcan_dev.o rtcan_socket.o rtcan_module.o rtcan_raw.o rtcan_raw_dev.o rtcan_raw_filter.o +xeno_can-y := rtcan_dev.o rtcan_socket.o rtcan_module.o rtcan_raw.o rtcan_raw_dev.o rtcan_raw_filter.o rtcan_ethtool.o xeno_can_virt-y := rtcan_virt.o xeno_can_flexcan-y := rtcan_flexcan.o
kernel/drivers/can/rtcan_dev.h +3 -1
@@ -34,7 +34,7 @@#include <linux/semaphore.h> #include "rtcan_list.h" - +#include "rtcan_ethtool.h" /* Number of MSCAN devices the driver can handle */ #define RTCAN_MAX_DEVICES CONFIG_XENO_DRIVERS_CAN_MAX_DEVICES
@@ -137,6 +137,8 @@ struct rtcan_device {void (*do_enable_bus_err)(struct rtcan_device *dev);#endif +const struct rtcan_ethtool_ops *ethtool_ops; +/* Reception list head. This list contains all filters which have been * registered via a bind call. */ struct rtcan_recv *recv_list;
kernel/drivers/can/rtcan_ethtool.c new file +75 -0
75 lines not on this page · raw message
kernel/drivers/can/rtcan_ethtool.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef __RTCAN_ETHTOOL_H_ +#define __RTCAN_ETHTOOL_H_ + +#ifdef __KERNEL__ + +#include <linux/ethtool.h> + +struct rtcan_device ; + +struct rtcan_ethtool_ops { +int (*begin)(struct rtcan_device *dev); +int (*complete)(struct rtcan_device *dev); +void (*get_drvinfo)(struct rtcan_device *dev, +struct ethtool_drvinfo *info); +void (*get_ringparam)(struct rtcan_device *dev, +struct ethtool_ringparam *ring); +}; + +int rtcan_ethtool (struct rtdm_fd *fd,struct rtcan_device *dev, +struct ifreq *ifr); + +#endif /* __KERNEL__ */ + +#endif /* __RTCAN_ETHTOOL_H_ */
kernel/drivers/can/rtcan_raw_dev.c +20 -0
@@ -354,6 +354,7 @@ static inline int rtcan_raw_ioctl_dev_set(struct rtcan_device *dev,int rtcan_raw_ioctl_dev (struct rtdm_fd *fd,int request,void *arg) {struct can_ifreq *ifr; +struct ifreq *ifreq;int ret =0 , get =0 ;union {/*
@@ -414,7 +415,26 @@ int rtcan_raw_ioctl_dev(struct rtdm_fd *fd, int request, void *arg)rtcan_dev_dereference (dev); }break ; +case SIOCETHTOOL : +if (rtdm_fd_is_user (fd)) { +/* Copy struct can_ifreq from userspace */ +if (!rtdm_read_user_ok (fd, arg,sizeof (*ifreq)) || +rtdm_copy_from_user (fd, &ifr_buf, arg,sizeof (*ifreq))) +return -EFAULT ; + + ifreq = &ifr_buf.ifr_legacy; + }else { + ifreq = (struct ifreq *)arg; + } +/* Get interface index and data */ + dev =rtcan_dev_get_by_name (ifreq->ifr_name); +if (dev ==NULL ) +return -ENODEV ; + + ret =rtcan_ethtool (fd, dev, ifreq); +rtcan_dev_dereference (dev); +break ;default : ret = -EOPNOTSUPP ;break ;
Signature · 1 line
2.17.1
PATCH v4 7/8 drivers/can: fix updating of tx_count statistics
In reply to Dario BinacchiAs in the Linux kernel, the counter is updated only after the message has been really transmitted.
---
(no changes since v1)
kernel/drivers/can/mscan/rtcan_mscan.c | 1 + kernel/drivers/can/rtcan_flexcan.c | 1 + kernel/drivers/can/rtcan_raw.c | 1 - kernel/drivers/can/rtcan_virt.c | 1 + kernel/drivers/can/sja1000/rtcan_sja1000.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-)
kernel/drivers/can/mscan/rtcan_mscan.c +1 -0
@@ -217,6 +217,7 @@ static int rtcan_mscan_interrupt(rtdm_irq_t *irq_handle)out_8 (®s->cantier,0 );/* Wake up a sender */ rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev)) {
kernel/drivers/can/rtcan_flexcan.c +1 -0
@@ -897,6 +897,7 @@ static int flexcan_irq(rtdm_irq_t *irq_handle) &priv->tx_mb->can_ctrl);flexcan_write (FLEXCAN_IFLAG_MB (priv->tx_mb_idx), ®s->iflag1);rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev))rtcan_loopback (dev); handled =RTDM_IRQ_HANDLED ;
kernel/drivers/can/rtcan_raw.c +0 -1
@@ -844,7 +844,6 @@ static ssize_t __rtcan_raw_sendmsg(struct rtcan_device *dev, struct rtcan_socket goto send_out2; } - dev->tx_count++; ret = dev->hard_start_xmit (dev, frame);/* Return number of bytes sent upon successful completion */
kernel/drivers/can/rtcan_virt.c +1 -0
@@ -56,6 +56,7 @@ static int rtcan_virt_start_xmit(struct rtcan_device *tx_dev,/* we can transmit immediately again */ rtdm_sem_up (&tx_dev->tx_sem); + tx_dev->tx_count++; skb.rb_frame_size =EMPTY_RB_FRAME_SIZE ;
kernel/drivers/can/sja1000/rtcan_sja1000.c +1 -0
@@ -326,6 +326,7 @@ static int rtcan_sja_interrupt(rtdm_irq_t *irq_handle)if (irq_source &SJA_IR_TI ) {/* Wake up a sender */ rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev)) {
Signature · 1 line
2.17.1
Re: [PATCH v4 7/8] drivers/can: fix updating of tx_count statistics
Quoted 69 lines · Dario Binacchi
As in the Linux kernel, the counter is updated only after the message has been really transmitted.
Signed-off-by Dario Binacchi <[email protected]>---
(no changes since v1)
kernel/drivers/can/mscan/rtcan_mscan.c | 1 + kernel/drivers/can/rtcan_flexcan.c | 1 + kernel/drivers/can/rtcan_raw.c | 1 - kernel/drivers/can/rtcan_virt.c | 1 + kernel/drivers/can/sja1000/rtcan_sja1000.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-)kernel/drivers/can/mscan/rtcan_mscan.c +1
-0@@ -217,6 +217,7 @@ static int rtcan_mscan_interrupt(rtdm_irq_t *irq_handle)out_8 (®s->cantier,0 );/* Wake up a sender */ rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev)) {kernel/drivers/can/rtcan_flexcan.c +1
-0@@ -897,6 +897,7 @@ static int flexcan_irq(rtdm_irq_t *irq_handle) &priv->tx_mb->can_ctrl);flexcan_write (FLEXCAN_IFLAG_MB (priv->tx_mb_idx), ®s->iflag1);rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev))rtcan_loopback (dev); handled =RTDM_IRQ_HANDLED ;kernel/drivers/can/rtcan_raw.c +0
-1@@ -844,7 +844,6 @@ static ssize_t __rtcan_raw_sendmsg(struct rtcan_device *dev, struct rtcan_socket goto send_out2; } - dev->tx_count++; ret = dev->hard_start_xmit (dev, frame);/* Return number of bytes sent upon successful completion */ kernel/drivers/can/rtcan_virt.c +1
-0@@ -56,6 +56,7 @@ static int rtcan_virt_start_xmit(struct rtcan_device *tx_dev,/* we can transmit immediately again */ rtdm_sem_up (&tx_dev->tx_sem); + tx_dev->tx_count++; skb.rb_frame_size =EMPTY_RB_FRAME_SIZE ;kernel/drivers/can/sja1000/rtcan_sja1000.c +0
-0
kernel/drivers/can/sja1000/rtcan_sja1000.c static int rtcan_sja_interrupt(rtdm_irq_t *irq_handle) · line 332
Quoted 7 lines
kernel/drivers/can/sja1000/rtcan_sja1000.c +1
-0@@ -326,6 +326,7 @@ static int rtcan_sja_interrupt(rtdm_irq_t *irq_handle)if (irq_source &SJA_IR_TI ) {/* Wake up a sender */ rtdm_sem_up (&dev->tx_sem); + dev->tx_count++;if (rtcan_loopback_pending (dev)) {
I'll keep this fix in next and will later on propagate it to stable. So you can drop it from v5.
Thanks,
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
PATCH v4 8/8 drivers/can: add support for Bosch C_CAN controller
In reply to Dario BinacchiBosch C_CAN controller is a full-CAN implementation which is compliant to CAN protocol version 2.0 part A and B.
Starting from the RTDM porting [1] by Stephen Battazzo, Michael applied some fixes for proper driver operation. Then I ported the commits from Linux kernel version 5.12 and finally I added support for 64 message objects [2] and improved the FIFO management [2] to get the best possible RX/TX throughput. Features [2] and [3] led to the creation of patches applied to the Linux kernel too.
The patch was tested on a custom board mounting an AM335x SOC.
PCI support has not been developed.
[1] http://xenomai.org/pipermail/xenomai/2015-July/034690.html
[2] 132f2d45fb23 ("can: c_can: add support to 64 message objects")
[3] 387da6bc7a82 ("can: c_can: cache frames to operate as a true FIFO")
---
(no changes since v3)
Changes in v3:
- Add virtual CAN testsuite
Changes in v2:
- Drop 'default n' Kconfig
- Enable the driver for Xenomai CI builds
- Drop commented code
- Drop power managemet (pm) code
.gitlab-ci.yml | 2 + kernel/drivers/can/Kconfig | 1 + kernel/drivers/can/Makefile | 2 +- kernel/drivers/can/README | 1 + kernel/drivers/can/c_can/Kconfig | 15 + kernel/drivers/can/c_can/Makefile | 8 + kernel/drivers/can/c_can/rtcan_c_can.c | 1298 +++++++++++++++++ kernel/drivers/can/c_can/rtcan_c_can.h | 255 ++++ .../drivers/can/c_can/rtcan_c_can_ethtool.c | 47 + .../drivers/can/c_can/rtcan_c_can_platform.c | 461 ++++++ 10 files changed, 2089 insertions(+), 1 deletion(-) create mode 100644 kernel/drivers/can/c_can/Kconfig create mode 100644 kernel/drivers/can/c_can/Makefile create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.h create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_ethtool.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_platform.c
.gitlab-ci.yml +2 -0
@@ -118,6 +118,8 @@ variables: - ./scripts/config -e XENO_DRIVERS_CAN_SJA1000_ESD_PCI - ./scripts/config -e XENO_DRIVERS_CAN_SJA1000_PEAK_DNG - ./scripts/config -e XENO_DRIVERS_CAN_PEAK_CANFD + - ./scripts/config -e XENO_DRIVERS_CAN_C_CAN + - ./scripts/config -e XENO_DRIVERS_CAN_C_CAN_PLATFORM - ./scripts/config -m XENO_DRIVERS_NET - ./scripts/config -e XENO_DRIVERS_RTNET_CHECKED - ./scripts/config -e XENO_DRIVERS_NET_ETH_P_ALL
kernel/drivers/can/Kconfig +1 -0
@@ -85,6 +85,7 @@ config XENO_DRIVERS_CAN_FLEXCAN Say Y here if you want to support for Freescale FlexCAN. +source "drivers/xenomai/can/c_can/Kconfig" source "drivers/xenomai/can/mscan/Kconfig" source "drivers/xenomai/can/peak_canfd/Kconfig" source "drivers/xenomai/can/sja1000/Kconfig"
kernel/drivers/can/Makefile +1 -1
@@ -1,7 +1,7 @@ ccflags-y += -I$(srctree)/drivers/xenomai/can -obj-$(CONFIG_XENO_DRIVERS_CAN) += xeno_can.o mscan/ sja1000/ peak_canfd/ +obj-$(CONFIG_XENO_DRIVERS_CAN) += xeno_can.o mscan/ sja1000/ peak_canfd/ c_can/ obj-$(CONFIG_XENO_DRIVERS_CAN_FLEXCAN) += xeno_can_flexcan.o obj-$(CONFIG_XENO_DRIVERS_CAN_VIRT) += xeno_can_virt.o
kernel/drivers/can/README +1 -0
@@ -20,6 +20,7 @@ devices: SJA1000 PEAK parallel port Dongle SJA1000 IXXAT PCI card MSCAN for MPC5200 boards + C_CAN/D_CAN for AM335x/AM437x Sitara processors and DRA7 SOC Utilities for RT-Socket-CAN are available in "src/utils/can".
kernel/drivers/can/c_can/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +config XENO_DRIVERS_CAN_C_CAN + depends on XENO_DRIVERS_CAN && OF + tristate "Bosch C-CAN based chips" + +config XENO_DRIVERS_CAN_C_CAN_PLATFORM + depends on XENO_DRIVERS_CAN_C_CAN + tristate "Generic Platform Bus based controller" + help + + This driver adds support for the C_CAN/D_CAN chips connected + to the "platform bus" (Linux abstraction for directly to the + processor attached devices) which can be found on various + boards from ST Microelectronics (http://www.st.com) like the + SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com) + boards like am335x, dm814x, dm813x and dm811x.
kernel/drivers/can/c_can/Makefile new file +8 -0
@@ -0,0 +1,8 @@ + +ccflags-y += -Idrivers/xenomai/can -Idrivers/xenomai/can/c_can + +obj-$(CONFIG_XENO_DRIVERS_CAN_C_CAN) += xeno_can_c_can.o +obj-$(CONFIG_XENO_DRIVERS_CAN_C_CAN_PLATFORM) += xeno_can_c_can_platform.o + +xeno_can_c_can-y := rtcan_c_can.o rtcan_c_can_ethtool.o +xeno_can_c_can_platform-y := rtcan_c_can_platform.o
kernel/drivers/can/c_can/rtcan_c_can.c new file +1298 -0
1,298 lines not on this page · raw message
kernel/drivers/can/c_can/rtcan_c_can.h new file +255 -0
255 lines not on this page · raw message
kernel/drivers/can/c_can/rtcan_c_can_ethtool.c new file +47 -0
47 lines not on this page · raw message
kernel/drivers/can/c_can/rtcan_c_can_platform.c new file +461 -0
461 lines not on this page · raw message
Signature · 1 line
2.17.1
Jan Kiszka
AppliedQuoted 95 lines · Dario Binacchi
The series was created to optimize the use of the
C_CANcontroller (maximum number of message objects, use of FIFO, ...) to get the best possible RX/TX throughput from hardware.To emphasize the purpose of the series I also added the patch which adds multi-message support to `sendmsg ', rather than' submitting it separately. In fact, it too has contributed to increasing transmission throughput.
The patches prior to the one adding the BOSCH
C_CANcontroller driver, are a backporting of commits from the linux kernel that also impacted on the driver itself and I found it necessary to add to the series.The latest patch, as described in its commit, modified Stephen Battazzo's patch [1] with bug fixes, backporting of commits from the linux kernel, extension of message objects to 64 and improvements in FIFO handling. This series was in fact preceded by the creation of patches which I sent to the Linux kernel and which were then accepted:
387da6bc7a82("can:c_can: cache frames to operate as a true FIFO")28e86e9ab522("can:c_can: support tx ring algorithm")a54cdbba9dee("can:c_can: exitc_can_do_tx()early if no frames have been sent")5064e40596f4("can:c_can: remove structc_can_priv::privfield")06fc143b2ededt-bindings: net: can:c_can: convert to json-schema132f2d45fb23("can:c_can: add support to 64 message objects")13831ce69c77("can:c_can: prepare to up the message objects number")fcbded019855("can:c_can: use 32-bit write to set arbitration register")eddf67115040("can:c_can: add a comment aboutIF_RXinterface's use")c8a6b44388cb("can:c_can: fix indentation")f65735c203d5("can:c_can: remove unused code")The patch was tested on a custom board mounting an AM335x SOC.
PCI support has not been developed.
[1] http://xenomai.org/pipermail/xenomai/2015-July/034690.html
Changes in v4:
- Add the patch to the series.
- Load/unload the CAN drivers modules before/after running the test.
- Add setup/teardown functionChanges in v3:
- Add the patch to the series.
- Add virtual CAN testsuiteChanges in v2:
- Expand the commit message to better describe the added API.
- Drop 'default n'Kconfig
- Enable the driver for Xenomai CI builds
- Drop commented code
- Drop power managemet (pm) codeDario Binacchi (8):
lib/smokey: add smokey_{modprobe,rmmod} helpers testsuite/smokey: add virtual CAN testsuitedrivers/can: add multi message support to sendmsgdrivers/can: addCAN_ERR_CRTL_ACTIVEinfo statusdrivers/can: add len field to can frame structuresdrivers/can: add a minimal support to ethtool APIdrivers/can: fix updating oftx_countstatisticsdrivers/can: add support for BoschC_CANcontroller.gitlab-ci.yml | 2 + configure.ac | 1 + include/rtdm/uapi/can.h | 6 +- include/smokey/smokey.h | 6 +- kernel/drivers/can/Kconfig | 1 + kernel/drivers/can/Makefile | 4 +- kernel/drivers/can/README | 1 + kernel/drivers/can/c_can/Kconfig | 15 + kernel/drivers/can/c_can/Makefile | 8 + kernel/drivers/can/c_can/rtcan_c_can.c | 1298 +++++++++++++++++ kernel/drivers/can/c_can/rtcan_c_can.h | 255 ++++ .../drivers/can/c_can/rtcan_c_can_ethtool.c | 47 + .../drivers/can/c_can/rtcan_c_can_platform.c | 461 ++++++ kernel/drivers/can/mscan/rtcan_mscan.c | 1 + kernel/drivers/can/rtcan_dev.h | 4 +- kernel/drivers/can/rtcan_ethtool.c | 75 + kernel/drivers/can/rtcan_ethtool.h | 24 + kernel/drivers/can/rtcan_flexcan.c | 1 + kernel/drivers/can/rtcan_raw.c | 240 +-- kernel/drivers/can/rtcan_raw_dev.c | 20 + kernel/drivers/can/rtcan_socket.h | 5 +- kernel/drivers/can/rtcan_virt.c | 1 + kernel/drivers/can/sja1000/rtcan_sja1000.c | 1 + lib/smokey/helpers.c | 99 ++ testsuite/smokey/Makefile.am | 2 + testsuite/smokey/can-virt/Makefile.am | 8 + testsuite/smokey/can-virt/virt.c | 356 +++++ testsuite/smokey/net_common/setup.c | 68 +- 28 files changed, 2826 insertions(+), 184 deletions(-) create mode 100644 kernel/drivers/can/c_can/Kconfig create mode 100644 kernel/drivers/can/c_can/Makefile
Quoted 9 lines
create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can.h create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_ethtool.c create mode 100644 kernel/drivers/can/c_can/rtcan_c_can_platform.c create mode 100644 kernel/drivers/can/rtcan_ethtool.c create mode 100644 kernel/drivers/can/rtcan_ethtool.h create mode 100644 testsuite/smokey/can-virt/Makefile.am create mode 100644 testsuite/smokey/can-virt/virt.c
Thanks, applied to next.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux