sock: Add the socket priority setting function.
Purpose: This API can be used to set the socket with different priority. Signed-off-by: Ziye Yang <ziye.yang@intel.com> Change-Id: I9df1122bf6ae640eba731e635a1784f4e9da4104 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461738 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
ae679483d6
commit
ecb4ea90ce
@ -98,6 +98,7 @@ sock groups. This API is intended to provide the user with that information.
|
||||
|
||||
spdk_sock_group_get_ctx() was added to return the context of the spdk_sock_group.
|
||||
spdk_sock_group_create() is updated to allow input the user provided ctx.
|
||||
spdk_sock_set_priority() is added to set the priority of the socket.
|
||||
|
||||
### rpc
|
||||
|
||||
|
@ -157,6 +157,16 @@ int spdk_sock_set_recvlowat(struct spdk_sock *sock, int nbytes);
|
||||
*/
|
||||
int spdk_sock_set_recvbuf(struct spdk_sock *sock, int sz);
|
||||
|
||||
/**
|
||||
* Set priority for the given socket.
|
||||
*
|
||||
* \param sock Socket to set the priority.
|
||||
* \param priority Priority given by the user.
|
||||
*
|
||||
* \return 0 on success, -1 on failure.
|
||||
*/
|
||||
int spdk_sock_set_priority(struct spdk_sock *sock, int priority);
|
||||
|
||||
/**
|
||||
* Set send buffer size for the given socket.
|
||||
*
|
||||
|
@ -82,6 +82,7 @@ struct spdk_net_impl {
|
||||
int (*set_recvlowat)(struct spdk_sock *sock, int nbytes);
|
||||
int (*set_recvbuf)(struct spdk_sock *sock, int sz);
|
||||
int (*set_sendbuf)(struct spdk_sock *sock, int sz);
|
||||
int (*set_priority)(struct spdk_sock *sock, int priority);
|
||||
|
||||
bool (*is_ipv6)(struct spdk_sock *sock);
|
||||
bool (*is_ipv4)(struct spdk_sock *sock);
|
||||
|
@ -427,6 +427,22 @@ spdk_posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
|
||||
&sz, sizeof(sz));
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_posix_sock_set_priority(struct spdk_sock *_sock, int priority)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
#if defined(SO_PRIORITY)
|
||||
struct spdk_posix_sock *sock = __posix_sock(_sock);
|
||||
|
||||
assert(sock != NULL);
|
||||
|
||||
rc = setsockopt(sock->fd, SOL_SOCKET, SO_PRIORITY,
|
||||
&priority, sizeof(priority));
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static bool
|
||||
spdk_posix_sock_is_ipv6(struct spdk_sock *_sock)
|
||||
{
|
||||
@ -620,6 +636,7 @@ static struct spdk_net_impl g_posix_net_impl = {
|
||||
.set_recvlowat = spdk_posix_sock_set_recvlowat,
|
||||
.set_recvbuf = spdk_posix_sock_set_recvbuf,
|
||||
.set_sendbuf = spdk_posix_sock_set_sendbuf,
|
||||
.set_priority = spdk_posix_sock_set_priority,
|
||||
.is_ipv6 = spdk_posix_sock_is_ipv6,
|
||||
.is_ipv4 = spdk_posix_sock_is_ipv4,
|
||||
.get_placement_id = spdk_posix_sock_get_placement_id,
|
||||
|
@ -286,6 +286,12 @@ spdk_sock_set_sendbuf(struct spdk_sock *sock, int sz)
|
||||
return sock->net_impl->set_sendbuf(sock, sz);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_sock_set_priority(struct spdk_sock *sock, int priority)
|
||||
{
|
||||
return sock->net_impl->set_priority(sock, priority);
|
||||
}
|
||||
|
||||
bool
|
||||
spdk_sock_is_ipv6(struct spdk_sock *sock)
|
||||
{
|
||||
|
@ -962,6 +962,14 @@ spdk_vpp_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_vpp_sock_set_priority(struct spdk_sock *_sock, int priority)
|
||||
{
|
||||
assert(g_svm.vpp_initialized);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
spdk_vpp_sock_is_ipv6(struct spdk_sock *_sock)
|
||||
{
|
||||
@ -1391,6 +1399,7 @@ static struct spdk_net_impl g_vpp_net_impl = {
|
||||
.set_recvlowat = spdk_vpp_sock_set_recvlowat,
|
||||
.set_recvbuf = spdk_vpp_sock_set_recvbuf,
|
||||
.set_sendbuf = spdk_vpp_sock_set_sendbuf,
|
||||
.set_priority = spdk_vpp_sock_set_priority,
|
||||
.is_ipv6 = spdk_vpp_sock_is_ipv6,
|
||||
.is_ipv4 = spdk_vpp_sock_is_ipv4,
|
||||
.get_placement_id = spdk_vpp_sock_get_placement_id,
|
||||
|
@ -250,6 +250,12 @@ spdk_ut_sock_get_placement_id(struct spdk_sock *_sock, int *placement_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_ut_sock_set_priority(struct spdk_sock *_sock, int priority)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spdk_sock_group_impl *
|
||||
spdk_ut_sock_group_impl_create(void)
|
||||
{
|
||||
@ -321,6 +327,7 @@ static struct spdk_net_impl g_ut_net_impl = {
|
||||
.set_recvlowat = spdk_ut_sock_set_recvlowat,
|
||||
.set_recvbuf = spdk_ut_sock_set_recvbuf,
|
||||
.set_sendbuf = spdk_ut_sock_set_sendbuf,
|
||||
.set_priority = spdk_ut_sock_set_priority,
|
||||
.is_ipv6 = spdk_ut_sock_is_ipv6,
|
||||
.is_ipv4 = spdk_ut_sock_is_ipv4,
|
||||
.get_placement_id = spdk_ut_sock_get_placement_id,
|
||||
|
Loading…
Reference in New Issue
Block a user