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=-4.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_PASS 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 2E59EC282D8 for ; Fri, 1 Feb 2019 21:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E760820863 for ; Fri, 1 Feb 2019 21:44:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="ctG6uG8n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbfBAVoJ (ORCPT ); Fri, 1 Feb 2019 16:44:09 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33034 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfBAVoJ (ORCPT ); Fri, 1 Feb 2019 16:44:09 -0500 Received: by mail-pf1-f194.google.com with SMTP id c123so3870595pfb.0 for ; Fri, 01 Feb 2019 13:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=zrCCfhooULD3j1xMFnMUEu1ii3cqHBcdlROvoYnwBS0=; b=ctG6uG8nyqB4bUjaMkJpmNCNrl+B3RmhndG3UldbEHy4WQXiSIRU2xuuYhi62T6isg V4smss8IZr4YMnr0a8G/jrET9s2YPfFl8NaPZpvOJFPeIb7zc163aVlMgWGC60fL3QhB JBr29hUytn9qNdB50G3XgR0NnBAnhu+kgPrO04tpBLl44LONT2Fi1xUmMyv3M8+j+B6P b5UE3ljHhe1L8vqjUAUto32STE9Ud/gDXi5dCRMquXMmAOnNw9NFLyIHW08UBytQf0Dy 3yhAO7OVriEsjpzM4LIjWMvQ5z96muVd0mUOMrz1owXQ6ZPyjjPZ/zEMFDGbyZznnse3 Rlew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=zrCCfhooULD3j1xMFnMUEu1ii3cqHBcdlROvoYnwBS0=; b=uSbFQpOi7hxXVYLbae5fQ0JwunBqPe5dkFhwXqxQ/eKKGDs95uSSqNX3Y57SAiBbxL lpF4CO0H20TOH2YHSdWgGZV/1viQBMEaECLtEQGoQsiPhzlJaAzVQJqU9wlFWEsZlKv5 Zli7mXZfYeLjWEL1+iO6IWFBZPKCP+ExVbazpzcrZJae4SxrAIjrC4mWlt3YwbyuRti9 FjUsmrAppXm6l5M3iSVn+ASud8ra0i5VhbnSmkqWncN4ywrjjuzSQAySZ1HgilyX7g1d p7Dvs5aLei6/Mog4KmEWs5FdDyypbrLgSYUxMKnuD9xsL8NhrVENfWbqFS2Ddi+vpG2M FHoQ== X-Gm-Message-State: AJcUukfLYeixb4cobzEJ9wRskLYMhsBFoO7XgPteVE/FR0OhcDbiqog9 ZqfcBE4eaHWUxK3G9tjJHmRYYA== X-Google-Smtp-Source: ALg8bN6TWAsRjMX7d9LuWs6BAB/G5yFwQuhmYf/n3pDZiGeGsy+R9CqF+zCmNehRqIT7diSsEf7M9Q== X-Received: by 2002:a62:e201:: with SMTP id a1mr40264523pfi.75.1549057448341; Fri, 01 Feb 2019 13:44:08 -0800 (PST) Received: from cakuba.hsd1.ca.comcast.net ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id r4sm27036234pgn.54.2019.02.01.13.44.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Feb 2019 13:44:08 -0800 (PST) Date: Fri, 1 Feb 2019 13:44:03 -0800 From: Jakub Kicinski To: Daniel Borkmann Cc: Jesper Dangaard Brouer , ast@kernel.org, David Miller , Maciej Fijalkowski , netdev@vger.kernel.org, john.fastabend@gmail.com, David Ahern , Saeed Mahameed Subject: Re: Co-existing XDP generic and native mode? (Re: [PATCH bpf-next v5 5/8] xdp: Provide extack messages when prog attachment failed) Message-ID: <20190201134403.44131386@cakuba.hsd1.ca.comcast.net> In-Reply-To: References: <20190201001954.4130-1-maciej.fijalkowski@intel.com> <20190201001954.4130-6-maciej.fijalkowski@intel.com> <20190131191101.2e9dc9f6@cakuba.hsd1.ca.comcast.net> <20190201080236.446d84d4@redhat.com> <20190201104738.7a3b33d6@cakuba.hsd1.ca.comcast.net> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 1 Feb 2019 22:33:22 +0100, Daniel Borkmann wrote: > On 02/01/2019 07:47 PM, Jakub Kicinski wrote: > >> These are only refactor ideas, so if you can argue why your internal > >> feature request for simultaneous generic and native make more sense, > >> then I'm open for allowing this ? > > > > The request was actually to enable xdpoffload and xdpgeneric at the > > same time. I'm happy to have that as another HW offload exclusive > > for now :) > > The latter is probably fine, though what's the concrete use case? :) I think it was more of a "I expected this to work, since driver+offload worked" than a feature request. Looking back at it it was filed as bug I converted it to feature. > Reason we kept native vs generic separate is mainly so that native XDP > drivers are discouraged to punt missing features to generic hook instead > of properly implementing them in native mode. Agreed, although one could make a counter argument that the performance should be a strong enough incentive and we shouldn't stop people for experimenting and prototyping :) The code change looks simple enough: diff --git a/net/core/dev.c b/net/core/dev.c index 8e276e0192a1..ce4880e5e95d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7976,11 +7976,13 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, enum bpf_netdev_command query; struct bpf_prog *prog = NULL; bpf_op_t bpf_op, bpf_chk; + bool offload; int err; ASSERT_RTNL(); - query = flags & XDP_FLAGS_HW_MODE ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG; + offload = flags & XDP_FLAGS_HW_MODE; + query = offload ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG; bpf_op = bpf_chk = ops->ndo_bpf; if (!bpf_op && (flags & (XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE))) @@ -7991,8 +7993,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, bpf_chk = generic_xdp_install; if (fd >= 0) { - if (__dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG) || - __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG_HW)) + if (!offload && __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG)) return -EEXIST; if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && __dev_xdp_query(dev, bpf_op, query)) @@ -8003,8 +8004,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, if (IS_ERR(prog)) return PTR_ERR(prog); - if (!(flags & XDP_FLAGS_HW_MODE) && - bpf_prog_is_dev_bound(prog->aux)) { + if (!offload && bpf_prog_is_dev_bound(prog->aux)) { NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported"); bpf_prog_put(prog); return -EINVAL; Do you think we shouldn't do it?