Skip to contentSkip to conversation

ENETC PMD basic features and bug fixes

PATCH Superseded Gagandeep Singh 4 participants 63 messages Apr 8, 2019 – Apr 16, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

cover ENETC PMD basic features and bug fixes

* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation and basic stats
* some bug fixes

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: use correct buffer allocation API net/enetc: set interface mode for SXGMII net/enetc: add statistics APIs
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

 doc/guides/nics/enetc.rst          |   7 +
 doc/guides/nics/features/enetc.ini |   9 +
 drivers/net/enetc/base/enetc_hw.h  |  53 ++-
 drivers/net/enetc/enetc.h          |  13 +-
 drivers/net/enetc/enetc_ethdev.c   | 739 +++++++++++++++++++++++++------------
 drivers/net/enetc/enetc_rxtx.c     | 128 ++++++-
 6 files changed, 685 insertions(+), 264 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/13 net/enetc: support physical addressing mode

Support added for physical addressing mode and
change driver flags to don't care.

---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/net/enetc/enetc_ethdev.c +12 -10
index 023fe75..7a9a97d 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -334,14 +334,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uintptr_t base_addr;
 	uint32_t tbmr;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)tx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)tx_ring->bd_base);
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
@@ -478,14 +479,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		  struct rte_mempool *mb_pool)
 {
 	int idx = rx_ring->index;
-	uintptr_t base_addr;
 	uint16_t buf_size;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)rx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)rx_ring->bd_base);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBLENR,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
@@ -612,7 +614,7 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 
 static struct rte_pci_driver rte_enetc_pmd = {
 	.id_table = pci_id_enetc_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = enetc_pci_probe,
 	.remove = enetc_pci_remove,
 };
drivers/net/enetc/enetc_rxtx.c +3 -3
index 631e243..a31a387 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -64,7 +64,7 @@
 		txbd->buf_len = txbd->frm_len;
 		txbd->flags = rte_cpu_to_le_16(ENETC_TXBD_FLAGS_F);
 		txbd->addr = (uint64_t)(uintptr_t)
-		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_addr +
+		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_iova +
 				 tx_swbd->buffer_addr->data_off);
 		i++;
 		start++;
@@ -91,7 +91,7 @@
 		rx_swbd->buffer_addr =
 			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
-			       rx_swbd->buffer_addr->buf_addr +
+			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
 		/* clear 'R" as well */
 		rxbd->r.lstatus = 0;
Signature · 1 line
1.9.1
#2 lore raw

Re: [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode

Quoted 4 lines · Gagandeep Singh

Support added for physical addressing mode and
change driver flags to don't care.

Hi Gagandeep,

Since the patchset has been sent after RC1, I assume it is for 19.08. Can you please mark patch title as 19.08 to not confuse with current release?

Thanks,
ferruh

#3 lore raw

PATCH 2/13 net/enetc: fix SMMU unhandled context fault

In reply to Gagandeep Singh

First configure ring with BDs properly then enable the ring.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/enetc/enetc_ethdev.c +3 -3
index 7a9a97d..f1807b9 100644
@@ -492,15 +492,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
 	rx_ring->mb_pool = mb_pool;
-	/* enable ring */
-	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
-	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 	rx_ring->rcir = (void *)((size_t)hw->reg +
 			ENETC_BDR(RX, idx, ENETC_RBCIR));
 	enetc_refill_rx_ring(rx_ring, (enetc_bd_unused(rx_ring)));
 	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rx_ring->mb_pool) -
 		   RTE_PKTMBUF_HEADROOM);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBSR, buf_size);
+	/* enable ring */
+	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
+	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 }
 
 static int
Signature · 1 line
1.9.1
#4 lore raw

PATCH 3/13 net/enetc: use correct buffer allocation API

In reply to Gagandeep Singh

rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enetc/enetc_rxtx.c +1 -1
index a31a387..90d6979 100644
@@ -89,7 +89,7 @@
 	rxbd = ENETC_RXBD(*rx_ring, i);
 	for (j = 0; j < buff_cnt; j++) {
 		rx_swbd->buffer_addr =
-			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
+			rte_cpu_to_le_64(rte_pktmbuf_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
 			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
Signature · 1 line
1.9.1
#5 lore raw

PATCH 4/13 net/enetc: set interface mode for SXGMII

In reply to Gagandeep Singh

Support for SXGMII port has been enabled. It will depends on boot loader information passed through IERB.

---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/enetc/base/enetc_hw.h +12 -1
index f36fa11..e3738a6 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_HW_H_
@@ -84,6 +84,12 @@
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
 #define ENETC_PCAPR1			0x00904
+#define ENETC_PM0_IF_MODE		0x8300
+#define ENETC_PM1_IF_MODE		0x9300
+#define ENETC_PMO_IFM_RG		BIT(2)
+#define ENETC_PM0_IFM_RLP		(BIT(5) | BIT(11))
+#define ENETC_PM0_IFM_RGAUTO		(BIT(15) | ENETC_PMO_IFM_RG | BIT(1))
+#define ENETC_PM0_IFM_XGMII		BIT(12)
 
 #define ENETC_PV0CFGR(n)		(0x00920 + (n) * 0x10)
 #define ENETC_PVCFGR_SET_TXBDR(val)	((val) & 0xff)
@@ -109,6 +115,11 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
+
+/* MAC Counters */
+#define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
+#define ENETC_G_EPFBLPR1_XGMII		0x80000000
+
 /* general register accessors */
 #define enetc_rd_reg(reg)	rte_read32((void *)(reg))
 #define enetc_wr_reg(reg, val)	rte_write32((val), (void *)(reg))
drivers/net/enetc/enetc_ethdev.c +11 -0
index f1807b9..91e9692 100644
@@ -139,6 +139,17 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
 			val | ENETC_PMR_EN);
 
+	/* set auto-speed for RGMII */
+	if (enetc_port_rd(&hw->hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+	}
+	if (enetc_global_rd(&hw->hw,
+			    ENETC_G_EPFBLPR(1)) == ENETC_G_EPFBLPR1_XGMII) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_XGMII);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH 5/13 net/enetc: add statistics APIs

In reply to Gagandeep Singh

Add basic statistics APIs enetc_stats_get
and enetc_stats_reset.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  | 27 +++++++++++++++++++++-
 drivers/net/enetc/enetc_ethdev.c   | 46 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 1 deletion(-)
doc/guides/nics/enetc.rst +1 -0
index 8038bf2..9f575d2 100644
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 69476a2..d8bd567 100644
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +26 -1
index e3738a6..3f0a2a9 100644
@@ -115,8 +115,33 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
-
 /* MAC Counters */
+/* Config register to reset counters*/
+#define ENETC_PM0_STAT_CONFIG		0x080E0
+/* Receive frames counter without error */
+#define ENETC_PM0_RFRM			0x08120
+/* Receive packets counter, good + bad */
+#define ENETC_PM0_RPKT			0x08160
+/* Received octets, good + bad */
+#define ENETC_PM0_REOCT			0x08120
+/* Transmit octets, good + bad */
+#define ENETC_PM0_TEOCT			0x08200
+/* Transmit frames counter without error */
+#define ENETC_PM0_TFRM			0x08220
+/* Transmit packets counter, good + bad */
+#define ENETC_PM0_TPKT			0x08260
+/* Dropped not Truncated packets counter */
+#define ENETC_PM0_RDRNTP		0x081C8
+/* Dropped + trucated packets counter */
+#define ENETC_PM0_RDRP			0x08158
+/* Receive packets error counter */
+#define ENETC_PM0_RERR			0x08138
+/* Transmit packets error counter */
+#define ENETC_PM0_TERR			0x08238
+
+/* Stats Reset Bit*/
+#define ENETC_CLEAR_STATS		BIT(2)
+
 #define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
 #define ENETC_G_EPFBLPR1_XGMII		0x80000000
 
drivers/net/enetc/enetc_ethdev.c +46 -0

64 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs

drivers/net/enetc/enetc_ethdev.c static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, · line 625

Quoted 11 lines · Gagandeep Singh
drivers/net/enetc/enetc_ethdev.c +10 -0
+static
+int enetc_stats_get(struct rte_eth_dev *dev,
+                   struct rte_eth_stats *stats)
+{
+       struct enetc_eth_hw *hw =
+               ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct enetc_hw *enetc_hw = &hw->hw;
+
+       if (stats == NULL)
+               return -1;

+

Quoted 2 lines

+ memset(stats, 0, sizeof(struct rte_eth_stats));

Both the check and the memset are unneeded.
https://git.dpdk.org/dpdk/tree/lib/librte_ethdev/rte_ethdev.c?h=v19.05-rc1#n1969

Signature · 1 line
David Marchand
#8 lore raw

Re: [dpdk-dev] [EXT] Re: [PATCH 05/13] net/enetc: add statistics APIs

Hi David,

I will incorporate your comments in v2.

Thanks,
Gagan

From: David Marchand <[email protected]>
Sent: Monday, April 8, 2019 5:06 PM
To: Gagandeep Singh <[email protected]>
Cc: [email protected]; [email protected]
Subject: [EXT] Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs

On Mon, Apr 8, 2019 at 1:23 PM Gagandeep Singh <[email protected]<mailto:[email protected]>> wrote:
+static
+int enetc_stats_get(struct rte_eth_dev *dev,
+ struct rte_eth_stats *stats)
+{
+ struct enetc_eth_hw *hw =
+ ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct enetc_hw *enetc_hw = &hw->hw;
+
+ if (stats == NULL)
+ return -1;
+
+ memset(stats, 0, sizeof(struct rte_eth_stats));

Both the check and the memset are unneeded.
https://git.dpdk.org/dpdk/tree/lib/librte_ethdev/rte_ethdev.c?h=v19.05-rc1#n1969<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.dpdk.org%2Fdpdk%2Ftree%2Flib%2Flibrte_ethdev%2Frte_ethdev.c%3Fh%3Dv19.05-rc1%23n1969&data=02%7C01%7CG.Singh%40nxp.com%7C803f77a628b944a3118308d6bc165532%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636903201440478754&sdata=Kc5hyTHdcOdAqPOTB%2ByClbzmclebaXJhZXcSMg0Q0RE%3D&reserved=0>

--
David Marchand

#9 lore raw

PATCH 6/13 net/enetc: replace register read/write macros with functions

In reply to Gagandeep Singh

Replacing read-write macros with already available read-write functions.

---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)
drivers/net/enetc/enetc.h +1 -6
index 0e80d1c..56454dc 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_H_
@@ -86,11 +86,6 @@ struct enetc_eth_adapter {
 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
 	(&((struct enetc_eth_adapter *)adapter)->intr)
 
-#define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr)))
-#define ENETC_REG_READ(addr) (*(uint32_t *)addr)
-#define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr = val)
-#define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr = val)
-
 /*
  * RX/TX ENETC function prototypes
  */
drivers/net/enetc/enetc_ethdev.c +30 -31

118 lines not on this page · raw message

Signature · 1 line
1.9.1
#10 lore raw

PATCH 7/13 net/enetc: remove forward declarations

In reply to Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)
drivers/net/enetc/enetc_ethdev.c +107 -130
index d403d7a..f8b9510 100644
@@ -10,115 +10,6 @@
 
 int enetc_logtype_pmd;
 
-/* Functions Prototypes */
-static int enetc_dev_configure(struct rte_eth_dev *dev);
-static int enetc_dev_start(struct rte_eth_dev *dev);
-static void enetc_dev_stop(struct rte_eth_dev *dev);
-static void enetc_dev_close(struct rte_eth_dev *dev);
-static void enetc_dev_infos_get(struct rte_eth_dev *dev,
-				struct rte_eth_dev_info *dev_info);
-static int enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-static int enetc_hardware_init(struct enetc_eth_hw *hw);
-static int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
-		uint16_t nb_rx_desc, unsigned int socket_id,
-		const struct rte_eth_rxconf *rx_conf,
-		struct rte_mempool *mb_pool);
-static void enetc_rx_queue_release(void *rxq);
-static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
-		uint16_t nb_tx_desc, unsigned int socket_id,
-		const struct rte_eth_txconf *tx_conf);
-static void enetc_tx_queue_release(void *txq);
-static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev);
-static int enetc_stats_get(struct rte_eth_dev *dev,
-		struct rte_eth_stats *stats);
-static void enetc_stats_reset(struct rte_eth_dev *dev);
-
-/*
- * The set of PCI devices this driver supports
- */
-static const struct rte_pci_id pci_id_enetc_map[] = {
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
-	{ .vendor_id = 0, /* sentinel */ },
-};
-
-/* Features supported by this driver */
-static const struct eth_dev_ops enetc_ops = {
-	.dev_configure        = enetc_dev_configure,
-	.dev_start            = enetc_dev_start,
-	.dev_stop             = enetc_dev_stop,
-	.dev_close            = enetc_dev_close,
-	.link_update          = enetc_link_update,
-	.stats_get            = enetc_stats_get,
-	.stats_reset          = enetc_stats_reset,
-	.dev_infos_get        = enetc_dev_infos_get,
-	.rx_queue_setup       = enetc_rx_queue_setup,
-	.rx_queue_release     = enetc_rx_queue_release,
-	.tx_queue_setup       = enetc_tx_queue_setup,
-	.tx_queue_release     = enetc_tx_queue_release,
-	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
-};
-
-/**
- * Initialisation of the enetc device
- *
- * @param eth_dev
- *   - Pointer to the structure rte_eth_dev
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static int
-enetc_dev_init(struct rte_eth_dev *eth_dev)
-{
-	int error = 0;
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	struct enetc_eth_hw *hw =
-		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-
-	PMD_INIT_FUNC_TRACE();
-	eth_dev->dev_ops = &enetc_ops;
-	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
-	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
-
-	/* Retrieving and storing the HW base address of device */
-	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
-	hw->device_id = pci_dev->id.device_id;
-
-	error = enetc_hardware_init(hw);
-	if (error != 0) {
-		ENETC_PMD_ERR("Hardware initialization failed");
-		return -1;
-	}
-
-	/* Allocate memory for storing MAC addresses */
-	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
-	if (!eth_dev->data->mac_addrs) {
-		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
-			      "store MAC addresses",
-			      ETHER_ADDR_LEN * 1);
-		error = -ENOMEM;
-		return -1;
-	}
-
-	/* Copy the permanent MAC address */
-	ether_addr_copy((struct ether_addr *)hw->mac.addr,
-			&eth_dev->data->mac_addrs[0]);
-
-	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
-			eth_dev->data->port_id, pci_dev->id.vendor_id,
-			pci_dev->id.device_id);
-	return 0;
-}
-
-static int
-enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
@@ -179,27 +70,6 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
-static void
-enetc_dev_close(struct rte_eth_dev *dev)
-{
-	uint16_t i;
-
-	PMD_INIT_FUNC_TRACE();
-	enetc_dev_stop(dev);
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		enetc_rx_queue_release(dev->data->rx_queues[i]);
-		dev->data->rx_queues[i] = NULL;
-	}
-	dev->data->nb_rx_queues = 0;
-
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		enetc_tx_queue_release(dev->data->tx_queues[i]);
-		dev->data->tx_queues[i] = NULL;
-	}
-	dev->data->nb_tx_queues = 0;
-}
-
 static const uint32_t *
 enetc_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 {
@@ -653,6 +523,113 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
 }
 
