diff mbox

[net-next,V1,08/12] net/mlx5e: Move to checksum complete

Message ID 1455791573-5270-9-git-send-email-saeedm@mellanox.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Saeed Mahameed Feb. 18, 2016, 10:32 a.m. UTC
From: Matthew Finlay <matt@mellanox.com>

Use checksum complete for all IP packets, unless they are HW LRO,
in which case, use checksum unnecessary.

Signed-off-by: Matt Finlay <matt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

Comments

Tom Herbert Feb. 19, 2016, 2:25 a.m. UTC | #1
On Thu, Feb 18, 2016 at 2:32 AM, Saeed Mahameed <saeedm@mellanox.com> wrote:
> From: Matthew Finlay <matt@mellanox.com>
>
> Use checksum complete for all IP packets, unless they are HW LRO,
> in which case, use checksum unnecessary.
>
Awesome! Thanks for this fix.


> Signed-off-by: Matt Finlay <matt@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_rx.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> index dd959d9..519a07f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> @@ -167,14 +167,15 @@ static inline bool is_first_ethertype_ip(struct sk_buff *skb)
>  static inline void mlx5e_handle_csum(struct net_device *netdev,
>                                      struct mlx5_cqe64 *cqe,
>                                      struct mlx5e_rq *rq,
> -                                    struct sk_buff *skb)
> +                                    struct sk_buff *skb,
> +                                    bool   lro)
>  {
>         if (unlikely(!(netdev->features & NETIF_F_RXCSUM)))
>                 goto csum_none;
>
> -       if (likely(cqe->hds_ip_ext & CQE_L4_OK)) {
> +       if (lro) {
>                 skb->ip_summed = CHECKSUM_UNNECESSARY;
> -       } else if (is_first_ethertype_ip(skb)) {
> +       } else if (likely(is_first_ethertype_ip(skb))) {
>                 skb->ip_summed = CHECKSUM_COMPLETE;
>                 skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
>                 rq->stats.csum_sw++;
> @@ -211,7 +212,7 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
>         if (unlikely(mlx5e_rx_hw_stamp(tstamp)))
>                 mlx5e_fill_hwstamp(tstamp, get_cqe_ts(cqe), skb_hwtstamps(skb));
>
> -       mlx5e_handle_csum(netdev, cqe, rq, skb);
> +       mlx5e_handle_csum(netdev, cqe, rq, skb, !!lro_num_seg);
>
>         skb->protocol = eth_type_trans(skb, netdev);
>
> --
> 1.7.1
>
Or Gerlitz Feb. 19, 2016, 8:20 a.m. UTC | #2
On Fri, Feb 19, 2016 at 4:25 AM, Tom Herbert <tom@herbertland.com> wrote:
> On Thu, Feb 18, 2016 at 2:32 AM, Saeed Mahameed <saeedm@mellanox.com> wrote:
>> From: Matthew Finlay <matt@mellanox.com>
>>
>> Use checksum complete for all IP packets, unless they are HW LRO,
>> in which case, use checksum unnecessary.
>>
> Awesome! Thanks for this fix.
Or Gerlitz Feb. 19, 2016, 8:21 a.m. UTC | #3
On Fri, Feb 19, 2016 at 4:25 AM, Tom Herbert <tom@herbertland.com> wrote:
> On Thu, Feb 18, 2016 at 2:32 AM, Saeed Mahameed <saeedm@mellanox.com> wrote:
>> From: Matthew Finlay <matt@mellanox.com>

>> Use checksum complete for all IP packets, unless they are HW LRO,
>> in which case, use checksum unnecessary.

> Awesome!

I know...

> Thanks for this fix.

we consider it  a feature ...
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index dd959d9..519a07f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -167,14 +167,15 @@  static inline bool is_first_ethertype_ip(struct sk_buff *skb)
 static inline void mlx5e_handle_csum(struct net_device *netdev,
 				     struct mlx5_cqe64 *cqe,
 				     struct mlx5e_rq *rq,
-				     struct sk_buff *skb)
+				     struct sk_buff *skb,
+				     bool   lro)
 {
 	if (unlikely(!(netdev->features & NETIF_F_RXCSUM)))
 		goto csum_none;
 
-	if (likely(cqe->hds_ip_ext & CQE_L4_OK)) {
+	if (lro) {
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
-	} else if (is_first_ethertype_ip(skb)) {
+	} else if (likely(is_first_ethertype_ip(skb))) {
 		skb->ip_summed = CHECKSUM_COMPLETE;
 		skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
 		rq->stats.csum_sw++;
@@ -211,7 +212,7 @@  static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
 	if (unlikely(mlx5e_rx_hw_stamp(tstamp)))
 		mlx5e_fill_hwstamp(tstamp, get_cqe_ts(cqe), skb_hwtstamps(skb));
 
-	mlx5e_handle_csum(netdev, cqe, rq, skb);
+	mlx5e_handle_csum(netdev, cqe, rq, skb, !!lro_num_seg);
 
 	skb->protocol = eth_type_trans(skb, netdev);