From patchwork Thu Jan 14 16:17:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryk Rybak X-Patchwork-Id: 1426411 X-Patchwork-Delegate: anthony.l.nguyen@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DGmjs0n8tz9sVk for ; Fri, 15 Jan 2021 01:22:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AABAA873B1; Thu, 14 Jan 2021 14:22:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BTpLBmaJeSQN; Thu, 14 Jan 2021 14:22:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id F2A4A8739A; Thu, 14 Jan 2021 14:22:38 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 196A91BF3D4 for ; Thu, 14 Jan 2021 14:22:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 1476E86BA2 for ; Thu, 14 Jan 2021 14:22:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jwx4SWqDZVs1 for ; Thu, 14 Jan 2021 14:22:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by whitealder.osuosl.org (Postfix) with ESMTPS id 1B91786B3C for ; Thu, 14 Jan 2021 14:22:37 +0000 (UTC) IronPort-SDR: pRtpkVJuiLlzOq0j6ftkoqtzlpAxbuDAZWdKr2UyMNftUSdGqQwnrOjBRmdArSFkYMsoi5wg1i wZ2xguzluHUw== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="158148048" X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="158148048" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2021 06:22:36 -0800 IronPort-SDR: UGja4mLg398ojEOLuXyS5/EqYVtyRGfCs8LfSX+0vjQK+JK9rLXKoRdnTjvLrtdiOExerhVawt UDF7tP3RNsBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="398060702" Received: from amlin-018-147.igk.intel.com ([10.102.18.147]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2021 06:22:35 -0800 From: Eryk Rybak To: intel-wired-lan@lists.osuosl.org Date: Thu, 14 Jan 2021 16:17:06 +0000 Message-Id: <20210114161706.9224-1-eryk.roch.rybak@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net-next v2] i40e: Log error for oversized MTU on device X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eryk Rybak , Aleksandr Loktionov Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" When attempting to link XDP prog with MTU larger than supported, user is not informed why XDP linking fails. Adding proper error message: "MTU too large to enable XDP". Due to the lack of support for non-static variables in netlinks extended ACK feature, additional information has been added to dmesg to better inform about invalid MTU setting. Signed-off-by: Aleksandr Loktionov Signed-off-by: Eryk Rybak Tested-by: Kiran Bhandare A Contingent Worker at Intel Tested-by: Kiran Bhandare A Contingent Worker at Intel --- v2: add dmesg trace, change commit message drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) base-commit: 3fac2a7d07287daca672479f02d4849c27bc7806 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 2a7e116..0ea04cb 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -12933,9 +12933,10 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * i40e_xdp_setup - add/remove an XDP program * @vsi: VSI to changed * @prog: XDP program + * @extack: netlink extended ack **/ -static int i40e_xdp_setup(struct i40e_vsi *vsi, - struct bpf_prog *prog) +static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog, + struct netlink_ext_ack *extack) { int frame_size = vsi->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; struct i40e_pf *pf = vsi->back; @@ -12944,8 +12945,12 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, int i; /* Don't allow frames that span over multiple buffers */ - if (frame_size > vsi->rx_buf_len) + if (frame_size > vsi->rx_buf_len) { + NL_SET_ERR_MSG_MOD(extack, "MTU too large to enable XDP"); + dev_info(&pf->pdev->dev, + "MTU of %u bytes is too large to enable XDP (maximum: %u bytes)\n", vsi->netdev->mtu, vsi->rx_buf_len); return -EINVAL; + } /* When turning XDP on->off/off->on we reset and rebuild the rings. */ need_reset = (i40e_enabled_xdp_vsi(vsi) != !!prog); @@ -13254,7 +13259,7 @@ static int i40e_xdp(struct net_device *dev, switch (xdp->command) { case XDP_SETUP_PROG: - return i40e_xdp_setup(vsi, xdp->prog); + return i40e_xdp_setup(vsi, xdp->prog, xdp->extack); case XDP_SETUP_XSK_POOL: return i40e_xsk_pool_setup(vsi, xdp->xsk.pool, xdp->xsk.queue_id);