Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp729924lqo; Fri, 10 May 2024 13:04:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQbLkcFS9pAM5jZJFpklgpgrino7Ckh8eU3iiLaDBQPMI6AfbFqqNnir+4bSkJ9jAM5abaGuuohTLTnl7W5VW0l8krfCPFvKtq/gLRaQ== X-Google-Smtp-Source: AGHT+IHTWGUrYALX9Nhss4OxECpsTpIn9g5825hTMrYB6XuN8uqzoxK3EBt1n2XFsBK2xavfvdUF X-Received: by 2002:a19:644d:0:b0:51f:3b4d:b087 with SMTP id 2adb3069b0e04-52210473f62mr2584196e87.63.1715371449716; Fri, 10 May 2024 13:04:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715371449; cv=pass; d=google.com; s=arc-20160816; b=JGXjhVO18Y1s6diQhOsAzzRa69vadXMSVbRK6VWXPaBv5N46JVwtvJ7yuSQ5ZPFYVq iIFUJjjVRmN0lvIkMXMz4Q9jdPJDESWIYJdDPG0wpODH8f8NY+62aGI/r8KTn5bvhn3C 16q4ZbSjySoyGC2hjas5hXA7Gvzn0gLlTwR0/wwYNVzkKgp8RvTaOjNQj+6w6tVusGG0 nWeQSpYs57Qis4fw7Jre8NytMba/fZcpGsfmT+A0j0tv8JklQd78jHBnXAayzg7aDsRf HtZ40K/dN7r2+NUoViKP74VRjHHbbyH3dJMVziOIw2AsdNecPYEka2qMSfF8ocwieodG yLlA== 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:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=RskZ8n5PeN0X02QsGxL+0rF1EfA4GzHbygmSEftJMSg=; fh=zY1OiHJjUKmAQ2UCqcETDH5JYpDFRDDioD9NSEsJj+8=; b=i56eUbFUSmZ77jtv7kMfRf+T73RGoPEDdJL1AqrN27GcV5IBSr1ls1SqJV+U6J5UBV +bdIks1gbUO9VKDLDGzxkcKw5Sm258RwWs/BuI3Z89dNLgbkcq1NhsRdXLwNsQaUNbbf Q0RX7yK9FfwmKrO3XBpRbt10ijvZVj4G/6mYOhcdSNdCLUC7QDP5g480vUMnKUb/Prha Wib6GPPNrVQJ9wzHdJdXqJiY9/EXcPeMNH30ubwpPMs7FLG/jGSrENeWpuYn6R41XYQm +pKJp/xEqUNboPbC/aIoQJ++RaDpXE73D1VKvnSR1FkF5AilH/O720hOQOKWs949yQXT fIfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@davidwei-uk.20230601.gappssmtp.com header.s=20230601 header.b=uiZsIrz8; arc=pass (i=1 dkim=pass dkdomain=davidwei-uk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-176154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176154-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c04320si218187766b.899.2024.05.10.13.04.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 13:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@davidwei-uk.20230601.gappssmtp.com header.s=20230601 header.b=uiZsIrz8; arc=pass (i=1 dkim=pass dkdomain=davidwei-uk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-176154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176154-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 477921F238CA for ; Fri, 10 May 2024 20:04:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB35D4D9E8; Fri, 10 May 2024 20:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="uiZsIrz8" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B90D14CB28 for ; Fri, 10 May 2024 20:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715371436; cv=none; b=hhM3un89sFVn6bwI8+R63Uec47SBhcBzE1cdofe8mXdw0dBQovk2M7DXESe2OnBYQ+sSj60tp9g2aRNmVL8qlgow1J2dpXXNeEF1z+TSezlzloDl3oinZW6t2oNNscRqcpt5TuANToi6RJ0NDZvUKNZE1rrGSlcjOCbPfB9hu/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715371436; c=relaxed/simple; bh=SxPIHdr8S+eRfdtMNOCxfApLuqEkP+GJwy3FGwuKuXU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DPoalLgquwa3XJ31cUd4/tKKtl+442EkiGFN0WEpFeSiUUn77bSYV1lXgygiZz1TiemNP1Y/l7dtaKFoAwojD/KG7vvUoFE6pK8tP44RwJuSkcV5D3eus54pNdvBJjp1JcCHqZMBB50yPR2Y/FSJr8vqDEmO6SXlzehhOmVAwQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk; spf=none smtp.mailfrom=davidwei.uk; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b=uiZsIrz8; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1ec92e355bfso22351245ad.3 for ; Fri, 10 May 2024 13:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1715371434; x=1715976234; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=RskZ8n5PeN0X02QsGxL+0rF1EfA4GzHbygmSEftJMSg=; b=uiZsIrz8SMQXKrZmOR0alh6olSRedJ14V3AMT7QFTckfotZeJadzVEHQ3iBI1+Li82 NCwTDl9/x496x8BpbWH35nnePcAK7t0OcQYhRsgxz3aZsu7Q8sayVBfM6cEuLyNJ9ETW 4AbEDevqkT0o8Tz3MxxYVNZvKx46Mapuh6PI7hTWJ4/dx0C/qzony26aIMpM/04+09QT 3ogiNoyl7zfd/kQqpRwX55AyEjCvNVBK9gT0W6BCAulXLJJZCKvBApxWM9Zw/kTSB6Z5 46wGFS9wbvNskpjX9TzhDhiCyvkuxNBuE41KTJueKsvzlMOt9lu4M8nkAA2KM49vLIh/ 0mug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715371434; x=1715976234; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RskZ8n5PeN0X02QsGxL+0rF1EfA4GzHbygmSEftJMSg=; b=cwTAOdE1XxyFx+FjPC/CurAKDCzLGpm287736jyKB2UcfMYpRrneYnOTKxwIfwYMkB M+gechyWmW1UlzySImkGUFPhlG+hqhCz6miX0B8YQJXm8Z3Xedizki0fzajjym1UjoE3 8bGI2sxd4DvGtYf6ti47M59as9ZBTAGqnXOclgw9Ds+yUpaH6JtytrYbZA3FizZfamsS +Gg5syI9JPJnWJ2aVDcC6hm8GRze3sioSJ+NDLSMk76jK5Q2Lsa3ZBNCbWAP0LmCuVcy 8VCTHphrkRifyXOoQpxZc0r06mu5yshUBJ9RxqNLOKtO3WWUENfEx/3LwBt7cMAWv4xr ZOHA== X-Forwarded-Encrypted: i=1; AJvYcCU5IdGbvw5QvUMHU2xK48QM/vAMk8qIvQyo5RKsRPlqgLM3jQMI7RthPUVQYrKHfuSFZ6BQF7l3QNE778mAUM4ytXj1ercBejmOjTt2 X-Gm-Message-State: AOJu0YwSioMp7x7ffJQybnadvd7Qj6oCtGZQ88LwGuiLF80GxwRtgs5s 6G7cYf4eu8Sp/0HSAud4+kG4xP/Vbp3ISYzDFzeHvvGrS4uTcHds83Fn58Noh9A= X-Received: by 2002:a17:902:a9ca:b0:1eb:1473:c878 with SMTP id d9443c01a7336-1ef43e266bbmr35101295ad.36.1715371433758; Fri, 10 May 2024 13:03:53 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1156:1:1cbd:da2b:a9f2:881? ([2620:10d:c090:500::7:10f0]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf2f722sm36034885ad.120.2024.05.10.13.03.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 May 2024 13:03:53 -0700 (PDT) Message-ID: <0ef50183-42d4-4abd-adeb-bd92b030fe6a@davidwei.uk> Date: Fri, 10 May 2024 13:03:50 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V1 8/9] bnxt_en: Add TPH support in BNXT driver Content-Language: en-GB To: Andy Gospodarek , Vadim Fedorenko 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> From: David Wei In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024-05-10 08: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. > >> 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. Hi Andy, I have an implementation of the new ndo_queue_stop/start() API [1] and would appreciate comments. I've been trying to test it but without avail due to FW issues. [1]: https://lore.kernel.org/netdev/20240502045410.3524155-1-dw@davidwei.uk/ > >> 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 >>>> >>