Date: Thu, 18 Jun 2020 10:12:17 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r362306 - stable/11/sys/dev/mlx5/mlx5_en Message-ID: <202006181012.05IACHh6061491@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Jun 18 10:12:17 2020 New Revision: 362306 URL: https://svnweb.freebsd.org/changeset/base/362306 Log: 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 Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:08:41 2020 (r362305) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:12:17 2020 (r362306) @@ -173,18 +173,26 @@ max_inline: return (MIN(mb->m_pkthdr.len, sq->max_inline)); } +/* + * 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_full_header_size(struct mbuf *mb) +mlx5e_get_full_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)) { @@ -198,7 +206,7 @@ mlx5e_get_full_header_size(struct mbuf *mb) } 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); switch (ip->ip_p) { @@ -215,7 +223,7 @@ mlx5e_get_full_header_size(struct mbuf *mb) } 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); switch (ip6->ip6_nxt) { @@ -234,7 +242,7 @@ mlx5e_get_full_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; done:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006181012.05IACHh6061491>