Skip to contentSkip to conversation

Improve the qlge driver based on drivers/staging/qlge/TODO

RFC In review Coiby Xu 4 participants 47 messages Jun 21, 2021 – Jul 3, 2021

Subsystems (3)
lore
Share & tools
lore

Coiby Xu

author
#0 lore raw

cover Improve the qlge driver based on drivers/staging/qlge/TODO

This patch set improves qlge driver based on drivers/staging/qlge/TODO written by Benjamin.

For the testing, the kernel was build with KASAN, UBSAN,
DEBUG_ATOMIC_SLEEP, PROVE_LOCKING and DEBUG_KMEMLEAK enabled on a
machine from Red Hat. The machine happened to have two NICs managed by
this qlge driver. I put these two NICs into separate network namespaces
and no errors occurred for the following tests,
- with default MTU
- non TCP packet
- ping the other NIC from one NIC with different packet size, e.g.
200, 300, 2200
- TCP packets
- start a http server on one NIC
$ ip netns exec ns1 python -m http.server 8000 --bind 192.168.1.209
- download a file from the http server using the other NIC
curl -X GET --interface enp94s0f0 http://192.168.1.209:8000/kernel-5.11.3-300.fc34.src.rpm -L -O
- do the same tests with jumbo frame enabled (ip link set enp94s0f0 mtu 9000)

[1] https://lore.kernel.org/netdev/20200816025717.GA28176@f3/T/

Coiby Xu (19):
staging: qlge: fix incorrect truesize accounting
staging: qlge: change LARGE_BUFFER_MAX_SIZE to 4096
staging: qlge: alloc skb with only enough room for header when data is
put in the fragments
staging: qlge: add qlge_* prefix to avoid namespace clashes
staging: qlge: rename rx to completion queue and seperate rx_ring from
completion queue
staging: qlge: disable flow control by default
staging: qlge: remove the TODO item of unnecessary memset 0
staging: qlge: reorder members of qlge_adapter for optimization
staging: qlge: remove the TODO item of reorder struct
staging: qlge: remove the TODO item of avoid legacy/deprecated apis
staging: qlge: the number of pages to contain a buffer queue is
constant
staging: qlge: rewrite do while loops as for loops in
qlge_start_rx_ring
staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock
staging: qlge: rewrite do while loop as for loop in qlge_refill_bq
staging: qlge: remove the TODO item about rewriting while loops as
simple for loops
staging: qlge: remove deadcode in qlge_build_rx_skb
staging: qlge: fix weird line wrapping
staging: qlge: fix two indentation issues
staging: qlge: remove TODO item of unnecessary runtime checks

 drivers/staging/qlge/TODO           |  31 --
 drivers/staging/qlge/qlge.h         |  88 +++--
 drivers/staging/qlge/qlge_dbg.c     |  36 +-
 drivers/staging/qlge/qlge_ethtool.c |  26 +-
 drivers/staging/qlge/qlge_main.c    | 586 ++++++++++++++--------------
 drivers/staging/qlge/qlge_mpi.c     |  11 +-
 6 files changed, 373 insertions(+), 405 deletions(-)
Signature · 1 line
2.32.0
author
#1 lore raw

RFC 1/19 staging: qlge: fix incorrect truesize accounting

Commit 7c734359d3504c869132166d159c7f0649f0ab34 ("qlge: Size RX buffers based on MTU") introduced page_chunk structure. We should add qdev->lbq_buf_size to skb->truesize after __skb_fill_page_desc.

---
 drivers/staging/qlge/TODO        |  2 --
 drivers/staging/qlge/qlge_main.c | 10 +++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/staging/qlge/TODO +0 -2
index c76394b9451b..449d7dca478b 100644
@@ -4,8 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* truesize accounting is incorrect (ex: a 9000B frame has skb->truesize 10280
-  while containing two frags of order-1 allocations, ie. >16K)
 * while in that area, using two 8k buffers to store one 9k frame is a poor
   choice of buffer size.
 * in the "chain of large buffers" case, the driver uses an skb allocated with
drivers/staging/qlge/qlge_main.c +5 -5
index 19a02e958865..6dd69b689a58 100644
@@ -1446,7 +1446,7 @@ static void qlge_process_mac_rx_gro_page(struct qlge_adapter *qdev,
 
 	skb->len += length;
 	skb->data_len += length;
-	skb->truesize += length;
+	skb->truesize += qdev->lbq_buf_size;
 	skb_shinfo(skb)->nr_frags++;
 
 	rx_ring->rx_packets++;
@@ -1507,7 +1507,7 @@ static void qlge_process_mac_rx_page(struct qlge_adapter *qdev,
 			   lbq_desc->p.pg_chunk.offset + hlen, length - hlen);
 	skb->len += length - hlen;
 	skb->data_len += length - hlen;
-	skb->truesize += length - hlen;
+	skb->truesize += qdev->lbq_buf_size;
 
 	rx_ring->rx_packets++;
 	rx_ring->rx_bytes += skb->len;
@@ -1757,7 +1757,7 @@ static struct sk_buff *qlge_build_rx_skb(struct qlge_adapter *qdev,
 					   lbq_desc->p.pg_chunk.offset, length);
 			skb->len += length;
 			skb->data_len += length;
-			skb->truesize += length;
+			skb->truesize += qdev->lbq_buf_size;
 		} else {
 			/*
 			 * The headers and data are in a single large buffer. We
@@ -1783,7 +1783,7 @@ static struct sk_buff *qlge_build_rx_skb(struct qlge_adapter *qdev,
 					   length);
 			skb->len += length;
 			skb->data_len += length;
-			skb->truesize += length;
+			skb->truesize += qdev->lbq_buf_size;
 			qlge_update_mac_hdr_len(qdev, ib_mac_rsp,
 						lbq_desc->p.pg_chunk.va,
 						&hlen);
@@ -1835,7 +1835,7 @@ static struct sk_buff *qlge_build_rx_skb(struct qlge_adapter *qdev,
 					   lbq_desc->p.pg_chunk.offset, size);
 			skb->len += size;
 			skb->data_len += size;
-			skb->truesize += size;
+			skb->truesize += qdev->lbq_buf_size;
 			length -= size;
 			i++;
 		} while (length > 0);
Signature · 1 line
2.32.0
#2 lore raw

Re: [RFC 01/19] staging: qlge: fix incorrect truesize accounting

Quoted 4 lines · Coiby Xu

Commit 7c734359d3504c869132166d159c7f0649f0ab34 ("qlge: Size RX buffers based on MTU") introduced page_chunk structure. We should add qdev->lbq_buf_size to skb->truesize after __skb_fill_page_desc.

Add a Fixes tag.

The runtime impact of this is just that ethtool will report things incorrectly, right? It's not 100% from the commit message. Could you please edit the commit message so that an ignoramous like myself can understand it?

Why is this an RFC instead of just a normal patch which we can apply?

regards,
dan carpenter

author
#3 lore raw

Re: [RFC 01/19] staging: qlge: fix incorrect truesize accounting

Quoted 7 lines · Dan Carpenter
Quoted 4 lines · Coiby Xu

Commit 7c734359d3504c869132166d159c7f0649f0ab34 ("qlge: Size RX buffers based on MTU") introduced page_chunk structure. We should add qdev->lbq_buf_size to skb->truesize after __skb_fill_page_desc.

Add a Fixes tag.

I will fix it in next version, thanks!

Quoted 5 lines

The runtime impact of this is just that ethtool will report things incorrectly, right? It's not 100% from the commit message. Could you please edit the commit message so that an ignoramous like myself can understand it?

I'm not sure how it would affect ethtool. But according to "git log --grep=truesize", it affects coalescing SKBs. Btw, I fixed the issue according to the definition of truesize which according to Linux Kernel Network by Rami Rosen, it's defined as follows,

Quoted 1 line

The total memory allocated for the SKB (including the SKB structure itself and the size of the allocated data block).

I'll edit the commit message to include it, thanks!

Quoted 2 lines

Why is this an RFC instead of just a normal patch which we can apply?

After doing the tests mentioned in the cover letter, I found Red Hat's network QE team has quite a rigorous test suite. But I needed to return the machine before having the time to learn about the test suite and run it by myself. So I mark it as an RFC before I borrow the machine again to run the test suite.

Quoted 4 lines

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
#4 lore raw

Re: [RFC 01/19] staging: qlge: fix incorrect truesize accounting

Quoted 16 lines · Coiby Xu
Quoted 7 lines · Dan Carpenter
Quoted 4 lines · Coiby Xu

Commit 7c734359d3504c869132166d159c7f0649f0ab34 ("qlge: Size RX buffers based on MTU") introduced page_chunk structure. We should add qdev->lbq_buf_size to skb->truesize after __skb_fill_page_desc.

Add a Fixes tag.

I will fix it in next version, thanks!

Quoted 5 lines

The runtime impact of this is just that ethtool will report things incorrectly, right? It's not 100% from the commit message. Could you please edit the commit message so that an ignoramous like myself can understand it?

truesize is used in socket memory accounting, the stuff behind sysctl net.core.rmem_max, SO_RCVBUF, ss -m, ...

Some helpful chap wrote a page about it a while ago:
http://vger.kernel.org/~davem/skb_sk.html

Quoted 11 lines

I'm not sure how it would affect ethtool. But according to "git log --grep=truesize", it affects coalescing SKBs. Btw, I fixed the issue according to the definition of truesize which according to Linux Kernel Network by Rami Rosen, it's defined as follows,

Quoted 2 lines

The total memory allocated for the SKB (including the SKB structure itself and the size of the allocated data block).

I'll edit the commit message to include it, thanks!

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Why is this an RFC instead of just a normal patch which we can apply?

After doing the tests mentioned in the cover letter, I found Red Hat's network QE team has quite a rigorous test suite. But I needed to return the machine before having the time to learn about the test suite and run it by myself. So I mark it as an RFC before I borrow the machine again to run the test suite.

Interesting. Is this test suite based on a public project?

author
#5 lore raw

Re: [RFC 01/19] staging: qlge: fix incorrect truesize accounting

Quoted 18 lines · Benjamin Poirier
Quoted 16 lines · Coiby Xu
Quoted 7 lines · Dan Carpenter
Quoted 4 lines · Coiby Xu

Commit 7c734359d3504c869132166d159c7f0649f0ab34 ("qlge: Size RX buffers based on MTU") introduced page_chunk structure. We should add qdev->lbq_buf_size to skb->truesize after __skb_fill_page_desc.

Add a Fixes tag.

I will fix it in next version, thanks!

Quoted 5 lines

The runtime impact of this is just that ethtool will report things incorrectly, right? It's not 100% from the commit message. Could you please edit the commit message so that an ignoramous like myself can understand it?

Quoted 5 lines

truesize is used in socket memory accounting, the stuff behind sysctl net.core.rmem_max, SO_RCVBUF, ss -m, ...

Some helpful chap wrote a page about it a while ago:
http://vger.kernel.org/~davem/skb_sk.html

Thanks for the explanation and the reference!

Quoted 14 lines
Quoted 14 lines

I'm not sure how it would affect ethtool. But according to "git log --grep=truesize", it affects coalescing SKBs. Btw, I fixed the issue according to the definition of truesize which according to Linux Kernel Network by Rami Rosen, it's defined as follows,

Quoted 2 lines

The total memory allocated for the SKB (including the SKB structure itself and the size of the allocated data block).

I'll edit the commit message to include it, thanks!

Quoted 2 lines

Why is this an RFC instead of just a normal patch which we can apply?

Quoted 7 lines
Quoted 5 lines

After doing the tests mentioned in the cover letter, I found Red Hat's network QE team has quite a rigorous test suite. But I needed to return the machine before having the time to learn about the test suite and run it by myself. So I mark it as an RFC before I borrow the machine again to run the test suite.

Interesting. Is this test suite based on a public project?

The test suite is written for Beaker [1] but it seems it's not public.

[1] https://fedoraproject.org/wiki/QA/Beaker

Signature · 2 lines
Best regards,
Coiby
author
#6 lore raw

Re: [RFC 01/19] staging: qlge: fix incorrect truesize accounting

Quoted 1 line · Coiby Xu

On Wed, Jun 23, 2021 at 01:55:15PM +0900, Benjamin Poirier wrote:

[..]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 1 line

Why is this an RFC instead of just a normal patch which we can apply?

After doing the tests mentioned in the cover letter, I found Red Hat's network QE team has quite a rigorous test suite. But I needed to return the machine before having the time to learn about the test suite and run it by myself. So I mark it as an RFC before I borrow the machine again to run the test suite.

Quoted 5 lines
Quoted 1 line

Interesting. Is this test suite based on a public project?

The test suite is written for Beaker [1] but it seems it's not public.

[1] https://fedoraproject.org/wiki/QA/Beaker

FYI, the tier-1 tests are part of the CKI project and are public [2].

[2] https://gitlab.com/cki-project/kernel-tests/-/tree/main/networking

Signature · 2 lines
Best regards,
Coiby
author
#7 lore raw

RFC 2/19 staging: qlge: change LARGE_BUFFER_MAX_SIZE to 4096

In reply to Coiby Xu

LARGE_BUFFER_MAX_SIZE=4096 could make better use of memory. This choice is consist with ixgbe and e1000 ,
- ixgbe sets the rx buffer's page order to 0 unless FCoE is enabled
- e1000 allocs a page for a jumbo receive buffer

---
 drivers/staging/qlge/TODO   | 2 --
 drivers/staging/qlge/qlge.h | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 449d7dca478b..0e26fac1ddc5 100644
@@ -4,8 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* while in that area, using two 8k buffers to store one 9k frame is a poor
-  choice of buffer size.
 * in the "chain of large buffers" case, the driver uses an skb allocated with
   head room but only puts data in the frags.
 * rename "rx" queues to "completion" queues. Calling tx completion queues "rx
drivers/staging/qlge/qlge.h +1 -1
index 55e0ad759250..f54d38606b78 100644
@@ -52,7 +52,7 @@
 #define RX_RING_SHADOW_SPACE	(sizeof(u64) + \
 		MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64) + \
 		MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64))
-#define LARGE_BUFFER_MAX_SIZE 8192
+#define LARGE_BUFFER_MAX_SIZE 4096
 #define LARGE_BUFFER_MIN_SIZE 2048
 
 #define MAX_CQ 128
Signature · 1 line
2.32.0
author
#8 lore raw

RFC 3/19 staging: qlge: alloc skb with only enough room for header when data is put in the fragments

In reply to Coiby Xu

Data is put in the fragments. No need to alloc a skb with unnecessarily large data buffer.

---
 drivers/staging/qlge/TODO        | 2 --
 drivers/staging/qlge/qlge_main.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 0e26fac1ddc5..49cb09fc2be4 100644
@@ -4,8 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* in the "chain of large buffers" case, the driver uses an skb allocated with
-  head room but only puts data in the frags.
 * rename "rx" queues to "completion" queues. Calling tx completion queues "rx
   queues" is confusing.
 * struct rx_ring is used for rx and tx completions, with some members relevant
drivers/staging/qlge/qlge_main.c +2 -2
index 6dd69b689a58..c91969b01bd5 100644
@@ -1471,7 +1471,7 @@ static void qlge_process_mac_rx_page(struct qlge_adapter *qdev,
 	struct napi_struct *napi = &rx_ring->napi;
 	size_t hlen = ETH_HLEN;
 
-	skb = netdev_alloc_skb(ndev, length);
+	skb = napi_alloc_skb(&rx_ring->napi, SMALL_BUFFER_SIZE);
 	if (!skb) {
 		rx_ring->rx_dropped++;
 		put_page(lbq_desc->p.pg_chunk.page);
@@ -1765,7 +1765,7 @@ static struct sk_buff *qlge_build_rx_skb(struct qlge_adapter *qdev,
 			 * jumbo mtu on a non-TCP/UDP frame.
 			 */
 			lbq_desc = qlge_get_curr_lchunk(qdev, rx_ring);
-			skb = netdev_alloc_skb(qdev->ndev, length);
+			skb = napi_alloc_skb(&rx_ring->napi, SMALL_BUFFER_SIZE);
 			if (!skb) {
 				netif_printk(qdev, probe, KERN_DEBUG, qdev->ndev,
 					     "No skb available, drop the packet.\n");
Signature · 1 line
2.32.0
author
#9 lore raw

RFC 4/19 staging: qlge: add qlge_* prefix to avoid namespace clashes

In reply to Coiby Xu

This patch extends commit f8c047be540197ec69cde33e00e82d23961459ea ("staging: qlge: use qlge_* prefix to avoid namespace clashes with other qlogic drivers") to add qlge_ prefix to rx_ring and tx_ring related structures.

---
 drivers/staging/qlge/qlge.h         |  40 ++++-----
 drivers/staging/qlge/qlge_ethtool.c |   4 +-
 drivers/staging/qlge/qlge_main.c    | 124 ++++++++++++++--------------
 3 files changed, 84 insertions(+), 84 deletions(-)
drivers/staging/qlge/qlge.h +20 -20
index f54d38606b78..09d5878b95f7 100644
@@ -869,17 +869,17 @@ enum {
 };
 
 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
-#define SMALL_BUFFER_SIZE 256
-#define SMALL_BUF_MAP_SIZE SMALL_BUFFER_SIZE
+#define QLGE_SMALL_BUFFER_SIZE 256
+#define QLGE_SMALL_BUF_MAP_SIZE QLGE_SMALL_BUFFER_SIZE
 #define SPLT_SETTING  FSC_DBRST_1024
 #define SPLT_LEN 0
 #define QLGE_SB_PAD 0
 #else
-#define SMALL_BUFFER_SIZE 512
-#define SMALL_BUF_MAP_SIZE (SMALL_BUFFER_SIZE / 2)
+#define QLGE_SMALL_BUFFER_SIZE 512
+#define QLGE_SMALL_BUF_MAP_SIZE (QLGE_SMALL_BUFFER_SIZE / 2)
 #define SPLT_SETTING  FSC_SH
 #define SPLT_LEN (SPLT_HDR_EP | \
-	min(SMALL_BUF_MAP_SIZE, 1023))
+	min(QLGE_SMALL_BUF_MAP_SIZE, 1023))
 #define QLGE_SB_PAD 32
 #endif
 
