summaryrefslogtreecommitdiff
path: root/drivers/infiniband/sw/rxe
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/sw/rxe')
-rw-r--r--drivers/infiniband/sw/rxe/rxe_resp.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index c32bc12cc82f..382d2053db43 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -393,16 +393,36 @@ static enum resp_states check_resource(struct rxe_qp *qp,
static enum resp_states check_length(struct rxe_qp *qp,
struct rxe_pkt_info *pkt)
{
- switch (qp_type(qp)) {
- case IB_QPT_RC:
- return RESPST_CHK_RKEY;
+ int mtu = qp->mtu;
+ u32 payload = payload_size(pkt);
+ u32 dmalen = reth_len(pkt);
- case IB_QPT_UC:
- return RESPST_CHK_RKEY;
+ /* RoCEv2 packets do not have LRH.
+ * Let's skip checking it.
+ */
- default:
- return RESPST_CHK_RKEY;
+ if ((pkt->opcode & RXE_START_MASK) &&
+ (pkt->opcode & RXE_END_MASK)) {
+ /* "only" packets */
+ if (payload > mtu)
+ return RESPST_ERR_LENGTH;
+ } else if ((pkt->opcode & RXE_START_MASK) ||
+ (pkt->opcode & RXE_MIDDLE_MASK)) {
+ /* "first" or "middle" packets */
+ if (payload != mtu)
+ return RESPST_ERR_LENGTH;
+ } else if (pkt->opcode & RXE_END_MASK) {
+ /* "last" packets */
+ if ((payload == 0) || (payload > mtu))
+ return RESPST_ERR_LENGTH;
+ }
+
+ if (pkt->opcode & (RXE_WRITE_MASK | RXE_READ_MASK)) {
+ if (dmalen > (1 << 31))
+ return RESPST_ERR_LENGTH;
}
+
+ return RESPST_CHK_RKEY;
}
static enum resp_states check_rkey(struct rxe_qp *qp,