Merge from projects/sendfile: extend protocols API to support
sending not ready data: o Add new flag to pru_send() flags - PRUS_NOTREADY. o Add new protocol method pru_ready(). Sponsored by: Nginx, Inc. Sponsored by: Netflix
This commit is contained in:
parent
dcf58f92e2
commit
651e4e6a30
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275329
@ -1199,7 +1199,7 @@ do_rx_data(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m)
|
||||
}
|
||||
|
||||
toep->tp_enqueued += m->m_pkthdr.len;
|
||||
sbappendstream_locked(so_rcv, m);
|
||||
sbappendstream_locked(so_rcv, m, 0);
|
||||
sorwakeup_locked(so);
|
||||
SOCKBUF_UNLOCK_ASSERT(so_rcv);
|
||||
|
||||
|
@ -1086,7 +1086,7 @@ do_peer_close(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
|
||||
#ifdef USE_DDP_RX_FLOW_CONTROL
|
||||
toep->rx_credits -= m->m_len; /* adjust for F_RX_FC_DDP */
|
||||
#endif
|
||||
sbappendstream_locked(sb, m);
|
||||
sbappendstream_locked(sb, m, 0);
|
||||
toep->sb_cc = sbused(sb);
|
||||
}
|
||||
socantrcvmore_locked(so); /* unlocks the sockbuf */
|
||||
@ -1586,7 +1586,7 @@ do_rx_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
|
||||
("%s: sb %p has more data (%d) than last time (%d).",
|
||||
__func__, sb, sbused(sb), toep->sb_cc));
|
||||
toep->rx_credits += toep->sb_cc - sbused(sb);
|
||||
sbappendstream_locked(sb, m);
|
||||
sbappendstream_locked(sb, m, 0);
|
||||
toep->sb_cc = sbused(sb);
|
||||
sorwakeup_locked(so);
|
||||
SOCKBUF_UNLOCK_ASSERT(sb);
|
||||
|
@ -231,7 +231,7 @@ insert_ddp_data(struct toepcb *toep, uint32_t n)
|
||||
#ifdef USE_DDP_RX_FLOW_CONTROL
|
||||
toep->rx_credits -= n; /* adjust for F_RX_FC_DDP */
|
||||
#endif
|
||||
sbappendstream_locked(sb, m);
|
||||
sbappendstream_locked(sb, m, 0);
|
||||
toep->sb_cc = sbused(sb);
|
||||
}
|
||||
|
||||
@ -466,7 +466,7 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report, __be32 rcv_nxt, int len)
|
||||
#ifdef USE_DDP_RX_FLOW_CONTROL
|
||||
toep->rx_credits -= len; /* adjust for F_RX_FC_DDP */
|
||||
#endif
|
||||
sbappendstream_locked(sb, m);
|
||||
sbappendstream_locked(sb, m, 0);
|
||||
toep->sb_cc = sbused(sb);
|
||||
wakeup:
|
||||
KASSERT(toep->ddp_flags & db_flag,
|
||||
|
@ -152,6 +152,7 @@ protosw_init(struct protosw *pr)
|
||||
DEFAULT(pu->pru_sosend, sosend_generic);
|
||||
DEFAULT(pu->pru_soreceive, soreceive_generic);
|
||||
DEFAULT(pu->pru_sopoll, sopoll_generic);
|
||||
DEFAULT(pu->pru_ready, pru_ready_notsupp);
|
||||
#undef DEFAULT
|
||||
if (pr->pr_init)
|
||||
(*pr->pr_init)();
|
||||
|
@ -388,7 +388,7 @@ mb_dupcl(struct mbuf *n, struct mbuf *m)
|
||||
* cleaned too.
|
||||
*/
|
||||
void
|
||||
m_demote(struct mbuf *m0, int all)
|
||||
m_demote(struct mbuf *m0, int all, int flags)
|
||||
{
|
||||
struct mbuf *m;
|
||||
|
||||
@ -400,7 +400,7 @@ m_demote(struct mbuf *m0, int all)
|
||||
m->m_flags &= ~M_PKTHDR;
|
||||
bzero(&m->m_pkthdr, sizeof(struct pkthdr));
|
||||
}
|
||||
m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE);
|
||||
m->m_flags = m->m_flags & (M_EXT | M_RDONLY | M_NOFREE | flags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -997,7 +997,7 @@ m_catpkt(struct mbuf *m, struct mbuf *n)
|
||||
M_ASSERTPKTHDR(n);
|
||||
|
||||
m->m_pkthdr.len += n->m_pkthdr.len;
|
||||
m_demote(n, 1);
|
||||
m_demote(n, 1, 0);
|
||||
|
||||
m_cat(m, n);
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ sbappend(struct sockbuf *sb, struct mbuf *m)
|
||||
* that is, a stream protocol (such as TCP).
|
||||
*/
|
||||
void
|
||||
sbappendstream_locked(struct sockbuf *sb, struct mbuf *m)
|
||||
sbappendstream_locked(struct sockbuf *sb, struct mbuf *m, int flags)
|
||||
{
|
||||
SOCKBUF_LOCK_ASSERT(sb);
|
||||
|
||||
@ -646,8 +646,8 @@ sbappendstream_locked(struct sockbuf *sb, struct mbuf *m)
|
||||
SBLASTMBUFCHK(sb);
|
||||
|
||||
/* Remove all packet headers and mbuf tags to get a pure data chain. */
|
||||
m_demote(m, 1);
|
||||
|
||||
m_demote(m, 1, flags & PRUS_NOTREADY ? M_NOTREADY : 0);
|
||||
|
||||
sbcompress(sb, m, sb->sb_mbtail);
|
||||
|
||||
sb->sb_lastrecord = sb->sb_mb;
|
||||
@ -660,11 +660,11 @@ sbappendstream_locked(struct sockbuf *sb, struct mbuf *m)
|
||||
* that is, a stream protocol (such as TCP).
|
||||
*/
|
||||
void
|
||||
sbappendstream(struct sockbuf *sb, struct mbuf *m)
|
||||
sbappendstream(struct sockbuf *sb, struct mbuf *m, int flags)
|
||||
{
|
||||
|
||||
SOCKBUF_LOCK(sb);
|
||||
sbappendstream_locked(sb, m);
|
||||
sbappendstream_locked(sb, m, flags);
|
||||
SOCKBUF_UNLOCK(sb);
|
||||
}
|
||||
|
||||
|
@ -3178,6 +3178,13 @@ pru_send_notsupp(struct socket *so, int flags, struct mbuf *m,
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int
|
||||
pru_ready_notsupp(struct socket *so, struct mbuf *m, int count)
|
||||
{
|
||||
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
* This isn't really a ``null'' operation, but it's the default one and
|
||||
* doesn't do anything destructive.
|
||||
|
@ -1855,7 +1855,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
newsize, so, NULL))
|
||||
so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
|
||||
m_adj(m, drop_hdrlen); /* delayed header drop */
|
||||
sbappendstream_locked(&so->so_rcv, m);
|
||||
sbappendstream_locked(&so->so_rcv, m, 0);
|
||||
}
|
||||
/* NB: sorwakeup_locked() does an implicit unlock. */
|
||||
sorwakeup_locked(so);
|
||||
@ -2882,7 +2882,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
|
||||
m_freem(m);
|
||||
else
|
||||
sbappendstream_locked(&so->so_rcv, m);
|
||||
sbappendstream_locked(&so->so_rcv, m, 0);
|
||||
/* NB: sorwakeup_locked() does an implicit unlock. */
|
||||
sorwakeup_locked(so);
|
||||
} else {
|
||||
|
@ -262,7 +262,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
|
||||
m_freem(mq);
|
||||
else {
|
||||
mq->m_nextpkt = NULL;
|
||||
sbappendstream_locked(&so->so_rcv, mq);
|
||||
sbappendstream_locked(&so->so_rcv, mq, 0);
|
||||
wakeup = 1;
|
||||
}
|
||||
}
|
||||
|
@ -843,7 +843,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
m_freem(control); /* empty control, just free it */
|
||||
}
|
||||
if (!(flags & PRUS_OOB)) {
|
||||
sbappendstream(&so->so_snd, m);
|
||||
sbappendstream(&so->so_snd, m, flags);
|
||||
if (nam && tp->t_state < TCPS_SYN_SENT) {
|
||||
/*
|
||||
* Do implied connect if not yet connected,
|
||||
@ -901,7 +901,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
* of data past the urgent section.
|
||||
* Otherwise, snd_up should be one lower.
|
||||
*/
|
||||
sbappendstream_locked(&so->so_snd, m);
|
||||
sbappendstream_locked(&so->so_snd, m, flags);
|
||||
SOCKBUF_UNLOCK(&so->so_snd);
|
||||
if (nam && tp->t_state < TCPS_SYN_SENT) {
|
||||
/*
|
||||
|
@ -889,7 +889,7 @@ sdp_append(struct sdp_sock *ssk, struct sockbuf *sb, struct mbuf *mb, int cnt)
|
||||
m_adj(mb, SDP_HEAD_SIZE);
|
||||
n->m_pkthdr.len += mb->m_pkthdr.len;
|
||||
n->m_flags |= mb->m_flags & (M_PUSH | M_URG);
|
||||
m_demote(mb, 1);
|
||||
m_demote(mb, 1, 0);
|
||||
sbcompress(sb, mb, sb->sb_mbtail);
|
||||
return;
|
||||
}
|
||||
|
@ -950,7 +950,7 @@ struct mbuf *m_copypacket(struct mbuf *, int);
|
||||
void m_copy_pkthdr(struct mbuf *, struct mbuf *);
|
||||
struct mbuf *m_copyup(struct mbuf *, int, int);
|
||||
struct mbuf *m_defrag(struct mbuf *, int);
|
||||
void m_demote(struct mbuf *, int);
|
||||
void m_demote(struct mbuf *, int, int);
|
||||
struct mbuf *m_devget(char *, int, int, struct ifnet *,
|
||||
void (*)(char *, caddr_t, u_int));
|
||||
struct mbuf *m_dup(struct mbuf *, int);
|
||||
|
@ -208,6 +208,8 @@ struct pr_usrreqs {
|
||||
#define PRUS_OOB 0x1
|
||||
#define PRUS_EOF 0x2
|
||||
#define PRUS_MORETOCOME 0x4
|
||||
#define PRUS_NOTREADY 0x8
|
||||
int (*pru_ready)(struct socket *so, struct mbuf *m, int count);
|
||||
int (*pru_sense)(struct socket *so, struct stat *sb);
|
||||
int (*pru_shutdown)(struct socket *so);
|
||||
int (*pru_flush)(struct socket *so, int direction);
|
||||
@ -251,6 +253,7 @@ int pru_rcvd_notsupp(struct socket *so, int flags);
|
||||
int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags);
|
||||
int pru_send_notsupp(struct socket *so, int flags, struct mbuf *m,
|
||||
struct sockaddr *addr, struct mbuf *control, struct thread *td);
|
||||
int pru_ready_notsupp(struct socket *so, struct mbuf *m, int count);
|
||||
int pru_sense_null(struct socket *so, struct stat *sb);
|
||||
int pru_shutdown_notsupp(struct socket *so);
|
||||
int pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam);
|
||||
|
@ -131,8 +131,8 @@ struct sockbuf {
|
||||
|
||||
void sbappend(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappendstream(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappendstream(struct sockbuf *sb, struct mbuf *m, int flags);
|
||||
void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m, int flags);
|
||||
int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
|
||||
struct mbuf *m0, struct mbuf *control);
|
||||
int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
|
||||
|
Loading…
Reference in New Issue
Block a user