1From 1640688018f329559c61352646f283f98938af31 Mon Sep 17 00:00:00 2001
2From: Cole Helbling <cole.helbling@determinate.systems>
3Date: Thu, 16 Feb 2023 09:30:21 -0800
4Subject: [PATCH] Revert "RDMA/irdma: Report the correct link speed"
5
6This reverts commit 425c9bd06b7a70796d880828d15c11321bdfb76d.
7
8Some Equinix Metal instances, such as a3.large.x86, m3.large.x86
9(specific hardware revisions), and n3.large.x86, use the `ice` kernel
10driver for their network cards, in conjunction with bonded devices.
11However, this commit caused a regression where these bonded devices
12would deadlock. This was initially reported by Jaroslav Pulchart on
13the netdev mailing list[1], and there were follow-up patches from Dave
14Ertman[2][3] that attempted to fix this but were not up to snuff for
15various reasons[4].
16
17Specifically, v2 of the patch ([3]) appears to fix the issue on some
18devices (tested with 8086:159B network cards), while it is still broken
19on others (such as an 8086:1593 network card).
20
21We revert the patch exposing the issue until upstream has a working
22solution in order to make Equinix Metal instances work reliably again.
23
24[1]: https://lore.kernel.org/netdev/CAK8fFZ6A_Gphw_3-QMGKEFQk=sfCw1Qmq0TVZK3rtAi7vb621A@mail.gmail.com/
25[2]: https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20230111183145.1497367-1-david.m.ertman@intel.com/
26[3]: https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20230215191757.1826508-1-david.m.ertman@intel.com/
27[4]: https://lore.kernel.org/netdev/cb31a911-ba80-e2dc-231f-851757cfd0b8@intel.com/T/#m6e53f8c43093693c10268140126abe99e082dc1c
28---
29 drivers/infiniband/hw/irdma/verbs.c | 35 ++++++++++++++++++++++++++---
30 1 file changed, 32 insertions(+), 3 deletions(-)
31
32diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
33index c5971a840b87..911902d2b93e 100644
34--- a/drivers/infiniband/hw/irdma/verbs.c
35+++ b/drivers/infiniband/hw/irdma/verbs.c
36@@ -60,6 +60,36 @@ static int irdma_query_device(struct ib_device *ibdev,
37 return 0;
38 }
39
40+/**
41+ * irdma_get_eth_speed_and_width - Get IB port speed and width from netdev speed
42+ * @link_speed: netdev phy link speed
43+ * @active_speed: IB port speed
44+ * @active_width: IB port width
45+ */
46+static void irdma_get_eth_speed_and_width(u32 link_speed, u16 *active_speed,
47+ u8 *active_width)
48+{
49+ if (link_speed <= SPEED_1000) {
50+ *active_width = IB_WIDTH_1X;
51+ *active_speed = IB_SPEED_SDR;
52+ } else if (link_speed <= SPEED_10000) {
53+ *active_width = IB_WIDTH_1X;
54+ *active_speed = IB_SPEED_FDR10;
55+ } else if (link_speed <= SPEED_20000) {
56+ *active_width = IB_WIDTH_4X;
57+ *active_speed = IB_SPEED_DDR;
58+ } else if (link_speed <= SPEED_25000) {
59+ *active_width = IB_WIDTH_1X;
60+ *active_speed = IB_SPEED_EDR;
61+ } else if (link_speed <= SPEED_40000) {
62+ *active_width = IB_WIDTH_4X;
63+ *active_speed = IB_SPEED_FDR10;
64+ } else {
65+ *active_width = IB_WIDTH_4X;
66+ *active_speed = IB_SPEED_EDR;
67+ }
68+}
69+
70 /**
71 * irdma_query_port - get port attributes
72 * @ibdev: device pointer from stack
73@@ -87,9 +117,8 @@ static int irdma_query_port(struct ib_device *ibdev, u32 port,
74 props->state = IB_PORT_DOWN;
75 props->phys_state = IB_PORT_PHYS_STATE_DISABLED;
76 }
77-
78- ib_get_eth_speed(ibdev, port, &props->active_speed,
79- &props->active_width);
80+ irdma_get_eth_speed_and_width(SPEED_100000, &props->active_speed,
81+ &props->active_width);
82
83 if (rdma_protocol_roce(ibdev, 1)) {
84 props->gid_tbl_len = 32;
85--
862.39.0
87