+static void
+enetc_dev_close(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+
+	PMD_INIT_FUNC_TRACE();
+	enetc_dev_stop(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		enetc_rx_queue_release(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		enetc_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static const struct rte_pci_id pci_id_enetc_map[] = {
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+/* Features supported by this driver */
+static const struct eth_dev_ops enetc_ops = {
+	.dev_configure        = enetc_dev_configure,
+	.dev_start            = enetc_dev_start,
+	.dev_stop             = enetc_dev_stop,
+	.dev_close            = enetc_dev_close,
+	.link_update          = enetc_link_update,
+	.stats_get            = enetc_stats_get,
+	.stats_reset          = enetc_stats_reset,
+	.dev_infos_get        = enetc_dev_infos_get,
+	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_release     = enetc_rx_queue_release,
+	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_release     = enetc_tx_queue_release,
+	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
+};
+
+/**
+ * Initialisation of the enetc device
+ *
+ * @param eth_dev
+ *   - Pointer to the structure rte_eth_dev
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static int
+enetc_dev_init(struct rte_eth_dev *eth_dev)
+{
+	int error = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+	eth_dev->dev_ops = &enetc_ops;
+	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
+	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
+
+	/* Retrieving and storing the HW base address of device */
+	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
+	hw->device_id = pci_dev->id.device_id;
+
+	error = enetc_hardware_init(hw);
+	if (error != 0) {
+		ENETC_PMD_ERR("Hardware initialization failed");
+		return -1;
+	}
+
+	/* Allocate memory for storing MAC addresses */
+	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
+	if (!eth_dev->data->mac_addrs) {
+		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
+			      "store MAC addresses",
+			      ETHER_ADDR_LEN * 1);
+		error = -ENOMEM;
+		return -1;
+	}
+
+	/* Copy the permanent MAC address */
+	ether_addr_copy((struct ether_addr *)hw->mac.addr,
+			&eth_dev->data->mac_addrs[0]);
+
+	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
+			eth_dev->data->port_id, pci_dev->id.vendor_id,
+			pci_dev->id.device_id);
+	return 0;
+}
+
+static int
+enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+	return 0;
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
Signature · 1 line
1.9.1
#11 lore raw

PATCH 8/13 net/enetc: enable promiscuous and allmulticast feature

In reply to Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

---
 doc/guides/nics/enetc.rst          |  2 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  3 +-
 drivers/net/enetc/enetc_ethdev.c   | 90 ++++++++++++++++++++++++++++++++------
 4 files changed, 81 insertions(+), 16 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index 9f575d2..ab13211 100644
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index d8bd567..6b7bbfb 100644
@@ -7,6 +7,8 @@
 Packet type parsing  = Y
 Link status          = Y
 Basic stats          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -2
index 3f0a2a9..90a383a 100644
@@ -78,8 +78,7 @@
 #define ENETC_PSR			0x00004 /* RO */
 #define ENETC_PSIPMR			0x00018
 #define ENETC_PSIPMR_SET_UP(n)		(0x1 << (n)) /* n = SI index */
-#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 8))
-#define ENETC_PSIPMR_SET_VLAN_MP(n)	(0x1 << ((n) + 16))
+#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 16))
 #define ENETC_PSIPMAR0(n)		(0x00100 + (n) * 0x20)
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
drivers/net/enetc/enetc_ethdev.c +76 -14

115 lines not on this page · raw message

Signature · 1 line
1.9.1
#12 lore raw

PATCH 9/13 net/enetc: add MTU update and jumbo frames support

In reply to Gagandeep Singh

Enable the jumbo frames and mtu update feature.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  6 ++-
 drivers/net/enetc/enetc.h          |  5 +++
 drivers/net/enetc/enetc_ethdev.c   | 86 ++++++++++++++++++++++++++++++++++----
 5 files changed, 91 insertions(+), 9 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index ab13211..eeb0752 100644
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index 6b7bbfb..0eed2cb 100644
@@ -9,6 +9,8 @@ Link status          = Y
 Basic stats          = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+MTU update           = Y
+Jumbo frame          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -1
index 90a383a..2eb1df3 100644
@@ -99,7 +99,11 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 
 #define ENETC_PM0_MAXFRM		0x08014
-#define ENETC_SET_MAXFRM(val)		((val) << 16)
+#define ENETC_SET_TX_MTU(val)		((val) << 16)
+#define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
+#define ENETC_PTXMBAR			0x0608
+/* n = TC index [0..7] */
+#define ENETC_PTCMSDUR(n)		(0x2020 + (n) * 4)
 
 #define ENETC_PM0_STATUS		0x08304
 #define ENETC_LINK_MODE			0x0000000000080000ULL
drivers/net/enetc/enetc.h +5 -0
index 56454dc..e494eb8 100644
@@ -24,6 +24,11 @@
 /* BD ALIGN */
 #define BD_ALIGN       8
 
+/* minimum frame size supported */
+#define ENETC_MAC_MINFRM_SIZE	68
+/* maximum frame size supported */
+#define ENETC_MAC_MAXFRM_SIZE	9600
+
 /*
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
drivers/net/enetc/enetc_ethdev.c +78 -8

116 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

PATCH 10/13 net/enetc: enable Rx-Tx queue start/stop feature

In reply to Gagandeep Singh

Rx and Tx queue start-stop and deferred queue start features enabled.

---
 doc/guides/nics/enetc.rst          |   2 +
 doc/guides/nics/features/enetc.ini |   1 +
 drivers/net/enetc/enetc_ethdev.c   | 185 ++++++++++++++++++++++++++-----------
 3 files changed, 134 insertions(+), 54 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index eeb0752..26d61f6 100644
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 0eed2cb..bd901fa 100644
@@ -11,6 +11,7 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
+Queue start/stop     = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/enetc_ethdev.c +131 -54

263 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH 11/13 net/enetc: enable CRC offload feature

In reply to Gagandeep Singh

CRC offload keep feature supported

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  |  1 +
 drivers/net/enetc/enetc.h          |  1 +
 drivers/net/enetc/enetc_ethdev.c   | 20 +++++++++++++++++---
 drivers/net/enetc/enetc_rxtx.c     |  6 ++++--
 6 files changed, 25 insertions(+), 5 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index 26d61f6..2620460 100644
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index bd901fa..101dc0a 100644
@@ -12,6 +12,7 @@ Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
+CRC offload          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -0
index 2eb1df3..261ad15 100644
@@ -97,6 +97,7 @@
 #define ENETC_PM0_CMD_CFG		0x08008
 #define ENETC_PM0_TX_EN			BIT(0)
 #define ENETC_PM0_RX_EN			BIT(1)
+#define ENETC_PM0_CRC			BIT(6)
 
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
drivers/net/enetc/enetc.h +1 -0
index e494eb8..8c830a5 100644
@@ -69,6 +69,7 @@ struct enetc_bdr {
 		void *tcisr; /* Tx */
 		int next_to_alloc; /* Rx */
 	};
+	uint8_t	crc_len; /* 0 if CRC stripped, 4 otherwise */
 };
 
 /*
drivers/net/enetc/enetc_ethdev.c +17 -3
index db23276..a59a030 100644
@@ -162,7 +162,9 @@
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
-	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
+	dev_info->rx_offload_capa =
+		(DEV_RX_OFFLOAD_KEEP_CRC |
+		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
 static int
@@ -378,6 +380,7 @@
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
+	uint64_t rx_offloads = data->dev_conf.rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	if (nb_rx_desc > MAX_BD_COUNT)
@@ -410,6 +413,9 @@
 			       RTE_ETH_QUEUE_STATE_STOPPED;
 	}
 
+	rx_ring->crc_len = (uint8_t)((rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) ?
+				     ETHER_CRC_LEN : 0);
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -630,11 +636,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 static int
 enetc_dev_configure(struct rte_eth_dev *dev)
 {
-	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
-	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct enetc_hw *enetc_hw = &hw->hw;
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -652,6 +658,14 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
+		int config;
+
+		config = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+		config |= ENETC_PM0_CRC;
+		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
+	}
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +4 -2
index 90d6979..7497a47 100644
@@ -207,8 +207,10 @@ static inline void __attribute__((hot))
 		if (!bd_status)
 			break;
 
-		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len;
-		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len;
+		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len -
+						rx_ring->crc_len;
+		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len -
+						 rx_ring->crc_len;
 		rx_swbd->buffer_addr->hash.rss = rxbd->r.rss_hash;
 		rx_swbd->buffer_addr->ol_flags = 0;
 		enetc_dev_rx_parse(rx_swbd->buffer_addr,
Signature · 1 line
1.9.1
#15 lore raw

PATCH 12/13 net/enetc: enable Rx checksum offload validation

In reply to Gagandeep Singh

Checksum Validation on Rx is supported.

---
 doc/guides/nics/features/enetc.ini |   2 +
 drivers/net/enetc/base/enetc_hw.h  |   5 ++
 drivers/net/enetc/enetc_ethdev.c   |  15 +++++-
 drivers/net/enetc/enetc_rxtx.c     | 107 ++++++++++++++++++++++++++++++++-----
 4 files changed, 115 insertions(+), 14 deletions(-)
doc/guides/nics/features/enetc.ini +2 -0
index 101dc0a..39a5201 100644
@@ -13,6 +13,8 @@ MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
 CRC offload          = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -0
index 261ad15..ff2bda5 100644
@@ -99,6 +99,10 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 #define ENETC_PM0_CRC			BIT(6)
 
+#define ENETC_PAR_PORT_CFG		0x03050
+#define L3_CKSUM			BIT(0)
+#define L4_CKSUM			BIT(1)
+
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
 #define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
@@ -182,6 +186,7 @@
 #define ENETC_TXBD_FLAGS_F		BIT(15)
 
 /* ENETC Parsed values (Little Endian) */
+#define ENETC_PARSE_ERROR		0x8000
 #define ENETC_PKT_TYPE_ETHER            0x0060
 #define ENETC_PKT_TYPE_IPV4             0x0000
 #define ENETC_PKT_TYPE_IPV6             0x0020
drivers/net/enetc/enetc_ethdev.c +14 -1
index a59a030..6b49fd4 100644
@@ -163,7 +163,10 @@
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
 	dev_info->rx_offload_capa =
-		(DEV_RX_OFFLOAD_KEEP_CRC |
+		(DEV_RX_OFFLOAD_IPV4_CKSUM |
+		 DEV_RX_OFFLOAD_UDP_CKSUM |
+		 DEV_RX_OFFLOAD_TCP_CKSUM |
+		 DEV_RX_OFFLOAD_KEEP_CRC |
 		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
@@ -641,6 +644,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
 	uint64_t rx_offloads = eth_conf->rxmode.offloads;
+	uint32_t checksum = L3_CKSUM | L4_CKSUM;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -666,6 +670,15 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM)
+		checksum &= ~L3_CKSUM;
+
+	if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM))
+		checksum &= ~L4_CKSUM;
+
+	enetc_port_wr(enetc_hw, ENETC_PAR_PORT_CFG, checksum);
+
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +94 -13

163 lines not on this page · raw message

Signature · 1 line
1.9.1
#16 lore raw

PATCH 13/13 net/enetc: fix crash at high speed traffic

In reply to Gagandeep Singh

