* [RFC PATCH v1 2/4] net: addr_list: add exclusive dev_uc_add
2012-03-09 22:47 [RFC PATCH v1 0/4] net: bridge: FDB management John Fastabend
@ 2012-03-09 22:48 ` John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 3/4] net: add fdb generic dump routine John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops John Fastabend
2 siblings, 0 replies; 6+ messages in thread
From: John Fastabend @ 2012-03-09 22:48 UTC (permalink / raw)
To: jhs, shemminger, bhutchings
Cc: hadi, roprabhu, netdev, mst, chrisw, davem, gregory.v.rose, kvm,
sri, chealy
This adds a dev_uc_add_excl() call similar to the original
dev_uc_add() except it sets the global bit. With this
change the reference count will not be bumped and -EEXIST
will be returned if a duplicate address exists.
This is useful for drivers that support SR-IOV and want
to manage the unicast lists.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/netdevice.h | 1 +
net/core/dev_addr_lists.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3963992..7e4a86f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2553,6 +2553,7 @@ extern int dev_addr_init(struct net_device *dev);
/* Functions used for unicast addresses handling */
extern int dev_uc_add(struct net_device *dev, unsigned char *addr);
+extern int dev_uc_add_excl(struct net_device *dev, unsigned char *addr);
extern int dev_uc_del(struct net_device *dev, unsigned char *addr);
extern int dev_uc_sync(struct net_device *to, struct net_device *from);
extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 29c07fe..c7d27ad 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -377,6 +377,25 @@ EXPORT_SYMBOL(dev_addr_del_multiple);
*/
/**
+ * dev_uc_add_excl - Add a global secondary unicast address
+ * @dev: device
+ * @addr: address to add
+ */
+int dev_uc_add_excl(struct net_device *dev, unsigned char *addr)
+{
+ int err;
+
+ netif_addr_lock_bh(dev);
+ err = __hw_addr_add_ex(&dev->uc, addr, dev->addr_len,
+ NETDEV_HW_ADDR_T_UNICAST, true);
+ if (!err)
+ __dev_set_rx_mode(dev);
+ netif_addr_unlock_bh(dev);
+ return err;
+}
+EXPORT_SYMBOL(dev_uc_add_excl);
+
+/**
* dev_uc_add - Add a secondary unicast address
* @dev: device
* @addr: address to add
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH v1 3/4] net: add fdb generic dump routine
2012-03-09 22:47 [RFC PATCH v1 0/4] net: bridge: FDB management John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 2/4] net: addr_list: add exclusive dev_uc_add John Fastabend
@ 2012-03-09 22:48 ` John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops John Fastabend
2 siblings, 0 replies; 6+ messages in thread
From: John Fastabend @ 2012-03-09 22:48 UTC (permalink / raw)
To: jhs, shemminger, bhutchings
Cc: hadi, roprabhu, netdev, mst, chrisw, davem, gregory.v.rose, kvm,
sri, chealy
This adds a generic dump routine drivers can call. It
should be sufficient to handle any bridging model that
uses the unicast address list. This should be most SR-IOV
enabled NICs.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
net/core/rtnetlink.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 8c3278a..35ee2d6 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2082,6 +2082,62 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
return err;
}
+/**
+ * ndo_dflt_fdb_dump: default netdevice operation to dump an FDB table.
+ * @nlh: netlink message header
+ * @dev: netdevice
+ *
+ * Default netdevice operation to dump the existing unicast address list.
+ * Returns zero on success.
+ */
+int ndo_dflt_fdb_dump(struct sk_buff *skb,
+ struct netlink_callback *cb,
+ struct net_device *dev,
+ int idx)
+{
+ struct netdev_hw_addr *ha;
+ struct nlmsghdr *nlh;
+ struct ndmsg *ndm;
+ u32 pid, seq;
+
+ pid = NETLINK_CB(cb->skb).pid;
+ seq = cb->nlh->nlmsg_seq;
+
+ netif_addr_lock_bh(dev);
+ list_for_each_entry(ha, &dev->uc.list, list) {
+ if (idx < cb->args[0])
+ goto skip;
+
+ nlh = nlmsg_put(skb, pid, seq,
+ RTM_NEWNEIGH, sizeof(*ndm), NLM_F_MULTI);
+ if (!nlh)
+ break;
+
+ ndm = nlmsg_data(nlh);
+ ndm->ndm_family = AF_BRIDGE;
+ ndm->ndm_pad1 = 0;
+ ndm->ndm_pad2 = 0;
+ ndm->ndm_flags = NTF_LOWERDEV;
+ ndm->ndm_type = 0;
+ ndm->ndm_ifindex = dev->ifindex;
+ ndm->ndm_state = NUD_PERMANENT;
+
+ NLA_PUT(skb, NDA_LLADDR, ETH_ALEN, ha->addr);
+
+ nlmsg_end(skb, nlh);
+skip:
+ ++idx;
+ }
+ netif_addr_unlock_bh(dev);
+
+ return idx;
+nla_put_failure:
+ netif_addr_unlock_bh(dev);
+ nlmsg_cancel(skb, nlh);
+ return idx;
+}
+EXPORT_SYMBOL(ndo_dflt_fdb_dump);
+
static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
{
int idx = 0;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops
2012-03-09 22:47 [RFC PATCH v1 0/4] net: bridge: FDB management John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 2/4] net: addr_list: add exclusive dev_uc_add John Fastabend
2012-03-09 22:48 ` [RFC PATCH v1 3/4] net: add fdb generic dump routine John Fastabend
@ 2012-03-09 22:48 ` John Fastabend
2012-03-10 3:48 ` Stephen Hemminger
2 siblings, 1 reply; 6+ messages in thread
From: John Fastabend @ 2012-03-09 22:48 UTC (permalink / raw)
To: jhs, shemminger, bhutchings
Cc: hadi, roprabhu, netdev, mst, chrisw, davem, gregory.v.rose, kvm,
sri, chealy
Enable FDB ops on ixgbe when in SR-IOV mode.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 59 +++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 23a4665..c41439c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7484,6 +7484,62 @@ static int ixgbe_set_features(struct net_device *netdev,
}
+static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
+ struct net_device *dev,
+ unsigned char *addr,
+ u16 flags)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+ int err = -EOPNOTSUPP;
+
+ 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)
+ err = dev_uc_add_excl(dev, addr);
+
+ /* Only return duplicate errors if NLM_F_EXCL is set */
+ if (err == -EEXIST && !(flags & NLM_F_EXCL))
+ err = 0;
+
+ return err;
+}
+
+static int ixgbe_ndo_fdb_del(struct ndmsg *ndm,
+ struct net_device *dev,
+ unsigned char *addr)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+ int err = -EOPNOTSUPP;
+
+ 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)
+ err = dev_uc_del(dev, addr);
+
+ return err;
+}
+
+static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
+ struct netlink_callback *cb,
+ 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;
+}
+
static const struct net_device_ops ixgbe_netdev_ops = {
.ndo_open = ixgbe_open,
.ndo_stop = ixgbe_close,
@@ -7518,6 +7574,9 @@ static const struct net_device_ops ixgbe_netdev_ops = {
#endif /* IXGBE_FCOE */
.ndo_set_features = ixgbe_set_features,
.ndo_fix_features = ixgbe_fix_features,
+ .ndo_fdb_add = ixgbe_ndo_fdb_add,
+ .ndo_fdb_del = ixgbe_ndo_fdb_del,
+ .ndo_fdb_dump = ixgbe_ndo_fdb_dump,
};
static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops
2012-03-09 22:48 ` [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops John Fastabend
@ 2012-03-10 3:48 ` Stephen Hemminger
2012-03-10 5:06 ` John Fastabend
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2012-03-10 3:48 UTC (permalink / raw)
To: John Fastabend
Cc: hadi, roprabhu, netdev, mst, chrisw, davem, gregory v rose, kvm,
sri, chealy, jhs, bhutchings
> Enable FDB ops on ixgbe when in SR-IOV mode.
>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Will all this break anything on the vf client? What if the vf is running
a bridge.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v1 4/4] ixgbe: enable FDB netdevice ops
2012-03-10 3:48 ` Stephen Hemminger
@ 2012-03-10 5:06 ` John Fastabend
0 siblings, 0 replies; 6+ messages in thread
From: John Fastabend @ 2012-03-10 5:06 UTC (permalink / raw)
To: Stephen Hemminger
Cc: hadi, roprabhu, netdev, mst, chrisw, davem, gregory v rose, kvm,
sri, chealy, jhs, bhutchings
On 3/9/2012 7:48 PM, Stephen Hemminger wrote:
>
>> Enable FDB ops on ixgbe when in SR-IOV mode.
>>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>
> Will all this break anything on the vf client? What if the vf is running
> a bridge.
No shouldn't break anything.
Actually, implementing these ops in the VF driver (ixgbevf in this
case) will allow bridging to work on the VF. Because at least on
the intel 82599 devices the VF can't be put in promiscuous mode
so bridging doesn't work as expected. With the ops implemented
we could at least get traffic forwarded correctly for addresses
that were known above the VF.
^ permalink raw reply [flat|nested] 6+ messages in thread