From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A865E8E6A for ; Tue, 12 Jan 2016 17:18:38 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 12 Jan 2016 08:18:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,558,1444719600"; d="scan'208";a="888996647" Received: from tanjianf-mobl.ccr.corp.intel.com (HELO [10.255.25.24]) ([10.255.25.24]) by orsmga002.jf.intel.com with ESMTP; 12 Jan 2016 08:18:35 -0800 To: Amit Tomer References: <1446748276-132087-1-git-send-email-jianfeng.tan@intel.com> <1452426182-86851-1-git-send-email-jianfeng.tan@intel.com> <058a01d14c7b$5cdc60d0$16952270$@samsung.com> <5693CFE4.4060405@intel.com> <009a01d14d0c$3ab6cd60$b0246820$@samsung.com> <00b101d14d14$bab82510$30286f30$@samsung.com> <5694BE75.7010708@intel.com> <00d901d14d26$d04fc600$70ef5200$@samsung.com> <56951357.2030008@intel.com> From: "Tan, Jianfeng" Message-ID: <5695275A.5050203@intel.com> Date: Wed, 13 Jan 2016 00:18:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: nakajima.yoshihiro@lab.ntt.co.jp, "Michael S. Tsirkin" , dev@dpdk.org, ann.zhuangyanying@huawei.com Subject: Re: [dpdk-dev] [PATCH 0/4] virtio support for container 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: Tue, 12 Jan 2016 16:18:39 -0000 Hello, On 1/12/2016 11:11 PM, Amit Tomer wrote: > Hello, > >> In vhost-switch, it judges if a virtio device is ready for processing after >> receiving >> a pkt from virtio device. So you'd better construct a pkt, and send it out >> firstly >> in l2fwd. > I tried to ping the socket interface from host for the same purpose > but it didn't work. > > Could you please suggest some other approach for achieving same(how > pkt can be sent out to l2fwd)? > > Also, before trying this, I have verified that vhost-switch is working > ok with testpmd . > > Thanks, > Amit. You can use below patch for l2fwd to send out an arp packet when it gets started. diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 720fd5a..572b1ac 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -69,6 +69,8 @@ #include #include +#define SEND_ARP + #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 #define NB_MBUF 8192 @@ -185,6 +187,53 @@ print_stats(void) printf("\n====================================================\n"); } +#ifdef SEND_ARP +static void +dpdk_send_arp(int portid, struct rte_mempool *mp) +{ + /* + * len = 14 + 46 + * ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 46 + */ + static const uint8_t arp_request[] = { + /*0x0000:*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xec, 0xa8, 0x6b, 0xfd, 0x02, 0x29, 0x08, 0x06, 0x00, 0x01, + /*0x0010:*/ 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xec, 0xa8, 0x6b, 0xfd, 0x02, 0x29, 0x0a, 0x00, 0x00, 0x01, + /*0x0020:*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*0x0030:*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + int ret; + struct rte_mbuf *m; + struct ether_addr mac_addr; + int pkt_len = sizeof(arp_request) - 1; + + m = rte_pktmbuf_alloc(mp); + + memcpy((void *)((uint64_t)m->buf_addr + m->data_off), arp_request, pkt_len); + rte_pktmbuf_pkt_len(m) = pkt_len; + rte_pktmbuf_data_len(m) = pkt_len; + + rte_eth_macaddr_get(portid, &mac_addr); + memcpy((void *)((uint64_t)m->buf_addr + m->data_off + 6), &mac_addr, 6); + + ret = rte_eth_tx_burst(portid, 0, &m, 1); + if (ret == 1) { + printf("arp sent: ok\n"); + printf("%02x:%02x:%02x:%02x:%02x:%02x\n", + mac_addr.addr_bytes[0], + mac_addr.addr_bytes[1], + mac_addr.addr_bytes[2], + mac_addr.addr_bytes[3], + mac_addr.addr_bytes[4], + mac_addr.addr_bytes[5]); + } else { + printf("arp sent: fail\n"); + } + + rte_pktmbuf_free(m); +} +#endif + + /* Send the burst of packets on an output interface */ static int l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port) @@ -281,6 +330,9 @@ l2fwd_main_loop(void) portid = qconf->rx_port_list[i]; RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id, portid); +#ifdef SEND_ARP + dpdk_send_arp(portid, l2fwd_pktmbuf_pool); +#endif } while (1) {