From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id CD2DD1B169 for ; Tue, 9 Jan 2018 12:42:17 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 48B4720AC6; Tue, 9 Jan 2018 06:42:17 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 09 Jan 2018 06:42:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=2O8iu9ocdnmLXm8vyV8+NOoxPO M3VaS3qre2pxwYOro=; b=jsbq9c+v36HmUsWs21a6fqWTKwGZ+PKEqxspMhV+fd ZJDoEQQWRyh4SJp/pnUFPSVKdfnxRNSbZ3NczakoBoUwzuPRmr8p2ytcTLE4pwpU G6BXqJAfNR70dzUSFMGtexvG4yxY8Y+CQkU9ufIf30tQRIBOgDOcCWz0YhyYXNw3 A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=2O8iu9 ocdnmLXm8vyV8+NOoxPOM3VaS3qre2pxwYOro=; b=orOgwkYMPqA4k5VJfaJWA8 sKxABslf5GfuCf5G+n82nYDiIxobB3DuqLomCMeZP64E1yK+skx6wiitF8i2SP6Y ZUPUwfImcI1wSNoiPTFzh9hr/R1ui6JDiMWUFhwvc16+/hgmF7i5FcJJbZzb4LIA vLhAJmTeR+XYCJuT0SzIITa0WFZCGIa9yRq/+3C18SM/JY1t8+8KKLIjRvG+S9yd 9Y4EdFJjaFh2/mBjCgYFiq8FKY5bOqxVh0J9iZVNkMCrhY0GdmfWRat6tsDxBUfv B0mr4PTxh7NL08oRrXOKW+NIIDzM7eewVOjHVaiouhFxg2o1lCgkzIejwgv7J89Q == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id EFFFF7E4C6; Tue, 9 Jan 2018 06:42:16 -0500 (EST) From: Thomas Monjalon To: "Wang, Xiao W" Cc: Maxime Coquelin , "yliu@fridaylinux.org" , "Bie, Tiwei" , dev@dpdk.org, "stephen@networkplumber.org" Date: Tue, 09 Jan 2018 12:41:53 +0100 Message-ID: <2111831.jDyPzsQBf4@xps> In-Reply-To: References: <20180107120513.142196-3-xiao.w.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v7 3/3] net/virtio: support GUEST ANNOUNCE X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 11:42:18 -0000 09/01/2018 12:03, Wang, Xiao W: > > From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com] > > On 01/09/2018 03:26 PM, Xiao Wang wrote: > > > +#define RARP_PKT_SIZE 64 > > > +static int > > > +make_rarp_packet(struct rte_mbuf *rarp_mbuf, const struct ether_addr > > *mac) > > > +{ > > > + struct ether_hdr *eth_hdr; > > > + struct arp_hdr *rarp; > > > + > > > + if (rarp_mbuf->buf_len < RARP_PKT_SIZE) { > > > + PMD_DRV_LOG(ERR, "mbuf size too small %u (< %d)", > > > + rarp_mbuf->buf_len, RARP_PKT_SIZE); > > > + return -1; > > > + } > > > + > > > + /* Ethernet header. */ > > > + eth_hdr = rte_pktmbuf_mtod(rarp_mbuf, struct ether_hdr *); > > > + memset(eth_hdr->d_addr.addr_bytes, 0xff, ETHER_ADDR_LEN); > > > + ether_addr_copy(mac, ð_hdr->s_addr); > > > + eth_hdr->ether_type = htons(ETHER_TYPE_RARP); > > > + > > > + /* RARP header. */ > > > + rarp = (struct arp_hdr *)(eth_hdr + 1); > > > + rarp->arp_hrd = htons(ARP_HRD_ETHER); > > > + rarp->arp_pro = htons(ETHER_TYPE_IPv4); > > > + rarp->arp_hln = ETHER_ADDR_LEN; > > > + rarp->arp_pln = 4; > > > + rarp->arp_op = htons(ARP_OP_REVREQUEST); > > > + > > > + ether_addr_copy(mac, &rarp->arp_data.arp_sha); > > > + ether_addr_copy(mac, &rarp->arp_data.arp_tha); > > > + memset(&rarp->arp_data.arp_sip, 0x00, 4); > > > + memset(&rarp->arp_data.arp_tip, 0x00, 4); > > > + > > > + rarp_mbuf->data_len = RARP_PKT_SIZE; > > > + rarp_mbuf->pkt_len = RARP_PKT_SIZE; > > > + > > > + return 0; > > > +} > > > > Do you think it could make sense to have this function in a lib, as > > vhost user lib does exactly the same? > > > > I don't know if it could be useful to others than vhost/virtio though. > > Hi Thomas, > > Do you think it's worth adding a new helper for ARP in lib/librte_net/? > Currently we just need a helper to build RARP packet (the above make_rarp_packet) Yes, good idea