From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id D1F872E8A for ; Wed, 6 Aug 2014 05:30:32 +0200 (CEST) Received: by mail-pa0-f46.google.com with SMTP id lj1so2561175pab.19 for ; Tue, 05 Aug 2014 20:32:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=AnRZIkSJHai6+jomQcvfCNA01PJLER3tW3ZayEwJ+ko=; b=cpqxT+qCJzK89jQ8dJfHQ/Tl7Q+O3HK3BAOs7o6wz3IBIKRh8dUzXr5uXgbZMt6Lof CgE11I6NU1c3WkH/ddfb3GTI4ztmlZwGVP2vM1E0QpFwwxbnbIm/2y8LBZNFfcczdhqd dbbigbZa5Vfbika/NIgqI2H8p7QP7He52oFeQ5d+xT7ams4Wh7nvzmSB8Zxp9VgYnawU Gx0hc3vI/EnLZeNPWXoKhip6XGKa7VUf5WOy/csYuFObGHZjPjD5JeJnf8KBEw8OEpOt FuRvUIq32gWkXf5eKyoiQbpZWSyXA9zYbmMLeZOHiH35KHMKU4A3Yuzc+tvR/ajVZNP7 eV2w== X-Gm-Message-State: ALoCoQn42/v95+2v7U/2QibKxVeykzmlUpB9o2CQwafrvq4BIWfp8fAmGdGw1QISrNZ6/4ysUlVK X-Received: by 10.68.131.134 with SMTP id om6mr8533207pbb.41.1407295977988; Tue, 05 Aug 2014 20:32:57 -0700 (PDT) Received: from haswell.linuxnetplumber.net (static-50-53-72-226.bvtn.or.frontiernet.net. [50.53.72.226]) by mx.google.com with ESMTPSA id oy3sm5352535pdb.79.2014.08.05.20.32.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Aug 2014 20:32:57 -0700 (PDT) Date: Tue, 5 Aug 2014 20:32:54 -0700 From: Stephen Hemminger To: Huawei Xie Message-ID: <20140805203254.2240a09c@haswell.linuxnetplumber.net> In-Reply-To: <1407254286-23972-4-git-send-email-huawei.xie@intel.com> References: <1407254286-23972-1-git-send-email-huawei.xie@intel.com> <1407254286-23972-4-git-send-email-huawei.xie@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 3/3] examples/vhost: add new vhost example X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2014 03:30:33 -0000 > +static const uint16_t external_pkt_default_vlan_tag = 2000; > +const uint16_t vlan_tags[] = { > + 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, > + 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, > + 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, > + 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, > + 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, > + 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, > + 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, > + 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, > +}; Why pre-compute table if it is just: vlan_tag = n + 1000? > + > +/* Per-device statistics struct */ > +struct device_statistics { > + uint64_t tx_total; > + rte_atomic64_t rx_total_atomic; > + uint64_t rx_total; > + uint64_t tx; > + rte_atomic64_t rx_atomic; > + uint64_t rx; > +} __rte_cache_aligned; > +struct device_statistics dev_statistics[MAX_DEVICES]; Doing per-core statistics would be faster than using atomic's which have implicit lock. > +/* > + * Builds up the correct configuration for VMDQ VLAN pool map > + * according to the pool & queue limits. > + */ > +static inline int > +get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices) > +{ > + struct rte_eth_vmdq_rx_conf conf; > + unsigned i; > + > + memset(&conf, 0, sizeof(conf)); > + conf.nb_queue_pools = (enum rte_eth_nb_pools)num_devices; > + conf.nb_pool_maps = num_devices; > + conf.enable_loop_back = > + vmdq_conf_default.rx_adv_conf.vmdq_rx_conf.enable_loop_back; > + > + for (i = 0; i < conf.nb_pool_maps; i++) { > + conf.pool_map[i].vlan_id = vlan_tags[i]; > + conf.pool_map[i].pools = (1UL << i); > + } > + > + (void)(rte_memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf))); > + (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &conf, > + sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf))); > + return 0; > +} If function always returns 0 just make it void. No point in making non-fastpath code inline. The cast to (void) is unnecessary and just makes things ugly. Why not use structure assignment rather than memcpy() which is not type safe?