From patchwork Mon Dec 12 03:24:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 32235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2024557wrr; Sun, 11 Dec 2022 19:25:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6I8LMOfN54vNf7FLSk3QraBDiQ/3DqHHUfwx36l9N0xf7oMiTCx2Cv2WB7R3bfotQcWyr7 X-Received: by 2002:a05:6a20:6f90:b0:a7:e65:2b65 with SMTP id gv16-20020a056a206f9000b000a70e652b65mr17999952pzb.23.1670815532054; Sun, 11 Dec 2022 19:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670815532; cv=none; d=google.com; s=arc-20160816; b=gSkKHyZdOW1D4QxlrmqZTJEkPhvrPYTM/urSemV2AG7MgOVdGGQpDdtF1gleFH2I0x a9jfcA11EbXop0EzMVdX6E29xaNkEhpeC7JtPigBBE9T69JkKLQtRfCMcGPVgGuKNdfu yrhTn7Hp0CtgEZoxAhpjeG0SPuH1MHcPiDduePhuSA35fT6ke8bX5VMsPJ7ZMIFxSr1F sTeLSzpajJVBlGdV02rwtuZP8iLyBO0ze+BSzOS2bKs0/i0FgMmXAr5/u1eFGimLIfMW mIEsq0AU9Umb0yzA6QDXIxa9ig/ePlym78PYhmWtTsGb+ktoHlaWGjV+o+O2tNN903/E z5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2kv6taADrUXZGWEAA29gEjPDVJ72VTv8pYf+Q3uWIsA=; b=MOda1pBluZOWEK9mv00kEnM39F0LcLlr2+efLnjGYiO45FbCOf3GfMhHVIg4RDasIt A7BBq8E041akV0r+kTpAbUoCdHUNc5/Z7dAVPXUTapB8jeb4/SFBsqx4q47+extTHpcd qaNVRQnwEbkjA0T2Trj6byEiNtdTifHAQcWIPtlGX7O0ZZOSgNXQHvrnrrz+yfiHLpxQ /N0GdJpcB7J7z8RbQTz5x9nfzAiFCPPbBnthpZ/8bUe62i3maAG/wGNCKWooptyPsXC3 x1IjKmEEZZTu8tErPg5eF4rCsMtvA1T2Z7YBt6aRggW+vzD2W9tkV7EN4tkiXBaCX/vJ TyGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t64-20020a638143000000b004772e485146si7955281pgd.6.2022.12.11.19.25.18; Sun, 11 Dec 2022 19:25:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbiLLDYY (ORCPT + 99 others); Sun, 11 Dec 2022 22:24:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbiLLDYW (ORCPT ); Sun, 11 Dec 2022 22:24:22 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8257BE38; Sun, 11 Dec 2022 19:24:21 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NVn5S431hz15NKR; Mon, 12 Dec 2022 11:23:24 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 12 Dec 2022 11:24:19 +0800 From: Yunsheng Lin To: , , , CC: , , Subject: [PATCH net-next v2] net: tso: inline tso_count_descs() Date: Mon, 12 Dec 2022 11:24:26 +0800 Message-ID: <20221212032426.16050-1-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751977067284698942?= X-GMAIL-MSGID: =?utf-8?q?1751977067284698942?= tso_count_descs() is a small function doing simple calculation, and tso_count_descs() is used in fast path, so inline it to reduce the overhead of calls. Signed-off-by: Yunsheng Lin --- V2: include skbuff.h explicitly and refactor comment as jakub's suggestion. --- include/net/tso.h | 8 +++++++- net/core/tso.c | 8 -------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/net/tso.h b/include/net/tso.h index 62c98a9c60f1..e7e157ae0526 100644 --- a/include/net/tso.h +++ b/include/net/tso.h @@ -2,6 +2,7 @@ #ifndef _TSO_H #define _TSO_H +#include #include #define TSO_HEADER_SIZE 256 @@ -16,7 +17,12 @@ struct tso_t { u32 tcp_seq; }; -int tso_count_descs(const struct sk_buff *skb); +/* Calculate the worst case buffer count */ +static inline int tso_count_descs(const struct sk_buff *skb) +{ + return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; +} + void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, int size, bool is_last); void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size); diff --git a/net/core/tso.c b/net/core/tso.c index 4148f6d48953..e00796e3b146 100644 --- a/net/core/tso.c +++ b/net/core/tso.c @@ -5,14 +5,6 @@ #include #include -/* Calculate expected number of TX descriptors */ -int tso_count_descs(const struct sk_buff *skb) -{ - /* The Marvell Way */ - return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; -} -EXPORT_SYMBOL(tso_count_descs); - void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, int size, bool is_last) {