From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE74CC2D0C2 for ; Fri, 3 Jan 2020 20:50:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80B6521835 for ; Fri, 3 Jan 2020 20:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OC+9IvFV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728657AbgACUuk (ORCPT ); Fri, 3 Jan 2020 15:50:40 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:38651 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727848AbgACUuk (ORCPT ); Fri, 3 Jan 2020 15:50:40 -0500 Received: by mail-pj1-f67.google.com with SMTP id l35so5147784pje.3; Fri, 03 Jan 2020 12:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JGc9D5zEn2o0lcVrmYX3RzYiRak+InYhZKaeLJxHuDc=; b=OC+9IvFVaC0V+hwAFlKP3lQ+86WDkVT3bIeu8kFJ1J8VBl9vRsLVF66swW5Ed7Rjy6 C1iemrKCodux9Sofixlv9w5FUuZWH1t2HVskcf881QYTH1GV9KnkTyoiIkyBnpVxb/hK QcJ+Za6Rne++DBX6ZBqwhTWn7xF+OJAwCZwWrTkVhxy/wQeBz0UUvE49hGp4lxfe6uOR 8xJnz3B0IHBKmnvusyGAG/qfywjje/31gBqmB3pWRMcazRIZgv8KDwWJ6g/cp2jGE2M+ 3sgNVeByoVzfnKcZKgwlrpakcoYg63XM58WzMVHdjoDQDdKT7zwOL39FX3iilf7LpT9M Wf7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=JGc9D5zEn2o0lcVrmYX3RzYiRak+InYhZKaeLJxHuDc=; b=t2cDCwVuU0N2+PGW+QU47p7TyegnpMkdWXj6MkYq4cmXV1hSrZBi4jX918YdtPVl7s m9c5IVu2FvK9rQYrvBr2ECbUXHeO4QltylNsg9Tkj2M89pJivk2c2RTQVYqiQASKy07o 2b1zyo0TlxEAaOUzNrbvYbRLFWAf7QtmboGlXFKNcmuXAzlNUsqB+VVjKTZ78C0lM2I2 sCImKLT9T96ZCC3H5eL9NxzbzoMXLw/YtEWY5AWb5Z6rRA6xEYBAzeRwNctLZTxA9BZH t6o2G6r0fgaK3XNft+pTWWiF0e6Yl6fHMotr0ZV62SEFN1uU4ulnz2AtQ8MRNOgeeKqp Mg0g== X-Gm-Message-State: APjAAAWfvI+xpGFZIu77g0oGvFt2VdNxfr7jVfxH1cEHtFgCszH3vIQG +wkpb0GuSNE3U68GEWk+0Bg= X-Google-Smtp-Source: APXvYqyskQdIKnfAyC9L13L+zG+g4mS3D5jHlvCY+EYdgx82n8fk2XrounkjXjhTbqwnjZz3xG5gdQ== X-Received: by 2002:a17:90a:246c:: with SMTP id h99mr29191034pje.134.1578084639116; Fri, 03 Jan 2020 12:50:39 -0800 (PST) Received: from [10.67.50.49] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id o17sm15361533pjq.1.2020.01.03.12.50.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Jan 2020 12:50:38 -0800 (PST) Subject: Re: [PATCH net-next] net: dsa: Remove indirect function call for flow dissection To: Vladimir Oltean Cc: netdev , Alexander Lobakin , Russell King , Andrew Lunn , Vivien Didelot , "David S. Miller" , Hauke Mehrtens , Woojung Huh , Microchip Linux Driver Support , Sean Wang , Matthias Brugger , Vladimir Oltean , Claudiu Manoil , Stanislav Fomichev , Daniel Borkmann , Song Liu , Petar Penkov , Matteo Croce , Jakub Sitnicki , Eric Dumazet , Paul Blakey , Yoshiki Komachi , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" References: <20200102233657.12933-1-f.fainelli@gmail.com> From: Florian Fainelli Autocrypt: addr=f.fainelli@gmail.com; prefer-encrypt=mutual; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5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Wg/2qv3b G10n8gCguORqNGMsVRxrlLs7/himep7MrCc= Message-ID: <91eb2720-d933-f1fd-8d50-e9a81434545b@gmail.com> Date: Fri, 3 Jan 2020 12:50:35 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/2/20 4:19 PM, Vladimir Oltean wrote: > Hi Florian, > > On Fri, 3 Jan 2020 at 01:39, Florian Fainelli wrote: >> >> We only need "static" information to be given for DSA flow dissection, >> so replace the expensive call to .flow_dissect() with an integer giving >> us the offset into the packet array of bytes that we must de-reference > > packet array? packed array? Yes, packet array skb->data[] if you prefe > >> to obtain the protocol number. The overhead was alreayd available from > > already > >> the dsa_device_ops structure so use that directly. >> >> The presence of a flow_dissect callback used to indicate that the DSA >> tagger supported returning that information,we now encode this with a >> proto_off value of DSA_PROTO_OFF_UNPSEC if the tagger does not support > > UNSPEC > >> providing that information yet. >> >> Signed-off-by: Florian Fainelli >> --- > > Unfortunately I don't really understand the DSA implementations of flow_dissect. > Is proto_off supposed to mean "the __be16 pointer difference A - B > between A. the position of the real EtherType and B. the current > skb->data (aka ETH_HLEN bytes into the frame, aka 2 bytes after the > normal EtherType was supposed to be)"? > Otherwise said, the offset in bytes between the real EtherType > position and skb->data is 2 * (proto_off + 1).> Furthermore, the offset in bytes is exactly equal to the tagger > overhead in bytes, unless it's a tag that doesn't push the EtherType > to the right, such as the trailer tag. The call path is the following on TX (e.g.: when you run a DHCP client), so this is always hit for raw packets: __sys_sendto packet_sendmsg packet_parse_headers __skb_flow_dissect and on RX this is not hit by default until you configure a RFS map on your DSA master network device (more on that below), then the call stack is: napi_complete_done gro_normal_list netif_receive_skb_list_internal get_rps_cpu skb_get_hash __skb_get_hash __skb_flow_dissect and this is called from the DSA master's RX path, so with an Ethernet frame that has the DSA switch tag, and for which eth_type_trans() has already been called so the SKB has already been pulled by ETH_HLEN and skb->protocol is ETH_P_XDSA. I don't think your formula works for EDSA which has an EtherType, but this would probably work for all tags we currently support except trailer. proto = (__be16 *)(skb->data)[overhead / 2 - 1]; > > If the above is indeed correct, can you just skip DSA_PROTO_OFF_UNSPEC > and add proper proto_off values "in blind" for all taggers? I think > it's rather safe to assume that they all push the EtherType to the > right with the exception of the trailer tag, which will have an offset > of -1 in terms of __be16 pointers, by the way (so your -1 encoding of > DSA_PROTO_OFF_UNSPEC won't work for it anyway). > > Also, documenting the unit of measurement for proto_off would really > go a long way. > > What is a good test that the flow_dissector does what it's supposed to > do with DSA? The commit that introduced flow dissection meant to fix it for the DSA master network device (as you can see from the call trace), and this was presumably meant to be used to steer traffic onto different RX or TX queues on the DSA master, which is IMHO the wrong location where it should be done for a number of reasons, but mainly because DSA slave network devices can inherit the number of RX queues of their DSA master and you can perform RFS there, in a standard way, without requiring further changes down net/core/flow_dissect.c. I don't think anyone except Alexander did serious investigation this. For now, what I am interested in is reducing the amount of technical debt and expensive function calls. -- Florian