Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14452706ybl; Mon, 30 Dec 2019 10:21:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxGMPe4FtOS6TppY4awqYYjuE9MY6M7Ox9Ps7HaOEEZmmNksBfNrDEpGVMtom5GrRCRWNkd X-Received: by 2002:a05:6830:1141:: with SMTP id x1mr1492557otq.120.1577730109086; Mon, 30 Dec 2019 10:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577730109; cv=none; d=google.com; s=arc-20160816; b=z6O7+g8RX6J1P/TXc1IKkJ8TmOf9VTfiaPV4rfuUBfduzBjO7YamIa4kPf1rsoaf3s LKrCpZgjwspQqZO+g4flrOoDI8h7Iflbx/h8fNOj8yAjKBa7CK/RtvGG1DeSOhjYm8zr 8j89UKaEUvnCRSac4Rc31M7O6Sqr3Mt352UiH1xB9ea8N08NbYXj+m7KPlJUAN1B6p36 BtAAxlAX98IQQ+cVFDFQ/vdNMpVB8rgKsnOqXGp6Gy8F2u4c//FjxCWwe3p2QwNXD/fU yo5562dy8MGaKubGaTLq6ksfxSWTlhqssstoSOzoV54vi7dlj6Tw2/IIhd9ZLlusAVcK 4iNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=w0q654yqDEnffJ0BauqH2GM/TgoupvqMZ4bdJnZRrYA=; b=Nmqq/TRgT6wRKpE8JPwTxRq38WUwWYq8p/nGV1JUPLOcZRRmMdRZewVZlpxcNAqOYh 8J+x+GnGQbn9uOwtQSGEjnNsFQ7w0WZVVFLK78PJb8CC3+Pi+ywgSfj5f3i2D/dohhpo T2sIsXiEDnkD34nEuHugKG1GiHEm7S6zyj+jS87NyWqAaYVJuk5xkfrocHhbw+L58ALx rsod8dx6NAs8lPRUCCdUR9qHz6DlkeDlKTQRzW/b9W3PHC6hS53a6QNkCsNxA6tMXTQe O6u1dmSCZ67i7k1jaZmSDqYhQZBTHiJrsNX2l8SXaXkKlZ+bW/rXL17O8TcK639WWrug RASA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MG23K+tz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si10771168otj.258.2019.12.30.10.21.37; Mon, 30 Dec 2019 10:21:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MG23K+tz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727543AbfL3SU7 (ORCPT + 99 others); Mon, 30 Dec 2019 13:20:59 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44088 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727498AbfL3SU7 (ORCPT ); Mon, 30 Dec 2019 13:20:59 -0500 Received: by mail-ed1-f67.google.com with SMTP id bx28so33399064edb.11; Mon, 30 Dec 2019 10:20:57 -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=w0q654yqDEnffJ0BauqH2GM/TgoupvqMZ4bdJnZRrYA=; b=MG23K+tz5O/93loAW9k0F55CyVOXjs17QmgMRA6BN7XICGWToDF/npEWf/TF1zexim tDDlPWaTiPX3W53v41Y9bgQ+7/JhxHPUsLbULg4YFZYTjmam6q76mAy8IC2u/zeBvuJ2 ZydaHRxR7MFtbMv2e7v6OzPILVzlNv37OFk+o4SHST7PwaIMjRNmBp4G88Jz3bYdM3LF Hp/BOits5addgWkXD2KPkH9esfshnzZAM5oCurlel74wnKpDOA62/CUv2T2v9Iq619ms 6CwkcDNCrNKS8stc3w904JUQoAF0sKj9B6ntWRukRUO6c7Z6OIwWLgerfNaletdEHLkK E2lg== 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=w0q654yqDEnffJ0BauqH2GM/TgoupvqMZ4bdJnZRrYA=; b=UeBbQHEml2Gbl1Oc24822/ibaCi2przzVyqH943HhWLfv+Q8uao6ImM1aBjNo9FKo/ gEZUo7tHK0d+62r2JjMxvZ5IECBBcXq5FRam4l2VgCklLDjyazCjDwnwRBt2aEz/p1bg 4S2kbGE/DL6iKaLyaJy3A9hLnyIRnX16g6sLh62Egw0JrnNJn3/cc+Myt/yejRbjooO5 /jVbS81IjYmVb8sZsCq/HMK6YrC8Z0iWxfiOL4iaQeOlpckVNlfLVLYjiidBiSD7wdwq 5qMqAkqaZ7dSDnrgmgRU26pbIgHZTL5BaF0Dkn3CbvzdvZmV1Zc1ByG8VN06l4x9MJCH 2Gpw== X-Gm-Message-State: APjAAAWuPmXrZ8pV2M1XYkJYS8Mx88GE7v1R/9qUYITLr5Aj6nl3vX00 Eu+esy1gIRy7YtiCqHPwwVs= X-Received: by 2002:a17:906:2e46:: with SMTP id r6mr71882689eji.310.1577730056943; Mon, 30 Dec 2019 10:20:56 -0800 (PST) Received: from [10.67.50.49] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id f13sm5411640edq.26.2019.12.30.10.20.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Dec 2019 10:20:56 -0800 (PST) Subject: Re: [PATCH RFC net-next 05/19] net: dsa: tag_ar9331: add GRO callbacks To: Alexander Lobakin , "David S. Miller" Cc: Edward Cree , Andrew Lunn , Vivien Didelot , Hauke Mehrtens , Sean Wang , Matthias Brugger , Jiri Pirko , Eric Dumazet , Paolo Abeni , Jakub Kicinski , Taehee Yoo , Stephen Hemminger , Stanislav Fomichev , Daniel Borkmann , Song Liu , Matteo Croce , Jakub Sitnicki , Paul Blakey , Yoshiki Komachi , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20191230143028.27313-1-alobakin@dlink.ru> <20191230143028.27313-6-alobakin@dlink.ru> 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 qIWgvr3SIEuR6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pDHql+Wg/2qv3b G10n8gCguORqNGMsVRxrlLs7/himep7MrCc= Message-ID: Date: Mon, 30 Dec 2019 10:20:50 -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: <20191230143028.27313-6-alobakin@dlink.ru> 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 12/30/19 6:30 AM, Alexander Lobakin wrote: > Add GRO callbacks to the AR9331 tagger so GRO layer can now process > such frames. > > Signed-off-by: Alexander Lobakin This is a good example and we should probably build a tagger abstraction that is much simpler to fill in callbacks for (although indirect function calls may end-up killing performance with retpoline and friends), but let's consider this idea. > --- > net/dsa/tag_ar9331.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 77 insertions(+) > > diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c > index c22c1b515e02..99cc7fd92d8e 100644 > --- a/net/dsa/tag_ar9331.c > +++ b/net/dsa/tag_ar9331.c > @@ -100,12 +100,89 @@ static void ar9331_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, > *proto = ar9331_tag_encap_proto(skb->data); > } > > +static struct sk_buff *ar9331_tag_gro_receive(struct list_head *head, > + struct sk_buff *skb) > +{ > + const struct packet_offload *ptype; > + struct sk_buff *p, *pp = NULL; > + u32 data_off, data_end; > + const u8 *data; > + int flush = 1; > + > + data_off = skb_gro_offset(skb); > + data_end = data_off + AR9331_HDR_LEN; AR9331_HDR_LEN is a parameter here which is incidentally dsa_device_ops::overhead. > + > + data = skb_gro_header_fast(skb, data_off); > + if (skb_gro_header_hard(skb, data_end)) { > + data = skb_gro_header_slow(skb, data_end, data_off); > + if (unlikely(!data)) > + goto out; > + } > + > + /* Data that is to the left from the current position is already > + * pulled to the head > + */ > + if (unlikely(!ar9331_tag_sanity_check(skb->data + data_off))) > + goto out; This is applicable to all taggers, they need to verify the sanity of the header they are being handed. > + > + rcu_read_lock(); > + > + ptype = gro_find_receive_by_type(ar9331_tag_encap_proto(data)); If there is no encapsulation a tagger can return the frame's protocol directly, so similarly the tagger can be interrogated for returning that. > + if (!ptype) > + goto out_unlock; > + > + flush = 0; > + > + list_for_each_entry(p, head, list) { > + if (!NAPI_GRO_CB(p)->same_flow) > + continue; > + > + if (ar9331_tag_source_port(skb->data + data_off) ^ > + ar9331_tag_source_port(p->data + data_off)) Similarly here, the tagger could provide a function whose job is to return the port number from within its own tag. So with that being said, what do you think about building a tagger abstraction which is comprised of: - header length which is dsa_device_ops::overhead - validate_tag() - get_tag_encap_proto() - get_port_number() and the rest is just wrapping the general GRO list manipulation? Also, I am wondering should we somehow expose the DSA master net_device's napi_struct such that we could have the DSA slave net_devices call napi_gro_receive() themselves directly such that they could also perform additional GRO on top of Ethernet frames? -- Florian