On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/enetc/enetc_rxtx.c +6 -1
index ed39665..baf5d27 100644
@@ -49,11 +49,16 @@
 		uint16_t nb_pkts)
 {
 	struct enetc_swbd *tx_swbd;
-	int i, start;
+	int i, start, bds_to_use;
 	struct enetc_tx_bd *txbd;
 	struct enetc_bdr *tx_ring = (struct enetc_bdr *)tx_queue;
 
 	i = tx_ring->next_to_use;
+
+	bds_to_use = enetc_bd_unused(tx_ring);
+	if (bds_to_use < nb_pkts)
+		nb_pkts = bds_to_use;
+
 	start = 0;
 	while (nb_pkts--) {
 		enetc_clean_tx_ring(tx_ring);
Signature · 1 line
1.9.1
#17 lore raw

v2 cover ENETC PMD basic features and bug fixes

In reply to Gagandeep Singh

V1 log:
* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation, basic stats
* some bug fixes

V2 change-log:
* remove unneeded code from stats get
* fix big endian compilation

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: use correct buffer allocation API net/enetc: set interface mode for SXGMII net/enetc: add basic statistics
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

 doc/guides/nics/enetc.rst          |   7 +
 doc/guides/nics/features/enetc.ini |   9 +
 drivers/net/enetc/base/enetc_hw.h  |  53 ++-
 drivers/net/enetc/enetc.h          |  13 +-
 drivers/net/enetc/enetc_ethdev.c   | 734 +++++++++++++++++++++++++------------
 drivers/net/enetc/enetc_rxtx.c     | 131 +++++--
 6 files changed, 682 insertions(+), 265 deletions(-)
Signature · 1 line
1.9.1
#18 lore raw

PATCH v2 1/13 net/enetc: support physical addressing mode

Support added for physical addressing mode and
change driver flags to don't care.

---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/net/enetc/enetc_ethdev.c +12 -10
index 023fe75..7a9a97d 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -334,14 +334,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uintptr_t base_addr;
 	uint32_t tbmr;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)tx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)tx_ring->bd_base);
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
@@ -478,14 +479,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		  struct rte_mempool *mb_pool)
 {
 	int idx = rx_ring->index;
-	uintptr_t base_addr;
 	uint16_t buf_size;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)rx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)rx_ring->bd_base);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBLENR,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
@@ -612,7 +614,7 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 
 static struct rte_pci_driver rte_enetc_pmd = {
 	.id_table = pci_id_enetc_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = enetc_pci_probe,
 	.remove = enetc_pci_remove,
 };
drivers/net/enetc/enetc_rxtx.c +3 -3
index 631e243..a31a387 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -64,7 +64,7 @@
 		txbd->buf_len = txbd->frm_len;
 		txbd->flags = rte_cpu_to_le_16(ENETC_TXBD_FLAGS_F);
 		txbd->addr = (uint64_t)(uintptr_t)
-		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_addr +
+		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_iova +
 				 tx_swbd->buffer_addr->data_off);
 		i++;
 		start++;
@@ -91,7 +91,7 @@
 		rx_swbd->buffer_addr =
 			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
-			       rx_swbd->buffer_addr->buf_addr +
+			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
 		/* clear 'R" as well */
 		rxbd->r.lstatus = 0;
Signature · 1 line
1.9.1
#19 lore raw

PATCH v2 2/13 net/enetc: fix SMMU unhandled context fault

In reply to Gagandeep Singh

First configure ring with BDs properly then enable the ring.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/enetc/enetc_ethdev.c +3 -3
index 7a9a97d..f1807b9 100644
@@ -492,15 +492,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
 	rx_ring->mb_pool = mb_pool;
-	/* enable ring */
-	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
-	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 	rx_ring->rcir = (void *)((size_t)hw->reg +
 			ENETC_BDR(RX, idx, ENETC_RBCIR));
 	enetc_refill_rx_ring(rx_ring, (enetc_bd_unused(rx_ring)));
 	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rx_ring->mb_pool) -
 		   RTE_PKTMBUF_HEADROOM);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBSR, buf_size);
+	/* enable ring */
+	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
+	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 }
 
 static int
Signature · 1 line
1.9.1
#20 lore raw

PATCH v2 3/13 net/enetc: use correct buffer allocation API

In reply to Gagandeep Singh

rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/enetc/enetc_rxtx.c +3 -2
index a31a387..42f16ca 100644
@@ -88,8 +88,9 @@
 	rx_swbd = &rx_ring->q_swbd[i];
 	rxbd = ENETC_RXBD(*rx_ring, i);
 	for (j = 0; j < buff_cnt; j++) {
-		rx_swbd->buffer_addr =
-			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
+		rx_swbd->buffer_addr = (void *)(uintptr_t)
+			rte_cpu_to_le_64((uint64_t)(uintptr_t)
+					rte_pktmbuf_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
 			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
Signature · 1 line
1.9.1
#21 lore raw

Re: [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API

12/04/2019 09:04, Gagandeep Singh:

Quoted 6 lines

rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")

You should mention it is also fixing big endian compilation.

#22 lore raw

Re: [dpdk-dev] [EXT] Re: [PATCH v2 03/13] net/enetc: use correct buffer allocation API

Quoted 9 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, April 12, 2019 2:08 PM
To: Gagandeep Singh <[email protected]>
Cc: [email protected]; [email protected]>

12/04/2019 09:04, Gagandeep Singh:

Quoted 10 lines
Quoted 6 lines

rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")

You should mention it is also fixing big endian compilation.

Ok, I'll do that.

Thanks,
Gagandeep Singh

#23 lore raw

PATCH v2 4/13 net/enetc: set interface mode for SXGMII

In reply to Gagandeep Singh

Support for SXGMII port has been enabled. It will depends on boot loader information passed through IERB.

---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/enetc/base/enetc_hw.h +12 -1
index f36fa11..e3738a6 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_HW_H_
@@ -84,6 +84,12 @@
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
 #define ENETC_PCAPR1			0x00904
+#define ENETC_PM0_IF_MODE		0x8300
+#define ENETC_PM1_IF_MODE		0x9300
+#define ENETC_PMO_IFM_RG		BIT(2)
+#define ENETC_PM0_IFM_RLP		(BIT(5) | BIT(11))
+#define ENETC_PM0_IFM_RGAUTO		(BIT(15) | ENETC_PMO_IFM_RG | BIT(1))
+#define ENETC_PM0_IFM_XGMII		BIT(12)
 
 #define ENETC_PV0CFGR(n)		(0x00920 + (n) * 0x10)
 #define ENETC_PVCFGR_SET_TXBDR(val)	((val) & 0xff)
@@ -109,6 +115,11 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
+
+/* MAC Counters */
+#define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
+#define ENETC_G_EPFBLPR1_XGMII		0x80000000
+
 /* general register accessors */
 #define enetc_rd_reg(reg)	rte_read32((void *)(reg))
 #define enetc_wr_reg(reg, val)	rte_write32((val), (void *)(reg))
drivers/net/enetc/enetc_ethdev.c +11 -0
index f1807b9..91e9692 100644
@@ -139,6 +139,17 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
 			val | ENETC_PMR_EN);
 
+	/* set auto-speed for RGMII */
+	if (enetc_port_rd(&hw->hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+	}
+	if (enetc_global_rd(&hw->hw,
+			    ENETC_G_EPFBLPR(1)) == ENETC_G_EPFBLPR1_XGMII) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_XGMII);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#24 lore raw

PATCH v2 5/13 net/enetc: add basic statistics

In reply to Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  | 27 ++++++++++++++++++++++++-
 drivers/net/enetc/enetc_ethdev.c   | 41 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 1 deletion(-)
doc/guides/nics/enetc.rst +1 -0
index 8038bf2..9f575d2 100644
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 69476a2..d8bd567 100644
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +26 -1
index e3738a6..3f0a2a9 100644
@@ -115,8 +115,33 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
-
 /* MAC Counters */
+/* Config register to reset counters*/
+#define ENETC_PM0_STAT_CONFIG		0x080E0
+/* Receive frames counter without error */
+#define ENETC_PM0_RFRM			0x08120
+/* Receive packets counter, good + bad */
+#define ENETC_PM0_RPKT			0x08160
+/* Received octets, good + bad */
+#define ENETC_PM0_REOCT			0x08120
+/* Transmit octets, good + bad */
+#define ENETC_PM0_TEOCT			0x08200
+/* Transmit frames counter without error */
+#define ENETC_PM0_TFRM			0x08220
+/* Transmit packets counter, good + bad */
+#define ENETC_PM0_TPKT			0x08260
+/* Dropped not Truncated packets counter */
+#define ENETC_PM0_RDRNTP		0x081C8
+/* Dropped + trucated packets counter */
+#define ENETC_PM0_RDRP			0x08158
+/* Receive packets error counter */
+#define ENETC_PM0_RERR			0x08138
+/* Transmit packets error counter */
+#define ENETC_PM0_TERR			0x08238
+
+/* Stats Reset Bit*/
+#define ENETC_CLEAR_STATS		BIT(2)
+
 #define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
 #define ENETC_G_EPFBLPR1_XGMII		0x80000000
 
drivers/net/enetc/enetc_ethdev.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
1.9.1
#25 lore raw

PATCH v2 6/13 net/enetc: replace register read/write macros with functions

In reply to Gagandeep Singh

Replacing read-write macros with already available read-write functions.

---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)
drivers/net/enetc/enetc.h +1 -6
index 0e80d1c..56454dc 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_H_
@@ -86,11 +86,6 @@ struct enetc_eth_adapter {
 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
 	(&((struct enetc_eth_adapter *)adapter)->intr)
 
-#define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr)))
-#define ENETC_REG_READ(addr) (*(uint32_t *)addr)
-#define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr = val)
-#define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr = val)
-
 /*
  * RX/TX ENETC function prototypes
  */
drivers/net/enetc/enetc_ethdev.c +30 -31

118 lines not on this page · raw message

Signature · 1 line
1.9.1
#26 lore raw

PATCH v2 7/13 net/enetc: remove forward declarations

In reply to Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)
drivers/net/enetc/enetc_ethdev.c +107 -130
index 2d8c4e6..d0f9e2b 100644
@@ -10,115 +10,6 @@
 
 int enetc_logtype_pmd;
 
-/* Functions Prototypes */
-static int enetc_dev_configure(struct rte_eth_dev *dev);
-static int enetc_dev_start(struct rte_eth_dev *dev);
-static void enetc_dev_stop(struct rte_eth_dev *dev);
-static void enetc_dev_close(struct rte_eth_dev *dev);
-static void enetc_dev_infos_get(struct rte_eth_dev *dev,
-				struct rte_eth_dev_info *dev_info);
-static int enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-static int enetc_hardware_init(struct enetc_eth_hw *hw);
-static int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
-		uint16_t nb_rx_desc, unsigned int socket_id,
-		const struct rte_eth_rxconf *rx_conf,
-		struct rte_mempool *mb_pool);
-static void enetc_rx_queue_release(void *rxq);
-static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
-		uint16_t nb_tx_desc, unsigned int socket_id,
-		const struct rte_eth_txconf *tx_conf);
-static void enetc_tx_queue_release(void *txq);
-static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev);
-static int enetc_stats_get(struct rte_eth_dev *dev,
-		struct rte_eth_stats *stats);
-static void enetc_stats_reset(struct rte_eth_dev *dev);
-
-/*
- * The set of PCI devices this driver supports
- */
-static const struct rte_pci_id pci_id_enetc_map[] = {
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
-	{ .vendor_id = 0, /* sentinel */ },
-};
-
-/* Features supported by this driver */
-static const struct eth_dev_ops enetc_ops = {
-	.dev_configure        = enetc_dev_configure,
-	.dev_start            = enetc_dev_start,
-	.dev_stop             = enetc_dev_stop,
-	.dev_close            = enetc_dev_close,
-	.link_update          = enetc_link_update,
-	.stats_get            = enetc_stats_get,
-	.stats_reset          = enetc_stats_reset,
-	.dev_infos_get        = enetc_dev_infos_get,
-	.rx_queue_setup       = enetc_rx_queue_setup,
-	.rx_queue_release     = enetc_rx_queue_release,
-	.tx_queue_setup       = enetc_tx_queue_setup,
-	.tx_queue_release     = enetc_tx_queue_release,
-	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
-};
-
-/**
- * Initialisation of the enetc device
- *
- * @param eth_dev
- *   - Pointer to the structure rte_eth_dev
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static int
-enetc_dev_init(struct rte_eth_dev *eth_dev)
-{
-	int error = 0;
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	struct enetc_eth_hw *hw =
-		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-
-	PMD_INIT_FUNC_TRACE();
-	eth_dev->dev_ops = &enetc_ops;
-	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
-	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
-
-	/* Retrieving and storing the HW base address of device */
-	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
-	hw->device_id = pci_dev->id.device_id;
-
-	error = enetc_hardware_init(hw);
-	if (error != 0) {
-		ENETC_PMD_ERR("Hardware initialization failed");
-		return -1;
-	}
-
-	/* Allocate memory for storing MAC addresses */
-	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
-	if (!eth_dev->data->mac_addrs) {
-		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
-			      "store MAC addresses",
-			      ETHER_ADDR_LEN * 1);
-		error = -ENOMEM;
-		return -1;
-	}
-
-	/* Copy the permanent MAC address */
-	ether_addr_copy((struct ether_addr *)hw->mac.addr,
-			&eth_dev->data->mac_addrs[0]);
-
-	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
-			eth_dev->data->port_id, pci_dev->id.vendor_id,
-			pci_dev->id.device_id);
-	return 0;
-}
-
-static int
-enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
@@ -179,27 +70,6 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
-static void
-enetc_dev_close(struct rte_eth_dev *dev)
-{
-	uint16_t i;
-
-	PMD_INIT_FUNC_TRACE();
-	enetc_dev_stop(dev);
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		enetc_rx_queue_release(dev->data->rx_queues[i]);
-		dev->data->rx_queues[i] = NULL;
-	}
-	dev->data->nb_rx_queues = 0;
-
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		enetc_tx_queue_release(dev->data->tx_queues[i]);
-		dev->data->tx_queues[i] = NULL;
-	}
-	dev->data->nb_tx_queues = 0;
-}
-
 static const uint32_t *
 enetc_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 {
@@ -648,6 +518,113 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
 }
 
