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 ED755A054A for ; Thu, 8 Sep 2022 18:58:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4752427EA; Thu, 8 Sep 2022 18:58:43 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by mails.dpdk.org (Postfix) with ESMTP id 906C34021F; Thu, 8 Sep 2022 18:58:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lxJlSfjpxE9vHhfW+DYLHP58QNlkjh4abESltUd42Ktw7m/wb4n+JxtXak6jtuHja4syxY8O53D43vUZ5FQZIDdVDTdxK/PXyh0FlZYIntZ17BaVt4gO5Rwa5gBMYqHWQz3NcZW4lKM51ASEzzEp3PNrZmoVnYp4I84THDU8VQxSQoGXkXfHjTLhoUsn3P+rdywTuur26t+bH6GNf0nA3G+W9f/QZVWIApvS3W4b2boXEuieLbmxNU2yRkm2MkZWnhh5ni9GRA2zxDRaFmiSF5+dYj6in7rar5JjbuuaaaBVYGHYEcbmT4GETWNCIQlaU9dhu4woAD7ZP3+JgkmlZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e+ORanh3PmTTb6CbFoOeEGd4FaWEFvoCmQ6+enzMlGs=; b=T/N9Qe2aS5iQZsuF8JqKgoltejDz1SFcYWcTtIVThhsSjnswOHuGSFTro8Chtk9zkId6b5zvMY1baZtJgPI0VhckKxsr2yNqpRpVBBWlQfwXpKzI5vuNSS6qc2fjUwfafmaSGtNPvdLyrUwkcQwe7xwKcG8oDy6o5AqPoMEzOQKfYAwHXwYqTgHvvpr0876tynL5yyyqDyYfsX2TcaW15ycnywcC9E1rqaoYnj+B0b5Wu5JagYbAXC6koYQqCZpU8J6c7Gar0Xw12ZbNfwrvyRPXDYGfsmd7z2d2dJGKKbQ5V21M/kULW59+0+8sFIDWZ1Kvpxf6k//LnohVXKOeXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e+ORanh3PmTTb6CbFoOeEGd4FaWEFvoCmQ6+enzMlGs=; b=e0M4MEh8mc3Ss27Xb/nrEf+NaEiZFcRjsE3URNAdh4hjGrFaui9ElzsNLg+S8ZcbhI6dCEs9nZXh0JTC5Bzd45e6vUvWOvA6zo+3stXA+7vF8HXuqQj/yKWC4QEcMNypOJv9DTvwDRZuuujk4WaucKvgTeTL1GWa0BFKGb0uayA= Received: from DS7PR03CA0040.namprd03.prod.outlook.com (2603:10b6:5:3b5::15) by CH0PR12MB5220.namprd12.prod.outlook.com (2603:10b6:610:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.16; Thu, 8 Sep 2022 16:58:39 +0000 Received: from DM6NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b5:cafe::d9) by DS7PR03CA0040.outlook.office365.com (2603:10b6:5:3b5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12 via Frontend Transport; Thu, 8 Sep 2022 16:58:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT096.mail.protection.outlook.com (10.13.173.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5612.13 via Frontend Transport; Thu, 8 Sep 2022 16:58:38 +0000 Received: from cae-Selwin.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 8 Sep 2022 11:58:36 -0500 From: Bhagyada Modali To: , CC: , , Bhagyada Modali Subject: [PATCH] net/axgbe: support segmented Tx Date: Thu, 8 Sep 2022 12:58:17 -0400 Message-ID: <20220908165817.6536-1-bhagyada.modali@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT096:EE_|CH0PR12MB5220:EE_ X-MS-Office365-Filtering-Correlation-Id: 33570168-c48c-4358-0375-08da91bb608b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5GpvUiXAmo3ai/LHpoDHu34V35ZtO5Yj+CzAl2LZKcts3n+sG6GkW/IlO6+W/dPj+xidnQt6NaNP3WFJTLq9Js1hBIk3HSm4u5q/kfD7+cfcZSqKhIY6Acid763iCIInLOO7RCit1qyYSxCNhK6qW/gr6WoeylOwt91KLUcxt2ANmlz7I4Oy9Ur0WfATdOP/1VHnfMCLxD0ArMZ90YmGB76Lpx6OEl63NGmKEVg1j7OiFmhXRQqk3CzTKNwUOJClBAuDPyosEATVFgA1d6oItQGanrObuUXqa+B6H3LCgXH8srHCcrCwC7brml3tcKj9JsHXUtpr5sRQDeG0BwwQOxwOgvMT/25r4k8BB+zfCx3wYviELpSHDeDFNnUKpmvdu6sohGL5qJV1t3iLOcr2IKmpZYiUYXS6F5LexQCOtMZqurQo5UYR+/onSlmljzCB5w6+P1XS977nqC8uXd1a+27oXM+vNgw3piQRpswNrPzM7dZkePsAyChFNqkkq2YUIsJzfdHCx8QQ2COyFDfQX7HcBoEhKSzsd7QpXKX75KOeSdmW9m236vE4AJGMVmyeWsy0kdZeB4pfkoWYEDNScElPr9OIGPcSK5NSWu/mbjDtZagxhl6y8NZzq1AVTufNbm19dbq2D+TGh0GcYYVXQDQinpIvuWlwU+QBZDJ2sOeRq/kQsMBpDIMi3m8qhNhWnJFUNtBkcYrE1ToyEynDjZqgTKZLp1WkbRQLaWWDKVOKpoCgjRavOhVPZb+/HglX7yfRcemJT0zaVCSO+PbksyQHFLjleNqS9n2B0jw+1wn2FZxIMbn5ReZhBsCk+DPa X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(346002)(136003)(376002)(36840700001)(46966006)(40470700004)(8676002)(450100002)(82310400005)(40480700001)(70206006)(70586007)(86362001)(4326008)(82740400003)(2616005)(6636002)(336012)(1076003)(8936002)(16526019)(5660300002)(40460700003)(316002)(54906003)(110136005)(36756003)(44832011)(2906002)(7696005)(41300700001)(36860700001)(356005)(26005)(478600001)(81166007)(6666004)(186003)(426003)(83380400001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2022 16:58:38.9887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33570168-c48c-4358-0375-08da91bb608b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5220 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Enable segmented tx support and add jumbo packet transmit capability Signed-off-by: Bhagyada Modali --- drivers/net/axgbe/axgbe_ethdev.c | 1 + drivers/net/axgbe/axgbe_ethdev.h | 1 + drivers/net/axgbe/axgbe_rxtx.c | 215 ++++++++++++++++++++++++++++++- drivers/net/axgbe/axgbe_rxtx.h | 4 + 4 files changed, 220 insertions(+), 1 deletion(-) diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index e6822fa711..b071e4e460 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -1228,6 +1228,7 @@ axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_ETH_TX_OFFLOAD_VLAN_INSERT | RTE_ETH_TX_OFFLOAD_QINQ_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | + RTE_ETH_TX_OFFLOAD_MULTI_SEGS | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM; diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index e06d40f9eb..7f19321d88 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -582,6 +582,7 @@ struct axgbe_port { unsigned int tx_pbl; unsigned int tx_osp_mode; unsigned int tx_max_fifo_size; + unsigned int multi_segs_tx; /* Rx settings */ unsigned int rx_sf_mode; diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c index 8b43e8160b..c32ebe24bb 100644 --- a/drivers/net/axgbe/axgbe_rxtx.c +++ b/drivers/net/axgbe/axgbe_rxtx.c @@ -544,6 +544,7 @@ int axgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, unsigned int tsize; const struct rte_memzone *tz; uint64_t offloads; + struct rte_eth_dev_data *dev_data = dev->data; tx_desc = nb_desc; pdata = dev->data->dev_private; @@ -611,7 +612,13 @@ int axgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, if (!pdata->tx_queues) pdata->tx_queues = dev->data->tx_queues; - if (txq->vector_disable || + if ((dev_data->dev_conf.txmode.offloads & + RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) + pdata->multi_segs_tx = true; + + if (pdata->multi_segs_tx) + dev->tx_pkt_burst = &axgbe_xmit_pkts_seg; + else if (txq->vector_disable || rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_128) dev->tx_pkt_burst = &axgbe_xmit_pkts; else @@ -762,6 +769,29 @@ void axgbe_dev_enable_tx(struct rte_eth_dev *dev) AXGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 1); } +/* Free Tx conformed mbufs segments */ +static void +axgbe_xmit_cleanup_seg(struct axgbe_tx_queue *txq) +{ + volatile struct axgbe_tx_desc *desc; + uint16_t idx; + + idx = AXGBE_GET_DESC_IDX(txq, txq->dirty); + while (txq->cur != txq->dirty) { + if (unlikely(idx == txq->nb_desc)) + idx = 0; + desc = &txq->desc[idx]; + /* Check for ownership */ + if (AXGMAC_GET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, OWN)) + return; + memset((void *)&desc->desc2, 0, 8); + /* Free mbuf */ + rte_pktmbuf_free_seg(txq->sw_ring[idx]); + txq->sw_ring[idx++] = NULL; + txq->dirty++; + } +} + /* Free Tx conformed mbufs */ static void axgbe_xmit_cleanup(struct axgbe_tx_queue *txq) { @@ -854,6 +884,189 @@ static int axgbe_xmit_hw(struct axgbe_tx_queue *txq, return 0; } +/* Tx Descriptor formation for segmented mbuf + * Each mbuf will require multiple descriptors + */ + +static int +axgbe_xmit_hw_seg(struct axgbe_tx_queue *txq, + struct rte_mbuf *mbuf) +{ + volatile struct axgbe_tx_desc *desc; + uint16_t idx; + uint64_t mask; + int start_index; + uint32_t pkt_len = 0; + int nb_desc_free; + struct rte_mbuf *tx_pkt; + + nb_desc_free = txq->nb_desc - (txq->cur - txq->dirty); + + if (mbuf->nb_segs > nb_desc_free) { + axgbe_xmit_cleanup_seg(txq); + nb_desc_free = txq->nb_desc - (txq->cur - txq->dirty); + if (unlikely(mbuf->nb_segs > nb_desc_free)) + return RTE_ETH_TX_DESC_UNAVAIL; + } + + idx = AXGBE_GET_DESC_IDX(txq, txq->cur); + desc = &txq->desc[idx]; + /* Saving the start index for setting the OWN bit finally */ + start_index = idx; + + tx_pkt = mbuf; + /* Max_pkt len = 9018 ; need to update it according to Jumbo pkt size */ + pkt_len = tx_pkt->pkt_len; + + /* Update buffer address and length */ + desc->baddr = rte_mbuf_data_iova(tx_pkt); + AXGMAC_SET_BITS_LE(desc->desc2, TX_NORMAL_DESC2, HL_B1L, + tx_pkt->data_len); + /* Total msg length to transmit */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, FL, + tx_pkt->pkt_len); + /* Timestamp enablement check */ + if (mbuf->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST) + AXGMAC_SET_BITS_LE(desc->desc2, TX_NORMAL_DESC2, TTSE, 1); + + rte_wmb(); + /* Mark it as First Descriptor */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, FD, 1); + /* Mark it as a NORMAL descriptor */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, CTXT, 0); + /* configure h/w Offload */ + mask = mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK; + if (mask == RTE_MBUF_F_TX_TCP_CKSUM || mask == RTE_MBUF_F_TX_UDP_CKSUM) + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, CIC, 0x3); + else if (mbuf->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, CIC, 0x1); + rte_wmb(); + + if (mbuf->ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) { + /* Mark it as a CONTEXT descriptor */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_CONTEXT_DESC3, + CTXT, 1); + /* Set the VLAN tag */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_CONTEXT_DESC3, + VT, mbuf->vlan_tci); + /* Indicate this descriptor contains the VLAN tag */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_CONTEXT_DESC3, + VLTV, 1); + AXGMAC_SET_BITS_LE(desc->desc2, TX_NORMAL_DESC2, VTIR, + TX_NORMAL_DESC2_VLAN_INSERT); + } else { + AXGMAC_SET_BITS_LE(desc->desc2, TX_NORMAL_DESC2, VTIR, 0x0); + } + rte_wmb(); + + /* Save mbuf */ + txq->sw_ring[idx] = tx_pkt; + /* Update current index*/ + txq->cur++; + + tx_pkt = tx_pkt->next; + + while (tx_pkt != NULL) { + idx = AXGBE_GET_DESC_IDX(txq, txq->cur); + desc = &txq->desc[idx]; + + /* Update buffer address and length */ + desc->baddr = rte_mbuf_data_iova(tx_pkt); + + AXGMAC_SET_BITS_LE(desc->desc2, + TX_NORMAL_DESC2, HL_B1L, tx_pkt->data_len); + + rte_wmb(); + + /* Mark it as a NORMAL descriptor */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, CTXT, 0); + /* configure h/w Offload */ + mask = mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK; + if (mask == RTE_MBUF_F_TX_TCP_CKSUM || + mask == RTE_MBUF_F_TX_UDP_CKSUM) + AXGMAC_SET_BITS_LE(desc->desc3, + TX_NORMAL_DESC3, CIC, 0x3); + else if (mbuf->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) + AXGMAC_SET_BITS_LE(desc->desc3, + TX_NORMAL_DESC3, CIC, 0x1); + + rte_wmb(); + + /* Set OWN bit */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, OWN, 1); + rte_wmb(); + + /* Save mbuf */ + txq->sw_ring[idx] = tx_pkt; + /* Update current index*/ + txq->cur++; + + tx_pkt = tx_pkt->next; + + } + + /* Set LD bit for the last descriptior */ + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, LD, 1); + rte_wmb(); + + /* Update stats */ + txq->bytes += pkt_len; + + /* Set OWN bit for the first descriptor */ + desc = &txq->desc[start_index]; + AXGMAC_SET_BITS_LE(desc->desc3, TX_NORMAL_DESC3, OWN, 1); + rte_wmb(); + + return 0; +} + +/* Eal supported tx wrapper- Segmented*/ +uint16_t +axgbe_xmit_pkts_seg(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + PMD_INIT_FUNC_TRACE(); + + struct axgbe_tx_queue *txq; + uint16_t nb_desc_free; + uint16_t nb_pkt_sent = 0; + uint16_t idx; + uint32_t tail_addr; + struct rte_mbuf *mbuf = NULL; + + if (unlikely(nb_pkts == 0)) + return nb_pkts; + + txq = (struct axgbe_tx_queue *)tx_queue; + + nb_desc_free = txq->nb_desc - (txq->cur - txq->dirty); + if (unlikely(nb_desc_free <= txq->free_thresh)) { + axgbe_xmit_cleanup_seg(txq); + nb_desc_free = txq->nb_desc - (txq->cur - txq->dirty); + if (unlikely(nb_desc_free == 0)) + return 0; + } + + while (nb_pkts--) { + + mbuf = *tx_pkts++; + + if (axgbe_xmit_hw_seg(txq, mbuf)) + goto out; + nb_pkt_sent++; + } +out: + /* Sync read and write */ + rte_mb(); + idx = AXGBE_GET_DESC_IDX(txq, txq->cur); + tail_addr = low32_value(txq->ring_phys_addr + + idx * sizeof(struct axgbe_tx_desc)); + /* Update tail reg with next immediate address to kick Tx DMA channel*/ + AXGMAC_DMA_IOWRITE(txq, DMA_CH_TDTR_LO, tail_addr); + txq->pkts += nb_pkt_sent; + return nb_pkt_sent; +} + /* Eal supported tx wrapper*/ uint16_t axgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h index 2a330339cd..c19d6d9db1 100644 --- a/drivers/net/axgbe/axgbe_rxtx.h +++ b/drivers/net/axgbe/axgbe_rxtx.h @@ -167,6 +167,10 @@ int axgbe_dev_fw_version_get(struct rte_eth_dev *eth_dev, uint16_t axgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); + +uint16_t axgbe_xmit_pkts_seg(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); + uint16_t axgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); -- 2.25.1