Skip to contentSkip to conversation

cxgbe: Optimize tx/rx for 40GbE and add Jumbo Frame support for CXGBE PMD

PATCH Superseded Rahul Lakkireddy 4 participants 23 messages Oct 2, 2015 – Oct 21, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

cover cxgbe: Optimize tx/rx for 40GbE and add Jumbo Frame support for CXGBE PMD

This series of patches improve forwarding performance for Chelsio T5 40GbE cards and add Jumbo Frame support for cxgbe pmd. Also update documentation and release notes.

Rahul Lakkireddy (6):
cxgbe: Optimize forwarding performance for 40G
cxgbe: Update device info and perform sanity checks to enable jumbo
frames
cxgbe: Update tx path to transmit jumbo frames
cxgbe: Update rx path to receive jumbo frames
cxgbe: Allow apps to change mtu
doc: Update cxgbe documentation and release notes

 doc/guides/nics/cxgbe.rst            |  81 ++++++++++++-----
 doc/guides/rel_notes/release_2_2.rst |   5 +
 drivers/net/cxgbe/base/t4_regs.h     |  16 ++++
 drivers/net/cxgbe/cxgbe.h            |   3 +
 drivers/net/cxgbe/cxgbe_ethdev.c     |  52 ++++++++++-
 drivers/net/cxgbe/cxgbe_main.c       |  10 +-
 drivers/net/cxgbe/sge.c              | 171 ++++++++++++++++++++++++++---------
 7 files changed, 268 insertions(+), 70 deletions(-)
Signature · 1 line
2.5.3
#1 lore raw

PATCH 1/6 cxgbe: Optimize forwarding performance for 40G

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

Approx. 4 MPPS improvement seen in forwarding performance after the optimization.

---
 drivers/net/cxgbe/base/t4_regs.h | 16 ++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c   |  7 +++++++
 drivers/net/cxgbe/sge.c          | 17 ++++++++++++-----
 3 files changed, 35 insertions(+), 5 deletions(-)
drivers/net/cxgbe/base/t4_regs.h +16 -0
index cd28b59..9057e40 100644
@@ -266,6 +266,18 @@
 #define A_SGE_FL_BUFFER_SIZE2 0x104c
 #define A_SGE_FL_BUFFER_SIZE3 0x1050
 
+#define A_SGE_FLM_CFG 0x1090
+
+#define S_CREDITCNT    4
+#define M_CREDITCNT    0x3U
+#define V_CREDITCNT(x) ((x) << S_CREDITCNT)
+#define G_CREDITCNT(x) (((x) >> S_CREDITCNT) & M_CREDITCNT)
+
+#define S_CREDITCNTPACKING    2
+#define M_CREDITCNTPACKING    0x3U
+#define V_CREDITCNTPACKING(x) ((x) << S_CREDITCNTPACKING)
+#define G_CREDITCNTPACKING(x) (((x) >> S_CREDITCNTPACKING) & M_CREDITCNTPACKING)
+
 #define A_SGE_CONM_CTRL 0x1094
 
 #define S_EGRTHRESHOLD    8
@@ -361,6 +373,10 @@
 
 #define A_SGE_CONTROL2 0x1124
 
+#define S_IDMAARBROUNDROBIN    19
+#define V_IDMAARBROUNDROBIN(x) ((x) << S_IDMAARBROUNDROBIN)
+#define F_IDMAARBROUNDROBIN    V_IDMAARBROUNDROBIN(1U)
+
 #define S_INGPACKBOUNDARY    16
 #define M_INGPACKBOUNDARY    0x7U
 #define V_INGPACKBOUNDARY(x) ((x) << S_INGPACKBOUNDARY)
drivers/net/cxgbe/cxgbe_main.c +7 -0
index 3755444..316b87d 100644
@@ -422,6 +422,13 @@ static int adap_init0_tweaks(struct adapter *adapter)
 	t4_set_reg_field(adapter, A_SGE_CONTROL, V_PKTSHIFT(M_PKTSHIFT),
 			 V_PKTSHIFT(rx_dma_offset));
 
+	t4_set_reg_field(adapter, A_SGE_FLM_CFG,
+			 V_CREDITCNT(M_CREDITCNT) | M_CREDITCNTPACKING,
+			 V_CREDITCNT(3) | V_CREDITCNTPACKING(1));
+
+	t4_set_reg_field(adapter, A_SGE_CONTROL2, V_IDMAARBROUNDROBIN(1U),
+			 V_IDMAARBROUNDROBIN(1U));
+
 	/*
 	 * Don't include the "IP Pseudo Header" in CPL_RX_PKT checksums: Linux
 	 * adds the pseudo header itself.
drivers/net/cxgbe/sge.c +12 -5
index 6eb1244..e540881 100644
@@ -286,8 +286,7 @@ static void unmap_rx_buf(struct sge_fl *q)
 
 static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
 {
-	/* see if we have exceeded q->size / 4 */
-	if (q->pend_cred >= (q->size / 4)) {
+	if (q->pend_cred >= 64) {
 		u32 val = adap->params.arch.sge_fl_db;
 
 		if (is_t4(adap->params.chip))
@@ -995,7 +994,14 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq,
 			int i;
 
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;
 			}
 		}
@@ -1054,7 +1060,6 @@ out_free:
 		return 0;
 	}
 
-	rte_prefetch0(&((&txq->q)->sdesc->mbuf->pool));
 	pi = (struct port_info *)txq->eth_dev->data->dev_private;
 	adap = pi->adapter;
 
@@ -1070,6 +1075,7 @@ out_free:
 				txq->stats.mapping_err++;
 				goto out_free;
 			}
