Re: [Qemu-devel] [QEMU PATCH v2] virtio-net: introduce a new macaddr control

2013-01-17 Thread Amos Kong
On Thu, Jan 17, 2013 at 01:45:11PM +0800, Amos Kong wrote:
 On Thu, Jan 17, 2013 at 11:49:20AM +1030, Rusty Russell wrote:
  ak...@redhat.com writes:
   @@ -349,6 +351,14 @@ static int virtio_net_handle_mac(VirtIONet *n, 
   uint8_t cmd,
{
struct virtio_net_ctrl_mac mac_data;

   +if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET  elem-out_num == 2 
   +elem-out_sg[1].iov_len == ETH_ALEN) {
   +/* Set MAC address */
   +memcpy(n-mac, elem-out_sg[1].iov_base, 
   elem-out_sg[1].iov_len);
   +qemu_format_nic_info_str(n-nic-nc, n-mac);
   +return VIRTIO_NET_OK;
   +}
  
  Does the rest of the net device still rely on the layout of descriptors?
 
 No, only info string of net client relies on n-mac

I misunderstood. There is no clear limitation of how much descriptor are
used for each vq command, but many commands rely on the layout of
descriptiors. eg:

virtio-net:
   VIRTIO_NET_CTRL_RX_PROMISC
   VIRTIO_NET_CTRL_RX_ALLMULTI
   VIRTIO_NET_CTRL_MAC_TABLE_SET
   etc
 
  If so, OK, we'll fix them all together.  If not, this introduces a new
  one.
  
  Cheers,
  Rusty.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [QEMU PATCH v2] virtio-net: introduce a new macaddr control

2013-01-17 Thread Stefan Hajnoczi
On Thu, Jan 17, 2013 at 01:45:11PM +0800, Amos Kong wrote:
 On Thu, Jan 17, 2013 at 11:49:20AM +1030, Rusty Russell wrote:
  ak...@redhat.com writes:
   @@ -349,6 +351,14 @@ static int virtio_net_handle_mac(VirtIONet *n, 
   uint8_t cmd,
{
struct virtio_net_ctrl_mac mac_data;

   +if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET  elem-out_num == 2 
   +elem-out_sg[1].iov_len == ETH_ALEN) {
   +/* Set MAC address */
   +memcpy(n-mac, elem-out_sg[1].iov_base, 
   elem-out_sg[1].iov_len);
   +qemu_format_nic_info_str(n-nic-nc, n-mac);
   +return VIRTIO_NET_OK;
   +}
  
  Does the rest of the net device still rely on the layout of descriptors?
 
 No, only info string of net client relies on n-mac

I think the question is whether the hw/virtio-net.c code makes
assumptions about virtqueue descriptor layout (e.g. sg[0] is the header,
sg[1] is the data buffer).

The answer is yes, the control virtqueue function directly accesses
iov[n].

Additional patches would be required to convert the existing
hw/virtio-net.c code to make no assumptions about virtqueue descriptor
layout.  It's outside the scope of this series.

Stefan
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [Qemu-devel] [QEMU PATCH v2] virtio-net: introduce a new macaddr control

2013-01-17 Thread Michael S. Tsirkin
On Thu, Jan 17, 2013 at 09:39:54AM +0100, Stefan Hajnoczi wrote:
 On Thu, Jan 17, 2013 at 01:45:11PM +0800, Amos Kong wrote:
  On Thu, Jan 17, 2013 at 11:49:20AM +1030, Rusty Russell wrote:
   ak...@redhat.com writes:
@@ -349,6 +351,14 @@ static int virtio_net_handle_mac(VirtIONet *n, 
uint8_t cmd,
 {
 struct virtio_net_ctrl_mac mac_data;
 
+if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET  elem-out_num == 2 
+elem-out_sg[1].iov_len == ETH_ALEN) {
+/* Set MAC address */
+memcpy(n-mac, elem-out_sg[1].iov_base, 
elem-out_sg[1].iov_len);
+qemu_format_nic_info_str(n-nic-nc, n-mac);
+return VIRTIO_NET_OK;
+}
   
   Does the rest of the net device still rely on the layout of descriptors?
  
  No, only info string of net client relies on n-mac
 
 I think the question is whether the hw/virtio-net.c code makes
 assumptions about virtqueue descriptor layout (e.g. sg[0] is the header,
 sg[1] is the data buffer).
 
 The answer is yes, the control virtqueue function directly accesses
 iov[n].
 
 Additional patches would be required to convert the existing
 hw/virtio-net.c code to make no assumptions about virtqueue descriptor
 layout.  It's outside the scope of this series.
 
 Stefan

It's not hard at all though - the harder part is data path
processing, this has been done already. Will send a
patch shortly.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [QEMU PATCH v2] virtio-net: introduce a new macaddr control

2013-01-16 Thread Amos Kong
On Thu, Jan 17, 2013 at 11:49:20AM +1030, Rusty Russell wrote:
 ak...@redhat.com writes:
  @@ -349,6 +351,14 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t 
  cmd,
   {
   struct virtio_net_ctrl_mac mac_data;
   
  +if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET  elem-out_num == 2 
  +elem-out_sg[1].iov_len == ETH_ALEN) {
  +/* Set MAC address */
  +memcpy(n-mac, elem-out_sg[1].iov_base, elem-out_sg[1].iov_len);
  +qemu_format_nic_info_str(n-nic-nc, n-mac);
  +return VIRTIO_NET_OK;
  +}
 
 Does the rest of the net device still rely on the layout of descriptors?

No, only info string of net client relies on n-mac

 If so, OK, we'll fix them all together.  If not, this introduces a new
 one.
 
 Cheers,
 Rusty.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html