[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240130053438.945789-1-hayatake396@gmail.com>
Date: Tue, 30 Jan 2024 05:34:38 +0000
From: Takeru Hayasaka <hayatake396@...il.com>
To: netdev@...r.kernel.org
Cc: mkubecek@...e.cz,
Takeru Hayasaka <hayatake396@...il.com>
Subject: [PATCH ethtool-next v2] ethtool: add support for rx-flow-hash gtp
GTP Flow hash was added to the ice driver.
By executing "ethtool -N <dev> rx-flow-hash gtpu4 sde", RSS can include
not only the IP's src/dst but also the TEID of GTP packets.
Additionally, options <e> have been support.
These allow specification to include TEID in the hash computation.
Signed-off-by: Takeru Hayasaka <hayatake396@...il.com>
---
update to object flow_type.
ethtool.c | 71 ++++++++++++++++++++++++++++++++++++++++++--
uapi/linux/ethtool.h | 41 +++++++++++++++++++++++++
2 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 3ac15a7..05596c1 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -360,6 +360,18 @@ static int rxflow_str_to_type(const char *str)
flow_type = AH_ESP_V4_FLOW;
else if (!strcmp(str, "sctp4"))
flow_type = SCTP_V4_FLOW;
+ else if (!strcmp(str, "gtpc4"))
+ flow_type = GTPC_V4_FLOW;
+ else if (!strcmp(str, "gtpc4t"))
+ flow_type = GTPC_TEID_V4_FLOW;
+ else if (!strcmp(str, "gtpu4"))
+ flow_type = GTPU_V4_FLOW;
+ else if (!strcmp(str, "gtpu4e"))
+ flow_type = GTPU_EH_V4_FLOW;
+ else if (!strcmp(str, "gtpu4u"))
+ flow_type = GTPU_UL_V4_FLOW;
+ else if (!strcmp(str, "gtpu4d"))
+ flow_type = GTPU_DL_V4_FLOW;
else if (!strcmp(str, "tcp6"))
flow_type = TCP_V6_FLOW;
else if (!strcmp(str, "udp6"))
@@ -370,6 +382,18 @@ static int rxflow_str_to_type(const char *str)
flow_type = SCTP_V6_FLOW;
else if (!strcmp(str, "ether"))
flow_type = ETHER_FLOW;
+ else if (!strcmp(str, "gtpc6"))
+ flow_type = GTPC_V6_FLOW;
+ else if (!strcmp(str, "gtpc6t"))
+ flow_type = GTPC_TEID_V6_FLOW;
+ else if (!strcmp(str, "gtpu6"))
+ flow_type = GTPU_V6_FLOW;
+ else if (!strcmp(str, "gtpu6e"))
+ flow_type = GTPU_EH_V6_FLOW;
+ else if (!strcmp(str, "gtpu6u"))
+ flow_type = GTPU_UL_V6_FLOW;
+ else if (!strcmp(str, "gtpu6d"))
+ flow_type = GTPU_DL_V6_FLOW;
return flow_type;
}
@@ -1010,6 +1034,9 @@ static int parse_rxfhashopts(char *optstr, u32 *data)
case 'n':
*data |= RXH_L4_B_2_3;
break;
+ case 'e':
+ *data |= RXH_GTP_TEID;
+ break;
case 'r':
*data |= RXH_DISCARD;
break;
@@ -1042,6 +1069,8 @@ static char *unparse_rxfhashopts(u64 opts)
strcat(buf, "L4 bytes 0 & 1 [TCP/UDP src port]\n");
if (opts & RXH_L4_B_2_3)
strcat(buf, "L4 bytes 2 & 3 [TCP/UDP dst port]\n");
+ if (opts & RXH_GTP_TEID)
+ strcat(buf, "GTP TEID\n");
} else {
sprintf(buf, "None");
}
@@ -1559,6 +1588,24 @@ static int dump_rxfhash(int fhash, u64 val)
case SCTP_V4_FLOW:
fprintf(stdout, "SCTP over IPV4 flows");
break;
+ case GTPC_V4_FLOW:
+ fprintf(stdout, "GTP-C over IPV4 flows");
+ break;
+ case GTPC_TEID_V4_FLOW:
+ fprintf(stdout, "GTP-C (include TEID) over IPV4 flows");
+ break;
+ case GTPU_V4_FLOW:
+ fprintf(stdout, "GTP-U over IPV4 flows");
+ break;
+ case GTPU_EH_V4_FLOW:
+ fprintf(stdout, "GTP-U and Extension Header over IPV4 flows");
+ break;
+ case GTPU_UL_V4_FLOW:
+ fprintf(stdout, "GTP-U PSC Uplink over IPV4 flows");
+ break;
+ case GTPU_DL_V4_FLOW:
+ fprintf(stdout, "GTP-U PSC Downlink over IPV4 flows");
+ break;
case AH_ESP_V4_FLOW:
case AH_V4_FLOW:
case ESP_V4_FLOW:
@@ -1573,6 +1620,24 @@ static int dump_rxfhash(int fhash, u64 val)
case SCTP_V6_FLOW:
fprintf(stdout, "SCTP over IPV6 flows");
break;
+ case GTPC_V6_FLOW:
+ fprintf(stdout, "GTP-C over IPV6 flows");
+ break;
+ case GTPC_TEID_V6_FLOW:
+ fprintf(stdout, "GTP-C (include TEID) over IPV6 flows");
+ break;
+ case GTPU_V6_FLOW:
+ fprintf(stdout, "GTP-U over IPV6 flows");
+ break;
+ case GTPU_EH_V6_FLOW:
+ fprintf(stdout, "GTP-U and Extension Header over IPV6 flows");
+ break;
+ case GTPU_UL_V6_FLOW:
+ fprintf(stdout, "GTP-U PSC Uplink over IPV6 flows");
+ break;
+ case GTPU_DL_V6_FLOW:
+ fprintf(stdout, "GTP-U PSC Downlink over IPV6 flows");
+ break;
case AH_ESP_V6_FLOW:
case AH_V6_FLOW:
case ESP_V6_FLOW:
@@ -5834,7 +5899,8 @@ static const struct option args[] = {
.func = do_grxclass,
.help = "Show Rx network flow classification options or rules",
.xhelp = " [ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|"
- "tcp6|udp6|ah6|esp6|sctp6 [context %d] |\n"
+ "gtpc4|gtpc4t|gtpu4|gtpu4e|gtpu4u|gtpu4d|tcp6|udp6|ah6|esp6|sctp6|"
+ "gtpc6|gtpc6t|gtpu6|gtpu6e|gtpu6u|gtpu6d [context %d] |\n"
" rule %d ]\n"
},
{
@@ -5842,7 +5908,8 @@ static const struct option args[] = {
.func = do_srxclass,
.help = "Configure Rx network flow classification options or rules",
.xhelp = " rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|"
- "tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r... [context %d] |\n"
+ "gtpc4|gtpc4t|gtpu4|gtpu4e|gtpu4u|gtpu4d|tcp6|udp6|ah6|esp6|sctp6"
+ "|gtpc6|gtpc6t|gtpu6|gtpu6e|gtpu6u|gtpu6d m|v|t|s|d|f|n|r|e... [context %d] |\n"
" flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4|"
"ip6|tcp6|udp6|ah6|esp6|sctp6\n"
" [ src %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]\n"
diff --git a/uapi/linux/ethtool.h b/uapi/linux/ethtool.h
index 70f2b90..d0dfffe 100644
--- a/uapi/linux/ethtool.h
+++ b/uapi/linux/ethtool.h
@@ -2021,6 +2021,46 @@ static __inline__ int ethtool_validate_duplex(__u8 duplex)
#define IPV4_FLOW 0x10 /* hash only */
#define IPV6_FLOW 0x11 /* hash only */
#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
+/* Used for GTP-U IPv4 and IPv6.
+ * The format of GTP packets only includes
+ * elements such as TEID and GTP version.
+ * It is primarily intended for data communication of the UE.
+ */
+#define GTPU_V4_FLOW 0x13 /* hash only */
+#define GTPU_V6_FLOW 0x14 /* hash only */
+/* Use for GTP-C IPv4 and v6.
+ * The format of these GTP packets does not include TEID.
+ * Primarily expected to be used for communication
+ * to create sessions for UE data communication,
+ * commonly referred to as CSR (Create Session Request).
+ */
+#define GTPC_V4_FLOW 0x15 /* hash only */
+#define GTPC_V6_FLOW 0x16 /* hash only */
+/* Use for GTP-C IPv4 and v6.
+ * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID.
+ * After session creation, it becomes this packet.
+ * This is mainly used for requests to realize UE handover.
+ */
+#define GTPC_TEID_V4_FLOW 0x17 /* hash only */
+#define GTPC_TEID_V6_FLOW 0x18 /* hash only */
+/* Use for GTP-U and extended headers for the PDU session container(PSC).
+ * The format of these GTP packets includes TEID and QFI.
+ * In 5G communication using UPF (User Plane Function),
+ * data communication with this extended header is performed.
+ */
+#define GTPU_EH_V4_FLOW 0x19 /* hash only */
+#define GTPU_EH_V6_FLOW 0x1a /* hash only */
+/* Use for GTP-U IPv4 and v6 PDU session container(PSC) extended headers.
+ * The difference from before is distinguishing based on the PSC.
+ * There are differences in the data included based on Downlink/Uplink,
+ * and can be used to distinguish packets.
+ * The functions described so far are useful when you want to
+ * handle communication from the mobile network in UPF, PGW, etc.
+ */
+#define GTPU_UL_V4_FLOW 0x1b /* hash only */
+#define GTPU_UL_V6_FLOW 0x1c /* hash only */
+#define GTPU_DL_V4_FLOW 0x1d /* hash only */
+#define GTPU_DL_V6_FLOW 0x1e /* hash only */
/* Flag to enable additional fields in struct ethtool_rx_flow_spec */
#define FLOW_EXT 0x80000000
#define FLOW_MAC_EXT 0x40000000
@@ -2035,6 +2075,7 @@ static __inline__ int ethtool_validate_duplex(__u8 duplex)
#define RXH_IP_DST (1 << 5)
#define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */
#define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */
+#define RXH_GTP_TEID (1 << 8) /* teid in case of GTP */
#define RXH_DISCARD (1 << 31)
#define RX_CLS_FLOW_DISC 0xffffffffffffffffULL
--
2.34.1
Powered by blists - more mailing lists