aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ntb/hw/idt/ntb_hw_idt.c27
-rw-r--r--include/linux/ntb.h34
2 files changed, 28 insertions, 33 deletions
diff --git a/drivers/ntb/hw/idt/ntb_hw_idt.c b/drivers/ntb/hw/idt/ntb_hw_idt.c
index 0cd79f367f7c..24040317bb9c 100644
--- a/drivers/ntb/hw/idt/ntb_hw_idt.c
+++ b/drivers/ntb/hw/idt/ntb_hw_idt.c
@@ -1744,20 +1744,19 @@ static int idt_ntb_msg_clear_mask(struct ntb_dev *ntb, u64 mask_bits)
1744 * idt_ntb_msg_read() - read message register with specified index 1744 * idt_ntb_msg_read() - read message register with specified index
1745 * (NTB API callback) 1745 * (NTB API callback)
1746 * @ntb: NTB device context. 1746 * @ntb: NTB device context.
1747 * @midx: Message register index
1748 * @pidx: OUT - Port index of peer device a message retrieved from 1747 * @pidx: OUT - Port index of peer device a message retrieved from
1749 * @msg: OUT - Data 1748 * @midx: Message register index
1750 * 1749 *
1751 * Read data from the specified message register and source register. 1750 * Read data from the specified message register and source register.
1752 * 1751 *
1753 * Return: zero on success, negative error if invalid argument passed. 1752 * Return: inbound message register value.
1754 */ 1753 */
1755static int idt_ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg) 1754static u32 idt_ntb_msg_read(struct ntb_dev *ntb, int *pidx, int midx)
1756{ 1755{
1757 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb); 1756 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb);
1758 1757
1759 if (midx < 0 || IDT_MSG_CNT <= midx) 1758 if (midx < 0 || IDT_MSG_CNT <= midx)
1760 return -EINVAL; 1759 return ~(u32)0;
1761 1760
1762 /* Retrieve source port index of the message */ 1761 /* Retrieve source port index of the message */
1763 if (pidx != NULL) { 1762 if (pidx != NULL) {
@@ -1772,18 +1771,15 @@ static int idt_ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg)
1772 } 1771 }
1773 1772
1774 /* Retrieve data of the corresponding message register */ 1773 /* Retrieve data of the corresponding message register */
1775 if (msg != NULL) 1774 return idt_nt_read(ndev, ntdata_tbl.msgs[midx].in);
1776 *msg = idt_nt_read(ndev, ntdata_tbl.msgs[midx].in);
1777
1778 return 0;
1779} 1775}
1780 1776
1781/* 1777/*
1782 * idt_ntb_msg_write() - write data to the specified message register 1778 * idt_ntb_peer_msg_write() - write data to the specified message register
1783 * (NTB API callback) 1779 * (NTB API callback)
1784 * @ntb: NTB device context. 1780 * @ntb: NTB device context.
1785 * @midx: Message register index
1786 * @pidx: Port index of peer device a message being sent to 1781 * @pidx: Port index of peer device a message being sent to
1782 * @midx: Message register index
1787 * @msg: Data to send 1783 * @msg: Data to send
1788 * 1784 *
1789 * Just try to send data to a peer. Message status register should be 1785 * Just try to send data to a peer. Message status register should be
@@ -1791,7 +1787,8 @@ static int idt_ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg)
1791 * 1787 *
1792 * Return: zero on success, negative error if invalid argument passed. 1788 * Return: zero on success, negative error if invalid argument passed.
1793 */ 1789 */
1794static int idt_ntb_msg_write(struct ntb_dev *ntb, int midx, int pidx, u32 msg) 1790static int idt_ntb_peer_msg_write(struct ntb_dev *ntb, int pidx, int midx,
1791 u32 msg)
1795{ 1792{
1796 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb); 1793 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb);
1797 unsigned long irqflags; 1794 unsigned long irqflags;
@@ -2058,7 +2055,7 @@ static const struct ntb_dev_ops idt_ntb_ops = {
2058 .msg_set_mask = idt_ntb_msg_set_mask, 2055 .msg_set_mask = idt_ntb_msg_set_mask,
2059 .msg_clear_mask = idt_ntb_msg_clear_mask, 2056 .msg_clear_mask = idt_ntb_msg_clear_mask,
2060 .msg_read = idt_ntb_msg_read, 2057 .msg_read = idt_ntb_msg_read,
2061 .msg_write = idt_ntb_msg_write 2058 .peer_msg_write = idt_ntb_peer_msg_write
2062}; 2059};
2063 2060
2064/* 2061/*
@@ -2269,7 +2266,7 @@ static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf,
2269 "Message data:\n"); 2266 "Message data:\n");
2270 for (idx = 0; idx < IDT_MSG_CNT; idx++) { 2267 for (idx = 0; idx < IDT_MSG_CNT; idx++) {
2271 int src; 2268 int src;
2272 (void)idt_ntb_msg_read(&ndev->ntb, idx, &src, &data); 2269 data = idt_ntb_msg_read(&ndev->ntb, &src, idx);
2273 off += scnprintf(strbuf + off, size - off, 2270 off += scnprintf(strbuf + off, size - off,
2274 "\t%hhu. 0x%08x from peer %hhu (Port %hhu)\n", 2271 "\t%hhu. 0x%08x from peer %hhu (Port %hhu)\n",
2275 idx, data, src, ndev->peers[src].port); 2272 idx, data, src, ndev->peers[src].port);
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index ea3be7275a5e..21b1826a0953 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -253,7 +253,7 @@ static inline int ntb_ctx_ops_is_valid(const struct ntb_ctx_ops *ops)
253 * @msg_set_mask: See ntb_msg_set_mask(). 253 * @msg_set_mask: See ntb_msg_set_mask().
254 * @msg_clear_mask: See ntb_msg_clear_mask(). 254 * @msg_clear_mask: See ntb_msg_clear_mask().
255 * @msg_read: See ntb_msg_read(). 255 * @msg_read: See ntb_msg_read().
256 * @msg_write: See ntb_msg_write(). 256 * @peer_msg_write: See ntb_peer_msg_write().
257 */ 257 */
258struct ntb_dev_ops { 258struct ntb_dev_ops {
259 int (*port_number)(struct ntb_dev *ntb); 259 int (*port_number)(struct ntb_dev *ntb);
@@ -324,8 +324,8 @@ struct ntb_dev_ops {
324 int (*msg_clear_sts)(struct ntb_dev *ntb, u64 sts_bits); 324 int (*msg_clear_sts)(struct ntb_dev *ntb, u64 sts_bits);
325 int (*msg_set_mask)(struct ntb_dev *ntb, u64 mask_bits); 325 int (*msg_set_mask)(struct ntb_dev *ntb, u64 mask_bits);
326 int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits); 326 int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits);
327 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);
328 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);
329}; 329};
330 330
331static 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)
@@ -387,7 +387,7 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
387 /* !ops->msg_set_mask == !ops->msg_count && */ 387 /* !ops->msg_set_mask == !ops->msg_count && */
388 /* !ops->msg_clear_mask == !ops->msg_count && */ 388 /* !ops->msg_clear_mask == !ops->msg_count && */
389 !ops->msg_read == !ops->msg_count && 389 !ops->msg_read == !ops->msg_count &&
390 !ops->msg_write == !ops->msg_count && 390 !ops->peer_msg_write == !ops->msg_count &&
391 1; 391 1;
392} 392}
393 393
@@ -1462,31 +1462,29 @@ static inline int ntb_msg_clear_mask(struct ntb_dev *ntb, u64 mask_bits)
1462} 1462}
1463 1463
1464/** 1464/**
1465 * ntb_msg_read() - read message register with specified index 1465 * ntb_msg_read() - read inbound message register with specified index
1466 * @ntb: NTB device context. 1466 * @ntb: NTB device context.
1467 * @midx: Message register index
1468 * @pidx: OUT - Port index of peer device a message retrieved from 1467 * @pidx: OUT - Port index of peer device a message retrieved from
1469 * @msg: OUT - Data 1468 * @midx: Message register index
1470 * 1469 *
1471 * 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
1472 * message is retrieved as well. 1471 * message is retrieved as well.
1473 * 1472 *
1474 * Return: Zero on success, otherwise a negative error number. 1473 * Return: The value of the inbound message register.
1475 */ 1474 */
1476static 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)
1477 u32 *msg)
1478{ 1476{
1479 if (!ntb->ops->msg_read) 1477 if (!ntb->ops->msg_read)
1480 return -EINVAL; 1478 return ~(u32)0;
1481 1479
1482 return ntb->ops->msg_read(ntb, midx, pidx, msg); 1480 return ntb->ops->msg_read(ntb, pidx, midx);
1483} 1481}
1484 1482
1485/** 1483/**
1486 * ntb_msg_write() - write data to the specified message register 1484 * ntb_peer_msg_write() - write data to the specified peer message register
1487 * @ntb: NTB device context. 1485 * @ntb: NTB device context.
1488 * @midx: Message register index
1489 * @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
1490 * @msg: Data to send 1488 * @msg: Data to send
1491 * 1489 *
1492 * 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.
@@ -1495,13 +1493,13 @@ static inline int ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx,
1495 * 1493 *
1496 * Return: Zero on success, otherwise a negative error number. 1494 * Return: Zero on success, otherwise a negative error number.
1497 */ 1495 */
1498static 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,
1499 u32 msg) 1497 u32 msg)
1500{ 1498{
1501 if (!ntb->ops->msg_write) 1499 if (!ntb->ops->peer_msg_write)
1502 return -EINVAL; 1500 return -EINVAL;
1503 1501
1504 return ntb->ops->msg_write(ntb, midx, pidx, msg); 1502 return ntb->ops->peer_msg_write(ntb, pidx, midx, msg);
1505} 1503}
1506 1504
1507#endif 1505#endif