sock: Add spdk_sock_impl_get/set_opts function
spdk_sock_impl_get/set_opts functions allow to set different socket layer configuration options. Options can be set independently for each socket layer implementation. Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com> Change-Id: I617e58366a153fae2cf0de1b271cc4f4f19ec451 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/607 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
c965542795
commit
eb0faf2634
@ -26,6 +26,11 @@ Two providers are available - verbs (used by default when RDMA is enabled or ena
|
||||
using --with-rdma=verbs) and mlx5 Direct Verbs aka DV (enabled by --with-rdma=mlx5_dv).
|
||||
Using mlx5_dv requires libmlx5 installed on the system.
|
||||
|
||||
### sock
|
||||
|
||||
Added `spdk_sock_impl_get_opts` and `spdk_sock_impl_set_opts` functions to set/get socket layer configuration
|
||||
options. Options can be set independently for each implementation.
|
||||
|
||||
## v20.04:
|
||||
|
||||
IDXD engine support for compare has been added.
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
* Copyright (c) Intel Corporation. All rights reserved.
|
||||
* Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -79,6 +79,15 @@ struct spdk_sock_request {
|
||||
|
||||
#define SPDK_SOCK_REQUEST_IOV(req, i) ((struct iovec *)(((uint8_t *)req + sizeof(struct spdk_sock_request)) + (sizeof(struct iovec) * i)))
|
||||
|
||||
/**
|
||||
* SPDK socket implementation options.
|
||||
*
|
||||
* A pointer to this structure is used by spdk_sock_impl_get_opts() and spdk_sock_impl_set_opts()
|
||||
* to allow the user to request options for the socket module implementation.
|
||||
* Each socket module defines which options from this structure are applicable to the module.
|
||||
*/
|
||||
struct spdk_sock_impl_opts;
|
||||
|
||||
/**
|
||||
* Spdk socket initialization options.
|
||||
*
|
||||
@ -408,6 +417,29 @@ int spdk_sock_group_close(struct spdk_sock_group **group);
|
||||
*/
|
||||
int spdk_sock_get_optimal_sock_group(struct spdk_sock *sock, struct spdk_sock_group **group);
|
||||
|
||||
/**
|
||||
* Get current socket implementation options.
|
||||
*
|
||||
* \param impl_name The socket implementation to use, such as "posix".
|
||||
* \param opts Pointer to allocated spdk_sock_impl_opts structure that will be filled with actual values.
|
||||
* \param len On input specifies size of passed opts structure. On return it is set to actual size that was filled with values.
|
||||
*
|
||||
* \return 0 on success, -1 on failure. errno is set to indicate the reason of failure.
|
||||
*/
|
||||
int spdk_sock_impl_get_opts(const char *impl_name, struct spdk_sock_impl_opts *opts, size_t *len);
|
||||
|
||||
/**
|
||||
* Set socket implementation options.
|
||||
*
|
||||
* \param impl_name The socket implementation to use, such as "posix".
|
||||
* \param opts Pointer to allocated spdk_sock_impl_opts structure with new options values.
|
||||
* \param len Size of passed opts structure.
|
||||
*
|
||||
* \return 0 on success, -1 on failure. errno is set to indicate the reason of failure.
|
||||
*/
|
||||
int spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_opts *opts,
|
||||
size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
* Copyright (c) Intel Corporation. All rights reserved.
|
||||
* Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -119,6 +119,9 @@ struct spdk_net_impl {
|
||||
struct spdk_sock **socks);
|
||||
int (*group_impl_close)(struct spdk_sock_group_impl *group);
|
||||
|
||||
int (*get_opts)(struct spdk_sock_impl_opts *opts, size_t *len);
|
||||
int (*set_opts)(const struct spdk_sock_impl_opts *opts, size_t len);
|
||||
|
||||
STAILQ_ENTRY(spdk_net_impl) link;
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 3
|
||||
SO_MINOR := 0
|
||||
SO_MINOR := 1
|
||||
|
||||
C_SRCS = sock.c net_framework.c
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
* Copyright (c) Intel Corporation. All rights reserved.
|
||||
* Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -688,6 +688,69 @@ spdk_sock_group_close(struct spdk_sock_group **group)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct spdk_net_impl *
|
||||
sock_get_impl_by_name(const char *impl_name)
|
||||
{
|
||||
struct spdk_net_impl *impl;
|
||||
|
||||
assert(impl_name != NULL);
|
||||
STAILQ_FOREACH(impl, &g_net_impls, link) {
|
||||
if (0 == strcmp(impl_name, impl->name)) {
|
||||
return impl;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_sock_impl_get_opts(const char *impl_name, struct spdk_sock_impl_opts *opts, size_t *len)
|
||||
{
|
||||
struct spdk_net_impl *impl;
|
||||
|
||||
if (!impl_name || !opts || !len) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
impl = sock_get_impl_by_name(impl_name);
|
||||
if (!impl) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!impl->get_opts) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return impl->get_opts(opts, len);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_opts *opts, size_t len)
|
||||
{
|
||||
struct spdk_net_impl *impl;
|
||||
|
||||
if (!impl_name || !opts) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
impl = sock_get_impl_by_name(impl_name);
|
||||
if (!impl) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!impl->set_opts) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return impl->set_opts(opts, len);
|
||||
}
|
||||
|
||||
void
|
||||
spdk_net_impl_register(struct spdk_net_impl *impl, int priority)
|
||||
{
|
||||
|
@ -29,6 +29,8 @@
|
||||
spdk_sock_group_poll_count;
|
||||
spdk_sock_group_close;
|
||||
spdk_sock_get_optimal_sock_group;
|
||||
spdk_sock_impl_get_opts;
|
||||
spdk_sock_impl_set_opts;
|
||||
|
||||
# public functions in spdk/net.h
|
||||
spdk_net_framework_register;
|
||||
|
Loading…
x
Reference in New Issue
Block a user