Commit a9c766bb authored by Or Gerlitz's avatar Or Gerlitz Committed by Roland Dreier

IB/mlx4: Fix info returned when querying IBoE ports

To issue a port query, use the QUERY_(Ethernet)_PORT command instead
of the MAD_IFC command, since MAD_IFC attempts to query the firmware
IB SMA, which is irrelevant for IBoE ports.

This allows us to handle both 10Gb/s and 40Gb/s rates (e.g in sysfs),
using QDR speed (10Gb/s) and width of 1X or 4X.
Signed-off-by: default avatarDotan Barak <dotanb@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 3616f9ce
...@@ -182,12 +182,27 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num) ...@@ -182,12 +182,27 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
} }
static int ib_link_query_port(struct ib_device *ibdev, u8 port, static int ib_link_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props, struct ib_port_attr *props)
struct ib_smp *in_mad,
struct ib_smp *out_mad)
{ {
struct ib_smp *in_mad = NULL;
struct ib_smp *out_mad = NULL;
int ext_active_speed; int ext_active_speed;
int err; int err = -ENOMEM;
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port);
err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL,
in_mad, out_mad);
if (err)
goto out;
props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16)); props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16));
props->lmc = out_mad->data[34] & 0x7; props->lmc = out_mad->data[34] & 0x7;
...@@ -234,15 +249,17 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port, ...@@ -234,15 +249,17 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port, err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port,
NULL, NULL, in_mad, out_mad); NULL, NULL, in_mad, out_mad);
if (err) if (err)
return err; goto out;
/* Checking LinkSpeedActive for FDR-10 */ /* Checking LinkSpeedActive for FDR-10 */
if (out_mad->data[15] & 0x1) if (out_mad->data[15] & 0x1)
props->active_speed = 8; props->active_speed = 8;
} }
} }
out:
return 0; kfree(in_mad);
kfree(out_mad);
return err;
} }
static u8 state_to_phys_state(enum ib_port_state state) static u8 state_to_phys_state(enum ib_port_state state)
...@@ -251,32 +268,42 @@ static u8 state_to_phys_state(enum ib_port_state state) ...@@ -251,32 +268,42 @@ static u8 state_to_phys_state(enum ib_port_state state)
} }
static int eth_link_query_port(struct ib_device *ibdev, u8 port, static int eth_link_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props, struct ib_port_attr *props)
struct ib_smp *out_mad)
{ {
struct mlx4_ib_iboe *iboe = &to_mdev(ibdev)->iboe;
struct mlx4_ib_dev *mdev = to_mdev(ibdev);
struct mlx4_ib_iboe *iboe = &mdev->iboe;
struct net_device *ndev; struct net_device *ndev;
enum ib_mtu tmp; enum ib_mtu tmp;
struct mlx4_cmd_mailbox *mailbox;
int err = 0;
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, port, 0,
MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B,
MLX4_CMD_WRAPPED);
if (err)
goto out;
props->active_width = IB_WIDTH_1X; props->active_width = (((u8 *)mailbox->buf)[5] == 0x40) ?
IB_WIDTH_4X : IB_WIDTH_1X;
props->active_speed = 4; props->active_speed = 4;
props->port_cap_flags = IB_PORT_CM_SUP; props->port_cap_flags = IB_PORT_CM_SUP;
props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len[port]; props->gid_tbl_len = mdev->dev->caps.gid_table_len[port];
props->max_msg_sz = to_mdev(ibdev)->dev->caps.max_msg_sz; props->max_msg_sz = mdev->dev->caps.max_msg_sz;
props->pkey_tbl_len = 1; props->pkey_tbl_len = 1;
props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46));
props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
props->max_mtu = IB_MTU_4096; props->max_mtu = IB_MTU_4096;
props->subnet_timeout = 0; props->max_vl_num = 2;
props->max_vl_num = out_mad->data[37] >> 4;
props->init_type_reply = 0;
props->state = IB_PORT_DOWN; props->state = IB_PORT_DOWN;
props->phys_state = state_to_phys_state(props->state); props->phys_state = state_to_phys_state(props->state);
props->active_mtu = IB_MTU_256; props->active_mtu = IB_MTU_256;
spin_lock(&iboe->lock); spin_lock(&iboe->lock);
ndev = iboe->netdevs[port - 1]; ndev = iboe->netdevs[port - 1];
if (!ndev) if (!ndev)
goto out; goto out_unlock;
tmp = iboe_get_mtu(ndev->mtu); tmp = iboe_get_mtu(ndev->mtu);
props->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256; props->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256;
...@@ -284,41 +311,23 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port, ...@@ -284,41 +311,23 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
props->state = (netif_running(ndev) && netif_carrier_ok(ndev)) ? props->state = (netif_running(ndev) && netif_carrier_ok(ndev)) ?
IB_PORT_ACTIVE : IB_PORT_DOWN; IB_PORT_ACTIVE : IB_PORT_DOWN;
props->phys_state = state_to_phys_state(props->state); props->phys_state = state_to_phys_state(props->state);
out_unlock:
out:
spin_unlock(&iboe->lock); spin_unlock(&iboe->lock);
return 0; out:
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
return err;
} }
static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port, static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props) struct ib_port_attr *props)
{ {
struct ib_smp *in_mad = NULL; int err;
struct ib_smp *out_mad = NULL;
int err = -ENOMEM;
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
memset(props, 0, sizeof *props); memset(props, 0, sizeof *props);
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port);
err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad);
if (err)
goto out;
err = mlx4_ib_port_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND ? err = mlx4_ib_port_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND ?
ib_link_query_port(ibdev, port, props, in_mad, out_mad) : ib_link_query_port(ibdev, port, props) :
eth_link_query_port(ibdev, port, props, out_mad); eth_link_query_port(ibdev, port, props);
out:
kfree(in_mad);
kfree(out_mad);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment