Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp743991lqo; Fri, 10 May 2024 13:34:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlGdJMt2gzNACdFZCbwv3IvXbiHrXkvlaUfXFody+UlnNPtuVK0UXyBgEysqZzmRwQepZAgC2yCkXZtonxwR8oxhDTqS5bEseXo2SRfw== X-Google-Smtp-Source: AGHT+IHuiskJyC88zWCmUkwlH3j8zxD3hYfdZZyu245WTYg4r/aap4Km4fzYVWFEd4+llr9QJWGD X-Received: by 2002:a05:6a00:3c91:b0:6ec:ef1c:4dcd with SMTP id d2e1a72fcca58-6f4df3d7edbmr5533015b3a.6.1715373294479; Fri, 10 May 2024 13:34:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715373293; cv=pass; d=google.com; s=arc-20160816; b=yArvoZRoc1d45kSdwbgPzIxl2Sv/237AoRRbtOJLjpC3OnntzB+1I5yOnk+smKqa7K RoBVMNNsUQRkkLHnRcxIXs/EAJzvLFJARhHVIeIBLos3+dvSCAic5kG0UgeiQgvEu1JO fFs6c5RD64iSE1s8lzbwyUDACm1/BprrmrsWM576QDFEF3X0vokk7F8qAgDLOyPUi2dF N1uqrrh5IDWgP1xsAZm2eow2EuoKhDwygLWb0fouUZjm74vYywxnDRCHhKKHaxtKWiBW aGpZmibL9sYTYcvsvWTtMoJpHfpixhqSZzQErW5m9D0uDvFVXYJViNS+hBMD69JvfVC6 xgSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=cetiniD45CBouS5rWdVFhgRrr6hhWZD4pNNYMEDnJI4=; fh=jaA67NMVkYb6b56fG0zU76guBXH4s80jEkZJyrN+cM8=; b=jRY82Tuh/gWJTyeJ89HzvAdc0p08H5BO7aHDb97GUmaAg+W+GVmaCdgz7IKbYOz5Wk nNi0OOoQOtr5o7wnSW/pzV1cq+lgv1PmXDfyzNJHIatE54VNnTzjVQOjHlbTFuhLiUAU Keqykr0NfuyA9YM3ay5KKZoFbdbvtO29mqV30QJeIqZ8dXLuM/G8MnbyAxQOzjipNedG 8CXJurzT+d9VeEl18G3B43EnJ3joOukwrHWUSDhvy1fhzCiLqoNSdX93aNvkDiJVdC6W pIjs5MLU12CTUVmJ0DRp6szs9e4FJY6XNeC1NHqJELNjjzrKkEDXWzkKWTlFxkYOwfMD 6F1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vMhpDnWP; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-176172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f7350si4128199a12.350.2024.05.10.13.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 13:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vMhpDnWP; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-176172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3AD21B2447F for ; Fri, 10 May 2024 20:34:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C104938DCC; Fri, 10 May 2024 20:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vMhpDnWP" Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40DB1288D1 for ; Fri, 10 May 2024 20:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715373235; cv=none; b=Ar9kteba4Io+C+SSo5NZhn3QOnoFM+CnZypfRDyInD6BbGgnfyGTmpVywXfJ48xcMlqnG8txj6vn9uj9hesn8ScULU9UoJS5qBo0BX82VQwes5L9vnm/aaDvLntJbJlUImp7+9lqSwd+i2FjfRvSzo8SGdKhIBIQ/knUI/QoX6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715373235; c=relaxed/simple; bh=f+QoB78WiDYe+erb2kWuyu4YFE/EwYr6fk+DmZHq3t4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=o6zo3HpyrmWhu7Pg8q/G8XByDHtbC7rJYMrKV7CkbnBmZBrIV0pzzv2LQCgdYZu3MfLcOYVffhq2ed3MxnKg0HUUHc9mZRHGz2SMFGG2ftZKxu3JHlbIMP95Ltuxz7MCrQvwlK1/4jSsFV4MZNwAXAkC1wiYx0JVgjEl9Okouic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vMhpDnWP; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715373231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cetiniD45CBouS5rWdVFhgRrr6hhWZD4pNNYMEDnJI4=; b=vMhpDnWPLEhdMMdfgh/RCC1rcFcQqx2gtAW5PeT8G6siHlKgqG9xztERMtLROosjfDbEjm iuOf12MLNGN4k5863GsZeyYE2dRzqIYkx0D2tQqFv7YmdVDjsv/zjUb5KvWlzsRKz7ydne gUnaI9/SqYA+1qjNhLTu6UPpnQzJiR0= Date: Fri, 10 May 2024 21:33:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH V1 8/9] bnxt_en: Add TPH support in BNXT driver To: Andy Gospodarek Cc: Ajit Khaparde , Wei Huang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, bhelgaas@google.com, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alex.williamson@redhat.com, michael.chan@broadcom.com, manoj.panicker2@amd.com, Eric.VanTassell@amd.com References: <20240509162741.1937586-1-wei.huang2@amd.com> <20240509162741.1937586-9-wei.huang2@amd.com> <868a4758-2873-4ede-83e5-65f42cb12b81@linux.dev> <4c6a8b86-6544-4c99-a0f2-030e2ec4e98f@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 10/05/2024 16:23, Andy Gospodarek wrote: > On Fri, May 10, 2024 at 11:35:35AM +0100, Vadim Fedorenko wrote: >> On 10.05.2024 04:55, Ajit Khaparde wrote: >>> On Thu, May 9, 2024 at 2:50 PM Vadim Fedorenko >>> wrote: >>>> >>>> On 09/05/2024 17:27, Wei Huang wrote: >>>>> From: Manoj Panicker >>>>> >>>>> As a usage example, this patch implements TPH support in Broadcom BNXT >>>>> device driver by invoking pcie_tph_set_st() function when interrupt >>>>> affinity is changed. >>>>> >>>>> Reviewed-by: Ajit Khaparde >>>>> Reviewed-by: Andy Gospodarek >>>>> Reviewed-by: Wei Huang >>>>> Signed-off-by: Manoj Panicker >>>>> --- >>>>> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 51 +++++++++++++++++++++++ >>>>> drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++ >>>>> 2 files changed, 55 insertions(+) >>>>> >>>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>>>> index 2c2ee79c4d77..be9c17566fb4 100644 >>>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>>>> @@ -55,6 +55,7 @@ >>>>> #include >>>>> #include >>>>> #include >>>>> +#include >>>>> >>>>> #include "bnxt_hsi.h" >>>>> #include "bnxt.h" >>>>> @@ -10491,6 +10492,7 @@ static void bnxt_free_irq(struct bnxt *bp) >>>>> free_cpumask_var(irq->cpu_mask); >>>>> irq->have_cpumask = 0; >>>>> } >>>>> + irq_set_affinity_notifier(irq->vector, NULL); >>>>> free_irq(irq->vector, bp->bnapi[i]); >>>>> } >>>>> >>>>> @@ -10498,6 +10500,45 @@ static void bnxt_free_irq(struct bnxt *bp) >>>>> } >>>>> } >>>>> >>>>> +static void bnxt_rtnl_lock_sp(struct bnxt *bp); >>>>> +static void bnxt_rtnl_unlock_sp(struct bnxt *bp); >>>>> +static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify, >>>>> + const cpumask_t *mask) >>>>> +{ >>>>> + struct bnxt_irq *irq; >>>>> + >>>>> + irq = container_of(notify, struct bnxt_irq, affinity_notify); >>>>> + cpumask_copy(irq->cpu_mask, mask); >>>>> + >>>>> + if (!pcie_tph_set_st(irq->bp->pdev, irq->msix_nr, >>>>> + cpumask_first(irq->cpu_mask), >>>>> + TPH_MEM_TYPE_VM, PCI_TPH_REQ_TPH_ONLY)) >>>>> + pr_err("error in configuring steering tag\n"); >>>>> + >>>>> + if (netif_running(irq->bp->dev)) { >>>>> + rtnl_lock(); >>>>> + bnxt_close_nic(irq->bp, false, false); >>>>> + bnxt_open_nic(irq->bp, false, false); >>>>> + rtnl_unlock(); >>>>> + } >>>> >>>> Is it really needed? It will cause link flap and pause in the traffic >>>> service for the device. Why the device needs full restart in this case? >>> >>> In that sequence only the rings are recreated for the hardware to sync >>> up the tags. >>> >>> Actually its not a full restart. There is no link reinit or other >>> heavy lifting in this sequence. >>> The pause in traffic may be momentary. Do IRQ/CPU affinities change frequently? >>> Probably not? >> >> From what I can see in bnxt_en, proper validation of link_re_init parameter is >> not (yet?) implemented, __bnxt_open_nic will unconditionally call >> netif_carrier_off() which will be treated as loss of carrier with counters >> increment and proper events posted. Changes to CPU affinities were >> non-disruptive before the patch, but now it may break user-space >> assumptions. > > From my testing the link should not flap. I just fired up a recent net-next > and confirmed the same by calling $ ethtool -G ens7f0np0 rx 1024 which does a > similar bnxt_close_nic(bp, false, false)/bnxt_open_nic(bp, false, false) as > this patch. Link remained up -- even with a non-Broadocm link-partner. Hi Andy! Well, it might be that from phy PoV the link didn't flap, but from network subsystem it does flap: [root@host ~]# ethtool -G eth0 rx 512 [root@host ~]# cat /sys/class/net/eth0/carrier_changes 6 [root@host ~]# ethtool -G eth0 rx 1024 [root@host ~]# cat /sys/class/net/eth0/carrier_changes 8 And this is what I'm referring to when talking about user-space experience. But I would like to see new ndo_queue_stop/start implementation, it may help in this situation. >> Does FW need full rings re-init to update target value, which is one u32 write? >> It looks like overkill TBH. > > Full rings do not, but the initialization of that particular ring associated > with this irq does need to be done. On my list of things we need to do in > bnxt_en is implement the new ndo_queue_stop/start and ndo_queue_mem_alloc/free > operations and once those are done we could make a switch as that may be less > disruptive. > >> And yes, affinities can be change on fly according to the changes of the >> workload on the host. >> >>>> >>>> >>>>> +} >>>>> + >>>>> +static void bnxt_irq_affinity_release(struct kref __always_unused *ref) >>>>> +{ >>>>> +} >>>>> + >>>>> +static inline void __bnxt_register_notify_irqchanges(struct bnxt_irq *irq) >>>> >>>> No inlines in .c files, please. Let compiler decide what to inline. >>>> >>>>> +{ >>>>> + struct irq_affinity_notify *notify; >>>>> + >>>>> + notify = &irq->affinity_notify; >>>>> + notify->irq = irq->vector; >>>>> + notify->notify = bnxt_irq_affinity_notify; >>>>> + notify->release = bnxt_irq_affinity_release; >>>>> + >>>>> + irq_set_affinity_notifier(irq->vector, notify); >>>>> +} >>>>> + >>>>> static int bnxt_request_irq(struct bnxt *bp) >>>>> { >>>>> int i, j, rc = 0; >>>>> @@ -10543,6 +10584,7 @@ static int bnxt_request_irq(struct bnxt *bp) >>>>> int numa_node = dev_to_node(&bp->pdev->dev); >>>>> >>>>> irq->have_cpumask = 1; >>>>> + irq->msix_nr = map_idx; >>>>> cpumask_set_cpu(cpumask_local_spread(i, numa_node), >>>>> irq->cpu_mask); >>>>> rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask); >>>>> @@ -10552,6 +10594,15 @@ static int bnxt_request_irq(struct bnxt *bp) >>>>> irq->vector); >>>>> break; >>>>> } >>>>> + >>>>> + if (!pcie_tph_set_st(bp->pdev, i, >>>>> + cpumask_first(irq->cpu_mask), >>>>> + TPH_MEM_TYPE_VM, PCI_TPH_REQ_TPH_ONLY)) { >>>>> + netdev_err(bp->dev, "error in setting steering tag\n"); >>>>> + } else { >>>>> + irq->bp = bp; >>>>> + __bnxt_register_notify_irqchanges(irq); >>>>> + } >>>>> } >>>>> } >>>>> return rc; >>>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h >>>>> index dd849e715c9b..0d3442590bb4 100644 >>>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h >>>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h >>>>> @@ -1195,6 +1195,10 @@ struct bnxt_irq { >>>>> u8 have_cpumask:1; >>>>> char name[IFNAMSIZ + 2]; >>>>> cpumask_var_t cpu_mask; >>>>> + >>>>> + int msix_nr; >>>>> + struct bnxt *bp; >>>>> + struct irq_affinity_notify affinity_notify; >>>>> }; >>>>> >>>>> #define HWRM_RING_ALLOC_TX 0x1 >>>> >>