8 .Nd Provide Receive-side scaling awareness to userland applications
13 .Ft struct rss_config *
14 .Fn rss_config_get "void"
16 .Fn rss_config_free "struct rss_config *cfg"
18 .Fn rss_config_get_bucket_count "struct rss_config *cfg"
20 .Fn rss_set_bucket_rebalance_cb "rss_bucket_rebalance_cb_t *cb" "void *cbdata"
22 .Fn rss_sock_set_bindmulti "int fd" "int af" "int val"
24 .Fn rss_sock_set_rss_bucket "int fd" "int af" "int rss_bucket"
26 .Fn rss_sock_set_recvrss "int fd" "int af" "int val"
30 library and the functions it provides are used for both fetching
31 the system RSS configuration and interacting with RSS aware
34 Applications will typically call
36 to fetch the current RSS configuration from the system and perform
38 This typically involves spawning worker threads, one per RSS bucket,
39 and optionally binding them to the per-bucket CPU set.
53 Applications will typically use the
54 .Fn rss_config_get_bucket_count
55 function to fetch the number of RSS buckets, create one thread
56 per RSS bucket for RSS aware work, then one RSS aware socket to receive
57 UDP datagrams or TCP connections
58 in each particular RSS bucket / thread.
61 .Fn rss_get_bucket_cpuset
62 function sets the given cpuset up for the given
63 RSS bucket and behaviour.
64 Typically applications will wish to just query for
65 .Vt RSS_BUCKET_TYPE_KERNEL_ALL
66 unless they wish to potentially setup different
67 worker threads for transmit and receive.
74 RSS_BUCKET_TYPE_NONE = 0,
75 RSS_BUCKET_TYPE_KERNEL_ALL = 1,
76 RSS_BUCKET_TYPE_KERNEL_TX = 2,
77 RSS_BUCKET_TYPE_KERNEL_RX = 3,
78 RSS_BUCKET_TYPE_MAX = 3,
82 The rebalance callback
83 .Vt rss_bucket_rebalance_cb_t
86 typedef void rss_bucket_rebalance_cb_t(void *arg);
90 .Fn rss_set_bucket_rebalance_cb
91 function sets an optional callback that will be called if the kernel
92 rebalances RSS buckets.
93 This is intended as a future expansion to rebalance buckets rather than
94 reprogram the RSS key, so typically the only work to be performed
95 is to rebind worker threads to an updated cpuset.
97 Once RSS setup is completed,
99 is called to free the RSS configuration structure.
103 socket RSS aware, the
104 .Fn rss_sock_set_bindmulti
105 function is used to enable or disable per-RSS bucket
107 The socket filedescriptor, address family and enable flag
113 is set to 1, the socket can be placed in an RSS bucket and will only accept
114 datagrams (for UDP) or connections (for TCP) that are received for that
116 If set to 0, the socket is placed in the default PCB and will see
117 datagrams/connections that are not initially consumed by a PCB aware
121 .Fn rss_sock_set_rss_bucket
122 function configures the RSS bucket which a socket belongs in.
123 Note that TCP sockets created by
125 will automatically be assigned to the RSS bucket.
128 .Fn rss_sock_set_recvrss
129 function enables or disables receiving RSS related information
130 as socket options in.
134 When enabled, UDP datagrams will have a message with the
136 option indicating the 32-bit receive flowid as a uint32_t,
138 .Vt IP_RECVRSSBUCKETID
139 option indicating the 32 bit RSS bucket id as a uint32_t.
141 The functions return either <0 or NULL as appropriate upon error.
147 library first appeared in
150 .An Adrian Chadd Aq Mt adrian@FreeBSD.org
152 There is currently no kernel mechanism to rebalance the RSS bucket to CPU
153 mapping, and so the callback mechanism is a no-op.