Skip to content

Commit

Permalink
Merge branch 'rocker-next'
Browse files Browse the repository at this point in the history
Jiri Pirko says:

====================
introduce rocker switch driver with hardware accelerated datapath api - phase 1: bridge fdb offload

This patchset is just the first phase of switch and switch-ish device
support api in kernel. Note that the api will extend.

So what this patchset includes:
- introduce switchdev api skeleton for implementing switch drivers
- introduce rocker switch driver which implements switchdev api fdb and
  bridge set/get link ndos

As to the discussion if there is need to have specific class of device
representing the switch itself, so far we found no need to introduce that.
But we are generally ok with the idea and when the time comes and it will
be needed, it can be easily introduced without any disturbance.

This patchset introduces switch id export through rtnetlink and sysfs,
which is similar to what we have for port id in SR-IOV. I will send iproute2
patchset for showing the switch id for port netdevs once this is applied.
This applies also for the PF_BRIDGE and fdb iproute2 patches.

iproute2 patches are now available here:
https://github.com/jpirko/iproute2-rocker

For detailed description and version history, please see individual patches.

In v4 I reordered the patches leaving rocker patches on the end of the patchset.

In v5 I only fixed whitespace issues of patch #13

We have a TODO for related items we want to work on in near future:
https://etherpad.wikimedia.org/p/netdev-swdev-todo
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Dec 3, 2014
2 parents cd4c910 + 51ace88 commit cbc2465
Show file tree
Hide file tree
Showing 35 changed files with 5,366 additions and 105 deletions.
8 changes: 8 additions & 0 deletions Documentation/ABI/testing/sysfs-class-net
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,11 @@ Contact: netdev@vger.kernel.org
Description:
Indicates the interface protocol type as a decimal value. See
include/uapi/linux/if_arp.h for all possible values.

What: /sys/class/net/<iface>/phys_switch_id
Date: November 2014
KernelVersion: 3.19
Contact: netdev@vger.kernel.org
Description:
Indicates the unique physical switch identifier of a switch this
port belongs to, as a string.
59 changes: 59 additions & 0 deletions Documentation/networking/switchdev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Switch (and switch-ish) device drivers HOWTO
===========================

Please note that the word "switch" is here used in very generic meaning.
This include devices supporting L2/L3 but also various flow offloading chips,
including switches embedded into SR-IOV NICs.

Lets describe a topology a bit. Imagine the following example:

+----------------------------+ +---------------+
| SOME switch chip | | CPU |
+----------------------------+ +---------------+
port1 port2 port3 port4 MNGMNT | PCI-E |
| | | | | +---------------+
PHY PHY | | | | NIC0 NIC1
| | | | | |
| | +- PCI-E -+ | |
| +------- MII -------+ |
+------------- MII ------------+

In this example, there are two independent lines between the switch silicon
and CPU. NIC0 and NIC1 drivers are not aware of a switch presence. They are
separate from the switch driver. SOME switch chip is by managed by a driver
via PCI-E device MNGMNT. Note that MNGMNT device, NIC0 and NIC1 may be
connected to some other type of bus.

Now, for the previous example show the representation in kernel:

+----------------------------+ +---------------+
| SOME switch chip | | CPU |
+----------------------------+ +---------------+
sw0p0 sw0p1 sw0p2 sw0p3 MNGMNT | PCI-E |
| | | | | +---------------+
PHY PHY | | | | eth0 eth1
| | | | | |
| | +- PCI-E -+ | |
| +------- MII -------+ |
+------------- MII ------------+

Lets call the example switch driver for SOME switch chip "SOMEswitch". This
driver takes care of PCI-E device MNGMNT. There is a netdevice instance sw0pX
created for each port of a switch. These netdevices are instances
of "SOMEswitch" driver. sw0pX netdevices serve as a "representation"
of the switch chip. eth0 and eth1 are instances of some other existing driver.

The only difference of the switch-port netdevice from the ordinary netdevice
is that is implements couple more NDOs:

ndo_switch_parent_id_get - This returns the same ID for two port netdevices
of the same physical switch chip. This is
mandatory to be implemented by all switch drivers
and serves the caller for recognition of a port
netdevice.
ndo_switch_parent_* - Functions that serve for a manipulation of the switch
chip itself (it can be though of as a "parent" of the
port, therefore the name). They are not port-specific.
Caller might use arbitrary port netdevice of the same
switch and it will make no difference.
ndo_switch_port_* - Functions that serve for a port-specific manipulation.
14 changes: 14 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -7865,6 +7865,13 @@ F: drivers/hid/hid-roccat*
F: include/linux/hid-roccat*
F: Documentation/ABI/*/sysfs-driver-hid-roccat*

ROCKER DRIVER
M: Jiri Pirko <jiri@resnulli.us>
M: Scott Feldman <sfeldma@gmail.com>
L: netdev@vger.kernel.org
S: Supported
F: drivers/net/ethernet/rocker/

ROCKETPORT DRIVER
P: Comtrol Corp.
W: http://www.comtrol.com
Expand Down Expand Up @@ -9059,6 +9066,13 @@ F: lib/swiotlb.c
F: arch/*/kernel/pci-swiotlb.c
F: include/linux/swiotlb.h