+static void
+enetc_dev_close(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+
+	PMD_INIT_FUNC_TRACE();
+	enetc_dev_stop(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		enetc_rx_queue_release(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		enetc_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static const struct rte_pci_id pci_id_enetc_map[] = {
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+/* Features supported by this driver */
+static const struct eth_dev_ops enetc_ops = {
+	.dev_configure        = enetc_dev_configure,
+	.dev_start            = enetc_dev_start,
+	.dev_stop             = enetc_dev_stop,
+	.dev_close            = enetc_dev_close,
+	.link_update          = enetc_link_update,
+	.stats_get            = enetc_stats_get,
+	.stats_reset          = enetc_stats_reset,
+	.dev_infos_get        = enetc_dev_infos_get,
+	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_release     = enetc_rx_queue_release,
+	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_release     = enetc_tx_queue_release,
+	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
+};
+
+/**
+ * Initialisation of the enetc device
+ *
+ * @param eth_dev
+ *   - Pointer to the structure rte_eth_dev
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static int
+enetc_dev_init(struct rte_eth_dev *eth_dev)
+{
+	int error = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+	eth_dev->dev_ops = &enetc_ops;
+	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
+	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
+
+	/* Retrieving and storing the HW base address of device */
+	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
+	hw->device_id = pci_dev->id.device_id;
+
+	error = enetc_hardware_init(hw);
+	if (error != 0) {
+		ENETC_PMD_ERR("Hardware initialization failed");
+		return -1;
+	}
+
+	/* Allocate memory for storing MAC addresses */
+	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
+	if (!eth_dev->data->mac_addrs) {
+		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
+			      "store MAC addresses",
+			      ETHER_ADDR_LEN * 1);
+		error = -ENOMEM;
+		return -1;
+	}
+
+	/* Copy the permanent MAC address */
+	ether_addr_copy((struct ether_addr *)hw->mac.addr,
+			&eth_dev->data->mac_addrs[0]);
+
+	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
+			eth_dev->data->port_id, pci_dev->id.vendor_id,
+			pci_dev->id.device_id);
+	return 0;
+}
+
+static int
+enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+	return 0;
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
Signature · 1 line
1.9.1
#27 lore raw

PATCH v2 8/13 net/enetc: enable promiscuous and allmulticast feature

In reply to Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

---
 doc/guides/nics/enetc.rst          |  2 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  3 +-
 drivers/net/enetc/enetc_ethdev.c   | 90 ++++++++++++++++++++++++++++++++------
 4 files changed, 81 insertions(+), 16 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index 9f575d2..ab13211 100644
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index d8bd567..6b7bbfb 100644
@@ -7,6 +7,8 @@
 Packet type parsing  = Y
 Link status          = Y
 Basic stats          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -2
index 3f0a2a9..90a383a 100644
@@ -78,8 +78,7 @@
 #define ENETC_PSR			0x00004 /* RO */
 #define ENETC_PSIPMR			0x00018
 #define ENETC_PSIPMR_SET_UP(n)		(0x1 << (n)) /* n = SI index */
-#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 8))
-#define ENETC_PSIPMR_SET_VLAN_MP(n)	(0x1 << ((n) + 16))
+#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 16))
 #define ENETC_PSIPMAR0(n)		(0x00100 + (n) * 0x20)
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
drivers/net/enetc/enetc_ethdev.c +76 -14

115 lines not on this page · raw message

Signature · 1 line
1.9.1
#28 lore raw

PATCH v2 9/13 net/enetc: add MTU update and jumbo frames support

In reply to Gagandeep Singh

Enable the jumbo frames and mtu update feature.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  6 ++-
 drivers/net/enetc/enetc.h          |  5 +++
 drivers/net/enetc/enetc_ethdev.c   | 86 ++++++++++++++++++++++++++++++++++----
 5 files changed, 91 insertions(+), 9 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index ab13211..eeb0752 100644
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index 6b7bbfb..0eed2cb 100644
@@ -9,6 +9,8 @@ Link status          = Y
 Basic stats          = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+MTU update           = Y
+Jumbo frame          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -1
index 90a383a..2eb1df3 100644
@@ -99,7 +99,11 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 
 #define ENETC_PM0_MAXFRM		0x08014
-#define ENETC_SET_MAXFRM(val)		((val) << 16)
+#define ENETC_SET_TX_MTU(val)		((val) << 16)
+#define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
+#define ENETC_PTXMBAR			0x0608
+/* n = TC index [0..7] */
+#define ENETC_PTCMSDUR(n)		(0x2020 + (n) * 4)
 
 #define ENETC_PM0_STATUS		0x08304
 #define ENETC_LINK_MODE			0x0000000000080000ULL
drivers/net/enetc/enetc.h +5 -0
index 56454dc..e494eb8 100644
@@ -24,6 +24,11 @@
 /* BD ALIGN */
 #define BD_ALIGN       8
 
+/* minimum frame size supported */
+#define ENETC_MAC_MINFRM_SIZE	68
+/* maximum frame size supported */
+#define ENETC_MAC_MAXFRM_SIZE	9600
+
 /*
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
drivers/net/enetc/enetc_ethdev.c +78 -8

116 lines not on this page · raw message

Signature · 1 line
1.9.1
#29 lore raw

PATCH v2 10/13 net/enetc: enable Rx-Tx queue start/stop feature

In reply to Gagandeep Singh

Rx and Tx queue start-stop and deferred queue start features enabled.

---
 doc/guides/nics/enetc.rst          |   2 +
 doc/guides/nics/features/enetc.ini |   1 +
 drivers/net/enetc/enetc_ethdev.c   | 185 ++++++++++++++++++++++++++-----------
 3 files changed, 134 insertions(+), 54 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index eeb0752..26d61f6 100644
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 0eed2cb..bd901fa 100644
@@ -11,6 +11,7 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
+Queue start/stop     = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/enetc_ethdev.c +131 -54

263 lines not on this page · raw message

Signature · 1 line
1.9.1
#30 lore raw

PATCH v2 11/13 net/enetc: enable CRC offload feature

In reply to Gagandeep Singh

CRC offload keep feature supported

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  |  1 +
 drivers/net/enetc/enetc.h          |  1 +
 drivers/net/enetc/enetc_ethdev.c   | 20 +++++++++++++++++---
 drivers/net/enetc/enetc_rxtx.c     |  6 ++++--
 6 files changed, 25 insertions(+), 5 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index 26d61f6..2620460 100644
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index bd901fa..101dc0a 100644
@@ -12,6 +12,7 @@ Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
+CRC offload          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -0
index 2eb1df3..261ad15 100644
@@ -97,6 +97,7 @@
 #define ENETC_PM0_CMD_CFG		0x08008
 #define ENETC_PM0_TX_EN			BIT(0)
 #define ENETC_PM0_RX_EN			BIT(1)
+#define ENETC_PM0_CRC			BIT(6)
 
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
drivers/net/enetc/enetc.h +1 -0
index e494eb8..8c830a5 100644
@@ -69,6 +69,7 @@ struct enetc_bdr {
 		void *tcisr; /* Tx */
 		int next_to_alloc; /* Rx */
 	};
+	uint8_t	crc_len; /* 0 if CRC stripped, 4 otherwise */
 };
 
 /*
drivers/net/enetc/enetc_ethdev.c +17 -3
index ff9301e..ffae8ae 100644
@@ -162,7 +162,9 @@
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
-	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
+	dev_info->rx_offload_capa =
+		(DEV_RX_OFFLOAD_KEEP_CRC |
+		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
 static int
@@ -378,6 +380,7 @@
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
+	uint64_t rx_offloads = data->dev_conf.rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	if (nb_rx_desc > MAX_BD_COUNT)
@@ -410,6 +413,9 @@
 			       RTE_ETH_QUEUE_STATE_STOPPED;
 	}
 
+	rx_ring->crc_len = (uint8_t)((rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) ?
+				     ETHER_CRC_LEN : 0);
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -625,11 +631,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 static int
 enetc_dev_configure(struct rte_eth_dev *dev)
 {
-	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
-	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct enetc_hw *enetc_hw = &hw->hw;
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -647,6 +653,14 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
+		int config;
+
+		config = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+		config |= ENETC_PM0_CRC;
+		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
+	}
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +4 -2
index 42f16ca..4a758d2 100644
@@ -208,8 +208,10 @@ static inline void __attribute__((hot))
 		if (!bd_status)
 			break;
 
-		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len;
-		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len;
+		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len -
+						rx_ring->crc_len;
+		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len -
+						 rx_ring->crc_len;
 		rx_swbd->buffer_addr->hash.rss = rxbd->r.rss_hash;
 		rx_swbd->buffer_addr->ol_flags = 0;
 		enetc_dev_rx_parse(rx_swbd->buffer_addr,
Signature · 1 line
1.9.1
#31 lore raw

PATCH v2 12/13 net/enetc: enable Rx checksum offload validation

In reply to Gagandeep Singh

Checksum Validation on Rx is supported.

---
 doc/guides/nics/features/enetc.ini |   2 +
 drivers/net/enetc/base/enetc_hw.h  |   5 ++
 drivers/net/enetc/enetc_ethdev.c   |  15 +++++-
 drivers/net/enetc/enetc_rxtx.c     | 107 ++++++++++++++++++++++++++++++++-----
 4 files changed, 115 insertions(+), 14 deletions(-)
doc/guides/nics/features/enetc.ini +2 -0
index 101dc0a..39a5201 100644
@@ -13,6 +13,8 @@ MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
 CRC offload          = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -0
index 261ad15..ff2bda5 100644
@@ -99,6 +99,10 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 #define ENETC_PM0_CRC			BIT(6)
 
+#define ENETC_PAR_PORT_CFG		0x03050
+#define L3_CKSUM			BIT(0)
+#define L4_CKSUM			BIT(1)
+
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
 #define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
@@ -182,6 +186,7 @@
 #define ENETC_TXBD_FLAGS_F		BIT(15)
 
 /* ENETC Parsed values (Little Endian) */
+#define ENETC_PARSE_ERROR		0x8000
 #define ENETC_PKT_TYPE_ETHER            0x0060
 #define ENETC_PKT_TYPE_IPV4             0x0000
 #define ENETC_PKT_TYPE_IPV6             0x0020
drivers/net/enetc/enetc_ethdev.c +14 -1
index ffae8ae..362e074 100644
@@ -163,7 +163,10 @@
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
 	dev_info->rx_offload_capa =
-		(DEV_RX_OFFLOAD_KEEP_CRC |
+		(DEV_RX_OFFLOAD_IPV4_CKSUM |
+		 DEV_RX_OFFLOAD_UDP_CKSUM |
+		 DEV_RX_OFFLOAD_TCP_CKSUM |
+		 DEV_RX_OFFLOAD_KEEP_CRC |
 		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
@@ -636,6 +639,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
 	uint64_t rx_offloads = eth_conf->rxmode.offloads;
+	uint32_t checksum = L3_CKSUM | L4_CKSUM;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -661,6 +665,15 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM)
+		checksum &= ~L3_CKSUM;
+
+	if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM))
+		checksum &= ~L4_CKSUM;
+
+	enetc_port_wr(enetc_hw, ENETC_PAR_PORT_CFG, checksum);
+
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +94 -13

163 lines not on this page · raw message

Signature · 1 line
1.9.1
#32 lore raw

PATCH v2 13/13 net/enetc: fix crash at high speed traffic

In reply to Gagandeep Singh

On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/enetc/enetc_rxtx.c +6 -1
index 0ce7dbe..81b0ef3 100644
@@ -49,11 +49,16 @@
 		uint16_t nb_pkts)
 {
 	struct enetc_swbd *tx_swbd;
-	int i, start;
+	int i, start, bds_to_use;
 	struct enetc_tx_bd *txbd;
 	struct enetc_bdr *tx_ring = (struct enetc_bdr *)tx_queue;
 
 	i = tx_ring->next_to_use;
+
+	bds_to_use = enetc_bd_unused(tx_ring);
+	if (bds_to_use < nb_pkts)
+		nb_pkts = bds_to_use;
+
 	start = 0;
 	while (nb_pkts--) {
 		enetc_clean_tx_ring(tx_ring);
Signature · 1 line
1.9.1
#33 lore raw

v3 cover ENETC PMD basic features and bug fixes

In reply to Gagandeep Singh

V1 log:
* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation, basic stats
* some bug fixes

V2 change-log:
* remove unneeded code from stats get
* fix big endian compilation

v3 change-log:
* commit message updated for 03/13 patch
* add stable to Cc for fixes

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: fix big endian build and correct buffer allocation net/enetc: set interface mode for SXGMII
net/enetc: add basic statistics
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

 doc/guides/nics/enetc.rst          |   7 +
 doc/guides/nics/features/enetc.ini |   9 +
 drivers/net/enetc/base/enetc_hw.h  |  53 ++-
 drivers/net/enetc/enetc.h          |  13 +-
 drivers/net/enetc/enetc_ethdev.c   | 734 +++++++++++++++++++++++++------------
 drivers/net/enetc/enetc_rxtx.c     | 131 +++++--
 6 files changed, 682 insertions(+), 265 deletions(-)
Signature · 1 line
1.9.1
#34 lore raw

PATCH v3 1/13 net/enetc: support physical addressing mode

Support added for physical addressing mode and
change driver flags to don't care.

---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/net/enetc/enetc_ethdev.c +12 -10
index 023fe75..7a9a97d 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -334,14 +334,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uintptr_t base_addr;
 	uint32_t tbmr;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)tx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)tx_ring->bd_base);
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
@@ -478,14 +479,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		  struct rte_mempool *mb_pool)
 {
 	int idx = rx_ring->index;
-	uintptr_t base_addr;
 	uint16_t buf_size;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)rx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)rx_ring->bd_base);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBLENR,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
@@ -612,7 +614,7 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 
 static struct rte_pci_driver rte_enetc_pmd = {
 	.id_table = pci_id_enetc_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = enetc_pci_probe,
 	.remove = enetc_pci_remove,
 };
drivers/net/enetc/enetc_rxtx.c +3 -3
index 631e243..a31a387 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -64,7 +64,7 @@
 		txbd->buf_len = txbd->frm_len;
 		txbd->flags = rte_cpu_to_le_16(ENETC_TXBD_FLAGS_F);
 		txbd->addr = (uint64_t)(uintptr_t)
