From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC70045BAA; Wed, 23 Oct 2024 07:32:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0354A40A6F; Wed, 23 Oct 2024 07:32:36 +0200 (CEST) Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by mails.dpdk.org (Postfix) with ESMTP id E297B40A6E for ; Wed, 23 Oct 2024 07:32:34 +0200 (CEST) Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3e6104701ffso1871042b6e.0 for ; Tue, 22 Oct 2024 22:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729661554; x=1730266354; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=jhR+QXIa0kf9biyTv7Wkojv4afdD8Y40VLDGmLzDaac=; b=2YbDSjB8Ql+ZJE5og48E/GTzrh13U+TBPxyD1FZpj6LnYIt41I+79+/+QmI3saG/us OM0vY2FutKsqrjKEHSl5s4ojFXjt+ZydL1hJuMtYBxdsaCGaOAU3O1D4XzhdwhwW0/83 H8z2bABcrtsktPpsmvHDPiAHoLgrqpOtrkiLaYQoB2vjmxADC7thrv2mPes/LOfvOpXv KX9eoCjIWDjJhii2xjOSACCkssoJ1qeA3y/N3evdZZfEuWLDmVK4afg+thBtALa09uiX WRb+0RZ1KHisC6b3Xff95qnVxeM1fdKOL8uNEEstsXNU0T9DV6V1ShGxCVtbiA8w3jGN lRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729661554; x=1730266354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jhR+QXIa0kf9biyTv7Wkojv4afdD8Y40VLDGmLzDaac=; b=RAXwN5sHH80tWe7zn485HOtfKlRmfoctb3zVt87JYWQdEmgxo1kvQJktZXtDHy4IFE sMgUlLWm0oj8FQlHaTsLR+moBqJXe6NNGa8FR9JViMQyS5+QU4m2lhSqacBnWQ7pulWi TIGNP4AiKCWVKpqasVal1WPbMTVXXMFwahDZ/u/cFQ0w8j9kM4a1Blb8GHCnZHx6GI5K qsabmK4hVkWSwFiHCMo4rfMd6tpeELGOe0tqYttv2A4/hd3A4SvLhYYSmKTuhLMfnnIa OYuIsbkSt5sXtMDAe0fQP2DzGzaw+4eBfsn2j64EYU3vFPROVkVWdQ1QmGAe5zt2n0FL Cylg== X-Gm-Message-State: AOJu0YxQT3oAFiKg/oLc65LbXqiV9nnU9Ce2lHFZEe5fG0MCy7MUvcW+ 5OuKlWFX3YGj0n0WEx1uSP+ylLsBicgA4oIVAllR48EmGMYEIstnR28lRXbZImA= X-Google-Smtp-Source: AGHT+IFAj1uDVC4DM5m2OHMSGLlgkgd4QtcYYhAobsNX+L7O4KnxUwSq7jtgfY+PpdL640htEpvgBQ== X-Received: by 2002:a05:6871:8d90:b0:277:dc01:75d6 with SMTP id 586e51a60fabf-28ccb5dfe83mr1100868fac.38.1729661553826; Tue, 22 Oct 2024 22:32:33 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec13ea219sm5590024b3a.162.2024.10.22.22.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 22:32:33 -0700 (PDT) Date: Tue, 22 Oct 2024 22:22:53 -0700 From: Stephen Hemminger To: Howard Wang Cc: , Subject: Re: [PATCH v3 12/18] net/r8169: implement Tx path Message-ID: <20241022222253.5a4e905f@hermes.local> In-Reply-To: <20241023033328.191827-13-howard_wang@realsil.com.cn> References: <20241023033328.191827-1-howard_wang@realsil.com.cn> <20241023033328.191827-13-howard_wang@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 23 Oct 2024 11:33:22 +0800 Howard Wang wrote: > +static uint32_t > +rtl8125_get_patch_pad_len(struct rte_mbuf *tx_pkt) > +{ > + uint16_t dest_port = 0; > + uint32_t pad_len = 0; > + int udp_hdr_len = 8; > + int trans_data_len, l4_offset; > + > + if (!(tx_pkt->l4_len && (tx_pkt->data_len < 175))) > + goto no_padding; > + > + l4_offset = tx_pkt->l2_len + tx_pkt->l3_len; > + trans_data_len = tx_pkt->data_len - l4_offset; > + > + if (trans_data_len > 3 && trans_data_len < MIN_PATCH_LENGTH) { > + rte_memcpy(&dest_port, rte_pktmbuf_mtod(tx_pkt, > + struct rte_ether_hdr *) + l4_offset + 2, 2); > + dest_port = ntohs(dest_port); A couple things here. 1. Use the function rte_pktmbuf_mtod_offset to pick up the header. 2. Don't use hard coded offset from that use a local pointer to the type 3. Don't hard code the size of uint16. 4. Don't use rte_memcpy() for trivially small fixed size objects. 5. Avoid useless initializations (like dest_port) 6. Don't hard code size of UDP header.