From patchwork Fri Oct 5 14:47:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 46177 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 522BE1B2AB; Fri, 5 Oct 2018 16:47:16 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 1FA7C1B135 for ; Fri, 5 Oct 2018 16:47:12 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id BE7C3B40084; Fri, 5 Oct 2018 14:47:10 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 5 Oct 2018 07:47:08 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 5 Oct 2018 07:47:07 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w95El6Fc018894; Fri, 5 Oct 2018 15:47:06 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 5358D1626D2; Fri, 5 Oct 2018 15:47:06 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Fri, 5 Oct 2018 15:47:01 +0100 Message-ID: <1538750823-26291-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538750823-26291-1-git-send-email-arybchenko@solarflare.com> References: <1538750823-26291-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24136.004 X-TM-AS-Result: No-9.287800-4.000000-10 X-TMASE-MatchedRID: 6QDoz0YEpeCjqaJ4m4ncdU1Wvi92YKnOUAjrAJWsTe9ct5jgLX72gKB3 wfMR5ciTYK2MeoqGYrtM8qdoCvOVvj13WcdbGR6QAoNa2r+Edw2PmFSaq6xM+OeB5is8slOZJ7o vlkPXpS3AGzIFxUDKkuMX7wX+rbXfxkSgnHUeW2UMH4SsGvRsA7mnDa2zGPi080VZ5SgxdNDqCC iMStZu129ouIygpjDSO29ybNxer1TZDqKcMoCKOcLPXKYZysJR3b6LzJtd3JWbKItl61J/yZ+in TK0bC9eKrauXd3MZDVfr1DNZ8uC4Ok4ePTIKOfxcWh1mwgtSfWvkktlSkRgeeIUB9yTBqCYwL6S xPpr1/I= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--9.287800-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24136.004 X-MDID: 1538750831-QjFWRbwOIwD9 Subject: [dpdk-dev] [PATCH 1/3] net/sfc: put generalised TSO declarations in a header X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Igor Romanov Move general TSO declarations in a separate header to be able to use them in other datapaths (not only EFX). Also update the function that prepares TSO header to make it useful in other datapaths. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_tso.c | 25 ++++++++++++------------- drivers/net/sfc/sfc_tso.h | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 drivers/net/sfc/sfc_tso.h diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index effe98539..076a25d44 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -14,12 +14,7 @@ #include "sfc_debug.h" #include "sfc_tx.h" #include "sfc_ev.h" - -/** Standard TSO header length */ -#define SFC_TSOH_STD_LEN 256 - -/** The number of TSO option descriptors that precede the packet descriptors */ -#define SFC_TSO_OPDESCS_IDX_SHIFT 2 +#include "sfc_tso.h" int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring, @@ -57,13 +52,14 @@ sfc_efx_tso_free_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring, } } -static void -sfc_efx_tso_prepare_header(struct sfc_efx_txq *txq, struct rte_mbuf **in_seg, - size_t *in_off, unsigned int idx, size_t bytes_left) +unsigned int +sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len, + struct rte_mbuf **in_seg, size_t *in_off) { struct rte_mbuf *m = *in_seg; size_t bytes_to_copy = 0; - uint8_t *tsoh = txq->sw_ring[idx & txq->ptr_mask].tsoh; + size_t bytes_left = header_len; + unsigned int segments_copied = 0; do { bytes_to_copy = MIN(bytes_left, m->data_len); @@ -77,16 +73,20 @@ sfc_efx_tso_prepare_header(struct sfc_efx_txq *txq, struct rte_mbuf **in_seg, if (bytes_left > 0) { m = m->next; SFC_ASSERT(m != NULL); + segments_copied++; } } while (bytes_left > 0); if (bytes_to_copy == m->data_len) { *in_seg = m->next; *in_off = 0; + segments_copied++; } else { *in_seg = m; *in_off = bytes_to_copy; } + + return segments_copied; } int @@ -105,7 +105,7 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, size_t header_len = m->l2_len + m->l3_len + m->l4_len; const efx_nic_cfg_t *encp = efx_nic_cfg_get(txq->evq->sa->nic); - idx += SFC_TSO_OPDESCS_IDX_SHIFT; + idx += SFC_TSO_OPT_DESCS_NUM; /* Packets which have too big headers should be discarded */ if (unlikely(header_len > SFC_TSOH_STD_LEN)) @@ -129,9 +129,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, * limitations on address boundaries crossing by DMA descriptor data. */ if (m->data_len < header_len) { - sfc_efx_tso_prepare_header(txq, in_seg, in_off, idx, - header_len); tsoh = txq->sw_ring[idx & txq->ptr_mask].tsoh; + sfc_tso_prepare_header(tsoh, header_len, in_seg, in_off); header_paddr = rte_malloc_virt2iova((void *)tsoh); } else { diff --git a/drivers/net/sfc/sfc_tso.h b/drivers/net/sfc/sfc_tso.h new file mode 100644 index 000000000..e8b558f50 --- /dev/null +++ b/drivers/net/sfc/sfc_tso.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2018 Solarflare Communications Inc. + * All rights reserved. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +/** Standard TSO header length */ +#define SFC_TSOH_STD_LEN 256 + +/** The number of TSO option descriptors that precede the packet descriptors */ +#define SFC_TSO_OPT_DESCS_NUM 2 + +unsigned int sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len, + struct rte_mbuf **in_seg, size_t *in_off);