-		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_addr +
+		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_iova +
 				 tx_swbd->buffer_addr->data_off);
 		i++;
 		start++;
@@ -91,7 +91,7 @@
 		rx_swbd->buffer_addr =
 			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
-			       rx_swbd->buffer_addr->buf_addr +
+			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
 		/* clear 'R" as well */
 		rxbd->r.lstatus = 0;
Signature · 1 line
1.9.1
#35 lore raw

PATCH v3 2/13 net/enetc: fix SMMU unhandled context fault

In reply to Gagandeep Singh

First configure ring with BDs properly then enable the ring.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/enetc/enetc_ethdev.c +3 -3
index 7a9a97d..f1807b9 100644
@@ -492,15 +492,15 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
 	rx_ring->mb_pool = mb_pool;
-	/* enable ring */
-	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
-	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 	rx_ring->rcir = (void *)((size_t)hw->reg +
 			ENETC_BDR(RX, idx, ENETC_RBCIR));
 	enetc_refill_rx_ring(rx_ring, (enetc_bd_unused(rx_ring)));
 	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rx_ring->mb_pool) -
 		   RTE_PKTMBUF_HEADROOM);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBSR, buf_size);
+	/* enable ring */
+	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
+	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 }
 
 static int
Signature · 1 line
1.9.1
#36 lore raw

PATCH v3 3/13 net/enetc: fix big endian build and correct buffer allocation

In reply to Gagandeep Singh

There was an error at rte_constant_bswap64 while compiling with big endian toolchain. so fixing it by adding type cast.

Also, rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/enetc/enetc_rxtx.c +3 -2
index a31a387..42f16ca 100644
@@ -88,8 +88,9 @@
 	rx_swbd = &rx_ring->q_swbd[i];
 	rxbd = ENETC_RXBD(*rx_ring, i);
 	for (j = 0; j < buff_cnt; j++) {
-		rx_swbd->buffer_addr =
-			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
+		rx_swbd->buffer_addr = (void *)(uintptr_t)
+			rte_cpu_to_le_64((uint64_t)(uintptr_t)
+					rte_pktmbuf_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
 			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
Signature · 1 line
1.9.1
#37 lore raw

PATCH v3 4/13 net/enetc: set interface mode for SXGMII

In reply to Gagandeep Singh

Support for SXGMII port has been enabled. It will depends on boot loader information passed through IERB.

---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/enetc/base/enetc_hw.h +12 -1
index f36fa11..e3738a6 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_HW_H_
@@ -84,6 +84,12 @@
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
 #define ENETC_PCAPR1			0x00904
+#define ENETC_PM0_IF_MODE		0x8300
+#define ENETC_PM1_IF_MODE		0x9300
+#define ENETC_PMO_IFM_RG		BIT(2)
+#define ENETC_PM0_IFM_RLP		(BIT(5) | BIT(11))
+#define ENETC_PM0_IFM_RGAUTO		(BIT(15) | ENETC_PMO_IFM_RG | BIT(1))
+#define ENETC_PM0_IFM_XGMII		BIT(12)
 
 #define ENETC_PV0CFGR(n)		(0x00920 + (n) * 0x10)
 #define ENETC_PVCFGR_SET_TXBDR(val)	((val) & 0xff)
@@ -109,6 +115,11 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
+
+/* MAC Counters */
+#define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
+#define ENETC_G_EPFBLPR1_XGMII		0x80000000
+
 /* general register accessors */
 #define enetc_rd_reg(reg)	rte_read32((void *)(reg))
 #define enetc_wr_reg(reg, val)	rte_write32((val), (void *)(reg))
drivers/net/enetc/enetc_ethdev.c +11 -0
index f1807b9..91e9692 100644
@@ -139,6 +139,17 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
 			val | ENETC_PMR_EN);
 
+	/* set auto-speed for RGMII */
+	if (enetc_port_rd(&hw->hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+	}
+	if (enetc_global_rd(&hw->hw,
+			    ENETC_G_EPFBLPR(1)) == ENETC_G_EPFBLPR1_XGMII) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_XGMII);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#38 lore raw

PATCH v3 5/13 net/enetc: add basic statistics

In reply to Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  | 27 ++++++++++++++++++++++++-
 drivers/net/enetc/enetc_ethdev.c   | 41 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 1 deletion(-)
doc/guides/nics/enetc.rst +1 -0
index 8038bf2..9f575d2 100644
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 69476a2..d8bd567 100644
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +26 -1
index e3738a6..3f0a2a9 100644
@@ -115,8 +115,33 @@
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
-
 /* MAC Counters */
+/* Config register to reset counters*/
+#define ENETC_PM0_STAT_CONFIG		0x080E0
+/* Receive frames counter without error */
+#define ENETC_PM0_RFRM			0x08120
+/* Receive packets counter, good + bad */
+#define ENETC_PM0_RPKT			0x08160
+/* Received octets, good + bad */
+#define ENETC_PM0_REOCT			0x08120
+/* Transmit octets, good + bad */
+#define ENETC_PM0_TEOCT			0x08200
+/* Transmit frames counter without error */
+#define ENETC_PM0_TFRM			0x08220
+/* Transmit packets counter, good + bad */
+#define ENETC_PM0_TPKT			0x08260
+/* Dropped not Truncated packets counter */
+#define ENETC_PM0_RDRNTP		0x081C8
+/* Dropped + trucated packets counter */
+#define ENETC_PM0_RDRP			0x08158
+/* Receive packets error counter */
+#define ENETC_PM0_RERR			0x08138
+/* Transmit packets error counter */
+#define ENETC_PM0_TERR			0x08238
+
+/* Stats Reset Bit*/
+#define ENETC_CLEAR_STATS		BIT(2)
+
 #define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
 #define ENETC_G_EPFBLPR1_XGMII		0x80000000
 
drivers/net/enetc/enetc_ethdev.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
1.9.1
#39 lore raw

PATCH v3 6/13 net/enetc: replace register read/write macros with functions

In reply to Gagandeep Singh

Replacing read-write macros with already available read-write functions.

---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)
drivers/net/enetc/enetc.h +1 -6
index 0e80d1c..56454dc 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_H_
@@ -86,11 +86,6 @@ struct enetc_eth_adapter {
 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
 	(&((struct enetc_eth_adapter *)adapter)->intr)
 
-#define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr)))
-#define ENETC_REG_READ(addr) (*(uint32_t *)addr)
-#define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr = val)
-#define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr = val)
-
 /*
  * RX/TX ENETC function prototypes
  */
drivers/net/enetc/enetc_ethdev.c +30 -31

118 lines not on this page · raw message

Signature · 1 line
1.9.1
#40 lore raw

PATCH v3 7/13 net/enetc: remove forward declarations

In reply to Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)
drivers/net/enetc/enetc_ethdev.c +107 -130
index 2d8c4e6..d0f9e2b 100644
@@ -10,115 +10,6 @@
 
 int enetc_logtype_pmd;
 
-/* Functions Prototypes */
-static int enetc_dev_configure(struct rte_eth_dev *dev);
-static int enetc_dev_start(struct rte_eth_dev *dev);
-static void enetc_dev_stop(struct rte_eth_dev *dev);
-static void enetc_dev_close(struct rte_eth_dev *dev);
-static void enetc_dev_infos_get(struct rte_eth_dev *dev,
-				struct rte_eth_dev_info *dev_info);
-static int enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-static int enetc_hardware_init(struct enetc_eth_hw *hw);
-static int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
-		uint16_t nb_rx_desc, unsigned int socket_id,
-		const struct rte_eth_rxconf *rx_conf,
-		struct rte_mempool *mb_pool);
-static void enetc_rx_queue_release(void *rxq);
-static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
-		uint16_t nb_tx_desc, unsigned int socket_id,
-		const struct rte_eth_txconf *tx_conf);
-static void enetc_tx_queue_release(void *txq);
-static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev);
-static int enetc_stats_get(struct rte_eth_dev *dev,
-		struct rte_eth_stats *stats);
-static void enetc_stats_reset(struct rte_eth_dev *dev);
-
-/*
- * The set of PCI devices this driver supports
- */
-static const struct rte_pci_id pci_id_enetc_map[] = {
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
-	{ .vendor_id = 0, /* sentinel */ },
-};
-
-/* Features supported by this driver */
-static const struct eth_dev_ops enetc_ops = {
-	.dev_configure        = enetc_dev_configure,
-	.dev_start            = enetc_dev_start,
-	.dev_stop             = enetc_dev_stop,
-	.dev_close            = enetc_dev_close,
-	.link_update          = enetc_link_update,
-	.stats_get            = enetc_stats_get,
-	.stats_reset          = enetc_stats_reset,
-	.dev_infos_get        = enetc_dev_infos_get,
-	.rx_queue_setup       = enetc_rx_queue_setup,
-	.rx_queue_release     = enetc_rx_queue_release,
-	.tx_queue_setup       = enetc_tx_queue_setup,
-	.tx_queue_release     = enetc_tx_queue_release,
-	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
-};
-
-/**
- * Initialisation of the enetc device
- *
- * @param eth_dev
- *   - Pointer to the structure rte_eth_dev
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static int
-enetc_dev_init(struct rte_eth_dev *eth_dev)
-{
-	int error = 0;
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	struct enetc_eth_hw *hw =
-		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-
-	PMD_INIT_FUNC_TRACE();
-	eth_dev->dev_ops = &enetc_ops;
-	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
-	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
-
-	/* Retrieving and storing the HW base address of device */
-	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
-	hw->device_id = pci_dev->id.device_id;
-
-	error = enetc_hardware_init(hw);
-	if (error != 0) {
-		ENETC_PMD_ERR("Hardware initialization failed");
-		return -1;
-	}
-
-	/* Allocate memory for storing MAC addresses */
-	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
-	if (!eth_dev->data->mac_addrs) {
-		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
-			      "store MAC addresses",
-			      ETHER_ADDR_LEN * 1);
-		error = -ENOMEM;
-		return -1;
-	}
-
-	/* Copy the permanent MAC address */
-	ether_addr_copy((struct ether_addr *)hw->mac.addr,
-			&eth_dev->data->mac_addrs[0]);
-
-	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
-			eth_dev->data->port_id, pci_dev->id.vendor_id,
-			pci_dev->id.device_id);
-	return 0;
-}
-
-static int
-enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
@@ -179,27 +70,6 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
-static void
-enetc_dev_close(struct rte_eth_dev *dev)
-{
-	uint16_t i;
-
-	PMD_INIT_FUNC_TRACE();
-	enetc_dev_stop(dev);
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		enetc_rx_queue_release(dev->data->rx_queues[i]);
-		dev->data->rx_queues[i] = NULL;
-	}
-	dev->data->nb_rx_queues = 0;
-
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		enetc_tx_queue_release(dev->data->tx_queues[i]);
-		dev->data->tx_queues[i] = NULL;
-	}
-	dev->data->nb_tx_queues = 0;
-}
-
 static const uint32_t *
 enetc_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 {
@@ -648,6 +518,113 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
 }
 
