linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: c_can: rename IF_RX -> IF_NAPI
@ 2021-08-09  8:06 Marc Kleine-Budde
  2021-08-10  5:34 ` Dario Binacchi
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2021-08-09  8:06 UTC (permalink / raw)
  To: linux-can; +Cc: Marc Kleine-Budde, Dario Binacchi

The C_CAN/D_CAN cores implement 2 interfaces to manage the message
objects. To avoid concurrency and the need for locking one interface
is used in the TX path (IF_TX). While the other one, named IF_RX is
used from NAPI context only. As this interface is not only used to
manage RX, but also TX message objects, this patch renames IF_RX to
IF_NAPI.

Cc: Dario Binacchi <dariobin@libero.it>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hey Dario,

as promised a patch to rename IF_RX -> IF_NAPI.

In my current patch stack, I've added this patch before your FIFO
changes (and updated your patch accordingly), to avoid changing the
newly added IF_RX in your patch to IF_NAPI in the next patch.

regards,
Marc

 drivers/net/can/c_can/c_can_main.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/c_can/c_can_main.c b/drivers/net/can/c_can/c_can_main.c
index e65bd7a9cf1d..a3c2d9ec90f9 100644
--- a/drivers/net/can/c_can/c_can_main.c
+++ b/drivers/net/can/c_can/c_can_main.c
@@ -161,7 +161,7 @@
 #define IF_MCONT_TX		(IF_MCONT_TXIE | IF_MCONT_EOB)
 
 /* Use IF1 for RX and IF2 for TX */
-#define IF_RX			0
+#define IF_NAPI			0
 #define IF_TX			1
 
 /* minimum timeout for checking BUSY status */
@@ -529,13 +529,13 @@ static void c_can_configure_msg_objects(struct net_device *dev)
 
 	/* first invalidate all message objects */
 	for (i = priv->msg_obj_rx_first; i <= priv->msg_obj_num; i++)
-		c_can_inval_msg_object(dev, IF_RX, i);
+		c_can_inval_msg_object(dev, IF_NAPI, i);
 
 	/* setup receive message objects */
 	for (i = priv->msg_obj_rx_first; i < priv->msg_obj_rx_last; i++)
-		c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
+		c_can_setup_receive_object(dev, IF_NAPI, i, 0, 0, IF_MCONT_RCV);
 
-	c_can_setup_receive_object(dev, IF_RX, priv->msg_obj_rx_last, 0, 0,
+	c_can_setup_receive_object(dev, IF_NAPI, priv->msg_obj_rx_last, 0, 0,
 				   IF_MCONT_RCV_EOB);
 }
 
@@ -710,11 +710,11 @@ static void c_can_do_tx(struct net_device *dev)
 		pend &= ~BIT(idx);
 		obj = idx + priv->msg_obj_tx_first;
 
-		/* We use IF_RX interface instead of IF_TX because we
+		/* We use IF_NAPI interface instead of IF_TX because we
 		 * are called from c_can_poll(), which runs inside
 		 * NAPI. We are not transmitting.
 		 */
-		c_can_inval_tx_object(dev, IF_RX, obj);
+		c_can_inval_tx_object(dev, IF_NAPI, obj);
 		can_get_echo_skb(dev, idx, NULL);
 		bytes += priv->dlc[idx];
 		pkts++;
@@ -766,14 +766,14 @@ static u32 c_can_adjust_pending(u32 pend, u32 rx_mask)
 static inline void c_can_rx_object_get(struct net_device *dev,
 				       struct c_can_priv *priv, u32 obj)
 {
-	c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high);
+	c_can_object_get(dev, IF_NAPI, obj, priv->comm_rcv_high);
 }
 
 static inline void c_can_rx_finalize(struct net_device *dev,
 				     struct c_can_priv *priv, u32 obj)
 {
 	if (priv->type != BOSCH_D_CAN)
-		c_can_object_get(dev, IF_RX, obj, IF_COMM_CLR_NEWDAT);
+		c_can_object_get(dev, IF_NAPI, obj, IF_COMM_CLR_NEWDAT);
 }
 
 static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
@@ -785,10 +785,12 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
 		pend &= ~BIT(obj - 1);
 
 		c_can_rx_object_get(dev, priv, obj);
-		ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_RX));
+		ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_NAPI));
 
 		if (ctrl & IF_MCONT_MSGLST) {
-			int n = c_can_handle_lost_msg_obj(dev, IF_RX, obj, ctrl);
+			int n;
+
+			n = c_can_handle_lost_msg_obj(dev, IF_NAPI, obj, ctrl);
 
 			pkts += n;
 			quota -= n;
@@ -803,7 +805,7 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
 			continue;
 
 		/* read the data from the message object */
-		c_can_read_msg_object(dev, IF_RX, ctrl);
+		c_can_read_msg_object(dev, IF_NAPI, ctrl);
 
 		c_can_rx_finalize(dev, priv, obj);
 
-- 
2.30.2



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

* Re: [PATCH] can: c_can: rename IF_RX -> IF_NAPI
  2021-08-09  8:06 [PATCH] can: c_can: rename IF_RX -> IF_NAPI Marc Kleine-Budde
@ 2021-08-10  5:34 ` Dario Binacchi
  0 siblings, 0 replies; 2+ messages in thread
From: Dario Binacchi @ 2021-08-10  5:34 UTC (permalink / raw)
  To: Marc Kleine-Budde, linux-can

Hi Marc,

> Il 09/08/2021 10:06 Marc Kleine-Budde <mkl@pengutronix.de> ha scritto:
> 
>  
> The C_CAN/D_CAN cores implement 2 interfaces to manage the message
> objects. To avoid concurrency and the need for locking one interface
> is used in the TX path (IF_TX). While the other one, named IF_RX is
> used from NAPI context only. As this interface is not only used to
> manage RX, but also TX message objects, this patch renames IF_RX to
> IF_NAPI.
> 
> Cc: Dario Binacchi <dariobin@libero.it>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> Hey Dario,
> 
> as promised a patch to rename IF_RX -> IF_NAPI.
>

I agree with you. It's the right choice.
Thanks and regards,
Dario
 
> In my current patch stack, I've added this patch before your FIFO
> changes (and updated your patch accordingly), to avoid changing the
> newly added IF_RX in your patch to IF_NAPI in the next patch.
> 
> regards,
> Marc
> 
>  drivers/net/can/c_can/c_can_main.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/can/c_can/c_can_main.c b/drivers/net/can/c_can/c_can_main.c
> index e65bd7a9cf1d..a3c2d9ec90f9 100644
> --- a/drivers/net/can/c_can/c_can_main.c
> +++ b/drivers/net/can/c_can/c_can_main.c
> @@ -161,7 +161,7 @@
>  #define IF_MCONT_TX		(IF_MCONT_TXIE | IF_MCONT_EOB)
>  
>  /* Use IF1 for RX and IF2 for TX */
> -#define IF_RX			0
> +#define IF_NAPI			0
>  #define IF_TX			1
>  
>  /* minimum timeout for checking BUSY status */
> @@ -529,13 +529,13 @@ static void c_can_configure_msg_objects(struct net_device *dev)
>  
>  	/* first invalidate all message objects */
>  	for (i = priv->msg_obj_rx_first; i <= priv->msg_obj_num; i++)
> -		c_can_inval_msg_object(dev, IF_RX, i);
> +		c_can_inval_msg_object(dev, IF_NAPI, i);
>  
>  	/* setup receive message objects */
>  	for (i = priv->msg_obj_rx_first; i < priv->msg_obj_rx_last; i++)
> -		c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
> +		c_can_setup_receive_object(dev, IF_NAPI, i, 0, 0, IF_MCONT_RCV);
>  
> -	c_can_setup_receive_object(dev, IF_RX, priv->msg_obj_rx_last, 0, 0,
> +	c_can_setup_receive_object(dev, IF_NAPI, priv->msg_obj_rx_last, 0, 0,
>  				   IF_MCONT_RCV_EOB);
>  }
>  
> @@ -710,11 +710,11 @@ static void c_can_do_tx(struct net_device *dev)
>  		pend &= ~BIT(idx);
>  		obj = idx + priv->msg_obj_tx_first;
>  
> -		/* We use IF_RX interface instead of IF_TX because we
> +		/* We use IF_NAPI interface instead of IF_TX because we
>  		 * are called from c_can_poll(), which runs inside
>  		 * NAPI. We are not transmitting.
>  		 */
> -		c_can_inval_tx_object(dev, IF_RX, obj);
> +		c_can_inval_tx_object(dev, IF_NAPI, obj);
>  		can_get_echo_skb(dev, idx, NULL);
>  		bytes += priv->dlc[idx];
>  		pkts++;
> @@ -766,14 +766,14 @@ static u32 c_can_adjust_pending(u32 pend, u32 rx_mask)
>  static inline void c_can_rx_object_get(struct net_device *dev,
>  				       struct c_can_priv *priv, u32 obj)
>  {
> -	c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high);
> +	c_can_object_get(dev, IF_NAPI, obj, priv->comm_rcv_high);
>  }
>  
>  static inline void c_can_rx_finalize(struct net_device *dev,
>  				     struct c_can_priv *priv, u32 obj)
>  {
>  	if (priv->type != BOSCH_D_CAN)
> -		c_can_object_get(dev, IF_RX, obj, IF_COMM_CLR_NEWDAT);
> +		c_can_object_get(dev, IF_NAPI, obj, IF_COMM_CLR_NEWDAT);
>  }
>  
>  static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
> @@ -785,10 +785,12 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
>  		pend &= ~BIT(obj - 1);
>  
>  		c_can_rx_object_get(dev, priv, obj);
> -		ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_RX));
> +		ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_NAPI));
>  
>  		if (ctrl & IF_MCONT_MSGLST) {
> -			int n = c_can_handle_lost_msg_obj(dev, IF_RX, obj, ctrl);
> +			int n;
> +
> +			n = c_can_handle_lost_msg_obj(dev, IF_NAPI, obj, ctrl);
>  
>  			pkts += n;
>  			quota -= n;
> @@ -803,7 +805,7 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
>  			continue;
>  
>  		/* read the data from the message object */
> -		c_can_read_msg_object(dev, IF_RX, ctrl);
> +		c_can_read_msg_object(dev, IF_NAPI, ctrl);
>  
>  		c_can_rx_finalize(dev, priv, obj);
>  
> -- 
> 2.30.2

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

end of thread, other threads:[~2021-08-10  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  8:06 [PATCH] can: c_can: rename IF_RX -> IF_NAPI Marc Kleine-Budde
2021-08-10  5:34 ` Dario Binacchi

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).