aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ntb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ntb.h')
-rw-r--r--include/linux/ntb.h51
1 files changed, 26 insertions, 25 deletions
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index c308964777eb..181d16601dd9 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -71,6 +71,7 @@ struct pci_dev;
71 * @NTB_TOPO_B2B_USD: On primary side of local ntb upstream of remote ntb. 71 * @NTB_TOPO_B2B_USD: On primary side of local ntb upstream of remote ntb.
72 * @NTB_TOPO_B2B_DSD: On primary side of local ntb downstream of remote ntb. 72 * @NTB_TOPO_B2B_DSD: On primary side of local ntb downstream of remote ntb.
73 * @NTB_TOPO_SWITCH: Connected via a switch which supports ntb. 73 * @NTB_TOPO_SWITCH: Connected via a switch which supports ntb.
74 * @NTB_TOPO_CROSSLINK: Connected via two symmetric switchecs
74 */ 75 */
75enum ntb_topo { 76enum ntb_topo {
76 NTB_TOPO_NONE = -1, 77 NTB_TOPO_NONE = -1,
@@ -79,6 +80,7 @@ enum ntb_topo {
79 NTB_TOPO_B2B_USD, 80 NTB_TOPO_B2B_USD,
80 NTB_TOPO_B2B_DSD, 81 NTB_TOPO_B2B_DSD,
81 NTB_TOPO_SWITCH, 82 NTB_TOPO_SWITCH,
83 NTB_TOPO_CROSSLINK,
82}; 84};
83 85
84static inline int ntb_topo_is_b2b(enum ntb_topo topo) 86static inline int ntb_topo_is_b2b(enum ntb_topo topo)
@@ -94,12 +96,13 @@ static inline int ntb_topo_is_b2b(enum ntb_topo topo)
94static inline char *ntb_topo_string(enum ntb_topo topo) 96static inline char *ntb_topo_string(enum ntb_topo topo)
95{ 97{
96 switch (topo) { 98 switch (topo) {
97 case NTB_TOPO_NONE: return "NTB_TOPO_NONE"; 99 case NTB_TOPO_NONE: return "NTB_TOPO_NONE";
98 case NTB_TOPO_PRI: return "NTB_TOPO_PRI"; 100 case NTB_TOPO_PRI: return "NTB_TOPO_PRI";
99 case NTB_TOPO_SEC: return "NTB_TOPO_SEC"; 101 case NTB_TOPO_SEC: return "NTB_TOPO_SEC";
100 case NTB_TOPO_B2B_USD: return "NTB_TOPO_B2B_USD"; 102 case NTB_TOPO_B2B_USD: return "NTB_TOPO_B2B_USD";
101 case NTB_TOPO_B2B_DSD: return "NTB_TOPO_B2B_DSD"; 103 case NTB_TOPO_B2B_DSD: return "NTB_TOPO_B2B_DSD";
102 case NTB_TOPO_SWITCH: return "NTB_TOPO_SWITCH"; 104 case NTB_TOPO_SWITCH: return "NTB_TOPO_SWITCH";
105 case NTB_TOPO_CROSSLINK: return "NTB_TOPO_CROSSLINK";
103 } 106 }
104 return "NTB_TOPO_INVALID"; 107 return "NTB_TOPO_INVALID";
105} 108}
@@ -250,7 +253,7 @@ static inline int ntb_ctx_ops_is_valid(const struct ntb_ctx_ops *ops)
250 * @msg_set_mask: See ntb_msg_set_mask(). 253 * @msg_set_mask: See ntb_msg_set_mask().
251 * @msg_clear_mask: See ntb_msg_clear_mask(). 254 * @msg_clear_mask: See ntb_msg_clear_mask().
252 * @msg_read: See ntb_msg_read(). 255 * @msg_read: See ntb_msg_read().
253 * @msg_write: See ntb_msg_write(). 256 * @peer_msg_write: See ntb_peer_msg_write().
254 */ 257 */
255struct ntb_dev_ops { 258struct ntb_dev_ops {
256 int (*port_number)(struct ntb_dev *ntb); 259 int (*port_number)(struct ntb_dev *ntb);
@@ -321,8 +324,8 @@ struct ntb_dev_ops {
321 int (*msg_clear_sts)(struct ntb_dev *ntb, u64 sts_bits); 324 int (*msg_clear_sts)(struct ntb_dev *ntb, u64 sts_bits);
322 int (*msg_set_mask)(struct ntb_dev *ntb, u64 mask_bits); 325 int (*msg_set_mask)(struct ntb_dev *ntb, u64 mask_bits);
323 int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits); 326 int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits);
324 int (*msg_read)(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg); 327 u32 (*msg_read)(struct ntb_dev *ntb, int *pidx, int midx);
325 int (*msg_write)(struct ntb_dev *ntb, int midx, int pidx, u32 msg); 328 int (*peer_msg_write)(struct ntb_dev *ntb, int pidx, int midx, u32 msg);
326}; 329};
327 330
328static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops) 331static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
@@ -384,7 +387,7 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
384 /* !ops->msg_set_mask == !ops->msg_count && */ 387 /* !ops->msg_set_mask == !ops->msg_count && */
385 /* !ops->msg_clear_mask == !ops->msg_count && */ 388 /* !ops->msg_clear_mask == !ops->msg_count && */
386 !ops->msg_read == !ops->msg_count && 389 !ops->msg_read == !ops->msg_count &&
387 !ops->msg_write == !ops->msg_count && 390 !ops->peer_msg_write == !ops->msg_count &&
388 1; 391 1;
389} 392}
390 393
@@ -764,7 +767,7 @@ static inline int ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int widx,
764 resource_size_t *size_align, 767 resource_size_t *size_align,
765 resource_size_t *size_max) 768 resource_size_t *size_max)
766{ 769{
767 if (!(ntb_link_is_up(ntb, NULL, NULL) & (1 << pidx))) 770 if (!(ntb_link_is_up(ntb, NULL, NULL) & BIT_ULL(pidx)))
768 return -ENOTCONN; 771 return -ENOTCONN;
769 772
770 return ntb->ops->mw_get_align(ntb, pidx, widx, addr_align, size_align, 773 return ntb->ops->mw_get_align(ntb, pidx, widx, addr_align, size_align,
@@ -1459,31 +1462,29 @@ static inline int ntb_msg_clear_mask(struct ntb_dev *ntb, u64 mask_bits)
1459} 1462}
1460 1463
1461/** 1464/**
1462 * ntb_msg_read() - read message register with specified index 1465 * ntb_msg_read() - read inbound message register with specified index
1463 * @ntb: NTB device context. 1466 * @ntb: NTB device context.
1464 * @midx: Message register index
1465 * @pidx: OUT - Port index of peer device a message retrieved from 1467 * @pidx: OUT - Port index of peer device a message retrieved from
1466 * @msg: OUT - Data 1468 * @midx: Message register index
1467 * 1469 *
1468 * Read data from the specified message register. Source port index of a 1470 * Read data from the specified message register. Source port index of a
1469 * message is retrieved as well. 1471 * message is retrieved as well.
1470 * 1472 *
1471 * Return: Zero on success, otherwise a negative error number. 1473 * Return: The value of the inbound message register.
1472 */ 1474 */
1473static inline int ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, 1475static inline u32 ntb_msg_read(struct ntb_dev *ntb, int *pidx, int midx)
1474 u32 *msg)
1475{ 1476{
1476 if (!ntb->ops->msg_read) 1477 if (!ntb->ops->msg_read)
1477 return -EINVAL; 1478 return ~(u32)0;
1478 1479
1479 return ntb->ops->msg_read(ntb, midx, pidx, msg); 1480 return ntb->ops->msg_read(ntb, pidx, midx);
1480} 1481}
1481 1482
1482/** 1483/**
1483 * ntb_msg_write() - write data to the specified message register 1484 * ntb_peer_msg_write() - write data to the specified peer message register
1484 * @ntb: NTB device context. 1485 * @ntb: NTB device context.
1485 * @midx: Message register index
1486 * @pidx: Port index of peer device a message being sent to 1486 * @pidx: Port index of peer device a message being sent to
1487 * @midx: Message register index
1487 * @msg: Data to send 1488 * @msg: Data to send
1488 * 1489 *
1489 * Send data to a specified peer device using the defined message register. 1490 * Send data to a specified peer device using the defined message register.
@@ -1492,13 +1493,13 @@ static inline int ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx,
1492 * 1493 *
1493 * Return: Zero on success, otherwise a negative error number. 1494 * Return: Zero on success, otherwise a negative error number.
1494 */ 1495 */
1495static inline int ntb_msg_write(struct ntb_dev *ntb, int midx, int pidx, 1496static inline int ntb_peer_msg_write(struct ntb_dev *ntb, int pidx, int midx,
1496 u32 msg) 1497 u32 msg)
1497{ 1498{
1498 if (!ntb->ops->msg_write) 1499 if (!ntb->ops->peer_msg_write)
1499 return -EINVAL; 1500 return -EINVAL;
1500 1501
1501 return ntb->ops->msg_write(ntb, midx, pidx, msg); 1502 return ntb->ops->peer_msg_write(ntb, pidx, midx, msg);
1502} 1503}
1503 1504
1504#endif 1505#endif