diff options
author | Ido Schimmel <idosch@mellanox.com> | 2016-04-06 11:10:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-06 17:24:18 -0400 |
commit | f00817df2b428ec13711bd27729f992b8c3af054 (patch) | |
tree | dce172d82fc82ea526a93698e6ad3965e0e22035 | |
parent | 90183b980d0af77df2369dee924fff13c792dcc5 (diff) |
mlxsw: spectrum: Introduce support for Data Center Bridging (DCB)
Introduce basic infrastructure for DCB and add the missing ops in
following patches.
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/Kconfig | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 17 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | 65 |
5 files changed, 101 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig index 2ad7f67854d5..5989f7cb5462 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig +++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig | |||
@@ -50,3 +50,11 @@ config MLXSW_SPECTRUM | |||
50 | 50 | ||
51 | To compile this driver as a module, choose M here: the | 51 | To compile this driver as a module, choose M here: the |
52 | module will be called mlxsw_spectrum. | 52 | module will be called mlxsw_spectrum. |
53 | |||
54 | config MLXSW_SPECTRUM_DCB | ||
55 | bool "Data Center Bridging (DCB) support" | ||
56 | depends on MLXSW_SPECTRUM && DCB | ||
57 | default y | ||
58 | ---help--- | ||
59 | Say Y here if you want to use Data Center Bridging (DCB) in the | ||
60 | driver. | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/Makefile b/drivers/net/ethernet/mellanox/mlxsw/Makefile index 584cac444852..9b5ebf84c051 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Makefile +++ b/drivers/net/ethernet/mellanox/mlxsw/Makefile | |||
@@ -8,3 +8,4 @@ mlxsw_switchx2-objs := switchx2.o | |||
8 | obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o | 8 | obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o |
9 | mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ | 9 | mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ |
10 | spectrum_switchdev.o | 10 | spectrum_switchdev.o |
11 | mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 1243c7404356..baaa9ea52035 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c | |||
@@ -1681,6 +1681,14 @@ static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, | |||
1681 | goto err_port_ets_init; | 1681 | goto err_port_ets_init; |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | /* ETS and buffers must be initialized before DCB. */ | ||
1685 | err = mlxsw_sp_port_dcb_init(mlxsw_sp_port); | ||
1686 | if (err) { | ||
1687 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize DCB\n", | ||
1688 | mlxsw_sp_port->local_port); | ||
1689 | goto err_port_dcb_init; | ||
1690 | } | ||
1691 | |||
1684 | mlxsw_sp_port_switchdev_init(mlxsw_sp_port); | 1692 | mlxsw_sp_port_switchdev_init(mlxsw_sp_port); |
1685 | err = register_netdev(dev); | 1693 | err = register_netdev(dev); |
1686 | if (err) { | 1694 | if (err) { |
@@ -1701,6 +1709,7 @@ static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, | |||
1701 | err_port_vlan_init: | 1709 | err_port_vlan_init: |
1702 | unregister_netdev(dev); | 1710 | unregister_netdev(dev); |
1703 | err_register_netdev: | 1711 | err_register_netdev: |
1712 | err_port_dcb_init: | ||
1704 | err_port_ets_init: | 1713 | err_port_ets_init: |
1705 | err_port_buffers_init: | 1714 | err_port_buffers_init: |
1706 | err_port_admin_status_set: | 1715 | err_port_admin_status_set: |
@@ -1771,6 +1780,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) | |||
1771 | devlink_port = &mlxsw_sp_port->devlink_port; | 1780 | devlink_port = &mlxsw_sp_port->devlink_port; |
1772 | devlink_port_type_clear(devlink_port); | 1781 | devlink_port_type_clear(devlink_port); |
1773 | unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ | 1782 | unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ |
1783 | mlxsw_sp_port_dcb_fini(mlxsw_sp_port); | ||
1774 | devlink_port_unregister(devlink_port); | 1784 | devlink_port_unregister(devlink_port); |
1775 | mlxsw_sp_port_vports_fini(mlxsw_sp_port); | 1785 | mlxsw_sp_port_vports_fini(mlxsw_sp_port); |
1776 | mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); | 1786 | mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 84dddd47f1b0..1f50af8e25c2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h | |||
@@ -270,4 +270,21 @@ int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 vfid, | |||
270 | void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port); | 270 | void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port); |
271 | int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | 271 | int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
272 | 272 | ||
273 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB | ||
274 | |||
275 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); | ||
276 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); | ||
277 | |||
278 | #else | ||
279 | |||
280 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) | ||
281 | { | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) | ||
286 | {} | ||
287 | |||
288 | #endif | ||
289 | |||
273 | #endif | 290 | #endif |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c new file mode 100644 index 000000000000..631e9803978d --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | ||
3 | * Copyright (c) 2016 Mellanox Technologies. All rights reserved. | ||
4 | * Copyright (c) 2016 Ido Schimmel <idosch@mellanox.com> | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the names of the copyright holders nor the names of its | ||
15 | * contributors may be used to endorse or promote products derived from | ||
16 | * this software without specific prior written permission. | ||
17 | * | ||
18 | * Alternatively, this software may be distributed under the terms of the | ||
19 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
20 | * Software Foundation. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
32 | * POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #include <linux/netdevice.h> | ||
36 | #include <net/dcbnl.h> | ||
37 | |||
38 | #include "spectrum.h" | ||
39 | |||
40 | static u8 mlxsw_sp_dcbnl_getdcbx(struct net_device __always_unused *dev) | ||
41 | { | ||
42 | return DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE; | ||
43 | } | ||
44 | |||
45 | static u8 mlxsw_sp_dcbnl_setdcbx(struct net_device __always_unused *dev, | ||
46 | u8 mode) | ||
47 | { | ||
48 | return (mode != (DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE)) ? 1 : 0; | ||
49 | } | ||
50 | |||
51 | static const struct dcbnl_rtnl_ops mlxsw_sp_dcbnl_ops = { | ||
52 | .getdcbx = mlxsw_sp_dcbnl_getdcbx, | ||
53 | .setdcbx = mlxsw_sp_dcbnl_setdcbx, | ||
54 | }; | ||
55 | |||
56 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) | ||
57 | { | ||
58 | mlxsw_sp_port->dev->dcbnl_ops = &mlxsw_sp_dcbnl_ops; | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) | ||
64 | { | ||
65 | } | ||