svn commit: r362305 - stable/12/sys/dev/mlx5/mlx5_en

Hans Petter Selasky hselasky at FreeBSD.org
Thu Jun 18 10:08:42 UTC 2020


Author: hselasky
Date: Thu Jun 18 10:08:41 2020
New Revision: 362305
URL: https://svnweb.freebsd.org/changeset/base/362305

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/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c	Thu Jun 18 10:03:17 2020	(r362304)
+++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c	Thu Jun 18 10:08:41 2020	(r362305)
@@ -214,18 +214,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)) {
@@ -239,7 +247,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) {
@@ -256,7 +264,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) {
@@ -275,7 +283,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:


More information about the svn-src-all mailing list