cxgbe tom: Restore support for zerocopy TCP receive for aio_read()

The commit to introduce TCP_USE_DDP support had a couple of bugs that
broke support for zerocopy receive via aio_read().  First, the length
and offset arguments to mk_update_tcb_for_ddp() were reversed which
prevented DDP from working.  Second, the AIO state in the toep was
initialized too late when the first aio_read() request was queued.

Reported by:	Harshavardhan Tanneru @ Chelsio
Fixes:		eba13bbc37ab cxgbe: Support TCP_USE_DDP on offloaded TOE connections
MFC after:	1 week
Sponsored by:	Chelsio Communications

(cherry picked from commit 70693a45381b687e40ea30710aa38cb9f24b6b02)
This commit is contained in:
John Baldwin 2024-12-10 18:13:51 -08:00
parent 18a9da18ad
commit 1e87d76855

View file

@ -2653,8 +2653,8 @@ sbcopy:
* which will keep it open and keep the TCP PCB attached until
* after the job is completed.
*/
wr = mk_update_tcb_for_ddp(sc, toep, db_idx, &ps->prsv, ps->len,
job->aio_received, ddp_flags, ddp_flags_mask);
wr = mk_update_tcb_for_ddp(sc, toep, db_idx, &ps->prsv,
job->aio_received, ps->len, ddp_flags, ddp_flags_mask);
if (wr == NULL) {
recycle_pageset(toep, ps);
aio_ddp_requeue_one(toep, job);
@ -2820,6 +2820,14 @@ t4_aio_queue_ddp(struct socket *so, struct kaiocb *job)
return (EOPNOTSUPP);
}
if ((toep->ddp.flags & DDP_AIO) == 0) {
toep->ddp.flags |= DDP_AIO;
TAILQ_INIT(&toep->ddp.cached_pagesets);
TAILQ_INIT(&toep->ddp.aiojobq);
TASK_INIT(&toep->ddp.requeue_task, 0, aio_ddp_requeue_task,
toep);
}
/*
* XXX: Think about possibly returning errors for ENOTCONN,
* etc. Perhaps the caller would only queue the request
@ -2834,14 +2842,6 @@ t4_aio_queue_ddp(struct socket *so, struct kaiocb *job)
TAILQ_INSERT_TAIL(&toep->ddp.aiojobq, job, list);
toep->ddp.waiting_count++;
if ((toep->ddp.flags & DDP_AIO) == 0) {
toep->ddp.flags |= DDP_AIO;
TAILQ_INIT(&toep->ddp.cached_pagesets);
TAILQ_INIT(&toep->ddp.aiojobq);
TASK_INIT(&toep->ddp.requeue_task, 0, aio_ddp_requeue_task,
toep);
}
/*
* Try to handle this request synchronously. If this has
* to block because the task is running, it will just bail