Skip to content

Commit fd0edee

Browse files
committed
Fix crosslink NTB requester ID issue
It was observed in a crosslink NT setup with two hosts having different numbers of requester IDs that the traffic can go only in one direction. In the setup, the switch of host A connects to CPU1, while the switch of host B connects to CPU0. After loading the driver, the two hosts have the following requester IDs. And the traffic only goes from B to A. Host A - Host B 0:0.0 0:0.0 80:3.0 When a TLP gose from host A to host B, it first goes from host A CPU to the local crosslink partition (there are a pair of virtual partitions in between the two switches in the crosslink NTB setup), with the original requester ID be replaced with a proxy ID, then be routed to the peer crosslink partition. If the new requester ID (prxoy ID of the local crosslink partition) hit one entry in the requester ID table of the peer crosslink partition, it will finally be routed to Host B. Otherwise, it will be dropped. The reason for the above phenomenon is that the driver wrongly registers the requester IDs to the local crosslink partition, instead of to its peer. So when the traffic from host A with requester ID reaches the crosslink partition of host B and hits no entry, it goes nowhere. This patch fixes this by registering the proper requester IDs to the peer crosslink partition. Another internal LUT window is allocated for routing the configuration traffic to the GAS region of the peer crosslink partition.
1 parent a9686a7 commit fd0edee

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

ntb_hw_switchtec.c

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ struct switchtec_ntb {
9494
struct ntb_dbmsg_regs __iomem *mmio_dbmsg;
9595
struct ntb_ctrl_regs __iomem *mmio_self_ctrl;
9696
struct ntb_ctrl_regs __iomem *mmio_peer_ctrl;
97+
struct ntb_ctrl_regs __iomem *mmio_xlink_peer_ctrl;
9798
struct ntb_dbmsg_regs __iomem *mmio_self_dbmsg;
9899
struct ntb_dbmsg_regs __iomem *mmio_peer_dbmsg;
99100

100101
void __iomem *mmio_xlink_dbmsg_win;
102+
void __iomem *mmio_xlink_ctrl_win;
101103

102104
struct shared_mw *self_shared;
103105
struct shared_mw __iomem *peer_shared;
@@ -616,6 +618,9 @@ static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,
616618
return sndev->link_is_up;
617619
}
618620

621+
static int crosslink_setup_req_ids(struct switchtec_ntb *sndev,
622+
struct ntb_ctrl_regs __iomem *mmio_ctrl);
623+
619624
static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
620625
enum ntb_speed max_speed,
621626
enum ntb_width max_width)
@@ -627,6 +632,9 @@ static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
627632
sndev->self_shared->link_sta = 1;
628633
switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
629634

635+
if (crosslink_is_enabled(sndev))
636+
crosslink_setup_req_ids(sndev, sndev->mmio_xlink_peer_ctrl);
637+
630638
switchtec_ntb_link_status_update(sndev);
631639

632640
return 0;
@@ -1154,7 +1162,9 @@ static int clr_req_ids(struct switchtec_ntb *sndev,
11541162
return 0;
11551163
}
11561164

