Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Aug 2015 11:31:59 GMT
From:      iateaca@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r289057 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve
Message-ID:  <201508011131.t71BVxQ6011500@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: iateaca
Date: Sat Aug  1 11:31:59 2015
New Revision: 289057
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289057

Log:
  copy the ether_crc32_be function from the net kernel module in the FreeBSD tree sources into my ne2000_ether_crc32_be

Modified:
  soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c

Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c
==============================================================================
--- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c	Sat Aug  1 10:40:17 2015	(r289056)
+++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c	Sat Aug  1 11:31:59 2015	(r289057)
@@ -150,6 +150,9 @@
 static int
 ne2000_ether_frame_is_valid(struct pci_ne2000_softc *sc);
 
+static uint32_t
+ne2000_ether_crc32_be(const uint8_t *buf, size_t len);
+
 static int
 ne2000_parse_input(char *opts, char *tap_name, uint8_t *mac);
 
@@ -449,6 +452,32 @@
 	return 0;
 }
 
+/*
+ * This function is a copy of the ether_crc32_be function from the net kernel
+ * module in the FreeBSD tree sources
+ */
+static uint32_t
+ne2000_ether_crc32_be(const uint8_t *buf, size_t len)
+{
+	size_t i;
+	uint32_t crc, carry;
+	int bit;
+	uint8_t data;
+
+	crc = 0xffffffff;	/* initial value */
+
+	for (i = 0; i < len; i++) {
+		for (data = *buf++, bit = 0; bit < 8; bit++, data >>= 1) {
+			carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
+			crc <<= 1;
+			if (carry)
+				crc = (crc ^ ETHER_CRC_POLY_BE) | carry;
+		}
+	}
+
+	return (crc);
+}
+
 static int
 ne2000_parse_input(char *opts, char *tap_name, uint8_t *mac)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508011131.t71BVxQ6011500>