SWITCHDEV
M: Jiri Pirko <jiri@resnulli.us>
L: netdev@vger.kernel.org
S: Supported
F: net/switchdev/
F: include/net/switchdev.h

SYNOPSYS ARC ARCHITECTURE
M: Vineet Gupta <vgupta@synopsys.com>
S: Supported
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ source "drivers/net/ethernet/qualcomm/Kconfig"
source "drivers/net/ethernet/realtek/Kconfig"
source "drivers/net/ethernet/renesas/Kconfig"
source "drivers/net/ethernet/rdc/Kconfig"
source "drivers/net/ethernet/rocker/Kconfig"

config S6GMAC
tristate "S6105 GMAC ethernet support"
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ obj-$(CONFIG_NET_VENDOR_QUALCOMM) += qualcomm/
obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/
obj-$(CONFIG_SH_ETH) += renesas/
obj-$(CONFIG_NET_VENDOR_RDC) += rdc/
obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/
obj-$(CONFIG_S6GMAC) += s6gmac.o
obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/
obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12537,7 +12537,7 @@ static int bnx2x_validate_addr(struct net_device *dev)
}

static int bnx2x_get_phys_port_id(struct net_device *netdev,
struct netdev_phys_port_id *ppid)
struct netdev_phys_item_id *ppid)
{
struct bnx2x *bp = netdev_priv(netdev);

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4367,7 +4367,8 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,

return ndo_dflt_bridge_getlink(skb, pid, seq, dev,
hsw_mode == PORT_FWD_TYPE_VEPA ?
BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB);
BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB,
0, 0);
}

#ifdef CONFIG_BE2NET_VXLAN
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7511,7 +7511,7 @@ static void i40e_del_vxlan_port(struct net_device *netdev,

#endif
static int i40e_get_phys_port_id(struct net_device *netdev,
struct netdev_phys_port_id *ppid)
struct netdev_phys_item_id *ppid)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_pf *pf = np->vsi->back;
Expand All @@ -7536,7 +7536,7 @@ static int i40e_get_phys_port_id(struct net_device *netdev,
*/
static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev,
const unsigned char *addr,
const unsigned char *addr, u16 vid,
u16 flags)
{
struct i40e_netdev_priv *np = netdev_priv(dev);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7708,7 +7708,7 @@ static int ixgbe_set_features(struct net_device *netdev,

static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev,
const unsigned char *addr,
const unsigned char *addr, u16 vid,
u16 flags)
{
/* guarantee we can provide a unique filter for the unicast address */
Expand All @@ -7717,7 +7717,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
return -ENOMEM;
}

return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
return ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, flags);
}

static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
Expand Down Expand Up @@ -7778,7 +7778,7 @@ static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
else
mode = BRIDGE_MODE_VEPA;

return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0);
}

static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_st

#define PORT_ID_BYTE_LEN 8
static int mlx4_en_get_phys_port_id(struct net_device *dev,
struct netdev_phys_port_id *ppid)
struct netdev_phys_item_id *ppid)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_dev *mdev = priv->mdev->dev;
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,14 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
}

static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *netdev, const unsigned char *addr)
struct net_device *netdev,
const unsigned char *addr, u16 vid)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
int err = -EOPNOTSUPP;

if (!adapter->fdb_mac_learn)
return ndo_dflt_fdb_del(ndm, tb, netdev, addr);
return ndo_dflt_fdb_del(ndm, tb, netdev, addr, vid);

if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
qlcnic_sriov_check(adapter)) {
Expand All @@ -401,13 +402,13 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],

static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *netdev,
const unsigned char *addr, u16 flags)
const unsigned char *addr, u16 vid, u16 flags)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
int err = 0;

if (!adapter->fdb_mac_learn)
return ndo_dflt_fdb_add(ndm, tb, netdev, addr, flags);
return ndo_dflt_fdb_add(ndm, tb, netdev, addr, vid, flags);

if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) &&
!qlcnic_sriov_check(adapter)) {
Expand Down Expand Up @@ -460,7 +461,7 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter)
}

static int qlcnic_get_phys_port_id(struct net_device *netdev,
struct netdev_phys_port_id *ppid)
struct netdev_phys_item_id *ppid)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
struct qlcnic_hardware_context *ahw = adapter->ahw;
Expand Down
27 changes: 27 additions & 0 deletions drivers/net/ethernet/rocker/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Rocker device configuration
#

config NET_VENDOR_ROCKER
bool "Rocker devices"
default y
---help---
If you have a network device belonging to this class, say Y.

Note that the answer to this question doesn't directly affect the
kernel: saying N will just cause the configurator to skip all
the questions about Rocker devices. If you say Y, you will be asked for
your specific card in the following questions.

if NET_VENDOR_ROCKER

config ROCKER
tristate "Rocker switch driver (EXPERIMENTAL)"
depends on PCI && NET_SWITCHDEV
---help---
This driver supports Rocker switch device.

To compile this driver as a module, choose M here: the
module will be called rocker.

endif # NET_VENDOR_ROCKER
5 changes: 5 additions & 0 deletions drivers/net/ethernet/rocker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Makefile for the Rocker network device drivers.
#

obj-$(CONFIG_ROCKER) += rocker.o
Loading

0 comments on commit cbc2465

Please sign in to comment.