Skip to contentSkip to conversation

cxgb3 - Add SW LRO support

PATCH In review [email protected] 5 participants 8 messages Feb 25, 2007 – Jun 1, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 7/7 cxgb3 - Add SW LRO support

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

---

 drivers/net/cxgb3/adapter.h     |   21 ++
 drivers/net/cxgb3/common.h      |    1 
 drivers/net/cxgb3/cxgb3_ioctl.h |    1 
 drivers/net/cxgb3/cxgb3_main.c  |   16 ++
 drivers/net/cxgb3/sge.c         |  341 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/cxgb3/t3_cpl.h      |   10 +
 6 files changed, 384 insertions(+), 6 deletions(-)
drivers/net/cxgb3/adapter.h +21 -0
index 80c3d8f..576db4a 100644
@@ -95,6 +95,23 @@ struct sge_fl {			/* SGE per free-buffer
 	unsigned long alloc_failed; /* # of times buffer allocation failed */
 };
 
+/* Max active LRO sessions per queue set */
+#define MAX_LRO_PER_QSET 8
+
+struct sge_lro_session {
+	struct sk_buff *skb;
+	struct sk_buff *skb_last_frag;
+	u32 seq;
+	u16 iplen;
+};
+
+struct sge_lro {
+	unsigned int enabled;
+	unsigned int num_active;
+	struct sge_lro_session *last_s;
+	struct sge_lro_session s[MAX_LRO_PER_QSET];
+};
+
 /*
  * Bundle size for grouping offload RX packets for delivery to the stack.
  * Don't make this too big as we do prefetch on each packet in a bundle.
@@ -164,6 +181,9 @@ enum {				/* per port SGE statistics */
 	SGE_PSTAT_TX_CSUM,	/* # of TX checksum offloads */
 	SGE_PSTAT_VLANEX,	/* # of VLAN tag extractions */
 	SGE_PSTAT_VLANINS,	/* # of VLAN tag insertions */
+	SGE_PSTATS_LRO_QUEUED,	/* # of LRO appended packets */
+	SGE_PSTATS_LRO_FLUSHED,	/* # of LRO flushed packets */
+	SGE_PSTATS_LRO_X_STREAMS,	/* # of exceeded LRO contexts */
 
 	SGE_PSTAT_MAX		/* must be last */
 };
