From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>,
linux-can@vger.kernel.org
Cc: wg@grandegger.com
Subject: Re: [PATCH 15/17] can: ems_usb: In CAN error handling routine checking which CAN controller type is issuing the error
Date: Fri, 6 Nov 2020 19:01:58 +0100 [thread overview]
Message-ID: <d84c8bd0-1f27-6737-bffc-40413c29d3e9@pengutronix.de> (raw)
In-Reply-To: <20201106170206.32162-16-uttenthaler@ems-wuensche.com>
[-- Attachment #1.1: Type: text/plain, Size: 4082 bytes --]
On 11/6/20 6:02 PM, Gerhard Uttenthaler wrote:
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
> ---
> drivers/net/can/usb/ems_usb.c | 77 +++++++++++++++++++----------------
> 1 file changed, 43 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
> index c36f02eeec85..4a67c57c4760 100644
> --- a/drivers/net/can/usb/ems_usb.c
> +++ b/drivers/net/can/usb/ems_usb.c
> @@ -103,6 +103,9 @@ MODULE_LICENSE("GPL v2");
>
> #define SJA1000_DEFAULT_OUTPUT_CONTROL 0xDA
>
> +#define SJA1000 2 // NXP basic CAN controller
> +#define LPC546XX 5 // NXP CAN FD controller
please add a proper prefix to these definees
> +
> /* CPC-USB/ARM7 actually uses a 16MHz clock to generate the CAN clock
> * but it expects SJA1000 bit settings based on 8MHz (is internally
> * converted).
> @@ -441,6 +444,9 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg)
> if (!skb)
> return;
>
> + /* The CPC_MSG_TYPE_CAN_STATE works for both
> + * CPC-USB/ARM7 and CPC-USB/FD
> + */
> if (msg->type == CPC_MSG_TYPE_CAN_STATE) {
> u8 state = msg->msg.can_state;
>
> @@ -458,40 +464,43 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg)
> dev->can.can_stats.error_passive++;
> }
> } else if (msg->type == CPC_MSG_TYPE_CAN_FRAME_ERROR) {
> - u8 ecc = msg->msg.error.cc.regs.sja1000.ecc;
> - u8 txerr = msg->msg.error.cc.regs.sja1000.txerr;
> - u8 rxerr = msg->msg.error.cc.regs.sja1000.rxerr;
> -
> - /* bus error interrupt */
> - dev->can.can_stats.bus_error++;
> - stats->rx_errors++;
> -
> - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
> -
> - switch (ecc & SJA1000_ECC_MASK) {
> - case SJA1000_ECC_BIT:
> - cf->data[2] |= CAN_ERR_PROT_BIT;
> - break;
> - case SJA1000_ECC_FORM:
> - cf->data[2] |= CAN_ERR_PROT_FORM;
> - break;
> - case SJA1000_ECC_STUFF:
> - cf->data[2] |= CAN_ERR_PROT_STUFF;
> - break;
> - default:
> - cf->data[3] = ecc & SJA1000_ECC_SEG;
> - break;
> - }
> -
> - /* Error occurred during transmission? */
> - if ((ecc & SJA1000_ECC_DIR) == 0)
> - cf->data[2] |= CAN_ERR_PROT_TX;
> -
> - if (dev->can.state == CAN_STATE_ERROR_WARNING ||
> - dev->can.state == CAN_STATE_ERROR_PASSIVE) {
> - cf->can_id |= CAN_ERR_CRTL;
> - cf->data[1] = (txerr > rxerr) ?
> - CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE;
> + // CPC-USB/ARM7
no c++ comments
> + if (msg->msg.error.cc.cc_type == SJA1000) {
> + u8 ecc = msg->msg.error.cc.regs.sja1000.ecc;
> + u8 txerr = msg->msg.error.cc.regs.sja1000.txerr;
> + u8 rxerr = msg->msg.error.cc.regs.sja1000.rxerr;
> +
> + /* bus error interrupt */
> + dev->can.can_stats.bus_error++;
> + stats->rx_errors++;
> +
> + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
> +
> + switch (ecc & SJA1000_ECC_MASK) {
> + case SJA1000_ECC_BIT:
> + cf->data[2] |= CAN_ERR_PROT_BIT;
> + break;
> + case SJA1000_ECC_FORM:
> + cf->data[2] |= CAN_ERR_PROT_FORM;
> + break;
> + case SJA1000_ECC_STUFF:
> + cf->data[2] |= CAN_ERR_PROT_STUFF;
> + break;
> + default:
> + cf->data[3] = ecc & SJA1000_ECC_SEG;
> + break;
> + }
> +
> + /* Error occurred during transmission? */
> + if ((ecc & SJA1000_ECC_DIR) == 0)
> + cf->data[2] |= CAN_ERR_PROT_TX;
> +
> + if (dev->can.state == CAN_STATE_ERROR_WARNING ||
> + dev->can.state == CAN_STATE_ERROR_PASSIVE) {
> + cf->can_id |= CAN_ERR_CRTL;
> + cf->data[1] = (txerr > rxerr) ?
> + CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE;
> + }
> }
> } else if (msg->type == CPC_MSG_TYPE_OVERRUN) {
> cf->can_id |= CAN_ERR_CRTL;
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-11-06 18:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 17:01 [PATCH 00/17] Add support for CPC-USB/FD CAN FD interface Gerhard Uttenthaler
2020-11-06 17:01 ` [PATCH 01/17] can: ems_usb: Fixed warnings given by checkpatch.pl and fixed some outdated comments Gerhard Uttenthaler
2020-11-06 17:04 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 02/17] can: ems_usb: Added defines and product id needed for CPC-USB/FD Gerhard Uttenthaler
2020-11-06 17:01 ` [PATCH 03/17] can: ems_usb: Added CAN FD message representation Gerhard Uttenthaler
2020-11-06 17:08 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 04/17] can: ems_usb: Added struct used for CAN FD initialization Gerhard Uttenthaler
2020-11-06 17:07 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 05/17] can: ems_usb: Replace constant define RX_BUFFER_SIZE by variable bulk_rd_buf_size, because this will have different values for CPC-USB/ARM7 and CPC-USB/FD. For the same reason added a function pointer ems_usb_write_mode. In device probe function added a switch statement to select between CPC-USB/ARM7 and CPC-USB/FD and rearranged initialization sequence accordingly Gerhard Uttenthaler
2020-11-06 17:15 ` Marc Kleine-Budde
2020-11-10 10:31 ` Gerhard Uttenthaler
2020-11-10 10:57 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 06/17] can: ems_usb: Added listen only mode for CPC-USB/ARM7 and moved evaluation of can.ctrlmode from set_bittiming routine to ems_usb_write_mode_arm7 routine. Wrapped a long line Gerhard Uttenthaler
2020-11-06 17:23 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 07/17] can: ems_usb: Added CPC_ClearCmdQueue routine to get access to the interface even it is flooded with messages which cannot successfully be sent. Set timestamp to 0 in ems_usb_control_cmd Gerhard Uttenthaler
2020-11-06 17:25 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 08/17] can: ems_usb: Modified ems_usb_read_bulk_callback to be able to handle also CPC-USB/FD Gerhard Uttenthaler
2020-11-06 17:32 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 09/17] can: ems_usb: For CPC-USB/FD added clock definitions, bittiming constants, set_bittiming functions, bittiming init function and add all that to probe function Gerhard Uttenthaler
2020-11-06 17:51 ` Marc Kleine-Budde
2020-11-11 10:22 ` Gerhard Uttenthaler
2020-11-11 11:28 ` Marc Kleine-Budde
2020-11-06 17:01 ` [PATCH 10/17] can: ems_usb: Added receive routine for CAN FD messages and its call in ems_usb_read_bulk_callback Gerhard Uttenthaler
2020-11-06 17:33 ` Marc Kleine-Budde
2020-11-06 17:43 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 11/17] can: ems_usb: Added ems_usb_write_mode_fd and its call in device probe routine. Fixed indentation Gerhard Uttenthaler
2020-11-06 17:35 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 12/17] can: ems_usb: In ems_usb_start_xmit send only bytes with valid content to interface and not the complete buffer. Set first four bytes of buffer to 0. Wrapped long lines Gerhard Uttenthaler
2020-11-06 17:58 ` Marc Kleine-Budde
2020-11-12 8:31 ` Gerhard Uttenthaler
2020-11-12 8:35 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 13/17] can: ems_usb: Rearrange code in ems_usb_start_xmit to check with can_is_canfd_skb for CAN FD frames Gerhard Uttenthaler
2020-11-06 18:01 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 14/17] can: ems_usb: Added code to handle CAN FD frames in ems_usb_start_xmit Gerhard Uttenthaler
2020-11-06 17:56 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 15/17] can: ems_usb: In CAN error handling routine checking which CAN controller type is issuing the error Gerhard Uttenthaler
2020-11-06 18:01 ` Marc Kleine-Budde [this message]
2020-11-06 17:02 ` [PATCH 16/17] can: ems_usb: Added error handling part for CPC-USB/FD. Get some structures packed Gerhard Uttenthaler
2020-11-06 18:05 ` Marc Kleine-Budde
2020-11-06 17:02 ` [PATCH 17/17] can: ems_usb: Made another struct packed. Enable CPC-USB/FD by adding it to the drivers device table Gerhard Uttenthaler
2020-11-06 18:05 ` Marc Kleine-Budde
2020-11-06 18:07 ` [PATCH 00/17] Add support for CPC-USB/FD CAN FD interface Marc Kleine-Budde
2020-11-06 19:04 ` Gerhard Uttenthaler
2020-11-06 19:59 ` Marc Kleine-Budde
2020-12-08 17:13 ` Gerhard Uttenthaler
2020-11-06 18:15 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d84c8bd0-1f27-6737-bffc-40413c29d3e9@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=uttenthaler@ems-wuensche.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).