mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
e1000x: Share more Rx filtering logic
This saves some code and enables tracepoint for e1000's VLAN filtering. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
0b11783014
commit
e9e5b93069
6 changed files with 56 additions and 119 deletions
|
@ -1034,48 +1034,11 @@ e1000e_rx_l4_cso_enabled(E1000ECore *core)
|
|||
}
|
||||
|
||||
static bool
|
||||
e1000e_receive_filter(E1000ECore *core, const uint8_t *buf, int size)
|
||||
e1000e_receive_filter(E1000ECore *core, const void *buf)
|
||||
{
|
||||
uint32_t rctl = core->mac[RCTL];
|
||||
|
||||
if (e1000x_is_vlan_packet(buf, core->mac[VET]) &&
|
||||
e1000x_vlan_rx_filter_enabled(core->mac)) {
|
||||
uint16_t vid = lduw_be_p(&PKT_GET_VLAN_HDR(buf)->h_tci);
|
||||
uint32_t vfta =
|
||||
ldl_le_p((uint32_t *)(core->mac + VFTA) +
|
||||
((vid >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK));
|
||||
if ((vfta & (1 << (vid & E1000_VFTA_ENTRY_BIT_SHIFT_MASK))) == 0) {
|
||||
trace_e1000e_rx_flt_vlan_mismatch(vid);
|
||||
return false;
|
||||
} else {
|
||||
trace_e1000e_rx_flt_vlan_match(vid);
|
||||
}
|
||||
}
|
||||
|
||||
switch (net_rx_pkt_get_packet_type(core->rx_pkt)) {
|
||||
case ETH_PKT_UCAST:
|
||||
if (rctl & E1000_RCTL_UPE) {
|
||||
return true; /* promiscuous ucast */
|
||||
}
|
||||
break;
|
||||
|
||||
case ETH_PKT_BCAST:
|
||||
if (rctl & E1000_RCTL_BAM) {
|
||||
return true; /* broadcast enabled */
|
||||
}
|
||||
break;
|
||||
|
||||
case ETH_PKT_MCAST:
|
||||
if (rctl & E1000_RCTL_MPE) {
|
||||
return true; /* promiscuous mcast */
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
return e1000x_rx_group_filter(core->mac, buf);
|
||||
return (!e1000x_is_vlan_packet(buf, core->mac[VET]) ||
|
||||
e1000x_rx_vlan_filter(core->mac, PKT_GET_VLAN_HDR(buf))) &&
|
||||
e1000x_rx_group_filter(core->mac, buf);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -1736,7 +1699,7 @@ e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iovcnt,
|
|||
net_rx_pkt_set_packet_type(core->rx_pkt,
|
||||
get_eth_packet_type(PKT_GET_ETH_HDR(buf)));
|
||||
|
||||
if (!e1000e_receive_filter(core, buf, size)) {
|
||||
if (!e1000e_receive_filter(core, buf)) {
|
||||
trace_e1000e_rx_flt_dropped();
|
||||
return orig_size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue