Skip to contentSkip to conversation

Provide default fdb operation to allow mac filter

RFC PATCH In review Vlad Yasevich 3 participants 8 messages Feb 27, 2013 – Feb 28, 2013 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Provide default fdb operation to allow mac filter

This is a short series that now allows mac filter programming on any card that support IFF_UNICAST_FLT by using the existing FDB interface.

Some existing drivers that had FDB functionality usually supported it only in SR-IOV mode. Since that's not always enabled, and we want to take advantage of IFF_UNICAST_FLT support, these drivers have been converted to call the default handler when not in SRIOV mode.

John Fastabend (1):
net: generic fdb support for drivers without ndo_fdb_<op>

Vlad Yasevich (2):
ixgbe: Use default fdb handlers when not in VF mode.
mlx4: Use default fdb handlers when not multifunction.

 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  |   26 +++-----
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   12 +---
 include/linux/rtnetlink.h                      |    9 +++
 net/core/rtnetlink.c                           |   81 ++++++++++++++++++++++--
 4 files changed, 98 insertions(+), 30 deletions(-)
Signature · 1 line
1.7.7.6
#1 lore raw

RFC PATCH 1/3 net: generic fdb support for drivers without ndo_fdb_<op>

If the driver does not support the ndo_op use the generic handler for it. This should work in the majority of cases. Eventually the fdb_dflt_add call gets translated into a __dev_set_rx_mode() call which should handle hardware support for filtering via the IFF_UNICAST_FLT flag.

Namely IFF_UNICAST_FLT indicates if the hardware can do unicast address filtering. If no support is available the device is put into promisc mode.

---
 include/linux/rtnetlink.h |    9 +++++
 net/core/rtnetlink.c      |   81 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 84 insertions(+), 6 deletions(-)
include/linux/rtnetlink.h +9 -0
index 489dd7bb..55d33a3 100644
@@ -69,6 +69,15 @@ extern int ndo_dflt_fdb_dump(struct sk_buff *skb,
 			     struct netlink_callback *cb,
 			     struct net_device *dev,
 			     int idx);
+extern int ndo_dflt_fdb_add(struct sk_buff *skb,
+			    struct nlattr *tb[],
+			    struct net_device *dev,
+			    const unsigned char *addr,
+			    u16 flags);
+extern int ndo_dflt_fdb_del(struct sk_buff *skb,
+			    struct nlattr *tb[],
+			    struct net_device *dev,
+			    const unsigned char *addr);
 
 extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				   struct net_device *dev, u16 mode);
net/core/rtnetlink.c +75 -6

111 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#2 lore raw

RFC PATCH 2/3 ixgbe: Use default fdb handlers when not in VF mode.

In reply to Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter does not have VF configured. This allows for IFF_UNICAST_FLT support and allows VF handling to potentially do something different.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   26 ++++++++++--------------
 1 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +11 -15
