Commit 2b46c17d authored by Jim Harris's avatar Jim Harris
Browse files

sock: change socket_id to int32_t



These changes were added since last release, so it's safe to just
change them now without breaking API/ABI.

I mistakenly used uint32_t for the socket_id, when in fact DPDK and
our env layer really treat it as an int. This mostly shows up
with the SPDK_ENV_SOCKET_ID_ANY that is defined as -1, which forces
a lot of annoying casting if we're trying to pass this value through
a uint32_t interface.

This socket_id concept will be getting plumbed into
nvme, bdev and nvmf layers, so instead of proliferating the
uint32_t socket_id there, just change sock layer to use
int32_t instead.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I573ba7f9aeed3b216bef72f39fc671c9c6688d3a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24577


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent a1a81923
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ const char *spdk_sock_get_interface_name(struct spdk_sock *sock);
 *
 * \return NUMA socket ID, or SPDK_ENV_SOCKET_ID_ANY if the NUMA socket ID is unknown
 */
uint32_t spdk_sock_get_numa_socket_id(struct spdk_sock *sock);
int32_t spdk_sock_get_numa_socket_id(struct spdk_sock *sock);

/**
 * Close a socket.
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ struct spdk_net_impl {
	int (*getaddr)(struct spdk_sock *sock, char *saddr, int slen, uint16_t *sport, char *caddr,
		       int clen, uint16_t *cport);
	const char *(*get_interface_name)(struct spdk_sock *sock);
	uint32_t (*get_numa_socket_id)(struct spdk_sock *sock);
	int32_t (*get_numa_socket_id)(struct spdk_sock *sock);
	struct spdk_sock *(*connect)(const char *ip, int port, struct spdk_sock_opts *opts);
	struct spdk_sock *(*listen)(const char *ip, int port, struct spdk_sock_opts *opts);
	struct spdk_sock *(*accept)(struct spdk_sock *sock);
+1 −1
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ spdk_sock_get_interface_name(struct spdk_sock *sock)
	}
}

uint32_t
int32_t
spdk_sock_get_numa_socket_id(struct spdk_sock *sock)
{
	if (sock->net_impl->get_numa_socket_id) {
+3 −3
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ posix_sock_get_interface_name(struct spdk_sock *_sock)
	return sock->interface_name;
}

static uint32_t
static int32_t
posix_sock_get_numa_socket_id(struct spdk_sock *sock)
{
	const char *interface_name;
@@ -270,8 +270,8 @@ posix_sock_get_numa_socket_id(struct spdk_sock *sock)

	rc = spdk_read_sysfs_attribute_uint32(&numa_socket_id,
					      "/sys/class/net/%s/device/numa_node", interface_name);
	if (rc == 0) {
		return numa_socket_id;
	if (rc == 0 && numa_socket_id <= INT32_MAX) {
		return (int32_t)numa_socket_id;
	} else {
		return SPDK_ENV_SOCKET_ID_ANY;
	}
+3 −3
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ uring_sock_get_interface_name(struct spdk_sock *_sock)
	return sock->interface_name;
}

static uint32_t
static int32_t
uring_sock_get_numa_socket_id(struct spdk_sock *sock)
{
	const char *interface_name;
@@ -274,8 +274,8 @@ uring_sock_get_numa_socket_id(struct spdk_sock *sock)

	rc = spdk_read_sysfs_attribute_uint32(&numa_socket_id,
					      "/sys/class/net/%s/device/numa_node", interface_name);
	if (rc == 0) {
		return numa_socket_id;
	if (rc == 0 && numa_socket_id <= INT32_MAX) {
		return (int32_t)numa_socket_id;
	} else {
		return SPDK_ENV_SOCKET_ID_ANY;
	}