mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-15 22:21:57 -06:00
etsec: Move etsec_can_receive into etsec_receive
When etsec_reset returns 0, peer would queue the packet as if .can_receive returns false. Drop etsec_can_receive and let etsec_receive carry the semantics. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com> Message-id: 1436955553-22791-6-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
913440249e
commit
b6cb6610c2
3 changed files with 10 additions and 17 deletions
|
@ -338,13 +338,6 @@ static void etsec_reset(DeviceState *d)
|
||||||
MII_SR_100X_FD_CAPS | MII_SR_100T4_CAPS;
|
MII_SR_100X_FD_CAPS | MII_SR_100T4_CAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int etsec_can_receive(NetClientState *nc)
|
|
||||||
{
|
|
||||||
eTSEC *etsec = qemu_get_nic_opaque(nc);
|
|
||||||
|
|
||||||
return etsec->rx_buffer_len == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t etsec_receive(NetClientState *nc,
|
static ssize_t etsec_receive(NetClientState *nc,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf,
|
||||||
size_t size)
|
size_t size)
|
||||||
|
@ -355,8 +348,7 @@ static ssize_t etsec_receive(NetClientState *nc,
|
||||||
fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
|
fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
|
||||||
qemu_hexdump(buf, stderr, "", size);
|
qemu_hexdump(buf, stderr, "", size);
|
||||||
#endif
|
#endif
|
||||||
etsec_rx_ring_write(etsec, buf, size);
|
return etsec_rx_ring_write(etsec, buf, size);
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,7 +362,6 @@ static void etsec_set_link_status(NetClientState *nc)
|
||||||
static NetClientInfo net_etsec_info = {
|
static NetClientInfo net_etsec_info = {
|
||||||
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = etsec_can_receive,
|
|
||||||
.receive = etsec_receive,
|
.receive = etsec_receive,
|
||||||
.link_status_changed = etsec_set_link_status,
|
.link_status_changed = etsec_set_link_status,
|
||||||
};
|
};
|
||||||
|
|
|
@ -162,7 +162,7 @@ DeviceState *etsec_create(hwaddr base,
|
||||||
|
|
||||||
void etsec_walk_tx_ring(eTSEC *etsec, int ring_nbr);
|
void etsec_walk_tx_ring(eTSEC *etsec, int ring_nbr);
|
||||||
void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr);
|
void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr);
|
||||||
void etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size);
|
ssize_t etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size);
|
||||||
|
|
||||||
void etsec_write_miim(eTSEC *etsec,
|
void etsec_write_miim(eTSEC *etsec,
|
||||||
eTSEC_Register *reg,
|
eTSEC_Register *reg,
|
||||||
|
|
|
@ -481,40 +481,42 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size)
|
||||||
etsec->rx_buffer_len, etsec->rx_padding);
|
etsec->rx_buffer_len, etsec->rx_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size)
|
ssize_t etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size)
|
||||||
{
|
{
|
||||||
int ring_nbr = 0; /* Always use ring0 (no filer) */
|
int ring_nbr = 0; /* Always use ring0 (no filer) */
|
||||||
|
|
||||||
if (etsec->rx_buffer_len != 0) {
|
if (etsec->rx_buffer_len != 0) {
|
||||||
RING_DEBUG("%s: We can't receive now,"
|
RING_DEBUG("%s: We can't receive now,"
|
||||||
" a buffer is already in the pipe\n", __func__);
|
" a buffer is already in the pipe\n", __func__);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (etsec->regs[RSTAT].value & 1 << (23 - ring_nbr)) {
|
if (etsec->regs[RSTAT].value & 1 << (23 - ring_nbr)) {
|
||||||
RING_DEBUG("%s: The ring is halted\n", __func__);
|
RING_DEBUG("%s: The ring is halted\n", __func__);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (etsec->regs[DMACTRL].value & DMACTRL_GRS) {
|
if (etsec->regs[DMACTRL].value & DMACTRL_GRS) {
|
||||||
RING_DEBUG("%s: Graceful receive stop\n", __func__);
|
RING_DEBUG("%s: Graceful receive stop\n", __func__);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(etsec->regs[MACCFG1].value & MACCFG1_RX_EN)) {
|
if (!(etsec->regs[MACCFG1].value & MACCFG1_RX_EN)) {
|
||||||
RING_DEBUG("%s: MAC Receive not enabled\n", __func__);
|
RING_DEBUG("%s: MAC Receive not enabled\n", __func__);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((etsec->regs[RCTRL].value & RCTRL_RSF) && (size < 60)) {
|
if ((etsec->regs[RCTRL].value & RCTRL_RSF) && (size < 60)) {
|
||||||
/* CRC is not in the packet yet, so short frame is below 60 bytes */
|
/* CRC is not in the packet yet, so short frame is below 60 bytes */
|
||||||
RING_DEBUG("%s: Drop short frame\n", __func__);
|
RING_DEBUG("%s: Drop short frame\n", __func__);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rx_init_frame(etsec, buf, size);
|
rx_init_frame(etsec, buf, size);
|
||||||
|
|
||||||
etsec_walk_rx_ring(etsec, ring_nbr);
|
etsec_walk_rx_ring(etsec, ring_nbr);
|
||||||
|
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr)
|
void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue