Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1957562lqo; Mon, 13 May 2024 03:57:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaV5Mo1qnV7+Snsd9iuUqtvOJsxJLeQP2ykNIEvlduFz4s4Bksvg48iZja+za24tZwKVRPvF97ohrHSNZ7RJctJv91MwLpsFt/edtSNg== X-Google-Smtp-Source: AGHT+IFgZlvx7Vf3HIYofLxxbEov8CM/joQuivme5sBpEnosvskbvzBmiceXAOfDGik6SEd+r777 X-Received: by 2002:a17:90b:792:b0:2b2:a04b:cf4a with SMTP id 98e67ed59e1d1-2b6cc76cd2fmr6505255a91.25.1715597836428; Mon, 13 May 2024 03:57:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715597836; cv=pass; d=google.com; s=arc-20160816; b=EfHF1aI7b/SiVaiwrXY8tWonRZltsMq/XOtzGlOjIt0X5X5Gk+MMWslTEi6b5C/j50 uNUGDw2xVRABvL22jgd0Ql6/QYow/5UMuGhMnPDMn5i6tGj40edunoLzOn4Vs6kRBcCM KbIQdZPnc8WQN4+WPaejM+xl/CH829pjXnZVbGMhgfuhk5ivb+4kwqpcGW6ct8OfMncX HqwAq2561OBpgrFj3JYhe8HNvi656p4oE9i3Z/2a0vCUjINrz2MukSG1dUecdUsw4X9Z 6or2LyKCGdCJtIrIfrc+MThp2HzKjsHlyH6tpDbG6o33OXUW9LGoN14Uy8TxUoEVQirx U/Xw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n3ThqkvFOjh8sW3y6L5JjcHLygVz7+TBKbfwXf77C6w=; fh=bmjP/KIb7yRXxywpA+4EodyCgFIr3x04cvs2nu37av8=; b=Urp6mX8VZWdq1XepxG04GjKUGmDKTq71z2TenUhHCPBf59+y+16OlbPK7ipnOZ1Vm/ KlK6KXrvU2XZv+CjZkcaSziLzrp8dP1FcUpqCJpzsV67UlHPvb3eUEPSMZX6Bbx0fZ2V sz7ZEQxvUuunZhfNz0a43r5Gz9jTeX3HSKWAJNogfLL9udcbFCZj19M2YTxg/b3gSS/D w9NXsOmUNBSyOc3ad+UhBSlFBn3vLTWMK5YJGOkn31qI+4sfWoka895LWlIMtOM9VwmF iTVtBXDkME2DjhV411lzlollUOqwp6oWFp3GgbMdBwqV3+wjqrn0S06mqZqOI7dmO+yy b27A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=hmRI5Za2; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-177480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6c7fdef93si7792068a91.113.2024.05.13.03.57.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 03:57:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=hmRI5Za2; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-177480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DC749B22B85 for ; Mon, 13 May 2024 10:55:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9909C14D703; Mon, 13 May 2024 10:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="hmRI5Za2" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 460EC14D29C; Mon, 13 May 2024 10:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715597720; cv=none; b=QRWlTwxoVNmY1BBT7eDeLrY7b8y9W/SUUbofhS0DPxetfF/ZfXVFbXgqGZZLfI61ynLcNF2QDnkILQhbKFvoU2kLdww4C+0RYZBXyjWV9WCV81NfXnybRKEmwkVHoOyoHJGvGW4GA0hHAwry6pYtcto22dUe8dEXbpKI1GRApQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715597720; c=relaxed/simple; bh=ZEjE5gSDkEnEEHSk+YaLYsjF06BS6AizX0EEg8MHbos=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bK5TZ4667ma/psuHdocZzyKGiZsBwWFGAWwab2JEg8SBzxaaRM1e50ZS3Tz0bGs6cm4FahDyGfdkAC4oM2sl4fqOm8/e3qx1dEWWObxMesRVNNfVM5HcgFNwrz/EIgalOHSSwlLQU464pvbmsMNiaDUxjtghXlEt+lvbG9lodFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=hmRI5Za2; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44D8X8GY002142; Mon, 13 May 2024 03:55:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=n3ThqkvFOjh8sW3y6L5JjcHLygVz7+TBKbfwXf77C6w=; b=hmR I5Za2lxnTbxdqmcW7Sm06ercJWsak+7sBmeWTgQidz8OYbckOXFNcmJJrC0LZyqt It+OT04P5w5IgCFMA6lGqKiosgbtK+JKpyTjGTg2GWJpmh2aAiP1C2zCiVJEXDkt m/aAMxlmq6P1qm0lHA1DMySKKqPtInInTNQPlrKn5PniCHMKeCrHfwQFJ+TXGtkS HzZN1/TodC1pF1pLgxc2alEKZFBxkbET1xuLGuvfnTkpBzacquz/yUs91n5s3QnT H16M0LVT1mZZ23auttj++GR3mj9AC1/aTc+KNEShyIR14CPADFKj3/iToe8eOrPX KYibJYbWnRUdcsiNfNQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3y286jbyb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 May 2024 03:55:06 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 13 May 2024 03:55:05 -0700 Received: from bharat-OptiPlex-3070.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 13 May 2024 03:55:00 -0700 From: Bharat Bhushan To: , , , , , , , , , , , , CC: Bharat Bhushan Subject: [net-next,v2 2/8] octeontx2-pf: Move skb fragment map/unmap to common code Date: Mon, 13 May 2024 16:24:40 +0530 Message-ID: <20240513105446.297451-3-bbhushan2@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513105446.297451-1-bbhushan2@marvell.com> References: <20240513105446.297451-1-bbhushan2@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: cOgp4MDQD36pe_xRv_WKnebW4aczbUKy X-Proofpoint-ORIG-GUID: cOgp4MDQD36pe_xRv_WKnebW4aczbUKy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-13_07,2024-05-10_02,2023-05-22_02 Move skb fragment map/unmap function to common file so as to re-use same for inline ipsec transmit Signed-off-by: Bharat Bhushan --- .../marvell/octeontx2/nic/otx2_common.c | 32 +++++++++++++++++++ .../marvell/octeontx2/nic/otx2_common.h | 3 ++ .../marvell/octeontx2/nic/otx2_txrx.c | 32 ------------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index a85ac039d779..7ec99c8d610c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c @@ -1911,3 +1911,35 @@ EXPORT_SYMBOL(otx2_mbox_up_handler_ ## _fn_name); MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES #undef M + +dma_addr_t otx2_dma_map_skb_frag(struct otx2_nic *pfvf, + struct sk_buff *skb, int seg, int *len) +{ + const skb_frag_t *frag; + struct page *page; + int offset; + + /* First segment is always skb->data */ + if (!seg) { + page = virt_to_page(skb->data); + offset = offset_in_page(skb->data); + *len = skb_headlen(skb); + } else { + frag = &skb_shinfo(skb)->frags[seg - 1]; + page = skb_frag_page(frag); + offset = skb_frag_off(frag); + *len = skb_frag_size(frag); + } + return otx2_dma_map_page(pfvf, page, offset, *len, DMA_BIDIRECTIONAL); +} + +void otx2_dma_unmap_skb_frags(struct otx2_nic *pfvf, struct sg_list *sg) +{ + int seg; + + for (seg = 0; seg < sg->num_segs; seg++) { + otx2_dma_unmap_page(pfvf, sg->dma_addr[seg], + sg->size[seg], DMA_BIDIRECTIONAL); + } + sg->num_segs = 0; +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index 24fbbef265a6..99b480e21e1c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -1128,4 +1128,7 @@ u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb, int otx2_get_txq_by_classid(struct otx2_nic *pfvf, u16 classid); void otx2_qos_config_txschq(struct otx2_nic *pfvf); void otx2_clean_qos_queues(struct otx2_nic *pfvf); +dma_addr_t otx2_dma_map_skb_frag(struct otx2_nic *pfvf, + struct sk_buff *skb, int seg, int *len); +void otx2_dma_unmap_skb_frags(struct otx2_nic *pfvf, struct sg_list *sg); #endif /* OTX2_COMMON_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c index 847052b57d9b..f368eac28fdd 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c @@ -80,38 +80,6 @@ static unsigned int frag_num(unsigned int i) #endif } -static dma_addr_t otx2_dma_map_skb_frag(struct otx2_nic *pfvf, - struct sk_buff *skb, int seg, int *len) -{ - const skb_frag_t *frag; - struct page *page; - int offset; - - /* First segment is always skb->data */ - if (!seg) { - page = virt_to_page(skb->data); - offset = offset_in_page(skb->data); - *len = skb_headlen(skb); - } else { - frag = &skb_shinfo(skb)->frags[seg - 1]; - page = skb_frag_page(frag); - offset = skb_frag_off(frag); - *len = skb_frag_size(frag); - } - return otx2_dma_map_page(pfvf, page, offset, *len, DMA_BIDIRECTIONAL); -} - -static void otx2_dma_unmap_skb_frags(struct otx2_nic *pfvf, struct sg_list *sg) -{ - int seg; - - for (seg = 0; seg < sg->num_segs; seg++) { - otx2_dma_unmap_page(pfvf, sg->dma_addr[seg], - sg->size[seg], DMA_BIDIRECTIONAL); - } - sg->num_segs = 0; -} - static void otx2_xdp_snd_pkt_handler(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, struct nix_cqe_tx_s *cqe) -- 2.34.1