1157-
static int crosslink_setup_mws(struct switchtec_ntb *sndev, int dbmsg_lut_idx,
1165+
static int crosslink_setup_mws(struct switchtec_ntb *sndev,
1166+
int ntb_dbmsg_lut_idx,
1167+
int ntb_req_id_lut_idx,
11581168
u64 *mw_addrs, int mw_count)
11591169
{
11601170
int rc, i;
@@ -1171,7 +1181,7 @@ static int crosslink_setup_mws(struct switchtec_ntb *sndev, int dbmsg_lut_idx,
11711181
return rc;
11721182

11731183
for (i = 0; i < sndev->nr_lut_mw; i++) {
1174-
if (i == dbmsg_lut_idx)
1184+
if (i == ntb_dbmsg_lut_idx || i == ntb_req_id_lut_idx)
11751185
continue;
11761186

11771187
addr = mw_addrs[0] + LUT_SIZE * i;
@@ -1290,6 +1300,7 @@ static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
12901300
int rc;
12911301
int bar = sndev->direct_mw_to_bar[0];
12921302
const int dbmsg_lut_idx = 1;
1303+
const int req_id_lut_idx = 2;
12931304
u64 bar_addrs[6];
12941305
u64 addr;
12951306
int offset;
@@ -1320,34 +1331,60 @@ static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
13201331
if (rc)
13211332
return rc;
13221333

1323-
rc = crosslink_setup_mws(sndev, dbmsg_lut_idx, &bar_addrs[1],
1324-
bar_cnt - 1);
1325-
if (rc)
1334+
sndev->mmio_xlink_dbmsg_win = pci_iomap_range(sndev->stdev->pdev, bar,
1335+
dbmsg_lut_idx * LUT_SIZE,
1336+
LUT_SIZE);
1337+
if (!sndev->mmio_xlink_dbmsg_win) {
1338+
rc = -ENOMEM;
13261339
return rc;
1340+
}
1341+
1342+
sndev->mmio_peer_dbmsg = sndev->mmio_xlink_dbmsg_win + offset;
1343+
sndev->nr_rsvd_luts++;
1344+
1345+
addr = (bar_addrs[0] + SWITCHTEC_GAS_NTB_OFFSET +
1346+
SWITCHTEC_NTB_REG_CTRL_OFFSET +
1347+
sizeof(struct ntb_ctrl_regs) * sndev->peer_partition);
1348+
1349+
offset = addr & (LUT_SIZE - 1);
1350+
addr -= offset;
13271351

1328-
rc = crosslink_setup_req_ids(sndev, sndev->mmio_peer_ctrl);
1352+
rc = config_rsvd_lut_win(sndev, sndev->mmio_self_ctrl,
1353+
req_id_lut_idx,
1354+
sndev->peer_partition, addr);
13291355
if (rc)
13301356
return rc;
13311357

1332-
sndev->mmio_xlink_dbmsg_win = pci_iomap_range(sndev->stdev->pdev, bar,
1333-
LUT_SIZE, LUT_SIZE);
1334-
if (!sndev->mmio_xlink_dbmsg_win) {
1358+
sndev->mmio_xlink_ctrl_win = pci_iomap_range(sndev->stdev->pdev, bar,
1359+
req_id_lut_idx * LUT_SIZE,
1360+
LUT_SIZE);
1361+
if (!sndev->mmio_xlink_ctrl_win) {
13351362
rc = -ENOMEM;
13361363
return rc;
13371364
}
13381365

1339-
sndev->mmio_peer_dbmsg = sndev->mmio_xlink_dbmsg_win + offset;
1366+
sndev->mmio_xlink_peer_ctrl = sndev->mmio_xlink_ctrl_win + offset;
13401367
sndev->nr_rsvd_luts++;
13411368

1369+
rc = crosslink_setup_mws(sndev, dbmsg_lut_idx, req_id_lut_idx,
1370+
&bar_addrs[1], bar_cnt - 1);
1371+
if (rc)
1372+
return rc;
1373+
13421374
crosslink_init_dbmsgs(sndev);
13431375

1376+
crosslink_setup_req_ids(sndev, sndev->mmio_xlink_peer_ctrl);
1377+
13441378
return 0;
13451379
}
13461380

13471381
static void switchtec_ntb_deinit_crosslink(struct switchtec_ntb *sndev)
13481382
{
13491383
if (sndev->mmio_xlink_dbmsg_win)
13501384
pci_iounmap(sndev->stdev->pdev, sndev->mmio_xlink_dbmsg_win);
1385+
1386+
if (sndev->mmio_xlink_ctrl_win)
1387+
pci_iounmap(sndev->stdev->pdev, sndev->mmio_xlink_ctrl_win);
13511388
}
13521389

13531390
static int map_bars(int *map, struct ntb_ctrl_regs __iomem *ctrl)
@@ -1659,7 +1696,8 @@ static ssize_t add_requester_id_store(struct device *dev,
16591696
return rc;
16601697

16611698
if (crosslink_is_enabled(sndev)) {
1662-
rc = crosslink_setup_req_ids(sndev, sndev->mmio_peer_ctrl);
1699+
rc = crosslink_setup_req_ids(sndev,
1700+
sndev->mmio_xlink_peer_ctrl);
16631701
if (rc)
16641702
return rc;
16651703
}
@@ -1687,7 +1725,8 @@ static ssize_t del_requester_id_store(struct device *dev,
16871725
return rc;
16881726

16891727
if (crosslink_is_enabled(sndev)) {
1690-
rc = crosslink_setup_req_ids(sndev, sndev->mmio_peer_ctrl);
1728+
rc = crosslink_setup_req_ids(sndev,
1729+
sndev->mmio_xlink_peer_ctrl);
16911730
if (rc)
16921731
return rc;
16931732
}

0 commit comments

Comments
 (0)