@@ -1063,7 +1063,7 @@ struct tx_doorbell_context {
 };
 
 /* DATA STRUCTURES SHARED WITH HARDWARE. */
-struct tx_buf_desc {
+struct qlge_tx_buf_desc {
 	__le64 addr;
 	__le32 len;
 #define TX_DESC_LEN_MASK	0x000fffff
@@ -1101,7 +1101,7 @@ struct qlge_ob_mac_iocb_req {
 	__le32 reserved3;
 	__le16 vlan_tci;
 	__le16 reserved4;
-	struct tx_buf_desc tbd[TX_DESC_PER_IOCB];
+	struct qlge_tx_buf_desc tbd[TX_DESC_PER_IOCB];
 } __packed;
 
 struct qlge_ob_mac_iocb_rsp {
@@ -1146,7 +1146,7 @@ struct qlge_ob_mac_tso_iocb_req {
 #define OB_MAC_TRANSPORT_HDR_SHIFT 6
 	__le16 vlan_tci;
 	__le16 mss;
-	struct tx_buf_desc tbd[TX_DESC_PER_IOCB];
+	struct qlge_tx_buf_desc tbd[TX_DESC_PER_IOCB];
 } __packed;
 
 struct qlge_ob_mac_tso_iocb_rsp {
@@ -1347,7 +1347,7 @@ struct ricb {
 /* SOFTWARE/DRIVER DATA STRUCTURES. */
 
 struct qlge_oal {
-	struct tx_buf_desc oal[TX_DESC_PER_OAL];
+	struct qlge_tx_buf_desc oal[TX_DESC_PER_OAL];
 };
 
 struct map_list {
@@ -1355,19 +1355,19 @@ struct map_list {
 	DEFINE_DMA_UNMAP_LEN(maplen);
 };
 
-struct tx_ring_desc {
+struct qlge_tx_ring_desc {
 	struct sk_buff *skb;
 	struct qlge_ob_mac_iocb_req *queue_entry;
 	u32 index;
 	struct qlge_oal oal;
 	struct map_list map[MAX_SKB_FRAGS + 2];
 	int map_cnt;
-	struct tx_ring_desc *next;
+	struct qlge_tx_ring_desc *next;
 };
 
 #define QL_TXQ_IDX(qdev, skb) (smp_processor_id() % (qdev->tx_ring_count))
 
-struct tx_ring {
+struct qlge_tx_ring {
 	/*
 	 * queue info.
 	 */
@@ -1384,7 +1384,7 @@ struct tx_ring {
 	u16 cq_id;		/* completion (rx) queue for tx completions */
 	u8 wq_id;		/* queue id for this entry */
 	u8 reserved1[3];
-	struct tx_ring_desc *q;	/* descriptor list for the queue */
+	struct qlge_tx_ring_desc *q;	/* descriptor list for the queue */
 	spinlock_t lock;
 	atomic_t tx_count;	/* counts down for every outstanding IO */
 	struct delayed_work tx_work;
@@ -1437,9 +1437,9 @@ struct qlge_bq {
 #define QLGE_BQ_CONTAINER(bq) \
 ({ \
 	typeof(bq) _bq = bq; \
-	(struct rx_ring *)((char *)_bq - (_bq->type == QLGE_SB ? \
-					  offsetof(struct rx_ring, sbq) : \
-					  offsetof(struct rx_ring, lbq))); \
+	(struct qlge_rx_ring *)((char *)_bq - (_bq->type == QLGE_SB ? \
+					  offsetof(struct qlge_rx_ring, sbq) : \
+					  offsetof(struct qlge_rx_ring, lbq))); \
 })
 
 /* Experience shows that the device ignores the low 4 bits of the tail index.
@@ -1456,7 +1456,7 @@ struct qlge_bq {
 		     (_bq)->next_to_clean); \
 })
 
-struct rx_ring {
+struct qlge_rx_ring {
 	struct cqicb cqicb;	/* The chip's completion queue init control block. */
 
 	/* Completion queue elements. */
@@ -2135,8 +2135,8 @@ struct qlge_adapter {
 	int ring_mem_size;
 	void *ring_mem;
 
-	struct rx_ring rx_ring[MAX_RX_RINGS];
-	struct tx_ring tx_ring[MAX_TX_RINGS];
+	struct qlge_rx_ring rx_ring[MAX_RX_RINGS];
+	struct qlge_tx_ring tx_ring[MAX_TX_RINGS];
 	unsigned int lbq_buf_order;
 	u32 lbq_buf_size;
 
@@ -2287,6 +2287,6 @@ void qlge_get_dump(struct qlge_adapter *qdev, void *buff);
 netdev_tx_t qlge_lb_send(struct sk_buff *skb, struct net_device *ndev);
 void qlge_check_lb_frame(struct qlge_adapter *qdev, struct sk_buff *skb);
 int qlge_own_firmware(struct qlge_adapter *qdev);
-int qlge_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget);
+int qlge_clean_lb_rx_ring(struct qlge_rx_ring *rx_ring, int budget);
 
 #endif /* _QLGE_H_ */
drivers/staging/qlge/qlge_ethtool.c +2 -2
index b70570b7b467..22c27b97a908 100644
@@ -186,7 +186,7 @@ static const char qlge_gstrings_test[][ETH_GSTRING_LEN] = {
 static int qlge_update_ring_coalescing(struct qlge_adapter *qdev)
 {
 	int i, status = 0;
-	struct rx_ring *rx_ring;
+	struct qlge_rx_ring *rx_ring;
 	struct cqicb *cqicb;
 
 	if (!netif_running(qdev->ndev))
@@ -537,7 +537,7 @@ static int qlge_run_loopback_test(struct qlge_adapter *qdev)
 	int i;
 	netdev_tx_t rc;
 	struct sk_buff *skb;
-	unsigned int size = SMALL_BUF_MAP_SIZE;
+	unsigned int size = QLGE_SMALL_BUF_MAP_SIZE;
 
 	for (i = 0; i < 64; i++) {
 		skb = netdev_alloc_skb(qdev->ndev, size);
drivers/staging/qlge/qlge_main.c +62 -62

453 lines not on this page · raw message

Signature · 1 line
2.32.0
#10 lore raw

Re: [RFC 04/19] staging: qlge: add qlge_* prefix to avoid namespace clashes

Quoted 3 lines · Coiby Xu

This patch extends commit f8c047be540197ec69cde33e00e82d23961459ea ("staging: qlge: use qlge_* prefix to avoid namespace clashes with other qlogic drivers") to add qlge_ prefix to rx_ring and tx_ring related structures.

There are still many struct, defines and enums in qlge.h which don't have a prefix or mix ql_ and qlge_, some of which conflict with other instances elsewhere in the kernel.
ex: QL_ADAPTER_UP

I think they should all be changed, not just the ones have a conflict today.

author
#11 lore raw

Re: [RFC 04/19] staging: qlge: add qlge_* prefix to avoid namespace clashes

Quoted 5 lines · Benjamin Poirier
Quoted 3 lines · Coiby Xu

This patch extends commit f8c047be540197ec69cde33e00e82d23961459ea ("staging: qlge: use qlge_* prefix to avoid namespace clashes with other qlogic drivers") to add qlge_ prefix to rx_ring and tx_ring related structures.

Quoted 7 lines

There are still many struct, defines and enums in qlge.h which don't have a prefix or mix ql_ and qlge_, some of which conflict with other instances elsewhere in the kernel.
ex: QL_ADAPTER_UP

I think they should all be changed, not just the ones have a conflict today.

I'll fix them in next version. Thanks for the reminder!

Signature · 2 lines
Best regards,
Coiby
author
#12 lore raw

RFC 5/19 staging: qlge: rename rx to completion queue and seperate rx_ring from completion queue

In reply to Coiby Xu

This patch addresses the following TODO items,

Quoted 4 lines

* rename "rx" queues to "completion" queues. Calling tx completion queues "rx queues" is confusing.
* struct rx_ring is used for rx and tx completions, with some members relevant to one case only

The first part of the completion queue (index range: [0, qdev->rss_ring_count)) is for inbound completions and the remaining part (index range:
[qdev->rss_ring_count, qdev->cq_count)) is for outbound completions.

Note the structure filed name and reserved is unused, remove it to reduce holes.

---
 drivers/staging/qlge/TODO           |   4 -
 drivers/staging/qlge/qlge.h         |  30 +--
 drivers/staging/qlge/qlge_dbg.c     |   6 +-
 drivers/staging/qlge/qlge_ethtool.c |  24 +--
 drivers/staging/qlge/qlge_main.c    | 291 +++++++++++++++-------------
 5 files changed, 188 insertions(+), 167 deletions(-)
drivers/staging/qlge/TODO +0 -4
index 49cb09fc2be4..b7a60425fcd2 100644
@@ -4,10 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* rename "rx" queues to "completion" queues. Calling tx completion queues "rx
-  queues" is confusing.
-* struct rx_ring is used for rx and tx completions, with some members relevant
-  to one case only
 * the flow control implementation in firmware is buggy (sends a flood of pause
   frames, resets the link, device and driver buffer queues become
   desynchronized), disable it by default
drivers/staging/qlge/qlge.h +17 -13
index 09d5878b95f7..926af25b14fa 100644
@@ -1456,15 +1456,15 @@ struct qlge_bq {
 		     (_bq)->next_to_clean); \
 })
 
-struct qlge_rx_ring {
+struct qlge_cq {
 	struct cqicb cqicb;	/* The chip's completion queue init control block. */
 
 	/* Completion queue elements. */
+	u16 cq_id;
 	void *cq_base;
 	dma_addr_t cq_base_dma;
 	u32 cq_size;
 	u32 cq_len;
-	u16 cq_id;
 	__le32 *prod_idx_sh_reg;	/* Shadowed producer register. */
 	dma_addr_t prod_idx_sh_reg_dma;
 	void __iomem *cnsmr_idx_db_reg;	/* PCI doorbell mem area + 0 */
@@ -1472,6 +1472,13 @@ struct qlge_rx_ring {
 	struct qlge_net_rsp_iocb *curr_entry;	/* next entry on queue */
 	void __iomem *valid_db_reg;	/* PCI doorbell mem area + 0x04 */
 
+	/* Misc. handler elements. */
+	u32 irq;		/* Which vector this ring is assigned. */
+	u32 cpu;		/* Which CPU this should run on. */
+	struct qlge_adapter *qdev;
+};
+
+struct qlge_rx_ring {
 	/* Large buffer queue elements. */
 	struct qlge_bq lbq;
 	struct qlge_page_chunk master_chunk;
@@ -1480,19 +1487,15 @@ struct qlge_rx_ring {
 	/* Small buffer queue elements. */
 	struct qlge_bq sbq;
 
-	/* Misc. handler elements. */
-	u32 irq;		/* Which vector this ring is assigned. */
-	u32 cpu;		/* Which CPU this should run on. */
-	struct delayed_work refill_work;
-	char name[IFNAMSIZ + 5];
 	struct napi_struct napi;
-	u8 reserved;
-	struct qlge_adapter *qdev;
+	struct delayed_work refill_work;
 	u64 rx_packets;
 	u64 rx_multicast;
 	u64 rx_bytes;
 	u64 rx_dropped;
 	u64 rx_errors;
+	struct qlge_adapter *qdev;
+	u16 cq_id;
 };
 
 /*
@@ -1753,7 +1756,7 @@ enum {
 #define SHADOW_REG_SHIFT	20
 
 struct qlge_nic_misc {
-	u32 rx_ring_count;
+	u32 cq_count;
 	u32 tx_ring_count;
 	u32 intr_count;
 	u32 function;
@@ -2127,14 +2130,15 @@ struct qlge_adapter {
 	int tx_ring_count;	/* One per online CPU. */
 	u32 rss_ring_count;	/* One per irq vector.  */
 	/*
-	 * rx_ring_count =
+	 * cq_count =
 	 *  (CPU count * outbound completion rx_ring) +
 	 *  (irq_vector_cnt * inbound (RSS) completion rx_ring)
 	 */
-	int rx_ring_count;
+	int cq_count;
 	int ring_mem_size;
 	void *ring_mem;
 
+	struct qlge_cq cq[MAX_RX_RINGS];
 	struct qlge_rx_ring rx_ring[MAX_RX_RINGS];
 	struct qlge_tx_ring tx_ring[MAX_TX_RINGS];
 	unsigned int lbq_buf_order;
@@ -2287,6 +2291,6 @@ void qlge_get_dump(struct qlge_adapter *qdev, void *buff);
 netdev_tx_t qlge_lb_send(struct sk_buff *skb, struct net_device *ndev);
 void qlge_check_lb_frame(struct qlge_adapter *qdev, struct sk_buff *skb);
 int qlge_own_firmware(struct qlge_adapter *qdev);
-int qlge_clean_lb_rx_ring(struct qlge_rx_ring *rx_ring, int budget);
+int qlge_clean_lb_cq(struct qlge_cq *cq, int budget);
 
 #endif /* _QLGE_H_ */
drivers/staging/qlge/qlge_dbg.c +3 -3
index 37e593f0fd82..d093e6c9f19c 100644
@@ -403,7 +403,7 @@ static void qlge_get_intr_states(struct qlge_adapter *qdev, u32 *buf)
 {
 	int i;
 
-	for (i = 0; i < qdev->rx_ring_count; i++, buf++) {
+	for (i = 0; i < qdev->cq_count; i++, buf++) {
 		qlge_write32(qdev, INTR_EN,
 			     qdev->intr_context[i].intr_read_mask);
 		*buf = qlge_read32(qdev, INTR_EN);
@@ -1074,7 +1074,7 @@ int qlge_core_dump(struct qlge_adapter *qdev, struct qlge_mpi_coredump *mpi_core
 				       sizeof(struct mpi_coredump_segment_header)
 				       + sizeof(mpi_coredump->misc_nic_info),
 				       "MISC NIC INFO");
-	mpi_coredump->misc_nic_info.rx_ring_count = qdev->rx_ring_count;
+	mpi_coredump->misc_nic_info.cq_count = qdev->cq_count;
 	mpi_coredump->misc_nic_info.tx_ring_count = qdev->tx_ring_count;
 	mpi_coredump->misc_nic_info.intr_count = qdev->intr_count;
 	mpi_coredump->misc_nic_info.function = qdev->func;
@@ -1237,7 +1237,7 @@ static void qlge_gen_reg_dump(struct qlge_adapter *qdev,
 				       sizeof(struct mpi_coredump_segment_header)
 				       + sizeof(mpi_coredump->misc_nic_info),
 				       "MISC NIC INFO");
-	mpi_coredump->misc_nic_info.rx_ring_count = qdev->rx_ring_count;
+	mpi_coredump->misc_nic_info.cq_count = qdev->cq_count;
 	mpi_coredump->misc_nic_info.tx_ring_count = qdev->tx_ring_count;
 	mpi_coredump->misc_nic_info.intr_count = qdev->intr_count;
 	mpi_coredump->misc_nic_info.function = qdev->func;
drivers/staging/qlge/qlge_ethtool.c +12 -12
index 22c27b97a908..7f77f99cc047 100644
@@ -186,7 +186,7 @@ static const char qlge_gstrings_test[][ETH_GSTRING_LEN] = {
 static int qlge_update_ring_coalescing(struct qlge_adapter *qdev)
 {
 	int i, status = 0;
-	struct qlge_rx_ring *rx_ring;
+	struct qlge_cq *cq;
 	struct cqicb *cqicb;
 
 	if (!netif_running(qdev->ndev))
@@ -195,18 +195,18 @@ static int qlge_update_ring_coalescing(struct qlge_adapter *qdev)
 	/* Skip the default queue, and update the outbound handler
 	 * queues if they changed.
 	 */
-	cqicb = (struct cqicb *)&qdev->rx_ring[qdev->rss_ring_count];
+	cqicb = (struct cqicb *)&qdev->cq[qdev->rss_ring_count];
 	if (le16_to_cpu(cqicb->irq_delay) != qdev->tx_coalesce_usecs ||
 	    le16_to_cpu(cqicb->pkt_delay) != qdev->tx_max_coalesced_frames) {
-		for (i = qdev->rss_ring_count; i < qdev->rx_ring_count; i++) {
-			rx_ring = &qdev->rx_ring[i];
-			cqicb = (struct cqicb *)rx_ring;
+		for (i = qdev->rss_ring_count; i < qdev->cq_count; i++) {
+			cq = &qdev->cq[i];
+			cqicb = (struct cqicb *)cq;
 			cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs);
 			cqicb->pkt_delay =
 				cpu_to_le16(qdev->tx_max_coalesced_frames);
 			cqicb->flags = FLAGS_LI;
 			status = qlge_write_cfg(qdev, cqicb, sizeof(*cqicb),
-						CFG_LCQ, rx_ring->cq_id);
+						CFG_LCQ, cq->cq_id);
 			if (status) {
 				netif_err(qdev, ifup, qdev->ndev,
 					  "Failed to load CQICB.\n");
@@ -216,18 +216,18 @@ static int qlge_update_ring_coalescing(struct qlge_adapter *qdev)
 	}
 
 	/* Update the inbound (RSS) handler queues if they changed. */
-	cqicb = (struct cqicb *)&qdev->rx_ring[0];
+	cqicb = (struct cqicb *)&qdev->cq[0];
 	if (le16_to_cpu(cqicb->irq_delay) != qdev->rx_coalesce_usecs ||
 	    le16_to_cpu(cqicb->pkt_delay) != qdev->rx_max_coalesced_frames) {
-		for (i = 0; i < qdev->rss_ring_count; i++, rx_ring++) {
-			rx_ring = &qdev->rx_ring[i];
-			cqicb = (struct cqicb *)rx_ring;
+		for (i = 0; i < qdev->rss_ring_count; i++, cq++) {
+			cq = &qdev->cq[i];
+			cqicb = (struct cqicb *)cq;
 			cqicb->irq_delay = cpu_to_le16(qdev->rx_coalesce_usecs);
 			cqicb->pkt_delay =
 				cpu_to_le16(qdev->rx_max_coalesced_frames);
 			cqicb->flags = FLAGS_LI;
 			status = qlge_write_cfg(qdev, cqicb, sizeof(*cqicb),
-						CFG_LCQ, rx_ring->cq_id);
+						CFG_LCQ, cq->cq_id);
 			if (status) {
 				netif_err(qdev, ifup, qdev->ndev,
 					  "Failed to load CQICB.\n");
@@ -554,7 +554,7 @@ static int qlge_run_loopback_test(struct qlge_adapter *qdev)
 	}
 	/* Give queue time to settle before testing results. */
 	msleep(2);
-	qlge_clean_lb_rx_ring(&qdev->rx_ring[0], 128);
+	qlge_clean_lb_cq(&qdev->cq[0], 128);
 	return atomic_read(&qdev->lb_count) ? -EIO : 0;
 }
 
drivers/staging/qlge/qlge_main.c +156 -135

603 lines not on this page · raw message

Signature · 1 line
2.32.0
author
#13 lore raw

RFC 6/19 staging: qlge: disable flow control by default

In reply to Coiby Xu

According to the TODO item,

Quoted 3 lines

* the flow control implementation in firmware is buggy (sends a flood of pause frames, resets the link, device and driver buffer queues become desynchronized), disable it by default

Currently, qlge_mpi_port_cfg_work calls qlge_mb_get_port_cfg which gets the link config from the firmware and saves it to qdev->link_config. By default, flow control is enabled. This commit writes the save the pause parameter of qdev->link_config and don't let it overwritten by link settings of current port. Since qdev->link_config=0 when qdev is initialized, this could disable flow control by default and the pause parameter value could also survive MPI resetting,

    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             off
    TX:             off

The follow control can be enabled manually,

    $ ethtool -A enp94s0f0 rx on tx on
    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             on
    TX:             on
---
 drivers/staging/qlge/TODO       |  3 ---
 drivers/staging/qlge/qlge_mpi.c | 11 ++++++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/staging/qlge/TODO +0 -3
index b7a60425fcd2..8c84160b5993 100644
@@ -4,9 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* the flow control implementation in firmware is buggy (sends a flood of pause
-  frames, resets the link, device and driver buffer queues become
-  desynchronized), disable it by default
 * some structures are initialized redundantly (ex. memset 0 after
   alloc_etherdev())
 * the driver has a habit of using runtime checks where compile time checks are
drivers/staging/qlge/qlge_mpi.c +10 -1
index 2630ebf50341..0f1c7da80413 100644
@@ -806,6 +806,7 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 {
 	struct mbox_params mbc;
 	struct mbox_params *mbcp = &mbc;
+	u32 saved_pause_link_config = 0;
 	int status = 0;
 
 	memset(mbcp, 0, sizeof(struct mbox_params));
@@ -826,7 +827,15 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 	} else	{
 		netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev,
 			     "Passed Get Port Configuration.\n");
-		qdev->link_config = mbcp->mbox_out[1];
+		/*
+		 * Don't let the pause parameter be overwritten by
+		 *
+		 * In this way, follow control can be disabled by default
+		 * and the setting could also survive the MPI reset
+		 */
+		saved_pause_link_config = qdev->link_config & CFG_PAUSE_STD;
+		qdev->link_config = ~CFG_PAUSE_STD & mbcp->mbox_out[1];
+		qdev->link_config |= saved_pause_link_config;
 		qdev->max_frame_size = mbcp->mbox_out[2];
 	}
 	return status;
Signature · 1 line
2.32.0
#14 lore raw

Re: [RFC 06/19] staging: qlge: disable flow control by default

Quoted 52 lines · Coiby Xu

According to the TODO item,

Quoted 3 lines

* the flow control implementation in firmware is buggy (sends a flood of pause frames, resets the link, device and driver buffer queues become desynchronized), disable it by default

Currently, qlge_mpi_port_cfg_work calls qlge_mb_get_port_cfg which gets the link config from the firmware and saves it to qdev->link_config. By default, flow control is enabled. This commit writes the save the pause parameter of qdev->link_config and don't let it overwritten by link settings of current port. Since qdev->link_config=0 when qdev is initialized, this could disable flow control by default and the pause parameter value could also survive MPI resetting,

    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             off
    TX:             off

The follow control can be enabled manually,

    $ ethtool -A enp94s0f0 rx on tx on
    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             on
    TX:             on
---
 drivers/staging/qlge/TODO       |  3 ---
 drivers/staging/qlge/qlge_mpi.c | 11 ++++++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/staging/qlge/TODO +0 -3
index b7a60425fcd2..8c84160b5993 100644
@@ -4,9 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* the flow control implementation in firmware is buggy (sends a flood of pause
-  frames, resets the link, device and driver buffer queues become
-  desynchronized), disable it by default
 * some structures are initialized redundantly (ex. memset 0 after
   alloc_etherdev())
 * the driver has a habit of using runtime checks where compile time checks are
drivers/staging/qlge/qlge_mpi.c +0 -0
index 2630ebf50341..0f1c7da80413 100644

drivers/staging/qlge/qlge_mpi.c int qlge_mb_get_port_cfg(struct qlge_adapter *qdev) · line 809

Quoted 4 lines
drivers/staging/qlge/qlge_mpi.c +1 -0
@@ -806,6 +806,7 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 {
 	struct mbox_params mbc;
 	struct mbox_params *mbcp = &mbc;
+	u32 saved_pause_link_config = 0;

Initialization is not needed given the code below, in fact the declaration can be moved to the block below.

Quoted 4 lines
drivers/staging/qlge/qlge_mpi.c +0 -0
 	int status = 0;
 
 	memset(mbcp, 0, sizeof(struct mbox_params));

drivers/staging/qlge/qlge_mpi.c int qlge_mb_get_port_cfg(struct qlge_adapter *qdev) · line 835

Quoted 10 lines
drivers/staging/qlge/qlge_mpi.c +6 -1
@@ -826,7 +827,15 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 	} else	{
 		netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev,
 			     "Passed Get Port Configuration.\n");
-		qdev->link_config = mbcp->mbox_out[1];
+		/*
+		 * Don't let the pause parameter be overwritten by
+		 *
+		 * In this way, follow control can be disabled by default
+		 * and the setting could also survive the MPI reset
+		 */

It seems this comment is incomplete. Also, it's "flow control", not "follow control".

Quoted 9 lines
drivers/staging/qlge/qlge_mpi.c +3 -0
+		saved_pause_link_config = qdev->link_config & CFG_PAUSE_STD;
+		qdev->link_config = ~CFG_PAUSE_STD & mbcp->mbox_out[1];
+		qdev->link_config |= saved_pause_link_config;
 		qdev->max_frame_size = mbcp->mbox_out[2];
 	}
 	return status;
Signature · 1 line
2.32.0
author
#15 lore raw

Re: [RFC 06/19] staging: qlge: disable flow control by default

Quoted 51 lines · Benjamin Poirier
Quoted 50 lines · Coiby Xu

According to the TODO item,

Quoted 3 lines

* the flow control implementation in firmware is buggy (sends a flood of pause frames, resets the link, device and driver buffer queues become desynchronized), disable it by default

Currently, qlge_mpi_port_cfg_work calls qlge_mb_get_port_cfg which gets the link config from the firmware and saves it to qdev->link_config. By default, flow control is enabled. This commit writes the save the pause parameter of qdev->link_config and don't let it overwritten by link settings of current port. Since qdev->link_config=0 when qdev is initialized, this could disable flow control by default and the pause parameter value could also survive MPI resetting,

    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             off
    TX:             off

The follow control can be enabled manually,

    $ ethtool -A enp94s0f0 rx on tx on
    $ ethtool -a enp94s0f0
    Pause parameters for enp94s0f0:
    Autonegotiate:  off
    RX:             on
    TX:             on
---
 drivers/staging/qlge/TODO       |  3 ---
 drivers/staging/qlge/qlge_mpi.c | 11 ++++++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/staging/qlge/TODO +0 -3
index b7a60425fcd2..8c84160b5993 100644
@@ -4,9 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* the flow control implementation in firmware is buggy (sends a flood of pause
-  frames, resets the link, device and driver buffer queues become
-  desynchronized), disable it by default
 * some structures are initialized redundantly (ex. memset 0 after
   alloc_etherdev())
 * the driver has a habit of using runtime checks where compile time checks are
drivers/staging/qlge/qlge_mpi.c +0 -1
index 2630ebf50341..0f1c7da80413 100644
--- a/drivers/staging/qlge/qlge_mpi.c
Quoted 8 lines

drivers/staging/qlge/qlge_mpi.c int qlge_mb_get_port_cfg(struct qlge_adapter *qdev) · line 809

Quoted 6 lines

+++ b/drivers/staging/qlge/qlge_mpi.c

drivers/staging/qlge/qlge_mpi.c +1 -0
@@ -806,6 +806,7 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 {
 	struct mbox_params mbc;
 	struct mbox_params *mbcp = &mbc;
+	u32 saved_pause_link_config = 0;

Initialization is not needed given the code below,

Thanks for the spotting this issue!

Quoted 2 lines

in fact the
declaration can be moved to the block below.

I thought I need to put the declaration in the beginning of the function. But it seems Linux kernel coding style doesn't require it. I'll move it to the else block below then.

Quoted 18 lines
Quoted 5 lines
drivers/staging/qlge/qlge_mpi.c +0 -0
 	int status = 0;
 
 	memset(mbcp, 0, sizeof(struct mbox_params));

drivers/staging/qlge/qlge_mpi.c int qlge_mb_get_port_cfg(struct qlge_adapter *qdev) · line 835

Quoted 10 lines
drivers/staging/qlge/qlge_mpi.c +6 -1
@@ -826,7 +827,15 @@ int qlge_mb_get_port_cfg(struct qlge_adapter *qdev)
 	} else	{
 		netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev,
 			     "Passed Get Port Configuration.\n");
-		qdev->link_config = mbcp->mbox_out[1];
+		/*
+		 * Don't let the pause parameter be overwritten by
+		 *
+		 * In this way, follow control can be disabled by default
+		 * and the setting could also survive the MPI reset
+		 */

It seems this comment is incomplete. Also, it's "flow control", not "follow control".

Ah, yes. I should state it as "Don't let the pause parameter be overwritten by be overwritten by the firmware.". And thanks for correcting the typo.

Quoted 10 lines
Quoted 10 lines
drivers/staging/qlge/qlge_mpi.c +3 -1
+		saved_pause_link_config = qdev->link_config & CFG_PAUSE_STD;
+		qdev->link_config = ~CFG_PAUSE_STD & mbcp->mbox_out[1];
+		qdev->link_config |= saved_pause_link_config;
 		qdev->max_frame_size = mbcp->mbox_out[2];
 	}
 	return status;
--

2.32.0

Signature · 2 lines
Best regards,
Coiby
author
#16 lore raw

RFC 7/19 staging: qlge: remove the TODO item of unnecessary memset 0

In reply to Coiby Xu

commit 953b94009377419f28fd0153f91fcd5b5a347608 ("staging: qlge:
Initialize devlink health dump framework") removed the unnecessary memset 0 after alloc_etherdev_mq. Delete this TODO item.

---
 drivers/staging/qlge/TODO | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 8c84160b5993..cc5f8cf7608d 100644
@@ -4,8 +4,6 @@
   ql_build_rx_skb(). That function is now used exclusively to handle packets
   that underwent header splitting but it still contains code to handle non
   split cases.
-* some structures are initialized redundantly (ex. memset 0 after
-  alloc_etherdev())
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
 * reorder struct members to avoid holes if it doesn't impact performance
Signature · 1 line
2.32.0
author
#17 lore raw

RFC 8/19 staging: qlge: reorder members of qlge_adapter for optimization

In reply to Coiby Xu

Before reordering, pahole shows,

    /* size: 21168, cachelines: 331, members: 69 */
    /* sum members: 21144, holes: 4, sum holes: 18 */
    /* padding: 6 */
    /* paddings: 6, sum paddings: 24 */
    /* forced alignments: 1 */
    /* last cacheline: 48 bytes */

After reordering following pahole's suggestion,

    /* size: 21152, cachelines: 331, members: 69 */
    /* sum members: 21144, holes: 1, sum holes: 2 */
    /* padding: 6 */
    /* paddings: 6, sum paddings: 24 */
    /* forced alignments: 1 */
    /* last cacheline: 32 bytes */
---
 drivers/staging/qlge/qlge.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/qlge/qlge.h +4 -3
index 926af25b14fa..9177baa9f022 100644
@@ -2081,8 +2081,8 @@ struct qlge_adapter *netdev_to_qdev(struct net_device *ndev)
  */
 struct qlge_adapter {
 	struct ricb ricb;
-	unsigned long flags;
 	u32 wol;
+	unsigned long flags;
 
 	struct nic_stats nic_stats;
 
@@ -2103,6 +2103,8 @@ struct qlge_adapter {
 	spinlock_t adapter_lock;
 	spinlock_t stats_lock;
 
+	u32 intr_count;
+
 	/* PCI Bus Relative Register Addresses */
 	void __iomem *reg_base;
 	void __iomem *doorbell_area;
@@ -2123,7 +2125,6 @@ struct qlge_adapter {
 
 	int tx_ring_size;
 	int rx_ring_size;
-	u32 intr_count;
 	struct msix_entry *msi_x_entry;
 	struct intr_context intr_context[MAX_RX_RINGS];
 
@@ -2162,6 +2163,7 @@ struct qlge_adapter {
 	u32 max_frame_size;
 
 	union flash_params flash;
+	u16 device_id;
 
 	struct workqueue_struct *workqueue;
 	struct delayed_work asic_reset_work;
@@ -2171,7 +2173,6 @@ struct qlge_adapter {
 	struct delayed_work mpi_idc_work;
 	struct completion ide_completion;
 	const struct nic_operations *nic_ops;
-	u16 device_id;
 	struct timer_list timer;
 	atomic_t lb_count;
 	/* Keep local copy of current mac address. */
Signature · 1 line
2.32.0
author
#18 lore raw

RFC 9/19 staging: qlge: remove the TODO item of reorder struct

In reply to Coiby Xu

struct qlge_cq has one hole, but for the sake of readability (irq is one of the Misc. handler elements, don't move it from after 'irq' to after 'cnsmr_idx' ), keep it untouched. Then, there is no struct that need reordering according to pahole.

---
 drivers/staging/qlge/TODO | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/qlge/TODO +0 -1
index cc5f8cf7608d..2c4cc586a4bf 100644
@@ -6,7 +6,6 @@
   split cases.
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
-* reorder struct members to avoid holes if it doesn't impact performance
 * avoid legacy/deprecated apis (ex. replace pci_dma_*, replace pci_enable_msi,
   use pci_iomap)
 * some "while" loops could be rewritten with simple "for", ex.
Signature · 1 line
2.32.0
author
#19 lore raw

RFC 10/19 staging: qlge: remove the TODO item of avoid legacy/deprecated apis

In reply to Coiby Xu

The following commits have finished the job,
- commit e955a071b9b3e6b634b7ceda64025bfbd6529dcc ("staging: qlge:
replace deprecated apis pci_dma_*")
- commit 50b483a1457abd6fe27117f0507297e107ef42b2 ("qlge: Use pci_enable_msix_range() instead of pci_enable_msix()")

---
 drivers/staging/qlge/TODO | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 2c4cc586a4bf..8bb6779a5bb4 100644
@@ -6,8 +6,6 @@
   split cases.
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
-* avoid legacy/deprecated apis (ex. replace pci_dma_*, replace pci_enable_msi,
-  use pci_iomap)
 * some "while" loops could be rewritten with simple "for", ex.
   ql_wait_reg_rdy(), ql_start_rx_ring())
 * remove duplicate and useless comments
Signature · 1 line
2.32.0
author
#20 lore raw

RFC 11/19 staging: qlge: the number of pages to contain a buffer queue is constant

In reply to Coiby Xu

This patch is extented work of commit ec705b983b46b8e2d3cafd40c188458bf4241f11 ("staging: qlge: Remove qlge_bq.len & size"). Since the same len is used for both sbq (small buffer queue) and lbq (large buffer queue), the number of pages to contain a buffer queue is also known at compile time.

---
 drivers/staging/qlge/qlge.h      | 13 ++++++-------
 drivers/staging/qlge/qlge_main.c |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/staging/qlge/qlge.h +6 -7
index 9177baa9f022..32755b0e2fb7 100644
@@ -42,16 +42,15 @@
 
 #define DB_PAGE_SIZE 4096
 
-/* Calculate the number of (4k) pages required to
- * contain a buffer queue of the given length.
+/*
+ * The number of (4k) pages required to contain a buffer queue.
  */
-#define MAX_DB_PAGES_PER_BQ(x) \
-		(((x * sizeof(u64)) / DB_PAGE_SIZE) + \
-		(((x * sizeof(u64)) % DB_PAGE_SIZE) ? 1 : 0))
+#define MAX_DB_PAGES_PER_BQ \
+		(((QLGE_BQ_LEN * sizeof(u64)) / DB_PAGE_SIZE) + \
+		(((QLGE_BQ_LEN * sizeof(u64)) % DB_PAGE_SIZE) ? 1 : 0))
 
 #define RX_RING_SHADOW_SPACE	(sizeof(u64) + \
-		MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64) + \
-		MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64))
+		MAX_DB_PAGES_PER_BQ * sizeof(u64) * 2)
 #define LARGE_BUFFER_MAX_SIZE 4096
 #define LARGE_BUFFER_MIN_SIZE 2048
 
drivers/staging/qlge/qlge_main.c +4 -4
index 94853b182608..7aee9e904097 100644
@@ -3015,8 +3015,8 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		shadow_reg_dma += sizeof(u64);
 		rx_ring->lbq.base_indirect = shadow_reg;
 		rx_ring->lbq.base_indirect_dma = shadow_reg_dma;
-		shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN));
-		shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN));
+		shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ);
+		shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ);
 		rx_ring->sbq.base_indirect = shadow_reg;
 		rx_ring->sbq.base_indirect_dma = shadow_reg_dma;
 		/* PCI doorbell mem area + 0x18 for large buffer consumer */
@@ -3034,7 +3034,7 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
 			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN));
+		} while (page_entries < MAX_DB_PAGES_PER_BQ);
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
 		cqicb->lbq_buf_size =
 			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
@@ -3051,7 +3051,7 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
 			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN));
+		} while (page_entries < MAX_DB_PAGES_PER_BQ);
 		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
 		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
Signature · 1 line
2.32.0
author
#21 lore raw

RFC 12/19 staging: qlge: rewrite do while loops as for loops in qlge_start_rx_ring

In reply to Coiby Xu

Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while loop.

---
 drivers/staging/qlge/qlge_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/qlge/qlge_main.c +4 -6
index 7aee9e904097..c5e161595b1f 100644
@@ -3029,12 +3029,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->lbq.base_dma;
 		base_indirect_ptr = rx_ring->lbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
 		cqicb->lbq_buf_size =
 			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
@@ -3046,12 +3045,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->sbq.base_dma;
 		base_indirect_ptr = rx_ring->sbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
 		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
Signature · 1 line
2.32.0
#22 lore raw

Re: [RFC 12/19] staging: qlge: rewrite do while loops as for loops in qlge_start_rx_ring

Quoted 13 lines · Coiby Xu

Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while loop.

---
 drivers/staging/qlge/qlge_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/qlge/qlge_main.c +0 -0
index 7aee9e904097..c5e161595b1f 100644

drivers/staging/qlge/qlge_main.c static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq) · line 3031

Quoted 3 lines
drivers/staging/qlge/qlge_main.c +0 -0
@@ -3029,12 +3029,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->lbq.base_dma;
 		base_indirect_ptr = rx_ring->lbq.base_indirect;
 		page_entries = 0;

This initialization can be removed now. Same thing below.

Quoted 29 lines
drivers/staging/qlge/qlge_main.c +4 -6
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
 		cqicb->lbq_buf_size =
 			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
@@ -3046,12 +3045,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->sbq.base_dma;
 		base_indirect_ptr = rx_ring->sbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
 		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
Signature · 1 line
2.32.0
author
#23 lore raw

Re: [RFC 12/19] staging: qlge: rewrite do while loops as for loops in qlge_start_rx_ring

Quoted 9 lines · Benjamin Poirier
Quoted 8 lines · Coiby Xu

Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while loop.

---
 drivers/staging/qlge/qlge_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Quoted 10 lines

drivers/staging/qlge/qlge_main.c static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq) · line 3031

Quoted 8 lines
drivers/staging/qlge/qlge_main.c +0 -0
index 7aee9e904097..c5e161595b1f 100644
@@ -3029,12 +3029,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->lbq.base_dma;
 		base_indirect_ptr = rx_ring->lbq.base_indirect;
 		page_entries = 0;

This initialization can be removed now. Same thing below.

Yes, thanks for the suggestion!

Quoted 30 lines
Quoted 30 lines
drivers/staging/qlge/qlge_main.c +4 -7
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
 		cqicb->lbq_buf_size =
 			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
@@ -3046,12 +3045,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->sbq.base_dma;
 		base_indirect_ptr = rx_ring->sbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
 		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
--

2.32.0

Signature · 2 lines
Best regards,
Coiby
author
#24 lore raw

RFC 13/19 staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

In reply to Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

---
 drivers/staging/qlge/qlge_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/qlge/qlge_main.c +4 -3
index c5e161595b1f..2d2405be38f5 100644
@@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask)
 int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask)
 {
 	unsigned int wait_count = 30;
+	int count;
 
-	do {
+	for (count = 0; count < wait_count; count++) {
 		if (!qlge_sem_trylock(qdev, sem_mask))
 			return 0;
-		udelay(100);
-	} while (--wait_count);
+		udelay(UDELAY_DELAY);
+	}
 	return -ETIMEDOUT;
 }
 
Signature · 1 line
2.32.0
#25 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 15 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

---
 drivers/staging/qlge/qlge_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/qlge/qlge_main.c +0 -0
index c5e161595b1f..2d2405be38f5 100644
@@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask)
 int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask)
 {

drivers/staging/qlge/qlge_main.c static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask) · line 148

Quoted 10 lines
drivers/staging/qlge/qlge_main.c +3 -3
 	unsigned int wait_count = 30;
+	int count;
 
-	do {
+	for (count = 0; count < wait_count; count++) {
 		if (!qlge_sem_trylock(qdev, sem_mask))
 			return 0;
-		udelay(100);
-	} while (--wait_count);
+		udelay(UDELAY_DELAY);

This is an interesting way to silence the checkpatch udelay warning. ;)

regards,
dan carpenter

author
#26 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 19 lines · Dan Carpenter
Quoted 18 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

---
 drivers/staging/qlge/qlge_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/qlge/qlge_main.c +1 -0
index c5e161595b1f..2d2405be38f5 100644
@@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask)
 int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask)
 {
 	unsigned int wait_count = 30;
+	int count;
 
Quoted 9 lines

drivers/staging/qlge/qlge_main.c static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask) · line 148

Quoted 7 lines
drivers/staging/qlge/qlge_main.c +2 -3
-	do {
+	for (count = 0; count < wait_count; count++) {
 		if (!qlge_sem_trylock(qdev, sem_mask))
 			return 0;
-		udelay(100);
-	} while (--wait_count);
+		udelay(UDELAY_DELAY);

This is an interesting way to silence the checkpatch udelay warning. ;)

I didn't know this could silence the warning :)

Quoted 4 lines

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
#27 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 4 lines · Coiby Xu
Quoted 3 lines · Dan Carpenter
Quoted 2 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

[]

Quoted 1 line
Quoted 1 line

drivers/staging/qlge/qlge_main.c

Quoted 1 line
drivers/staging/qlge/qlge_main.c +0 -0

[]

Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
drivers/staging/qlge/qlge_main.c +1 -0
@@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask)
  int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask)
  {
  	unsigned int wait_count = 30;
+	int count;
 
Quoted 9 lines

drivers/staging/qlge/qlge_main.c static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask) · line 148

