Skip to content

Commit f00817d

Browse files
idoschdavem330
authored andcommitted
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>
1 parent 90183b9 commit f00817d

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ config MLXSW_SPECTRUM
5050

5151
To compile this driver as a module, choose M here: the
5252
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.

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ mlxsw_switchx2-objs := switchx2.o
88
obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o
99
mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \
1010
spectrum_switchdev.o
11+
mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,14 @@ static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
16811681
goto err_port_ets_init;
16821682
}
16831683

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+
16841692
mlxsw_sp_port_switchdev_init(mlxsw_sp_port);
16851693
err = register_netdev(dev);
16861694
if (err) {
@@ -1701,6 +1709,7 @@ static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
17011709
err_port_vlan_init:
17021710
unregister_netdev(dev);
17031711
err_register_netdev:
1712+
err_port_dcb_init:
17041713
err_port_ets_init:
17051714
err_port_buffers_init:
17061715
err_port_admin_status_set:
@@ -1771,6 +1780,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
17711780
devlink_port = &mlxsw_sp_port->devlink_port;
17721781
devlink_port_type_clear(devlink_port);
17731782
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
1783+
mlxsw_sp_port_dcb_fini(mlxsw_sp_port);
17741784
devlink_port_unregister(devlink_port);
17751785
mlxsw_sp_port_vports_fini(mlxsw_sp_port);
17761786
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,21 @@ int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 vfid,
270270
void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port);
271271
int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
272272

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+
273290
#endif
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)