From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F93DA0573; Wed, 4 Mar 2020 14:44:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C39D91BE7D; Wed, 4 Mar 2020 14:44:37 +0100 (CET) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760053.outbound.protection.outlook.com [40.107.76.53]) by dpdk.org (Postfix) with ESMTP id 6757B2C02 for ; Wed, 4 Mar 2020 14:44:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d+94ooNOiFfwy/Khkk0cDOLelMaWD2PwULajAanFwlhH/EckA8s8wFmj4ee2Co6bFltuzGW1WVtNVa7pWyLBvTRPYO5cY6AxtjOhfOynvYBCvEMRG8gSt39nV3lmhVQ4HhjDU+rkpBuWWqxtv8MizohsgluAKKnhCIkyF/KsAtOq7MBJsbohKm7yytGOMvQNwWKvA/M8tP6ba5EC9GqIihyAwLCdwASnYuDM/rP3KjUnTX/R69LOBRMGlr3S7seqqpalbYSbxVUCRaKpyrR4YNXMju7QXSHtV8Nh9SIlvHdXA6LmzW5rDs3XsLEM9/yM8YkbQkwwsnVTLBl1ketLQw== 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-SenderADCheck; bh=CrBcih1OEFO3N6Pe1GqCoE8lGTD9vP1QmzsC5NHOyrc=; b=A0Bmav13Z6yFGTH6yUH1YS5+ufijTPX9sfn+sQHEG2HbUC3LD7n6SUWrCu5osG/l13XhMxzjQh0yiN50gu90e3E+Juk3sJ9zsONBet4ABm/5f4VyXSAyw4ADzEXZLgJWHlbGdl8l+B9vpfO+cFtiikYJ0+01VPtKD8ZZDQjjC+Kta/fpbFSGfJaxtT1lSCUDiNQ96z87S58XNTaQqeovQ7xhXVFogclx12KxGcyI4yASFul0wOHe1Z0sgWYqbw9EQTpHvWB1UydrplYRI3bY0rnRl/M3ue98xOvdov8m2VIzg+NoUdoHvyY37xOJmG4R0/FpTJHyGJbO/L6dDAwQ9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CrBcih1OEFO3N6Pe1GqCoE8lGTD9vP1QmzsC5NHOyrc=; b=eVxBsCPyaoDpYAnTOJZ6tmz3dlfDztWjUdcS0jj2h4ByGnttz72v2Twzhrs9bkTpenybzvm7dtJRDebVbyDr4evQxVJePWQmeeUl9MEL0kPz3jGTHPrMRdBAPyhWObKAAfQOgffHcBw10XVhDrmuDf89qy7448xjKmBe7+H1xTE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Selwin.Sebastian@amd.com; Received: from SN6PR12MB2704.namprd12.prod.outlook.com (2603:10b6:805:72::20) by SN6PR12MB2622.namprd12.prod.outlook.com (2603:10b6:805:72::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Wed, 4 Mar 2020 13:44:35 +0000 Received: from SN6PR12MB2704.namprd12.prod.outlook.com ([fe80::75b9:540c:dece:bf3]) by SN6PR12MB2704.namprd12.prod.outlook.com ([fe80::75b9:540c:dece:bf3%4]) with mapi id 15.20.2772.019; Wed, 4 Mar 2020 13:44:35 +0000 From: ssebasti@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com, ferruh.yigit@intel.com Date: Wed, 4 Mar 2020 19:14:14 +0530 Message-Id: <20200304134414.32762-1-ssebasti@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MAXPR0101CA0055.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::17) To SN6PR12MB2704.namprd12.prod.outlook.com (2603:10b6:805:72::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from cae-Bilby-RV1.amd.com (165.204.156.251) by MAXPR0101CA0055.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11 via Frontend Transport; Wed, 4 Mar 2020 13:44:33 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.156.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 51bb9c06-6b42-4404-8840-08d7c0422cab X-MS-TrafficTypeDiagnostic: SN6PR12MB2622:|SN6PR12MB2622: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:45; X-Forefront-PRVS: 0332AACBC3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(366004)(396003)(346002)(39860400002)(199004)(189003)(6916009)(8676002)(7696005)(52116002)(2906002)(81156014)(81166006)(26005)(2616005)(956004)(6666004)(186003)(8936002)(16526019)(1076003)(9686003)(66946007)(36756003)(4326008)(66556008)(66476007)(5660300002)(316002)(478600001)(6486002)(83323001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR12MB2622; H:SN6PR12MB2704.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fWlsiy39MH1YZ+EB1mhSHeyPwRsOIWKQF+7/NhOt8Z37V+odIQiMO1yreCRYk+mdErcmSkeTkTx/BEDEjeWePO94C2bzuIboqqPqTez6zz+eTJ0SBnKZB/fTyEVp5YGK58P9rmg7kJ4aptDAUJV9GEINLMMSHYfUBnIEOnZIelJ6HaFv0JDg6S6+p4tXiIrIj2JiDGJ4Mj27aqXjJeeb0Zm/1YS+eyleH+xFgfOdb3K+IOMzF+zctvc/rE19a8LPZ4LTUHhMXWeb5vPXZfumiUSCfracKiQt9Yqljrte3vQ8sEMiTbOEeP0pX+Clw32hpdE6/wNfQlIeFJ8SNvjklw6Ses8pPMIjwAnt1f6ydC0iP+eqZ3rdXypt7fy97GXLfbUwG6FatDxfpc7b0Ag1Pc+56U4XHvgAMclJ8d4wjiIRUzWW1QpT9pQUjj0RxI6iAZWPPB9Jn5vgW2dlO+N5gffgp52El65YefV9w0iXAYsFZzUSHM2dGLINcZ+1Svvm X-MS-Exchange-AntiSpam-MessageData: 1a4i69CQsP0YiFgU0jPfLNSBZdF+BEoiBNhfvjhykWfPRFOGw8sUMlVrarluh9HY524kQtsIfcraqy6i4m81pCm13wFc7Cd3TwsZP1RPyc4Y/ooJtrjdCKs2funYUfXOrZ6OzS+Of4F7QRAu99zBtQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51bb9c06-6b42-4404-8840-08d7c0422cab X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2020 13:44:35.0325 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WpU5/sd4IsniJt6yIKf39IlPemu/EvGTtB4mJey+yAsIv8XqMCAORIfoWofUGuK8ZWS6w+j0ZLbjexMlzjzeLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2622 Subject: [dpdk-dev] [PATCH v2] net/axgbe: add support for Scattered Rx 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: Selwin Sebastian Enable scattered rx support and add jumbo packet receive capability Signed-off-by: Selwin Sebastian --- doc/guides/nics/features/axgbe.ini | 1 + drivers/net/axgbe/axgbe_common.h | 2 + drivers/net/axgbe/axgbe_ethdev.c | 17 +++- drivers/net/axgbe/axgbe_rxtx.c | 146 +++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_rxtx.h | 2 + 5 files changed, 167 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini index ab4da559f..0becaa097 100644 --- a/doc/guides/nics/features/axgbe.ini +++ b/doc/guides/nics/features/axgbe.ini @@ -7,6 +7,7 @@ Speed capabilities = Y Link status = Y Jumbo frame = Y +Scattered Rx = Y Promiscuous mode = Y Allmulticast mode = Y RSS hash = Y diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h index fdb037dd5..fbd46150c 100644 --- a/drivers/net/axgbe/axgbe_common.h +++ b/drivers/net/axgbe/axgbe_common.h @@ -1135,6 +1135,8 @@ #define RX_NORMAL_DESC3_PL_WIDTH 14 #define RX_NORMAL_DESC3_RSV_INDEX 26 #define RX_NORMAL_DESC3_RSV_WIDTH 1 +#define RX_NORMAL_DESC3_LD_INDEX 28 +#define RX_NORMAL_DESC3_LD_WIDTH 1 #define RX_DESC3_L34T_IPV4_TCP 1 #define RX_DESC3_L34T_IPV4_UDP 2 diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index d0b6f091f..542003bda 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -249,6 +249,10 @@ axgbe_dev_start(struct rte_eth_dev *dev) { struct axgbe_port *pdata = dev->data->dev_private; int ret; + struct rte_eth_dev_data *dev_data = dev->data; + uint16_t max_pkt_len = dev_data->dev_conf.rxmode.max_rx_pkt_len; + + dev->dev_ops = &axgbe_eth_dev_ops; PMD_INIT_FUNC_TRACE(); @@ -279,6 +283,16 @@ axgbe_dev_start(struct rte_eth_dev *dev) axgbe_clear_bit(AXGBE_STOPPED, &pdata->dev_state); axgbe_clear_bit(AXGBE_DOWN, &pdata->dev_state); + if ((dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) || + max_pkt_len > pdata->rx_buf_size) + dev_data->scattered_rx = 1; + + /* Scatter Rx handling */ + if (dev_data->scattered_rx) + dev->rx_pkt_burst = ð_axgbe_recv_scattered_pkts; + else + dev->rx_pkt_burst = &axgbe_recv_pkts; + return 0; } @@ -789,6 +803,8 @@ axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_RX_OFFLOAD_IPV4_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_JUMBO_FRAME | + DEV_RX_OFFLOAD_SCATTER | DEV_RX_OFFLOAD_KEEP_CRC; dev_info->tx_offload_capa = @@ -1020,7 +1036,6 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev) int ret; eth_dev->dev_ops = &axgbe_eth_dev_ops; - eth_dev->rx_pkt_burst = &axgbe_recv_pkts; /* * For secondary processes, we don't initialise any further as primary diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c index 96055c25b..57e2bbb34 100644 --- a/drivers/net/axgbe/axgbe_rxtx.c +++ b/drivers/net/axgbe/axgbe_rxtx.c @@ -307,6 +307,152 @@ axgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, return nb_rx; } + +uint16_t eth_axgbe_recv_scattered_pkts(void *rx_queue, + struct rte_mbuf **rx_pkts, uint16_t nb_pkts) +{ + PMD_INIT_FUNC_TRACE(); + uint16_t nb_rx = 0; + struct axgbe_rx_queue *rxq = rx_queue; + volatile union axgbe_rx_desc *desc; + + uint64_t old_dirty = rxq->dirty; + struct rte_mbuf *first_seg = NULL; + struct rte_mbuf *mbuf, *tmbuf; + unsigned int err; + uint32_t error_status; + uint16_t idx, pidx, data_len = 0, pkt_len = 0; + + idx = AXGBE_GET_DESC_IDX(rxq, rxq->cur); + while (nb_rx < nb_pkts) { + bool eop = 0; +next_desc: + if (unlikely(idx == rxq->nb_desc)) + idx = 0; + + desc = &rxq->desc[idx]; + + if (AXGMAC_GET_BITS_LE(desc->write.desc3, RX_NORMAL_DESC3, OWN)) + break; + + tmbuf = rte_mbuf_raw_alloc(rxq->mb_pool); + if (unlikely(!tmbuf)) { + PMD_DRV_LOG(ERR, "RX mbuf alloc failed port_id = %u" + " queue_id = %u\n", + (unsigned int)rxq->port_id, + (unsigned int)rxq->queue_id); + rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++; + break; + } + + pidx = idx + 1; + if (unlikely(pidx == rxq->nb_desc)) + pidx = 0; + + rte_prefetch0(rxq->sw_ring[pidx]); + if ((pidx & 0x3) == 0) { + rte_prefetch0(&rxq->desc[pidx]); + rte_prefetch0(&rxq->sw_ring[pidx]); + } + + mbuf = rxq->sw_ring[idx]; + /* Check for any errors and free mbuf*/ + err = AXGMAC_GET_BITS_LE(desc->write.desc3, + RX_NORMAL_DESC3, ES); + error_status = 0; + if (unlikely(err)) { + error_status = desc->write.desc3 & AXGBE_ERR_STATUS; + if ((error_status != AXGBE_L3_CSUM_ERR) + && (error_status != AXGBE_L4_CSUM_ERR)) { + rxq->errors++; + rte_pktmbuf_free(mbuf); + goto err_set; + } + } + rte_prefetch1(rte_pktmbuf_mtod(mbuf, void *)); + + if (!AXGMAC_GET_BITS_LE(desc->write.desc3, + RX_NORMAL_DESC3, LD)) { + eop = 0; + pkt_len = rxq->buf_size; + data_len = pkt_len; + } else { + eop = 1; + pkt_len = AXGMAC_GET_BITS_LE(desc->write.desc3, + RX_NORMAL_DESC3, PL); + data_len = pkt_len - rxq->crc_len; + } + + if (first_seg != NULL) { + if (rte_pktmbuf_chain(first_seg, mbuf) != 0) + rte_mempool_put(rxq->mb_pool, + first_seg); + } else { + first_seg = mbuf; + } + + /* Get the RSS hash */ + if (AXGMAC_GET_BITS_LE(desc->write.desc3, RX_NORMAL_DESC3, RSV)) + mbuf->hash.rss = rte_le_to_cpu_32(desc->write.desc1); + + /* Mbuf populate */ + mbuf->data_off = RTE_PKTMBUF_HEADROOM; + mbuf->data_len = data_len; + +err_set: + rxq->cur++; + rxq->sw_ring[idx++] = tmbuf; + desc->read.baddr = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(tmbuf)); + memset((void *)(&desc->read.desc2), 0, 8); + AXGMAC_SET_BITS_LE(desc->read.desc3, RX_NORMAL_DESC3, OWN, 1); + rxq->dirty++; + + if (!eop) { + rte_pktmbuf_free(mbuf); + goto next_desc; + } + + first_seg->pkt_len = pkt_len; + rxq->bytes += pkt_len; + mbuf->next = NULL; + + first_seg->port = rxq->port_id; + if (rxq->pdata->rx_csum_enable) { + mbuf->ol_flags = 0; + mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD; + mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD; + if (unlikely(error_status == AXGBE_L3_CSUM_ERR)) { + mbuf->ol_flags &= ~PKT_RX_IP_CKSUM_GOOD; + mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD; + mbuf->ol_flags &= ~PKT_RX_L4_CKSUM_GOOD; + mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN; + } else if (unlikely(error_status + == AXGBE_L4_CSUM_ERR)) { + mbuf->ol_flags &= ~PKT_RX_L4_CKSUM_GOOD; + mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD; + } + } + + rx_pkts[nb_rx++] = first_seg; + + /* Setup receipt context for a new packet.*/ + first_seg = NULL; + } + + /* Save receive context.*/ + rxq->pkts += nb_rx; + + if (rxq->dirty != old_dirty) { + rte_wmb(); + idx = AXGBE_GET_DESC_IDX(rxq, rxq->dirty - 1); + AXGMAC_DMA_IOWRITE(rxq, DMA_CH_RDTR_LO, + low32_value(rxq->ring_phys_addr + + (idx * sizeof(union axgbe_rx_desc)))); + } + return nb_rx; +} + /* Tx Apis */ static void axgbe_tx_queue_release(struct axgbe_tx_queue *tx_queue) { diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h index a21537df9..f6796b09b 100644 --- a/drivers/net/axgbe/axgbe_rxtx.h +++ b/drivers/net/axgbe/axgbe_rxtx.h @@ -179,6 +179,8 @@ int axgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); int axgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); uint16_t axgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t eth_axgbe_recv_scattered_pkts(void *rx_queue, + struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t axgbe_recv_pkts_threshold_refresh(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); -- 2.17.1