Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net-next 0/4] net: macb: few code cleanups
@ 2020-07-01 13:08 Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Claudiu Beznea @ 2020-07-01 13:08 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

Claudiu Beznea (4):
  net: macb: do not set again bit 0 of queue_mask
  net: macb: use hweight_long() 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] 6+ messages in thread

* [PATCH net-next 1/4] net: macb: do not set again bit 0 of queue_mask
  2020-07-01 13:08 [PATCH net-next 0/4] net: macb: few code cleanups Claudiu Beznea
@ 2020-07-01 13:08 ` Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 2/4] net: macb: use hweight_long() to count set bits in queue_mask Claudiu Beznea
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2020-07-01 13:08 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	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/4] net: macb: use hweight_long() to count set bits in queue_mask
  2020-07-01 13:08 [PATCH net-next 0/4] net: macb: few code cleanups Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
@ 2020-07-01 13:08 ` Claudiu Beznea
  2020-07-01 19:22   ` David Miller
  2020-07-01 13:08 ` [PATCH net-next 3/4] net: macb: do not initialize queue variable Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 4/4] net: macb: remove is_udp variable Claudiu Beznea
  3 siblings, 1 reply; 6+ messages in thread
From: Claudiu Beznea @ 2020-07-01 13:08 UTC (permalink / raw)
  To: nicolas.ferre, davem, kuba; +Cc: netdev, linux-kernel, Claudiu Beznea

Use hweight_long() 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..a84fb0ec53f0 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 = hweight_long(*queue_mask);
 }
 
 static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
-- 
2.7.4


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

* [PATCH net-next 3/4] net: macb: do not initialize queue variable
  2020-07-01 13:08 [PATCH net-next 0/4] net: macb: few code cleanups Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 1/4] net: macb: do not set again bit 0 of queue_mask Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 2/4] net: macb: use hweight_long() to count set bits in queue_mask Claudiu Beznea
@ 2020-07-01 13:08 ` Claudiu Beznea
  2020-07-01 13:08 ` [PATCH net-next 4/4] net: macb: remove is_udp variable Claudiu Beznea
  3 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2020-07-01 13:08 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 a84fb0ec53f0..3603ab707e0f 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	[flat|nested] 6+ messages in thread

* [PATCH net-next 4/4] net: macb: remove is_udp variable
  2020-07-01 13:08 [PATCH net-next 0/4] net: macb: few code cleanups Claudiu Beznea
                   ` (2 preceding siblings ...)
  2020-07-01 13:08 ` [PATCH net-next 3/4] net: macb: do not initialize queue variable Claudiu Beznea
@ 2020-07-01 13:08 ` Claudiu Beznea
  3 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2020-07-01 13:08 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 3603ab707e0f..4e7317747f54 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	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/4] net: macb: use hweight_long() to count set bits in queue_mask
  2020-07-01 13:08 ` [PATCH net-next 2/4] net: macb: use hweight_long() to count set bits in queue_mask Claudiu Beznea
@ 2020-07-01 19:22   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-07-01 19:22 UTC (permalink / raw)
  To: claudiu.beznea; +Cc: nicolas.ferre, kuba, netdev, linux-kernel

From: Claudiu Beznea <claudiu.beznea@microchip.com>
Date: Wed, 1 Jul 2020 16:08:49 +0300

> @@ -3482,8 +3482,6 @@ static void macb_probe_queues(void __iomem *mem,
>  			      unsigned int *queue_mask,
 ...
> +	*num_queues = hweight_long(*queue_mask);

queue_mask is not a long, it is an unsinged int, therefore hweight32() is
probably more appropriate.

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

end of thread, back to index

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

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git