From owner-svn-soc-all@freebsd.org Sat Aug 1 11:32:00 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E3F69B0652 for ; Sat, 1 Aug 2015 11:32:00 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F18F1D23 for ; Sat, 1 Aug 2015 11:32:00 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t71BW0Ot011519 for ; Sat, 1 Aug 2015 11:32:00 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t71BVxQ6011500 for svn-soc-all@FreeBSD.org; Sat, 1 Aug 2015 11:31:59 GMT (envelope-from iateaca@FreeBSD.org) Date: Sat, 1 Aug 2015 11:31:59 GMT Message-Id: <201508011131.t71BVxQ6011500@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289057 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Aug 2015 11:32:00 -0000 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) {