From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v7 3/3] net/virtio: support GUEST ANNOUNCE Date: Tue, 09 Jan 2018 12:41:53 +0100 Message-ID: <2111831.jDyPzsQBf4@xps> References: <20180107120513.142196-3-xiao.w.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: Maxime Coquelin , "yliu@fridaylinux.org" , "Bie, Tiwei" , dev@dpdk.org, "stephen@networkplumber.org" To: "Wang, Xiao W" 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) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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