FreeBSD/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
/*
 * Allocate an sdp_sock for the socket and reserve socket buffer space.
 */
Allocate an sdp_sock for the socket and reserve socket buffer space.
Allocate an sdp_sock for the socket and reserve socket buffer space .
static int
sdp_attach(struct socket *so, int proto, struct thread *td)
{
	struct sdp_sock *ssk;
	int error;
	ssk = sdp_sk(so);
	KASSERT(ssk == NULL, ("sdp_attach: ssk already set on so %p", so));
	if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
		error = soreserve(so, sdp_sendspace, sdp_recvspace);
		if (error)
			return (error);
	}
	so->so_rcv.sb_flags |= SB_AUTOSIZE;
	so->so_snd.sb_flags |= SB_AUTOSIZE;
	ssk = uma_zalloc(sdp_zone, M_NOWAIT | M_ZERO);
	if (ssk == NULL)
		return (ENOBUFS);
	rw_init(&ssk->lock, "sdpsock");
	ssk->socket = so;
	ssk->cred = crhold(so->so_cred);
	so->so_pcb = (caddr_t)ssk;
	sdp_init_sock(so);
	ssk->flags = 0;
	ssk->qp_active = 0;
	ssk->state = TCPS_CLOSED;
	SDP_LIST_WLOCK();
	LIST_INSERT_HEAD(&sdp_list, ssk, list);
	sdp_count++;
	SDP_LIST_WUNLOCK();
	if ((so->so_options & SO_LINGER) && so->so_linger == 0)
		so->so_linger = TCP_LINGERTIME;
	return (0);
}
static int sdp_attach ( struct socket * so , int proto , struct thread * td ) { struct sdp_sock * ssk ; int error ; ssk = sdp_sk ( so ) ; KASSERT ( ssk == NULL , ( " " , so ) ) ; if ( so -> so_snd . sb_hiwat == 0 || so -> so_rcv . sb_hiwat == 0 ) { error = soreserve ( so , sdp_sendspace , sdp_recvspace ) ; if ( error ) return ( error ) ; } so -> so_rcv . sb_flags |= SB_AUTOSIZE ; so -> so_snd . sb_flags |= SB_AUTOSIZE ; ssk = uma_zalloc ( sdp_zone , M_NOWAIT | M_ZERO ) ; if ( ssk == NULL ) return ( ENOBUFS ) ; rw_init ( & ssk -> lock , " " ) ; ssk -> socket = so ; ssk -> cred = crhold ( so -> so_cred ) ; so -> so_pcb = ( caddr_t ) ssk ; sdp_init_sock ( so ) ; ssk -> flags = 0 ; ssk -> qp_active = 0 ; ssk -> state = TCPS_CLOSED ; SDP_LIST_WLOCK ( ) ; LIST_INSERT_HEAD ( & sdp_list , ssk , list ) ; sdp_count ++ ; SDP_LIST_WUNLOCK ( ) ; if ( ( so -> so_options & SO_LINGER ) && so -> so_linger == 0 ) so -> so_linger = TCP_LINGERTIME ; return ( 0 ) ; }
Allocate an sdp_sock for the socket and reserve socket buffer space.
Allocate an sdp_sock for the socket and reserve socket buffer space .