Quoted 7 lines
drivers/staging/qlge/qlge_main.c +2 -3
-	do {
+	for (count = 0; count < wait_count; count++) {
  		if (!qlge_sem_trylock(qdev, sem_mask))
  			return 0;
-		udelay(100);
-	} while (--wait_count);
+		udelay(UDELAY_DELAY);

This is an interesting way to silence the checkpatch udelay warning. ;)

Quoted 1 line

I didn't know this could silence the warning :)

It also seems odd to have unsigned int wait_count and int count.

Maybe just use 30 in the loop without using wait_count at all.

I also think using UDELAY_DELAY is silly and essentially misleading as it's also used as an argument value for mdelay

$ git grep -w UDELAY_DELAY
drivers/staging/qlge/qlge.h:#define UDELAY_DELAY 100
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY); /* 100ms */
author
#28 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 24 lines · Joe Perches
Quoted 4 lines · Coiby Xu
Quoted 3 lines · Dan Carpenter
Quoted 2 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

[]

Quoted 1 line
Quoted 1 line

drivers/staging/qlge/qlge_main.c

Quoted 1 line
drivers/staging/qlge/qlge_main.c +0 -0

[]

Quoted 16 lines
Quoted 15 lines

drivers/staging/qlge/qlge_main.c static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask) · line 148

