Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757986AbcK3T1Y (ORCPT ); Wed, 30 Nov 2016 14:27:24 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:40354 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756879AbcK3TZq (ORCPT ); Wed, 30 Nov 2016 14:25:46 -0500 Date: Wed, 30 Nov 2016 14:25:39 -0500 (EST) Message-Id: <20161130.142539.1927956259851457047.davem@davemloft.net> To: salil.mehta@huawei.com Cc: yisen.zhuang@huawei.com, mehta.salil.lnk@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com Subject: Re: [PATCH V2 net-next] net: hns: Fix to conditionally convey RX checksum flag to stack From: David Miller In-Reply-To: <20161129130945.919372-1-salil.mehta@huawei.com> References: <20161129130945.919372-1-salil.mehta@huawei.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 30 Nov 2016 10:26:17 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1331 Lines: 42 From: Salil Mehta Date: Tue, 29 Nov 2016 13:09:45 +0000 > + /* We only support checksum for IPv4,UDP(over IPv4 or IPv6), TCP(over > + * IPv4 or IPv6) and SCTP but we support many L3(IPv4, IPv6, MPLS, > + * PPPoE etc) and L4(TCP, UDP, GRE, SCTP, IGMP, ICMP etc.) protocols. > + * We want to filter out L3 and L4 protocols early on for which checksum > + * is not supported. ... > + */ > + l3id = hnae_get_field(flag, HNS_RXD_L3ID_M, HNS_RXD_L3ID_S); > + l4id = hnae_get_field(flag, HNS_RXD_L4ID_M, HNS_RXD_L4ID_S); > + if ((l3id != HNS_RX_FLAG_L3ID_IPV4) && > + ((l3id != HNS_RX_FLAG_L3ID_IPV6) || > + (l4id != HNS_RX_FLAG_L4ID_UDP)) && > + ((l3id != HNS_RX_FLAG_L3ID_IPV6) || > + (l4id != HNS_RX_FLAG_L4ID_TCP)) && > + (l4id != HNS_RX_FLAG_L4ID_SCTP)) > + return; I have a hard time understanding this seemingly overcomplicated check. It looks like if L3 is IPV4 it will accept any underlying L4 protocol, but is that what is really intended? That doesn't match what this new comment states. My understanding is that the chip supports checksums for: UDP/IPV4 UDP/IPV6 TCP/IPV4 TCP/IPV6 SCTP/IPV4 SCTP/IPV6 So the simplest thing is to validate each level one at a time: if (l3 != IPV4 && l3 != IPV6) return; if (l4 != UDP && l4 != TCP && l4 != SCTP) return;