diff mbox series

[U-Boot,1/2] net: move ether_crc to tsec driver

Message ID 20181126080029.27738-1-judge.packham@gmail.com
State Accepted
Commit 1a4af5c562fdb9f5a884a53f136f2b2075ffd1d8
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/2] net: move ether_crc to tsec driver | expand

Commit Message

Chris Packham Nov. 26, 2018, 8 a.m. UTC
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>
---

 drivers/net/tsec.c | 25 +++++++++++++++++++++++++
 include/net.h      |  1 -
 net/eth_legacy.c   | 24 ------------------------
 3 files changed, 25 insertions(+), 25 deletions(-)

Comments

Simon Goldschmidt Nov. 26, 2018, 8:12 a.m. UTC | #1
On Mon, Nov 26, 2018 at 9:00 AM Chris Packham <judge.packham@gmail.com> wrote:
>
> 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>
> ---
>
>  drivers/net/tsec.c | 25 +++++++++++++++++++++++++
>  include/net.h      |  1 -
>  net/eth_legacy.c   | 24 ------------------------
>  3 files changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index 03a46da2f8a1..9a4fab85e928 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -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)

I haven't checked, but can't we use lib/crc32.c for this? The
polynomial is the same...

> +{
> +       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);

Does lib/bitrev.c do this job?

Regards,
Simon

> +       return crc;
> +}
> +
>  /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
>
>  /* Set the appropriate hash bit for the given addr */
> diff --git a/include/net.h b/include/net.h
> index 51c099dae2e5..359bfb5ef69f 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -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
>
>
> diff --git a/net/eth_legacy.c b/net/eth_legacy.c
> index 2a9caa3509b0..d2e16b8fa3da 100644
> --- a/net/eth_legacy.c
> +++ b/net/eth_legacy.c
> @@ -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
>
>
> --
> 2.19.2
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Chris Packham Nov. 27, 2018, 3:19 a.m. UTC | #2
On Mon, Nov 26, 2018 at 9:12 PM Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com> wrote:
>
> On Mon, Nov 26, 2018 at 9:00 AM Chris Packham <judge.packham@gmail.com> wrote:
> >
> > 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>
> > ---
> >
> >  drivers/net/tsec.c | 25 +++++++++++++++++++++++++
> >  include/net.h      |  1 -
> >  net/eth_legacy.c   | 24 ------------------------
> >  3 files changed, 25 insertions(+), 25 deletions(-)
> >
> > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> > index 03a46da2f8a1..9a4fab85e928 100644
> > --- a/drivers/net/tsec.c
> > +++ b/drivers/net/tsec.c
> > @@ -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)
>
> I haven't checked, but can't we use lib/crc32.c for this? The
> polynomial is the same...
>

Yes more than likely.  I erred on the side of not changing more than
absolutely necessary. However given the fact that this code isn't
currently run on any platform maybe that's too cautious.

> > +{
> > +       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);
>
> Does lib/bitrev.c do this job?
>
> Regards,
> Simon
>
> > +       return crc;
> > +}
> > +
> >  /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
> >
> >  /* Set the appropriate hash bit for the given addr */
> > diff --git a/include/net.h b/include/net.h
> > index 51c099dae2e5..359bfb5ef69f 100644
> > --- a/include/net.h
> > +++ b/include/net.h
> > @@ -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
> >
> >
> > diff --git a/net/eth_legacy.c b/net/eth_legacy.c
> > index 2a9caa3509b0..d2e16b8fa3da 100644
> > --- a/net/eth_legacy.c
> > +++ b/net/eth_legacy.c
> > @@ -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
> >
> >
> > --
> > 2.19.2
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
Simon Goldschmidt Nov. 27, 2018, 6:09 a.m. UTC | #3
On Tue, Nov 27, 2018 at 4:19 AM Chris Packham <judge.packham@gmail.com> wrote:
>
> On Mon, Nov 26, 2018 at 9:12 PM Simon Goldschmidt
> <simon.k.r.goldschmidt@gmail.com> wrote:
> >
> > On Mon, Nov 26, 2018 at 9:00 AM Chris Packham <judge.packham@gmail.com> wrote:
> > >
> > > 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>
> > > ---
> > >
> > >  drivers/net/tsec.c | 25 +++++++++++++++++++++++++
> > >  include/net.h      |  1 -
> > >  net/eth_legacy.c   | 24 ------------------------
> > >  3 files changed, 25 insertions(+), 25 deletions(-)
> > >
> > > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> > > index 03a46da2f8a1..9a4fab85e928 100644
> > > --- a/drivers/net/tsec.c
> > > +++ b/drivers/net/tsec.c
> > > @@ -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)
> >
> > I haven't checked, but can't we use lib/crc32.c for this? The
> > polynomial is the same...
> >
>
> Yes more than likely.  I erred on the side of not changing more than
> absolutely necessary. However given the fact that this code isn't
> currently run on any platform maybe that's too cautious.

