xref: /spdk/python/spdk/rpc/sock.py (revision fe22b50579d7b673a86bd2eba54c623881b5fdaf)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (C) 2021 Intel Corporation.
3#  All rights reserved.
4
5
6def sock_impl_get_options(client, impl_name=None):
7    """Get parameters for the socket layer implementation.
8
9    Args:
10        impl_name: name of socket implementation, e.g. posix
11    """
12    params = {}
13
14    params['impl_name'] = impl_name
15
16    return client.call('sock_impl_get_options', params)
17
18
19def sock_impl_set_options(client,
20                          impl_name=None,
21                          recv_buf_size=None,
22                          send_buf_size=None,
23                          enable_recv_pipe=None,
24                          enable_quickack=None,
25                          enable_placement_id=None,
26                          enable_zerocopy_send_server=None,
27                          enable_zerocopy_send_client=None,
28                          zerocopy_threshold=None,
29                          tls_version=None,
30                          enable_ktls=None):
31    """Set parameters for the socket layer implementation.
32
33    Args:
34        impl_name: name of socket implementation, e.g. posix
35        recv_buf_size: size of socket receive buffer in bytes (optional)
36        send_buf_size: size of socket send buffer in bytes (optional)
37        enable_recv_pipe: enable or disable receive pipe (optional)
38        enable_quickack: enable or disable quickack (optional)
39        enable_placement_id: option for placement_id. 0:disable,1:incoming_napi,2:incoming_cpu (optional)
40        enable_zerocopy_send_server: enable or disable zerocopy on send for server sockets(optional)
41        enable_zerocopy_send_client: enable or disable zerocopy on send for client sockets(optional)
42        zerocopy_threshold: set zerocopy_threshold in bytes(optional)
43        tls_version: set TLS protocol version (optional)
44        enable_ktls: enable or disable Kernel TLS (optional)
45    """
46    params = {}
47
48    params['impl_name'] = impl_name
49    if recv_buf_size is not None:
50        params['recv_buf_size'] = recv_buf_size
51    if send_buf_size is not None:
52        params['send_buf_size'] = send_buf_size
53    if enable_recv_pipe is not None:
54        params['enable_recv_pipe'] = enable_recv_pipe
55    if enable_quickack is not None:
56        params['enable_quickack'] = enable_quickack
57    if enable_placement_id is not None:
58        params['enable_placement_id'] = enable_placement_id
59    if enable_zerocopy_send_server is not None:
60        params['enable_zerocopy_send_server'] = enable_zerocopy_send_server
61    if enable_zerocopy_send_client is not None:
62        params['enable_zerocopy_send_client'] = enable_zerocopy_send_client
63    if zerocopy_threshold is not None:
64        params['zerocopy_threshold'] = zerocopy_threshold
65    if tls_version is not None:
66        params['tls_version'] = tls_version
67    if enable_ktls is not None:
68        params['enable_ktls'] = enable_ktls
69
70    return client.call('sock_impl_set_options', params)
71
72
73def sock_set_default_impl(client, impl_name=None):
74    """Set the default socket implementation.
75
76    Args:
77        impl_name: name of socket implementation, e.g. posix
78    """
79    params = {}
80
81    params['impl_name'] = impl_name
82
83    return client.call('sock_set_default_impl', params)
84
85
86def sock_get_default_impl(client):
87    "Get the default socket implementation name."
88
89    return client.call('sock_get_default_impl')
90