Skip to content

Commit 9912ade

Browse files
mwwunderkeithbusch
authored andcommitted
nvme-tcp: Set SO_PRIORITY for all host sockets
Enable ability to associate all sockets related to NVMf TCP traffic to a priority group that will perform optimized network processing for this traffic class. Maintain initial default behavior of using priority of zero. Signed-off-by: Kiran Patil <[email protected]> Signed-off-by: Mark Wunderlich <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent d3a9b0c commit 9912ade

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/nvme/host/tcp.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020

2121
struct nvme_tcp_queue;
2222

23+
/* Define the socket priority to use for connections were it is desirable
24+
* that the NIC consider performing optimized packet processing or filtering.
25+
* A non-zero value being sufficient to indicate general consideration of any
26+
* possible optimization. Making it a module param allows for alternative
27+
* values that may be unique for some NIC implementations.
28+
*/
29+
static int so_priority;
30+
module_param(so_priority, int, 0644);
31+
MODULE_PARM_DESC(so_priority, "nvme tcp socket optimize priority");
32+
2333
enum nvme_tcp_send_state {
2434
NVME_TCP_SEND_CMD_PDU = 0,
2535
NVME_TCP_SEND_H2C_PDU,
@@ -1309,6 +1319,17 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,
13091319
goto err_sock;
13101320
}
13111321

1322+
if (so_priority > 0) {
1323+
ret = kernel_setsockopt(queue->sock, SOL_SOCKET, SO_PRIORITY,
1324+
(char *)&so_priority, sizeof(so_priority));
1325+
if (ret) {
1326+
dev_err(ctrl->ctrl.device,
1327+
"failed to set SO_PRIORITY sock opt, ret %d\n",
1328+
ret);
1329+
goto err_sock;
1330+
}
1331+
}
1332+
13121333
/* Set socket type of service */
13131334
if (nctrl->opts->tos >= 0) {
13141335
opt = nctrl->opts->tos;

0 commit comments

Comments
 (0)