aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ntb/ntb_transport.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2016-07-29 21:03:30 +0000
committerAlexander Motin <mav@FreeBSD.org>2016-07-29 21:03:30 +0000
commit718e8abba90d94294e3e5a5cdc37caa7180b9474 (patch)
treee90f29e17672fc5476a0cf44187b31791936a380 /sys/dev/ntb/ntb_transport.c
parentadaf3c49064c49a5955d8c46eee31d86ca14de6c (diff)
downloadsrc-718e8abba90d94294e3e5a5cdc37caa7180b9474.tar.gz
src-718e8abba90d94294e3e5a5cdc37caa7180b9474.zip
Fix NTBT_QP_LINKS negotiation.
I believe it never worked correctly for more the one queue even in Linux. This fixes case when one of consumer drivers is not loaded on one side, but its queues still announced as ready if something else brought link up. While there, remove some pointless NULL checks.
Notes
Notes: svn path=/head/; revision=303514
Diffstat (limited to 'sys/dev/ntb/ntb_transport.c')
-rw-r--r--sys/dev/ntb/ntb_transport.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/sys/dev/ntb/ntb_transport.c b/sys/dev/ntb/ntb_transport.c
index c4b8fd0dc916..c7bc4da2c388 100644
--- a/sys/dev/ntb/ntb_transport.c
+++ b/sys/dev/ntb/ntb_transport.c
@@ -572,9 +572,6 @@ ntb_transport_free_queue(struct ntb_transport_qp *qp)
struct ntb_transport_ctx *nt = qp->transport;
struct ntb_queue_entry *entry;
- if (qp == NULL)
- return;
-
callout_drain(&qp->link_work);
ntb_db_set_mask(qp->dev, 1ull << qp->qp_num);
@@ -694,7 +691,7 @@ ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
struct ntb_queue_entry *entry;
int rc;
- if (qp == NULL || !qp->link_is_up || len == 0) {
+ if (!qp->link_is_up || len == 0) {
CTR0(KTR_NTB, "TX: link not up");
return (EINVAL);
}
@@ -1059,11 +1056,9 @@ ntb_transport_link_work(void *arg)
size >> 32);
ntb_peer_spad_write(dev, NTBT_MW0_SZ_LOW + (i * 2), size);
}
-
ntb_peer_spad_write(dev, NTBT_NUM_MWS, nt->mw_count);
-
ntb_peer_spad_write(dev, NTBT_NUM_QPS, nt->qp_count);
-
+ ntb_peer_spad_write(dev, NTBT_QP_LINKS, 0);
ntb_peer_spad_write(dev, NTBT_VERSION, NTB_TRANSPORT_VERSION);
/* Query the remote side for its info */
@@ -1245,16 +1240,18 @@ ntb_qp_link_work(void *arg)
struct ntb_transport_qp *qp = arg;
device_t dev = qp->dev;
struct ntb_transport_ctx *nt = qp->transport;
- uint32_t val, dummy;
-
- ntb_spad_read(dev, NTBT_QP_LINKS, &val);
-
- ntb_peer_spad_write(dev, NTBT_QP_LINKS, val | (1ull << qp->qp_num));
+ int i;
+ uint32_t val;
- /* query remote spad for qp ready bits */
- ntb_peer_spad_read(dev, NTBT_QP_LINKS, &dummy);
+ /* Report queues that are up on our side */
+ for (i = 0, val = 0; i < nt->qp_count; i++) {
+ if (nt->qp_vec[i].client_ready)
+ val |= (1 << i);
+ }
+ ntb_peer_spad_write(dev, NTBT_QP_LINKS, val);
/* See if the remote side is up */
+ ntb_spad_read(dev, NTBT_QP_LINKS, &val);
if ((val & (1ull << qp->qp_num)) != 0) {
ntb_printf(2, "qp %d link up\n", qp->qp_num);
qp->link_is_up = true;
@@ -1350,17 +1347,16 @@ ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
void
ntb_transport_link_down(struct ntb_transport_qp *qp)
{
+ struct ntb_transport_ctx *nt = qp->transport;
+ int i;
uint32_t val;
- if (qp == NULL)
- return;
-
qp->client_ready = false;
-
- ntb_spad_read(qp->dev, NTBT_QP_LINKS, &val);
-
- ntb_peer_spad_write(qp->dev, NTBT_QP_LINKS,
- val & ~(1 << qp->qp_num));
+ for (i = 0, val = 0; i < nt->qp_count; i++) {
+ if (nt->qp_vec[i].client_ready)
+ val |= (1 << i);
+ }
+ ntb_peer_spad_write(qp->dev, NTBT_QP_LINKS, val);
if (qp->link_is_up)
ntb_send_link_down(qp);
@@ -1379,8 +1375,6 @@ ntb_transport_link_down(struct ntb_transport_qp *qp)
bool
ntb_transport_link_query(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return (false);
return (qp->link_is_up);
}
@@ -1479,8 +1473,6 @@ out:
*/
unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return 0;
return (qp->qp_num);
}
@@ -1497,9 +1489,6 @@ unsigned int
ntb_transport_max_size(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return (0);
-
return (qp->tx_max_frame - sizeof(struct ntb_payload_header));
}