aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTuomas Taipale <tuomas.taipale@nokia.com>2023-03-03 12:23:41 +0000
committerPetri Savolainen <petri.savolainen@nokia.com>2023-05-04 13:26:59 +0300
commitdb83832096f8fc8468809772c07f3c65dd00b8f7 (patch)
treefd9f12a7a5a52b795973fad1aacc51f609c48566 /platform
parentfc0442c2100d5967af4170d08004846e38906b67 (diff)
linux-gen: socket_xdp: adjust queue count capability reporting
Report maximum input and output queue counts based on the supported combined count of the underlying driver. Additionally, maximally limit the count to the system core count as this is typically the actual maximum count supported by drivers even though theoretically supporting more. Signed-off-by: Tuomas Taipale <tuomas.taipale@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/pktio/socket_xdp.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/platform/linux-generic/pktio/socket_xdp.c b/platform/linux-generic/pktio/socket_xdp.c
index be79ca267..47dbdcdd6 100644
--- a/platform/linux-generic/pktio/socket_xdp.c
+++ b/platform/linux-generic/pktio/socket_xdp.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2022, Nokia
+/* Copyright (c) 2022-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -9,32 +9,33 @@
#ifdef _ODP_PKTIO_XDP
#include <odp_posix_extensions.h>
+#include <odp/api/cpu.h>
#include <odp/api/debug.h>
#include <odp/api/hints.h>
+#include <odp/api/packet_io_stats.h>
#include <odp/api/system_info.h>
#include <odp/api/ticketlock.h>
-#include <odp/api/packet_io_stats.h>
#include <odp_classification_internal.h>
#include <odp_debug_internal.h>
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
-#include <odp_packet_io_internal.h>
#include <odp_packet_internal.h>
+#include <odp_packet_io_internal.h>
#include <odp_parse_internal.h>
#include <odp_pool_internal.h>
#include <odp_socket_common.h>
-#include <string.h>
#include <errno.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/ioctl.h>
#include <linux/ethtool.h>
+#include <linux/if_xdp.h>
#include <linux/sockios.h>
#include <net/if.h>
-#include <linux/if_xdp.h>
+#include <poll.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <unistd.h>
#include <xdp/xsk.h>
@@ -830,12 +831,13 @@ static int sock_xdp_link_info(pktio_entry_t *pktio_entry, odp_pktio_link_info_t
pktio_entry->name, info);
}
-static int set_queue_capability(int fd, const char *devname, odp_pktio_capability_t *capa)
+static int get_nic_queue_capability(int fd, const char *devname, odp_pktio_capability_t *capa)
{
- struct ifreq ifr;
struct ethtool_channels channels;
- uint32_t max_channels;
+ struct ifreq ifr;
int ret;
+ const uint32_t cc = odp_cpu_count();
+ uint32_t max_channels;
memset(&channels, 0, sizeof(struct ethtool_channels));
channels.cmd = ETHTOOL_GCHANNELS;
@@ -845,16 +847,16 @@ static int set_queue_capability(int fd, const char *devname, odp_pktio_capabilit
if (ret == -1 || channels.max_combined == 0U) {
if (ret == -1 && errno != EOPNOTSUPP) {
- _ODP_ERR("Unable to query NIC channel capabilities: %s\n", strerror(errno));
+ _ODP_ERR("Unable to query NIC queue capabilities: %s\n", strerror(errno));
return -1;
}
channels.max_combined = 1U;
}
- max_channels = _ODP_MIN((uint32_t)ODP_PKTOUT_MAX_QUEUES, channels.max_combined);
+ max_channels = _ODP_MIN(cc, channels.max_combined);
capa->max_input_queues = _ODP_MIN((uint32_t)ODP_PKTIN_MAX_QUEUES, max_channels);
- capa->max_output_queues = max_channels;
+ capa->max_output_queues = _ODP_MIN((uint32_t)ODP_PKTOUT_MAX_QUEUES, max_channels);
return 0;
}
@@ -865,7 +867,7 @@ static int sock_xdp_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_
memset(capa, 0, sizeof(odp_pktio_capability_t));
- if (set_queue_capability(priv->helper_sock, pktio_entry->name, capa))
+ if (get_nic_queue_capability(priv->helper_sock, pktio_entry->name, capa))
return -1;
capa->set_op.op.promisc_mode = 1U;