Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_hpts.c
Show All 22 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_rss.h" | |||||
#include "opt_tcpdebug.h" | #include "opt_tcpdebug.h" | ||||
/** | /** | ||||
* Some notes about usage. | * Some notes about usage. | ||||
* | * | ||||
* The tcp_hpts system is designed to provide a high precision timer | * The tcp_hpts system is designed to provide a high precision timer | ||||
* system for tcp. Its main purpose is to provide a mechanism for | * system for tcp. Its main purpose is to provide a mechanism for | ||||
* pacing packets out onto the wire. It can be used in two ways | * pacing packets out onto the wire. It can be used in two ways | ||||
* by a given TCP stack (and those two methods can be used simultaneously). | * by a given TCP stack (and those two methods can be used simultaneously). | ||||
* | * | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
#include <sys/kern_prefetch.h> | #include <sys/kern_prefetch.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#ifdef RSS | |||||
#include <net/netisr.h> | |||||
#include <net/rss_config.h> | |||||
#endif | |||||
#define TCPSTATES /* for logging */ | #define TCPSTATES /* for logging */ | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/in_kdtrace.h> | #include <netinet/in_kdtrace.h> | ||||
#include <netinet/in_pcb.h> | #include <netinet/in_pcb.h> | ||||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||||
#include <netinet/ip_icmp.h> /* required for icmp_var.h */ | #include <netinet/ip_icmp.h> /* required for icmp_var.h */ | ||||
#include <netinet/icmp_var.h> /* for ICMP_BANDLIM */ | #include <netinet/icmp_var.h> /* for ICMP_BANDLIM */ | ||||
Show All 13 Lines | |||||
#ifdef tcpdebug | #ifdef tcpdebug | ||||
#include <netinet/tcp_debug.h> | #include <netinet/tcp_debug.h> | ||||
#endif /* tcpdebug */ | #endif /* tcpdebug */ | ||||
#ifdef tcp_offload | #ifdef tcp_offload | ||||
#include <netinet/tcp_offload.h> | #include <netinet/tcp_offload.h> | ||||
#endif | #endif | ||||
#include "opt_rss.h" | |||||
MALLOC_DEFINE(M_TCPHPTS, "tcp_hpts", "TCP hpts"); | MALLOC_DEFINE(M_TCPHPTS, "tcp_hpts", "TCP hpts"); | ||||
#ifdef RSS | #ifdef RSS | ||||
static int tcp_bind_threads = 1; | static int tcp_bind_threads = 1; | ||||
#else | #else | ||||
static int tcp_bind_threads = 2; | static int tcp_bind_threads = 2; | ||||
#endif | #endif | ||||
TUNABLE_INT("net.inet.tcp.bind_hptss", &tcp_bind_threads); | TUNABLE_INT("net.inet.tcp.bind_hptss", &tcp_bind_threads); | ||||
▲ Show 20 Lines • Show All 952 Lines • ▼ Show 20 Lines | if (inp->inp_input_cpu_set) { | ||||
return (inp->inp_hpts_cpu); | return (inp->inp_hpts_cpu); | ||||
} | } | ||||
/* Nothing set use a random number */ | /* Nothing set use a random number */ | ||||
ran = arc4random(); | ran = arc4random(); | ||||
cpuid = (ran & 0xffff) % mp_ncpus; | cpuid = (ran & 0xffff) % mp_ncpus; | ||||
return (cpuid); | return (cpuid); | ||||
} | } | ||||
static uint16_t | static uint16_t | ||||
donner: should this also be u_int? | |||||
bzAuthorUnsubmitted Done Inline ActionsYes in theory and in a lot more places that will be on the trail of all this. That's why I mentioned that it needs to be cleaned up. bz: Yes in theory and in a lot more places that will be on the trail of all this. That's why I… | |||||
hpts_cpuid(struct inpcb *inp){ | hpts_cpuid(struct inpcb *inp) | ||||
{ | |||||
u_int cpuid; | u_int cpuid; | ||||
#ifdef NUMA | #if !defined(RSS) && defined(NUMA) | ||||
struct hpts_domain_info *di; | struct hpts_domain_info *di; | ||||
#endif | #endif | ||||
/* | /* | ||||
* If one has been set use it i.e. we want both in and out on the | * If one has been set use it i.e. we want both in and out on the | ||||
* same hpts. | * same hpts. | ||||
*/ | */ | ||||
if (inp->inp_input_cpu_set) { | if (inp->inp_input_cpu_set) { | ||||
return (inp->inp_input_cpu); | return (inp->inp_input_cpu); | ||||
} else if (inp->inp_hpts_cpu_set) { | } else if (inp->inp_hpts_cpu_set) { | ||||
return (inp->inp_hpts_cpu); | return (inp->inp_hpts_cpu); | ||||
} | } | ||||
/* If one is set the other must be the same */ | /* If one is set the other must be the same */ | ||||
#ifdef RSS | #ifdef RSS | ||||
bzAuthorUnsubmitted Done Inline ActionsI am aware that there is some whitspace noise in here as well... bz: I am aware that there is some whitspace noise in here as well... | |||||
cpuid = rss_hash2cpuid(inp->inp_flowid, inp->inp_flowtype); | cpuid = rss_hash2cpuid(inp->inp_flowid, inp->inp_flowtype); | ||||
if (cpuid == NETISR_CPUID_NONE) | if (cpuid == NETISR_CPUID_NONE) | ||||
return (hpts_random_cpu(inp)); | return (hpts_random_cpu(inp)); | ||||
else | else | ||||
return (cpuid); | return (cpuid); | ||||
#else | #else | ||||
/* | /* | ||||
* We don't have a flowid -> cpuid mapping, so cheat and just map | * We don't have a flowid -> cpuid mapping, so cheat and just map | ||||
▲ Show 20 Lines • Show All 834 Lines • Show Last 20 Lines |
should this also be u_int?