All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>,
	qemu devel <qemu-devel@nongnu.org>
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
	weifuqiang <weifuqiang@huawei.com>,
	"eddie . dong" <eddie.dong@intel.com>,
	bian naimeng <biannm@cn.fujitsu.com>,
	Li Zhijian <lizhijian@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH V3 01/10] net: Add vnet_hdr_len related callback in NetClientInfo
Date: Tue, 2 May 2017 13:46:17 +0800	[thread overview]
Message-ID: <d487205d-6957-d8c1-678a-38a5668586df@redhat.com> (raw)
In-Reply-To: <1493372840-24551-2-git-send-email-zhangchen.fnst@cn.fujitsu.com>



On 2017年04月28日 17:47, Zhang Chen wrote:
> Add get_vnet_hdr_len and get_using_vnet_hdr callback
> that make we get vnet_hdr_len easily.
>
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> ---
>   include/net/net.h |  6 ++++++
>   net/net.c         | 18 ++++++++++++++++++
>   2 files changed, 24 insertions(+)
>
> diff --git a/include/net/net.h b/include/net/net.h
> index 99b28d5..402d913 100644
> --- a/include/net/net.h
> +++ b/include/net/net.h
> @@ -57,7 +57,9 @@ typedef RxFilterInfo *(QueryRxFilter)(NetClientState *);
>   typedef bool (HasUfo)(NetClientState *);
>   typedef bool (HasVnetHdr)(NetClientState *);
>   typedef bool (HasVnetHdrLen)(NetClientState *, int);
> +typedef int (GetVnetHdrLen)(NetClientState *);
>   typedef void (UsingVnetHdr)(NetClientState *, bool);
> +typedef bool (GetUsingVnetHdr)(NetClientState *);
>   typedef void (SetOffload)(NetClientState *, int, int, int, int, int);
>   typedef void (SetVnetHdrLen)(NetClientState *, int);
>   typedef int (SetVnetLE)(NetClientState *, bool);
> @@ -79,7 +81,9 @@ typedef struct NetClientInfo {
>       HasUfo *has_ufo;
>       HasVnetHdr *has_vnet_hdr;
>       HasVnetHdrLen *has_vnet_hdr_len;
> +    GetVnetHdrLen *get_vnet_hdr_len;
>       UsingVnetHdr *using_vnet_hdr;
> +    GetUsingVnetHdr *get_using_vnet_hdr;
>       SetOffload *set_offload;
>       SetVnetHdrLen *set_vnet_hdr_len;
>       SetVnetLE *set_vnet_le;
> @@ -155,7 +159,9 @@ void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]);
>   bool qemu_has_ufo(NetClientState *nc);
>   bool qemu_has_vnet_hdr(NetClientState *nc);
>   bool qemu_has_vnet_hdr_len(NetClientState *nc, int len);
> +int qemu_get_vnet_hdr_len(NetClientState *nc);
>   void qemu_using_vnet_hdr(NetClientState *nc, bool enable);
> +bool qemu_get_using_vnet_hdr(NetClientState *nc);
>   void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
>                         int ecn, int ufo);
>   void qemu_set_vnet_hdr_len(NetClientState *nc, int len);
> diff --git a/net/net.c b/net/net.c
> index 0ac3b9e..f69260f 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -466,6 +466,15 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len)
>       return nc->info->has_vnet_hdr_len(nc, len);
>   }
>   
> +int qemu_get_vnet_hdr_len(NetClientState *nc)
> +{
> +    if (!nc || !nc->info->get_vnet_hdr_len) {
> +        return false;
> +    }
> +
> +    return nc->info->get_vnet_hdr_len(nc);
> +}
> +
>   void qemu_using_vnet_hdr(NetClientState *nc, bool enable)
>   {
>       if (!nc || !nc->info->using_vnet_hdr) {
> @@ -475,6 +484,15 @@ void qemu_using_vnet_hdr(NetClientState *nc, bool enable)
>       nc->info->using_vnet_hdr(nc, enable);
>   }
>   
> +bool qemu_get_using_vnet_hdr(NetClientState *nc)
> +{
> +    if (!nc || !nc->info->get_using_vnet_hdr) {
> +        return false;
> +    }
> +
> +    return nc->info->get_using_vnet_hdr(nc);
> +}

Looks like we can do this simply by:

Introduce two common fields in NetClientState:

bool using_vnet_hdr;
int vnet_hdr_len;

And set them during qemu_using_vnet_hdr() and qemu_set_vnet_hdr_len(). 
Then we can query them directly without introducing any new callbacks.

Thanks

> +
>   void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
>                             int ecn, int ufo)
>   {

  reply	other threads:[~2017-05-02  5:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  9:47 [Qemu-devel] [PATCH V3 00/10] Add COLO-proxy virtio-net support Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 01/10] net: Add vnet_hdr_len related callback in NetClientInfo Zhang Chen
2017-05-02  5:46   ` Jason Wang [this message]
2017-05-03  3:08     ` Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 02/10] net/tap.c: Add tap_get_vnet_hdr_len and tap_get_using_vnet_hdr function Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 03/10] net/netmap.c: Add netmap_get_vnet_hdr_len function Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 04/10] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
2017-05-02  5:47   ` Jason Wang
2017-05-03  3:18     ` Zhang Chen
2017-05-03 10:19       ` Jason Wang
2017-05-05  8:44         ` Zhang Chen
2017-05-05  9:25           ` Jason Wang
2017-05-05  9:43             ` Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 05/10] net/net.c: Add vnet header length to SocketReadState Zhang Chen
2017-05-02  5:53   ` Jason Wang
2017-05-03  3:43     ` Zhang Chen
2017-05-03 10:42       ` Jason Wang
2017-05-08  3:47         ` Zhang Chen
2017-05-09  2:40           ` Jason Wang
2017-05-09  4:03             ` Zhang Chen
2017-05-09  5:36               ` Jason Wang
2017-05-09  6:59                 ` Zhang Chen
2017-05-09  7:36                   ` Jason Wang
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 06/10] tests/e1000e-test.c : change e1000e test case send data format Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 07/10] tests/virtio-net-test.c : change virtio-net test case iov " Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 08/10] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 09/10] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 10/10] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen

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=d487205d-6957-d8c1-678a-38a5668586df@redhat.com \
    --to=jasowang@redhat.com \
    --cc=biannm@cn.fujitsu.com \
    --cc=eddie.dong@intel.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weifuqiang@huawei.com \
    --cc=zhang.zhanghailiang@huawei.com \
    --cc=zhangchen.fnst@cn.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.