Skip to content

Commit 265bee7

Browse files
committed
Merge branch 'mlxsw-next'
Jiri Pirko says: ==================== mlxsw: small driver update, including switchdev doc update Ido Schimmel (3): mlxsw: spectrum: Reduce number of supported 802.1D bridges switchdev: Use switch ID in suggested udev rule mlxsw: spectrum: Add support for physical port names ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 15f41e2 + 2bf9a58 commit 265bee7

File tree

3 files changed

+57
-18
lines changed

3 files changed

+57
-18
lines changed

Documentation/networking/switchdev.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ Typically, the management port is not participating in offloaded data plane and
8989
is loaded with a different driver, such as a NIC driver, on the management port
9090
device.
9191

92+
Switch ID
93+
^^^^^^^^^
94+
95+
The switchdev driver must implement the switchdev op switchdev_port_attr_get
96+
for SWITCHDEV_ATTR_ID_PORT_PARENT_ID for each port netdev, returning the same
97+
physical ID for each port of a switch. The ID must be unique between switches
98+
on the same system. The ID does not need to be unique between switches on
99+
different systems.
100+
101+
The switch ID is used to locate ports on a switch and to know if aggregated
102+
ports belong to the same switch.
103+
92104
Port Netdev Naming
93105
^^^^^^^^^^^^^^^^^^
94106

@@ -104,25 +116,13 @@ external configuration. For example, if a physical 40G port is split logically
104116
into 4 10G ports, resulting in 4 port netdevs, the device can give a unique
105117
name for each port using port PHYS name. The udev rule would be:
106118

107-
SUBSYSTEM=="net", ACTION=="add", DRIVER="<driver>", ATTR{phys_port_name}!="", \
108-
NAME="$attr{phys_port_name}"
119+
SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}=="<phys_switch_id>", \
120+
ATTR{phys_port_name}!="", NAME="swX$attr{phys_port_name}"
109121

110122
Suggested naming convention is "swXpYsZ", where X is the switch name or ID, Y
111123
is the port name or ID, and Z is the sub-port name or ID. For example, sw1p1s0
112124
would be sub-port 0 on port 1 on switch 1.
113125

114-
Switch ID
115-
^^^^^^^^^
116-
117-
The switchdev driver must implement the switchdev op switchdev_port_attr_get
118-
for SWITCHDEV_ATTR_ID_PORT_PARENT_ID for each port netdev, returning the same
119-
physical ID for each port of a switch. The ID must be unique between switches
120-
on the same system. The ID does not need to be unique between switches on
121-
different systems.
122-
123-
The switch ID is used to locate ports on a switch and to know if aggregated
124-
ports belong to the same switch.
125-
126126
Port Features
127127
^^^^^^^^^^^^^
128128

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port)
305305
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
306306
}
307307

308-
static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
309-
u8 local_port, u8 *p_module,
310-
u8 *p_width)
308+
static int __mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
309+
u8 local_port, u8 *p_module,
310+
u8 *p_width, u8 *p_lane)
311311
{
312312
char pmlp_pl[MLXSW_REG_PMLP_LEN];
313313
int err;
@@ -318,9 +318,20 @@ static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
318318
return err;
319319
*p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
320320
*p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
321+
*p_lane = mlxsw_reg_pmlp_tx_lane_get(pmlp_pl, 0);
321322
return 0;
322323
}
323324

325+
static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
326+
u8 local_port, u8 *p_module,
327+
u8 *p_width)
328+
{
329+
u8 lane;
330+
331+
return __mlxsw_sp_port_module_info_get(mlxsw_sp, local_port, p_module,
332+
p_width, &lane);
333+
}
334+
324335
static int mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u8 local_port,
325336
u8 module, u8 width, u8 lane)
326337
{
@@ -861,6 +872,33 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev,
861872
return 0;
862873
}
863874

875+
static int mlxsw_sp_port_get_phys_port_name(struct net_device *dev, char *name,
876+
size_t len)
877+
{
878+
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
879+
u8 module, width, lane;
880+
int err;
881+
882+
err = __mlxsw_sp_port_module_info_get(mlxsw_sp_port->mlxsw_sp,
883+
mlxsw_sp_port->local_port,
884+
&module, &width, &lane);
885+
if (err) {
886+
netdev_err(dev, "Failed to retrieve module information\n");
887+
return err;
888+
}
889+
890+
if (!mlxsw_sp_port->split)
891+
err = snprintf(name, len, "p%d", module + 1);
892+
else
893+
err = snprintf(name, len, "p%ds%d", module + 1,
894+
lane / width);
895+
896+
if (err >= len)
897+
return -EINVAL;
898+
899+
return 0;
900+
}
901+
864902
static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
865903
.ndo_open = mlxsw_sp_port_open,
866904
.ndo_stop = mlxsw_sp_port_stop,
@@ -877,6 +915,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
877915
.ndo_bridge_setlink = switchdev_port_bridge_setlink,
878916
.ndo_bridge_getlink = switchdev_port_bridge_getlink,
879917
.ndo_bridge_dellink = switchdev_port_bridge_dellink,
918+
.ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name,
880919
};
881920

882921
static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
#define MLXSW_SP_VFID_BASE VLAN_N_VID
5252
#define MLXSW_SP_VFID_PORT_MAX 512 /* Non-bridged VLAN interfaces */
53-
#define MLXSW_SP_VFID_BR_MAX 8192 /* Bridged VLAN interfaces */
53+
#define MLXSW_SP_VFID_BR_MAX 6144 /* Bridged VLAN interfaces */
5454
#define MLXSW_SP_VFID_MAX (MLXSW_SP_VFID_PORT_MAX + MLXSW_SP_VFID_BR_MAX)
5555

5656
#define MLXSW_SP_LAG_MAX 64

0 commit comments

Comments
 (0)