aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-06-18 10:17:36 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-06-18 10:17:36 +0000
commit73356f025754fa313d4aab17a2afc0acc41e9c0d (patch)
treedf3fbfaadfc365afa6407d57b022b455fbf829a2
parent3e776406b031a85604827eaeb15b5e535e29987a (diff)
downloadsrc-73356f025754fa313d4aab17a2afc0acc41e9c0d.tar.gz
src-73356f025754fa313d4aab17a2afc0acc41e9c0d.zip
MFC r362043:
Use const keyword when parsing the TCP/IP header in the fast path in mlx5en(4). When parsing the TCP/IP header in the fast path, make it clear by using the const keyword, no fields are to be modified inside the transmitted packet. No functional change. Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/stable/10/; revision=362307
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_tx.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
index 6e32455b8285..92a5ad6968ce 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
@@ -176,18 +176,26 @@ mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq, struct mbuf *mb)
return (MIN(sq->max_inline, mb->m_pkthdr.len));
}
+/*
+ * This function parse IPv4 and IPv6 packets looking for TCP and UDP
+ * headers.
+ *
+ * The return value indicates the number of bytes from the beginning
+ * of the packet until the first byte after the TCP or UDP header. If
+ * this function returns zero, the parsing failed.
+ */
static int
-mlx5e_get_header_size(struct mbuf *mb)
+mlx5e_get_header_size(const struct mbuf *mb)
{
- struct ether_vlan_header *eh;
- struct tcphdr *th;
- struct ip *ip;
+ const struct ether_vlan_header *eh;
+ const struct tcphdr *th;
+ const struct ip *ip;
int ip_hlen, tcp_hlen;
- struct ip6_hdr *ip6;
+ const struct ip6_hdr *ip6;
uint16_t eth_type;
int eth_hdr_len;
- eh = mtod(mb, struct ether_vlan_header *);
+ eh = mtod(mb, const struct ether_vlan_header *);
if (mb->m_len < ETHER_HDR_LEN)
return (0);
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
@@ -201,7 +209,7 @@ mlx5e_get_header_size(struct mbuf *mb)
return (0);
switch (eth_type) {
case ETHERTYPE_IP:
- ip = (struct ip *)(mb->m_data + eth_hdr_len);
+ ip = (const struct ip *)(mb->m_data + eth_hdr_len);
if (mb->m_len < eth_hdr_len + sizeof(*ip))
return (0);
if (ip->ip_p != IPPROTO_TCP)
@@ -210,7 +218,7 @@ mlx5e_get_header_size(struct mbuf *mb)
eth_hdr_len += ip_hlen;
break;
case ETHERTYPE_IPV6:
- ip6 = (struct ip6_hdr *)(mb->m_data + eth_hdr_len);
+ ip6 = (const struct ip6_hdr *)(mb->m_data + eth_hdr_len);
if (mb->m_len < eth_hdr_len + sizeof(*ip6))
return (0);
if (ip6->ip6_nxt != IPPROTO_TCP)
@@ -222,7 +230,7 @@ mlx5e_get_header_size(struct mbuf *mb)
}
if (mb->m_len < eth_hdr_len + sizeof(*th))
return (0);
- th = (struct tcphdr *)(mb->m_data + eth_hdr_len);
+ th = (const struct tcphdr *)(mb->m_data + eth_hdr_len);
tcp_hlen = th->th_off << 2;
eth_hdr_len += tcp_hlen;
if (mb->m_len < eth_hdr_len)