index 68478d6..0ae2525 100644
@@ -7007,7 +7007,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 	int err;
 
 	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
 
 	/* Hardware does not support aging addresses so if a
 	 * ndm_state is given only allow permanent addresses
@@ -7045,20 +7045,21 @@ static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
 	struct ixgbe_adapter *adapter = netdev_priv(dev);
 	int err = -EOPNOTSUPP;
 
+	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
+		return ndo_dflt_fdb_del(ndm, tb, dev, addr);
+
 	if (ndm->ndm_state & NUD_PERMANENT) {
 		pr_info("%s: FDB only supports static addresses\n",
 			ixgbe_driver_name);
 		return -EINVAL;
 	}
 
-	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
-		if (is_unicast_ether_addr(addr))
-			err = dev_uc_del(dev, addr);
-		else if (is_multicast_ether_addr(addr))
-			err = dev_mc_del(dev, addr);
-		else
-			err = -EINVAL;
-	}
+	if (is_unicast_ether_addr(addr))
+		err = dev_uc_del(dev, addr);
+	else if (is_multicast_ether_addr(addr))
+		err = dev_mc_del(dev, addr);
+	else
+		err = -EINVAL;
 
 	return err;
 }
@@ -7068,12 +7069,7 @@ static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
 			      struct net_device *dev,
 			      int idx)
 {
-	struct ixgbe_adapter *adapter = netdev_priv(dev);
-
-	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
-		idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
-
-	return idx;
+	return ndo_dflt_fdb_dump(skb, cb, dev, idx);
 }
 
 static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
Signature · 1 line
1.7.7.6
#3 lore raw

Re: [RFC PATCH 2/3] ixgbe: Use default fdb handlers when not in VF mode.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],

Quoted 16 lines · Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter does not have VF configured. This allows for IFF_UNICAST_FLT support and allows VF handling to potentially do something different.

---
  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   26 ++++++++++--------------
  1 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index 68478d6..0ae2525 100644
@@ -7007,7 +7007,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],

With the first patch we can just remove this routine altogether and let the dflt handler do its work.

CC'd Greg in case I miss something.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],

Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
  	int err;
 
  	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
 
  	/* Hardware does not support aging addresses so if a
  	 * ndm_state is given only allow permanent addresses
@@ -7045,20 +7045,21 @@ static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],

same here just remove it and use the dflt handler.

Quoted 30 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +9 -8
  	struct ixgbe_adapter *adapter = netdev_priv(dev);
  	int err = -EOPNOTSUPP;
 
+	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
+		return ndo_dflt_fdb_del(ndm, tb, dev, addr);
+
  	if (ndm->ndm_state & NUD_PERMANENT) {
  		pr_info("%s: FDB only supports static addresses\n",
  			ixgbe_driver_name);
  		return -EINVAL;
  	}
 
-	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
-		if (is_unicast_ether_addr(addr))
-			err = dev_uc_del(dev, addr);
-		else if (is_multicast_ether_addr(addr))
-			err = dev_mc_del(dev, addr);
-		else
-			err = -EINVAL;
-	}
+	if (is_unicast_ether_addr(addr))
+		err = dev_uc_del(dev, addr);
+	else if (is_multicast_ether_addr(addr))
+		err = dev_mc_del(dev, addr);
+	else
+		err = -EINVAL;
 
  	return err;
  }

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_dump(struct sk_buff *skb, · line 7071

Quoted 3 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -7068,12 +7069,7 @@ static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
  			      struct net_device *dev,
  			      int idx)
  {

This is the same as not defining the op at all right? Just remove it.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_dump(struct sk_buff *skb, · line 7075

Quoted 11 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -6
-	struct ixgbe_adapter *adapter = netdev_priv(dev);
-
-	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
-		idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
-
-	return idx;
+	return ndo_dflt_fdb_dump(skb, cb, dev, idx);
  }
 
  static int ixgbe_ndo_bridge_setlink(struct net_device *dev,

Then we get a patch with all '-' which is sort of nice.

#4 lore raw

Re: [RFC PATCH 2/3] ixgbe: Use default fdb handlers when not in VF mode.

Quoted 24 lines · John Fastabend
Quoted 18 lines · Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter does not have VF configured. This allows for IFF_UNICAST_FLT support and allows VF handling to potentially do something different.

---
  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   26
++++++++++--------------
  1 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index 68478d6..0ae2525 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, · line 7007

Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -7007,7 +7007,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
 struct nlattr *tb[],

With the first patch we can just remove this routine altogether and let the dflt handler do its work.

Quoted 1 line

CC'd Greg in case I miss something.

OK. I took the safe approach and kept the functions. The only difference right now is that right now with VF configured, fdb_add refuses to add more then IXGBE_MAX_PF_MACVLANS and thus never would
enter into promisc mode. I am not sure if that how its supposed to
be have or not. That's one of the reasons I kept this around.

-vlad

Quoted 65 lines

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_del(struct ndmsg · line 7045

Quoted 11 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
      int err;
 
      if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
-        return -EOPNOTSUPP;
+        return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
 
      /* Hardware does not support aging addresses so if a

* ndm_state is given only allow permanent addresses

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -7045,20 +7045,21 @@ static int ixgbe_ndo_fdb_del(struct ndmsg
 *ndm, struct nlattr *tb[],

same here just remove it and use the dflt handler.

Quoted 30 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +9 -8
      struct ixgbe_adapter *adapter = netdev_priv(dev);
      int err = -EOPNOTSUPP;
 
+    if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
+        return ndo_dflt_fdb_del(ndm, tb, dev, addr);
+
      if (ndm->ndm_state & NUD_PERMANENT) {
          pr_info("%s: FDB only supports static addresses\n",
              ixgbe_driver_name);
          return -EINVAL;
      }
 
-    if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
-        if (is_unicast_ether_addr(addr))
-            err = dev_uc_del(dev, addr);
-        else if (is_multicast_ether_addr(addr))
-            err = dev_mc_del(dev, addr);
-        else
-            err = -EINVAL;
-    }
+    if (is_unicast_ether_addr(addr))
+        err = dev_uc_del(dev, addr);
+    else if (is_multicast_ether_addr(addr))
+        err = dev_mc_del(dev, addr);
+    else
+        err = -EINVAL;
 
      return err;
  }

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_dump(struct sk_buff *skb, · line 7071

Quoted 3 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -7068,12 +7069,7 @@ static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
                    struct net_device *dev,
                    int idx)
  {

This is the same as not defining the op at all right? Just remove it.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_fdb_dump(struct sk_buff *skb, · line 7075

Quoted 11 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -6
-    struct ixgbe_adapter *adapter = netdev_priv(dev);
-
-    if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
-        idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
-
-    return idx;
+    return ndo_dflt_fdb_dump(skb, cb, dev, idx);
  }
 
  static int ixgbe_ndo_bridge_setlink(struct net_device *dev,

Then we get a patch with all '-' which is sort of nice.

#5 lore raw

RFC PATCH 3/3 mlx4: Use default fdb handlers when not multifunction.

In reply to Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter is not configured with virtual functins (!mlx4_is_mfunc()) This allows proper IFF_UNICAST_FLT support and allows for additional handling by the driver if needed.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +3 -9
index 5385474..5732025 100644
@@ -1934,7 +1934,7 @@ static int mlx4_en_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 	int err;
 
 	if (!mlx4_is_mfunc(mdev))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
 
 	/* Hardware does not support aging addresses, allow only
 	 * permanent addresses if ndm_state is given
@@ -1968,7 +1968,7 @@ static int mlx4_en_fdb_del(struct ndmsg *ndm,
 	int err;
 
 	if (!mlx4_is_mfunc(mdev))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_del(ndm, tb, dev, addr);
 
 	if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
 		en_info(priv, "Del FDB only supports static addresses\n");
@@ -1989,13 +1989,7 @@ static int mlx4_en_fdb_dump(struct sk_buff *skb,
 			    struct netlink_callback *cb,
 			    struct net_device *dev, int idx)
 {
-	struct mlx4_en_priv *priv = netdev_priv(dev);
-	struct mlx4_dev *mdev = priv->mdev->dev;
-
-	if (mlx4_is_mfunc(mdev))
-		idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
-
-	return idx;
+	return ndo_dflt_fdb_dump(skb, cb, dev, idx);
 }
 
 static const struct net_device_ops mlx4_netdev_ops = {
Signature · 1 line
1.7.7.6
#6 lore raw

Re: [RFC PATCH 3/3] mlx4: Use default fdb handlers when not multifunction.

drivers/net/ethernet/mellanox/mlx4/en_netdev.c static int mlx4_en_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],

Quoted 16 lines · Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter is not configured with virtual functins (!mlx4_is_mfunc()) This allows proper IFF_UNICAST_FLT support and allows for additional handling by the driver if needed.

---
  drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   12 +++---------
  1 files changed, 3 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
index 5385474..5732025 100644
@@ -1934,7 +1934,7 @@ static int mlx4_en_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],

Amir are the default ops good enough here?

Quoted 18 lines
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +2 -2
  	int err;
 
  	if (!mlx4_is_mfunc(mdev))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
 
  	/* Hardware does not support aging addresses, allow only
  	 * permanent addresses if ndm_state is given
@@ -1968,7 +1968,7 @@ static int mlx4_en_fdb_del(struct ndmsg *ndm,
  	int err;
 
  	if (!mlx4_is_mfunc(mdev))
-		return -EOPNOTSUPP;
+		return ndo_dflt_fdb_del(ndm, tb, dev, addr);
 
  	if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
  		en_info(priv, "Del FDB only supports static addresses\n");

drivers/net/ethernet/mellanox/mlx4/en_netdev.c static int mlx4_en_fdb_dump(struct sk_buff *skb, · line 1991

Quoted 3 lines
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
@@ -1989,13 +1989,7 @@ static int mlx4_en_fdb_dump(struct sk_buff *skb,
  			    struct netlink_callback *cb,
  			    struct net_device *dev, int idx)
  {

same comment here. Don't define this op and we get the same behavior?

.John

A message that is not in the archive (sent off-list or not yet received): CAJZOPZLcphuZEXR+jhT35=qtOq9bfxWzWEokN6UrMorciCvvsA@mail.gmail.com

#8 lore raw

RE: [RFC PATCH 3/3] mlx4: Use default fdb handlers when not multifunction.

Quoted 23 lines

From: John Fastabend <[email protected]>
Date: Thu, Feb 28, 2013 at 6:27 AM
Subject: Re: [RFC PATCH 3/3] mlx4: Use default fdb handlers when not multifunction.
To: Vlad Yasevich <[email protected]>, Amir Vadai <[email protected]>
Cc: [email protected], [email protected]

Quoted 12 lines · Vlad Yasevich

Allow the use of ndo_dflt_fdb_<add|del|dump> when the adapter is not configured with virtual functins (!mlx4_is_mfunc()) This allows proper IFF_UNICAST_FLT support and allows for additional handling by the driver if needed.

---
  drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   12 +++---------
  1 files changed, 3 insertions(+), 9 deletions(-)
Quoted 11 lines

drivers/net/ethernet/mellanox/mlx4/en_netdev.c static int mlx4_en_fdb_add(struct ndmsg *ndm, · line 1934

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
index 5385474..5732025 100644
@@ -1934,7 +1934,7 @@ static int mlx4_en_fdb_add(struct ndmsg *ndm,
 struct nlattr *tb[],

Amir are the default ops good enough here?

The default ops can be used instead of mlx4 fdb_add, fdb_delete, and fdb_dump.

Yan