+static void
+enetc_dev_close(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+
+	PMD_INIT_FUNC_TRACE();
+	enetc_dev_stop(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		enetc_rx_queue_release(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		enetc_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static const struct rte_pci_id pci_id_enetc_map[] = {
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+/* Features supported by this driver */
+static const struct eth_dev_ops enetc_ops = {
+	.dev_configure        = enetc_dev_configure,
+	.dev_start            = enetc_dev_start,
+	.dev_stop             = enetc_dev_stop,
+	.dev_close            = enetc_dev_close,
+	.link_update          = enetc_link_update,
+	.stats_get            = enetc_stats_get,
+	.stats_reset          = enetc_stats_reset,
+	.dev_infos_get        = enetc_dev_infos_get,
+	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_release     = enetc_rx_queue_release,
+	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_release     = enetc_tx_queue_release,
+	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
+};
+
+/**
+ * Initialisation of the enetc device
+ *
+ * @param eth_dev
+ *   - Pointer to the structure rte_eth_dev
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static int
+enetc_dev_init(struct rte_eth_dev *eth_dev)
+{
+	int error = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+	eth_dev->dev_ops = &enetc_ops;
+	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
+	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
+
+	/* Retrieving and storing the HW base address of device */
+	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
+	hw->device_id = pci_dev->id.device_id;
+
+	error = enetc_hardware_init(hw);
+	if (error != 0) {
+		ENETC_PMD_ERR("Hardware initialization failed");
+		return -1;
+	}
+
+	/* Allocate memory for storing MAC addresses */
+	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
+	if (!eth_dev->data->mac_addrs) {
+		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
+			      "store MAC addresses",
+			      ETHER_ADDR_LEN * 1);
+		error = -ENOMEM;
+		return -1;
+	}
+
+	/* Copy the permanent MAC address */
+	ether_addr_copy((struct ether_addr *)hw->mac.addr,
+			&eth_dev->data->mac_addrs[0]);
+
+	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
+			eth_dev->data->port_id, pci_dev->id.vendor_id,
+			pci_dev->id.device_id);
+	return 0;
+}
+
+static int
+enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+	return 0;
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
Signature · 1 line
1.9.1
#41 lore raw

PATCH v3 8/13 net/enetc: enable promiscuous and allmulticast feature

In reply to Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

---
 doc/guides/nics/enetc.rst          |  2 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  3 +-
 drivers/net/enetc/enetc_ethdev.c   | 90 ++++++++++++++++++++++++++++++++------
 4 files changed, 81 insertions(+), 16 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index 9f575d2..ab13211 100644
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index d8bd567..6b7bbfb 100644
@@ -7,6 +7,8 @@
 Packet type parsing  = Y
 Link status          = Y
 Basic stats          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -2
index 3f0a2a9..90a383a 100644
@@ -78,8 +78,7 @@
 #define ENETC_PSR			0x00004 /* RO */
 #define ENETC_PSIPMR			0x00018
 #define ENETC_PSIPMR_SET_UP(n)		(0x1 << (n)) /* n = SI index */
-#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 8))
-#define ENETC_PSIPMR_SET_VLAN_MP(n)	(0x1 << ((n) + 16))
+#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 16))
 #define ENETC_PSIPMAR0(n)		(0x00100 + (n) * 0x20)
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
drivers/net/enetc/enetc_ethdev.c +76 -14

115 lines not on this page · raw message

Signature · 1 line
1.9.1
#42 lore raw

PATCH v3 9/13 net/enetc: add MTU update and jumbo frames support

In reply to Gagandeep Singh

Enable the jumbo frames and mtu update feature.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  6 ++-
 drivers/net/enetc/enetc.h          |  5 +++
 drivers/net/enetc/enetc_ethdev.c   | 86 ++++++++++++++++++++++++++++++++++----
 5 files changed, 91 insertions(+), 9 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index ab13211..eeb0752 100644
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index 6b7bbfb..0eed2cb 100644
@@ -9,6 +9,8 @@ Link status          = Y
 Basic stats          = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+MTU update           = Y
+Jumbo frame          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -1
index 90a383a..2eb1df3 100644
@@ -99,7 +99,11 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 
 #define ENETC_PM0_MAXFRM		0x08014
-#define ENETC_SET_MAXFRM(val)		((val) << 16)
+#define ENETC_SET_TX_MTU(val)		((val) << 16)
+#define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
+#define ENETC_PTXMBAR			0x0608
+/* n = TC index [0..7] */
+#define ENETC_PTCMSDUR(n)		(0x2020 + (n) * 4)
 
 #define ENETC_PM0_STATUS		0x08304
 #define ENETC_LINK_MODE			0x0000000000080000ULL
drivers/net/enetc/enetc.h +5 -0
index 56454dc..e494eb8 100644
@@ -24,6 +24,11 @@
 /* BD ALIGN */
 #define BD_ALIGN       8
 
+/* minimum frame size supported */
+#define ENETC_MAC_MINFRM_SIZE	68
+/* maximum frame size supported */
+#define ENETC_MAC_MAXFRM_SIZE	9600
+
 /*
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
drivers/net/enetc/enetc_ethdev.c +78 -8

116 lines not on this page · raw message

Signature · 1 line
1.9.1
#43 lore raw

PATCH v3 10/13 net/enetc: enable Rx-Tx queue start/stop feature

In reply to Gagandeep Singh

Rx and Tx queue start-stop and deferred queue start features enabled.

---
 doc/guides/nics/enetc.rst          |   2 +
 doc/guides/nics/features/enetc.ini |   1 +
 drivers/net/enetc/enetc_ethdev.c   | 185 ++++++++++++++++++++++++++-----------
 3 files changed, 134 insertions(+), 54 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index eeb0752..26d61f6 100644
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 0eed2cb..bd901fa 100644
@@ -11,6 +11,7 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
+Queue start/stop     = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/enetc_ethdev.c +131 -54

263 lines not on this page · raw message

Signature · 1 line
1.9.1
#44 lore raw

PATCH v3 11/13 net/enetc: enable CRC offload feature

In reply to Gagandeep Singh

CRC offload keep feature supported

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  |  1 +
 drivers/net/enetc/enetc.h          |  1 +
 drivers/net/enetc/enetc_ethdev.c   | 20 +++++++++++++++++---
 drivers/net/enetc/enetc_rxtx.c     |  6 ++++--
 6 files changed, 25 insertions(+), 5 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index 26d61f6..2620460 100644
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index bd901fa..101dc0a 100644
@@ -12,6 +12,7 @@ Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
+CRC offload          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -0
index 2eb1df3..261ad15 100644
@@ -97,6 +97,7 @@
 #define ENETC_PM0_CMD_CFG		0x08008
 #define ENETC_PM0_TX_EN			BIT(0)
 #define ENETC_PM0_RX_EN			BIT(1)
+#define ENETC_PM0_CRC			BIT(6)
 
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
drivers/net/enetc/enetc.h +1 -0
index e494eb8..8c830a5 100644
@@ -69,6 +69,7 @@ struct enetc_bdr {
 		void *tcisr; /* Tx */
 		int next_to_alloc; /* Rx */
 	};
+	uint8_t	crc_len; /* 0 if CRC stripped, 4 otherwise */
 };
 
 /*
drivers/net/enetc/enetc_ethdev.c +17 -3
index ff9301e..ffae8ae 100644
@@ -162,7 +162,9 @@
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
-	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
+	dev_info->rx_offload_capa =
+		(DEV_RX_OFFLOAD_KEEP_CRC |
+		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
 static int
@@ -378,6 +380,7 @@
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
+	uint64_t rx_offloads = data->dev_conf.rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	if (nb_rx_desc > MAX_BD_COUNT)
@@ -410,6 +413,9 @@
 			       RTE_ETH_QUEUE_STATE_STOPPED;
 	}
 
+	rx_ring->crc_len = (uint8_t)((rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) ?
+				     ETHER_CRC_LEN : 0);
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -625,11 +631,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 static int
 enetc_dev_configure(struct rte_eth_dev *dev)
 {
-	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
-	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct enetc_hw *enetc_hw = &hw->hw;
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -647,6 +653,14 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
+		int config;
+
+		config = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+		config |= ENETC_PM0_CRC;
+		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
+	}
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +4 -2
index 42f16ca..4a758d2 100644
@@ -208,8 +208,10 @@ static inline void __attribute__((hot))
 		if (!bd_status)
 			break;
 
-		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len;
-		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len;
+		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len -
+						rx_ring->crc_len;
+		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len -
+						 rx_ring->crc_len;
 		rx_swbd->buffer_addr->hash.rss = rxbd->r.rss_hash;
 		rx_swbd->buffer_addr->ol_flags = 0;
 		enetc_dev_rx_parse(rx_swbd->buffer_addr,
Signature · 1 line
1.9.1
#45 lore raw

PATCH v3 12/13 net/enetc: enable Rx checksum offload validation

In reply to Gagandeep Singh

Checksum Validation on Rx is supported.

---
 doc/guides/nics/features/enetc.ini |   2 +
 drivers/net/enetc/base/enetc_hw.h  |   5 ++
 drivers/net/enetc/enetc_ethdev.c   |  15 +++++-
 drivers/net/enetc/enetc_rxtx.c     | 107 ++++++++++++++++++++++++++++++++-----
 4 files changed, 115 insertions(+), 14 deletions(-)
doc/guides/nics/features/enetc.ini +2 -0
index 101dc0a..39a5201 100644
@@ -13,6 +13,8 @@ MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
 CRC offload          = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -0
index 261ad15..ff2bda5 100644
@@ -99,6 +99,10 @@
 #define ENETC_PM0_RX_EN			BIT(1)
 #define ENETC_PM0_CRC			BIT(6)
 
+#define ENETC_PAR_PORT_CFG		0x03050
+#define L3_CKSUM			BIT(0)
+#define L4_CKSUM			BIT(1)
+
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
 #define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
@@ -182,6 +186,7 @@
 #define ENETC_TXBD_FLAGS_F		BIT(15)
 
 /* ENETC Parsed values (Little Endian) */
+#define ENETC_PARSE_ERROR		0x8000
 #define ENETC_PKT_TYPE_ETHER            0x0060
 #define ENETC_PKT_TYPE_IPV4             0x0000
 #define ENETC_PKT_TYPE_IPV6             0x0020
drivers/net/enetc/enetc_ethdev.c +14 -1
index ffae8ae..362e074 100644
@@ -163,7 +163,10 @@
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
 	dev_info->rx_offload_capa =
-		(DEV_RX_OFFLOAD_KEEP_CRC |
+		(DEV_RX_OFFLOAD_IPV4_CKSUM |
+		 DEV_RX_OFFLOAD_UDP_CKSUM |
+		 DEV_RX_OFFLOAD_TCP_CKSUM |
+		 DEV_RX_OFFLOAD_KEEP_CRC |
 		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
@@ -636,6 +639,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
 	uint64_t rx_offloads = eth_conf->rxmode.offloads;
+	uint32_t checksum = L3_CKSUM | L4_CKSUM;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -661,6 +665,15 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM)
+		checksum &= ~L3_CKSUM;
+
+	if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM))
+		checksum &= ~L4_CKSUM;
+
+	enetc_port_wr(enetc_hw, ENETC_PAR_PORT_CFG, checksum);
+
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +94 -13

163 lines not on this page · raw message

Signature · 1 line
1.9.1
#46 lore raw

PATCH v3 13/13 net/enetc: fix crash at high speed traffic

In reply to Gagandeep Singh

On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/enetc/enetc_rxtx.c +6 -1
index 0ce7dbe..81b0ef3 100644
@@ -49,11 +49,16 @@
 		uint16_t nb_pkts)
 {
 	struct enetc_swbd *tx_swbd;
-	int i, start;
+	int i, start, bds_to_use;
 	struct enetc_tx_bd *txbd;
 	struct enetc_bdr *tx_ring = (struct enetc_bdr *)tx_queue;
 
 	i = tx_ring->next_to_use;
+
+	bds_to_use = enetc_bd_unused(tx_ring);
+	if (bds_to_use < nb_pkts)
+		nb_pkts = bds_to_use;
+
 	start = 0;
 	while (nb_pkts--) {
 		enetc_clean_tx_ring(tx_ring);
Signature · 1 line
1.9.1
#47 lore raw

v4 cover ENETC PMD basic features and bug fixes

In reply to Gagandeep Singh

*V1 log:
* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation, basic stats
* some bug fixes

V2 change-log:
* remove unneeded code from stats get
* fix big endian compilation

v3 change-log:
* commit message updated for 03/13 patch
* add stable to Cc for fixes

v4 change-log:
* Removed checkpatch errors for CRLF

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: fix big endian build and correct buffer allocation net/enetc: set interface mode for SXGMII
net/enetc: add basic statistics
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

 doc/guides/nics/enetc.rst          |   7 +
 doc/guides/nics/features/enetc.ini |   9 +
 drivers/net/enetc/base/enetc_hw.h  |  53 ++-
 drivers/net/enetc/enetc.h          |  13 +-
 drivers/net/enetc/enetc_ethdev.c   | 734 ++++++++++++++++++++---------
 drivers/net/enetc/enetc_rxtx.c     | 131 ++++-
 6 files changed, 682 insertions(+), 265 deletions(-)
Signature · 1 line
2.19.1
#48 lore raw

PATCH v4 1/13 net/enetc: support physical addressing mode

Support added for physical addressing mode and
change driver flags to don't care.

---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/net/enetc/enetc_ethdev.c +12 -10
index 023fe7517..7a9a97deb 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -334,14 +334,15 @@ static void
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uintptr_t base_addr;
 	uint32_t tbmr;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)tx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)tx_ring->bd_base);
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
@@ -478,14 +479,15 @@ enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
 		  struct rte_mempool *mb_pool)
 {
 	int idx = rx_ring->index;
-	uintptr_t base_addr;
 	uint16_t buf_size;
+	phys_addr_t bd_address;
 
-	base_addr = (uintptr_t)rx_ring->bd_base;
+	bd_address = (phys_addr_t)
+		     rte_mem_virt2iova((const void *)rx_ring->bd_base);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR0,
-		       lower_32_bits((uint64_t)base_addr));
+		       lower_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBAR1,
-		       upper_32_bits((uint64_t)base_addr));
+		       upper_32_bits((uint64_t)bd_address));
 	enetc_rxbdr_wr(hw, idx, ENETC_RBLENR,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
@@ -612,7 +614,7 @@ enetc_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_enetc_pmd = {
 	.id_table = pci_id_enetc_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = enetc_pci_probe,
 	.remove = enetc_pci_remove,
 };
drivers/net/enetc/enetc_rxtx.c +3 -3
index 631e2430d..a31a38725 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <stdbool.h>
@@ -64,7 +64,7 @@ enetc_xmit_pkts(void *tx_queue,
 		txbd->buf_len = txbd->frm_len;
 		txbd->flags = rte_cpu_to_le_16(ENETC_TXBD_FLAGS_F);
 		txbd->addr = (uint64_t)(uintptr_t)
-		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_addr +
+		rte_cpu_to_le_64((size_t)tx_swbd->buffer_addr->buf_iova +
 				 tx_swbd->buffer_addr->data_off);
 		i++;
 		start++;
@@ -91,7 +91,7 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 		rx_swbd->buffer_addr =
 			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
-			       rx_swbd->buffer_addr->buf_addr +
+			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
 		/* clear 'R" as well */
 		rxbd->r.lstatus = 0;
Signature · 1 line
2.19.1
#49 lore raw

PATCH v4 2/13 net/enetc: fix SMMU unhandled context fault

In reply to Gagandeep Singh

First configure ring with BDs properly then enable the ring.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/enetc/enetc_ethdev.c +3 -3
index 7a9a97deb..f1807b901 100644
@@ -492,15 +492,15 @@ enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
 		       ENETC_RTBLENR_LEN(rx_ring->bd_count));
 
 	rx_ring->mb_pool = mb_pool;
-	/* enable ring */
-	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
-	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 	rx_ring->rcir = (void *)((size_t)hw->reg +
 			ENETC_BDR(RX, idx, ENETC_RBCIR));
 	enetc_refill_rx_ring(rx_ring, (enetc_bd_unused(rx_ring)));
 	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rx_ring->mb_pool) -
 		   RTE_PKTMBUF_HEADROOM);
 	enetc_rxbdr_wr(hw, idx, ENETC_RBBSR, buf_size);
