IP LRO
Subsystems (2)
Hi,
We have recently implemented a reassembly of fragmented IP packets in mlx4_en driver. This offload gives a performance boost in case of incoming traffic with fragmented packets (such as UDP traffic with message size larger then MTU). The attached patch contains this offload. I believe that we can make this code generic, maybe part of inet_lro.
Please review and comment.
Thanks,
Yevgeny
Quoted 1 line
From
836650837d2c24014cdcc132c7c901676b1563d8Mon Sep 17 00:00:00 2001
From: Yevgeny Petrilin <[email protected]>
Date: Wed, 7 Jan 2009 19:31:59 +0200
Subject: [PATCH] IP LRO
--- drivers/net/mlx4/Makefile | 2 +- drivers/net/mlx4/en_frag.c | 246 ++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx4/en_params.c | 4 + drivers/net/mlx4/en_rx.c | 29 +++-- drivers/net/mlx4/mlx4_en.h | 36 ++++++- 5 files changed, 304 insertions(+), 13 deletions(-) create mode 100644 drivers/net/mlx4/en_frag.c
drivers/net/mlx4/Makefile +1 -1
@@ -6,4 +6,4 @@ mlx4_core-y := alloc.o catas.o cmd.o cq.o eq.o fw.o icm.o intf.o main.o mcg.o \ obj-$(CONFIG_MLX4_EN) += mlx4_en.o mlx4_en-y := en_main.o en_tx.o en_rx.o en_params.o en_port.o en_cq.o \ - en_resources.o en_netdev.o + en_resources.o en_netdev.o en_frag.o
drivers/net/mlx4/en_frag.c new file +246 -0
246 lines not on this page · raw message
drivers/net/mlx4/en_params.c +4 -0
@@ -59,6 +59,9 @@ MLX4_EN_PARM_INT(rss_mask, 0xf, "RSS hash type bitmask");MLX4_EN_PARM_INT (num_lro,MLX4_EN_MAX_LRO_DESCRIPTORS ,"Number of LRO sessions per ring or disabled (0)" ); +/* Allow reassembly of fragmented IP packets */ +MLX4_EN_PARM_INT (ip_reasm,1 ,"Allow reassembly of fragmented IP packets (!0)" ); +/* Priority pausing */ MLX4_EN_PARM_INT (pfctx,0 ,"Priority based Flow Control policy on TX[7:0]." " Per priority bit mask" );
@@ -73,6 +76,7 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) params->rss_xor = (rss_xor !=0 ); params->rss_mask = rss_mask &0x1f ; params->num_lro =min_t (int, num_lro ,MLX4_EN_MAX_LRO_DESCRIPTORS ); + params->ip_reasm = ip_reasm;for (i =1 ; i <=MLX4_MAX_PORTS ; i++) { params->prof[i].rx_pause =1 ; params->prof[i].rx_ppp = pfcrx;
drivers/net/mlx4/en_rx.c +18 -11
@@ -518,12 +518,12 @@ void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,/* Unmap a completed descriptor and free unused pages */ -static int mlx4_en_complete_rx_desc (struct mlx4_en_priv *priv, -struct mlx4_en_rx_desc *rx_desc, -struct skb_frag_struct *skb_frags, -struct skb_frag_struct *skb_frags_rx, -struct mlx4_en_rx_alloc *page_alloc, -int length) +int mlx4_en_complete_rx_desc (struct mlx4_en_priv *priv, +struct mlx4_en_rx_desc *rx_desc, +struct skb_frag_struct *skb_frags, +struct skb_frag_struct *skb_frags_rx, +struct mlx4_en_rx_alloc *page_alloc, +int length) {struct mlx4_en_dev *mdev = priv->mdev;struct mlx4_en_frag_info *frag_info;
@@ -566,11 +566,11 @@ fail: } -static struct sk_buff *mlx4_en_rx_skb (struct mlx4_en_priv *priv, -struct mlx4_en_rx_desc *rx_desc, -struct skb_frag_struct *skb_frags, -struct mlx4_en_rx_alloc *page_alloc, -unsigned int length) +struct sk_buff *mlx4_en_rx_skb (struct mlx4_en_priv *priv, +struct mlx4_en_rx_desc *rx_desc, +struct skb_frag_struct *skb_frags, +struct mlx4_en_rx_alloc *page_alloc, +unsigned int length) {struct mlx4_en_dev *mdev = priv->mdev;struct sk_buff *skb;
@@ -753,6 +753,12 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud }else { ip_summed =CHECKSUM_NONE ; priv->port_stats.rx_chksum_none++; +if (mdev->profile.ip_reasm && + cqe->status & +cpu_to_be16 (MLX4_CQE_STATUS_IPV4 ) && + !mlx4_en_rx_frags (priv, ring, rx_desc, + skb_frags, length, cqe)) + goto next; } }else { ip_summed =CHECKSUM_NONE ;
@@ -790,6 +796,7 @@ next: }/* If CQ is empty flush all LRO sessions unconditionally */ +mlx4_en_flush_frags (priv, ring);lro_flush_all (&ring->lro); out:
drivers/net/mlx4/mlx4_en.h +35 -1
@@ -104,6 +104,7 @@#define MLX4_EN_ALLOC_SIZE (PAGE_SIZE << MLX4_EN_ALLOC_ORDER)#define MLX4_EN_MAX_LRO_DESCRIPTORS 32 +#define MLX4_EN_NUM_IPFRAG_SESSIONS 16/* Receive fragment sizes; we use at most 4 fragments (for 9600 byte MTU * and 4K allocations) */
@@ -258,6 +259,19 @@ struct mlx4_en_tx_ring {spinlock_t comp_lock; }; + +struct mlx4_en_ipfrag { +struct sk_buff *fragments; +__be32 saddr; +__be32 daddr; +__be16 id; +u8 protocol; +int total_len; +u16 offset; +unsigned int vlan; +__be16 sl_vid; +}; +struct mlx4_en_rx_desc {struct mlx4_wqe_srq_next_seg next;/* actual number of entries depends on rx ring stride */
@@ -284,6 +298,7 @@ struct mlx4_en_rx_ring {void *rx_info;unsigned long bytes;unsigned long packets; +struct mlx4_en_ipfrag ipfrag[MLX4_EN_NUM_IPFRAG_SESSIONS ]; };
@@ -335,6 +350,7 @@ struct mlx4_en_port_profile {struct mlx4_en_profile {int rss_xor;int num_lro; +int ip_reasm;u8 rss_mask;u32 active_ports;u32 small_pkt_int;
@@ -489,7 +505,13 @@ struct mlx4_en_priv {struct mlx4_en_stat_out_mbox hw_stats; }; - +int mlx4_en_rx_frags (struct mlx4_en_priv *priv,struct mlx4_en_rx_ring *ring, +struct mlx4_en_rx_desc *rx_desc, +struct skb_frag_struct *skb_frags, +unsigned int length, +struct mlx4_cqe *cqe); +void mlx4_en_flush_frags (struct mlx4_en_priv *priv, +struct mlx4_en_rx_ring *ring);void mlx4_en_destroy_netdev (struct net_device *dev);int mlx4_en_init_netdev (struct mlx4_en_dev *mdev,int port,struct mlx4_en_port_profile *prof);
@@ -542,6 +564,18 @@ int mlx4_en_map_buffer(struct mlx4_buf *buf);void mlx4_en_unmap_buffer (struct mlx4_buf *buf);void mlx4_en_calc_rx_buf (struct net_device *dev); +int mlx4_en_complete_rx_desc (struct mlx4_en_priv *priv, +struct mlx4_en_rx_desc *rx_desc, +struct skb_frag_struct *skb_frags, +struct skb_frag_struct *skb_frags_rx, +struct mlx4_en_rx_alloc *page_alloc, +int length); +struct sk_buff *mlx4_en_rx_skb (struct mlx4_en_priv *priv, +struct mlx4_en_rx_desc *rx_desc, +struct skb_frag_struct *skb_frags, +struct mlx4_en_rx_alloc *page_alloc, +unsigned int length); +void mlx4_en_set_default_rss_map (struct mlx4_en_priv *priv,struct mlx4_en_rss_map *rss_map,int num_entries,int num_rings);
Signature · 1 line
1.5.4
Hi Yevgeny.
Quoted 6 lines · Yevgeny Petrilin
We have recently implemented a reassembly of fragmented IP packets in
mlx4_endriver. This offload gives a performance boost in case of incoming traffic with fragmented packets (such as UDP traffic with message size larger then MTU). The attached patch contains this offload. I believe that we can make this code generic, maybe part ofinet_lro.
Please review and comment.
Frankly from the patch it is quite hard to tell if it is suitable or not for the generic usage. For example no structure access or lookup are guarded with some locks, likely they are somewhere in the driver itself, so at least it should be documented. Fragment structure can be rearranged to better fit the alignment rules of the platform (there are gaps even on 32bit). Please provide higher-level description on how it operates compared to existing GRO/LRO (except that it is one layer lower), how strcutres are operated, what are the lifetime rules for them and appropriate skbs, what are the usage case. How will it live with GRO/LRO, i.e. who will steal the skb if it matches both subsystems.
Signature · 1 line
Evgeniy Polyakov
Hi,
Thanks for your comments
Quoted 7 lines
Quoted 6 lines
We have recently implemented a reassembly of fragmented IP packets in
mlx4_endriver. This offload gives a performance boost in case of incoming traffic with fragmented packets (such as UDP traffic with message size larger then MTU). The attached patch contains this offload. I believe that we can make this code generic, maybe part ofinet_lro.
Please review and comment.
Quoted 11 lines
Frankly from the patch it is quite hard to tell if it is suitable or not for the generic usage. For example no structure access or lookup are guarded with some locks, likely they are somewhere in the driver itself, so at least it should be documented. Fragment structure can be rearranged to better fit the alignment rules of the platform (there are gaps even on 32bit). Please provide higher-level description on how it operates compared to existing GRO/LRO (except that it is one layer lower), how strcutres are operated, what are the lifetime rules for them and appropriate skbs, what are the usage case. How will it live with GRO/LRO, i.e. who will steal the skb if it matches both subsystems.
The patch that I sent is suitable for our driver only. Naturally, to make
the code generic, changes are required. The structures protection is done
in the driver's receive flow. The sessions are per RX ring, and for each ring we handle the skbs sequentially.
This feature only handles packets that are not eligible for LRO. The skb should be IPv4 and IP fragmented. We currently only work with skb_frags, but there should not be a problem to add skb mode.
Packet is flushed in the following cases:
1. The last fragment of the IP packet arrived.
2. Received an "out of order" fragment (its offset doesn't fit what we are expecting) In this case all the aggregated fragments are flushed, and we start a new session.
3. Finished completion handle, we don't want to delay the packets for a long time.
Yevgeny