Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72a7720f authored by Kamal Heib's avatar Kamal Heib Committed by Doug Ledford
Browse files

RDMA: Introduce ib_port_phys_state enum



In order to improve readability, add ib_port_phys_state enum to replace
the use of magic numbers.

Signed-off-by: default avatarKamal Heib <kamalheib1@gmail.com>
Reviewed-by: default avatarAndrew Boyer <aboyer@tobark.org>
Acked-by: default avatarMichal Kalderon <michal.kalderon@marvell.com>
Acked-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
Link: https://lore.kernel.org/r/20190807103138.17219-2-kamalheib1@gmail.com


Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent cfa1f5f2
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -289,6 +289,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)
{
@@ -300,16 +318,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,
+2 −2
Original line number Diff line number Diff line
@@ -220,10 +220,10 @@ int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num,

	if (netif_running(rdev->netdev) && netif_carrier_ok(rdev->netdev)) {
		port_attr->state = IB_PORT_ACTIVE;
		port_attr->phys_state = 5;
		port_attr->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
	} else {
		port_attr->state = IB_PORT_DOWN;
		port_attr->phys_state = 3;
		port_attr->phys_state = IB_PORT_PHYS_STATE_DISABLED;
	}
	port_attr->max_mtu = IB_MTU_4096;
	port_attr->active_mtu = iboe_get_mtu(rdev->netdev->mtu);
+1 −1
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ int efa_query_port(struct ib_device *ibdev, u8 port,
	props->lmc = 1;

	props->state = IB_PORT_ACTIVE;
	props->phys_state = 5;
	props->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
	props->gid_tbl_len = 1;
	props->pkey_tbl_len = 1;
	props->active_speed = IB_SPEED_EDR;
+0 −10
Original line number Diff line number Diff line
@@ -989,16 +989,6 @@ struct hns_roce_hw {
	const struct ib_device_ops *hns_roce_dev_srq_ops;
};

enum hns_phy_state {
	HNS_ROCE_PHY_SLEEP		= 1,
	HNS_ROCE_PHY_POLLING		= 2,
	HNS_ROCE_PHY_DISABLED		= 3,
	HNS_ROCE_PHY_TRAINING		= 4,
	HNS_ROCE_PHY_LINKUP		= 5,
	HNS_ROCE_PHY_LINKERR		= 6,
	HNS_ROCE_PHY_TEST		= 7
};

struct hns_roce_dev {
	struct ib_device	ib_dev;
	struct platform_device  *pdev;
+2 −1
Original line number Diff line number Diff line
@@ -262,7 +262,8 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num,
	props->state = (netif_running(net_dev) && netif_carrier_ok(net_dev)) ?
			IB_PORT_ACTIVE : IB_PORT_DOWN;
	props->phys_state = (props->state == IB_PORT_ACTIVE) ?
			     HNS_ROCE_PHY_LINKUP : HNS_ROCE_PHY_DISABLED;
			     IB_PORT_PHYS_STATE_LINK_UP :
			     IB_PORT_PHYS_STATE_DISABLED;

	spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);

Loading