rds_recv.c revision cadbfdc3bdb156e92d7a88978bc98ea87f6e037f
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Copyright (c) 2006 Oracle. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
void
{
inc->i_rdma_cookie = 0;
}
void
{
RDSV3_DPRINTF4("rdsv3_inc_addref",
}
void
{
}
}
/*ARGSUSED*/
static void
struct rdsv3_cong_map *map,
{
int now_congested;
RDSV3_DPRINTF4("rdsv3_recv_rcvbuf_delta",
"Enter(rs: %p, map: %p, delta: %d, port: %d)",
if (delta == 0)
return;
RDSV3_DPRINTF5("rdsv3_recv_rcvbuf_delta",
"rs %p (%u.%u.%u.%u:%u) recv bytes %d buf %d "
"now_cong %d delta %d",
/* wasn't -> am congested */
}
/* was -> aren't congested */
/*
* Require more free space before reporting uncongested to prevent
*/
else if (rs->rs_congested &&
rs->rs_congested = 0;
}
/* do nothing if no change in cong state */
}
/*
* Process all extension headers that come with this message.
*/
static void
{
union {
struct rdsv3_ext_header_version version;
struct rdsv3_ext_header_rdma rdma;
struct rdsv3_ext_header_rdma_dest rdma_dest;
} buffer;
while (1) {
if (type == RDSV3_EXTHDR_NONE)
break;
/* Process extension header here */
switch (type) {
case RDSV3_EXTHDR_RDMA:
0);
break;
case RDSV3_EXTHDR_RDMA_DEST:
/*
* We ignore the size for now. We could stash it
* somewhere and use it for error checking.
*/
break;
}
}
}
/*
* The transport must make sure that this is serialized against other
* rx and conn reset on this specific conn.
*
* We currently assert that only one fragmented message will be sent
* down a connection at a time. This lets us reassemble in the conn
* instead of per-flow which means that we don't have to go digging through
* flows to tear down partial reassembly progress on conn failure and
* we save flow lookup and locking for each frag arrival. It does mean
* that small messages will wait behind large ones. Fragmenting at all
* is only to reduce the memory consumption of pre-posted buffers.
*
* The caller passes in saddr and daddr instead of us getting it from the
* conn. This lets loopback, who only has one conn for both directions,
* tell us which roles the addrs in the conn are playing for this message.
*/
/* ARGSUSED */
void
{
RDSV3_DPRINTF5("rdsv3_recv_incoming",
"conn %p next %llu inc %p seq %llu len %u sport %u dport %u "
"flags 0x%x rx_jiffies %lu", conn,
(unsigned long long)conn->c_next_rx_seq,
inc,
inc->i_rx_jiffies);
/*
* Sequence numbers should only increase. Messages get their
* sequence number as they're queued in a sending conn. They
* can be dropped, though, if the sending socket is closed before
* they hit the wire. So sequence numbers can skip forward
* under normal operation. They can also drop back in the conn
* failover case as previously sent messages are resent down the
* new instance of a conn. We drop those, otherwise we have
* to assume that the next valid seq does not come after a
* hole in the fragment stream.
*
* The headers don't give us a way to realize if fragments of
* a message have been dropped. We assume that frags that arrive
* to a flow are part of the current message on the flow that is
* being reassembled. This means that senders can't drop messages
* from the sending conn until all their frags are sent.
*
* XXX we could spend more on the wire to get more robust failure
* detection, arguably worth it to avoid data corruption.
*/
goto out;
}
goto out;
}
goto out;
}
/* Process extension headers */
/* We can be racing with rdsv3_release() which marks the socket dead. */
/* serialize with rdsv3_release -> sock_orphan */
RDSV3_DPRINTF5("rdsv3_recv_incoming",
/* wake up anyone waiting in poll */
if (error != 0) {
RDSV3_DPRINTF2("rdsv3_recv_incoming",
"su_recv returned: %d", error);
}
} else {
}
out:
if (rs)
}
/*
* be very careful here. This is being called as the condition in
* wait_event_*() needs to cope with being called many times.
*/
static int
{
}
}
}
static int
int drop)
{
int ret = 0;
ret = 1;
if (drop) {
/* XXX make sure this i_conn is reliable */
}
}
RDSV3_DPRINTF5("rdsv3_still_queued",
return (ret);
}
/*
* Pull errors off the error queue.
* If msghdr is NULL, we will just purge the error queue.
*/
int
{
struct rdsv3_notifier *notifier;
struct rdsv3_rdma_notify cmsg;
unsigned int count = 0, max_messages = ~0U;
int err = 0;
/*
* put_cmsg copies to user space and thus may sleep. We can't do this
* with rs_lock held, so first grab as many notifications as we can
* stuff
* in the user provided cmsg buffer. We don't try to copy more, to avoid
* losing notifications - except when the buffer is so small that
* it wouldn't
* even hold a single notification. Then we give him as much of this
* single
* msg as we can squeeze in, and set MSG_CTRUNC.
*/
if (msghdr) {
if (!max_messages)
max_messages = 1;
}
count++;
}
if (!count)
return (0);
while (!list_is_empty(©)) {
if (msghdr) {
if (err)
break;
}
}
/*
* If we bailed out because of an error in put_cmsg,
* we may be left with one or more notifications that we
* didn't process. Return them to the head of the list.
*/
if (!list_is_empty(©)) {
}
return (err);
}
/*
* Queue a congestion notification
*/
static int
{
int err;
if (err)
return (err);
return (0);
}
/*
* Receive any control messages.
*/
static int
{
}
int
{
long timeo;
RDSV3_DPRINTF4("rdsv3_recvmsg",
/* udp_recvmsg()->sock_recvtimeo() gets away without locking too.. */
goto out;
/* mark the first cmsg position */
if (msg) {
}
while (1) {
/*
* If there are pending notifications, do those -
* and nothing else
*/
KM_SLEEP);
if (inc) {
}
}
break;
}
if (rs->rs_cong_notify) {
goto out;
}
if (nonblock) {
break;
}
RDSV3_DPRINTF3("rdsv3_recvmsg",
"Before wait (rs: %p)", rs);
#if 0
!rs->rs_cong_notify &&
if (ret == 0) {
RDSV3_DPRINTF2("rdsv3_recvmsg",
"woke due to signal");
}
#else
!rs->rs_cong_notify &&
if (ret == 0) {
RDSV3_DPRINTF2("rdsv3_recvmsg",
"woke due to signal");
break;
}
}
#endif
RDSV3_DPRINTF5("rdsv3_recvmsg",
"recvmsg woke rs: %p inc %p ret %d",
if (ret < 0)
break;
/*
* if the wakeup was due to rs_notify_queue or
* rs_cong_notify then we need to handle those first.
*/
continue;
}
RDSV3_DPRINTF5("rdsv3_recvmsg",
"copying inc %p from %u.%u.%u.%u:%u to user", inc,
if (ret < 0)
break;
/*
* if the message we just copied isn't at the head of the
* recv queue then someone else raced us to return it, try
* to get the next message.
*/
continue;
}
}
goto out;
}
if (msg->msg_namelen) {
}
break;
}
if (inc)
out:
return (ret);
}
/*
* The socket is being shut down and we're asked to drop messages that were
* queued for recvmsg. The caller has unbound the socket so the receive path
* won't queue any more incoming fragments or messages on the socket.
*/
void
{
}
}
/*
* inc->i_saddr isn't used here because it is only set in the receive
* path.
*/
void
struct rdsv3_info_iterator *iter,
{
struct rdsv3_info_message minfo;
if (flip) {
} else {
}
}