Quoted 13 lines
drivers/staging/qlge/qlge_main.c +3 -3
@@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask)
  int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask)
  {
  	unsigned int wait_count = 30;
+	int count;
 
-	do {
+	for (count = 0; count < wait_count; count++) {
  		if (!qlge_sem_trylock(qdev, sem_mask))
  			return 0;
-		udelay(100);
-	} while (--wait_count);
+		udelay(UDELAY_DELAY);

This is an interesting way to silence the checkpatch udelay warning. ;)

Quoted 5 lines
Quoted 1 line

I didn't know this could silence the warning :)

It also seems odd to have unsigned int wait_count and int count.

Maybe just use 30 in the loop without using wait_count at all.

Thanks for the suggestion. I will apply it to v1.

Quoted 11 lines

I also think using UDELAY_DELAY is silly and essentially misleading as it's also used as an argument value for mdelay

$ git grep -w UDELAY_DELAY
drivers/staging/qlge/qlge.h:#define UDELAY_DELAY 100
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY); /* 100ms */

Thanks for spotting this issue! How about "#define MDELAY_DELAY 100" for mdelay?

Quoted 2 lines
Signature · 2 lines
Best regards,
Coiby
#29 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 20 lines · Coiby Xu
Quoted 11 lines · Joe Perches
Quoted 4 lines · Coiby Xu
Quoted 3 lines · Dan Carpenter
Quoted 2 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

