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=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT 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 BC51FC43381 for ; Thu, 28 Feb 2019 18:38:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EC34218C3 for ; Thu, 28 Feb 2019 18:38:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="MWYV+fgw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387911AbfB1SiZ (ORCPT ); Thu, 28 Feb 2019 13:38:25 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]:40543 "EHLO mail-pf1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387823AbfB1SiX (ORCPT ); Thu, 28 Feb 2019 13:38:23 -0500 Received: by mail-pf1-f180.google.com with SMTP id h1so10130103pfo.7 for ; Thu, 28 Feb 2019 10:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I+dO6fb560nqulv8oBkuJC2z7m09wba+k97Cy5oX9kw=; b=MWYV+fgwqA9/uS6OZE2kuX9agoHVH+fxYVZkbukOuOx+l6cBtQ+ySEVHgXRGELzAxc sEKCEvnuzJr5iVynjaCY0T0INxPtfNNUIVxNInAFNtKOwnleugJvrNUy6Q/WlwWsLA9p zpsLQfLKHUwNIVPudsUwzkMGvf6r2snKDyDvMQaXgCETURnfsfBu8qYTs3MrngVDeu/k FROFgyy8GwydnJB47mJz2YCrtZ0jWNXFXu2pEDf+53X9kWORnSlwohQmc9xAxYoLJVjX kqsQsMj/yydo60cc7jFNb4faL0K14WiaTRnCFiw07cHJTOtkEexKRRota7aBlmZBPNwM dW0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I+dO6fb560nqulv8oBkuJC2z7m09wba+k97Cy5oX9kw=; b=OqJ8FtH4oqYe/KZqSUI9yEU/29E+0X/vm3ES+hrAAIl7dOgEKo5AFktK5eIbrhrPZO m06MfGCg4e1QUY9KnoYrOEk1JlmikFIMkW3dHz2MaA3MB124BrnVIEPVMKARhqyPxeII QSRklwm/Z2HYX1QJIT+GWNbZISFutK3YR+kzIywSvpsTFHIuHnwErDu0yEJJzX6IVphU 92FpXLlAr7IOvekIbWxwAKOGi6eN/DUA5teyAfTrgquTzmsmAvfxtQVNroV2PQ1KuyiH yHPXjD4hWRQJE53SuSCgFgkb9JSlOcxPDH9HKOHDu2nTj134kRRH/o6JY5XyKITPcC7G uODA== X-Gm-Message-State: AHQUAuZufFwlVTMH0hUC8SKNkCkXaoXJa6pIS420b1Fvz5EUHKQY5kHt s+em05UBzF4XWOQZvoe0U1eg7HDWC7Y= X-Google-Smtp-Source: AHgI3IbU4KLzacWdQWQ7N+8PMEyuUPCmws7acm7R1M7djYg+bfkTXqCDc14Qj8IYAuNTGrudX4R+cA== X-Received: by 2002:aa7:85d1:: with SMTP id z17mr995773pfn.226.1551379102516; Thu, 28 Feb 2019 10:38:22 -0800 (PST) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c10sm25262702pfo.19.2019.02.28.10.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 10:38:21 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [RFC 6/6] mlx5: report XDP errors through extack Date: Thu, 28 Feb 2019 10:38:09 -0800 Message-Id: <20190228183809.25417-7-sthemmin@microsoft.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228183809.25417-1-sthemmin@microsoft.com> References: <20190228183809.25417-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Stephen Hemminger In case of errors in setting up XDP, report error through extack string rather than console log. Signed-off-by: Stephen Hemminger --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index e5f74eb986b3..f8e3661c6846 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4177,18 +4177,20 @@ static void mlx5e_tx_timeout(struct net_device *dev) queue_work(priv->wq, &priv->tx_timeout_work); } -static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog) +static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog, + struct netlink_ext_ack *extack) { - struct net_device *netdev = priv->netdev; struct mlx5e_channels new_channels = {}; if (priv->channels.params.lro_en) { - netdev_warn(netdev, "can't set XDP while LRO is on, disable LRO first\n"); + NL_SET_ERR_MSG(extack, + "can't set XDP while LRO is on, disable LRO first"); return -EINVAL; } if (MLX5_IPSEC_DEV(priv->mdev)) { - netdev_warn(netdev, "can't set XDP with IPSec offload\n"); + NL_SET_ERR_MSG(extack, + "can't set XDP with IPSec offload"); return -EINVAL; } @@ -4196,15 +4198,16 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog) new_channels.params.xdp_prog = prog; if (!mlx5e_rx_is_linear_skb(priv->mdev, &new_channels.params)) { - netdev_warn(netdev, "XDP is not allowed with MTU(%d) > %d\n", - new_channels.params.sw_mtu, MLX5E_XDP_MAX_MTU); + NL_SET_ERR_MSG(extack, + "XDP is not allowed with large MTU"); return -EINVAL; } return 0; } -static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) +static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog, + struct netlink_ext_ack *extack) { struct mlx5e_priv *priv = netdev_priv(netdev); struct bpf_prog *old_prog; @@ -4215,7 +4218,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) mutex_lock(&priv->state_lock); if (prog) { - err = mlx5e_xdp_allowed(priv, prog); + err = mlx5e_xdp_allowed(priv, prog, extack); if (err) goto unlock; } @@ -4297,11 +4300,12 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp) { switch (xdp->command) { case XDP_SETUP_PROG: - return mlx5e_xdp_set(dev, xdp->prog); + return mlx5e_xdp_set(dev, xdp->prog, xdp->extack); case XDP_QUERY_PROG: xdp->prog_id = mlx5e_xdp_query(dev); return 0; default: + NL_SET_ERR_MSG(xdp->extack, "Unsupported XDP command"); return -EINVAL; } } -- 2.17.1