A quick test shows me that a call to 'ether_crc(len, data)' can be
replaced by 'bitrev32(crc32_no_comp(~0, data, len))'.
Of course the code size increases as those files have tables (crc
table: 1K, bitrev table: 256 bytes).

Simon

>
> > > +{
> > > +       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);
> >
> > Does lib/bitrev.c do this job?
> >
> > Regards,
> > Simon
> >
> > > +       return crc;
> > > +}
> > > +
> > >  /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
> > >
> > >  /* Set the appropriate hash bit for the given addr */
> > > diff --git a/include/net.h b/include/net.h
> > > index 51c099dae2e5..359bfb5ef69f 100644
> > > --- a/include/net.h
> > > +++ b/include/net.h
> > > @@ -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
> > >
> > >
> > > diff --git a/net/eth_legacy.c b/net/eth_legacy.c
> > > index 2a9caa3509b0..d2e16b8fa3da 100644
> > > --- a/net/eth_legacy.c
> > > +++ b/net/eth_legacy.c
> > > @@ -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
> > >
> > >
> > > --
> > > 2.19.2
> > >
> > > _______________________________________________
> > > U-Boot mailing list
> > > U-Boot@lists.denx.de
> > > https://lists.denx.de/listinfo/u-boot
Joe Hershberger Jan. 22, 2019, 11:41 p.m. UTC | #4
On Tue, Nov 27, 2018 at 12:10 AM Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com> wrote:
>
> On Tue, Nov 27, 2018 at 4:19 AM Chris Packham <judge.packham@gmail.com> wrote:
> >
> > On Mon, Nov 26, 2018 at 9:12 PM Simon Goldschmidt
> > <simon.k.r.goldschmidt@gmail.com> wrote:
> > >
> > > On Mon, Nov 26, 2018 at 9:00 AM Chris Packham <judge.packham@gmail.com> wrote:
> > > >
> > > > 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>
> > > > ---
> > > >
> > > >  drivers/net/tsec.c | 25 +++++++++++++++++++++++++
> > > >  include/net.h      |  1 -
> > > >  net/eth_legacy.c   | 24 ------------------------
> > > >  3 files changed, 25 insertions(+), 25 deletions(-)
> > > >
> > > > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> > > > index 03a46da2f8a1..9a4fab85e928 100644
> > > > --- a/drivers/net/tsec.c
> > > > +++ b/drivers/net/tsec.c
> > > > @@ -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)
> > >
> > > I haven't checked, but can't we use lib/crc32.c for this? The
> > > polynomial is the same...
> > >
> >
> > Yes more than likely.  I erred on the side of not changing more than
> > absolutely necessary. However given the fact that this code isn't
> > currently run on any platform maybe that's too cautious.
>
> A quick test shows me that a call to 'ether_crc(len, data)' can be
> replaced by 'bitrev32(crc32_no_comp(~0, data, len))'.
> Of course the code size increases as those files have tables (crc
> table: 1K, bitrev table: 256 bytes).

Not sure if tsec devices are ever super memory constrained, but I
could go either way.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

But if someone wants to test it on tsec boards and send a
consolidation script. I'm good with that too.

Thanks,
-Joe

> Simon
>
> >
> > > > +{
> > > > +       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);
> > >
> > > Does lib/bitrev.c do this job?
> > >
> > > Regards,
> > > Simon
> > >
> > > > +       return crc;
> > > > +}
> > > > +
> > > >  /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
> > > >
> > > >  /* Set the appropriate hash bit for the given addr */
> > > > diff --git a/include/net.h b/include/net.h
> > > > index 51c099dae2e5..359bfb5ef69f 100644
> > > > --- a/include/net.h
> > > > +++ b/include/net.h
> > > > @@ -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
> > > >
> > > >
> > > > diff --git a/net/eth_legacy.c b/net/eth_legacy.c
> > > > index 2a9caa3509b0..d2e16b8fa3da 100644
> > > > --- a/net/eth_legacy.c
> > > > +++ b/net/eth_legacy.c
> > > > @@ -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
> > > >
> > > >
> > > > --
> > > > 2.19.2
> > > >
> > > > _______________________________________________
> > > > U-Boot mailing list
> > > > U-Boot@lists.denx.de
> > > > https://lists.denx.de/listinfo/u-boot
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Joe Hershberger Jan. 24, 2019, 5:38 p.m. UTC | #5
Hi Chris,

https://patchwork.ozlabs.org/patch/1003048/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 03a46da2f8a1..9a4fab85e928 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -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 */
diff --git a/include/net.h b/include/net.h
index 51c099dae2e5..359bfb5ef69f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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
 
 
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 2a9caa3509b0..d2e16b8fa3da 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -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