From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
yotamg@mellanox.com, ogerlitz@mellanox.com, yishaih@mellanox.com,
dledford@redhat.com, sean.hefty@intel.com,
hal.rosenstock@gmail.com, eugenia@mellanox.com,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
hadarh@mellanox.com, jhs@mojatatu.com, john.fastabend@gmail.com,
jeffrey.t.kirsher@intel.com, brouer@redhat.com,
ivecera@redhat.com, rami.rosen@intel.com
Subject: [patch net-next 7/9] mlxsw: spectrum: Store local port to module mapping during init
Date: Mon, 22 Feb 2016 19:32:02 +0100 [thread overview]
Message-ID: <1456165924-14399-8-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1456165924-14399-1-git-send-email-jiri@resnulli.us>
From: Ido Schimmel <idosch@mellanox.com>
The port netdevs are each associated with a different local port number
in the device. These local ports are grouped into groups of 4 (e.g.
(1-4), (5-8)) called clusters. The cluster constitutes the one of two
possible modules they can be mapped to. This mapping is board-specific
and done by the device's firmware during init.
When splitting a port by 4, the device requires us to first unmap all
the ports in the cluster and then map each to a single lane in the module
associated with the port netdev used as the handle for the operation.
This means that two port netdevs will disappear, as only 100Gb/s (4
lanes) ports can be split and we are guaranteed to have two of these
((1, 3), (5, 7) etc.) in a cluster.
When unsplit occurs we need to reinstantiate the two original 100Gb/s
ports and map each to its origianl module. Therefore, during driver init
store the initial local port to module mapping, so it can be used later
during unsplitting.
Note that a by 2 split doesn't require us to store the mapping, as we
only need to reinstantiate one port whose module is known.
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 36 +++++++++++---------------
drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 +
2 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1d6f1ef..b9d963a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -305,18 +305,19 @@ mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port)
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
}
-static int mlxsw_sp_port_module_check(struct mlxsw_sp_port *mlxsw_sp_port,
- bool *p_usable)
+static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
+ u8 local_port, u8 *p_module,
+ u8 *p_width)
{
- struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char pmlp_pl[MLXSW_REG_PMLP_LEN];
int err;
- mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port);
+ mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
if (err)
return err;
- *p_usable = mlxsw_reg_pmlp_width_get(pmlp_pl) ? true : false;
+ *p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
+ *p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
return 0;
}
@@ -1365,7 +1366,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
struct mlxsw_sp_port *mlxsw_sp_port;
struct devlink_port *devlink_port;
struct net_device *dev;
- bool usable;
size_t bytes;
int err;
@@ -1417,19 +1417,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
*/
dev->hard_header_len += MLXSW_TXHDR_LEN;
- err = mlxsw_sp_port_module_check(mlxsw_sp_port, &usable);
- if (err) {
- dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to check module\n",
- mlxsw_sp_port->local_port);
- goto err_port_module_check;
- }
-
- if (!usable) {
- dev_dbg(mlxsw_sp->bus_info->dev, "Port %d: Not usable, skipping initialization\n",
- mlxsw_sp_port->local_port);
- goto port_not_usable;
- }
-
devlink_port = &mlxsw_sp_port->devlink_port;
err = devlink_port_register(devlink, devlink_port, local_port);
if (err) {
@@ -1497,8 +1484,6 @@ err_port_swid_set:
err_port_system_port_mapping_set:
devlink_port_unregister(&mlxsw_sp_port->devlink_port);
err_devlink_port_register:
-port_not_usable:
-err_port_module_check:
err_dev_addr_init:
free_percpu(mlxsw_sp_port->pcpu_stats);
err_alloc_stats:
@@ -1560,6 +1545,7 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
{
size_t alloc_size;
+ u8 module, width;
int i;
int err;
@@ -1569,6 +1555,13 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
return -ENOMEM;
for (i = 1; i < MLXSW_PORT_MAX_PORTS; i++) {
+ err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, &module,
+ &width);
+ if (err)
+ goto err_port_module_info_get;
+ if (!width)
+ continue;
+ mlxsw_sp->port_to_module[i] = module;
err = mlxsw_sp_port_create(mlxsw_sp, i);
if (err)
goto err_port_create;
@@ -1576,6 +1569,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
return 0;
err_port_create:
+err_port_module_info_get:
for (i--; i >= 1; i--)
mlxsw_sp_port_remove(mlxsw_sp, i);
kfree(mlxsw_sp->ports);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 0df9a19..c75dd08 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -123,6 +123,7 @@ struct mlxsw_sp {
u32 ageing_time;
struct mlxsw_sp_upper master_bridge;
struct mlxsw_sp_upper lags[MLXSW_SP_LAG_MAX];
+ u8 port_to_module[MLXSW_PORT_MAX_PORTS];
};
static inline struct mlxsw_sp_upper *
--
2.5.0
next prev parent reply other threads:[~2016-02-22 18:32 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-22 18:31 [patch net-next 0/9] Introduce devlink interface and first drivers to use it Jiri Pirko
2016-02-22 18:31 ` [patch net-next 1/9] Introduce devlink infrastructure Jiri Pirko
2016-02-22 22:29 ` roopa
2016-02-23 7:47 ` Jiri Pirko
2016-02-24 7:02 ` Yuval Mintz
2016-02-24 10:56 ` Jiri Pirko
2016-02-22 18:31 ` [patch net-next 2/9] mlx4: Implement devlink interface Jiri Pirko
2016-02-22 18:31 ` [patch net-next 3/9] mlx4: Implement port type setting via " Jiri Pirko
2016-02-23 11:26 ` Hannes Frederic Sowa
2016-02-23 12:21 ` Jiri Pirko
2016-02-23 13:28 ` Hannes Frederic Sowa
2016-02-23 14:26 ` Jiri Pirko
2016-02-23 15:16 ` Hannes Frederic Sowa
2016-02-23 15:30 ` Jiri Pirko
2016-02-23 15:57 ` Hannes Frederic Sowa
2016-02-23 16:04 ` Jiri Pirko
2016-02-23 16:45 ` Hannes Frederic Sowa
2016-02-23 16:55 ` Jiri Pirko
2016-02-23 17:07 ` Hannes Frederic Sowa
2016-02-23 15:20 ` Andy Gospodarek
2016-02-23 15:31 ` Jiri Pirko
2016-02-23 18:16 ` David Miller
2016-02-23 17:31 ` Stephen Hemminger
2016-02-24 7:15 ` Jiri Pirko
2016-02-22 18:31 ` [patch net-next 4/9] mlxsw: Implement " Jiri Pirko
2016-02-22 18:32 ` [patch net-next 5/9] mlxsw: core: Add devlink port splitter callbacks Jiri Pirko
2016-02-22 18:32 ` [patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown Jiri Pirko
2016-02-22 20:32 ` John Fastabend
2016-02-22 21:00 ` Ido Schimmel
2016-02-22 21:08 ` John Fastabend
2016-02-23 4:50 ` Andy Gospodarek
2016-02-22 18:32 ` Jiri Pirko [this message]
2016-02-22 18:32 ` [patch net-next 8/9] mlxsw: spectrum: Mark unused ports using NULL Jiri Pirko
2016-02-22 18:32 ` [patch net-next 9/9] mlxsw: spectrum: Introduce port splitting Jiri Pirko
2016-02-23 5:12 ` [patch net-next 0/9] Introduce devlink interface and first drivers to use it Andy Gospodarek
2016-02-23 7:32 ` Jiri Pirko
2016-02-23 14:34 ` Andy Gospodarek
2016-02-23 14:45 ` Jiri Pirko
2016-02-23 15:55 ` Andy Gospodarek
2016-02-23 16:01 ` Jiri Pirko
2016-02-23 16:19 ` Andy Gospodarek
2016-02-23 16:23 ` Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456165924-14399-8-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=dledford@redhat.com \
--cc=eladr@mellanox.com \
--cc=eugenia@mellanox.com \
--cc=hadarh@mellanox.com \
--cc=hal.rosenstock@gmail.com \
--cc=idosch@mellanox.com \
--cc=ivecera@redhat.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jhs@mojatatu.com \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=ogerlitz@mellanox.com \
--cc=rami.rosen@intel.com \
--cc=roopa@cumulusnetworks.com \
--cc=sean.hefty@intel.com \
--cc=yishaih@mellanox.com \
--cc=yotamg@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).