[]

Quoted 1 line
Quoted 1 line

drivers/staging/qlge/qlge_main.c

Quoted 1 line
drivers/staging/qlge/qlge_main.c +0 -0

[]
I also think using UDELAY_DELAY is silly and essentially misleading as it's also used as an argument value for mdelay

Quoted 7 lines
$ git grep -w UDELAY_DELAY
drivers/staging/qlge/qlge.h:#define UDELAY_DELAY 100
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY); /* 100ms */
Quoted 2 lines

Thanks for spotting this issue! How about "#define MDELAY_DELAY 100" for mdelay?

I think the define is pointless and it'd be more readable to just use 100 in all the cases.

IMO: There really aren't enough cases to justify using defines.

author
#30 lore raw

Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock

Quoted 21 lines · Joe Perches
Quoted 20 lines · Coiby Xu
Quoted 18 lines · Joe Perches
Quoted 4 lines · Coiby Xu
Quoted 3 lines · Dan Carpenter
Quoted 2 lines · Coiby Xu

Since wait_count=30 > 0, the for loop is equivalent to do while loop. This commit also replaces 100 with UDELAY_DELAY.

[]

Quoted 1 line
Quoted 1 line

drivers/staging/qlge/qlge_main.c

Quoted 1 line
drivers/staging/qlge/qlge_main.c +0 -0

