net: move ether_crc to tsec driver
authorChris Packham <judge.packham@gmail.com>
Mon, 26 Nov 2018 08:00:28 +0000 (21:00 +1300)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 24 Jan 2019 17:35:29 +0000 (11:35 -0600)
ether_crc was added to the core net code in commit 53a5c424bf86
("multicast tftp: RFC2090") so that other drivers could use it. However
the only current user of it is tsec.c so move it there.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
drivers/net/tsec.c
include/net.h
net/eth_legacy.c

index 03a46da..9a4fab8 100644 (file)
@@ -80,6 +80,31 @@ static void tsec_configure_serdes(struct tsec_private *priv)
 
 #ifdef CONFIG_MCAST_TFTP
 
+/* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c
+ * and this is the ethernet-crc method needed for TSEC -- and perhaps
+ * some other adapter -- hash tables
+ */
+#define CRCPOLY_LE 0xedb88320
+static u32 ether_crc(size_t len, unsigned char const *p)
+{
+       int i;
+       u32 crc;
+
+       crc = ~0;
+       while (len--) {
+               crc ^= *p++;
+               for (i = 0; i < 8; i++)
+                       crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+       }
+       /* an reverse the bits, cuz of way they arrive -- last-first */
+       crc = (crc >> 16) | (crc << 16);
+       crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
+       crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0);
+       crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc);
+       crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa);
+       return crc;
+}
+
 /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
 
 /* Set the appropriate hash bit for the given addr */
index 51c099d..359bfb5 100644 (file)
@@ -289,7 +289,6 @@ const char *eth_get_name(void);             /* get name of current device */
 
 #ifdef CONFIG_MCAST_TFTP
 int eth_mcast_join(struct in_addr mcast_addr, int join);
-u32 ether_crc(size_t len, unsigned char const *p);
 #endif
 
 
index 2a9caa3..d2e16b8 100644 (file)
@@ -310,30 +310,6 @@ int eth_mcast_join(struct in_addr mcast_ip, int join)
        return eth_current->mcast(eth_current, mcast_mac, join);
 }
 
-/* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c
- * and this is the ethernet-crc method needed for TSEC -- and perhaps
- * some other adapter -- hash tables
- */
-#define CRCPOLY_LE 0xedb88320
-u32 ether_crc(size_t len, unsigned char const *p)
-{
-       int i;
-       u32 crc;
-       crc = ~0;
-       while (len--) {
-               crc ^= *p++;
-               for (i = 0; i < 8; i++)
-                       crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
-       }
-       /* an reverse the bits, cuz of way they arrive -- last-first */
-       crc = (crc >> 16) | (crc << 16);
-       crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
-       crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0);
-       crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc);
-       crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa);
-       return crc;
-}
-
 #endif