ibcore: Introduce ib_port_phys_state enum.
In order to improve readability, add ib_port_phys_state enum to replace the use of magic numbers. Linux commit: 72a7720fca37fec0daf295923f17ac5d88a613e1 MFC after: 1 week Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
This commit is contained in:
parent
d7d833e20b
commit
4238b4a7a2
@ -684,7 +684,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
|
||||
|
||||
static u8 state_to_phys_state(enum ib_port_state state)
|
||||
{
|
||||
return state == IB_PORT_ACTIVE ? 5 : 3;
|
||||
return state == IB_PORT_ACTIVE ?
|
||||
IB_PORT_PHYS_STATE_LINK_UP : IB_PORT_PHYS_STATE_DISABLED;
|
||||
}
|
||||
|
||||
static int eth_link_query_port(struct ib_device *ibdev, u8 port,
|
||||
|
@ -319,7 +319,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
|
||||
props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
|
||||
props->pkey_tbl_len = 1;
|
||||
props->state = IB_PORT_DOWN;
|
||||
props->phys_state = 3;
|
||||
props->phys_state = IB_PORT_PHYS_STATE_DISABLED;
|
||||
|
||||
mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev, &qkey_viol_cntr);
|
||||
props->qkey_viol_cntr = qkey_viol_cntr;
|
||||
@ -331,7 +331,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
|
||||
if (ndev->if_drv_flags & IFF_DRV_RUNNING &&
|
||||
ndev->if_link_state == LINK_STATE_UP) {
|
||||
props->state = IB_PORT_ACTIVE;
|
||||
props->phys_state = 5;
|
||||
props->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
|
||||
}
|
||||
|
||||
ndev_ib_mtu = iboe_get_mtu(ndev->if_mtu);
|
||||
|
@ -293,6 +293,24 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
|
||||
ib_width_enum_to_int(attr.active_width), speed);
|
||||
}
|
||||
|
||||
static const char *phys_state_to_str(enum ib_port_phys_state phys_state)
|
||||
{
|
||||
static const char * phys_state_str[] = {
|
||||
"<unknown>",
|
||||
"Sleep",
|
||||
"Polling",
|
||||
"Disabled",
|
||||
"PortConfigurationTraining",
|
||||
"LinkUp",
|
||||
"LinkErrorRecovery",
|
||||
"Phy Test",
|
||||
};
|
||||
|
||||
if (phys_state < ARRAY_SIZE(phys_state_str))
|
||||
return phys_state_str[phys_state];
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
|
||||
char *buf)
|
||||
{
|
||||
@ -304,16 +322,8 @@ static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
switch (attr.phys_state) {
|
||||
case 1: return sprintf(buf, "1: Sleep\n");
|
||||
case 2: return sprintf(buf, "2: Polling\n");
|
||||
case 3: return sprintf(buf, "3: Disabled\n");
|
||||
case 4: return sprintf(buf, "4: PortConfigurationTraining\n");
|
||||
case 5: return sprintf(buf, "5: LinkUp\n");
|
||||
case 6: return sprintf(buf, "6: LinkErrorRecovery\n");
|
||||
case 7: return sprintf(buf, "7: Phy Test\n");
|
||||
default: return sprintf(buf, "%d: <unknown>\n", attr.phys_state);
|
||||
}
|
||||
return sprintf(buf, "%d: %s\n", attr.phys_state,
|
||||
phys_state_to_str(attr.phys_state));
|
||||
}
|
||||
|
||||
static ssize_t link_layer_show(struct ib_port *p, struct port_attribute *unused,
|
||||
|
@ -396,6 +396,16 @@ enum ib_port_cap_flags {
|
||||
IB_PORT_IP_BASED_GIDS = 1 << 26,
|
||||
};
|
||||
|
||||
enum ib_port_phys_state {
|
||||
IB_PORT_PHYS_STATE_SLEEP = 1,
|
||||
IB_PORT_PHYS_STATE_POLLING = 2,
|
||||
IB_PORT_PHYS_STATE_DISABLED = 3,
|
||||
IB_PORT_PHYS_STATE_PORT_CONFIGURATION_TRAINING = 4,
|
||||
IB_PORT_PHYS_STATE_LINK_UP = 5,
|
||||
IB_PORT_PHYS_STATE_LINK_ERROR_RECOVERY = 6,
|
||||
IB_PORT_PHYS_STATE_PHY_TEST = 7,
|
||||
};
|
||||
|
||||
enum ib_port_width {
|
||||
IB_WIDTH_1X = 1,
|
||||
IB_WIDTH_2X = 16,
|
||||
|
Loading…
Reference in New Issue
Block a user