All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
@ 2014-07-09 19:31 Nikita Edward Baruzdin
  2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-09 19:31 UTC (permalink / raw)
  To: linux-can

This adds support for hardware loopback in SJA1000 by utilising its self
reception request (SRR) feature. Upon SRR the message is transmitted and
received simultaneously, meaning you can't have hardware loopback
without actually sending a message to the CAN bus in case of SJA1000.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 drivers/net/can/sja1000/sja1000.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index f31499a..c480bce 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -278,6 +278,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
 	uint8_t dlc;
 	canid_t id;
 	uint8_t dreg;
+	u8 cmd_reg_val = 0x00;
 	int i;
 
 	if (can_dropped_invalid_skb(dev, skb))
@@ -312,9 +313,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
 	can_put_echo_skb(skb, dev, 0);
 
 	if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
-		sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
+		cmd_reg_val |= CMD_AT;
+
+	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
+		cmd_reg_val |= CMD_SRR;
 	else
-		sja1000_write_cmdreg(priv, CMD_TR);
+		cmd_reg_val |= CMD_TR;
+
+	sja1000_write_cmdreg(priv, cmd_reg_val);
 
 	return NETDEV_TX_OK;
 }
@@ -622,9 +628,11 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
 	priv->can.do_set_bittiming = sja1000_set_bittiming;
 	priv->can.do_set_mode = sja1000_set_mode;
 	priv->can.do_get_berr_counter = sja1000_get_berr_counter;
-	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
-		CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY |
-		CAN_CTRLMODE_ONE_SHOT;
+	priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK
+				     | CAN_CTRLMODE_LISTENONLY
+				     | CAN_CTRLMODE_3_SAMPLES
+				     | CAN_CTRLMODE_ONE_SHOT
+				     | CAN_CTRLMODE_BERR_REPORTING;
 
 	spin_lock_init(&priv->cmdreg_lock);
 
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] can: netlink: Remove space before tab
  2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
@ 2014-07-09 19:31 ` Nikita Edward Baruzdin
  2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-09 19:31 UTC (permalink / raw)
  To: linux-can

Fixes the corresponing checkpatch.pl warning.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 include/uapi/linux/can/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 813d11f..3bbf5c7 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -92,7 +92,7 @@ struct can_ctrlmode {
 };
 
 #define CAN_CTRLMODE_LOOPBACK		0x01	/* Loopback mode */
-#define CAN_CTRLMODE_LISTENONLY		0x02 	/* Listen-only mode */
+#define CAN_CTRLMODE_LISTENONLY		0x02	/* Listen-only mode */
 #define CAN_CTRLMODE_3_SAMPLES		0x04	/* Triple sampling mode */
 #define CAN_CTRLMODE_ONE_SHOT		0x08	/* One-Shot mode */
 #define CAN_CTRLMODE_BERR_REPORTING	0x10	/* Bus-error reporting */
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
  2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
@ 2014-07-09 19:31 ` Nikita Edward Baruzdin
  2014-07-10 14:06   ` Oliver Hartkopp
  2014-07-09 19:31 ` [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
  2014-07-10 14:25 ` [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
  3 siblings, 1 reply; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-09 19:31 UTC (permalink / raw)
  To: linux-can

Most CAN controllers have a support for ignoring ACK absence. Some of
them refer to this feature as a self test mode (e. g. SJA1000) and some
include it as a part of a loopback mode (e. g. MCP2510).

Setting the introduced flag via netlink should make CAN controller
perform a successful transmission, even if there is no acknowledgement
(dominant ACK bit) received.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 include/uapi/linux/can/netlink.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 3bbf5c7..3e4323a 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -97,6 +97,7 @@ struct can_ctrlmode {
 #define CAN_CTRLMODE_ONE_SHOT		0x08	/* One-Shot mode */
 #define CAN_CTRLMODE_BERR_REPORTING	0x10	/* Bus-error reporting */
 #define CAN_CTRLMODE_FD			0x20	/* CAN FD mode */
+#define CAN_CTRLMODE_PRESUME_ACK	0x40	/* Ignore missing CAN ACKs */
 
 /*
  * CAN device statistics
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK
  2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
  2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
  2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
@ 2014-07-09 19:31 ` Nikita Edward Baruzdin
  2014-07-10 14:25 ` [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
  3 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-09 19:31 UTC (permalink / raw)
  To: linux-can

SJA1000 has a self test mode (STM) which does not require
acknowledgement for the successful message transmission. In this mode a
node test is possible without any other active node on the bus.

This patch adds a possibility to set STM for SJA1000 controller through
specifying the corresponding CAN_CTRLMODE_PRESUME_ACK netlink flag.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 drivers/net/can/sja1000/sja1000.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index c480bce..fd6ee05 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev)
 {
 	struct sja1000_priv *priv = netdev_priv(dev);
 	unsigned char status = priv->read_reg(priv, SJA1000_MOD);
+	u8 mod_reg_val = 0x00;
 	int i;
 
 	for (i = 0; i < 100; i++) {
@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev)
 
 		/* set chip to normal mode */
 		if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
-			priv->write_reg(priv, SJA1000_MOD, MOD_LOM);
-		else
-			priv->write_reg(priv, SJA1000_MOD, 0x00);
+			mod_reg_val |= MOD_LOM;
+		if (priv->can.ctrlmode & CAN_CTRLMODE_PRESUME_ACK)
+			mod_reg_val |= MOD_STM;
+		priv->write_reg(priv, SJA1000_MOD, mod_reg_val);
 
 		udelay(10);
 
@@ -632,7 +634,8 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
 				     | CAN_CTRLMODE_LISTENONLY
 				     | CAN_CTRLMODE_3_SAMPLES
 				     | CAN_CTRLMODE_ONE_SHOT
-				     | CAN_CTRLMODE_BERR_REPORTING;
+				     | CAN_CTRLMODE_BERR_REPORTING
+				     | CAN_CTRLMODE_PRESUME_ACK;
 
 	spin_lock_init(&priv->cmdreg_lock);
 
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
@ 2014-07-10 14:06   ` Oliver Hartkopp
  2014-07-10 14:12     ` Marc Kleine-Budde
  2014-07-14 12:21     ` Marc Kleine-Budde
  0 siblings, 2 replies; 17+ messages in thread
From: Oliver Hartkopp @ 2014-07-10 14:06 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg; +Cc: Nikita Edward Baruzdin, linux-can

Hello Marc and Wolfgang,

what do you think about this extension.

 From my side the patchset makes sense.

Regards,
Oliver

On 09.07.2014 15:31, Nikita Edward Baruzdin wrote:
> Most CAN controllers have a support for ignoring ACK absence. Some of
> them refer to this feature as a self test mode (e. g. SJA1000) and some
> include it as a part of a loopback mode (e. g. MCP2510).
>
> Setting the introduced flag via netlink should make CAN controller
> perform a successful transmission, even if there is no acknowledgement
> (dominant ACK bit) received.
>
> Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
> ---
>   include/uapi/linux/can/netlink.h | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
> index 3bbf5c7..3e4323a 100644
> --- a/include/uapi/linux/can/netlink.h
> +++ b/include/uapi/linux/can/netlink.h
> @@ -97,6 +97,7 @@ struct can_ctrlmode {
>   #define CAN_CTRLMODE_ONE_SHOT		0x08	/* One-Shot mode */
>   #define CAN_CTRLMODE_BERR_REPORTING	0x10	/* Bus-error reporting */
>   #define CAN_CTRLMODE_FD			0x20	/* CAN FD mode */
> +#define CAN_CTRLMODE_PRESUME_ACK	0x40	/* Ignore missing CAN ACKs */
>
>   /*
>    * CAN device statistics
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-10 14:06   ` Oliver Hartkopp
@ 2014-07-10 14:12     ` Marc Kleine-Budde
  2014-07-11 13:18       ` Oliver Hartkopp
  2014-07-14 12:21     ` Marc Kleine-Budde
  1 sibling, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2014-07-10 14:12 UTC (permalink / raw)
  To: Oliver Hartkopp, wg; +Cc: Nikita Edward Baruzdin, linux-can

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

On 07/10/2014 04:06 PM, Oliver Hartkopp wrote:
> what do you think about this extension.
> 
> From my side the patchset makes sense.
>> +#define CAN_CTRLMODE_PRESUME_ACK    0x40    /* Ignore missing CAN
>> ACKs */

Is this a good name? Does anyone come up with an alternative/better one?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
  2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
                   ` (2 preceding siblings ...)
  2014-07-09 19:31 ` [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
@ 2014-07-10 14:25 ` Marc Kleine-Budde
  2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
  3 siblings, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2014-07-10 14:25 UTC (permalink / raw)
  To: Nikita Edward Baruzdin, linux-can

[-- Attachment #1: Type: text/plain, Size: 2537 bytes --]

On 07/09/2014 09:31 PM, Nikita Edward Baruzdin wrote:
> This adds support for hardware loopback in SJA1000 by utilising its self
> reception request (SRR) feature. Upon SRR the message is transmitted and
> received simultaneously, meaning you can't have hardware loopback
> without actually sending a message to the CAN bus in case of SJA1000.
> 
> Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>

Looks good, coding style nitpick inline...

> ---
>  drivers/net/can/sja1000/sja1000.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
> index f31499a..c480bce 100644
> --- a/drivers/net/can/sja1000/sja1000.c
> +++ b/drivers/net/can/sja1000/sja1000.c
> @@ -278,6 +278,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
>  	uint8_t dlc;
>  	canid_t id;
>  	uint8_t dreg;
> +	u8 cmd_reg_val = 0x00;
>  	int i;
>  
>  	if (can_dropped_invalid_skb(dev, skb))
> @@ -312,9 +313,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
>  	can_put_echo_skb(skb, dev, 0);
>  
>  	if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
> -		sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
> +		cmd_reg_val |= CMD_AT;
> +
> +	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
> +		cmd_reg_val |= CMD_SRR;
>  	else
> -		sja1000_write_cmdreg(priv, CMD_TR);
> +		cmd_reg_val |= CMD_TR;
> +
> +	sja1000_write_cmdreg(priv, cmd_reg_val);
>  
>  	return NETDEV_TX_OK;
>  }
> @@ -622,9 +628,11 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
>  	priv->can.do_set_bittiming = sja1000_set_bittiming;
>  	priv->can.do_set_mode = sja1000_set_mode;
>  	priv->can.do_get_berr_counter = sja1000_get_berr_counter;
> -	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
> -		CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY |
> -		CAN_CTRLMODE_ONE_SHOT;
> +	priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK
> +				     | CAN_CTRLMODE_LISTENONLY
> +				     | CAN_CTRLMODE_3_SAMPLES
> +				     | CAN_CTRLMODE_ONE_SHOT
> +				     | CAN_CTRLMODE_BERR_REPORTING;

Please keep the '|' at the end of the lines.

>  
>  	spin_lock_init(&priv->cmdreg_lock);
>  
> 

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
  2014-07-10 14:25 ` [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
@ 2014-07-11 12:13   ` Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
                       ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-11 12:13 UTC (permalink / raw)
  To: linux-can

This adds support for hardware loopback in SJA1000 by utilising its self
reception request (SRR) feature. Upon SRR the message is transmitted and
received simultaneously, meaning you can't have hardware loopback
without actually sending a message to the CAN bus in case of SJA1000.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 drivers/net/can/sja1000/sja1000.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index f31499a..45400d9 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -278,6 +278,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
 	uint8_t dlc;
 	canid_t id;
 	uint8_t dreg;
+	u8 cmd_reg_val = 0x00;
 	int i;
 
 	if (can_dropped_invalid_skb(dev, skb))
@@ -312,9 +313,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
 	can_put_echo_skb(skb, dev, 0);
 
 	if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
-		sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
+		cmd_reg_val |= CMD_AT;
+
+	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
+		cmd_reg_val |= CMD_SRR;
 	else
-		sja1000_write_cmdreg(priv, CMD_TR);
+		cmd_reg_val |= CMD_TR;
+
+	sja1000_write_cmdreg(priv, cmd_reg_val);
 
 	return NETDEV_TX_OK;
 }
@@ -622,9 +628,11 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
 	priv->can.do_set_bittiming = sja1000_set_bittiming;
 	priv->can.do_set_mode = sja1000_set_mode;
 	priv->can.do_get_berr_counter = sja1000_get_berr_counter;
-	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
-		CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY |
-		CAN_CTRLMODE_ONE_SHOT;
+	priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
+				       CAN_CTRLMODE_LISTENONLY |
+				       CAN_CTRLMODE_3_SAMPLES |
+				       CAN_CTRLMODE_ONE_SHOT |
+				       CAN_CTRLMODE_BERR_REPORTING;
 
 	spin_lock_init(&priv->cmdreg_lock);
 
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/4] can: netlink: Remove space before tab
  2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
@ 2014-07-11 12:13     ` Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-11 12:13 UTC (permalink / raw)
  To: linux-can

Fixes the corresponing checkpatch.pl warning.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 include/uapi/linux/can/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 813d11f..3bbf5c7 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -92,7 +92,7 @@ struct can_ctrlmode {
 };
 
 #define CAN_CTRLMODE_LOOPBACK		0x01	/* Loopback mode */
-#define CAN_CTRLMODE_LISTENONLY		0x02 	/* Listen-only mode */
+#define CAN_CTRLMODE_LISTENONLY		0x02	/* Listen-only mode */
 #define CAN_CTRLMODE_3_SAMPLES		0x04	/* Triple sampling mode */
 #define CAN_CTRLMODE_ONE_SHOT		0x08	/* One-Shot mode */
 #define CAN_CTRLMODE_BERR_REPORTING	0x10	/* Bus-error reporting */
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
@ 2014-07-11 12:13     ` Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
  2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
  3 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-11 12:13 UTC (permalink / raw)
  To: linux-can

Most CAN controllers have a support for ignoring ACK absence. Some of
them refer to this feature as a self test mode (e. g. SJA1000) and some
include it as a part of a loopback mode (e. g. MCP2510).

Setting the introduced flag via netlink should make CAN controller
perform a successful transmission, even if there is no acknowledgement
(dominant ACK bit) received.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 include/uapi/linux/can/netlink.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 3bbf5c7..3e4323a 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -97,6 +97,7 @@ struct can_ctrlmode {
 #define CAN_CTRLMODE_ONE_SHOT		0x08	/* One-Shot mode */
 #define CAN_CTRLMODE_BERR_REPORTING	0x10	/* Bus-error reporting */
 #define CAN_CTRLMODE_FD			0x20	/* CAN FD mode */
+#define CAN_CTRLMODE_PRESUME_ACK	0x40	/* Ignore missing CAN ACKs */
 
 /*
  * CAN device statistics
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK
  2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
  2014-07-11 12:13     ` [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
@ 2014-07-11 12:13     ` Nikita Edward Baruzdin
  2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
  3 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-11 12:13 UTC (permalink / raw)
  To: linux-can

SJA1000 has a self test mode (STM) which does not require
acknowledgement for the successful message transmission. In this mode a
node test is possible without any other active node on the bus.

This patch adds a possibility to set STM for SJA1000 controller through
specifying the corresponding CAN_CTRLMODE_PRESUME_ACK netlink flag.

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
---
 drivers/net/can/sja1000/sja1000.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 45400d9..d169215 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev)
 {
 	struct sja1000_priv *priv = netdev_priv(dev);
 	unsigned char status = priv->read_reg(priv, SJA1000_MOD);
+	u8 mod_reg_val = 0x00;
 	int i;
 
 	for (i = 0; i < 100; i++) {
@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev)
 
 		/* set chip to normal mode */
 		if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
-			priv->write_reg(priv, SJA1000_MOD, MOD_LOM);
-		else
-			priv->write_reg(priv, SJA1000_MOD, 0x00);
+			mod_reg_val |= MOD_LOM;
+		if (priv->can.ctrlmode & CAN_CTRLMODE_PRESUME_ACK)
+			mod_reg_val |= MOD_STM;
+		priv->write_reg(priv, SJA1000_MOD, mod_reg_val);
 
 		udelay(10);
 
@@ -632,7 +634,8 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
 				       CAN_CTRLMODE_LISTENONLY |
 				       CAN_CTRLMODE_3_SAMPLES |
 				       CAN_CTRLMODE_ONE_SHOT |
-				       CAN_CTRLMODE_BERR_REPORTING;
+				       CAN_CTRLMODE_BERR_REPORTING |
+				       CAN_CTRLMODE_PRESUME_ACK;
 
 	spin_lock_init(&priv->cmdreg_lock);
 
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-10 14:12     ` Marc Kleine-Budde
@ 2014-07-11 13:18       ` Oliver Hartkopp
  2014-07-11 14:42         ` Nikita Edward Baruzdin
  0 siblings, 1 reply; 17+ messages in thread
From: Oliver Hartkopp @ 2014-07-11 13:18 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg; +Cc: Nikita Edward Baruzdin, linux-can

I tried to find a short name for:

- do not wait for ack
- ignore missing ack
- broadcast that doesn't require an ack
- ...

I'm really open for an alternative ;-)

On 10.07.2014 10:12, Marc Kleine-Budde wrote:
> On 07/10/2014 04:06 PM, Oliver Hartkopp wrote:
>> what do you think about this extension.
>>
>>  From my side the patchset makes sense.
>>> +#define CAN_CTRLMODE_PRESUME_ACK    0x40    /* Ignore missing CAN
>>> ACKs */
>
> Is this a good name? Does anyone come up with an alternative/better one?
>
> Marc
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-11 13:18       ` Oliver Hartkopp
@ 2014-07-11 14:42         ` Nikita Edward Baruzdin
  0 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-11 14:42 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: Marc Kleine-Budde, wg, linux-can

I actually think the word "PRESUME" is good enough. We could also use
"NOT_REQUIRE" instead: it's a bit more explicit, but a bit longer.
At least I couldn't think of anything better.

"NOT_WAIT" doesn't reflect the behaviour precisely in my view.
I also believe that the word "IGNORE" is better when it comes to some
"active" message (that supposes some reaction), like "IGNORE_ERRORS" or
"IGNORE_SERVICE_REQUEST". And ACK is more of a reply than a request for
action.

On Fri, 2014-07-11 at 09:18 -0400, Oliver Hartkopp wrote:
> I tried to find a short name for:
> 
> - do not wait for ack
> - ignore missing ack
> - broadcast that doesn't require an ack
> - ...
> 
> I'm really open for an alternative ;-)
> 
> On 10.07.2014 10:12, Marc Kleine-Budde wrote:
> > On 07/10/2014 04:06 PM, Oliver Hartkopp wrote:
> >> what do you think about this extension.
> >>
> >>  From my side the patchset makes sense.
> >>> +#define CAN_CTRLMODE_PRESUME_ACK    0x40    /* Ignore missing CAN
> >>> ACKs */
> >
> > Is this a good name? Does anyone come up with an alternative/better one?
> >
> > Marc
> >



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-10 14:06   ` Oliver Hartkopp
  2014-07-10 14:12     ` Marc Kleine-Budde
@ 2014-07-14 12:21     ` Marc Kleine-Budde
  2014-07-15  1:32       ` Oliver Hartkopp
  1 sibling, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2014-07-14 12:21 UTC (permalink / raw)
  To: Oliver Hartkopp, wg; +Cc: Nikita Edward Baruzdin, linux-can

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

On 07/10/2014 04:06 PM, Oliver Hartkopp wrote:
> Hello Marc and Wolfgang,
> 
> what do you think about this extension.
> 
> From my side the patchset makes sense.

Is this an Acked-by?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag
  2014-07-14 12:21     ` Marc Kleine-Budde
@ 2014-07-15  1:32       ` Oliver Hartkopp
  0 siblings, 0 replies; 17+ messages in thread
From: Oliver Hartkopp @ 2014-07-15  1:32 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg; +Cc: Nikita Edward Baruzdin, linux-can

Yes.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Just wanted to know if it's ok for you too.

Tnx,
Oliver

On 14.07.2014 08:21, Marc Kleine-Budde wrote:
> On 07/10/2014 04:06 PM, Oliver Hartkopp wrote:
>> Hello Marc and Wolfgang,
>>
>> what do you think about this extension.
>>
>>  From my side the patchset makes sense.
>
> Is this an Acked-by?
>
> Marc
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
  2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
                       ` (2 preceding siblings ...)
  2014-07-11 12:13     ` [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
@ 2014-07-15  7:35     ` Marc Kleine-Budde
  2014-07-15  8:44       ` Nikita Edward Baruzdin
  3 siblings, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2014-07-15  7:35 UTC (permalink / raw)
  To: Nikita Edward Baruzdin, linux-can

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

On 07/11/2014 02:13 PM, Nikita Edward Baruzdin wrote:
> This adds support for hardware loopback in SJA1000 by utilising its self
> reception request (SRR) feature. Upon SRR the message is transmitted and
> received simultaneously, meaning you can't have hardware loopback
> without actually sending a message to the CAN bus in case of SJA1000.
> 
> Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>

Thanks, applied to can-next. Do you care to provide patches for ip and
libsocketcan, too?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
  2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
@ 2014-07-15  8:44       ` Nikita Edward Baruzdin
  0 siblings, 0 replies; 17+ messages in thread
From: Nikita Edward Baruzdin @ 2014-07-15  8:44 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can

On Tue, 2014-07-15 at 09:35 +0200, Marc Kleine-Budde wrote:
> Thanks, applied to can-next. Do you care to provide patches for ip and
> libsocketcan, too?

Thank you. Yes, I'm going to a bit later.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-07-15  8:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 19:31 [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Nikita Edward Baruzdin
2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-10 14:06   ` Oliver Hartkopp
2014-07-10 14:12     ` Marc Kleine-Budde
2014-07-11 13:18       ` Oliver Hartkopp
2014-07-11 14:42         ` Nikita Edward Baruzdin
2014-07-14 12:21     ` Marc Kleine-Budde
2014-07-15  1:32       ` Oliver Hartkopp
2014-07-09 19:31 ` [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-10 14:25 ` [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
2014-07-15  8:44       ` Nikita Edward Baruzdin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.