diff options
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r-- | sys/kern/uipc_socket.c | 167 |
1 files changed, 0 insertions, 167 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 639d865..66af181 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -105,7 +105,6 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_zero.h" #include "opt_compat.h" #include <sys/param.h> @@ -221,21 +220,6 @@ static int numopensockets; SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD, &numopensockets, 0, "Number of open sockets"); -#if defined(SOCKET_SEND_COW) || defined(SOCKET_RECV_PFLIP) -SYSCTL_NODE(_kern_ipc, OID_AUTO, zero_copy, CTLFLAG_RD, 0, - "Zero copy controls"); -#ifdef SOCKET_RECV_PFLIP -int so_zero_copy_receive = 1; -SYSCTL_INT(_kern_ipc_zero_copy, OID_AUTO, receive, CTLFLAG_RW, - &so_zero_copy_receive, 0, "Enable zero copy receive"); -#endif -#ifdef SOCKET_SEND_COW -int so_zero_copy_send = 1; -SYSCTL_INT(_kern_ipc_zero_copy, OID_AUTO, send, CTLFLAG_RW, - &so_zero_copy_send, 0, "Enable zero copy send"); -#endif /* SOCKET_SEND_COW */ -#endif /* SOCKET_SEND_COW || SOCKET_RECV_PFLIP */ - /* * accept_mtx locks down per-socket fields relating to accept queues. See * socketvar.h for an annotation of the protected fields of struct socket. @@ -978,113 +962,6 @@ sodisconnect(struct socket *so) return (error); } -#ifdef SOCKET_SEND_COW -struct so_zerocopy_stats{ - int size_ok; - int align_ok; - int found_ifp; -}; -struct so_zerocopy_stats so_zerocp_stats = {0,0,0}; - -/* - * sosend_copyin() is only used if zero copy sockets are enabled. Otherwise - * sosend_dgram() and sosend_generic() use m_uiotombuf(). - * - * sosend_copyin() accepts a uio and prepares an mbuf chain holding part or - * all of the data referenced by the uio. If desired, it uses zero-copy. - * *space will be updated to reflect data copied in. - * - * NB: If atomic I/O is requested, the caller must already have checked that - * space can hold resid bytes. - * - * NB: In the event of an error, the caller may need to free the partial - * chain pointed to by *mpp. The contents of both *uio and *space may be - * modified even in the case of an error. - */ -static int -sosend_copyin(struct uio *uio, struct mbuf **retmp, int atomic, long *space, - int flags) -{ - struct mbuf *m, **mp, *top; - long len; - ssize_t resid; - int error; - int cow_send; - - *retmp = top = NULL; - mp = ⊤ - len = 0; - resid = uio->uio_resid; - error = 0; - do { - cow_send = 0; - if (resid >= MINCLSIZE) { - if (top == NULL) { - m = m_gethdr(M_WAITOK, MT_DATA); - m->m_pkthdr.len = 0; - m->m_pkthdr.rcvif = NULL; - } else - m = m_get(M_WAITOK, MT_DATA); - if (so_zero_copy_send && - resid >= PAGE_SIZE && - *space >= PAGE_SIZE && - uio->uio_iov->iov_len >= PAGE_SIZE) { - so_zerocp_stats.size_ok++; - so_zerocp_stats.align_ok++; - cow_send = socow_setup(m, uio); - len = cow_send; - } - if (!cow_send) { - m_clget(m, M_WAITOK); - len = min(min(MCLBYTES, resid), *space); - } - } else { - if (top == NULL) { - m = m_gethdr(M_WAITOK, MT_DATA); - m->m_pkthdr.len = 0; - m->m_pkthdr.rcvif = NULL; - - len = min(min(MHLEN, resid), *space); - /* - * For datagram protocols, leave room - * for protocol headers in first mbuf. - */ - if (atomic && m && len < MHLEN) - MH_ALIGN(m, len); - } else { - m = m_get(M_WAITOK, MT_DATA); - len = min(min(MLEN, resid), *space); - } - } - if (m == NULL) { - error = ENOBUFS; - goto out; - } - - *space -= len; - if (cow_send) - error = 0; - else - error = uiomove(mtod(m, void *), (int)len, uio); - resid = uio->uio_resid; - m->m_len = len; - *mp = m; - top->m_pkthdr.len += len; - if (error) - goto out; - mp = &m->m_next; - if (resid <= 0) { - if (flags & MSG_EOR) - top->m_flags |= M_EOR; - break; - } - } while (*space > 0 && atomic); -out: - *retmp = top; - return (error); -} -#endif /* SOCKET_SEND_COW */ - #define SBLOCKWAIT(f) (((f) & MSG_DONTWAIT) ? 0 : SBL_WAIT) int @@ -1094,9 +971,6 @@ sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio, long space; ssize_t resid; int clen = 0, error, dontroute; -#ifdef SOCKET_SEND_COW - int atomic = sosendallatonce(so) || top; -#endif KASSERT(so->so_type == SOCK_DGRAM, ("sosend_dgram: !SOCK_DGRAM")); KASSERT(so->so_proto->pr_flags & PR_ATOMIC, @@ -1179,11 +1053,6 @@ sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio, if (flags & MSG_EOR) top->m_flags |= M_EOR; } else { -#ifdef SOCKET_SEND_COW - error = sosend_copyin(uio, &top, atomic, &space, flags); - if (error) - goto out; -#else /* * Copy the data from userland into a mbuf chain. * If no data is to be copied in, a single empty mbuf @@ -1196,7 +1065,6 @@ sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio, goto out; } space -= resid - uio->uio_resid; -#endif /* SOCKET_SEND_COW */ resid = uio->uio_resid; } KASSERT(resid == 0, ("sosend_dgram: resid != 0")); @@ -1368,12 +1236,6 @@ restart: if (flags & MSG_EOR) top->m_flags |= M_EOR; } else { -#ifdef SOCKET_SEND_COW - error = sosend_copyin(uio, &top, atomic, - &space, flags); - if (error != 0) - goto release; -#else /* * Copy the data from userland into a mbuf * chain. If no data is to be copied in, @@ -1388,7 +1250,6 @@ restart: goto release; } space -= resid - uio->uio_resid; -#endif /* SOCKET_SEND_COW */ resid = uio->uio_resid; } if (dontroute) { @@ -1480,20 +1341,6 @@ soreceive_rcvoob(struct socket *so, struct uio *uio, int flags) if (error) goto bad; do { -#ifdef SOCKET_RECV_PFLIP - if (so_zero_copy_receive) { - int disposable; - - if ((m->m_flags & M_EXT) - && (m->m_ext.ext_type == EXT_DISPOSABLE)) - disposable = 1; - else - disposable = 0; - - error = uiomoveco(mtod(m, void *), - min(uio->uio_resid, m->m_len), uio, disposable); - } else -#endif /* SOCKET_RECV_PFLIP */ error = uiomove(mtod(m, void *), (int) min(uio->uio_resid, m->m_len), uio); m = m_free(m); @@ -1816,20 +1663,6 @@ dontblock: SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv); SOCKBUF_UNLOCK(&so->so_rcv); -#ifdef SOCKET_RECV_PFLIP - if (so_zero_copy_receive) { - int disposable; - - if ((m->m_flags & M_EXT) - && (m->m_ext.ext_type == EXT_DISPOSABLE)) - disposable = 1; - else - disposable = 0; - - error = uiomoveco(mtod(m, char *) + moff, - (int)len, uio, disposable); - } else -#endif /* SOCKET_RECV_PFLIP */ error = uiomove(mtod(m, char *) + moff, (int)len, uio); SOCKBUF_LOCK(&so->so_rcv); if (error) { |