16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * This file contains code imported from the OFED rds source file af_rds.c
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * Oracle elects to have and use the contents of af_rds.c under and governed
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * by the OpenIB.org BSD license (see below for full license text). However,
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * the following notice accompanied the original version of this file:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2006 Oracle. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * This software is available to you under a choice of one of two
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * licenses. You may choose to be licensed under the terms of the GNU
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * General Public License (GPL) Version 2, available from the file
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * COPYING in the main directory of this source tree, or the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * OpenIB.org BSD license below:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Redistribution and use in source and binary forms, with or
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * without modification, are permitted provided that the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * conditions are met:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions of source code must retain the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions in binary form must reproduce the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer in the documentation and/or other materials
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * provided with the distribution.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * SOFTWARE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern void rdsv3_remove_bound(struct rdsv3_sock *rds);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern int rdsv3_verify_bind_address(ipaddr_t addr);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* this is just used for stats gathering :/ */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * This is called as the final descriptor referencing this socket is closed.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * We have to unbind the socket so that another socket can be bound to the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * address it was using.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * We have to be careful about racing with the incoming path. sock_orphan()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * sets SOCK_DEAD and we use that as an indicator to the rx path that new
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * messages shouldn't be queued.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* ARGSUSED */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_release(sock_lower_handle_t proto_handle, int flgs, cred_t *cr)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_release", "Enter(rs: %p, sk: %p)", rs, sk);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Note - rdsv3_clear_recv_queue grabs rs_recv_lock, so
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * that ensures the recv path has completed messing
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * with the socket.
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * Note2 - rdsv3_clear_recv_queue(rs) should be called first
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * to prevent some race conditions, which is different from
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * the Linux code.
6e18d381c642549b8bb1774a803d3510aec6baafagiri /* wait for 1 sec and try again */
6e18d381c642549b8bb1774a803d3510aec6baafagiri /* this will free the rs and sk */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_release", "Return (rds: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* wakup anyone waiting in recvmsg */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (!rdsv3_sk_sock_flag(sk, SOCK_DEAD) && sk->sk_sleep)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Careful not to race with rdsv3_release -> sock_orphan which clears sk_sleep.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * _bh() isn't OK here, we're called from interrupt handlers. It's probably OK
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * to wake the waitqueue after sk_sleep is clear as we hold a sock ref, but
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * this seems more conservative.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * NB - normally, one would use sk_callback_lock for this, but we can
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * get here from interrupts, whereas the network code grabs sk_callback_lock
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * with _lock_bh only - so relying on sk_callback_lock introduces livelocks.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_wake_sk_sleep", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_getname(sock_lower_handle_t proto_handle, struct sockaddr *addr,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct sockaddr_in *sin = (struct sockaddr_in *)addr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getname", "Enter(rs: %p, port: %d)", rs,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * RDS' poll is without a doubt the least intuitive part of the interface,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * as POLLIN and POLLOUT do not behave entirely as you would expect from
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * a network protocol.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * POLLIN is asserted if
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - there is data on the receive queue.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - to signal that a previously congested destination may have become
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * uncongested
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - A notification has been queued to the socket (this can be a congestion
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * update, or a RDMA completion).
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * POLLOUT is asserted if there is room on the send queue. This does not mean
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * however, that the next sendmsg() call will succeed. If the application tries
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * to send to a congested destination, the system call may still fail (and
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * return ENOBUFS).
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* ARGSUSED */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic short
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_poll(sock_lower_handle_t proto_handle, short events, int anyyet,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_poll", "enter(%p %x %d)", rs, events, anyyet);
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * If rs_seen_congestion is on, wait until it's off.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * This is implemented for the following OFED code.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * if (rs->rs_seen_congestion)
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * poll_wait(file, &rds_poll_waitq, wait);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * When a congestion map was updated, we signal POLLIN for
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * "historical" reasons. Applications can also poll for
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * WRBAND instead.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota /* clear state any time we wake a seen-congested socket */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_poll", "return(%p %x)", rs, mask);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* ARGSUSED */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_ioctl(sock_lower_handle_t proto_handle, int cmd, intptr_t arg,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_ioctl", "enter: cmd: %d", cmd);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* Only ipv4 for now */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rval = ksocket_socket(&so4, PF_INET, SOCK_DGRAM, 0, KSOCKET_NOSLEEP,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rval != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "ksocket_socket returned %d",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rval = rdsv3_do_ip_ioctl(so4, &buf, &bufsize, &numifs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rval != 0) break;
b27516f55237249607f754e6e42e865f12456675agiri sizeof (struct lifnum), 0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota for (lifrp = (struct lifreq *)buf, rc = 0; rc < numifs;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sizeof (int), 0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyin((void *)arg, &lifc, sizeof (struct lifconf), 0)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "ddi_copyin failed lifc");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rval = rdsv3_do_ip_ioctl(so4, &buf, &bufsize, &numifs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rval != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "copyout of records failed");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyout(&lifc, (void *)arg, sizeof (struct lifconf),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "copyout of lifconf failed");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyin((void *)arg, &ifc, sizeof (struct ifconf), 0)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "ddi_copyin failed ifc");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "O_SIOCGIFCONF: ifc_len: %d, req: %p",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rval = rdsv3_do_ip_ioctl_old(so4, &buf, &bufsize, &numifs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rval != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "copyout of records failed");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyout(&ifc, (void *)arg, sizeof (struct ifconf),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "copyout of ifconf failed");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyin((void *)arg, &lifr, sizeof (struct lifreq), 0)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "ddi_copyin failed lifr");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rc = ksocket_ioctl(so4, cmd, (intptr_t)&lifr, &rval, CRED());
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rc != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ksocket_ioctl failed: %d, name: %s cmd: 0x%x",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sizeof (struct lifreq), 0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyin((void *)arg, &ifr, sizeof (struct ifreq), 0)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "ddi_copyin failed ifr");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "1. name: %s", ifr.ifr_name);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rc = ksocket_ioctl(so4, cmd, (intptr_t)&ifr, &rval, CRED());
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (rc != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ksocket_ioctl failed: %d, name: %s cmd: 0x%x",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_ioctl", "2. name: %s", ifr.ifr_name);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sizeof (struct ifreq), 0);
b27516f55237249607f754e6e42e865f12456675agiri return (rdsv3_info_ioctl((struct rsock *)proto_handle,
b27516f55237249607f754e6e42e865f12456675agiri RDSV3_DPRINTF2("rdsv3_ioctl", "Unknown ioctl cmd: %d", cmd);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota cmn_err(CE_CONT, "unsupported IOCTL cmd: %d \n", cmd);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_ioctl", "return: %d cmd: %d", rval, cmd);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_cancel_sent_to(struct rdsv3_sock *rs, char *optval, int len)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* racing with another thread binding seems ok here */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ddi_copyin((void *)optval, &sin, sizeof (struct sockaddr_in),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_cancel_sent_to", "ddi_copyin failed sin");
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_set_bool_option(unsigned char *optvar, char *optval, int optlen)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (optlen < sizeof (int))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_cong_monitor(struct rdsv3_sock *rs, char *optval, int optlen)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ret = rdsv3_set_bool_option(&rs->rs_cong_monitor, optval, optlen);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ret == 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_setsockopt(sock_lower_handle_t proto_handle, int level,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota int optname, const void *optval, socklen_t optlen, cred_t *cr)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_setsockopt", "enter(%p %d %d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ret = rdsv3_cancel_sent_to(rs, (char *)optval, optlen);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ret = rdsv3_cong_monitor(rs, (char *)optval, optlen);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_getsockopt(sock_lower_handle_t proto_handle, int level,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota int optname, void *optval, socklen_t *optlen, cred_t *cr)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getsockopt", "enter(%p %d %d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getsockopt", "SO_SNDBUF(%d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (*optlen != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getsockopt", "SO_RCVBUF(%d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (*optlen != 0) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getsockopt", "RDSV3_RECVERR(%d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (*optlen < sizeof (int))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *optlen = sizeof (int);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_getsockopt", "return(%p %d %d)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic int rdsv3_connect(sock_lower_handle_t proto_handle,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota const struct sockaddr *addr, socklen_t addr_len, sock_connid_t *conn,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct sockaddr_in *sin = (struct sockaddr_in *)addr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_connect", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sk->sk_upcalls->su_connected(sk->sk_upper_handle, 0, NULL, -1);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_connect", "Return(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_shutdown(sock_lower_handle_t proto_handle, int how, cred_t *cr)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_shutdown", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sock_upper_handle_t sock_handle, sock_upcalls_t *sock_upcalls,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_activate", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_activate", "Return (rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* ARGSUSED */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_send_uio(sock_lower_handle_t proto_handle, uio_t *uio,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_send_uio", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_send_uio", "Return(rs: %p ret %d)", rs, ret);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* ARGSUSED */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_recv_uio(sock_lower_handle_t proto_handle, uio_t *uio,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_recv_uio", "Enter (rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ret = rdsv3_recvmsg(rs, uio, msg, uio->uio_resid, msg->msg_flags);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_recv_uio", "Return(rs: %p ret %d)", rs, ret);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_getpeername(sock_lower_handle_t proto_handle, struct sockaddr *addr,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct sockaddr_in *sin = (struct sockaddr_in *)addr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_getpeername", "enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (void) memset(sin->sin_zero, 0, sizeof (sin->sin_zero));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* racey, don't care */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (0);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF2("rdsv3_clrflowctrl", "enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic struct sock_downcalls_s rdsv3_sock_downcalls = {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic struct sock_downcalls_s rdsv3_sock_downcalls = {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_create(int family, int type, int proto, sock_downcalls_t **sock_downcalls,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint_t *smodep, int *errorp, int flags, cred_t *credp)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_create", "Enter (family: %d type: %d, proto: %d "
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota mutex_init(&rs->rs_lock, NULL, MUTEX_DRIVER, NULL);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota list_create(&rs->rs_send_queue, sizeof (struct rdsv3_message),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota list_create(&rs->rs_recv_queue, sizeof (struct rdsv3_incoming),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota list_create(&rs->rs_notify_queue, sizeof (struct rdsv3_notifier),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota mutex_init(&rs->rs_rdma_lock, NULL, MUTEX_DRIVER, NULL);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sizeof (struct rdsv3_mr), offsetof(struct rdsv3_mr, r_rb_node));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota mutex_init(&rs->rs_conn_lock, NULL, MUTEX_DRIVER, NULL);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota mutex_init(&rs->rs_congested_lock, NULL, MUTEX_DRIVER, NULL);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota cv_init(&rs->rs_congested_cv, NULL, CV_DRIVER, NULL);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* Initialize RDMA/IB on the 1st socket if not done at attach */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_sock_addref", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_sock_put", "Enter(rs: %p)", rs);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_sock_inc_info(struct rsock *sock, unsigned int len,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct rdsv3_info_iterator *iter, struct rdsv3_info_lengths *lens)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_sock_inc_info", "Enter(rs: %p)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_FOR_EACH_LIST_NODE(rs, &rdsv3_sock_list, rs_item) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* XXX too lazy to maintain counts.. */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_FOR_EACH_LIST_NODE(inc, &rs->rs_recv_queue, i_item) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_sock_inc_info", "return(rs: %p)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_sock_info(struct rsock *sock, unsigned int len,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct rdsv3_info_iterator *iter, struct rdsv3_info_lengths *lens)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if ((len < rdsv3_sock_count) || (iter->addr == NULL))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_FOR_EACH_LIST_NODE(rs, &rdsv3_sock_list, rs_item) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_sock_info", "Return(rs: %p)",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern void rdsv3_rdma_init_worker(struct rdsv3_work_s *work);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (void) ddi_taskq_dispatch(rdsv3_taskq, rdsv3_rdma_exit,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF5("rdsv3", "%s-%d Waiting for rdsv3_rdma_exit",
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota rdsv3_info_deregister_func(RDS_INFO_SOCKETS, rdsv3_sock_info);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota kmem_free(rdsv3_rdma_dwp, sizeof (rdsv3_delayed_work_t));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*ARGSUSED*/
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota rdsv3_info_register_func(RDS_INFO_SOCKETS, rdsv3_sock_info);
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota rdsv3_info_register_func(RDS_INFO_RECV_MESSAGES, rdsv3_sock_inc_info);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* rdsv3_rdma_init need to be called with a little delay */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rdsv3_rdma_dwp = kmem_zalloc(sizeof (rdsv3_delayed_work_t), KM_SLEEP);