[]
I also think using UDELAY_DELAY is silly and essentially misleading as it's also used as an argument value for mdelay

$ git grep -w UDELAY_DELAY
drivers/staging/qlge/qlge.h:#define UDELAY_DELAY 100
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_main.c:               udelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY);
drivers/staging/qlge/qlge_mpi.c:                mdelay(UDELAY_DELAY); /* 100ms */
Quoted 7 lines
Quoted 2 lines

Thanks for spotting this issue! How about "#define MDELAY_DELAY 100" for mdelay?

I think the define is pointless and it'd be more readable to just use 100 in all the cases.

IMO: There really aren't enough cases to justify using defines.

I thought magic number should be avoided if possible. This case is new to me. Thanks for the explanation!

Quoted 2 lines
Signature · 2 lines
Best regards,
Coiby
author
#31 lore raw

RFC 14/19 staging: qlge: rewrite do while loop as for loop in qlge_refill_bq

In reply to Coiby Xu

Since refill_count > 0, the for loop is equivalent to do while loop.

---
 drivers/staging/qlge/qlge_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/qlge/qlge_main.c +3 -3
index 2d2405be38f5..904dba7aaee5 100644
@@ -1092,6 +1092,7 @@ static int qlge_refill_bq(struct qlge_bq *bq, gfp_t gfp)
 	struct qlge_bq_desc *bq_desc;
 	int refill_count;
 	int retval;
+	int count;
 	int i;
 
 	refill_count = QLGE_BQ_WRAP(QLGE_BQ_ALIGN(bq->next_to_clean - 1) -
@@ -1102,7 +1103,7 @@ static int qlge_refill_bq(struct qlge_bq *bq, gfp_t gfp)
 	i = bq->next_to_use;
 	bq_desc = &bq->queue[i];
 	i -= QLGE_BQ_LEN;
-	do {
+	for (count = 0; count < refill_count; count++) {
 		netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev,
 			     "ring %u %s: try cleaning idx %d\n",
 			     rx_ring->cq_id, bq_type_name[bq->type], i);
@@ -1124,8 +1125,7 @@ static int qlge_refill_bq(struct qlge_bq *bq, gfp_t gfp)
 			bq_desc = &bq->queue[0];
 			i -= QLGE_BQ_LEN;
 		}
-		refill_count--;
-	} while (refill_count);
+	}
 	i += QLGE_BQ_LEN;
 
 	if (bq->next_to_use != i) {
Signature · 1 line
2.32.0
author
#32 lore raw

RFC 15/19 staging: qlge: remove the TODO item about rewriting while loops as simple for loops

In reply to Coiby Xu

Since all while loops that could be written as simple for loops have been converted, remove the TODO item.

---
 drivers/staging/qlge/TODO | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 8bb6779a5bb4..4575f35114bf 100644
@@ -6,8 +6,6 @@
   split cases.
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
-* some "while" loops could be rewritten with simple "for", ex.
-  ql_wait_reg_rdy(), ql_start_rx_ring())
 * remove duplicate and useless comments
 * fix weird line wrapping (all over, ex. the ql_set_routing_reg() calls in
   qlge_set_multicast_list()).
