From patchwork Mon Apr 1 03:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavan Chebbi X-Patchwork-Id: 13612508 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 DBB752900 for ; Mon, 1 Apr 2024 03:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711943669; cv=none; b=sjE2Q/WHW+z3VSvydoheidUr5QNJeEFrZ1ZqM57fvg74M+JBamDpUsYR9jBcAh3G0WFIT37CQnneS36qSbIvcpeR5BTM3fMH8S4KCjKqsa/uEUJoatqJSsm2qm5koLKTBti8i88Lwkd9fkJ1ksxI4BhMxObJcnAGlTFV7mcOmMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711943669; c=relaxed/simple; bh=rO2MpXEnA5lJ3PnVWjtu4Id7Bc2Nen4BUGpkbmuP2NU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=XlhN8Td3yQHl/EaHjLPd0gP5sVB9SaZfmnAipNgFgaXLxOFSeZ6ISHqQ9raLdr47vXmdKta+7qgbMN24YhVL5xQGzSLWxY6FmTmgF7Bceid3aCiHNGz1+Zpc7ZJ/q0C1wOuOVaQ/p81q2U2pXRiGU3Q1jiJQJzw6tAtUq9e2kgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=evphzsQI; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="evphzsQI" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e6b729669bso3165403b3a.3 for ; Sun, 31 Mar 2024 20:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1711943667; x=1712548467; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xuE3VnBqMuSperiTqR8BuLLQZMQckOOFQZAiTAI55VA=; b=evphzsQIcrEnVK/KwIwlPJwkkc3oV4BtTrcHxUAD5RiB3JsO/hvbg+gmU8YWu92iIW DN81eru5TiUNDEQ0wIDwFfy2ATQ6AF9ukoP0IQc/q3oqRrW19n1jxCQRhrZSuPxra8m+ cPYH4NVD5PryEaNd1vNnjWgTRSmJ4KdaCS2dc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711943667; x=1712548467; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xuE3VnBqMuSperiTqR8BuLLQZMQckOOFQZAiTAI55VA=; b=Q6i6Tq8PIRV0x4EXtbvr5yykjI3GZe6MW/Z8pLO+GKt/swzpgstEwoCiqLZSKIJ/SU z0t0JZoIZdfTdujF/xyuXg/cCwTaguKtrm3D8mM2WtAzEZQ7+E59w478risIHclEHVUO pEikFXfFgLdy4JoS9vOUhABt30GAXSjcwkfDkSEvRaNgrNt6dg7cYMdc4ldJbJLBDgoH Pd1vSh+5hCFPbxBO6dPXxzvE9jjakq0UM9z74l/PDoyieD6BdPkQVNYeySICR+DtfqAN ifCt73H5uy9W5P6RV+kRO1wJD2566m6ECTfeDqHtKkB5FkHk90AFm1ht4KSkYU6kw3Yq DLVQ== X-Forwarded-Encrypted: i=1; AJvYcCU8cs8SfjWrDliP4rDX5HccNomoOPtSxFZU7SCdXPhbdn7fjijKto9kJSrtADvdQdJsH7G8oPw8Mi3AO7RPr+fhL6G3q0ag X-Gm-Message-State: AOJu0YwDirfX3MRA/x5wSmAzg1eoWdIVDcmGEJHg3VUZy1smzQsyyt1E XmE4HwVHeaYwijmRA/vKRDh67J5aFGBrs6OYbX9t37tRaC1Zyu+/sqwarc6FWQ== X-Google-Smtp-Source: AGHT+IHH8aO0K1LolGxAAojoERED0v6RiQ5ifv3y6EjgQbAIcvtjQn8GTZ8Iy7bfmr+pK9KQ6H3K8w== X-Received: by 2002:a05:6a00:a23:b0:6ea:f351:1df9 with SMTP id p35-20020a056a000a2300b006eaf3511df9mr8899372pfh.23.1711943666891; Sun, 31 Mar 2024 20:54:26 -0700 (PDT) Received: from PC-MID-R740.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id j26-20020a62b61a000000b006e73d1c0c0esm6860781pff.154.2024.03.31.20.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 20:54:26 -0700 (PDT) From: Pavan Chebbi To: michael.chan@broadcom.com Cc: davem@davemloft.net, edumazet@google.com, gospo@broadcom.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, Somnath Kotur , Pavan Chebbi Subject: [PATCH net-next 2/7] bnxt_en: Enable XPS by default on driver load Date: Sun, 31 Mar 2024 20:57:25 -0700 Message-Id: <20240401035730.306790-3-pavan.chebbi@broadcom.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240401035730.306790-1-pavan.chebbi@broadcom.com> References: <20240401035730.306790-1-pavan.chebbi@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Somnath Kotur Enable XPS on default during NIC open. The choice of Tx queue is based on the CPU executing the thread that submits the Tx request. The pool of Tx queues will be spread evenly across both device-attached NUMA nodes(local) and remote NUMA nodes. Signed-off-by: Somnath Kotur Reviewed-by: Michael Chan Signed-off-by: Pavan Chebbi --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6e24a341ad28..54955f878b73 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11804,6 +11804,45 @@ static void bnxt_cfg_usr_fltrs(struct bnxt *bp) bnxt_cfg_one_usr_fltr(bp, usr_fltr); } +static int bnxt_set_xps_mapping(struct bnxt *bp) +{ + int numa_node = dev_to_node(&bp->pdev->dev); + unsigned int q_idx, map_idx, cpu, i; + const struct cpumask *cpu_mask_ptr; + int nr_cpus = num_online_cpus(); + cpumask_t *q_map; + int rc = 0; + + q_map = kcalloc(bp->tx_nr_rings_per_tc, sizeof(*q_map), GFP_KERNEL); + if (!q_map) + return -ENOMEM; + + /* Create CPU mask for all TX queues across MQPRIO traffic classes. + * Each TC has the same number of TX queues. The nth TX queue for each + * TC will have the same CPU mask. + */ + for (i = 0; i < nr_cpus; i++) { + map_idx = i % bp->tx_nr_rings_per_tc; + cpu = cpumask_local_spread(i, numa_node); + cpu_mask_ptr = get_cpu_mask(cpu); + cpumask_or(&q_map[map_idx], &q_map[map_idx], cpu_mask_ptr); + } + + /* Register CPU mask for each TX queue excluding the ones marked for XDP */ + for (q_idx = 0; q_idx < bp->dev->real_num_tx_queues; q_idx++) { + map_idx = q_idx % bp->tx_nr_rings_per_tc; + rc = netif_set_xps_queue(bp->dev, &q_map[map_idx], q_idx); + if (rc) { + netdev_warn(bp->dev, "Error setting XPS for q:%d\n", q_idx); + break; + } + } + + kfree(q_map); + + return rc; +} + static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { int rc = 0; @@ -11866,8 +11905,12 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) } } - if (irq_re_init) + if (irq_re_init) { udp_tunnel_nic_reset_ntf(bp->dev); + rc = bnxt_set_xps_mapping(bp); + if (rc) + netdev_warn(bp->dev, "failed to set xps mapping\n"); + } if (bp->tx_nr_rings_xdp < num_possible_cpus()) { if (!static_key_enabled(&bnxt_xdp_locking_key))