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 E658AA055A; Tue, 25 Feb 2020 13:40:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BAA321BC24; Tue, 25 Feb 2020 13:40:30 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770087.outbound.protection.outlook.com [40.107.77.87]) by dpdk.org (Postfix) with ESMTP id D4BB13B5 for ; Tue, 25 Feb 2020 13:40:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZ1m/WHypD81yT3gGD9A3T9H1arU1rt2euvy+lAAklWMJSgzuOPp8kgNd8fhi4IwPDnn6/Z7M7IVSC6BwB9xCdR4RlxRZ6lRYcaYWDvVEihdpj0dv4lo3K1wzO02a/3R73n7orWdDilQFHOjeX3iDBmFJvrhBJ5XOu9cbqWw7T0oYy8wNhsA1uCnFYFUxV8BALwk/YGfVLI85hw+sQwyhpiaXY3uFvk3locc83Qdjjv2pxHXlsdN1vet+DWG5mdFeHA8R4ZDxyBvYCRU3yw/oevrOV8DcRjCI0dCsM3Q48IKVs25dSwh3e2fDq5z1+Ji5+VYOAne7KcrEAyfMID5kw== 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=RdO91z7pfjKJIG5FOhpolpDSaAyWD5KbNqW62fAIpMg=; b=HBcDq0gErRqCnqc5gQhG/jtpDpyMihRKQTUAeumuMZPqGQEX9AM7lm0xCXnjHtwDB/yWQCusa3XCLCEgKQreyR0HJuTb/JCRTUpaiuVLtbO0RHTdInG2ew7pEVA88vxLavd5A/QHvD/n+0Lj9TPB+TpovKOxXZou7U+yqCNssEsFQQ3JymXDTYFMfyOhxU6BvDQKo5bpq1dFhFYu4VgyCMFvqs4PE5r3MDiG60lM70Xem6g9p6WA+N6IJ7WlZX2rrFYQisQmNWgjAaIKmdxwVmeimwOLWRB9Vhu/j5EDTiWRYYANTRDflzoyvvw+cbhPeTPRMhHLTtimP42v38FALw== 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=RdO91z7pfjKJIG5FOhpolpDSaAyWD5KbNqW62fAIpMg=; b=u1LCsPnMpfdAwCrdj4kkrFf582i0zQ0gJ9m31qXWmrkONO4gUV1uyEpq5cc9zly1vMquenYaquHJNH4qhbdcUFKQhousvvkfSEo6R3+rtcfE7mCZ8YYroNxX05TFlgLYBcKGZ4/D9wPl2pDeoYXONJGyVsSP0yB0+R0SvkIVfo8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Selwin.Sebastian@amd.com; Received: from BYAPR12MB2693.namprd12.prod.outlook.com (2603:10b6:a03:6a::33) by BYAPR12MB3493.namprd12.prod.outlook.com (2603:10b6:a03:dd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2750.21; Tue, 25 Feb 2020 12:40:27 +0000 Received: from BYAPR12MB2693.namprd12.prod.outlook.com ([fe80::4076:da47:1f77:18f]) by BYAPR12MB2693.namprd12.prod.outlook.com ([fe80::4076:da47:1f77:18f%6]) with mapi id 15.20.2729.033; Tue, 25 Feb 2020 12:40:26 +0000 From: ssebasti@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com Date: Tue, 25 Feb 2020 18:10:04 +0530 Message-Id: <20200225124004.26946-1-ssebasti@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR01CA0094.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::34) To BYAPR12MB2693.namprd12.prod.outlook.com (2603:10b6:a03:6a::33) MIME-Version: 1.0 Received: from cae-Bilby-RV1.amd.com (165.204.156.251) by MA1PR01CA0094.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2750.18 via Frontend Transport; Tue, 25 Feb 2020 12:40:25 +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: ed785454-1bc1-42fa-7cc8-08d7b9efe3c4 X-MS-TrafficTypeDiagnostic: BYAPR12MB3493:|BYAPR12MB3493: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:79; X-Forefront-PRVS: 0324C2C0E2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(396003)(366004)(136003)(346002)(189003)(199004)(2616005)(956004)(5660300002)(26005)(186003)(1076003)(66556008)(2906002)(6486002)(66476007)(66946007)(316002)(9686003)(52116002)(81156014)(6666004)(8936002)(81166006)(7696005)(4326008)(6916009)(8676002)(36756003)(478600001)(16526019)(83323001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB3493; H:BYAPR12MB2693.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: YNwz1qp4EniIyo71UJ4vKDdk6gzB2Z3AItXZ3s8JTveaLIB0ArPz5e8gt9gxLZBcE23R3K9SzpjuU3sh2uqCQSVRhFw0L2ReWBhjBfma4zUMcETYNEgQ5p8BxhnKQglq3gn58qqtIlTWAJ6uhHsZfHzmgAdlSUeymZyYZta1dC3/2ENz2K18t0L+DJW2U1bhvA+11rrelBJaVML3EaE710QdHHTlrfR18doQBIxvSK5NjgDbiz8eNVhSJNLqwH72423W99gEM0JI/2rBHZoV2tsjhNk5jbLal03JnW0vJViIUCJJhy5XaU8DwbYAEzG7oe2kCi75ScULbp123Nj26BJmiwEqwU14iPVUelhyOAYp9aHAR6PUc3holkvvwClbmHnZqeis0c6ERL4rTtkrdtbnQNOHF3iDNocm9uPPXbx9cejkBQpv9RrVDI0YxECFI4+oFjzLsvj7BqV1OXGj4RSOMZFSAt9+odLKhvSnp/rexSg3iLhpB0gSfEiBCK0K X-MS-Exchange-AntiSpam-MessageData: wpXjGvWpJmZsMgBRuyGZzNsdtQx+meAUjcaCp5a7w/ehJ18DGt4FI6S/rTdfIDVku5CmQYC9zuK62tCUjk8R6IllM/AdZKdj8xMobowfPEXTwRSfK8j/DvyUBgbfFUsWHOSYhlIx8BH5LZrKFmcqZg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed785454-1bc1-42fa-7cc8-08d7b9efe3c4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2020 12:40:26.9329 (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: CWpqQ/q5yi0rUt1lWpVstCDq1SiAYwIZAKjyu5t+jT2FjJu2TUY44TVy2Dd4UDoW+p4b7c6vxI8sjD7pvTm81g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3493 Subject: [dpdk-dev] [PATCH v1] 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 transmit 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 | 18 +++- drivers/net/axgbe/axgbe_rxtx.c | 146 +++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_rxtx.h | 2 + 5 files changed, 168 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..eb2f51f89 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -789,11 +789,17 @@ 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 = DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_TSO | + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_TCP_CKSUM; if (pdata->hw_feat.rss) { @@ -1018,9 +1024,19 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev) struct rte_pci_device *pci_dev; uint32_t reg, mac_lo, mac_hi; int ret; + struct rte_eth_dev_info dev_info = { 0 }; eth_dev->dev_ops = &axgbe_eth_dev_ops; - eth_dev->rx_pkt_burst = &axgbe_recv_pkts; + eth_dev->dev_ops->dev_infos_get(eth_dev, &dev_info); + + if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCATTER) + eth_dev->data->scattered_rx = 1; + + /* Scatter Rx handling */ + if (eth_dev->data->scattered_rx) + eth_dev->rx_pkt_burst = ð_axgbe_recv_scattered_pkts; + else + 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