+	/* enable ring */
+	enetc_rxbdr_wr(hw, idx, ENETC_RBMR, ENETC_RBMR_EN);
+	enetc_rxbdr_wr(hw, idx, ENETC_RBPIR, 0);
 }
 
 static int
Signature · 1 line
2.19.1
#50 lore raw

PATCH v4 3/13 net/enetc: fix big endian build and correct buffer allocation

In reply to Gagandeep Singh

There was an error at rte_constant_bswap64 while compiling with big endian toolchain. so fixing it by adding type cast.

Also, rte_pktmbuf_alloc API should be used to allocate mbuf instead of rte_pktmbuf_raw_alloc to avoid use of stale mbuf information.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/enetc/enetc_rxtx.c +3 -2
index a31a38725..42f16cab1 100644
@@ -88,8 +88,9 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 	rx_swbd = &rx_ring->q_swbd[i];
 	rxbd = ENETC_RXBD(*rx_ring, i);
 	for (j = 0; j < buff_cnt; j++) {
-		rx_swbd->buffer_addr =
-			rte_cpu_to_le_64(rte_mbuf_raw_alloc(rx_ring->mb_pool));
+		rx_swbd->buffer_addr = (void *)(uintptr_t)
+			rte_cpu_to_le_64((uint64_t)(uintptr_t)
+					rte_pktmbuf_alloc(rx_ring->mb_pool));
 		rxbd->w.addr = (uint64_t)(uintptr_t)
 			       rx_swbd->buffer_addr->buf_iova +
 			       rx_swbd->buffer_addr->data_off;
Signature · 1 line
2.19.1
#51 lore raw

PATCH v4 4/13 net/enetc: set interface mode for SXGMII

In reply to Gagandeep Singh

Support for SXGMII port has been enabled. It will depends on boot loader information passed through IERB.

---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/enetc/base/enetc_hw.h +12 -1
index f36fa11e0..e3738a695 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_HW_H_
@@ -84,6 +84,12 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
 #define ENETC_PCAPR1			0x00904
+#define ENETC_PM0_IF_MODE		0x8300
+#define ENETC_PM1_IF_MODE		0x9300
+#define ENETC_PMO_IFM_RG		BIT(2)
+#define ENETC_PM0_IFM_RLP		(BIT(5) | BIT(11))
+#define ENETC_PM0_IFM_RGAUTO		(BIT(15) | ENETC_PMO_IFM_RG | BIT(1))
+#define ENETC_PM0_IFM_XGMII		BIT(12)
 
 #define ENETC_PV0CFGR(n)		(0x00920 + (n) * 0x10)
 #define ENETC_PVCFGR_SET_TXBDR(val)	((val) & 0xff)
@@ -109,6 +115,11 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
+
+/* MAC Counters */
+#define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
+#define ENETC_G_EPFBLPR1_XGMII		0x80000000
+
 /* general register accessors */
 #define enetc_rd_reg(reg)	rte_read32((void *)(reg))
 #define enetc_wr_reg(reg, val)	rte_write32((val), (void *)(reg))
drivers/net/enetc/enetc_ethdev.c +11 -0
index f1807b901..91e9692d6 100644
@@ -139,6 +139,17 @@ enetc_dev_start(struct rte_eth_dev *dev)
 	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
 			val | ENETC_PMR_EN);
 
+	/* set auto-speed for RGMII */
+	if (enetc_port_rd(&hw->hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+	}
+	if (enetc_global_rd(&hw->hw,
+			    ENETC_G_EPFBLPR(1)) == ENETC_G_EPFBLPR1_XGMII) {
+		enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_XGMII);
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.19.1
#52 lore raw

PATCH v4 5/13 net/enetc: add basic statistics

In reply to Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  | 27 +++++++++++++++++++-
 drivers/net/enetc/enetc_ethdev.c   | 41 ++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 1 deletion(-)
doc/guides/nics/enetc.rst +1 -0
index 8038bf205..9f575d27f 100644
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 69476a2a1..d8bd5679d 100644
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +26 -1
index e3738a695..3f0a2a9a3 100644
@@ -115,8 +115,33 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_G_EIPBRR0			0x00bf8
 #define ENETC_G_EIPBRR1			0x00bfc
 
-
 /* MAC Counters */
+/* Config register to reset counters*/
+#define ENETC_PM0_STAT_CONFIG		0x080E0
+/* Receive frames counter without error */
+#define ENETC_PM0_RFRM			0x08120
+/* Receive packets counter, good + bad */
+#define ENETC_PM0_RPKT			0x08160
+/* Received octets, good + bad */
+#define ENETC_PM0_REOCT			0x08120
+/* Transmit octets, good + bad */
+#define ENETC_PM0_TEOCT			0x08200
+/* Transmit frames counter without error */
+#define ENETC_PM0_TFRM			0x08220
+/* Transmit packets counter, good + bad */
+#define ENETC_PM0_TPKT			0x08260
+/* Dropped not Truncated packets counter */
+#define ENETC_PM0_RDRNTP		0x081C8
+/* Dropped + trucated packets counter */
+#define ENETC_PM0_RDRP			0x08158
+/* Receive packets error counter */
+#define ENETC_PM0_RERR			0x08138
+/* Transmit packets error counter */
+#define ENETC_PM0_TERR			0x08238
+
+/* Stats Reset Bit*/
+#define ENETC_CLEAR_STATS		BIT(2)
+
 #define ENETC_G_EPFBLPR(n)		(0xd00 + 4 * (n))
 #define ENETC_G_EPFBLPR1_XGMII		0x80000000
 
drivers/net/enetc/enetc_ethdev.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
2.19.1
#53 lore raw

PATCH v4 6/13 net/enetc: replace register read/write macros with functions

In reply to Gagandeep Singh

Replacing read-write macros with already available read-write functions.

---
 drivers/net/enetc/enetc.h        |  7 +---
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++----------------
 2 files changed, 31 insertions(+), 37 deletions(-)
drivers/net/enetc/enetc.h +1 -6
index 0e80d1c5b..56454dc9d 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #ifndef _ENETC_H_
@@ -86,11 +86,6 @@ struct enetc_eth_adapter {
 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
 	(&((struct enetc_eth_adapter *)adapter)->intr)
 
-#define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr)))
-#define ENETC_REG_READ(addr) (*(uint32_t *)addr)
-#define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr = val)
-#define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr = val)
-
 /*
  * RX/TX ENETC function prototypes
  */
drivers/net/enetc/enetc_ethdev.c +30 -31

118 lines not on this page · raw message

Signature · 1 line
2.19.1
#54 lore raw

PATCH v4 7/13 net/enetc: remove forward declarations

In reply to Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++-----------------
 1 file changed, 107 insertions(+), 130 deletions(-)
drivers/net/enetc/enetc_ethdev.c +107 -130
index 2d8c4e604..d0f9e2b35 100644
@@ -10,115 +10,6 @@
 
 int enetc_logtype_pmd;
 
-/* Functions Prototypes */
-static int enetc_dev_configure(struct rte_eth_dev *dev);
-static int enetc_dev_start(struct rte_eth_dev *dev);
-static void enetc_dev_stop(struct rte_eth_dev *dev);
-static void enetc_dev_close(struct rte_eth_dev *dev);
-static void enetc_dev_infos_get(struct rte_eth_dev *dev,
-				struct rte_eth_dev_info *dev_info);
-static int enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-static int enetc_hardware_init(struct enetc_eth_hw *hw);
-static int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
-		uint16_t nb_rx_desc, unsigned int socket_id,
-		const struct rte_eth_rxconf *rx_conf,
-		struct rte_mempool *mb_pool);
-static void enetc_rx_queue_release(void *rxq);
-static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
-		uint16_t nb_tx_desc, unsigned int socket_id,
-		const struct rte_eth_txconf *tx_conf);
-static void enetc_tx_queue_release(void *txq);
-static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev);
-static int enetc_stats_get(struct rte_eth_dev *dev,
-		struct rte_eth_stats *stats);
-static void enetc_stats_reset(struct rte_eth_dev *dev);
-
-/*
- * The set of PCI devices this driver supports
- */
-static const struct rte_pci_id pci_id_enetc_map[] = {
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
-	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
-	{ .vendor_id = 0, /* sentinel */ },
-};
-
-/* Features supported by this driver */
-static const struct eth_dev_ops enetc_ops = {
-	.dev_configure        = enetc_dev_configure,
-	.dev_start            = enetc_dev_start,
-	.dev_stop             = enetc_dev_stop,
-	.dev_close            = enetc_dev_close,
-	.link_update          = enetc_link_update,
-	.stats_get            = enetc_stats_get,
-	.stats_reset          = enetc_stats_reset,
-	.dev_infos_get        = enetc_dev_infos_get,
-	.rx_queue_setup       = enetc_rx_queue_setup,
-	.rx_queue_release     = enetc_rx_queue_release,
-	.tx_queue_setup       = enetc_tx_queue_setup,
-	.tx_queue_release     = enetc_tx_queue_release,
-	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
-};
-
-/**
- * Initialisation of the enetc device
- *
- * @param eth_dev
- *   - Pointer to the structure rte_eth_dev
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static int
-enetc_dev_init(struct rte_eth_dev *eth_dev)
-{
-	int error = 0;
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	struct enetc_eth_hw *hw =
-		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-
-	PMD_INIT_FUNC_TRACE();
-	eth_dev->dev_ops = &enetc_ops;
-	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
-	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
-
-	/* Retrieving and storing the HW base address of device */
-	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
-	hw->device_id = pci_dev->id.device_id;
-
-	error = enetc_hardware_init(hw);
-	if (error != 0) {
-		ENETC_PMD_ERR("Hardware initialization failed");
-		return -1;
-	}
-
-	/* Allocate memory for storing MAC addresses */
-	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
-	if (!eth_dev->data->mac_addrs) {
-		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
-			      "store MAC addresses",
-			      ETHER_ADDR_LEN * 1);
-		error = -ENOMEM;
-		return -1;
-	}
-
-	/* Copy the permanent MAC address */
-	ether_addr_copy((struct ether_addr *)hw->mac.addr,
-			&eth_dev->data->mac_addrs[0]);
-
-	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
-			eth_dev->data->port_id, pci_dev->id.vendor_id,
-			pci_dev->id.device_id);
-	return 0;
-}
-
-static int
-enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
@@ -179,27 +70,6 @@ enetc_dev_stop(struct rte_eth_dev *dev)
 		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
-static void
-enetc_dev_close(struct rte_eth_dev *dev)
-{
-	uint16_t i;
-
-	PMD_INIT_FUNC_TRACE();
-	enetc_dev_stop(dev);
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		enetc_rx_queue_release(dev->data->rx_queues[i]);
-		dev->data->rx_queues[i] = NULL;
-	}
-	dev->data->nb_rx_queues = 0;
-
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		enetc_tx_queue_release(dev->data->tx_queues[i]);
-		dev->data->tx_queues[i] = NULL;
-	}
-	dev->data->nb_tx_queues = 0;
-}
-
 static const uint32_t *
 enetc_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 {
@@ -648,6 +518,113 @@ enetc_stats_reset(struct rte_eth_dev *dev)
 	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
 }
 
+static void
+enetc_dev_close(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+
+	PMD_INIT_FUNC_TRACE();
+	enetc_dev_stop(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		enetc_rx_queue_release(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		enetc_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static const struct rte_pci_id pci_id_enetc_map[] = {
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) },
+	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+/* Features supported by this driver */
+static const struct eth_dev_ops enetc_ops = {
+	.dev_configure        = enetc_dev_configure,
+	.dev_start            = enetc_dev_start,
+	.dev_stop             = enetc_dev_stop,
+	.dev_close            = enetc_dev_close,
+	.link_update          = enetc_link_update,
+	.stats_get            = enetc_stats_get,
+	.stats_reset          = enetc_stats_reset,
+	.dev_infos_get        = enetc_dev_infos_get,
+	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_release     = enetc_rx_queue_release,
+	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_release     = enetc_tx_queue_release,
+	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
+};
+
+/**
+ * Initialisation of the enetc device
+ *
+ * @param eth_dev
+ *   - Pointer to the structure rte_eth_dev
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static int
+enetc_dev_init(struct rte_eth_dev *eth_dev)
+{
+	int error = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+	eth_dev->dev_ops = &enetc_ops;
+	eth_dev->rx_pkt_burst = &enetc_recv_pkts;
+	eth_dev->tx_pkt_burst = &enetc_xmit_pkts;
+
+	/* Retrieving and storing the HW base address of device */
+	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
+	hw->device_id = pci_dev->id.device_id;
+
+	error = enetc_hardware_init(hw);
+	if (error != 0) {
+		ENETC_PMD_ERR("Hardware initialization failed");
+		return -1;
+	}
+
+	/* Allocate memory for storing MAC addresses */
+	eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0);
+	if (!eth_dev->data->mac_addrs) {
+		ENETC_PMD_ERR("Failed to allocate %d bytes needed to "
+			      "store MAC addresses",
+			      ETHER_ADDR_LEN * 1);
+		error = -ENOMEM;
+		return -1;
+	}
+
+	/* Copy the permanent MAC address */
+	ether_addr_copy((struct ether_addr *)hw->mac.addr,
+			&eth_dev->data->mac_addrs[0]);
+
+	ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
+			eth_dev->data->port_id, pci_dev->id.vendor_id,
+			pci_dev->id.device_id);
+	return 0;
+}
+
+static int
+enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+	return 0;
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
Signature · 1 line
2.19.1
#55 lore raw

PATCH v4 8/13 net/enetc: enable promiscuous and allmulticast feature

In reply to Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

