All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: netdev@vger.kernel.org
Cc: Tom Herbert <tom@herbertland.com>
Subject: [RFC PATCH 02/11] net: Create netqueue.h and define NO_QUEUE
Date: Wed, 24 Jun 2020 10:17:41 -0700	[thread overview]
Message-ID: <20200624171749.11927-3-tom@herbertland.com> (raw)
In-Reply-To: <20200624171749.11927-1-tom@herbertland.com>

Create linux/netqueue.h to hold generic network queue definitions.

Define NO_QUEUE to replace NO_QUEUE_MAPPING in net/sock.h. NO_QUEUE
can generally be used to indicate that a 16 bit queue index does not
refer to a queue.

Also, define net_queue_pair which will be used as a generic way to store a
transmit/receive pair of network queues.
---
 include/linux/netdevice.h |  1 +
 include/linux/netqueue.h  | 25 +++++++++++++++++++++++++
 include/net/sock.h        | 12 +++++-------
 net/core/filter.c         |  4 ++--
 4 files changed, 33 insertions(+), 9 deletions(-)
 create mode 100644 include/linux/netqueue.h

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6fc613ed8eae..bf5f2a85da97 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -32,6 +32,7 @@
 #include <linux/percpu.h>
 #include <linux/rculist.h>
 #include <linux/workqueue.h>
+#include <linux/netqueue.h>
 #include <linux/dynamic_queue_limits.h>
 
 #include <linux/ethtool.h>
diff --git a/include/linux/netqueue.h b/include/linux/netqueue.h
new file mode 100644
index 000000000000..5a4d39821ada
--- /dev/null
+++ b/include/linux/netqueue.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Network queue identifier definitions
+ *
+ * Copyright (c) 2020 Tom Herbert <tom@herbertland.com>
+ */
+
+#ifndef _LINUX_NETQUEUE_H
+#define _LINUX_NETQUEUE_H
+
+/* Indicates no network queue is present in 16 bit queue number */
+#define NO_QUEUE	USHRT_MAX
+
+struct net_queue_pair {
+	unsigned short txq_id;
+	unsigned short rxq_id;
+};
+
+static inline void init_net_queue_pair(struct net_queue_pair *qpair)
+{
+	qpair->rxq_id = NO_QUEUE;
+	qpair->txq_id = NO_QUEUE;
+}
+
+#endif /* _LINUX_NETQUEUE_H */
diff --git a/include/net/sock.h b/include/net/sock.h
index c53cc42b5ab9..acb76cfaae1b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1800,16 +1800,14 @@ static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
 	sk->sk_tx_queue_mapping = tx_queue;
 }
 
-#define NO_QUEUE_MAPPING	USHRT_MAX
-
 static inline void sk_tx_queue_clear(struct sock *sk)
 {
-	sk->sk_tx_queue_mapping = NO_QUEUE_MAPPING;
+	sk->sk_tx_queue_mapping = NO_QUEUE;
 }
 
 static inline int sk_tx_queue_get(const struct sock *sk)
 {
-	if (sk && sk->sk_tx_queue_mapping != NO_QUEUE_MAPPING)
+	if (sk && sk->sk_tx_queue_mapping != NO_QUEUE)
 		return sk->sk_tx_queue_mapping;
 
 	return -1;
@@ -1821,7 +1819,7 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
 	if (skb_rx_queue_recorded(skb)) {
 		u16 rx_queue = skb_get_rx_queue(skb);
 
-		if (WARN_ON_ONCE(rx_queue == NO_QUEUE_MAPPING))
+		if (WARN_ON_ONCE(rx_queue == NO_QUEUE))
 			return;
 
 		sk->sk_rx_queue_mapping = rx_queue;
@@ -1832,14 +1830,14 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
 static inline void sk_rx_queue_clear(struct sock *sk)
 {
 #ifdef CONFIG_XPS
-	sk->sk_rx_queue_mapping = NO_QUEUE_MAPPING;
+	sk->sk_rx_queue_mapping = NO_QUEUE;
 #endif
 }
 
 #ifdef CONFIG_XPS
 static inline int sk_rx_queue_get(const struct sock *sk)
 {
-	if (sk && sk->sk_rx_queue_mapping != NO_QUEUE_MAPPING)
+	if (sk && sk->sk_rx_queue_mapping != NO_QUEUE)
 		return sk->sk_rx_queue_mapping;
 
 	return -1;
diff --git a/net/core/filter.c b/net/core/filter.c
index 73395384afe2..d696aaabe3af 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -7544,7 +7544,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 
 	case offsetof(struct __sk_buff, queue_mapping):
 		if (type == BPF_WRITE) {
-			*insn++ = BPF_JMP_IMM(BPF_JGE, si->src_reg, NO_QUEUE_MAPPING, 1);
+			*insn++ = BPF_JMP_IMM(BPF_JGE, si->src_reg, NO_QUEUE, 1);
 			*insn++ = BPF_STX_MEM(BPF_H, si->dst_reg, si->src_reg,
 					      bpf_target_off(struct sk_buff,
 							     queue_mapping,
@@ -7981,7 +7981,7 @@ u32 bpf_sock_convert_ctx_access(enum bpf_access_type type,
 				       sizeof_field(struct sock,
 						    sk_rx_queue_mapping),
 				       target_size));
-		*insn++ = BPF_JMP_IMM(BPF_JNE, si->dst_reg, NO_QUEUE_MAPPING,
+		*insn++ = BPF_JMP_IMM(BPF_JNE, si->dst_reg, NO_QUEUE,
 				      1);
 		*insn++ = BPF_MOV64_IMM(si->dst_reg, -1);
 #else
-- 
2.25.1


  parent reply	other threads:[~2020-06-24 17:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 17:17 [RFC PATCH 00/11] ptq: Per Thread Queues Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 01/11] cgroup: Export cgroup_{procs,threads}_start and cgroup_procs_next Tom Herbert
2020-06-24 17:17 ` Tom Herbert [this message]
2020-06-24 17:17 ` [RFC PATCH 03/11] arfs: Create set_arfs_queue Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 04/11] net-sysfs: Create rps_create_sock_flow_table Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 05/11] net: Infrastructure for per queue aRFS Tom Herbert
2020-06-28  8:55   ` kernel test robot
2020-06-24 17:17 ` [RFC PATCH 06/11] net: Function to check against maximum number for RPS queues Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 07/11] net: Introduce global queues Tom Herbert
2020-06-24 23:00   ` kernel test robot
2020-06-24 23:58   ` kernel test robot
2020-06-25  0:23   ` kernel test robot
2020-06-30 21:06   ` Jonathan Lemon
2020-06-24 17:17 ` [RFC PATCH 08/11] ptq: Per Thread Queues Tom Herbert
2020-06-24 21:20   ` kernel test robot
2020-06-25  1:50   ` [RFC PATCH] ptq: null_pcdesc can be static kernel test robot
2020-06-25  7:26   ` [RFC PATCH 08/11] ptq: Per Thread Queues kernel test robot
2020-06-24 17:17 ` [RFC PATCH 09/11] ptq: Hook up transmit side of Per Queue Threads Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 10/11] ptq: Hook up receive " Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 11/11] doc: Documentation for Per Thread Queues Tom Herbert
2020-06-25  2:20   ` kernel test robot
2020-06-25 23:00   ` Jacob Keller
2020-06-29  6:28   ` Saeed Mahameed
2020-06-29 15:10     ` Tom Herbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624171749.11927-3-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.