Signature · 1 line
2.32.0
author
#33 lore raw

RFC 16/19 staging: qlge: remove deadcode in qlge_build_rx_skb

In reply to Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

---
 drivers/staging/qlge/TODO        |  6 ---
 drivers/staging/qlge/qlge_main.c | 66 ++++++++------------------------
 2 files changed, 17 insertions(+), 55 deletions(-)
drivers/staging/qlge/TODO +0 -6
index 4575f35114bf..0f96186ed77c 100644
@@ -1,9 +1,3 @@
-* commit 7c734359d350 ("qlge: Size RX buffers based on MTU.", v2.6.33-rc1)
-  introduced dead code in the receive routines, which should be rewritten
-  anyways by the admission of the author himself, see the comment above
-  ql_build_rx_skb(). That function is now used exclusively to handle packets
-  that underwent header splitting but it still contains code to handle non
-  split cases.
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
 * remove duplicate and useless comments
drivers/staging/qlge/qlge_main.c +17 -49

72 lines not on this page · raw message

Signature · 1 line
2.32.0
#34 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

regards,
dan carpenter

author
#35 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

Quoted 5 lines

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

Do you suggest moving to upper if, i.e.

        } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL && ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS) {

and then deleting the else statement?

Quoted 4 lines

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
#36 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 15 lines · Coiby Xu
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

Quoted 5 lines

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

Quoted 6 lines

Do you suggest moving to upper if, i.e.

        } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL && ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS) {

and then deleting the else statement?

I have a rule that when people whinge about commit messages they should write a better one themselves, but I have violated my own rule. Sorry. Here is my suggestion:

If the "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" condition is true then we know that "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" must be true as well. Thus, we can remove that condition and delete the else statement which is dead code.

(Originally this code was for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting).

TBH, I don't know the code well enough to understand the second paragraph but the first paragraph is straight forward.

regards,
dan carpenter

author
#37 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 27 lines · Dan Carpenter
Quoted 15 lines · Coiby Xu
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

Quoted 5 lines

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

Quoted 6 lines

Do you suggest moving to upper if, i.e.

        } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL && ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS) {

and then deleting the else statement?

I have a rule that when people whinge about commit messages they should write a better one themselves, but I have violated my own rule. Sorry. Here is my suggestion:

Quoted 8 lines

If the "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" condition is true then we know that "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" must be true as well. Thus, we can remove that condition and delete the else statement which is dead code.

(Originally this code was for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting).

Thanks for sharing your commit message! Now I see what you mean. But I'm
not sure if "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" is true when "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" is true. We only know that the head splitting case is exclusively dealt with by the function qlge_process_mac_split_rx_intr,

    /* Process an inbound completion from an rx ring. */
    static unsigned long qlge_process_mac_rx_intr(struct qlge_adapter *qdev,
    					      struct rx_ring *rx_ring,
    					      struct qlge_ib_mac_iocb_rsp *ib_mac_rsp)
    {
        ...   
    	if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
    		/* The data and headers are split into
    		 * separate buffers.
    		 */
    		qlge_process_mac_split_rx_intr(qdev, rx_ring, ib_mac_rsp,
    					       vlan_id);
    	} else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS) {

And skb_build_skb is only called by qlge_build_rx_skb. So this part of code that deals with the packets that don't go through head splitting must be dead code. And the test that ping the NIC with packets of different sizes could also confirm it.

Quoted 6 lines

TBH, I don't know the code well enough to understand the second paragraph but the first paragraph is straight forward.

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
#38 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 33 lines · Coiby Xu
Quoted 32 lines · Dan Carpenter
Quoted 15 lines · Coiby Xu
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

Quoted 5 lines

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

Quoted 6 lines

Do you suggest moving to upper if, i.e.

        } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL && ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS) {

and then deleting the else statement?

I have a rule that when people whinge about commit messages they should write a better one themselves, but I have violated my own rule. Sorry. Here is my suggestion:

If the "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" condition is true then we know that "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" must be true as well. Thus, we can remove that condition and delete the else statement which is dead code.

Quoted 7 lines
Quoted 3 lines

(Originally this code was for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting).

Thanks for sharing your commit message! Now I see what you mean. But I'm not sure if "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" is true when "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" is true.

Well... It is true. qlge_process_mac_split_rx_intr() is only called when "->flags4 & IB_MAC_IOCB_RSP_HS" is true or when "->flags3 & IB_MAC_IOCB_RSP_DL" is false.

To me the fact that it's clearly dead code, helps me to verify that the patch doesn't change behavior. Anyway, "this part of code" was a bit vague and it took me a while to figure out the patch deletes the else statement.

regards,
dan carpenter

author
#39 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 38 lines · Dan Carpenter
Quoted 37 lines · Coiby Xu
Quoted 35 lines · Dan Carpenter
Quoted 15 lines · Coiby Xu
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Coiby Xu

This part of code is for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting. In reality, with jumbo frame enabled, the part of code couldn't be reached regardless of the packet size when ping the NIC.

Quoted 5 lines

This commit message is a bit confusing. We're just deleting the else statement. Once I knew that then it was easy enough to review qlge_process_mac_rx_intr() and see that if if ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL is set then ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV must be set.

Quoted 6 lines

Do you suggest moving to upper if, i.e.

        } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL && ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS) {

and then deleting the else statement?

I have a rule that when people whinge about commit messages they should write a better one themselves, but I have violated my own rule. Sorry. Here is my suggestion:

If the "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" condition is true then we know that "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" must be true as well. Thus, we can remove that condition and delete the else statement which is dead code.

(Originally this code was for the case that "the headers and data are in a single large buffer". However, qlge_process_mac_split_rx_intr is for handling packets that packets underwent head splitting).

Quoted 7 lines
Quoted 3 lines

Thanks for sharing your commit message! Now I see what you mean. But I'm not sure if "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" is true when "ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL" is true.

Well... It is true. qlge_process_mac_split_rx_intr() is only called when "->flags4 & IB_MAC_IOCB_RSP_HS" is true or when "->flags3 & IB_MAC_IOCB_RSP_DL" is false.

Actually qlge_process_mac_rx_intr calls qlge_process_mac_split_rx_intr when "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV" is true or in the last else,

    /* Process an inbound completion from an rx ring. */
    static unsigned long qlge_process_mac_rx_intr(struct qlge_adapter *qdev,
    					      struct rx_ring *rx_ring,
    					      struct qlge_ib_mac_iocb_rsp *ib_mac_rsp)
    {
        ...
    	if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
    		/* The data and headers are split into
    		 * separate buffers.
    		 */
    		qlge_process_mac_split_rx_intr(qdev, rx_ring, ib_mac_rsp,
    					       vlan_id);
    	} else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS) {
            ...
    	} else {
    		/* Non-TCP/UDP large frames that span multiple buffers
    		 * can be processed corrrectly by the split frame logic.
    		 */
    		qlge_process_mac_split_rx_intr(qdev, rx_ring, ib_mac_rsp,
    					       vlan_id);
    	}

So I think we can't say that if "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV" is true, then "ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS" must be true. And I don't know how to reach the conclusion that the last else means "->flags3 & IB_MAC_IOCB_RSP_DL" is false.

Quoted 9 lines

To me the fact that it's clearly dead code, helps me to verify that the patch doesn't change behavior. Anyway, "this part of code" was a bit vague and it took me a while to figure out the patch deletes the else statement.

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
#40 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

*sigh*

You're right. Sorry.

I misread IB_MAC_IOCB_RSP_HV as IB_MAC_IOCB_RSP_HS. In my defense, it's a five word name and only one letter is different. It's like trying to find Waldo.

regards,
dan carpenter

author
#41 lore raw

Re: [RFC 16/19] staging: qlge: remove deadcode in qlge_build_rx_skb

Quoted 7 lines · Dan Carpenter

*sigh*

You're right. Sorry.

I misread IB_MAC_IOCB_RSP_HV as IB_MAC_IOCB_RSP_HS. In my defense, it's a five word name and only one letter is different. It's like trying to find Waldo.

That's fine. Thanks for reviewing the patch and prompting me to write a more comprehensible commit message!

Quoted 4 lines

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
author
#42 lore raw

RFC 17/19 staging: qlge: fix weird line wrapping

In reply to Coiby Xu

This commits fix weird line wrapping based on "clang-format drivers/staging/qlge/qlge_main.c"

---
 drivers/staging/qlge/TODO        |   2 -
 drivers/staging/qlge/qlge_main.c | 106 +++++++++++++++----------------
 2 files changed, 52 insertions(+), 56 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 0f96186ed77c..b8def0c70614 100644
@@ -1,7 +1,5 @@
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
 * remove duplicate and useless comments
-* fix weird line wrapping (all over, ex. the ql_set_routing_reg() calls in
-  qlge_set_multicast_list()).
 * fix weird indentation (all over, ex. the for loops in qlge_get_stats())
 * fix checkpatch issues
drivers/staging/qlge/qlge_main.c +52 -54

272 lines not on this page · raw message

Signature · 1 line
2.32.0
#43 lore raw

Re: [RFC 17/19] staging: qlge: fix weird line wrapping

drivers/staging/qlge/qlge_main.c static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask, · line 527

Quoted 8 lines · Coiby Xu
drivers/staging/qlge/qlge_main.c +2 -2
@@ -524,8 +523,8 @@ static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask,
 		{
 			value = RT_IDX_DST_DFLT_Q | /* dest */
 				RT_IDX_TYPE_NICQ | /* type */
-				(RT_IDX_IP_CSUM_ERR_SLOT <<
-				RT_IDX_IDX_SHIFT); /* index */
+			(RT_IDX_IP_CSUM_ERR_SLOT
+			 << RT_IDX_IDX_SHIFT); /* index */

The original is not great but the new indenting is definitely worse. It might look nicer with the comments moved in the front? Why does RT_IDX_IDX_SHIFT have two IDX strings?

			/* value = dest | type | index; */
			value = RT_IDX_DST_DFLT_Q |
				RT_IDX_TYPE_NICQ  |
				(RT_IDX_IP_CSUM_ERR_SLOT << RT_IDX_IDX_SHIFT);

drivers/staging/qlge/qlge_main.c static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask, · line 557

Quoted 10 lines
drivers/staging/qlge/qlge_main.c +2 -1
 			break;
 		}
 	case RT_IDX_TU_CSUM_ERR: /* Pass up TCP/UDP CSUM error frames. */
