Skip to content

Commit fee356e

Browse files
committed
Fix a crosslink target partition configuration issue
The remote crosslink partition needs to have its outbound message mapped to the remote host partition which connects to the remote NT host, so that when a message from the local switch hits the remote crosslink partition, it can be forwarded to the remote host. Program the remote host partition ID into the corresponding message registers of the remote crosslink partition.
1 parent 64ab554 commit fee356e

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

ntb_hw_switchtec.c

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,23 +566,59 @@ static int crosslink_is_enabled(struct switchtec_ntb *sndev)
566566
return ioread8(&inf->ntp_info[sndev->peer_partition].xlink_enabled);
567567
}
568568

569-
static void crosslink_init_dbmsgs(struct switchtec_ntb *sndev)
569+
static int crosslink_init_dbmsgs(struct switchtec_ntb *sndev)
570570
{
571571
int i;
572+
u64 tpart_vec;
573+
u64 part_map;
574+
struct ntb_info_regs *xlink_ntb = sndev->mmio_xlink_peer_ntb;
575+
int xlink_self, xlink_peer;
572576
u32 msg_map = 0;
573577

574578
if (!crosslink_is_enabled(sndev))
575-
return;
579+
return 0;
580+
581+
xlink_peer = ioread8(&xlink_ntb->partition_id);
582+
if (xlink_peer == 0xFF)
583+
return -EIO;
584+
585+
tpart_vec = ioread32(&xlink_ntb->ntp_info[xlink_peer].target_part_high);
586+
tpart_vec <<= 32;
587+
tpart_vec |= ioread32(&xlink_ntb->ntp_info[xlink_peer].target_part_low);
588+
part_map = ioread32(&xlink_ntb->ep_map_high);
589+
part_map <<= 32;
590+
part_map |= ioread32(&xlink_ntb->ep_map_low);
591+
part_map &= ~(1 << xlink_peer);
592+
tpart_vec &= part_map;
593+
594+
if (!tpart_vec) {
595+
dev_err(&sndev->stdev->dev,
596+
"Remote crosslink partition has no NT target defined\n");
597+
return -ENODEV;
598+
}
599+
600+
if (__ffs64(tpart_vec) != (fls64(tpart_vec) - 1)) {
601+
dev_err(&sndev->stdev->dev,
602+
"Remote crosslink partition has more than 1 NT target\n");
603+
return -ENODEV;
604+
}
605+
606+
xlink_self = __ffs64(tpart_vec);
607+
608+
dev_dbg(&sndev->stdev->dev,
609+
"Remote self %d, peer %d\n", xlink_self, xlink_peer);
576610

577611
for (i = 0; i < ARRAY_SIZE(sndev->mmio_peer_dbmsg->imsg); i++) {
578-
int m = i | sndev->self_partition << 2;
612+
int m = i | xlink_self << 2;
579613

580614
msg_map |= m << i * 8;
581615
}
582616

583617
iowrite32(msg_map, &sndev->mmio_peer_dbmsg->msg_map);
584618
iowrite64(sndev->db_valid_mask << sndev->db_peer_shift,
585619
&sndev->mmio_peer_dbmsg->odb_mask);
620+
621+
return 0;
586622
}
587623

588624
enum switchtec_msg {

0 commit comments

Comments
 (0)