Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp9126831rwi; Tue, 25 Oct 2022 15:42:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79jhP4c/i7mY8iCrwcx/S7stbnWxhcCwW+hpPrfg+3HKXkxKFmVumS1xdyoJ6qwAdpLA1Y X-Received: by 2002:a17:902:f68d:b0:185:43a1:555a with SMTP id l13-20020a170902f68d00b0018543a1555amr39951262plg.2.1666737759685; Tue, 25 Oct 2022 15:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666737759; cv=none; d=google.com; s=arc-20160816; b=q9t5Mns21BW+D6Q3/mTBL9YHnTPPVeKuHTuOIlsMnGzflInVIW2LBCTL+o2z1BJxh+ y5CMhGVLetV/YqrSGWnndMJlvv2Vvj/mjxmdmuTEUdC/63gS+Yd9IXjGI8RvzLob7AVc otW9ji8bXcLivvyNpMTrNAJNQ5MWax8gKYbTdWxqqQ6xdqNaiWIs5EDGbSiY3fg6JhGQ STVU9Jfd5AWeBEqiwdkuAuo4yieH6EffksEBtMKTcBdwn41B7aboWOQjxAOWLwaC04rN RLz8d9BNQjQyT5x5hUf1KpIQnfj+tOpgC/uSJEfuuk1AJncwSCxx8KX0AE5g1XrJqogj F7ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kg+oKuPzQbTyP1EocNquVGFw+o9EuqAdUm+zEML38gE=; b=YhkwqMf79SUPlw2YrHoKbJQkpWkpO1Dy68oFFI3QCS9IqHEXURas3eaY9lP+hpRLN/ /7OpdZI+uVBGISrGBt8rhlCj2ephwfg9Qx/WwxCMSXfPYZBjTSkMyJ9sbH+QLcH2zUCk r3Y/cd/j3MqK97ZfGFgi7LG5zp8f7YvI8jtV1Fa4JAd9xwQrw3VnHx0E5BNzOhy4Ao7G oKQ6jGIuDKFp+BY+5jxQDWZAD4lA0nB4Dy34SPSyim7fUY0Vx2loKZXudXCiU8LFvIup CrM3EXdnug0z9m+84CNgFgoL8le74Cq8Fodt9ShLKehEMCrn7ogoqS5Wo5DbijwOn2yK XoIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=rl891+VA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g21-20020aa78195000000b005669cd93898si4053791pfi.233.2022.10.25.15.42.28; Tue, 25 Oct 2022 15:42:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=rl891+VA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbiJYWKG (ORCPT + 99 others); Tue, 25 Oct 2022 18:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232140AbiJYWJs (ORCPT ); Tue, 25 Oct 2022 18:09:48 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965C213E84; Tue, 25 Oct 2022 15:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=kg+oKuPzQbTyP1EocNquVGFw+o9EuqAdUm+zEML38gE=; b=rl891+VA1wNWpKwJKkDAu9W60J LLvLHuoukgccNS6YMAE5xHIrK+wuAflDjT3Ulvv+xBUqBY8Ti0vN6vlBpIY7QkV57uu40DLG9UbrJ jAF5eWHxpVyHtjfG5YARs7VdoQnrU72oulWU7SjxEolRQ3mD5qP1DxEFzJY8XfWbjDNk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1onS62-000aE9-85; Wed, 26 Oct 2022 00:08:30 +0200 Date: Wed, 26 Oct 2022 00:08:30 +0200 From: Andrew Lunn To: Shenwei Wang Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: Re: [PATCH 1/1] net: fec: add initial XDP support Message-ID: References: <20221025201156.776576-1-shenwei.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221025201156.776576-1-shenwei.wang@nxp.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +#define FEC_ENET_XDP_PASS 0 > +#define FEC_ENET_XDP_CONSUMED BIT(0) > +#define FEC_ENET_XDP_TX BIT(1) > +#define FEC_ENET_XDP_REDIR BIT(2) I don't know XDP, so maybe a silly question. Are these action mutually exclusive? Are these really bits, or should it be an enum? fec_enet_run_xdp() does not combine them as bits. > +static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf) > +{ > + struct fec_enet_private *fep = netdev_priv(dev); > + bool is_run = netif_running(dev); You have the space, so maybe call it is_running. > + struct bpf_prog *old_prog; > + unsigned int dsize; > + int i; > + > + switch (bpf->command) { > + case XDP_SETUP_PROG: > + if (is_run) > + fec_enet_close(dev); fec_net_close() followed by fec_enet_open() is pretty expensive. The PHY is stopped and disconnected, and then connected and started. That will probably trigger an auto-neg, which takes around 1.5 seconds before the link is up again. Maybe you should optimise this. I guess the real issue here is you need to resize the RX ring. You need to be careful with that anyway. If the machine is under memory pressure, you might not be able to allocate the ring, resulting in a broken interface. What is recommended for ethtool --set-ring is that you first allocate the new ring, and if that is successful, free the old ring. If the allocation fails, you still have the old ring, and you can safely return -ENOMEM and still have a working interface. So i think you can split this patch up into a few parts: XDP using the default ring size. Your benchmarks show it works, its just not optimal. But the resulting smaller patch will be easier to review. Add support for ethtool set-ring, which will allow you to pick apart the bits of fec_net_close() and fec_enet_open() which are needed for changing the rings. This might actually need a refactoring patch? And then add support for optimal ring size for XDP. Andrew