Message ID | e88a774a47c19ca85ae838b30b75dac549446f5b.1687524532.git.yin31149@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Vhost-vdpa Shadow Virtqueue _F_CTRL_RX_EXTRA commands support | expand |
On Fri, Jun 23, 2023 at 3:26 PM Hawkins Jiawei <yin31149@gmail.com> wrote: > > This patch refactors vhost_vdpa_net_load_rx() to > restore the packet receive filtering state in relation to > VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup. > > Signed-off-by: Hawkins Jiawei <yin31149@gmail.com> > --- > net/vhost-vdpa.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index ca800f97e2..9b929762c5 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -822,6 +822,36 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, > } > } > > + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTRA)) { > + /* Load the all-unicast mode */ > + on = n->alluni; > + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLUNI, on); > + if (r < 0) { > + return r; > + } > + > + /* Load the non-multicast mode */ > + on = n->nomulti; > + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOMULTI, on); > + if (r < 0) { > + return r; > + } > + > + /* Load the non-unicast mode */ > + on = n->nouni; > + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOUNI, on); > + if (r < 0) { > + return r; > + } > + > + /* Load the non-broadcast mode */ > + on = n->nobcast; > + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOBCAST, on); > + if (r < 0) { > + return r; > + } > + } > + Can we skip the load if the state matches the virtio defaults? by virtio_net_reset the defaults are: n->promisc = 1; n->allmulti = 0; n->alluni = 0; n->nomulti = 0; n->nouni = 0; n->nobcast = 0; Thanks! > return 0; > } > > -- > 2.25.1 >
On 2023/6/25 18:54, Eugenio Perez Martin wrote: > On Fri, Jun 23, 2023 at 3:26 PM Hawkins Jiawei <yin31149@gmail.com> wrote: >> >> This patch refactors vhost_vdpa_net_load_rx() to >> restore the packet receive filtering state in relation to >> VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup. >> >> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com> >> --- >> net/vhost-vdpa.c | 30 ++++++++++++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >> >> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c >> index ca800f97e2..9b929762c5 100644 >> --- a/net/vhost-vdpa.c >> +++ b/net/vhost-vdpa.c >> @@ -822,6 +822,36 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, >> } >> } >> >> + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTRA)) { >> + /* Load the all-unicast mode */ >> + on = n->alluni; >> + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLUNI, on); >> + if (r < 0) { >> + return r; >> + } >> + >> + /* Load the non-multicast mode */ >> + on = n->nomulti; >> + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOMULTI, on); >> + if (r < 0) { >> + return r; >> + } >> + >> + /* Load the non-unicast mode */ >> + on = n->nouni; >> + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOUNI, on); >> + if (r < 0) { >> + return r; >> + } >> + >> + /* Load the non-broadcast mode */ >> + on = n->nobcast; >> + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOBCAST, on); >> + if (r < 0) { >> + return r; >> + } >> + } >> + > > Can we skip the load if the state matches the virtio defaults? by > virtio_net_reset the defaults are: > n->promisc = 1; > n->allmulti = 0; > n->alluni = 0; > n->nomulti = 0; > n->nouni = 0; > n->nobcast = 0; Yes, you are right. Thanks for your reminder, I forgot this part when coding. I will refactor the patch according to your suggestion and take care of it in the following patches for this part. Thanks! > > Thanks! > >> return 0; >> } >> >> -- >> 2.25.1 >> >
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index ca800f97e2..9b929762c5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -822,6 +822,36 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, } } + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTRA)) { + /* Load the all-unicast mode */ + on = n->alluni; + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLUNI, on); + if (r < 0) { + return r; + } + + /* Load the non-multicast mode */ + on = n->nomulti; + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOMULTI, on); + if (r < 0) { + return r; + } + + /* Load the non-unicast mode */ + on = n->nouni; + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOUNI, on); + if (r < 0) { + return r; + } + + /* Load the non-broadcast mode */ + on = n->nobcast; + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOBCAST, on); + if (r < 0) { + return r; + } + } + return 0; }
This patch refactors vhost_vdpa_net_load_rx() to restore the packet receive filtering state in relation to VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup. Signed-off-by: Hawkins Jiawei <yin31149@gmail.com> --- net/vhost-vdpa.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)