linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] net: macb: few code cleanups
@ 2020-07-02  9:05 Claudiu Beznea
  2020-07-02  9:05 ` [PATCH net-next v2 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Claudiu Beznea @ 2020-07-02  9:05 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Hi,

Patches in this series cleanup a bit macb code.

Thank you,
Claudiu Beznea

Changes in v2:
- in patch 2/4 use hweight32() instead of hweight_long() 

Claudiu Beznea (4):
  net: macb: do not set again bit 0 of queue_mask
  net: macb: use hweight32() to count set bits in queue_mask
  net: macb: do not initialize queue variable
  net: macb: remove is_udp variable

 drivers/net/ethernet/cadence/macb_main.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

-- 
2.7.4


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

* [PATCH net-next v2 1/4] net: macb: do not set again bit 0 of queue_mask
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
@ 2020-07-02  9:05 ` Claudiu Beznea
  2020-07-02  9:05 ` [PATCH net-next v2 2/4] net: macb: use hweight32() to count set bits in queue_mask Claudiu Beznea
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Claudiu Beznea @ 2020-07-02  9:05 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Bit 0 of queue_mask is set at the beginning of
macb_probe_queues() function. Do not set it again after reading
DGFG6 but instead use "|=" operator.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 52582e8ed90e..1bc2810f3dc4 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3497,9 +3497,7 @@ static void macb_probe_queues(void __iomem *mem,
 		return;
 
 	/* bit 0 is never set but queue 0 always exists */
-	*queue_mask = readl_relaxed(mem + GEM_DCFG6) & 0xff;
-
-	*queue_mask |= 0x1;
+	*queue_mask |= readl_relaxed(mem + GEM_DCFG6) & 0xff;
 
 	for (hw_q = 1; hw_q < MACB_MAX_QUEUES; ++hw_q)
 		if (*queue_mask & (1 << hw_q))
-- 
2.7.4


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

* [PATCH net-next v2 2/4] net: macb: use hweight32() to count set bits in queue_mask
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
  2020-07-02  9:05 ` [PATCH net-next v2 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
@ 2020-07-02  9:05 ` Claudiu Beznea
  2020-07-02  9:06 ` [PATCH net-next v2 3/4] net: macb: do not initialize queue variable Claudiu Beznea
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Claudiu Beznea @ 2020-07-02  9:05 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Use hweight32() to count set bits in queue_mask.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 1bc2810f3dc4..7668b6ae8822 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3482,8 +3482,6 @@ static void macb_probe_queues(void __iomem *mem,
 			      unsigned int *queue_mask,
 			      unsigned int *num_queues)
 {
-	unsigned int hw_q;
-
 	*queue_mask = 0x1;
 	*num_queues = 1;
 
@@ -3498,10 +3496,7 @@ static void macb_probe_queues(void __iomem *mem,
 
 	/* bit 0 is never set but queue 0 always exists */
 	*queue_mask |= readl_relaxed(mem + GEM_DCFG6) & 0xff;
-
-	for (hw_q = 1; hw_q < MACB_MAX_QUEUES; ++hw_q)
-		if (*queue_mask & (1 << hw_q))
-			(*num_queues)++;
+	*num_queues = hweight32(*queue_mask);
 }
 
 static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
-- 
2.7.4


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

* [PATCH net-next v2 3/4] net: macb: do not initialize queue variable
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
  2020-07-02  9:05 ` [PATCH net-next v2 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
  2020-07-02  9:05 ` [PATCH net-next v2 2/4] net: macb: use hweight32() to count set bits in queue_mask Claudiu Beznea
@ 2020-07-02  9:06 ` Claudiu Beznea
  2020-07-02  9:06 ` [PATCH net-next v2 4/4] net: macb: remove is_udp variable Claudiu Beznea
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Claudiu Beznea @ 2020-07-02  9:06 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Do not initialize queue variable. It is already initialized in for loops.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 7668b6ae8822..c31c15e99e3c 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1467,7 +1467,7 @@ static void macb_hresp_error_task(unsigned long data)
 {
 	struct macb *bp = (struct macb *)data;
 	struct net_device *dev = bp->dev;
-	struct macb_queue *queue = bp->queues;
+	struct macb_queue *queue;
 	unsigned int q;
 	u32 ctrl;
 
-- 
2.7.4


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

* [PATCH net-next v2 4/4] net: macb: remove is_udp variable
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
                   ` (2 preceding siblings ...)
  2020-07-02  9:06 ` [PATCH net-next v2 3/4] net: macb: do not initialize queue variable Claudiu Beznea
@ 2020-07-02  9:06 ` Claudiu Beznea
  2020-07-02 13:51 ` [PATCH net-next v2 0/4] net: macb: few code cleanups Nicolas Ferre
  2020-07-02 21:22 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Claudiu Beznea @ 2020-07-02  9:06 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Remove is_udp variable that is used in only one place and use
ip_hdr(skb)->protocol == IPPROTO_UDP check instead.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index c31c15e99e3c..6c99a519ab06 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1933,7 +1933,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	unsigned long flags;
 	unsigned int desc_cnt, nr_frags, frag_size, f;
 	unsigned int hdrlen;
-	bool is_lso, is_udp = 0;
+	bool is_lso;
 	netdev_tx_t ret = NETDEV_TX_OK;
 
 	if (macb_clear_csum(skb)) {
@@ -1949,10 +1949,8 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	is_lso = (skb_shinfo(skb)->gso_size != 0);
 
 	if (is_lso) {
-		is_udp = !!(ip_hdr(skb)->protocol == IPPROTO_UDP);
-
 		/* length of headers */
-		if (is_udp)
+		if (ip_hdr(skb)->protocol == IPPROTO_UDP)
 			/* only queue eth + ip headers separately for UDP */
 			hdrlen = skb_transport_offset(skb);
 		else
-- 
2.7.4


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

* Re: [PATCH net-next v2 0/4] net: macb: few code cleanups
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
                   ` (3 preceding siblings ...)
  2020-07-02  9:06 ` [PATCH net-next v2 4/4] net: macb: remove is_udp variable Claudiu Beznea
@ 2020-07-02 13:51 ` Nicolas Ferre
  2020-07-02 21:22 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Nicolas Ferre @ 2020-07-02 13:51 UTC (permalink / raw)
  To: Claudiu Beznea, davem, kuba; +Cc: netdev, linux-kernel

On 02/07/2020 at 11:05, Claudiu Beznea wrote:
> Hi,
> 
> Patches in this series cleanup a bit macb code.
> 
> Thank you,
> Claudiu Beznea
> 
> Changes in v2:
> - in patch 2/4 use hweight32() instead of hweight_long()
> 
> Claudiu Beznea (4):
>    net: macb: do not set again bit 0 of queue_mask
>    net: macb: use hweight32() to count set bits in queue_mask
>    net: macb: do not initialize queue variable
>    net: macb: remove is_udp variable
> 
>   drivers/net/ethernet/cadence/macb_main.c | 19 +++++--------------
>   1 file changed, 5 insertions(+), 14 deletions(-)

You can add my:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

For the whole series.

Best regards,
   Nicolas

-- 
Nicolas Ferre

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

* Re: [PATCH net-next v2 0/4] net: macb: few code cleanups
  2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
                   ` (4 preceding siblings ...)
  2020-07-02 13:51 ` [PATCH net-next v2 0/4] net: macb: few code cleanups Nicolas Ferre
@ 2020-07-02 21:22 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2020-07-02 21:22 UTC (permalink / raw)
  To: claudiu.beznea; +Cc: nicolas.ferre, kuba, netdev, linux-kernel

From: Claudiu Beznea <claudiu.beznea@microchip.com>
Date: Thu, 2 Jul 2020 12:05:57 +0300

> Patches in this series cleanup a bit macb code.
 ...

Series applied, thanks.

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

end of thread, other threads:[~2020-07-02 21:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02  9:05 [PATCH net-next v2 0/4] net: macb: few code cleanups Claudiu Beznea
2020-07-02  9:05 ` [PATCH net-next v2 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
2020-07-02  9:05 ` [PATCH net-next v2 2/4] net: macb: use hweight32() to count set bits in queue_mask Claudiu Beznea
2020-07-02  9:06 ` [PATCH net-next v2 3/4] net: macb: do not initialize queue variable Claudiu Beznea
2020-07-02  9:06 ` [PATCH net-next v2 4/4] net: macb: remove is_udp variable Claudiu Beznea
2020-07-02 13:51 ` [PATCH net-next v2 0/4] net: macb: few code cleanups Nicolas Ferre
2020-07-02 21:22 ` David Miller

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