From patchwork Mon Feb 5 22:31:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546345 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 2EACB41746 for ; Mon, 5 Feb 2024 22:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172341; cv=none; b=TOZoYkdAaIdAIjRZOfutfDgjpH70Mc0w0CKw7UfAKmhb4NDvwHSxMMX+3qbtbOcRxTLMzN7g+seDz00WtFteWbsRmaYnE6WwOPAe4s+1SJEdN3RpeV+nu/q8qGcLD9gM9P87gaLugOKZjRGIst1xqYPRN8QtoY3Pa73nly8LCh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172341; c=relaxed/simple; bh=KhqOVtn0nvtmIhPJR3UQui/tjKKWd4Ht/3vN7k78Q4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tyrKdTxatMuFAk3qkEmitO/0rhPcH4HWwdzTllMhIvCla1rfYtxCma1HBEO9+vnhypRwxDzdzTfag2M6wAOo4K0b9CzrD7JJpryE+o00VZ3wE/ZU9BshEC9rwdUzDfQL1n0Ojr29/oPn9WEDXYR9F8ByzKJ6U3MKZGJ1XH+/vc4= 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=fTLjb5zJ; arc=none smtp.client-ip=209.85.210.47 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="fTLjb5zJ" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6e14b858785so3199383a34.0 for ; Mon, 05 Feb 2024 14:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172339; x=1707777139; 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=V/n6wG2nL+MfKB6pnX8UOLwYoNxtUZuVinAHTc4Vw70=; b=fTLjb5zJEPpCtyBd/vr3zCYPSR3PptGHjPCruiksmXLkJXgBHKhJoISPduVrirGmMB dLYaUo+eebKq3UcC9TlI34GVC9XuHxA71i2FXBll1HkwMfQm2nMKtNRetSCqgUuW1u4L TV0Kjk9dkfvDFnPk7Lvzw+DvkUsKq3PocUsrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172339; x=1707777139; 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=V/n6wG2nL+MfKB6pnX8UOLwYoNxtUZuVinAHTc4Vw70=; b=Xk0K9Nibiatek9MhzRYvKYYjJJc0qHScIxF6j+M4L0/h2ApqmVlnTQyXO4b7tdxUE8 704l/N3OpSJDkI7e0B+9uZTFiojs6p3yM5QJYuKryMbjlEW0uuadgBy5mDEpi4Jui4+Q D82UXNZsYieSR94hvgRwKyZynQWrHJlaTa4kKY6I0EB53WnPM+Fq9Q7zz3xBmFUlIb3E toBkc0SBCPo0bbb+0nkzbj7SfXrWfWws//3W3gkMpNQ3Lf+6db0a+Tkz0GUpw+Fn05xv /MZQh+/spdRFUAsrfZDUxZBAI6gKSV5AuWPf0eVk09QZEe+Iho46eHOPoSAMJofG2iHM f4qA== X-Gm-Message-State: AOJu0YzbsKVIaXOWXe9ETZVOBeoLYfhY2GQgmKW0TnPMMUuAEwx1xqW1 i6NoGq8eyBbtT+5uDFZb14o/S8vfxmJ22ahRzDvFPEo4ytpatqXX/xV+JhHvi9ct5D14KeL7ixg = X-Google-Smtp-Source: AGHT+IHWpCKOa7sbFBLFaGJE1A5RBk0DSbVYrOt8AMWJxXArrmcuL5P2TejXK/XgEvD/BitgWYOy5A== X-Received: by 2002:a9d:6299:0:b0:6dc:5d73:d744 with SMTP id x25-20020a9d6299000000b006dc5d73d744mr1077023otk.23.1707172339026; Mon, 05 Feb 2024 14:32:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUwoWma2G7eCPfTznX+nH6IeLlb9TTys8YodM+84MMJDvmLdQRR3gkgX8G5JrXYp1HrlTeGog+nro5aehlh3QCq50PqAEfdGP9kTnDZhOGPREDj/Vc1MHA/4USrKtghTlsp+oRa4kZ62YeT3hrqDL/Rez8HmySRDMrQ6HgOOzvMi2B966I7IbBq5+/KDjeps487bjpWSe1HyyEtJU0rF2V9e5U= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:18 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 03/13] bnxt_en: Support ethtool -n to display ether filters. Date: Mon, 5 Feb 2024 14:31:52 -0800 Message-Id: <20240205223202.25341-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 Implement ETHTOOL_GRXCLSRULE for the user defined ether filters. Use the common functions to walk the L2 filter hash table. Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 3cc3504181c7..da298f4512b5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5484,6 +5484,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, if (bit_id < 0) return -ENOMEM; fltr->base.sw_id = (u16)bit_id; + bp->ntp_fltr_count++; } head = &bp->l2_fltr_hash_tbl[idx]; hlist_add_head_rcu(&fltr->base.hash, head); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 2d8e847e8fdd..4d4dd2b231b8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1058,11 +1058,17 @@ static struct bnxt_filter_base *bnxt_get_one_fltr_rcu(struct bnxt *bp, static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd, u32 *rule_locs) { + u32 count; + cmd->data = bp->ntp_fltr_count; rcu_read_lock(); + count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, rule_locs, 0, + cmd->rule_cnt); cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, - rule_locs, 0, cmd->rule_cnt); + rule_locs, count, + cmd->rule_cnt); rcu_read_unlock(); return 0; @@ -1081,6 +1087,36 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) return rc; rcu_read_lock(); + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, + fs->location); + if (fltr_base) { + struct ethhdr *h_ether = &fs->h_u.ether_spec; + struct ethhdr *m_ether = &fs->m_u.ether_spec; + struct bnxt_l2_filter *l2_fltr; + struct bnxt_l2_key *l2_key; + + l2_fltr = container_of(fltr_base, struct bnxt_l2_filter, base); + l2_key = &l2_fltr->l2_key; + fs->flow_type = ETHER_FLOW; + ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); + eth_broadcast_addr(m_ether->h_dest); + if (l2_key->vlan) { + struct ethtool_flow_ext *m_ext = &fs->m_ext; + struct ethtool_flow_ext *h_ext = &fs->h_ext; + + fs->flow_type |= FLOW_EXT; + m_ext->vlan_tci = htons(0xfff); + h_ext->vlan_tci = htons(l2_key->vlan); + } + if (fltr_base->flags & BNXT_ACT_RING_DST) + fs->ring_cookie = fltr_base->rxq; + if (fltr_base->flags & BNXT_ACT_FUNC_DST) + fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << + ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; + rcu_read_unlock(); + return 0; + } fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, fs->location);