From patchwork Tue Feb 20 23:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13564716 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 0B4D9154450 for ; Tue, 20 Feb 2024 23:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708470241; cv=none; b=divEy3tWJ8YOEh3Huw44mZqiTAf8guQ+Gci+gymFgiOn2YIC1Z43PT7a0M1vHzpSR8RPaMRdXUQmHY+1SD5XjuNwAoUxUxXugf0Pqmltbc+btA1KcsJLFaBDvI075P0QTkGVSx3dHpE9FwBenbfIlUxIFIoddKUWWC5/pJne7jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708470241; c=relaxed/simple; bh=rnRaspjwsZYkIuP4b/2+e6LfEjItukpD9dRDnNHpBSo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SDvmufrDHZhI20G0mfHB+ihIVTjMR5hp5FNWV0boFseEg9Pa2W9PTQuLMM6FmCGmYZOrqAxbm2MOAxV0nu6bAhVFXqH7a72wYcmmLvpsLkzZRIEXyCZ4lzlflYNUoIrWFBgA+ieyKchzh5WCXnsWgMHm6U8ZWYLsGjxcfExZ/y8= 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=D6DrFmsm; arc=none smtp.client-ip=209.85.222.179 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="D6DrFmsm" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-78725b62cf2so288201985a.1 for ; Tue, 20 Feb 2024 15:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708470239; x=1709075039; 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=tu2Sh+oQmIUNQ6wfNuhr/+Jpj/gb3sRj4QnX45nYQAY=; b=D6DrFmsmeAHE76wPGXH0+j4qGfYkEToGaFfKcqxzaa/YzohOK+wvL76DiFBS63zPQm gPMj1a749yllZA8nb4y2NmenLExGtoTBqU/EdB6zTbv+y7Ap9xg2fiMtGEFDU0DO158z xjCvBb/BV+3MVwf3+CWf2MW6x9hY9Gy4uWC8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708470239; x=1709075039; 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=tu2Sh+oQmIUNQ6wfNuhr/+Jpj/gb3sRj4QnX45nYQAY=; b=qteMzJxN8rJhfvu/In/r6CW5lh2UV4nENdDYAltD1BsSZzmws4CZD73q9MY2S2X3QT 9msA5dB9MJ1wwuwpjjcaqqlAfR2/CJSFSHIf/gkNV8ZVGwhNhA/n8NgsKRi0ZgKNZMsu HXt3RrK6EtsKagmKjLTMZ7dXT4dAHq8nNGcYJZnc+P7hV6+GW/moFKLO4elFdIN55ZNs rlqAaICzLFEIgJmOpoWwBwZwb1EXOTUikyqW3Rbp3fgj8uYtD1vMKrNOt5oH2jA3OphN 2TCnMdBJP2geKz7pQcnXOYGgCHMCPM6kWYdqcpF7J8SClAmeBGfgsFk3FIApzxkU3a7y Hfow== X-Gm-Message-State: AOJu0YzH2h3q0DSnY+OO9oXjU4WwbWGHM3Mj1zsqu9pvVlk10SK7w+fh OvlC7XS9yn1NlzspEhbwlBhXltXvEBEGoaoiFKXOkR7gYFVSVNleM64dnngeDg== X-Google-Smtp-Source: AGHT+IHBXdUeh9C4JDCfiJymVVLChw6GMkMmQSnw5mrEhngoqtVCEOJSGKmffFttZfLkFSkfqzP30A== X-Received: by 2002:a05:620a:4046:b0:787:1f70:5a9f with SMTP id i6-20020a05620a404600b007871f705a9fmr20420457qko.71.1708470237096; Tue, 20 Feb 2024 15:03:57 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id g10-20020ae9e10a000000b00785d7dda9easm3797966qkm.28.2024.02.20.15.03.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2024 15:03:56 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Somnath Kotur Subject: [PATCH net-next 09/10] bnxt_en: Create and setup the additional VNIC for adding ntuple filters Date: Tue, 20 Feb 2024 15:03:16 -0800 Message-Id: <20240220230317.96341-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240220230317.96341-1-michael.chan@broadcom.com> References: <20240220230317.96341-1-michael.chan@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: Pavan Chebbi Allocate and setup the additional VNIC for ntuple filters if this new method is supported by the firmware. Even though this VNIC is only used for ntuple filters with direct ring destinations, we still setup the RSS hash to be identical to the default VNIC so that each RX packet will have the correct hash in the RX completion. This VNIC is always at VNIC index BNXT_VNIC_NTUPLE. Reviewed-by: Somnath Kotur Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0ca9dd397622..b8ef6c2ba40c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5135,6 +5135,10 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init) vnic0->flags |= BNXT_VNIC_RSS_FLAG | BNXT_VNIC_MCAST_FLAG | BNXT_VNIC_UCAST_FLAG; + if (BNXT_SUPPORTS_NTUPLE_VNIC(bp) && (bp->flags & BNXT_FLAG_RFS)) + bp->vnic_info[BNXT_VNIC_NTUPLE].flags |= + BNXT_VNIC_RSS_FLAG | BNXT_VNIC_NTUPLE_FLAG; + rc = bnxt_alloc_vnic_attributes(bp); if (rc) goto alloc_mem_err; @@ -6090,7 +6094,10 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, for (i = 0; i < tbl_size; i++) { u16 ring_id, j; - j = bp->rss_indir_tbl[i]; + if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) + j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings); + else + j = bp->rss_indir_tbl[i]; rxr = &bp->rx_ring[j]; ring_id = rxr->rx_ring_struct.fw_ring_id; @@ -9844,10 +9851,28 @@ static int bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id) return __bnxt_setup_vnic(bp, vnic_id); } +static int bnxt_alloc_and_setup_vnic(struct bnxt *bp, u16 vnic_id, + u16 start_rx_ring_idx, int rx_rings) +{ + int rc; + + rc = bnxt_hwrm_vnic_alloc(bp, vnic_id, start_rx_ring_idx, rx_rings); + if (rc) { + netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", + vnic_id, rc); + return rc; + } + return bnxt_setup_vnic(bp, vnic_id); +} + static int bnxt_alloc_rfs_vnics(struct bnxt *bp) { int i, rc = 0; + if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) + return bnxt_alloc_and_setup_vnic(bp, BNXT_VNIC_NTUPLE, 0, + bp->rx_nr_rings); + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) return 0; @@ -9863,14 +9888,7 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp) vnic->flags |= BNXT_VNIC_RFS_FLAG; if (bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; - rc = bnxt_hwrm_vnic_alloc(bp, vnic_id, ring_id, 1); - if (rc) { - netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", - vnic_id, rc); - break; - } - rc = bnxt_setup_vnic(bp, vnic_id); - if (rc) + if (bnxt_alloc_and_setup_vnic(bp, vnic_id, ring_id, 1)) break; } return rc; @@ -12467,12 +12485,12 @@ static int bnxt_reinit_features(struct bnxt *bp, bool irq_re_init, static int bnxt_set_features(struct net_device *dev, netdev_features_t features) { + bool update_tpa = false, update_ntuple = false; struct bnxt *bp = netdev_priv(dev); u32 flags = bp->flags; u32 changes; int rc = 0; bool re_init = false; - bool update_tpa = false; flags &= ~BNXT_FLAG_ALL_CONFIG_FEATS; if (features & NETIF_F_GRO_HW) @@ -12503,6 +12521,9 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features) if (changes & ~BNXT_FLAG_TPA) re_init = true; + if (changes & BNXT_FLAG_RFS) + update_ntuple = true; + if (flags != bp->flags) { u32 old_flags = bp->flags; @@ -12513,6 +12534,9 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features) return rc; } + if (update_ntuple) + return bnxt_reinit_features(bp, true, false, flags, update_tpa); + if (re_init) return bnxt_reinit_features(bp, false, false, flags, update_tpa); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index e9158407b181..dd849e715c9b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1214,6 +1214,7 @@ struct bnxt_ring_grp_info { }; #define BNXT_VNIC_DEFAULT 0 +#define BNXT_VNIC_NTUPLE 1 struct bnxt_vnic_info { u16 fw_vnic_id; /* returned by Chimp during alloc */ @@ -1254,6 +1255,7 @@ struct bnxt_vnic_info { #define BNXT_VNIC_MCAST_FLAG 4 #define BNXT_VNIC_UCAST_FLAG 8 #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 +#define BNXT_VNIC_NTUPLE_FLAG 0x20 }; struct bnxt_hw_rings {