+			rte_prefetch0((volatile void *)addr);
 			return tx_do_packet_coalesce(txq, mbuf, cflits, adap,
 						     pi, addr);
 		} else {
@@ -1454,7 +1460,8 @@ static int process_responses(struct sge_rspq *q, int budget,
 			unsigned int params;
 			u32 val;
 
-			__refill_fl(q->adapter, &rxq->fl);
+			if (fl_cap(&rxq->fl) - rxq->fl.avail >= 64)
+				__refill_fl(q->adapter, &rxq->fl);
 			params = V_QINTR_TIMER_IDX(X_TIMERREG_UPDATE_CIDX);
 			q->next_intr_params = params;
 			val = V_CIDXINC(cidx_inc) | V_SEINTARM(params);
Signature · 1 line
2.5.3
#2 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Rahul,

Quoted 3 lines · Rahul Lakkireddy

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

<<snip>>

drivers/net/cxgbe/sge.c static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, · line 1005

Quoted 11 lines
drivers/net/cxgbe/sge.c +8 -1
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;

Pardon my ignorance here, but rte_pktmbuf_free does this work. I can't actually see much difference between your rewrite of this block, and the implementation of rte_pktmbuf_free() (apart from moving your branch to the end of the function). Did your microbenchmarking really show this as an improvement?

Thanks for your time,
Aaron

#3 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Aaron,

Quoted 25 lines · Aaron Conole

Hi Rahul,

Quoted 3 lines · Rahul Lakkireddy

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

<<snip>>

drivers/net/cxgbe/sge.c static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, · line 1005

Quoted 11 lines
drivers/net/cxgbe/sge.c +8 -1
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;

Pardon my ignorance here, but rte_pktmbuf_free does this work. I can't actually see much difference between your rewrite of this block, and the implementation of rte_pktmbuf_free() (apart from moving your branch to the end of the function). Did your microbenchmarking really show this as an improvement?

Quoted 2 lines

Thanks for your time,
Aaron

rte_pktmbuf_free calls rte_mbuf_sanity_check which does a lot of checks. This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

The forwarding perf. improvement with only this particular block is around 1 Mpps for 64B packets when using l3fwd with 8 queues.

Thanks,
Rahul

#4 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Rahul Lakkireddy
Sent: Monday, October 05, 2015 11:06 AM
To: Aaron Conole
Cc: [email protected]; Felix Marti; Kumar A S; Nirranjan Kirubaharan
Subject: Re: [dpdk-dev] [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Aaron,

Quoted 25 lines · Aaron Conole

Hi Rahul,

Quoted 3 lines · Rahul Lakkireddy

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

<<snip>>

drivers/net/cxgbe/sge.c static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, · line 1005

Quoted 11 lines
drivers/net/cxgbe/sge.c +8 -1
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;

Pardon my ignorance here, but rte_pktmbuf_free does this work. I can't actually see much difference between your rewrite of this block, and the implementation of rte_pktmbuf_free() (apart from moving your branch to the end of the function). Did your microbenchmarking really show this as an improvement?

Quoted 5 lines
Quoted 2 lines

Thanks for your time,
Aaron

rte_pktmbuf_free calls rte_mbuf_sanity_check which does a lot of checks.

Only when RTE_LIBRTE_MBUF_DEBUG is enabled in your config. By default it is switched off.

Quoted 5 lines

This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

Other PMDs use rte_pktmbuf_free_seg() as each TD has an associated with it segment. So as HW is done with the TD, SW frees associated segment. In your case I don't see any point in re-implementing rte_pktmbuf_free() manually, and I don't think it would be any faster.

Konstantin

Quoted 6 lines

The forwarding perf. improvement with only this particular block is around 1 Mpps for 64B packets when using l3fwd with 8 queues.

Thanks,
Rahul

#5 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Konstantin,

Quoted 37 lines · Konstantin
Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Rahul Lakkireddy
Sent: Monday, October 05, 2015 11:06 AM
To: Aaron Conole
Cc: [email protected]; Felix Marti; Kumar A S; Nirranjan Kirubaharan
Subject: Re: [dpdk-dev] [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Aaron,

Quoted 25 lines · Aaron Conole

Hi Rahul,

Quoted 3 lines · Rahul Lakkireddy

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

<<snip>>

drivers/net/cxgbe/sge.c static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, · line 1005

Quoted 11 lines
drivers/net/cxgbe/sge.c +8 -1
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;

Pardon my ignorance here, but rte_pktmbuf_free does this work. I can't actually see much difference between your rewrite of this block, and the implementation of rte_pktmbuf_free() (apart from moving your branch to the end of the function). Did your microbenchmarking really show this as an improvement?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks for your time,
Aaron

rte_pktmbuf_free calls rte_mbuf_sanity_check which does a lot of checks.

Only when RTE_LIBRTE_MBUF_DEBUG is enabled in your config. By default it is switched off.

Right. I clearly missed this.
I am running with default config only btw.

Quoted 7 lines
Quoted 6 lines

This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

Quoted 6 lines

Other PMDs use rte_pktmbuf_free_seg() as each TD has an associated with it segment. So as HW is done with the TD, SW frees associated segment. In your case I don't see any point in re-implementing rte_pktmbuf_free() manually, and I don't think it would be any faster.

Konstantin

As I mentioned below, I am clearly seeing a difference of 1 Mpps. And 1 Mpps is not a small difference IMHO.

When running l3fwd with 8 queues, I also collected a perf report. When using rte_pktmbuf_free, I see that it eats up around 6% cpu as below in perf top report:-
--------------------

32.00%  l3fwd                        [.] cxgbe_poll
22.25%  l3fwd                        [.] t4_eth_xmit
20.30%  l3fwd                        [.] main_loop
 6.77%  l3fwd                        [.] rte_pktmbuf_free
 4.86%  l3fwd                        [.] refill_fl_usembufs
 2.00%  l3fwd                        [.] write_sgl

.....
--------------------

While, when using rte_pktmbuf_free_seg directly, I don't see above problem. perf top report now comes as:-
-------------------

33.36%  l3fwd                        [.] cxgbe_poll
32.69%  l3fwd                        [.] t4_eth_xmit
19.05%  l3fwd                        [.] main_loop
 5.21%  l3fwd                        [.] refill_fl_usembufs
 2.40%  l3fwd                        [.] write_sgl

....
-------------------

I obviously missed the debug flag for rte_mbuf_sanity_check. However, there is a clear difference of 1 Mpps. I don't know if its the change between while construct used in rte_pktmbuf_free and the do..while construct that I used - is making the difference.

Quoted 7 lines
Quoted 7 lines

The forwarding perf. improvement with only this particular block is around 1 Mpps for 64B packets when using l3fwd with 8 queues.

Thanks,
Rahul

#6 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Rahul,

Quoted 71 lines

-----Original Message-----
From: Rahul Lakkireddy [mailto:[email protected]]
Sent: Monday, October 05, 2015 1:42 PM
To: Ananyev, Konstantin
Cc: Aaron Conole; [email protected]; Felix Marti; Kumar A S; Nirranjan Kirubaharan
Subject: Re: [dpdk-dev] [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Konstantin,

Quoted 37 lines · Konstantin
Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Rahul Lakkireddy
Sent: Monday, October 05, 2015 11:06 AM
To: Aaron Conole
Cc: [email protected]; Felix Marti; Kumar A S; Nirranjan Kirubaharan
Subject: Re: [dpdk-dev] [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Hi Aaron,

Quoted 25 lines · Aaron Conole

Hi Rahul,

Quoted 3 lines · Rahul Lakkireddy

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch and free.

<<snip>>

drivers/net/cxgbe/sge.c static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, · line 1005

Quoted 11 lines
drivers/net/cxgbe/sge.c +8 -1
 			for (i = 0; i < sd->coalesce.idx; i++) {
-				rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+				struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+				do {
+					struct rte_mbuf *next = tmp->next;
+
+					rte_pktmbuf_free_seg(tmp);
+					tmp = next;
+				} while (tmp);
 				sd->coalesce.mbuf[i] = NULL;

Pardon my ignorance here, but rte_pktmbuf_free does this work. I can't actually see much difference between your rewrite of this block, and the implementation of rte_pktmbuf_free() (apart from moving your branch to the end of the function). Did your microbenchmarking really show this as an improvement?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks for your time,
Aaron

rte_pktmbuf_free calls rte_mbuf_sanity_check which does a lot of checks.

Only when RTE_LIBRTE_MBUF_DEBUG is enabled in your config. By default it is switched off.

Right. I clearly missed this.
I am running with default config only btw.

Quoted 12 lines
Quoted 6 lines

This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

Other PMDs use rte_pktmbuf_free_seg() as each TD has an associated with it segment. So as HW is done with the TD, SW frees associated segment. In your case I don't see any point in re-implementing rte_pktmbuf_free() manually, and I don't think it would be any faster.

Quoted 4 lines
Quoted 1 line

Konstantin

As I mentioned below, I am clearly seeing a difference of 1 Mpps. And 1 Mpps is not a small difference IMHO.

Agree with you here - it is a significant difference.

Quoted 17 lines

When running l3fwd with 8 queues, I also collected a perf report. When using rte_pktmbuf_free, I see that it eats up around 6% cpu as below in perf top report:-
--------------------

32.00%  l3fwd                        [.] cxgbe_poll
22.25%  l3fwd                        [.] t4_eth_xmit
20.30%  l3fwd                        [.] main_loop
 6.77%  l3fwd                        [.] rte_pktmbuf_free
 4.86%  l3fwd                        [.] refill_fl_usembufs
 2.00%  l3fwd                        [.] write_sgl

.....
--------------------

While, when using rte_pktmbuf_free_seg directly, I don't see above problem. perf top report now comes as:-
-------------------

Quoted 7 lines
33.36%  l3fwd                        [.] cxgbe_poll
32.69%  l3fwd                        [.] t4_eth_xmit
19.05%  l3fwd                        [.] main_loop
 5.21%  l3fwd                        [.] refill_fl_usembufs
 2.40%  l3fwd                        [.] write_sgl

....
-------------------

I don't think these 6% disappeared anywhere.
As I can see, now t4_eth_xmit() increased by roughly same amount
(you still have same job to do).
To me it looks like in that case compiler didn't really inline rte_pktmbuf_free(). Wonder can you add 'always_inline' attribute to the rte_pktmbuf_free(), and see would it make any difference?

Konstantin

Quoted 14 lines

I obviously missed the debug flag for rte_mbuf_sanity_check. However, there is a clear difference of 1 Mpps. I don't know if its the change between while construct used in rte_pktmbuf_free and the do..while construct that I used - is making the difference.

Quoted 7 lines
Quoted 7 lines

The forwarding perf. improvement with only this particular block is around 1 Mpps for 64B packets when using l3fwd with 8 queues.

Thanks,
Rahul

#7 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Quoted 1 line · Konstantin

Hi Rahul,

[...]

Quoted 43 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

Other PMDs use rte_pktmbuf_free_seg() as each TD has an associated with it segment. So as HW is done with the TD, SW frees associated segment. In your case I don't see any point in re-implementing rte_pktmbuf_free() manually, and I don't think it would be any faster.

Quoted 4 lines
Quoted 1 line

Konstantin

As I mentioned below, I am clearly seeing a difference of 1 Mpps. And 1 Mpps is not a small difference IMHO.

Agree with you here - it is a significant difference.

Quoted 17 lines

When running l3fwd with 8 queues, I also collected a perf report. When using rte_pktmbuf_free, I see that it eats up around 6% cpu as below in perf top report:-
--------------------

32.00%  l3fwd                        [.] cxgbe_poll
22.25%  l3fwd                        [.] t4_eth_xmit
20.30%  l3fwd                        [.] main_loop
 6.77%  l3fwd                        [.] rte_pktmbuf_free
 4.86%  l3fwd                        [.] refill_fl_usembufs
 2.00%  l3fwd                        [.] write_sgl

.....
--------------------

While, when using rte_pktmbuf_free_seg directly, I don't see above problem. perf top report now comes as:-
-------------------

Quoted 7 lines
33.36%  l3fwd                        [.] cxgbe_poll
32.69%  l3fwd                        [.] t4_eth_xmit
19.05%  l3fwd                        [.] main_loop
 5.21%  l3fwd                        [.] refill_fl_usembufs
 2.40%  l3fwd                        [.] write_sgl

....
-------------------

Quoted 3 lines

I don't think these 6% disappeared anywhere.
As I can see, now t4_eth_xmit() increased by roughly same amount (you still have same job to do).

Right.

Quoted 5 lines

To me it looks like in that case compiler didn't really inline rte_pktmbuf_free(). Wonder can you add 'always_inline' attribute to the rte_pktmbuf_free(), and see would it make any difference?

Konstantin

I will try out above and update further.

Thanks,
Rahul.

#8 lore raw

Re: [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

Quoted 54 lines · Rahul Lakkireddy
Quoted 1 line · Konstantin

Hi Rahul,

[...]

Quoted 43 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

This additional check seems redundant for single segment packets since rte_pktmbuf_free_seg also performs rte_mbuf_sanity_check.

Several PMDs already prefer to use rte_pktmbuf_free_seg directly over rte_pktmbuf_free as it is faster.

Other PMDs use rte_pktmbuf_free_seg() as each TD has an associated with it segment. So as HW is done with the TD, SW frees associated segment. In your case I don't see any point in re-implementing rte_pktmbuf_free() manually, and I don't think it would be any faster.

Quoted 4 lines
Quoted 1 line

Konstantin

As I mentioned below, I am clearly seeing a difference of 1 Mpps. And 1 Mpps is not a small difference IMHO.

Agree with you here - it is a significant difference.

Quoted 17 lines

When running l3fwd with 8 queues, I also collected a perf report. When using rte_pktmbuf_free, I see that it eats up around 6% cpu as below in perf top report:-
--------------------

32.00%  l3fwd                        [.] cxgbe_poll
22.25%  l3fwd                        [.] t4_eth_xmit
20.30%  l3fwd                        [.] main_loop
 6.77%  l3fwd                        [.] rte_pktmbuf_free
 4.86%  l3fwd                        [.] refill_fl_usembufs
 2.00%  l3fwd                        [.] write_sgl

.....
--------------------

While, when using rte_pktmbuf_free_seg directly, I don't see above problem. perf top report now comes as:-
-------------------

Quoted 7 lines
33.36%  l3fwd                        [.] cxgbe_poll
32.69%  l3fwd                        [.] t4_eth_xmit
19.05%  l3fwd                        [.] main_loop
 5.21%  l3fwd                        [.] refill_fl_usembufs
 2.40%  l3fwd                        [.] write_sgl

....
-------------------

Quoted 3 lines

I don't think these 6% disappeared anywhere.
As I can see, now t4_eth_xmit() increased by roughly same amount (you still have same job to do).

Right.

Quoted 8 lines
Quoted 5 lines

To me it looks like in that case compiler didn't really inline rte_pktmbuf_free(). Wonder can you add 'always_inline' attribute to the rte_pktmbuf_free(), and see would it make any difference?

Konstantin

I will try out above and update further.

Tried always_inline and didn't see any difference in performance in RHEL 6.4 with gcc 4.4.7, but was seeing 1 MPPS improvement with the above block.

I've moved to latest RHEL 7.1 with gcc 4.8.3 and tried both always_inline and the above block and I'm not seeing any difference for both.

Will drop this block and submit a v2.

Thanks for the review Aaron and Konstantin.

Thanks,
Rahul

#9 lore raw

PATCH 2/6 cxgbe: Update device info and perform sanity checks to enable jumbo frames

In reply to Rahul Lakkireddy

Increase max_rx_pktlen to accommodate jumbo frame size. Perform sanity checks and enable jumbo mode in rx queue setup. Set link mtu based on max_rx_pktlen.

---
 drivers/net/cxgbe/cxgbe.h        |  3 +++
 drivers/net/cxgbe/cxgbe_ethdev.c | 23 +++++++++++++++++++++--
 drivers/net/cxgbe/cxgbe_main.c   |  3 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)
drivers/net/cxgbe/cxgbe.h +3 -0
index 97c37d2..adc0d92 100644
@@ -43,6 +43,9 @@
 #define CXGBE_DEFAULT_TX_DESC_SIZE    1024 /* Default TX ring size */
 #define CXGBE_DEFAULT_RX_DESC_SIZE    1024 /* Default RX ring size */
 
+#define CXGBE_MIN_RX_BUFSIZE ETHER_MIN_MTU /* min buf size */
+#define CXGBE_MAX_RX_PKTLEN (9000 + ETHER_HDR_LEN + ETHER_CRC_LEN) /* max pkt */
+
 int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
drivers/net/cxgbe/cxgbe_ethdev.c +21 -2
index 478051a..6d7b29c 100644
@@ -141,8 +141,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 	struct adapter *adapter = pi->adapter;
 	int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;
 
-	device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
-	device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+	device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
+	device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
 	device_info->max_rx_queues = max_queues;
 	device_info->max_tx_queues = max_queues;
 	device_info->max_mac_addrs = 1;
@@ -498,6 +498,8 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	int err = 0;
 	int msi_idx = 0;
 	unsigned int temp_nb_desc;
+	struct rte_eth_dev_info dev_info;
+	unsigned int pkt_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	RTE_SET_USED(rx_conf);
 
@@ -505,6 +507,17 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 		  __func__, eth_dev->data->nb_rx_queues, queue_idx, nb_desc,
 		  socket_id, mp);
 
+	cxgbe_dev_info_get(eth_dev, &dev_info);
+
+	/* Must accommodate at least ETHER_MIN_MTU */
+	if ((pkt_len < dev_info.min_rx_bufsize) ||
+	    (pkt_len > dev_info.max_rx_pktlen)) {
+		dev_err(adap, "%s: max pkt len must be > %d and <= %d\n",
+			__func__, dev_info.min_rx_bufsize,
+			dev_info.max_rx_pktlen);
+		return -EINVAL;
+	}
+
 	/*  Free up the existing queue  */
 	if (eth_dev->data->rx_queues[queue_idx]) {
 		cxgbe_dev_rx_queue_release(eth_dev->data->rx_queues[queue_idx]);
@@ -534,6 +547,12 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	if ((&rxq->fl) != NULL)
 		rxq->fl.size = temp_nb_desc;
 
+	/* Set to jumbo mode if necessary */
+	if (pkt_len > ETHER_MAX_LEN)
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
 	err = t4_sge_alloc_rxq(adapter, &rxq->rspq, false, eth_dev, msi_idx,
 			       &rxq->fl, t4_ethrx_handler,
 			       t4_get_mps_bg_map(adapter, pi->tx_chan), mp,
drivers/net/cxgbe/cxgbe_main.c +2 -1
index 316b87d..aff23d0 100644
@@ -855,12 +855,13 @@ int link_start(struct port_info *pi)
 {
 	struct adapter *adapter = pi->adapter;
 	int ret;
+	unsigned int mtu = pi->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	/*
 	 * We do not set address filters and promiscuity here, the stack does
 	 * that step explicitly.
 	 */
-	ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, 1500, -1, -1,
+	ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, -1, -1,
 			    -1, 1, true);
 	if (ret == 0) {
 		ret = t4_change_mac(adapter, adapter->mbox, pi->viid,
Signature · 1 line
2.5.3
#10 lore raw

PATCH 3/6 cxgbe: Update tx path to transmit jumbo frames

In reply to Rahul Lakkireddy

Add a non-coalesce path. Skip coalescing for Jumbo Frames, and send the packet through non-coalesced path if there are enough credits. Also, free these non-coalesced packets while reclaiming credits.

---
 drivers/net/cxgbe/sge.c | 96 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 64 insertions(+), 32 deletions(-)
drivers/net/cxgbe/sge.c +64 -32
index e540881..921173a 100644
@@ -199,11 +199,20 @@ static void free_tx_desc(struct sge_txq *q, unsigned int n)
 
 static void reclaim_tx_desc(struct sge_txq *q, unsigned int n)
 {
+	struct tx_sw_desc *d;
 	unsigned int cidx = q->cidx;
 
+	d = &q->sdesc[cidx];
 	while (n--) {
-		if (++cidx == q->size)
+		if (d->mbuf) {                       /* an SGL is present */
+			rte_pktmbuf_free(d->mbuf);
+			d->mbuf = NULL;
+		}
+		++d;
+		if (++cidx == q->size) {
 			cidx = 0;
+			d = q->sdesc;
+		}
 	}
 	q->cidx = cidx;
 }
@@ -1045,6 +1054,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf)
 	u32 wr_mid;
 	u64 cntrl, *end;
 	bool v6;
+	u32 max_pkt_len = txq->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	/* Reject xmit if queue is stopped */
 	if (unlikely(txq->flags & EQ_STOPPED))
@@ -1060,6 +1070,10 @@ out_free:
 		return 0;
 	}
 
+	if ((!(m->ol_flags & PKT_TX_TCP_SEG)) &&
+	    (unlikely(m->pkt_len > max_pkt_len)))
+		goto out_free;
+
 	pi = (struct port_info *)txq->eth_dev->data->dev_private;
 	adap = pi->adapter;
 
@@ -1067,7 +1081,7 @@ out_free:
 	/* align the end of coalesce WR to a 512 byte boundary */
 	txq->q.coalesce.max = (8 - (txq->q.pidx & 7)) * 8;
 
-	if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+	if (!((m->ol_flags & PKT_TX_TCP_SEG) || (m->pkt_len > ETHER_MAX_LEN))) {
 		if (should_tx_packet_coalesce(txq, mbuf, &cflits, adap)) {
 			if (unlikely(map_mbuf(mbuf, addr) < 0)) {
 				dev_warn(adap, "%s: mapping err for coalesce\n",
@@ -1114,33 +1128,46 @@ out_free:
 
 	len = 0;
 	len += sizeof(*cpl);
-	lso = (void *)(wr + 1);
-	v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
-	l3hdr_len = m->l3_len;
-	l4hdr_len = m->l4_len;
-	eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
-	len += sizeof(*lso);
-	wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
-			       V_FW_WR_IMMDLEN(len));
-	lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
-			      F_LSO_FIRST_SLICE | F_LSO_LAST_SLICE |
-			      V_LSO_IPV6(v6) |
-			      V_LSO_ETHHDR_LEN(eth_xtra_len / 4) |
-			      V_LSO_IPHDR_LEN(l3hdr_len / 4) |
-			      V_LSO_TCPHDR_LEN(l4hdr_len / 4));
-	lso->ipid_ofst = htons(0);
-	lso->mss = htons(m->tso_segsz);
-	lso->seqno_offset = htonl(0);
-	if (is_t4(adap->params.chip))
-		lso->len = htonl(m->pkt_len);
-	else
-		lso->len = htonl(V_LSO_T5_XFER_SIZE(m->pkt_len));
-	cpl = (void *)(lso + 1);
-	cntrl = V_TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
-				  V_TXPKT_IPHDR_LEN(l3hdr_len) |
-				  V_TXPKT_ETHHDR_LEN(eth_xtra_len);
-	txq->stats.tso++;
-	txq->stats.tx_cso += m->tso_segsz;
+
+	/* Coalescing skipped and we send through normal path */
+	if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+		wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+				       V_FW_WR_IMMDLEN(len));
+		cpl = (void *)(wr + 1);
+		if (m->ol_flags & PKT_TX_IP_CKSUM) {
+			cntrl = hwcsum(adap->params.chip, m) |
+				F_TXPKT_IPCSUM_DIS;
+			txq->stats.tx_cso++;
+		}
+	} else {
+		lso = (void *)(wr + 1);
+		v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
+		l3hdr_len = m->l3_len;
+		l4hdr_len = m->l4_len;
+		eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
+		len += sizeof(*lso);
+		wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+				       V_FW_WR_IMMDLEN(len));
+		lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
+				      F_LSO_FIRST_SLICE | F_LSO_LAST_SLICE |
+				      V_LSO_IPV6(v6) |
+				      V_LSO_ETHHDR_LEN(eth_xtra_len / 4) |
+				      V_LSO_IPHDR_LEN(l3hdr_len / 4) |
+				      V_LSO_TCPHDR_LEN(l4hdr_len / 4));
+		lso->ipid_ofst = htons(0);
+		lso->mss = htons(m->tso_segsz);
+		lso->seqno_offset = htonl(0);
+		if (is_t4(adap->params.chip))
+			lso->len = htonl(m->pkt_len);
+		else
+			lso->len = htonl(V_LSO_T5_XFER_SIZE(m->pkt_len));
+		cpl = (void *)(lso + 1);
+		cntrl = V_TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
+			V_TXPKT_IPHDR_LEN(l3hdr_len) |
+			V_TXPKT_ETHHDR_LEN(eth_xtra_len);
+		txq->stats.tso++;
+		txq->stats.tx_cso += m->tso_segsz;
+	}
 
 	if (m->ol_flags & PKT_TX_VLAN_PKT) {
 		txq->stats.vlan_ins++;
@@ -1161,9 +1188,14 @@ out_free:
 		last_desc -= txq->q.size;
 
 	d = &txq->q.sdesc[last_desc];
-	if (d->mbuf) {
-		rte_pktmbuf_free(d->mbuf);
-		d->mbuf = NULL;
+	if (d->coalesce.idx) {
+		int i;
+
+		for (i = 0; i < d->coalesce.idx; i++) {
+			rte_pktmbuf_free(d->coalesce.mbuf[i]);
+			d->coalesce.mbuf[i] = NULL;
+		}
+		d->coalesce.idx = 0;
 	}
 	write_sgl(m, &txq->q, (struct ulptx_sgl *)(cpl + 1), end, 0,
 		  addr);
Signature · 1 line
2.5.3
#11 lore raw

PATCH 4/6 cxgbe: Update rx path to receive jumbo frames

In reply to Rahul Lakkireddy

Ensure jumbo mode is enabled and that the mbuf data room size can accommodate jumbo size. If the mbuf data room size can't accommodate jumbo size, chain mbufs to jumbo size.

---
 drivers/net/cxgbe/sge.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 53 insertions(+), 5 deletions(-)
drivers/net/cxgbe/sge.c +53 -5
index 921173a..91ef363 100644
@@ -247,6 +247,29 @@ static inline bool fl_starving(const struct adapter *adapter,
 	return fl->avail - fl->pend_cred <= s->fl_starve_thres;
 }
 
+static inline unsigned int get_buf_size(struct adapter *adapter,
+					const struct rx_sw_desc *d)
+{
+	unsigned int rx_buf_size_idx = d->dma_addr & RX_BUF_SIZE;
+	unsigned int buf_size = 0;
+
+	switch (rx_buf_size_idx) {
+	case RX_SMALL_MTU_BUF:
+		buf_size = FL_MTU_SMALL_BUFSIZE(adapter);
+		break;
+
+	case RX_LARGE_MTU_BUF:
+		buf_size = FL_MTU_LARGE_BUFSIZE(adapter);
+		break;
+
+	default:
+		BUG_ON(1);
+		/* NOT REACHED */
+	}
+
+	return buf_size;
+}
+
 /**
  * free_rx_bufs - free the Rx buffers on an SGE free list
  * @q: the SGE free list to free buffers from
@@ -362,6 +385,14 @@ static unsigned int refill_fl_usembufs(struct adapter *adap, struct sge_fl *q,
 	unsigned int buf_size_idx = RX_SMALL_MTU_BUF;
 	struct rte_mbuf *buf_bulk[n];
 	int ret, i;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	u8 jumbo_en = rxq->rspq.eth_dev->data->dev_conf.rxmode.jumbo_frame;
+
+	/* Use jumbo mtu buffers iff mbuf data room size can fit jumbo data. */
+	mbp_priv = rte_mempool_get_priv(rxq->rspq.mb_pool);
+	if (jumbo_en &&
+	    ((mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM) >= 9000))
+		buf_size_idx = RX_LARGE_MTU_BUF;
 
 	ret = rte_mempool_get_bulk(rxq->rspq.mb_pool, (void *)buf_bulk, n);
 	if (unlikely(ret != 0)) {
@@ -1439,14 +1470,31 @@ static int process_responses(struct sge_rspq *q, int budget,
 			const struct cpl_rx_pkt *cpl =
 						(const void *)&q->cur_desc[1];
 			bool csum_ok = cpl->csum_calc && !cpl->err_vec;
-			struct rte_mbuf *pkt;
-			u32 len = ntohl(rc->pldbuflen_qid);
+			struct rte_mbuf *pkt, *npkt;
+			u32 len, bufsz;
 
+			len = ntohl(rc->pldbuflen_qid);
 			BUG_ON(!(len & F_RSPD_NEWBUF));
 			pkt = rsd->buf;
-			pkt->data_len = G_RSPD_LEN(len);
-			pkt->pkt_len = pkt->data_len;
-			unmap_rx_buf(&rxq->fl);
+			npkt = pkt;
+			len = G_RSPD_LEN(len);
+			pkt->pkt_len = len;
+
+			/* Chain mbufs into len if necessary */
+			while (len) {
+				struct rte_mbuf *new_pkt = rsd->buf;
+
+				bufsz = min(get_buf_size(q->adapter, rsd), len);
+				new_pkt->data_len = bufsz;
+				unmap_rx_buf(&rxq->fl);
+				len -= bufsz;
+				npkt->next = new_pkt;
+				npkt = new_pkt;
+				pkt->nb_segs++;
+				rsd = &rxq->fl.sdesc[rxq->fl.cidx];
+			}
+			npkt->next = NULL;
+			pkt->nb_segs--;
 
 			if (cpl->l2info & htonl(F_RXF_IP)) {
 				pkt->packet_type = RTE_PTYPE_L3_IPV4;
Signature · 1 line
2.5.3
#12 lore raw

PATCH 5/6 cxgbe: Allow apps to change mtu

In reply to Rahul Lakkireddy

Add a mtu_set() eth_dev_ops to allow DPDK apps to modify device mtu.

---
 drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/net/cxgbe/cxgbe_ethdev.c +29 -0
index 6d7b29c..a8e057b 100644
@@ -225,6 +225,34 @@ static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
 	return 0;
 }
 
+static int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
+{
+	struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+	struct adapter *adapter = pi->adapter;
+	struct rte_eth_dev_info dev_info;
+	int err;
+	uint16_t new_mtu = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	cxgbe_dev_info_get(eth_dev, &dev_info);
+
+	/* Must accommodate at least ETHER_MIN_MTU */
+	if ((new_mtu < ETHER_MIN_MTU) || (new_mtu > dev_info.max_rx_pktlen))
+		return -EINVAL;
+
+	/* set to jumbo mode if needed */
+	if (new_mtu > ETHER_MAX_LEN)
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
+	err = t4_set_rxmode(adapter, adapter->mbox, pi->viid, new_mtu, -1, -1,
+			    -1, -1, true);
+	if (!err)
+		eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_mtu;
+
+	return err;
+}
+
 static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
 				    uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
@@ -724,6 +752,7 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.dev_configure		= cxgbe_dev_configure,
 	.dev_infos_get		= cxgbe_dev_info_get,
 	.link_update		= cxgbe_dev_link_update,
+	.mtu_set		= cxgbe_dev_mtu_set,
 	.tx_queue_setup         = cxgbe_dev_tx_queue_setup,
 	.tx_queue_start		= cxgbe_dev_tx_queue_start,
 	.tx_queue_stop		= cxgbe_dev_tx_queue_stop,
Signature · 1 line
2.5.3
#13 lore raw

PATCH 6/6 doc: Update cxgbe documentation and release notes

In reply to Rahul Lakkireddy

- Add a missed step to mount huge pages in Linux.
- Re-structure Sample Application Notes.
- Add Jumbo Frame support to list of supported features and instructions on how to enable it via testpmd.
- Update release notes.

---
 doc/guides/nics/cxgbe.rst            | 81 +++++++++++++++++++++++++-----------
 doc/guides/rel_notes/release_2_2.rst |  5 +++
 2 files changed, 61 insertions(+), 25 deletions(-)
doc/guides/nics/cxgbe.rst +56 -25
index 148cd25..d718f19 100644
@@ -50,6 +50,7 @@ CXGBE PMD has support for:
 - Promiscuous mode
 - All multicast mode
 - Port hardware statistics
+- Jumbo frames
 
 Limitations
 -----------
@@ -211,8 +212,8 @@ Unified Wire package for Linux operating system are as follows:
 
       firmware-version: 1.13.32.0, TP 0.1.4.8
 
-Sample Application Notes
-~~~~~~~~~~~~~~~~~~~~~~~~
+Running testpmd
+~~~~~~~~~~~~~~~
 
 This section demonstrates how to launch **testpmd** with Chelsio T5
 devices managed by librte_pmd_cxgbe in Linux operating system.
@@ -260,6 +261,13 @@ devices managed by librte_pmd_cxgbe in Linux operating system.
 
       echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages/nr_hugepages
 
+#. Mount huge pages:
+
+   .. code-block:: console
+
+      mkdir /mnt/huge
+      mount -t hugetlbfs nodev /mnt/huge
+
 #. Load igb_uio or vfio-pci driver:
 
    .. code-block:: console
@@ -329,19 +337,7 @@ devices managed by librte_pmd_cxgbe in Linux operating system.
 .. note::
 
    Flow control pause TX/RX is disabled by default and can be enabled via
-   testpmd as follows:
-
-   .. code-block:: console
-
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
-
-   To disable again, use:
-
-   .. code-block:: console
-
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+   testpmd. Refer section :ref:`flow-control` for more details.
 
 FreeBSD
 -------
@@ -409,8 +405,8 @@ Unified Wire package for FreeBSD operating system are as follows:
 
       dev.t5nex.0.firmware_version: 1.13.32.0
 
-Sample Application Notes
-~~~~~~~~~~~~~~~~~~~~~~~~
+Running testpmd
+~~~~~~~~~~~~~~~
 
 This section demonstrates how to launch **testpmd** with Chelsio T5
 devices managed by librte_pmd_cxgbe in FreeBSD operating system.
@@ -543,16 +539,51 @@ devices managed by librte_pmd_cxgbe in FreeBSD operating system.
 .. note::
 
    Flow control pause TX/RX is disabled by default and can be enabled via
-   testpmd as follows:
+   testpmd. Refer section :ref:`flow-control` for more details.
 
-   .. code-block:: console
+Sample Application Notes
+------------------------
 
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
+.. _flow-control:
 
-   To disable again, use:
+Enable/Disable Flow Control
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-   .. code-block:: console
+Flow control pause TX/RX is disabled by default and can be enabled via
+testpmd as follows:
+
+.. code-block:: console
+
+   testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
+   testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
+
+To disable again, run:
+
+.. code-block:: console
+
+   testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
+   testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+
+Jumbo Mode
+~~~~~~~~~~
+
+There are two ways to enable sending and receiving of jumbo frames via testpmd.
+One method involves using the **mtu** command, which changes the mtu of an
+individual port without having to stop the selected port. Another method
+involves stopping all the ports first and then running **max-pkt-len** command
+to configure the mtu of all the ports with a single command.
+
+- To configure each port individually, run the mtu command as follows:
+
+  .. code-block:: console
+
+     testpmd> port config mtu 0 9000
+     testpmd> port config mtu 1 9000
+
+- To configure all the ports at once, stop all the ports first and run the
+  max-pkt-len command as follows:
+
+  .. code-block:: console
 
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+     testpmd> port stop all
+     testpmd> port config all max-pkt-len 9000
doc/guides/rel_notes/release_2_2.rst +5 -0
index 5687676..a3f4f77 100644
@@ -4,6 +4,11 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **Enhanced support for the Chelsio CXGBE driver.**
+
+  *  Added support for Jumbo Frames.
+  *  Optimize forwarding performance for Chelsio T5 40GbE cards.
+
 
 Resolved Issues
 ---------------
Signature · 1 line
2.5.3
#14 lore raw

v2 cover cxgbe: Optimize tx/rx for 40GbE and add Jumbo Frame support for CXGBE PMD

In reply to Rahul Lakkireddy

This series of patches improve forwarding performance for Chelsio T5 40GbE cards and add Jumbo Frame support for cxgbe pmd. Also update documentation and release notes.

---
v2:
- Don't re-define rte_pktmbuf_free() locally. Thanks to review by Aaron Conole <[email protected]> and Konstantin Ananyev <[email protected]>

Rahul Lakkireddy (6):
cxgbe: Optimize forwarding performance for 40G
cxgbe: Update device info and perform sanity checks to enable jumbo
frames
cxgbe: Update tx path to transmit jumbo frames
cxgbe: Update rx path to receive jumbo frames
cxgbe: Allow apps to change mtu
doc: Update cxgbe documentation and release notes

 doc/guides/nics/cxgbe.rst            |  81 ++++++++++++------
 doc/guides/rel_notes/release_2_2.rst |   5 ++
 drivers/net/cxgbe/base/t4_regs.h     |  16 ++++
 drivers/net/cxgbe/cxgbe.h            |   3 +
 drivers/net/cxgbe/cxgbe_ethdev.c     |  52 ++++++++++-
 drivers/net/cxgbe/cxgbe_main.c       |  10 ++-
 drivers/net/cxgbe/sge.c              | 162 ++++++++++++++++++++++++++---------
 7 files changed, 260 insertions(+), 69 deletions(-)
Signature · 1 line
2.5.3
#15 lore raw

PATCH v2 1/6 cxgbe: Optimize forwarding performance for 40G

Update sge initialization with respect to free-list manager configuration and ingress arbiter. Also update refill logic to refill mbufs only after a certain threshold for rx. Optimize tx packet prefetch.

Approx. 3 MPPS improvement seen in forwarding performance after the optimization.

---
v2:
- Don't re-define rte_pktmbuf_free() locally. Thanks to review by Aaron Conole <[email protected]> and Konstantin Ananyev <[email protected]>

 drivers/net/cxgbe/base/t4_regs.h | 16 ++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c   |  7 +++++++
 drivers/net/cxgbe/sge.c          |  8 ++++----
 3 files changed, 27 insertions(+), 4 deletions(-)
drivers/net/cxgbe/base/t4_regs.h +16 -0
index cd28b59..9057e40 100644
@@ -266,6 +266,18 @@
 #define A_SGE_FL_BUFFER_SIZE2 0x104c
 #define A_SGE_FL_BUFFER_SIZE3 0x1050
 
+#define A_SGE_FLM_CFG 0x1090
+
+#define S_CREDITCNT    4
+#define M_CREDITCNT    0x3U
+#define V_CREDITCNT(x) ((x) << S_CREDITCNT)
+#define G_CREDITCNT(x) (((x) >> S_CREDITCNT) & M_CREDITCNT)
+
+#define S_CREDITCNTPACKING    2
+#define M_CREDITCNTPACKING    0x3U
+#define V_CREDITCNTPACKING(x) ((x) << S_CREDITCNTPACKING)
+#define G_CREDITCNTPACKING(x) (((x) >> S_CREDITCNTPACKING) & M_CREDITCNTPACKING)
+
 #define A_SGE_CONM_CTRL 0x1094
 
 #define S_EGRTHRESHOLD    8
@@ -361,6 +373,10 @@
 
 #define A_SGE_CONTROL2 0x1124
 
+#define S_IDMAARBROUNDROBIN    19
+#define V_IDMAARBROUNDROBIN(x) ((x) << S_IDMAARBROUNDROBIN)
+#define F_IDMAARBROUNDROBIN    V_IDMAARBROUNDROBIN(1U)
+
 #define S_INGPACKBOUNDARY    16
 #define M_INGPACKBOUNDARY    0x7U
 #define V_INGPACKBOUNDARY(x) ((x) << S_INGPACKBOUNDARY)
drivers/net/cxgbe/cxgbe_main.c +7 -0
index 3755444..316b87d 100644
@@ -422,6 +422,13 @@ static int adap_init0_tweaks(struct adapter *adapter)
 	t4_set_reg_field(adapter, A_SGE_CONTROL, V_PKTSHIFT(M_PKTSHIFT),
 			 V_PKTSHIFT(rx_dma_offset));
 
+	t4_set_reg_field(adapter, A_SGE_FLM_CFG,
+			 V_CREDITCNT(M_CREDITCNT) | M_CREDITCNTPACKING,
+			 V_CREDITCNT(3) | V_CREDITCNTPACKING(1));
+
+	t4_set_reg_field(adapter, A_SGE_CONTROL2, V_IDMAARBROUNDROBIN(1U),
+			 V_IDMAARBROUNDROBIN(1U));
+
 	/*
 	 * Don't include the "IP Pseudo Header" in CPL_RX_PKT checksums: Linux
 	 * adds the pseudo header itself.
drivers/net/cxgbe/sge.c +4 -4
index 6eb1244..69ab487 100644
@@ -286,8 +286,7 @@ static void unmap_rx_buf(struct sge_fl *q)
 
 static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
 {
-	/* see if we have exceeded q->size / 4 */
-	if (q->pend_cred >= (q->size / 4)) {
+	if (q->pend_cred >= 64) {
 		u32 val = adap->params.arch.sge_fl_db;
 
 		if (is_t4(adap->params.chip))
@@ -1054,7 +1053,6 @@ out_free:
 		return 0;
 	}
 
-	rte_prefetch0(&((&txq->q)->sdesc->mbuf->pool));
 	pi = (struct port_info *)txq->eth_dev->data->dev_private;
 	adap = pi->adapter;
 
@@ -1070,6 +1068,7 @@ out_free:
 				txq->stats.mapping_err++;
 				goto out_free;
 			}
+			rte_prefetch0((volatile void *)addr);
 			return tx_do_packet_coalesce(txq, mbuf, cflits, adap,
 						     pi, addr);
 		} else {
@@ -1454,7 +1453,8 @@ static int process_responses(struct sge_rspq *q, int budget,
 			unsigned int params;
 			u32 val;
 
-			__refill_fl(q->adapter, &rxq->fl);
+			if (fl_cap(&rxq->fl) - rxq->fl.avail >= 64)
+				__refill_fl(q->adapter, &rxq->fl);
 			params = V_QINTR_TIMER_IDX(X_TIMERREG_UPDATE_CIDX);
 			q->next_intr_params = params;
 			val = V_CIDXINC(cidx_inc) | V_SEINTARM(params);
Signature · 1 line
2.5.3
#16 lore raw

PATCH v2 2/6 cxgbe: Update device info and perform sanity checks to enable jumbo frames

In reply to Rahul Lakkireddy

Increase max_rx_pktlen to accommodate jumbo frame size. Perform sanity checks and enable jumbo mode in rx queue setup. Set link mtu based on max_rx_pktlen.

---
v2:
- No change

 drivers/net/cxgbe/cxgbe.h        |  3 +++
 drivers/net/cxgbe/cxgbe_ethdev.c | 23 +++++++++++++++++++++--
 drivers/net/cxgbe/cxgbe_main.c   |  3 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)
drivers/net/cxgbe/cxgbe.h +3 -0
index 97c37d2..adc0d92 100644
@@ -43,6 +43,9 @@
 #define CXGBE_DEFAULT_TX_DESC_SIZE    1024 /* Default TX ring size */
 #define CXGBE_DEFAULT_RX_DESC_SIZE    1024 /* Default RX ring size */
 
+#define CXGBE_MIN_RX_BUFSIZE ETHER_MIN_MTU /* min buf size */
+#define CXGBE_MAX_RX_PKTLEN (9000 + ETHER_HDR_LEN + ETHER_CRC_LEN) /* max pkt */
+
 int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
drivers/net/cxgbe/cxgbe_ethdev.c +21 -2
index 478051a..6d7b29c 100644
@@ -141,8 +141,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 	struct adapter *adapter = pi->adapter;
 	int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;
 
-	device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
-	device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+	device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
+	device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
 	device_info->max_rx_queues = max_queues;
 	device_info->max_tx_queues = max_queues;
 	device_info->max_mac_addrs = 1;
@@ -498,6 +498,8 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	int err = 0;
 	int msi_idx = 0;
 	unsigned int temp_nb_desc;
+	struct rte_eth_dev_info dev_info;
+	unsigned int pkt_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	RTE_SET_USED(rx_conf);
 
@@ -505,6 +507,17 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 		  __func__, eth_dev->data->nb_rx_queues, queue_idx, nb_desc,
 		  socket_id, mp);
 
+	cxgbe_dev_info_get(eth_dev, &dev_info);
+
+	/* Must accommodate at least ETHER_MIN_MTU */
+	if ((pkt_len < dev_info.min_rx_bufsize) ||
+	    (pkt_len > dev_info.max_rx_pktlen)) {
+		dev_err(adap, "%s: max pkt len must be > %d and <= %d\n",
+			__func__, dev_info.min_rx_bufsize,
+			dev_info.max_rx_pktlen);
+		return -EINVAL;
+	}
+
 	/*  Free up the existing queue  */
 	if (eth_dev->data->rx_queues[queue_idx]) {
 		cxgbe_dev_rx_queue_release(eth_dev->data->rx_queues[queue_idx]);
@@ -534,6 +547,12 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	if ((&rxq->fl) != NULL)
 		rxq->fl.size = temp_nb_desc;
 
+	/* Set to jumbo mode if necessary */
+	if (pkt_len > ETHER_MAX_LEN)
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
 	err = t4_sge_alloc_rxq(adapter, &rxq->rspq, false, eth_dev, msi_idx,
 			       &rxq->fl, t4_ethrx_handler,
 			       t4_get_mps_bg_map(adapter, pi->tx_chan), mp,
drivers/net/cxgbe/cxgbe_main.c +2 -1
index 316b87d..aff23d0 100644
@@ -855,12 +855,13 @@ int link_start(struct port_info *pi)
 {
 	struct adapter *adapter = pi->adapter;
 	int ret;
+	unsigned int mtu = pi->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	/*
 	 * We do not set address filters and promiscuity here, the stack does
 	 * that step explicitly.
 	 */
-	ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, 1500, -1, -1,
+	ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, -1, -1,
 			    -1, 1, true);
 	if (ret == 0) {
 		ret = t4_change_mac(adapter, adapter->mbox, pi->viid,
Signature · 1 line
2.5.3
#17 lore raw

PATCH v2 3/6 cxgbe: Update tx path to transmit jumbo frames

In reply to Rahul Lakkireddy

Add a non-coalesce path. Skip coalescing for Jumbo Frames, and send the packet through non-coalesced path if there are enough credits. Also, free these non-coalesced packets while reclaiming credits.

---
v2:
- No change

 drivers/net/cxgbe/sge.c | 96 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 64 insertions(+), 32 deletions(-)
drivers/net/cxgbe/sge.c +64 -32
index 69ab487..b1d0ea6 100644
@@ -199,11 +199,20 @@ static void free_tx_desc(struct sge_txq *q, unsigned int n)
 
 static void reclaim_tx_desc(struct sge_txq *q, unsigned int n)
 {
+	struct tx_sw_desc *d;
 	unsigned int cidx = q->cidx;
 
+	d = &q->sdesc[cidx];
 	while (n--) {
-		if (++cidx == q->size)
+		if (d->mbuf) {                       /* an SGL is present */
+			rte_pktmbuf_free(d->mbuf);
+			d->mbuf = NULL;
+		}
+		++d;
+		if (++cidx == q->size) {
 			cidx = 0;
+			d = q->sdesc;
+		}
 	}
 	q->cidx = cidx;
 }
@@ -1038,6 +1047,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf)
 	u32 wr_mid;
 	u64 cntrl, *end;
 	bool v6;
+	u32 max_pkt_len = txq->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
 
 	/* Reject xmit if queue is stopped */
 	if (unlikely(txq->flags & EQ_STOPPED))
@@ -1053,6 +1063,10 @@ out_free:
 		return 0;
 	}
 
+	if ((!(m->ol_flags & PKT_TX_TCP_SEG)) &&
+	    (unlikely(m->pkt_len > max_pkt_len)))
+		goto out_free;
+
 	pi = (struct port_info *)txq->eth_dev->data->dev_private;
 	adap = pi->adapter;
 
@@ -1060,7 +1074,7 @@ out_free:
 	/* align the end of coalesce WR to a 512 byte boundary */
 	txq->q.coalesce.max = (8 - (txq->q.pidx & 7)) * 8;
 
-	if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+	if (!((m->ol_flags & PKT_TX_TCP_SEG) || (m->pkt_len > ETHER_MAX_LEN))) {
 		if (should_tx_packet_coalesce(txq, mbuf, &cflits, adap)) {
 			if (unlikely(map_mbuf(mbuf, addr) < 0)) {
 				dev_warn(adap, "%s: mapping err for coalesce\n",
@@ -1107,33 +1121,46 @@ out_free:
 
 	len = 0;
 	len += sizeof(*cpl);
-	lso = (void *)(wr + 1);
-	v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
-	l3hdr_len = m->l3_len;
-	l4hdr_len = m->l4_len;
-	eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
-	len += sizeof(*lso);
-	wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
-			       V_FW_WR_IMMDLEN(len));
-	lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
-			      F_LSO_FIRST_SLICE | F_LSO_LAST_SLICE |
-			      V_LSO_IPV6(v6) |
-			      V_LSO_ETHHDR_LEN(eth_xtra_len / 4) |
-			      V_LSO_IPHDR_LEN(l3hdr_len / 4) |
-			      V_LSO_TCPHDR_LEN(l4hdr_len / 4));
-	lso->ipid_ofst = htons(0);
-	lso->mss = htons(m->tso_segsz);
-	lso->seqno_offset = htonl(0);
-	if (is_t4(adap->params.chip))
-		lso->len = htonl(m->pkt_len);
-	else
-		lso->len = htonl(V_LSO_T5_XFER_SIZE(m->pkt_len));
-	cpl = (void *)(lso + 1);
-	cntrl = V_TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
-				  V_TXPKT_IPHDR_LEN(l3hdr_len) |
-				  V_TXPKT_ETHHDR_LEN(eth_xtra_len);
-	txq->stats.tso++;
-	txq->stats.tx_cso += m->tso_segsz;
+
+	/* Coalescing skipped and we send through normal path */
+	if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+		wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+				       V_FW_WR_IMMDLEN(len));
+		cpl = (void *)(wr + 1);
+		if (m->ol_flags & PKT_TX_IP_CKSUM) {
+			cntrl = hwcsum(adap->params.chip, m) |
+				F_TXPKT_IPCSUM_DIS;
+			txq->stats.tx_cso++;
+		}
+	} else {
+		lso = (void *)(wr + 1);
+		v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
+		l3hdr_len = m->l3_len;
+		l4hdr_len = m->l4_len;
+		eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
+		len += sizeof(*lso);
+		wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+				       V_FW_WR_IMMDLEN(len));
+		lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
+				      F_LSO_FIRST_SLICE | F_LSO_LAST_SLICE |
+				      V_LSO_IPV6(v6) |
+				      V_LSO_ETHHDR_LEN(eth_xtra_len / 4) |
+				      V_LSO_IPHDR_LEN(l3hdr_len / 4) |
+				      V_LSO_TCPHDR_LEN(l4hdr_len / 4));
+		lso->ipid_ofst = htons(0);
+		lso->mss = htons(m->tso_segsz);
+		lso->seqno_offset = htonl(0);
+		if (is_t4(adap->params.chip))
+			lso->len = htonl(m->pkt_len);
+		else
+			lso->len = htonl(V_LSO_T5_XFER_SIZE(m->pkt_len));
+		cpl = (void *)(lso + 1);
+		cntrl = V_TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
+			V_TXPKT_IPHDR_LEN(l3hdr_len) |
+			V_TXPKT_ETHHDR_LEN(eth_xtra_len);
+		txq->stats.tso++;
+		txq->stats.tx_cso += m->tso_segsz;
+	}
 
 	if (m->ol_flags & PKT_TX_VLAN_PKT) {
 		txq->stats.vlan_ins++;
@@ -1154,9 +1181,14 @@ out_free:
 		last_desc -= txq->q.size;
 
 	d = &txq->q.sdesc[last_desc];
-	if (d->mbuf) {
-		rte_pktmbuf_free(d->mbuf);
-		d->mbuf = NULL;
+	if (d->coalesce.idx) {
+		int i;
+
+		for (i = 0; i < d->coalesce.idx; i++) {
+			rte_pktmbuf_free(d->coalesce.mbuf[i]);
+			d->coalesce.mbuf[i] = NULL;
+		}
+		d->coalesce.idx = 0;
 	}
 	write_sgl(m, &txq->q, (struct ulptx_sgl *)(cpl + 1), end, 0,
 		  addr);
Signature · 1 line
2.5.3
#18 lore raw

PATCH v2 4/6 cxgbe: Update rx path to receive jumbo frames

In reply to Rahul Lakkireddy

Ensure jumbo mode is enabled and that the mbuf data room size can accommodate jumbo size. If the mbuf data room size can't accommodate jumbo size, chain mbufs to jumbo size.

---
v2:
- No change

 drivers/net/cxgbe/sge.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 53 insertions(+), 5 deletions(-)
drivers/net/cxgbe/sge.c +53 -5
index b1d0ea6..aa0c2e5 100644
@@ -247,6 +247,29 @@ static inline bool fl_starving(const struct adapter *adapter,
 	return fl->avail - fl->pend_cred <= s->fl_starve_thres;
 }
 
+static inline unsigned int get_buf_size(struct adapter *adapter,
+					const struct rx_sw_desc *d)
+{
+	unsigned int rx_buf_size_idx = d->dma_addr & RX_BUF_SIZE;
+	unsigned int buf_size = 0;
+
+	switch (rx_buf_size_idx) {
+	case RX_SMALL_MTU_BUF:
+		buf_size = FL_MTU_SMALL_BUFSIZE(adapter);
+		break;
+
+	case RX_LARGE_MTU_BUF:
+		buf_size = FL_MTU_LARGE_BUFSIZE(adapter);
+		break;
+
+	default:
+		BUG_ON(1);
+		/* NOT REACHED */
+	}
+
+	return buf_size;
+}
+
 /**
  * free_rx_bufs - free the Rx buffers on an SGE free list
  * @q: the SGE free list to free buffers from
@@ -362,6 +385,14 @@ static unsigned int refill_fl_usembufs(struct adapter *adap, struct sge_fl *q,
 	unsigned int buf_size_idx = RX_SMALL_MTU_BUF;
 	struct rte_mbuf *buf_bulk[n];
 	int ret, i;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	u8 jumbo_en = rxq->rspq.eth_dev->data->dev_conf.rxmode.jumbo_frame;
+
+	/* Use jumbo mtu buffers iff mbuf data room size can fit jumbo data. */
+	mbp_priv = rte_mempool_get_priv(rxq->rspq.mb_pool);
+	if (jumbo_en &&
+	    ((mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM) >= 9000))
+		buf_size_idx = RX_LARGE_MTU_BUF;
 
 	ret = rte_mempool_get_bulk(rxq->rspq.mb_pool, (void *)buf_bulk, n);
 	if (unlikely(ret != 0)) {
@@ -1432,14 +1463,31 @@ static int process_responses(struct sge_rspq *q, int budget,
 			const struct cpl_rx_pkt *cpl =
 						(const void *)&q->cur_desc[1];
 			bool csum_ok = cpl->csum_calc && !cpl->err_vec;
-			struct rte_mbuf *pkt;
-			u32 len = ntohl(rc->pldbuflen_qid);
+			struct rte_mbuf *pkt, *npkt;
+			u32 len, bufsz;
 
+			len = ntohl(rc->pldbuflen_qid);
 			BUG_ON(!(len & F_RSPD_NEWBUF));
 			pkt = rsd->buf;
-			pkt->data_len = G_RSPD_LEN(len);
-			pkt->pkt_len = pkt->data_len;
-			unmap_rx_buf(&rxq->fl);
+			npkt = pkt;
+			len = G_RSPD_LEN(len);
+			pkt->pkt_len = len;
+
+			/* Chain mbufs into len if necessary */
+			while (len) {
+				struct rte_mbuf *new_pkt = rsd->buf;
+
+				bufsz = min(get_buf_size(q->adapter, rsd), len);
+				new_pkt->data_len = bufsz;
+				unmap_rx_buf(&rxq->fl);
+				len -= bufsz;
+				npkt->next = new_pkt;
+				npkt = new_pkt;
+				pkt->nb_segs++;
+				rsd = &rxq->fl.sdesc[rxq->fl.cidx];
+			}
+			npkt->next = NULL;
+			pkt->nb_segs--;
 
 			if (cpl->l2info & htonl(F_RXF_IP)) {
 				pkt->packet_type = RTE_PTYPE_L3_IPV4;
Signature · 1 line
2.5.3
#19 lore raw

PATCH v2 5/6 cxgbe: Allow apps to change mtu

In reply to Rahul Lakkireddy

Add a mtu_set() eth_dev_ops to allow DPDK apps to modify device mtu.

---
v2:
- No change

 drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/net/cxgbe/cxgbe_ethdev.c +29 -0
index 6d7b29c..a8e057b 100644
@@ -225,6 +225,34 @@ static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
 	return 0;
 }
 
+static int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
+{
+	struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+	struct adapter *adapter = pi->adapter;
+	struct rte_eth_dev_info dev_info;
+	int err;
+	uint16_t new_mtu = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	cxgbe_dev_info_get(eth_dev, &dev_info);
+
+	/* Must accommodate at least ETHER_MIN_MTU */
+	if ((new_mtu < ETHER_MIN_MTU) || (new_mtu > dev_info.max_rx_pktlen))
+		return -EINVAL;
+
+	/* set to jumbo mode if needed */
+	if (new_mtu > ETHER_MAX_LEN)
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
+	err = t4_set_rxmode(adapter, adapter->mbox, pi->viid, new_mtu, -1, -1,
+			    -1, -1, true);
+	if (!err)
+		eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_mtu;
+
+	return err;
+}
+
 static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
 				    uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
@@ -724,6 +752,7 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.dev_configure		= cxgbe_dev_configure,
 	.dev_infos_get		= cxgbe_dev_info_get,
 	.link_update		= cxgbe_dev_link_update,
+	.mtu_set		= cxgbe_dev_mtu_set,
 	.tx_queue_setup         = cxgbe_dev_tx_queue_setup,
 	.tx_queue_start		= cxgbe_dev_tx_queue_start,
 	.tx_queue_stop		= cxgbe_dev_tx_queue_stop,
Signature · 1 line
2.5.3
#20 lore raw

PATCH v2 6/6 doc: Update cxgbe documentation and release notes

In reply to Rahul Lakkireddy

- Add a missed step to mount huge pages in Linux.
- Re-structure Sample Application Notes.
- Add Jumbo Frame support to list of supported features and instructions on how to enable it via testpmd.
- Update release notes.

---
v2:
- No change

 doc/guides/nics/cxgbe.rst            | 81 +++++++++++++++++++++++++-----------
 doc/guides/rel_notes/release_2_2.rst |  5 +++
 2 files changed, 61 insertions(+), 25 deletions(-)
doc/guides/nics/cxgbe.rst +56 -25
index 148cd25..d718f19 100644
@@ -50,6 +50,7 @@ CXGBE PMD has support for:
 - Promiscuous mode
 - All multicast mode
 - Port hardware statistics
+- Jumbo frames
 
 Limitations
 -----------
@@ -211,8 +212,8 @@ Unified Wire package for Linux operating system are as follows:
 
       firmware-version: 1.13.32.0, TP 0.1.4.8
 
-Sample Application Notes
-~~~~~~~~~~~~~~~~~~~~~~~~
+Running testpmd
+~~~~~~~~~~~~~~~
 
 This section demonstrates how to launch **testpmd** with Chelsio T5
 devices managed by librte_pmd_cxgbe in Linux operating system.
@@ -260,6 +261,13 @@ devices managed by librte_pmd_cxgbe in Linux operating system.
 
       echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages/nr_hugepages
 
+#. Mount huge pages:
+
+   .. code-block:: console
+
+      mkdir /mnt/huge
+      mount -t hugetlbfs nodev /mnt/huge
+
 #. Load igb_uio or vfio-pci driver:
 
    .. code-block:: console
@@ -329,19 +337,7 @@ devices managed by librte_pmd_cxgbe in Linux operating system.
 .. note::
 
    Flow control pause TX/RX is disabled by default and can be enabled via
-   testpmd as follows:
-
-   .. code-block:: console
-
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
-
-   To disable again, use:
-
-   .. code-block:: console
-
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+   testpmd. Refer section :ref:`flow-control` for more details.
 
 FreeBSD
 -------
@@ -409,8 +405,8 @@ Unified Wire package for FreeBSD operating system are as follows:
 
       dev.t5nex.0.firmware_version: 1.13.32.0
 
-Sample Application Notes
-~~~~~~~~~~~~~~~~~~~~~~~~
+Running testpmd
+~~~~~~~~~~~~~~~
 
 This section demonstrates how to launch **testpmd** with Chelsio T5
 devices managed by librte_pmd_cxgbe in FreeBSD operating system.
@@ -543,16 +539,51 @@ devices managed by librte_pmd_cxgbe in FreeBSD operating system.
 .. note::
 
    Flow control pause TX/RX is disabled by default and can be enabled via
-   testpmd as follows:
+   testpmd. Refer section :ref:`flow-control` for more details.
 
-   .. code-block:: console
+Sample Application Notes
+------------------------
 
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
-      testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
+.. _flow-control:
 
-   To disable again, use:
+Enable/Disable Flow Control
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-   .. code-block:: console
+Flow control pause TX/RX is disabled by default and can be enabled via
+testpmd as follows:
+
+.. code-block:: console
+
+   testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 0
+   testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off autoneg on 1
+
+To disable again, run:
+
+.. code-block:: console
+
+   testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
+   testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+
+Jumbo Mode
+~~~~~~~~~~
+
+There are two ways to enable sending and receiving of jumbo frames via testpmd.
+One method involves using the **mtu** command, which changes the mtu of an
+individual port without having to stop the selected port. Another method
+involves stopping all the ports first and then running **max-pkt-len** command
+to configure the mtu of all the ports with a single command.
+
+- To configure each port individually, run the mtu command as follows:
+
+  .. code-block:: console
+
+     testpmd> port config mtu 0 9000
+     testpmd> port config mtu 1 9000
+
+- To configure all the ports at once, stop all the ports first and run the
+  max-pkt-len command as follows:
+
+  .. code-block:: console
 
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 0
-      testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off autoneg off 1
+     testpmd> port stop all
+     testpmd> port config all max-pkt-len 9000
doc/guides/rel_notes/release_2_2.rst +5 -0
index 5687676..a3f4f77 100644
@@ -4,6 +4,11 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **Enhanced support for the Chelsio CXGBE driver.**
+
+  *  Added support for Jumbo Frames.
+  *  Optimize forwarding performance for Chelsio T5 40GbE cards.
+
 
 Resolved Issues
 ---------------
Signature · 1 line
2.5.3
#21 lore raw
In reply to Rahul Lakkireddy

2015-10-08 19:16, Rahul Lakkireddy:

Quoted 3 lines

This series of patches improve forwarding performance for Chelsio T5 40GbE cards and add Jumbo Frame support for cxgbe pmd. Also update documentation and release notes.

Applied, thanks.

What are the performance numbers with these patches?

#22 lore raw

Hi Thomas,

Quoted 8 lines · Thomas Monjalon

2015-10-08 19:16, Rahul Lakkireddy:

Quoted 3 lines

This series of patches improve forwarding performance for Chelsio T5 40GbE cards and add Jumbo Frame support for cxgbe pmd. Also update documentation and release notes.

Applied, thanks.

What are the performance numbers with these patches?

Without this patch series, the l3fwd perf with 8 queues for 64B was ~28 MPPS. With this patch series, the perf has improved to ~31 MPPS.

Thanks,
Rahul