[PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-13 Thread Jakob Unterwurzacher
The UCAN driver supports the microcontroller-based USB/CAN adapters from Theobroma Systems. There are two form-factors that run essentially the same firmware: * Seal: standalone USB stick ( https://www.theobroma-systems.com/seal ) * Mule: integrated on the PCB of various System-on-Modules from

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-13 Thread Marc Kleine-Budde
On 03/13/2018 06:35 PM, Jakob Unterwurzacher wrote: [...] Please mark all multibyte values going over the USB as either le or be. > +struct ucan_ctl_cmd_start { > + u16 mode;/* oring any of UCAN_MODE_* */ > +} __packed; > + > +struct ucan_ctl_cmd_set_bittiming { > + u32 tq;

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-13 Thread Jakob Unterwurzacher
On 13.03.18 18:44, Marc Kleine-Budde wrote: On 03/13/2018 06:35 PM, Jakob Unterwurzacher wrote: [...] Please mark all multibyte values going over the USB as either le or be. This is documented in can_ucan_protocol.rst, All multi-byte integers are encoded as Little Endian. but it's proba

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-13 Thread Marc Kleine-Budde
On 03/13/2018 06:53 PM, Jakob Unterwurzacher wrote: > On 13.03.18 18:44, Marc Kleine-Budde wrote: >> On 03/13/2018 06:35 PM, Jakob Unterwurzacher wrote: >> >> [...] >> >> Please mark all multibyte values going over the USB as either le or be. > > This is documented in can_ucan_protocol.rst, > >

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Marc Kleine-Budde
On 03/13/2018 06:35 PM, Jakob Unterwurzacher wrote: > The UCAN driver supports the microcontroller-based USB/CAN > adapters from Theobroma Systems. There are two form-factors > that run essentially the same firmware: > > * Seal: standalone USB stick ( https://www.theobroma-systems.com/seal ) > >

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 08:51, Marc Kleine-Budde wrote: + memcpy(cf->data, m->msg.can_msg.data, cf->can_dlc); + + /* don't count error frames as real packets */ + if (!(canid & CAN_ERR_FLAG)) { + stats->rx_packets++; + stats->rx_bytes += cf->can_dlc; +

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 10:11, Wolfgang Grandegger wrote: +    /* handle error frames */ +    canid = le32_to_cpu(m->msg.can_msg.id); +    if (canid & CAN_ERR_FLAG) { +    ucan_handle_error_frame(up, m, canid); +    /* drop frame if berr-reporting is off */ +    if (!(up->can.ctrlmode & CAN_CTRLM

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Wolfgang Grandegger
Am 14.03.2018 um 10:14 schrieb Jakob Unterwurzacher: On 14.03.18 10:11, Wolfgang Grandegger wrote: +    /* handle error frames */ +    canid = le32_to_cpu(m->msg.can_msg.id); +    if (canid & CAN_ERR_FLAG) { +    ucan_handle_error_frame(up, m, canid); +    /* drop frame if berr-reporti

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Wolfgang Grandegger
Hello, Am 13.03.2018 um 18:35 schrieb Jakob Unterwurzacher: The UCAN driver supports the microcontroller-based USB/CAN adapters from Theobroma Systems. There are two form-factors that run essentially the same firmware: * Seal: standalone USB stick ( https://www.theobroma-systems.com/seal ) * M

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 10:17, Wolfgang Grandegger wrote: Counting the state changes is one thing but you should also generate error messages for them. We do for BUS-OFF already (see below), but not for other states - will do in v3. + /* we switched into a worse state */ + up->can.state = n

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Wolfgang Grandegger
Am 14.03.2018 um 10:17 schrieb Wolfgang Grandegger: Am 14.03.2018 um 10:14 schrieb Jakob Unterwurzacher: On 14.03.18 10:11, Wolfgang Grandegger wrote: +    /* handle error frames */ +    canid = le32_to_cpu(m->msg.can_msg.id); +    if (canid & CAN_ERR_FLAG) { +    ucan_handle_error_fram

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 10:25, Wolfgang Grandegger wrote: Counting the state changes is one thing but you should also generate error messages for them. The usual test here is: $ candump -td -e any,0:0,# should report proper state changes, if you send messages with 1. no cable connected 2. CAN hi

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Wolfgang Grandegger
Hello Jakob, Am 14.03.2018 um 10:48 schrieb Jakob Unterwurzacher: > On 14.03.18 10:25, Wolfgang Grandegger wrote: >>> Counting the state changes is one thing but you should also generate >>> error messages for them. >> >> The usual test here is: >> >> $ candump -td -e any,0:0,# >> >> shou

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 11:04, Wolfgang Grandegger wrote: controller-problem{rx-error-warning,tx-error-warning,rx-error-passive,tx-error-passive} Just, controller-problem{rx-error-passive,tx-error-passive} Ok. (1b) cable gets connected:  (000.000883)  can0  2034   [8]  00 3C 00 00

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Jakob Unterwurzacher
On 14.03.18 11:04, Wolfgang Grandegger wrote: (000.000443) can0 2034 [8] 00 0C 00 00 00 00 78 00 ERRORFRAME controller-problem{rx-error-warning,tx-error-warning} transceiver-status no-acknowledgement-on-tx error-counter-tx-rx{{120}{0}} (000.000444) can0 2034 [

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-14 Thread Wolfgang Grandegger
Am 14.03.2018 um 20:07 schrieb Jakob Unterwurzacher: On 14.03.18 11:04, Wolfgang Grandegger wrote:  (000.000443)  can0  2034   [8]  00 0C 00 00 00 00 78 00 ERRORFRAME     controller-problem{rx-error-warning,tx-error-warning}     transceiver-status     no-acknowledgement-on-tx     error-

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-16 Thread kbuild test robot
Hi Jakob, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.16-rc5] [cannot apply to next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://g

Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices

2018-03-16 Thread kbuild test robot
Hi Jakob, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.16-rc5] [cannot apply to next-20180316] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://g

rx_packets/bytes stats for error frames (was: Re: [PATCH v2 1/1] can: ucan: add driver for Theobroma Systems UCAN devices)

2018-03-14 Thread Marc Kleine-Budde
On 03/14/2018 10:09 AM, Jakob Unterwurzacher wrote: > On 14.03.18 08:51, Marc Kleine-Budde wrote: >>> + memcpy(cf->data, m->msg.can_msg.data, cf->can_dlc); >>> + >>> + /* don't count error frames as real packets */ >>> + if (!(canid & CAN_ERR_FLAG)) { >>> + stats->rx_packets