@@ -94,6 +94,7 @@ struct switchtec_ntb {
9494 struct ntb_ctrl_regs __iomem * mmio_self_ctrl ;
9595 struct ntb_ctrl_regs __iomem * mmio_peer_ctrl ;
9696 struct ntb_dbmsg_regs __iomem * mmio_self_dbmsg ;
97+ struct ntb_dbmsg_regs __iomem * mmio_peer_dbmsg ;
9798
9899 void __iomem * mmio_xlink_win ;
99100
@@ -188,10 +189,10 @@ static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,
188189static int switchtec_ntb_send_msg (struct switchtec_ntb * sndev , int idx ,
189190 u32 val )
190191{
191- if (idx < 0 || idx >= ARRAY_SIZE (sndev -> mmio_self_dbmsg -> omsg ))
192+ if (idx < 0 || idx >= ARRAY_SIZE (sndev -> mmio_peer_dbmsg -> omsg ))
192193 return - EINVAL ;
193194
194- iowrite32 (val , & sndev -> mmio_self_dbmsg -> omsg [idx ].msg );
195+ iowrite32 (val , & sndev -> mmio_peer_dbmsg -> omsg [idx ].msg );
195196
196197 return 0 ;
197198}
@@ -451,6 +452,25 @@ static int crosslink_is_enabled(struct switchtec_ntb *sndev)
451452 return ioread8 (& inf -> crosslink [sndev -> self_partition ].enabled );
452453}
453454
455+ static void crosslink_init_dbmsgs (struct switchtec_ntb * sndev )
456+ {
457+ int i ;
458+ u32 msg_map = 0 ;
459+
460+ if (!crosslink_is_enabled (sndev ))
461+ return ;
462+
463+ for (i = 0 ; i < ARRAY_SIZE (sndev -> mmio_peer_dbmsg -> imsg ); i ++ ) {
464+ int m = i | sndev -> self_partition << 2 ;
465+
466+ msg_map |= m << i * 8 ;
467+ }
468+
469+ iowrite32 (msg_map , & sndev -> mmio_peer_dbmsg -> msg_map );
470+ iowrite64 (sndev -> db_valid_mask << sndev -> db_peer_shift ,
471+ & sndev -> mmio_peer_dbmsg -> odb_mask );
472+ }
473+
454474enum {
455475 LINK_MESSAGE = 0 ,
456476 MSG_LINK_UP = 1 ,
@@ -481,6 +501,9 @@ static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
481501 ntb_link_event (& sndev -> ntb );
482502 dev_info (& sndev -> stdev -> dev , "ntb link %s" ,
483503 link_sta ? "up" : "down" );
504+
505+ if (link_sta )
506+ crosslink_init_dbmsgs (sndev );
484507 }
485508}
486509
@@ -626,7 +649,7 @@ static int switchtec_ntb_peer_db_addr(struct ntb_dev *ntb,
626649 struct switchtec_ntb * sndev = ntb_sndev (ntb );
627650 unsigned long offset ;
628651
629- offset = (unsigned long )sndev -> mmio_self_dbmsg -> odb -
652+ offset = (unsigned long )sndev -> mmio_peer_dbmsg -> odb -
630653 (unsigned long )sndev -> stdev -> mmio ;
631654
632655 offset += sndev -> db_shift / 8 ;
@@ -644,7 +667,7 @@ static int switchtec_ntb_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
644667 struct switchtec_ntb * sndev = ntb_sndev (ntb );
645668
646669 iowrite64 (db_bits << sndev -> db_peer_shift ,
647- & sndev -> mmio_self_dbmsg -> odb );
670+ & sndev -> mmio_peer_dbmsg -> odb );
648671
649672 return 0 ;
650673}
@@ -779,6 +802,7 @@ static void switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
779802 sndev -> mmio_self_ctrl = & sndev -> mmio_ctrl [sndev -> self_partition ];
780803 sndev -> mmio_peer_ctrl = & sndev -> mmio_ctrl [sndev -> peer_partition ];
781804 sndev -> mmio_self_dbmsg = & sndev -> mmio_dbmsg [sndev -> self_partition ];
805+ sndev -> mmio_peer_dbmsg = sndev -> mmio_self_dbmsg ;
782806}
783807
784808static int config_rsvd_lut_win (struct switchtec_ntb * sndev ,
@@ -997,6 +1021,7 @@ static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
9971021 const int ntb_lut_idx = 1 ;
9981022 u64 bar_addrs [6 ];
9991023 u64 addr ;
1024+ int offset ;
10001025 int bar_cnt ;
10011026
10021027 if (!crosslink_is_enabled (sndev ))
@@ -1011,7 +1036,13 @@ static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
10111036 return - EINVAL ;
10121037 }
10131038
1014- addr = bar_addrs [0 ];
1039+ addr = (bar_addrs [0 ] + SWITCHTEC_GAS_NTB_OFFSET +
1040+ SWITCHTEC_NTB_REG_DBMSG_OFFSET +
1041+ sizeof (struct ntb_dbmsg_regs ) * sndev -> peer_partition );
1042+
1043+ offset = addr & (LUT_SIZE - 1 );
1044+ addr -= offset ;
1045+
10151046 rc = config_rsvd_lut_win (sndev , sndev -> mmio_self_ctrl , ntb_lut_idx ,
10161047 sndev -> peer_partition , addr );
10171048 if (rc )
@@ -1033,8 +1064,11 @@ static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
10331064 return rc ;
10341065 }
10351066
1067+ sndev -> mmio_peer_dbmsg = sndev -> mmio_xlink_win + offset ;
10361068 sndev -> nr_rsvd_luts ++ ;
10371069
1070+ crosslink_init_dbmsgs (sndev );
1071+
10381072 return 0 ;
10391073}
10401074
@@ -1087,24 +1121,35 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev)
10871121 * shared among all partitions. So we must split them in half
10881122 * (32 for each partition). However, the message interrupts are
10891123 * also shared with the top 4 doorbells so we just limit this to
1090- * 28 doorbells per partition
1124+ * 28 doorbells per partition.
1125+ *
1126+ * In crosslink mode, each side has it's own dbmsg register so
1127+ * they can each use all 60 of the available doorbells.
10911128 */
10921129static void switchtec_ntb_init_db (struct switchtec_ntb * sndev )
10931130{
1094- sndev -> db_valid_mask = 0x0FFFFFFF ;
1131+ sndev -> db_mask = 0x0FFFFFFFFFFFFFFFULL ;
10951132
1096- if (sndev -> self_partition < sndev -> peer_partition ) {
1133+ if (sndev -> mmio_peer_dbmsg != sndev -> mmio_self_dbmsg ) {
1134+ sndev -> db_shift = 0 ;
1135+ sndev -> db_peer_shift = 0 ;
1136+ sndev -> db_valid_mask = sndev -> db_mask ;
1137+ } else if (sndev -> self_partition < sndev -> peer_partition ) {
10971138 sndev -> db_shift = 0 ;
10981139 sndev -> db_peer_shift = 32 ;
1140+ sndev -> db_valid_mask = 0x0FFFFFFF ;
10991141 } else {
11001142 sndev -> db_shift = 32 ;
11011143 sndev -> db_peer_shift = 0 ;
1144+ sndev -> db_valid_mask = 0x0FFFFFFF ;
11021145 }
11031146
1104- sndev -> db_mask = 0x0FFFFFFFFFFFFFFFULL ;
11051147 iowrite64 (~sndev -> db_mask , & sndev -> mmio_self_dbmsg -> idb_mask );
11061148 iowrite64 (sndev -> db_valid_mask << sndev -> db_peer_shift ,
1107- & sndev -> mmio_self_dbmsg -> odb_mask );
1149+ & sndev -> mmio_peer_dbmsg -> odb_mask );
1150+
1151+ dev_dbg (& sndev -> stdev -> dev , "dbs: shift %d/%d, mask %016llx\n" ,
1152+ sndev -> db_shift , sndev -> db_peer_shift , sndev -> db_valid_mask );
11081153}
11091154
11101155static void switchtec_ntb_init_msgs (struct switchtec_ntb * sndev )
0 commit comments