@@ -554,7 +553,8 @@ static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask,
 		{
 			value = RT_IDX_DST_DFLT_Q |	/* dest */
 			    RT_IDX_TYPE_NICQ |	/* type */
-			    (RT_IDX_MCAST_MATCH_SLOT << RT_IDX_IDX_SHIFT);/* index */
+			(RT_IDX_MCAST_MATCH_SLOT
+			 << RT_IDX_IDX_SHIFT); /* index */

Original is better.

Quoted 35 lines
drivers/staging/qlge/qlge_main.c +6 -6
 			break;
 		}
 	case RT_IDX_RSS_MATCH:	/* Pass up matched RSS frames. */
@@ -648,15 +648,15 @@ static int qlge_read_flash_word(struct qlge_adapter *qdev, int offset, __le32 *d
 {
 	int status = 0;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR);
+	status = qlge_wait_reg_rdy(qdev, FLASH_ADDR, FLASH_ADDR_RDY,
+				   FLASH_ADDR_ERR);
 	if (status)
 		goto exit;
 	/* set up for reg read */
 	qlge_write32(qdev, FLASH_ADDR, FLASH_ADDR_R | offset);
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR);
+	status = qlge_wait_reg_rdy(qdev, FLASH_ADDR, FLASH_ADDR_RDY,
+				   FLASH_ADDR_ERR);
 	if (status)
 		goto exit;
 	/* This data is stored on flash as an array of
@@ -792,8 +792,8 @@ static int qlge_write_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 data)
 {
 	int status;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);
 	if (status)
 		return status;
 	/* write the data to the data reg */

drivers/staging/qlge/qlge_main.c int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data) · line 815

Quoted 7 lines
drivers/staging/qlge/qlge_main.c +2 -2
@@ -811,15 +811,15 @@ int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data)
 {
 	int status = 0;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);

Need a blank line after the declaration block.

drivers/staging/qlge/qlge_main.c int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data) · line 825

Quoted 12 lines
drivers/staging/qlge/qlge_main.c +2 -2
 	if (status)
 		goto exit;
 	/* set up for reg read */
 	qlge_write32(qdev, XGMAC_ADDR, reg | XGMAC_ADDR_R);
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);
 	if (status)
 		goto exit;
 	/* get the data */

regards,
dan carpenter

author
#44 lore raw

Re: [RFC 17/19] staging: qlge: fix weird line wrapping

Quoted 13 lines · Dan Carpenter

drivers/staging/qlge/qlge_main.c static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask, · line 527

Quoted 8 lines · Coiby Xu
drivers/staging/qlge/qlge_main.c +2 -2
@@ -524,8 +523,8 @@ static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask,
 		{
 			value = RT_IDX_DST_DFLT_Q | /* dest */
 				RT_IDX_TYPE_NICQ | /* type */
-				(RT_IDX_IP_CSUM_ERR_SLOT <<
-				RT_IDX_IDX_SHIFT); /* index */
+			(RT_IDX_IP_CSUM_ERR_SLOT
+			 << RT_IDX_IDX_SHIFT); /* index */

The original is not great but the new indenting is definitely worse. It might look nicer with the comments moved in the front? Why does RT_IDX_IDX_SHIFT have two IDX strings?

I'm not sure about it. Two IDX strings seems to be a typo.

Quoted 6 lines
			/* value = dest | type | index; */
			value = RT_IDX_DST_DFLT_Q |
				RT_IDX_TYPE_NICQ  |
				(RT_IDX_IP_CSUM_ERR_SLOT << RT_IDX_IDX_SHIFT);

This looks better! Thanks!

Quoted 13 lines

drivers/staging/qlge/qlge_main.c static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask, · line 557

Quoted 11 lines
drivers/staging/qlge/qlge_main.c +2 -1
 			break;
 		}
 	case RT_IDX_TU_CSUM_ERR: /* Pass up TCP/UDP CSUM error frames. */
@@ -554,7 +553,8 @@ static int qlge_set_routing_reg(struct qlge_adapter *qdev, u32 index, u32 mask,
 		{
 			value = RT_IDX_DST_DFLT_Q |	/* dest */
 			    RT_IDX_TYPE_NICQ |	/* type */
-			    (RT_IDX_MCAST_MATCH_SLOT << RT_IDX_IDX_SHIFT);/* index */
+			(RT_IDX_MCAST_MATCH_SLOT
+			 << RT_IDX_IDX_SHIFT); /* index */

Original is better.

I'll also move the comments in the front.

Quoted 37 lines
Quoted 37 lines
drivers/staging/qlge/qlge_main.c +6 -6
 			break;
 		}
 	case RT_IDX_RSS_MATCH:	/* Pass up matched RSS frames. */
@@ -648,15 +648,15 @@ static int qlge_read_flash_word(struct qlge_adapter *qdev, int offset, __le32 *d
 {
 	int status = 0;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR);
+	status = qlge_wait_reg_rdy(qdev, FLASH_ADDR, FLASH_ADDR_RDY,
+				   FLASH_ADDR_ERR);
 	if (status)
 		goto exit;
 	/* set up for reg read */
 	qlge_write32(qdev, FLASH_ADDR, FLASH_ADDR_R | offset);
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR);
+	status = qlge_wait_reg_rdy(qdev, FLASH_ADDR, FLASH_ADDR_RDY,
+				   FLASH_ADDR_ERR);
 	if (status)
 		goto exit;
 	/* This data is stored on flash as an array of
@@ -792,8 +792,8 @@ static int qlge_write_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 data)
 {
 	int status;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);
 	if (status)
 		return status;
 	/* write the data to the data reg */
@@ -811,15 +811,15 @@ int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data)
 {
Quoted 8 lines

drivers/staging/qlge/qlge_main.c int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data) · line 815

Quoted 6 lines
drivers/staging/qlge/qlge_main.c +2 -2
 	int status = 0;
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);

Need a blank line after the declaration block.

Sure, I will fix it in next version.

Quoted 16 lines

drivers/staging/qlge/qlge_main.c int qlge_read_xgmac_reg(struct qlge_adapter *qdev, u32 reg, u32 *data) · line 825

Quoted 13 lines
drivers/staging/qlge/qlge_main.c +2 -2
 	if (status)
 		goto exit;
 	/* set up for reg read */
 	qlge_write32(qdev, XGMAC_ADDR, reg | XGMAC_ADDR_R);
 	/* wait for reg to come ready */
-	status = qlge_wait_reg_rdy(qdev,
-				   XGMAC_ADDR, XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
+	status = qlge_wait_reg_rdy(qdev, XGMAC_ADDR, XGMAC_ADDR_RDY,
+				   XGMAC_ADDR_XME);
 	if (status)
 		goto exit;
 	/* get the data */

regards,
dan carpenter

Signature · 2 lines
Best regards,
Coiby
author
#45 lore raw

RFC 18/19 staging: qlge: fix two indentation issues

In reply to Coiby Xu

Fix two indentation issues.

---
 drivers/staging/qlge/TODO        |  1 -
 drivers/staging/qlge/qlge_dbg.c  | 30 +++++++++++++++---------------
 drivers/staging/qlge/qlge_main.c |  4 ++--
 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/qlge/TODO +0 -1
index b8def0c70614..7e466a0f7771 100644
@@ -1,5 +1,4 @@
 * the driver has a habit of using runtime checks where compile time checks are
   possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
 * remove duplicate and useless comments
-* fix weird indentation (all over, ex. the for loops in qlge_get_stats())
 * fix checkpatch issues
drivers/staging/qlge/qlge_dbg.c +15 -15
index d093e6c9f19c..d4d486f99549 100644
@@ -353,21 +353,21 @@ static int qlge_get_xgmac_regs(struct qlge_adapter *qdev, u32 *buf,
 		 */
 		if ((i == 0x00000114) ||
 		    (i == 0x00000118) ||
-			(i == 0x0000013c) ||
-			(i == 0x00000140) ||
-			(i > 0x00000150 && i < 0x000001fc) ||
-			(i > 0x00000278 && i < 0x000002a0) ||
-			(i > 0x000002c0 && i < 0x000002cf) ||
-			(i > 0x000002dc && i < 0x000002f0) ||
-			(i > 0x000003c8 && i < 0x00000400) ||
-			(i > 0x00000400 && i < 0x00000410) ||
-			(i > 0x00000410 && i < 0x00000420) ||
-			(i > 0x00000420 && i < 0x00000430) ||
-			(i > 0x00000430 && i < 0x00000440) ||
-			(i > 0x00000440 && i < 0x00000450) ||
-			(i > 0x00000450 && i < 0x00000500) ||
-			(i > 0x0000054c && i < 0x00000568) ||
-			(i > 0x000005c8 && i < 0x00000600)) {
+		    (i == 0x0000013c) ||
+		    (i == 0x00000140) ||
+		    (i > 0x00000150 && i < 0x000001fc) ||
+		    (i > 0x00000278 && i < 0x000002a0) ||
+		    (i > 0x000002c0 && i < 0x000002cf) ||
+		    (i > 0x000002dc && i < 0x000002f0) ||
+		    (i > 0x000003c8 && i < 0x00000400) ||
+		    (i > 0x00000400 && i < 0x00000410) ||
+		    (i > 0x00000410 && i < 0x00000420) ||
+		    (i > 0x00000420 && i < 0x00000430) ||
+		    (i > 0x00000430 && i < 0x00000440) ||
+		    (i > 0x00000440 && i < 0x00000450) ||
+		    (i > 0x00000450 && i < 0x00000500) ||
+		    (i > 0x0000054c && i < 0x00000568) ||
+		    (i > 0x000005c8 && i < 0x00000600)) {
 			if (other_function)
 				status =
 				qlge_read_other_func_xgmac_reg(qdev, i, buf);
drivers/staging/qlge/qlge_main.c +2 -2
index 21fb942c2595..7cec2d6c3fea 100644
@@ -699,8 +699,8 @@ static int qlge_get_8000_flash_params(struct qlge_adapter *qdev)
 
 	status = qlge_validate_flash(qdev,
 				     sizeof(struct flash_params_8000) /
-				   sizeof(u16),
-				   "8000");
+				       sizeof(u16),
+				     "8000");
 	if (status) {
 		netif_err(qdev, ifup, qdev->ndev, "Invalid flash.\n");
 		status = -EINVAL;
Signature · 1 line
2.32.0
author
#46 lore raw

RFC 19/19 staging: qlge: remove TODO item of unnecessary runtime checks

In reply to Coiby Xu

The following commits [1],

- e4c911a73c89 ("staging: qlge: Remove rx_ring.type")
- a68a5b2fd3a2 ("staging: qlge: Remove bq_desc.maplen")
- 16714d98bf63 ("staging: qlge: Remove rx_ring.sbq_buf_size")
- ec705b983b46 ("staging: qlge: Remove qlge_bq.len & size")

and recent "commit a0e57b58d35d3d6808187bb10ee9e5030ff87618 ("staging: qlge: the number of pages to contain a buffer queue is
constant") has fixed issue. Thus remove the TODO item.

[1] https://lore.kernel.org/netdev/YJeUZo+zoNZmFuKs@f3/

---
 drivers/staging/qlge/TODO | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/qlge/TODO +0 -2
index 7e466a0f7771..0e349ffc630e 100644
@@ -1,4 +1,2 @@
-* the driver has a habit of using runtime checks where compile time checks are
-  possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
 * remove duplicate and useless comments
 * fix checkpatch issues
Signature · 1 line
2.32.0