@@ -171,6 +191,7 @@ enum {				/* per port SGE statistics */
 struct sge_qset {		/* an SGE queue set */
 	struct sge_rspq rspq;
 	struct sge_fl fl[SGE_RXQ_PER_SET];
+	struct sge_lro lro;
 	struct sge_txq txq[SGE_TXQ_PER_SET];
 	struct net_device *netdev;	/* associated net device */
 	unsigned long txq_stopped;	/* which Tx queues are stopped */
drivers/net/cxgb3/common.h +1 -0
index e23deeb..1031ad0 100644
@@ -322,6 +322,7 @@ struct tp_params {
 
 struct qset_params {		/* SGE queue set parameters */
 	unsigned int polling;	/* polling/interrupt service for rspq */
+	unsigned int lro;	/* large receive offload */
 	unsigned int coalesce_usecs;	/* irq coalescing timer */
 	unsigned int rspq_size;	/* # of entries in response queue */
 	unsigned int fl_size;	/* # of entries in regular free list */
drivers/net/cxgb3/cxgb3_ioctl.h +1 -0
index 0a82fcd..68200a1 100644
@@ -90,6 +90,7 @@ struct ch_qset_params {
 	int32_t fl_size[2];
 	int32_t intr_lat;
 	int32_t polling;
+	int32_t lro;
 	int32_t cong_thres;
 };
 
drivers/net/cxgb3/cxgb3_main.c +15 -1
index 7ff834e..b78eefb 100644
@@ -1031,7 +1031,11 @@ static char stats_strings[][ETH_GSTRING_
 	"VLANinsertions     ",
 	"TxCsumOffload      ",
 	"RxCsumGood         ",
-	"RxDrops            "
+	"RxDrops            ",
+
+	"LroQueued          ",
+	"LroFlushed         ",
+	"LroExceededSessions"
 };
 
 static int get_stats_count(struct net_device *dev)
@@ -1145,6 +1149,9 @@ static void get_stats(struct net_device
 	*data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_TX_CSUM);
 	*data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_RX_CSUM_GOOD);
 	*data++ = s->rx_cong_drops;
+	*data++ = collect_sge_port_stats(adapter, pi, SGE_PSTATS_LRO_QUEUED);
+	*data++ = collect_sge_port_stats(adapter, pi, SGE_PSTATS_LRO_FLUSHED);
+	*data++ = collect_sge_port_stats(adapter, pi, SGE_PSTATS_LRO_X_STREAMS);
 }
 
 static inline void reg_block_dump(struct adapter *ap, void *buf,
@@ -1624,6 +1631,12 @@ static int cxgb_extension_ioctl(struct n
 				}
 			}
 		}
+		if (t.lro >= 0) {
+			struct sge_qset *qs = &adapter->sge.qs[t.qset_idx];
+			
+			q->lro = t.lro;
+			qs->lro.enabled = t.lro;
+		}
 		break;
 	}
 	case CHELSIO_GET_QSET_PARAMS:{
@@ -1643,6 +1656,7 @@ static int cxgb_extension_ioctl(struct n
 		t.fl_size[0] = q->fl_size;
 		t.fl_size[1] = q->jumbo_size;
 		t.polling = q->polling;
+		t.lro = q->lro;
 		t.intr_lat = q->coalesce_usecs;
 		t.cong_thres = q->cong_thres;
 
drivers/net/cxgb3/sge.c +336 -5

389 lines not on this page · raw message

drivers/net/cxgb3/t3_cpl.h +10 -0
index b7a1a31..0f9f67d 100644
@@ -174,6 +174,12 @@ enum {				/* TCP congestion control algo
 	CONG_ALG_HIGHSPEED
 };
 
+enum {				/* RSS hash type */
+	RSS_HASH_NONE = 0,
+	RSS_HASH_2_TUPLE = 1 << 0,
+	RSS_HASH_4_TUPLE = 1 << 1
+};
+
 union opcode_tid {
 	__be32 opcode_tid;
 	__u8 opcode;
@@ -184,6 +190,10 @@ union opcode_tid {
 #define G_OPCODE(x) (((x) >> S_OPCODE) & 0xFF)
 #define G_TID(x)    ((x) & 0xFFFFFF)
 
+#define S_HASHTYPE 22
+#define M_HASHTYPE 0x3
+#define G_HASHTYPE(x) (((x) >> S_HASHTYPE) & M_HASHTYPE)
+
 /* tid is assumed to be 24-bits */
 #define MK_OPCODE_TID(opcode, tid) (V_OPCODE(opcode) | (tid))
 
#1 lore raw
Quoted 3 lines · On Sat, Feb 24, 2007 at 04:44:23PM -0800, [email protected] wrote:

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

Doing this in a LLDD doesn't sound like a good idea. Have you tried doing this in the core networking code instead?

#2 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · On Sat, Feb 24, 2007 at 04:44:23PM -0800, [email protected] wrote:

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

Doing this in a LLDD doesn't sound like a good idea. Have you tried doing this in the core networking code instead?

We have not tried to implement LRO in the core networking code.
Today, the available API for a driver to pass packets up is netif_receive_skb/netif_rx. Our implementation coalesces pages, then gets a skb to point at the pages and passes it up to the stack. LRO in the core networking code would require adding methods to pass up data segments in addition to skbs. HW might also be able to assist LRO by identifying the session an incoming packet belongs to, thus avoiding the session lookup. The API should also allow for the driver to indicate such info.

Cheers,
Divy

#3 lore raw
In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · On Sat, Feb 24, 2007 at 04:44:23PM -0800, [email protected] wrote:

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

Doing this in a LLDD doesn't sound like a good idea. Have you tried doing this in the core networking code instead?

It looks like both Netxen and Neterion drivers already have this. So I think for now the LLDD implements LRO. The stack supports it by virtue of allowing fragmented skbs that are bigger than the MTU.

Other drivers implementing LRO:

drivers/net/s2io.c
drivers/net/netxen/

Steve.

#4 lore raw
Quoted 10 lines · Steve Wise
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · On Sat, Feb 24, 2007 at 04:44:23PM -0800, [email protected] wrote:

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

Doing this in a LLDD doesn't sound like a good idea. Have you tried doing this in the core networking code instead?

It looks like both Netxen and Neterion drivers already have this. So I think for now the LLDD implements LRO. The stack supports it by virtue

That's argument to further avoiding compounding the problem, by reinventing the wheel for each driver.

Jeff

#5 lore raw
Quoted 6 lines · Jeff Garzik
Quoted 5 lines · Steve Wise
Quoted 4 lines · Christoph Hellwig
Quoted 3 lines · On Sat, Feb 24, 2007 at 04:44:23PM -0800, [email protected] wrote:

From: Divy Le Ray <[email protected]>

Add all-in-sw lro support.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Doing this in a LLDD doesn't sound like a good idea. Have you tried doing this in the core networking code instead?

It looks like both Netxen and Neterion drivers already have this. So I think for now the LLDD implements LRO. The stack supports it by virtue

That's argument to further avoiding compounding the problem, by reinventing the wheel for each driver.

You're right. But cxgb3 has it now in the driver (tested and working). Shouldn't it be pulled in? When the network stack design gets done (which could take a few releases to finalize), all the drivers can be updated to use it. It doesn't seem reasonable to allow some drivers to support LRO and others to not support it...

Steve.

#6 lore raw
Quoted 6 lines · Steve Wise

You're right. But cxgb3 has it now in the driver (tested and working). Shouldn't it be pulled in? When the network stack design gets done (which could take a few releases to finalize), all the drivers can be updated to use it. It doesn't seem reasonable to allow some drivers to support LRO and others to not support it...

I have to agree with Steve here. We have been requesting the inclusion of myri10ge LRO for 5 months now (before 2.6.19). I could understand that duplicating LRO code between s2io and myri10ge was not a good idea at this point. But, I now see that Netxen got merged way later (in 2.6.20) but it got its LRO merged immediately. I guess the LRO is already duplicated between s2io and netxen then. It does not look fair to me at all.

Thank you for understanding our concerns.
Brice

#7 lore raw
Quoted 8 lines · Brice Goglin
Quoted 6 lines · Steve Wise

You're right. But cxgb3 has it now in the driver (tested and working). Shouldn't it be pulled in? When the network stack design gets done (which could take a few releases to finalize), all the drivers can be updated to use it. It doesn't seem reasonable to allow some drivers to support LRO and others to not support it...

Quoted 7 lines

I have to agree with Steve here. We have been requesting the inclusion of myri10ge LRO for 5 months now (before 2.6.19). I could understand that duplicating LRO code between s2io and myri10ge was not a good idea at this point. But, I now see that Netxen got merged way later (in 2.6.20) but it got its LRO merged immediately. I guess the LRO is already duplicated between s2io and netxen then. It does not look fair to me at all.

It was an error on my part, that should not be compounded. Three wrongs don't make a right, etc., etc.

The normal way this stuff works in Linux is that people work together to create common code that everybody uses. I would gladly accept patches to rip out the code from NetXen.

Jeff