net: Introduce SO_INCOMING_NAPI_ID
authorSridhar Samudrala <sridhar.samudrala@intel.com>
Fri, 24 Mar 2017 17:08:36 +0000 (10:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 25 Mar 2017 03:49:31 +0000 (20:49 -0700)
This socket option returns the NAPI ID associated with the queue on which
the last frame is received. This information can be used by the apps to
split the incoming flows among the threads based on the Rx queue on which
they are received.

If the NAPI ID actually represents a sender_cpu then the value is ignored
and 0 is returned.

Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 files changed:
arch/alpha/include/uapi/asm/socket.h
arch/avr32/include/uapi/asm/socket.h
arch/frv/include/uapi/asm/socket.h
arch/ia64/include/uapi/asm/socket.h
arch/m32r/include/uapi/asm/socket.h
arch/mips/include/uapi/asm/socket.h
arch/mn10300/include/uapi/asm/socket.h
arch/parisc/include/uapi/asm/socket.h
arch/powerpc/include/uapi/asm/socket.h
arch/s390/include/uapi/asm/socket.h
arch/sparc/include/uapi/asm/socket.h
arch/xtensa/include/uapi/asm/socket.h
include/uapi/asm-generic/socket.h
net/core/sock.c

index 089db42..1bb8cac 100644 (file)
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _UAPI_ASM_SOCKET_H */
index 6eabcbd..f824eeb 100644 (file)
@@ -94,4 +94,6 @@
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _UAPI__ASM_AVR32_SOCKET_H */
index bd497f8..a8ad9be 100644 (file)
@@ -94,5 +94,7 @@
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_SOCKET_H */
 
index f1bb546..6af3253 100644 (file)
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_IA64_SOCKET_H */
index 459c460..e98b6bb 100644 (file)
@@ -94,4 +94,6 @@
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_M32R_SOCKET_H */
index 688c18d..ae2b62e 100644 (file)
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
 
 #endif /* _UAPI_ASM_SOCKET_H */
index 312d2c4..e4ac184 100644 (file)
@@ -94,4 +94,6 @@
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_SOCKET_H */
index b98ec38..f754c79 100644 (file)
@@ -93,4 +93,6 @@
 
 #define SO_MEMINFO             0x4030
 
+#define SO_INCOMING_NAPI_ID    0x4031
+
 #endif /* _UAPI_ASM_SOCKET_H */
index 099a889..5f84af7 100644 (file)
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_POWERPC_SOCKET_H */
index 6199bb3..25ac496 100644 (file)
 
 #define        SO_MEMINFO              55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _ASM_SOCKET_H */
index 12cd8c2..b05513a 100644 (file)
@@ -90,6 +90,8 @@
 
 #define SO_MEMINFO             0x0039
 
+#define SO_INCOMING_NAPI_ID    0x003a
+
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION             0x5001
 #define SO_SECURITY_ENCRYPTION_TRANSPORT       0x5002
index d0b85f6..786606c 100644 (file)
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* _XTENSA_SOCKET_H */
index 8313702..c98a52f 100644 (file)
@@ -96,4 +96,6 @@
 
 #define SO_MEMINFO             55
 
+#define SO_INCOMING_NAPI_ID    56
+
 #endif /* __ASM_GENERIC_SOCKET_H */
index 4b762f2..1a58a9d 100644 (file)
@@ -1328,6 +1328,18 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 
                goto lenout;
        }
+
+#ifdef CONFIG_NET_RX_BUSY_POLL
+       case SO_INCOMING_NAPI_ID:
+               v.val = READ_ONCE(sk->sk_napi_id);
+
+               /* aggregate non-NAPI IDs down to 0 */
+               if (v.val < MIN_NAPI_ID)
+                       v.val = 0;
+
+               break;
+#endif
+
        default:
                /* We implement the SO_SNDLOWAT etc to not be settable
                 * (1003.1g 7).