|
19 | 19 |
|
20 | 20 | #define NVMET_TCP_DEF_INLINE_DATA_SIZE (4 * PAGE_SIZE)
|
21 | 21 |
|
| 22 | +/* Define the socket priority to use for connections were it is desirable |
| 23 | + * that the NIC consider performing optimized packet processing or filtering. |
| 24 | + * A non-zero value being sufficient to indicate general consideration of any |
| 25 | + * possible optimization. Making it a module param allows for alternative |
| 26 | + * values that may be unique for some NIC implementations. |
| 27 | + */ |
| 28 | +static int so_priority; |
| 29 | +module_param(so_priority, int, 0644); |
| 30 | +MODULE_PARM_DESC(so_priority, "nvmet tcp socket optimize priority"); |
| 31 | + |
22 | 32 | #define NVMET_TCP_RECV_BUDGET 8
|
23 | 33 | #define NVMET_TCP_SEND_BUDGET 8
|
24 | 34 | #define NVMET_TCP_IO_WORK_BUDGET 64
|
@@ -1433,6 +1443,13 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue)
|
1433 | 1443 | if (ret)
|
1434 | 1444 | return ret;
|
1435 | 1445 |
|
| 1446 | + if (so_priority > 0) { |
| 1447 | + ret = kernel_setsockopt(sock, SOL_SOCKET, SO_PRIORITY, |
| 1448 | + (char *)&so_priority, sizeof(so_priority)); |
| 1449 | + if (ret) |
| 1450 | + return ret; |
| 1451 | + } |
| 1452 | + |
1436 | 1453 | /* Set socket type of service */
|
1437 | 1454 | if (inet->rcv_tos > 0) {
|
1438 | 1455 | int tos = inet->rcv_tos;
|
@@ -1622,6 +1639,15 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport)
|
1622 | 1639 | goto err_sock;
|
1623 | 1640 | }
|
1624 | 1641 |
|
| 1642 | + if (so_priority > 0) { |
| 1643 | + ret = kernel_setsockopt(port->sock, SOL_SOCKET, SO_PRIORITY, |
| 1644 | + (char *)&so_priority, sizeof(so_priority)); |
| 1645 | + if (ret) { |
| 1646 | + pr_err("failed to set SO_PRIORITY sock opt %d\n", ret); |
| 1647 | + goto err_sock; |
| 1648 | + } |
| 1649 | + } |
| 1650 | + |
1625 | 1651 | ret = kernel_bind(port->sock, (struct sockaddr *)&port->addr,
|
1626 | 1652 | sizeof(port->addr));
|
1627 | 1653 | if (ret) {
|
|
0 commit comments