From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: Sriram Yagnaraman <sriram.yagnaraman@est.tech>,
Jason Wang <jasowang@redhat.com>
Subject: [PULL 12/12] igb: respect VMVIR and VMOLR for VLAN
Date: Tue, 28 Mar 2023 13:19:17 +0800 [thread overview]
Message-ID: <20230328051917.18006-13-jasowang@redhat.com> (raw)
In-Reply-To: <20230328051917.18006-1-jasowang@redhat.com>
From: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
Add support for stripping/inserting VLAN for VFs.
Had to move CSUM calculation back into the for loop, since packet data
is pulled inside the loop based on strip VLAN decision for every VF.
net_rx_pkt_fix_l4_csum should be extended to accept a buffer instead for
igb. Work for a future patch.
Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/igb_core.c | 62 +++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 13 deletions(-)
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index 162ba8b..d733fed 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -386,6 +386,28 @@ igb_rss_parse_packet(IGBCore *core, struct NetRxPkt *pkt, bool tx,
info->queue = E1000_RSS_QUEUE(&core->mac[RETA], info->hash);
}
+static void
+igb_tx_insert_vlan(IGBCore *core, uint16_t qn, struct igb_tx *tx,
+ uint16_t vlan, bool insert_vlan)
+{
+ if (core->mac[MRQC] & 1) {
+ uint16_t pool = qn % IGB_NUM_VM_POOLS;
+
+ if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_DEFAULT) {
+ /* always insert default VLAN */
+ insert_vlan = true;
+ vlan = core->mac[VMVIR0 + pool] & 0xffff;
+ } else if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_NEVER) {
+ insert_vlan = false;
+ }
+ }
+
+ if (insert_vlan && e1000x_vlan_enabled(core->mac)) {
+ net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan,
+ core->mac[VET] & 0xffff);
+ }
+}
+
static bool
igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx)
{
@@ -583,12 +605,11 @@ igb_process_tx_desc(IGBCore *core,
if (cmd_type_len & E1000_TXD_CMD_EOP) {
if (!tx->skip_cp && net_tx_pkt_parse(tx->tx_pkt)) {
- if (cmd_type_len & E1000_TXD_CMD_VLE) {
- idx = (tx->first_olinfo_status >> 4) & 1;
- uint16_t vlan = tx->ctx[idx].vlan_macip_lens >> 16;
- uint16_t vet = core->mac[VET] & 0xffff;
- net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan, vet);
- }
+ idx = (tx->first_olinfo_status >> 4) & 1;
+ igb_tx_insert_vlan(core, queue_index, tx,
+ tx->ctx[idx].vlan_macip_lens >> 16,
+ !!(cmd_type_len & E1000_TXD_CMD_VLE));
+
if (igb_tx_pkt_send(core, tx, queue_index)) {
igb_on_tx_done_update_stats(core, tx->tx_pkt, queue_index);
}
@@ -1547,6 +1568,20 @@ igb_write_packet_to_guest(IGBCore *core, struct NetRxPkt *pkt,
igb_update_rx_stats(core, rxi, size, total_size);
}
+static bool
+igb_rx_strip_vlan(IGBCore *core, const E1000E_RingInfo *rxi)
+{
+ if (core->mac[MRQC] & 1) {
+ uint16_t pool = rxi->idx % IGB_NUM_VM_POOLS;
+ /* Sec 7.10.3.8: CTRL.VME is ignored, only VMOLR/RPLOLR is used */
+ return (net_rx_pkt_get_packet_type(core->rx_pkt) == ETH_PKT_MCAST) ?
+ core->mac[RPLOLR] & E1000_RPLOLR_STRVLAN :
+ core->mac[VMOLR0 + pool] & E1000_VMOLR_STRVLAN;
+ }
+
+ return e1000x_vlan_enabled(core->mac);
+}
+
static inline void
igb_rx_fix_l4_csum(IGBCore *core, struct NetRxPkt *pkt)
{
@@ -1627,10 +1662,7 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt,
ehdr = PKT_GET_ETH_HDR(filter_buf);
net_rx_pkt_set_packet_type(core->rx_pkt, get_eth_packet_type(ehdr));
-
- net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs,
- e1000x_vlan_enabled(core->mac),
- core->mac[VET] & 0xffff);
+ net_rx_pkt_set_protocols(core->rx_pkt, filter_buf, size);
queues = igb_receive_assign(core, ehdr, size, &rss_info, external_tx);
if (!queues) {
@@ -1638,9 +1670,6 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt,
return orig_size;
}
- total_size = net_rx_pkt_get_total_len(core->rx_pkt) +
- e1000x_fcs_len(core->mac);
-
for (i = 0; i < IGB_NUM_QUEUES; i++) {
if (!(queues & BIT(i)) ||
!(core->mac[RXDCTL0 + (i * 16)] & E1000_RXDCTL_QUEUE_ENABLE)) {
@@ -1649,6 +1678,13 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt,
igb_rx_ring_init(core, &rxr, i);
+ net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs,
+ igb_rx_strip_vlan(core, rxr.i),
+ core->mac[VET] & 0xffff);
+
+ total_size = net_rx_pkt_get_total_len(core->rx_pkt) +
+ e1000x_fcs_len(core->mac);
+
if (!igb_has_rxbufs(core, rxr.i, total_size)) {
n |= E1000_ICS_RXO;
trace_e1000e_rx_not_written_to_guest(rxr.i->idx);
--
2.7.4
next prev parent reply other threads:[~2023-03-28 5:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 5:19 [PULL 00/12] Net patches Jason Wang
2023-03-28 5:19 ` [PULL 01/12] igb: Save more Tx states Jason Wang
2023-03-28 5:19 ` [PULL 02/12] igb: Fix DMA requester specification for Tx packet Jason Wang
2023-03-28 5:19 ` [PULL 03/12] hw/net/net_tx_pkt: Ignore ECN bit Jason Wang
2023-03-28 5:19 ` [PULL 04/12] hw/net/net_tx_pkt: Align l3_hdr Jason Wang
2023-03-28 5:19 ` [PULL 05/12] MAINTAINERS: Add Sriram Yagnaraman as a igb reviewer Jason Wang
2023-03-28 5:19 ` [PULL 06/12] igb: handle PF/VF reset properly Jason Wang
2023-03-28 5:19 ` [PULL 07/12] igb: add ICR_RXDW Jason Wang
2023-03-28 5:19 ` [PULL 08/12] igb: implement VFRE and VFTE registers Jason Wang
2023-03-28 5:19 ` [PULL 09/12] igb: check oversized packets for VMDq Jason Wang
2023-03-28 5:19 ` [PULL 10/12] igb: respect E1000_VMOLR_RSSE Jason Wang
2023-03-28 5:19 ` [PULL 11/12] igb: implement VF Tx and Rx stats Jason Wang
2023-03-28 5:19 ` Jason Wang [this message]
2023-03-28 16:00 ` [PULL 00/12] Net patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328051917.18006-13-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sriram.yagnaraman@est.tech \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).