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 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10CD6C48BC3 for ; Wed, 21 Feb 2024 00:50:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C0B96415F5; Wed, 21 Feb 2024 00:50:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XFz6s7kwfP2G; Wed, 21 Feb 2024 00:50:53 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 924E2415C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1708476653; bh=r6a3FHKwgsoldc+fJqpWn7tbgKTVaaDSRsxc6VMClUw=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=58pJcJBWBxx5PG69Ok2VeKuLcyxIUVUF9cK/wX3/46xMvqPllW/Nr+qkYECGN//jQ g1qmLaOil2oiSzPn2foHvUu8UbYwuunsK/tAFdBfzwdspUm9JF6KeGB8SaXi65q4zB xWqvSPOxcP6QB3eFqcgnpj+X3eAen+Evcd1rb9Ym8DzQlMABeadWGFniIivZADBFOB ZC+6vMTkGiXYnGB+17Bgy60+5AcuMXYXZjLSLos1aB4Z4536WmhdMTvKffCA+hUW26 7dF3uEDm6HMYIFGaXiUd8Dxe5ryieKl9+4atA3d4t+Q0c2cEW+Tf9lYb6RlFBUMqpV 8mrHxwyZ7KdVw== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 924E2415C5; Wed, 21 Feb 2024 00:50:53 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id DC5FE1BF39D for ; Wed, 21 Feb 2024 00:50:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C98E1607E3 for ; Wed, 21 Feb 2024 00:50:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t7LT593Au5cB for ; Wed, 21 Feb 2024 00:50:49 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.18; helo=mgamail.intel.com; envelope-from=alan.brady@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 03B63607A4 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 03B63607A4 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by smtp3.osuosl.org (Postfix) with ESMTPS id 03B63607A4 for ; Wed, 21 Feb 2024 00:50:48 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="2500780" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="2500780" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 16:50:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="9550962" Received: from dev1-atbrady.jf.intel.com ([10.166.241.35]) by fmviesa004.fm.intel.com with ESMTP; 20 Feb 2024 16:50:49 -0800 From: Alan Brady To: intel-wired-lan@lists.osuosl.org Date: Tue, 20 Feb 2024 16:49:44 -0800 Message-ID: <20240221004949.2561972-6-alan.brady@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221004949.2561972-1-alan.brady@intel.com> References: <20240221004949.2561972-1-alan.brady@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708476649; x=1740012649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AcjckNDpXZ2CrE6JuYN8FCLzPvU85vFH345Qss+kUF4=; b=adAJAwgj+O0fevUON/7ijrxsHVfQekcnMMG92PdpYF/+NQffDKs7wc6y bXQIDxG7HujEaf5QNFoV0AmyqL5abRRu0shs8+eVp0Tsw7ez5gmdfh0/u fdy5xBf0TkEZfOCCF8DXn2cYW2kFCV4/7bZ34JScRYNditJKOGpBmD/EM ktPHmlSxY1xgGEAL38Jiufv3stRndhcDKvN9k7O/n1pMY8e2e0Rmphj9y Oawj2GS83DkKKowTW8wFM/f80Rs4Z0TKPFybRnWDpc0JvbnbyKejEqoow 8iGG22FV0A6ucAGmlVMpDQjaxz4k6GWHkJWN569p7w3uQEOUFShAHIgu0 A==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=adAJAwgj Subject: [Intel-wired-lan] [PATCH v5 05/10 iwl-next] idpf: add async_handler for MAC filter messages 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: netdev@vger.kernel.org, Alan Brady , Alexander Lobakin Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" There are situations where the driver needs to add a MAC filter but we're explicitly not allowed to sleep so we can wait for a virtchnl message to complete. This adds an async_handler for asynchronously sent messages for MAC filters so that we can better handle if there's an error of some kind. If success we don't need to do anything else, but if we failed to program the new filter we really should remove it from our list of MAC filters. If we don't remove bad filters, what I expect to happen is after a reset of some kind we try to program the MAC filter again and it fails again. This is clearly wrong and I would expect to be confusing for the user. It could also be the failure is for a delete MAC filter message but those filters get deleted regardless. Not much we can do about a delete failure. Tested-by: Alexander Lobakin Signed-off-by: Alan Brady --- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c index ca0fd7144e75..fa12b08e7965 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c @@ -3551,6 +3551,75 @@ u32 idpf_get_vport_id(struct idpf_vport *vport) return le32_to_cpu(vport_msg->vport_id); } +/** + * idpf_mac_filter_async_handler - Async callback for mac filters + * @adapter: private data struct + * @xn: transaction for message + * @ctlq_msg: received message + * + * In some scenarios driver can't sleep and wait for a reply (e.g.: stack is + * holding rtnl_lock) when adding a new mac filter. It puts us in a difficult + * situation to deal with errors returned on the reply. The best we can + * ultimately do is remove it from our list of mac filters and report the + * error. + */ +static int idpf_mac_filter_async_handler(struct idpf_adapter *adapter, + struct idpf_vc_xn *xn, + const struct idpf_ctlq_msg *ctlq_msg) +{ + struct virtchnl2_mac_addr_list *ma_list; + struct idpf_vport_config *vport_config; + struct virtchnl2_mac_addr *mac_addr; + struct idpf_mac_filter *f, *tmp; + struct list_head *ma_list_head; + struct idpf_vport *vport; + u16 num_entries; + int i; + + /* if success we're done, we're only here if something bad happened */ + if (!ctlq_msg->cookie.mbx.chnl_retval) + return 0; + + /* make sure at least struct is there */ + if (xn->reply_sz < sizeof(*ma_list)) + goto invalid_payload; + + ma_list = ctlq_msg->ctx.indirect.payload->va; + mac_addr = ma_list->mac_addr_list; + num_entries = le16_to_cpu(ma_list->num_mac_addr); + /* we should have received a buffer at least this big */ + if (xn->reply_sz < struct_size(ma_list, mac_addr_list, num_entries)) + goto invalid_payload; + + vport = idpf_vid_to_vport(adapter, le32_to_cpu(ma_list->vport_id)); + if (!vport) + goto invalid_payload; + + vport_config = adapter->vport_config[le32_to_cpu(ma_list->vport_id)]; + ma_list_head = &vport_config->user_config.mac_filter_list; + + /* We can't do much to reconcile bad filters at this point, however we + * should at least remove them from our list one way or the other so we + * have some idea what good filters we have. + */ + spin_lock_bh(&vport_config->mac_filter_list_lock); + list_for_each_entry_safe(f, tmp, ma_list_head, list) + for (i = 0; i < num_entries; i++) + if (ether_addr_equal(mac_addr[i].addr, f->macaddr)) + list_del(&f->list); + spin_unlock_bh(&vport_config->mac_filter_list_lock); + dev_err_ratelimited(&adapter->pdev->dev, "Received error sending MAC filter request (op %d)\n", + xn->vc_op); + + return 0; + +invalid_payload: + dev_err_ratelimited(&adapter->pdev->dev, "Received invalid MAC filter payload (op %d) (len %zd)\n", + xn->vc_op, xn->reply_sz); + + return -EINVAL; +} + /** * idpf_add_del_mac_filters - Add/del mac filters * @vport: Virtual port data structure @@ -3578,6 +3647,7 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport, VIRTCHNL2_OP_DEL_MAC_ADDR; xn_params.timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC; xn_params.async = async; + xn_params.async_handler = idpf_mac_filter_async_handler; vport_config = adapter->vport_config[np->vport_idx]; spin_lock_bh(&vport_config->mac_filter_list_lock); -- 2.43.0