netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shannon Nelson <snelson@pensando.io>
To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org
Cc: drivers@pensando.io, jtoppins@redhat.com,
	Shannon Nelson <snelson@pensando.io>
Subject: [PATCH net-next 6/9] ionic: generic filter delete
Date: Sat,  9 Oct 2021 11:45:20 -0700	[thread overview]
Message-ID: <20211009184523.73154-7-snelson@pensando.io> (raw)
In-Reply-To: <20211009184523.73154-1-snelson@pensando.io>

Similar to the filter add, make a generic filter delete.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 .../ethernet/pensando/ionic/ionic_rx_filter.c | 35 +++++++++++++------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
index 10837e41f819..40a12b9df982 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
@@ -413,7 +413,8 @@ int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr)
 	return ionic_lif_filter_add(lif, &ac);
 }
 
-int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
+static int ionic_lif_filter_del(struct ionic_lif *lif,
+				struct ionic_rx_filter_add_cmd *ac)
 {
 	struct ionic_admin_ctx ctx = {
 		.work = COMPLETION_INITIALIZER_ONSTACK(ctx.work),
@@ -427,24 +428,27 @@ int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
 	int err;
 
 	spin_lock_bh(&lif->rx_filters.lock);
-	f = ionic_rx_filter_by_addr(lif, addr);
+	f = ionic_rx_filter_find(lif, ac);
 	if (!f) {
 		spin_unlock_bh(&lif->rx_filters.lock);
 		return -ENOENT;
 	}
 
-	netdev_dbg(lif->netdev, "rx_filter del ADDR %pM (id %d)\n",
-		   addr, f->filter_id);
+	switch (le16_to_cpu(ac->match)) {
+	case IONIC_RX_FILTER_MATCH_MAC:
+		netdev_dbg(lif->netdev, "%s: rx_filter del ADDR %pM id %d\n",
+			   __func__, ac->mac.addr, f->filter_id);
+		if (is_multicast_ether_addr(ac->mac.addr) && lif->nmcast)
+			lif->nmcast--;
+		else if (!is_multicast_ether_addr(ac->mac.addr) && lif->nucast)
+			lif->nucast--;
+		break;
+	}
 
 	state = f->state;
 	ctx.cmd.rx_filter_del.filter_id = cpu_to_le32(f->filter_id);
 	ionic_rx_filter_free(lif, f);
 
-	if (is_multicast_ether_addr(addr) && lif->nmcast)
-		lif->nmcast--;
-	else if (!is_multicast_ether_addr(addr) && lif->nucast)
-		lif->nucast--;
-
 	spin_unlock_bh(&lif->rx_filters.lock);
 
 	if (state != IONIC_FILTER_STATE_NEW) {
@@ -456,6 +460,17 @@ int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
 	return 0;
 }
 
+int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
+{
+	struct ionic_rx_filter_add_cmd ac = {
+		.match = cpu_to_le16(IONIC_RX_FILTER_MATCH_MAC),
+	};
+
+	memcpy(&ac.mac.addr, addr, ETH_ALEN);
+
+	return ionic_lif_filter_del(lif, &ac);
+}
+
 struct sync_item {
 	struct list_head list;
 	struct ionic_rx_filter f;
@@ -510,7 +525,7 @@ void ionic_rx_filter_sync(struct ionic_lif *lif)
 	 * they can clear room for some new filters
 	 */
 	list_for_each_entry_safe(sync_item, spos, &sync_del_list, list) {
-		(void)ionic_lif_addr_del(lif, sync_item->f.cmd.mac.addr);
+		(void)ionic_lif_filter_del(lif, &sync_item->f.cmd);
 
 		list_del(&sync_item->list);
 		devm_kfree(dev, sync_item);
-- 
2.17.1


  parent reply	other threads:[~2021-10-09 18:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09 18:45 [PATCH net-next 0/9] ionic: add vlanid overflow management Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 1/9] ionic: add filterlist to debugfs Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 2/9] ionic: move lif mac address functions Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 3/9] ionic: remove mac overflow flags Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 4/9] ionic: add generic filter search Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 5/9] ionic: generic filter add Shannon Nelson
2021-10-09 18:45 ` Shannon Nelson [this message]
2021-10-09 18:45 ` [PATCH net-next 7/9] ionic: handle vlan id overflow Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 8/9] ionic: allow adminq requests to override default error message Shannon Nelson
2021-10-09 18:45 ` [PATCH net-next 9/9] ionic: tame the filter no space message Shannon Nelson
2021-10-10  9:50 ` [PATCH net-next 0/9] ionic: add vlanid overflow management patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211009184523.73154-7-snelson@pensando.io \
    --to=snelson@pensando.io \
    --cc=davem@davemloft.net \
    --cc=drivers@pensando.io \
    --cc=jtoppins@redhat.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).