mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
net: move compute_mcast_idx() to net.h
Reduce duplicated codes. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
afe0a59535
commit
7fc8d918b9
6 changed files with 26 additions and 98 deletions
24
hw/rtl8139.c
24
hw/rtl8139.c
|
@ -708,30 +708,6 @@ static void rtl8139_update_irq(RTL8139State *s)
|
|||
qemu_set_irq(s->dev.irq[0], (isr != 0));
|
||||
}
|
||||
|
||||
#define POLYNOMIAL 0x04c11db6
|
||||
|
||||
/* From FreeBSD */
|
||||
/* XXX: optimize */
|
||||
static int compute_mcast_idx(const uint8_t *ep)
|
||||
{
|
||||
uint32_t crc;
|
||||
int carry, i, j;
|
||||
uint8_t b;
|
||||
|
||||
crc = 0xffffffff;
|
||||
for (i = 0; i < 6; i++) {
|
||||
b = *ep++;
|
||||
for (j = 0; j < 8; j++) {
|
||||
carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
|
||||
crc <<= 1;
|
||||
b >>= 1;
|
||||
if (carry)
|
||||
crc = ((crc ^ POLYNOMIAL) | carry);
|
||||
}
|
||||
}
|
||||
return (crc >> 26);
|
||||
}
|
||||
|
||||
static int rtl8139_RxWrap(RTL8139State *s)
|
||||
{
|
||||
/* wrapping enabled; assume 1.5k more buffer space if size < 65536 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue