Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2660663lqb; Tue, 28 May 2024 06:56:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJbZ9CcNd6icVdN80YFc2pJgm5M/RB5bN42yHHwMvirszGhLzhxD+ef9cxgRzX56TUVJbVO73jTBWk5d1rf8S2zPnUtut+WOpLFiypVw== X-Google-Smtp-Source: AGHT+IGcVVMSfCviIMwbHvky6acsZk58anUDTMhsFLfZJZVA5+syFDl7z2xO+k1hl2qn6uLPG71l X-Received: by 2002:a05:620a:70f8:b0:792:b8c4:31a6 with SMTP id af79cd13be357-794ab0940b4mr1280327485a.35.1716904565438; Tue, 28 May 2024 06:56:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716904565; cv=pass; d=google.com; s=arc-20160816; b=vUc4qylcrfu3Jt2qBVznr+1bGF/Xh94WxfAFx0ksx0VnX5RVQFMs1O+PBARcXicBGv Y+N6DPNdRbniz2xJ/46BGyr2LIpGHHZ7IeHWDao99nsg9xTIEyFlHFwrA4PnRueCg9DR gZ9FFlbxZAmUpUHevMQpUkkBMBidNyXOg+dBDZZG9QGo4iD1Oi4jSakRIW+63+uuq0sg FpkuO1n+nBcpMAQevE14on1uR6XX4GI8bdVb1VbvBqWxYkWCFhAdXlXuuEXe0YQl38kh PVU5eDgVccwij99mmp+RGCB7i45QdnQIHqUgOPgUgTegeniGA3v09iv6FgjjWKpnczvy mZ0A== 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=j7UdCSvSbUmOxvkqY4yQZi9wqG46MeQhtGJgH3+ZkeE=; b=SfPBftV0SRK2zV/3EDyOrOL1NPzKtsHDWVtfktNuNun3ZVDx19LXpQ+EwuV4VM29pE Ti58v2vAo9qxTHOcuGsu/tVoaGAMHq1jo0ZS5pZzwz1YN9xVWBLBRmGZy7pZsG6HJ0Vx NWic9bEDgfEf5SuuMTZPUA5ucI+Fk+8BEdw50zItW6IpQaIT/1/j9tt+tpt03h2VQnwi s0MiF+HseYM9g/o8e+PYdBH5P2gLA9FsJjsyfz6B4LVrRQ+WKi+CiWQQdQc4C8Z2qo0m CC2Bjcl1mibYwWWtaCfEgrQUhKuJzyZo1XhXRxd4USnurocq5G5NiLpfHnpYkibtdmUu KPBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ANG9LWO3; 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-192473-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192473-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb17b96d2si101583771cf.6.2024.05.28.06.56.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 06:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192473-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ANG9LWO3; 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-192473-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192473-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 21F3D1C22B69 for ; Tue, 28 May 2024 13:56:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1C0B17109C; Tue, 28 May 2024 13:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="ANG9LWO3" Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 66B4A16F85B; Tue, 28 May 2024 13:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716904476; cv=none; b=nnxAI5oLg+1ZYeqUnrUtLC+nC9OzhokQauWUE5Ru0WM2yAgyeH0epd/T4L1kYZ85q+GzZ8D8WpnDwNkxCeaEr/LxvDNTQnFx1NJBuIt6qCCl8XWSy1yGhpYPO613IMUMY9+rn90dcl9d8ZOT3x8PzqFanfq4FbNek94ualwFX6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716904476; c=relaxed/simple; bh=ZEjE5gSDkEnEEHSk+YaLYsjF06BS6AizX0EEg8MHbos=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jg7ZawPBxliOtGP/G0rZCcmLlAEIZPu2Uyig5e2SkNuDS8UGr7j5vbXPCwUkmVpOtM3iMFk6JG+MHNsib6V4+9OvfxZBNfvOtYZljJ8QG6K7HvKJUxI0ULLPDKaJURy+i7/pcbMpQPxA3pRwvHBEz2fXRMoLsVlyv5Mujj18688= 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=ANG9LWO3; arc=none smtp.client-ip=67.231.148.174 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 (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44SCK9gB002481; Tue, 28 May 2024 06:54:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=n 3ThqkvFOjh8sW3y6L5JjcHLygVz7+TBKbfwXf77C6w=; b=ANG9LWO3k9EQ0K8qL Zj1BJNOTYcxb0OBdXYbNnq+9E/Y3O2otN85eDewO9Li2YnVtlD5jnum8xkEDTqp5 gSTQH0fNIRYw0Tr9gl1tx0gLVUjPJ/iJJ2a1/Q7sEuMQenSdO1iDIH3hrEhCOZT4 ncSiU75DXiIrx3sQIwo8ibCC4hlkfa49WCir3s1KxUm3m/L7z9DtK7AOUQbvrYMy 2+8e825hNoSBAoBdxc5TrjR0VBScOt8svTu+DlQVSm/Np3guCcOHu+CDLMdE7UYz ujt4ovaKFV1frcxJ4+zrxKW8o87bNavjZVgoLcoGY/3sgPB07o/eYmjFDdL/2AzX Pn7xA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yddn58pe8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 May 2024 06:54:09 -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; Tue, 28 May 2024 06:54:08 -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; Tue, 28 May 2024 06:54:03 -0700 From: Bharat Bhushan To: , , , , , , , , , , , , CC: Subject: [net-next,v3 2/8] octeontx2-pf: Move skb fragment map/unmap to common code Date: Tue, 28 May 2024 19:23:43 +0530 Message-ID: <20240528135349.932669-3-bbhushan2@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240528135349.932669-1-bbhushan2@marvell.com> References: <20240528135349.932669-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: NfQ7LO6vBRRHwXo79l2dU2CPsriIfjv5 X-Proofpoint-ORIG-GUID: NfQ7LO6vBRRHwXo79l2dU2CPsriIfjv5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-28_09,2024-05-28_01,2024-05-17_01 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