Hardware Checksum support on NetBSD-current(3)

dev/pci/if_wm.cとかを読んでると、

		/*
		 * Set up checksum info for this packet.
		 */
		if ((status & WRX_ST_IXSM) == 0) {
			if (status & WRX_ST_IPCS) {
				WM_EVCNT_INCR(&sc->sc_ev_rxipsum);
				m->m_pkthdr.csum_flags |= M_CSUM_IPv4;
				if (errors & WRX_ER_IPE)
					m->m_pkthdr.csum_flags |=
					    M_CSUM_IPv4_BAD;

とかいうコードが出てくる。

なので、m->m_pkthdrも見てみることにした:

/*
 * record/packet header in first mbuf of chain; valid if M_PKTHDR set
 *
 * A note about csum_data: For the out-bound direction, the low 16 bits
 * indicates the offset after the L4 header where the final L4 checksum value
 * is to be stored and the high 16 bits is the length of the L3 header (the
 * start of the data to be checksumed).  For the in-bound direction, it is only
 * valid if the M_CSUM_DATA flag is set.  In this case, an L4 checksum has been
 * calculated by hardware, but it is up to software to perform final
 * verification.
 *
 * Note for in-bound TCP/UDP checksums, we expect the csum_data to NOT
 * be bit-wise inverted (the final step in the calculation of an IP
 * checksum) -- this is so we can accumulate the checksum for fragmented
 * packets during reassembly.
 */
struct	pkthdr {
	struct	ifnet *rcvif;		/* rcv interface */
	SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
	int	len;			/* total packet length */
	int	csum_flags;		/* checksum flags */
	uint32_t csum_data;		/* checksum data */
	u_int	segsz;			/* segment size */
};

csum_dataの意味が書いてある。

下位16bitがL4 checksum valueへのオフセットで上位16bitがL3ヘッダの長さって言ってる?
本当かどうかはもう少し読み込んでみないと良く分からん。

csum_flags |= M_CSUM_TCP_UDP_BADはL4 checksum errorなんだろうけれど、
csum_flags |= M_CSUM_TCPv4というのはどういう意味だろう?
単にTCPでした、って言ってるのか?