---
 doc/guides/nics/enetc.rst          |  2 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  3 +-
 drivers/net/enetc/enetc_ethdev.c   | 90 +++++++++++++++++++++++++-----
 4 files changed, 81 insertions(+), 16 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index 9f575d27f..ab13211a5 100644
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index d8bd5679d..6b7bbfb3d 100644
@@ -7,6 +7,8 @@
 Packet type parsing  = Y
 Link status          = Y
 Basic stats          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -2
index 3f0a2a9a3..90a383a8b 100644
@@ -78,8 +78,7 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PSR			0x00004 /* RO */
 #define ENETC_PSIPMR			0x00018
 #define ENETC_PSIPMR_SET_UP(n)		(0x1 << (n)) /* n = SI index */
-#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 8))
-#define ENETC_PSIPMR_SET_VLAN_MP(n)	(0x1 << ((n) + 16))
+#define ENETC_PSIPMR_SET_MP(n)		(0x1 << ((n) + 16))
 #define ENETC_PSIPMAR0(n)		(0x00100 + (n) * 0x20)
 #define ENETC_PSIPMAR1(n)		(0x00104 + (n) * 0x20)
 #define ENETC_PCAPR0			0x00900
drivers/net/enetc/enetc_ethdev.c +76 -14

115 lines not on this page · raw message

Signature · 1 line
2.19.1
#56 lore raw

PATCH v4 9/13 net/enetc: add MTU update and jumbo frames support

In reply to Gagandeep Singh

Enable the jumbo frames and mtu update feature.

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  2 +
 drivers/net/enetc/base/enetc_hw.h  |  6 ++-
 drivers/net/enetc/enetc.h          |  5 ++
 drivers/net/enetc/enetc_ethdev.c   | 86 +++++++++++++++++++++++++++---
 5 files changed, 91 insertions(+), 9 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index ab13211a5..eeb07523d 100644
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +2 -0
index 6b7bbfb3d..0eed2cb9b 100644
@@ -9,6 +9,8 @@ Link status          = Y
 Basic stats          = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+MTU update           = Y
+Jumbo frame          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -1
index 90a383a8b..2eb1df30e 100644
@@ -99,7 +99,11 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PM0_RX_EN			BIT(1)
 
 #define ENETC_PM0_MAXFRM		0x08014
-#define ENETC_SET_MAXFRM(val)		((val) << 16)
+#define ENETC_SET_TX_MTU(val)		((val) << 16)
+#define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
+#define ENETC_PTXMBAR			0x0608
+/* n = TC index [0..7] */
+#define ENETC_PTCMSDUR(n)		(0x2020 + (n) * 4)
 
 #define ENETC_PM0_STATUS		0x08304
 #define ENETC_LINK_MODE			0x0000000000080000ULL
drivers/net/enetc/enetc.h +5 -0
index 56454dc9d..e494eb8b8 100644
@@ -24,6 +24,11 @@
 /* BD ALIGN */
 #define BD_ALIGN       8
 
+/* minimum frame size supported */
+#define ENETC_MAC_MINFRM_SIZE	68
+/* maximum frame size supported */
+#define ENETC_MAC_MAXFRM_SIZE	9600
+
 /*
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
drivers/net/enetc/enetc_ethdev.c +78 -8

116 lines not on this page · raw message

Signature · 1 line
2.19.1
#57 lore raw

PATCH v4 10/13 net/enetc: enable Rx-Tx queue start/stop feature

In reply to Gagandeep Singh

Rx and Tx queue start-stop and deferred queue start features enabled.

---
 doc/guides/nics/enetc.rst          |   2 +
 doc/guides/nics/features/enetc.ini |   1 +
 drivers/net/enetc/enetc_ethdev.c   | 185 ++++++++++++++++++++---------
 3 files changed, 134 insertions(+), 54 deletions(-)
doc/guides/nics/enetc.rst +2 -0
index eeb07523d..26d61f67d 100644
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index 0eed2cb9b..bd901faf4 100644
@@ -11,6 +11,7 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
+Queue start/stop     = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/enetc_ethdev.c +131 -54

263 lines not on this page · raw message

Signature · 1 line
2.19.1
#58 lore raw

PATCH v4 11/13 net/enetc: enable CRC offload feature

In reply to Gagandeep Singh

CRC offload keep feature supported

---
 doc/guides/nics/enetc.rst          |  1 +
 doc/guides/nics/features/enetc.ini |  1 +
 drivers/net/enetc/base/enetc_hw.h  |  1 +
 drivers/net/enetc/enetc.h          |  1 +
 drivers/net/enetc/enetc_ethdev.c   | 20 +++++++++++++++++---
 drivers/net/enetc/enetc_rxtx.c     |  6 ++++--
 6 files changed, 25 insertions(+), 5 deletions(-)
doc/guides/nics/enetc.rst +1 -0
index 26d61f67d..26204601a 100644
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
doc/guides/nics/features/enetc.ini +1 -0
index bd901faf4..101dc0a69 100644
@@ -12,6 +12,7 @@ Allmulticast mode    = Y
 MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
+CRC offload          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +1 -0
index 2eb1df30e..261ad157a 100644
@@ -97,6 +97,7 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PM0_CMD_CFG		0x08008
 #define ENETC_PM0_TX_EN			BIT(0)
 #define ENETC_PM0_RX_EN			BIT(1)
+#define ENETC_PM0_CRC			BIT(6)
 
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
drivers/net/enetc/enetc.h +1 -0
index e494eb8b8..8c830a5c0 100644
@@ -69,6 +69,7 @@ struct enetc_bdr {
 		void *tcisr; /* Tx */
 		int next_to_alloc; /* Rx */
 	};
+	uint8_t	crc_len; /* 0 if CRC stripped, 4 otherwise */
 };
 
 /*
drivers/net/enetc/enetc_ethdev.c +17 -3
index ff9301e01..ffae8ae25 100644
@@ -162,7 +162,9 @@ enetc_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
-	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
+	dev_info->rx_offload_capa =
+		(DEV_RX_OFFLOAD_KEEP_CRC |
+		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
 static int
@@ -378,6 +380,7 @@ enetc_rx_queue_setup(struct rte_eth_dev *dev,
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
+	uint64_t rx_offloads = data->dev_conf.rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	if (nb_rx_desc > MAX_BD_COUNT)
@@ -410,6 +413,9 @@ enetc_rx_queue_setup(struct rte_eth_dev *dev,
 			       RTE_ETH_QUEUE_STATE_STOPPED;
 	}
 
+	rx_ring->crc_len = (uint8_t)((rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) ?
+				     ETHER_CRC_LEN : 0);
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -625,11 +631,11 @@ enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 static int
 enetc_dev_configure(struct rte_eth_dev *dev)
 {
-	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
-	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct enetc_hw *enetc_hw = &hw->hw;
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	uint64_t rx_offloads = eth_conf->rxmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -647,6 +653,14 @@ enetc_dev_configure(struct rte_eth_dev *dev)
 		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
+		int config;
+
+		config = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+		config |= ENETC_PM0_CRC;
+		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
+	}
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +4 -2
index 42f16cab1..4a758d25a 100644
@@ -208,8 +208,10 @@ enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
 		if (!bd_status)
 			break;
 
-		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len;
-		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len;
+		rx_swbd->buffer_addr->pkt_len = rxbd->r.buf_len -
+						rx_ring->crc_len;
+		rx_swbd->buffer_addr->data_len = rxbd->r.buf_len -
+						 rx_ring->crc_len;
 		rx_swbd->buffer_addr->hash.rss = rxbd->r.rss_hash;
 		rx_swbd->buffer_addr->ol_flags = 0;
 		enetc_dev_rx_parse(rx_swbd->buffer_addr,
Signature · 1 line
2.19.1
#59 lore raw

PATCH v4 12/13 net/enetc: enable Rx checksum offload validation

In reply to Gagandeep Singh

Checksum Validation on Rx is supported.

---
 doc/guides/nics/features/enetc.ini |   2 +
 drivers/net/enetc/base/enetc_hw.h  |   5 ++
 drivers/net/enetc/enetc_ethdev.c   |  15 +++-
 drivers/net/enetc/enetc_rxtx.c     | 107 +++++++++++++++++++++++++----
 4 files changed, 115 insertions(+), 14 deletions(-)
doc/guides/nics/features/enetc.ini +2 -0
index 101dc0a69..39a520172 100644
@@ -13,6 +13,8 @@ MTU update           = Y
 Jumbo frame          = Y
 Queue start/stop     = Y
 CRC offload          = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
drivers/net/enetc/base/enetc_hw.h +5 -0
index 261ad157a..ff2bda592 100644
@@ -99,6 +99,10 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PM0_RX_EN			BIT(1)
 #define ENETC_PM0_CRC			BIT(6)
 
+#define ENETC_PAR_PORT_CFG		0x03050
+#define L3_CKSUM			BIT(0)
+#define L4_CKSUM			BIT(1)
+
 #define ENETC_PM0_MAXFRM		0x08014
 #define ENETC_SET_TX_MTU(val)		((val) << 16)
 #define ENETC_SET_MAXFRM(val)		((val) & 0xffff)
@@ -182,6 +186,7 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_TXBD_FLAGS_F		BIT(15)
 
 /* ENETC Parsed values (Little Endian) */
+#define ENETC_PARSE_ERROR		0x8000
 #define ENETC_PKT_TYPE_ETHER            0x0060
 #define ENETC_PKT_TYPE_IPV4             0x0000
 #define ENETC_PKT_TYPE_IPV6             0x0020
drivers/net/enetc/enetc_ethdev.c +14 -1
index ffae8ae25..362e0740c 100644
@@ -163,7 +163,10 @@ enetc_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
 	dev_info->max_tx_queues = MAX_TX_RINGS;
 	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
 	dev_info->rx_offload_capa =
-		(DEV_RX_OFFLOAD_KEEP_CRC |
+		(DEV_RX_OFFLOAD_IPV4_CKSUM |
+		 DEV_RX_OFFLOAD_UDP_CKSUM |
+		 DEV_RX_OFFLOAD_TCP_CKSUM |
+		 DEV_RX_OFFLOAD_KEEP_CRC |
 		 DEV_RX_OFFLOAD_JUMBO_FRAME);
 }
 
@@ -636,6 +639,7 @@ enetc_dev_configure(struct rte_eth_dev *dev)
 	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
 	uint64_t rx_offloads = eth_conf->rxmode.offloads;
+	uint32_t checksum = L3_CKSUM | L4_CKSUM;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -661,6 +665,15 @@ enetc_dev_configure(struct rte_eth_dev *dev)
 		enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config);
 	}
 
+	if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM)
+		checksum &= ~L3_CKSUM;
+
+	if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM))
+		checksum &= ~L4_CKSUM;
+
+	enetc_port_wr(enetc_hw, ENETC_PAR_PORT_CFG, checksum);
+
+
 	return 0;
 }
 
drivers/net/enetc/enetc_rxtx.c +94 -13

163 lines not on this page · raw message

Signature · 1 line
2.19.1
#60 lore raw

PATCH v4 13/13 net/enetc: fix crash at high speed traffic

In reply to Gagandeep Singh

On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue.

Fixes 469c6111a799 ("net/enetc: enable Rx and Tx")
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/enetc/enetc_rxtx.c +6 -1
index 0ce7dbee7..81b0ef3b1 100644
@@ -49,11 +49,16 @@ enetc_xmit_pkts(void *tx_queue,
 		uint16_t nb_pkts)
 {
 	struct enetc_swbd *tx_swbd;
-	int i, start;
+	int i, start, bds_to_use;
 	struct enetc_tx_bd *txbd;
 	struct enetc_bdr *tx_ring = (struct enetc_bdr *)tx_queue;
 
 	i = tx_ring->next_to_use;
+
+	bds_to_use = enetc_bd_unused(tx_ring);
+	if (bds_to_use < nb_pkts)
+		nb_pkts = bds_to_use;
+
 	start = 0;
 	while (nb_pkts--) {
 		enetc_clean_tx_ring(tx_ring);
Signature · 1 line
2.19.1
#61 lore raw
In reply to Gagandeep Singh
Quoted 16 lines · Gagandeep Singh

*V1 log:
* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation, basic stats
* some bug fixes

V2 change-log:
* remove unneeded code from stats get
* fix big endian compilation

v3 change-log:
* commit message updated for 03/13 patch
* add stable to Cc for fixes

v4 change-log:
* Removed checkpatch errors for CRLF

Quoted 14 lines

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: fix big endian build and correct buffer allocation net/enetc: set interface mode for SXGMII
net/enetc: add basic statistics
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

Series applied to dpdk-next-net/master, thanks.

#62 lore raw
Quoted 32 lines · Ferruh Yigit
Quoted 16 lines · Gagandeep Singh

*V1 log:
* support added for MTU, jumbo frame, queue start/stop, promiscuous, multicast, crc offload, RX checksum validation, basic stats
* some bug fixes

V2 change-log:
* remove unneeded code from stats get
* fix big endian compilation

v3 change-log:
* commit message updated for 03/13 patch
* add stable to Cc for fixes

v4 change-log:
* Removed checkpatch errors for CRLF

Quoted 14 lines

Gagandeep Singh (13):
net/enetc: support physical addressing mode net/enetc: fix SMMU unhandled context fault net/enetc: fix big endian build and correct buffer allocation net/enetc: set interface mode for SXGMII
net/enetc: add basic statistics
net/enetc: replace register read/write macros with functions net/enetc: remove forward declarations
net/enetc: enable promiscuous and allmulticast feature net/enetc: add MTU update and jumbo frames support net/enetc: enable Rx-Tx queue start/stop feature net/enetc: enable CRC offload feature
net/enetc: enable Rx checksum offload validation net/enetc: fix crash at high speed traffic

Quoted 2 lines

Series applied to dpdk-next-net/master, thanks.

Hi Gagandeep,

Can you please send a release notes update to document the update in the PMD, I can squash into the patchset if it comes in time.

Thanks,
ferruh