Lines Matching defs:sock

9 #include "spdk/sock.h"
10 #include "spdk_internal/sock.h"
35 sock_get_group_impl_from_group(struct spdk_sock *sock, struct spdk_sock_group *group)
40 if (sock->net_impl == group_impl->net_impl) {
204 spdk_sock_get_optimal_sock_group(struct spdk_sock *sock, struct spdk_sock_group **group,
213 hint_group_impl = sock_get_group_impl_from_group(sock, hint);
219 group_impl = sock->net_impl->group_impl_get_optimal(sock, hint_group_impl);
229 spdk_sock_getaddr(struct spdk_sock *sock, char *saddr, int slen, uint16_t *sport,
232 return sock->net_impl->getaddr(sock, saddr, slen, sport, caddr, clen, cport);
236 spdk_sock_get_interface_name(struct spdk_sock *sock)
238 if (sock->net_impl->get_interface_name) {
239 return sock->net_impl->get_interface_name(sock);
246 spdk_sock_get_numa_id(struct spdk_sock *sock)
248 if (sock->net_impl->get_numa_id) {
249 return sock->net_impl->get_numa_id(sock);
256 spdk_sock_get_impl_name(struct spdk_sock *sock)
258 return sock->net_impl->name;
353 struct spdk_sock *sock;
373 SPDK_DEBUGLOG(sock, "Creating a client socket using impl %s\n", impl->name);
375 sock = impl->connect(ip, port, &opts_local);
376 if (sock != NULL) {
378 memcpy(&sock->opts, &opts_local, sizeof(sock->opts));
381 sock->opts.impl_opts = NULL;
382 sock->net_impl = impl;
383 TAILQ_INIT(&sock->queued_reqs);
384 TAILQ_INIT(&sock->pending_reqs);
386 return sock;
407 struct spdk_sock *sock;
427 SPDK_DEBUGLOG(sock, "Creating a listening socket using impl %s\n", impl->name);
429 sock = impl->listen(ip, port, &opts_local);
430 if (sock != NULL) {
432 memcpy(&sock->opts, &opts_local, sizeof(sock->opts));
435 sock->opts.impl_opts = NULL;
436 sock->net_impl = impl;
439 return sock;
447 spdk_sock_accept(struct spdk_sock *sock)
451 new_sock = sock->net_impl->accept(sock);
453 /* Inherit the opts from the "accept sock" */
454 new_sock->opts = sock->opts;
455 memcpy(&new_sock->opts, &sock->opts, sizeof(new_sock->opts));
456 new_sock->net_impl = sock->net_impl;
467 struct spdk_sock *sock = *_sock;
469 if (sock == NULL) {
474 if (sock->cb_fn != NULL) {
475 /* This sock is still part of a sock_group. */
483 sock->flags.closed = true;
485 if (sock->cb_cnt > 0) {
490 spdk_sock_abort_requests(sock);
492 return sock->net_impl->close(sock);
496 spdk_sock_recv(struct spdk_sock *sock, void *buf, size_t len)
498 if (sock == NULL || sock->flags.closed) {
503 return sock->net_impl->recv(sock, buf, len);
507 spdk_sock_readv(struct spdk_sock *sock, struct iovec *iov, int iovcnt)
509 if (sock == NULL || sock->flags.closed) {
514 return sock->net_impl->readv(sock, iov, iovcnt);
518 spdk_sock_writev(struct spdk_sock *sock, struct iovec *iov, int iovcnt)
520 if (sock == NULL || sock->flags.closed) {
525 return sock->net_impl->writev(sock, iov, iovcnt);
529 spdk_sock_writev_async(struct spdk_sock *sock, struct spdk_sock_request *req)
533 if (sock == NULL || sock->flags.closed) {
538 sock->net_impl->writev_async(sock, req);
542 spdk_sock_recv_next(struct spdk_sock *sock, void **buf, void **ctx)
544 if (sock == NULL || sock->flags.closed) {
549 if (sock->group_impl == NULL) {
554 return sock->net_impl->recv_next(sock, buf, ctx);
558 spdk_sock_flush(struct spdk_sock *sock)
560 if (sock == NULL || sock->flags.closed) {
565 return sock->net_impl->flush(sock);
569 spdk_sock_set_recvlowat(struct spdk_sock *sock, int nbytes)
571 return sock->net_impl->set_recvlowat(sock, nbytes);
575 spdk_sock_set_recvbuf(struct spdk_sock *sock, int sz)
577 return sock->net_impl->set_recvbuf(sock, sz);
581 spdk_sock_set_sendbuf(struct spdk_sock *sock, int sz)
583 return sock->net_impl->set_sendbuf(sock, sz);
587 spdk_sock_is_ipv6(struct spdk_sock *sock)
589 return sock->net_impl->is_ipv6(sock);
593 spdk_sock_is_ipv4(struct spdk_sock *sock)
595 return sock->net_impl->is_ipv4(sock);
599 spdk_sock_is_connected(struct spdk_sock *sock)
601 return sock->net_impl->is_connected(sock);
645 spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
656 if (sock->group_impl != NULL) {
658 * This sock is already part of a sock_group.
664 group_impl = sock_get_group_impl_from_group(sock, group);
670 rc = group_impl->net_impl->group_impl_add_sock(group_impl, sock);
675 TAILQ_INSERT_TAIL(&group_impl->socks, sock, link);
676 sock->group_impl = group_impl;
677 sock->cb_fn = cb_fn;
678 sock->cb_arg = cb_arg;
684 spdk_sock_group_remove_sock(struct spdk_sock_group *group, struct spdk_sock *sock)
689 group_impl = sock_get_group_impl_from_group(sock, group);
695 assert(group_impl == sock->group_impl);
697 rc = group_impl->net_impl->group_impl_remove_sock(group_impl, sock);
699 TAILQ_REMOVE(&group_impl->socks, sock, link);
700 sock->group_impl = NULL;
701 sock->cb_fn = NULL;
702 sock->cb_arg = NULL;
763 struct spdk_sock *sock = socks[i];
764 assert(sock->cb_fn != NULL);
765 sock->cb_fn(sock->cb_arg, group, sock);
976 SPDK_DEBUGLOG(sock, "Change the default sock impl from %s to %s\n", g_default_impl->name,
979 SPDK_DEBUGLOG(sock, "Set default sock implementation to %s\n", impl_name);
1030 SPDK_LOG_REGISTER_COMPONENT(sock)
1063 SPDK_TRACE_REGISTER_FN(sock_trace, "sock", TRACE_GROUP_SOCK)