Commit 9912ade3 authored by Wunderlich, Mark's avatar Wunderlich, Mark Committed by Keith Busch
Browse files

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: default avatarKiran Patil <kiran.patil@intel.com>
Signed-off-by: default avatarMark Wunderlich <mark.wunderlich@intel.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent d3a9b0ca
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,16 @@


struct nvme_tcp_queue;
struct nvme_tcp_queue;


/* Define the socket priority to use for connections were it is desirable
 * that the NIC consider performing optimized packet processing or filtering.
 * A non-zero value being sufficient to indicate general consideration of any
 * possible optimization.  Making it a module param allows for alternative
 * values that may be unique for some NIC implementations.
 */
static int so_priority;
module_param(so_priority, int, 0644);
MODULE_PARM_DESC(so_priority, "nvme tcp socket optimize priority");

enum nvme_tcp_send_state {
enum nvme_tcp_send_state {
	NVME_TCP_SEND_CMD_PDU = 0,
	NVME_TCP_SEND_CMD_PDU = 0,
	NVME_TCP_SEND_H2C_PDU,
	NVME_TCP_SEND_H2C_PDU,
@@ -1309,6 +1319,17 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,
		goto err_sock;
		goto err_sock;
	}
	}


	if (so_priority > 0) {
		ret = kernel_setsockopt(queue->sock, SOL_SOCKET, SO_PRIORITY,
				(char *)&so_priority, sizeof(so_priority));
		if (ret) {
			dev_err(ctrl->ctrl.device,
				"failed to set SO_PRIORITY sock opt, ret %d\n",
				ret);
			goto err_sock;
		}
	}

	/* Set socket type of service */
	/* Set socket type of service */
	if (nctrl->opts->tos >= 0) {
	if (nctrl->opts->tos >= 0) {
		opt = nctrl->opts->tos;
		opt = nctrl->opts->tos;