DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes
@ 2019-04-08 11:22 Gagandeep Singh
  2019-04-08 11:22 ` Gagandeep Singh
                   ` (14 more replies)
  0 siblings, 15 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

* 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(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode Gagandeep Singh
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

* 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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-08 11:22 ` Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 13:16   ` Ferruh Yigit
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
                   ` (12 subsequent siblings)
  14 siblings, 2 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 13:16   ` Ferruh Yigit
  1 sibling, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (2 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..90d6979 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..90d6979 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (3 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs Gagandeep Singh
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (4 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:35   ` David Marchand
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
                   ` (8 subsequent siblings)
  14 siblings, 2 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Add basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..99c2ce7 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,47 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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));
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:35   ` David Marchand
  1 sibling, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Add basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..99c2ce7 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,47 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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));
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (5 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations Gagandeep Singh
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 99c2ce7..d403d7a 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 99c2ce7..d403d7a 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (6 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d403d7a..f8b9510 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d403d7a..f8b9510 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (7 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f8b9510..0bb3b2c 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -544,6 +534,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -562,6 +620,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f8b9510..0bb3b2c 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -544,6 +534,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -562,6 +620,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (8 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 0bb3b2c..4428678 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -602,6 +596,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -625,6 +689,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -679,6 +744,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 0bb3b2c..4428678 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -602,6 +596,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -625,6 +689,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -679,6 +744,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (9 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 4428678..db23276 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -666,6 +655,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -691,8 +764,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 4428678..db23276 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -666,6 +655,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -691,8 +764,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (10 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index db23276..a59a030 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 90d6979..7497a47 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index db23276..a59a030 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 90d6979..7497a47 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (11 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a59a030..6b49fd4 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 7497a47..ed39665 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -114,69 +114,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a59a030..6b49fd4 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 7497a47..ed39665 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -114,69 +114,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (12 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-08 11:22 ` Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index ed39665..baf5d27 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-08 11:22   ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-08 11:22 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index ed39665..baf5d27 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
@ 2019-04-08 11:35   ` David Marchand
  2019-04-08 11:35     ` David Marchand
  2019-04-10 11:18     ` [dpdk-dev] [EXT] " Gagandeep Singh
  1 sibling, 2 replies; 128+ messages in thread
From: David Marchand @ 2019-04-08 11:35 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev, ferruh.yigit

On Mon, Apr 8, 2019 at 1:23 PM Gagandeep Singh <G.Singh@nxp.com> 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


-- 
David Marchand

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-08 11:35   ` David Marchand
@ 2019-04-08 11:35     ` David Marchand
  2019-04-10 11:18     ` [dpdk-dev] [EXT] " Gagandeep Singh
  1 sibling, 0 replies; 128+ messages in thread
From: David Marchand @ 2019-04-08 11:35 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev, ferruh.yigit

On Mon, Apr 8, 2019 at 1:23 PM Gagandeep Singh <G.Singh@nxp.com> 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


-- 
David Marchand

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode Gagandeep Singh
  2019-04-08 11:22   ` Gagandeep Singh
@ 2019-04-08 13:16   ` Ferruh Yigit
  2019-04-08 13:16     ` Ferruh Yigit
  1 sibling, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-08 13:16 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/8/2019 12:22 PM, Gagandeep Singh wrote:
> Support added for physical addressing mode and
> change driver flags to don't care.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode
  2019-04-08 13:16   ` Ferruh Yigit
@ 2019-04-08 13:16     ` Ferruh Yigit
  0 siblings, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-08 13:16 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/8/2019 12:22 PM, Gagandeep Singh wrote:
> Support added for physical addressing mode and
> change driver flags to don't care.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

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


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [EXT] Re: [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-08 11:35   ` David Marchand
  2019-04-08 11:35     ` David Marchand
@ 2019-04-10 11:18     ` Gagandeep Singh
  2019-04-10 11:18       ` Gagandeep Singh
  1 sibling, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-10 11:18 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, ferruh.yigit

Hi David,

I will incorporate your comments in v2.

Thanks,
Gagan

From: David Marchand <david.marchand@redhat.com>
Sent: Monday, April 8, 2019 5:06 PM
To: Gagandeep Singh <G.Singh@nxp.com>
Cc: dev@dpdk.org; ferruh.yigit@intel.com
Subject: [EXT] Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs


On Mon, Apr 8, 2019 at 1:23 PM Gagandeep Singh <G.Singh@nxp.com<mailto:G.Singh@nxp.com>> 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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [EXT] Re: [PATCH 05/13] net/enetc: add statistics APIs
  2019-04-10 11:18     ` [dpdk-dev] [EXT] " Gagandeep Singh
@ 2019-04-10 11:18       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-10 11:18 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, ferruh.yigit

Hi David,

I will incorporate your comments in v2.

Thanks,
Gagan

From: David Marchand <david.marchand@redhat.com>
Sent: Monday, April 8, 2019 5:06 PM
To: Gagandeep Singh <G.Singh@nxp.com>
Cc: dev@dpdk.org; ferruh.yigit@intel.com
Subject: [EXT] Re: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs


On Mon, Apr 8, 2019 at 1:23 PM Gagandeep Singh <G.Singh@nxp.com<mailto:G.Singh@nxp.com>> 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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes
  2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                   ` (13 preceding siblings ...)
  2019-04-08 11:22 ` [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12  7:04 ` Gagandeep Singh
  2019-04-12  7:04   ` Gagandeep Singh
                     ` (14 more replies)
  14 siblings, 15 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode Gagandeep Singh
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12  7:04   ` Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
                     ` (12 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
                     ` (11 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (2 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  8:37     ` Thomas Monjalon
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
                     ` (10 subsequent siblings)
  14 siblings, 2 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..42f16ca 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  8:37     ` Thomas Monjalon
  1 sibling, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..42f16ca 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (3 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics Gagandeep Singh
                     ` (9 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (4 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
                     ` (8 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..10b2b39 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,42 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..10b2b39 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,42 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (5 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations Gagandeep Singh
                     ` (7 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b39..2d8c4e6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b39..2d8c4e6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (6 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
                     ` (6 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e6..d0f9e2b 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e6..d0f9e2b 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (7 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
                     ` (5 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b..a7dddc5 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b..a7dddc5 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (8 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
                     ` (4 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5..66cbf74 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5..66cbf74 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (9 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
                     ` (3 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74..ff9301e 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74..ff9301e 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (10 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
                     ` (2 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e..ffae8ae 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16ca..4a758d2 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e..ffae8ae 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16ca..4a758d2 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (11 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae..362e074 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d2..0ce7dbe 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae..362e074 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d2..0ce7dbe 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (12 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12  7:04   ` Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbe..81b0ef3 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12  7:04     ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  7:04 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: thomas, 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")
Cc: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbe..81b0ef3 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
  2019-04-12  7:04     ` Gagandeep Singh
@ 2019-04-12  8:37     ` Thomas Monjalon
  2019-04-12  8:37       ` Thomas Monjalon
  2019-04-12  8:50       ` [dpdk-dev] [EXT] " Gagandeep Singh
  1 sibling, 2 replies; 128+ messages in thread
From: Thomas Monjalon @ 2019-04-12  8:37 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev, ferruh.yigit

12/04/2019 09:04, 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")
> Cc: g.singh@nxp.com

You should mention it is also fixing big endian compilation.

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  8:37     ` Thomas Monjalon
@ 2019-04-12  8:37       ` Thomas Monjalon
  2019-04-12  8:50       ` [dpdk-dev] [EXT] " Gagandeep Singh
  1 sibling, 0 replies; 128+ messages in thread
From: Thomas Monjalon @ 2019-04-12  8:37 UTC (permalink / raw)
  To: Gagandeep Singh; +Cc: dev, ferruh.yigit

12/04/2019 09:04, 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")
> Cc: g.singh@nxp.com

You should mention it is also fixing big endian compilation.




^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [EXT] Re: [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  8:37     ` Thomas Monjalon
  2019-04-12  8:37       ` Thomas Monjalon
@ 2019-04-12  8:50       ` Gagandeep Singh
  2019-04-12  8:50         ` Gagandeep Singh
  1 sibling, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  8:50 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, ferruh.yigit



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, April 12, 2019 2:08 PM
> To: Gagandeep Singh <G.Singh@nxp.com>
> Cc: dev@dpdk.org; ferruh.yigit@intel.com> 
> 
> 12/04/2019 09:04, 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")
> > Cc: g.singh@nxp.com
> 
> You should mention it is also fixing big endian compilation.
> 
> 
Ok, I'll do that.

Thanks,
Gagandeep Singh

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [EXT] Re: [PATCH v2 03/13] net/enetc: use correct buffer allocation API
  2019-04-12  8:50       ` [dpdk-dev] [EXT] " Gagandeep Singh
@ 2019-04-12  8:50         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12  8:50 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, ferruh.yigit



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, April 12, 2019 2:08 PM
> To: Gagandeep Singh <G.Singh@nxp.com>
> Cc: dev@dpdk.org; ferruh.yigit@intel.com> 
> 
> 12/04/2019 09:04, 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")
> > Cc: g.singh@nxp.com
> 
> You should mention it is also fixing big endian compilation.
> 
> 
Ok, I'll do that.

Thanks,
Gagandeep Singh


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes
  2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                     ` (13 preceding siblings ...)
  2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12 11:01   ` Gagandeep Singh
  2019-04-12 11:01     ` Gagandeep Singh
                       ` (14 more replies)
  14 siblings, 15 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode Gagandeep Singh
                       ` (13 subsequent siblings)
  14 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12 11:01     ` Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
                       ` (12 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe75..7a9a97d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e243..a31a387 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
                       ` (11 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97d..f1807b9 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (2 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
                       ` (10 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, thomas, stable

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")
Cc: thomas@monjalon.net
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..42f16ca 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, thomas, stable

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")
Cc: thomas@monjalon.net
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a387..42f16ca 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (3 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics Gagandeep Singh
                       ` (9 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11..e3738a6 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b9..91e9692 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (4 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
                       ` (8 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..10b2b39 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,42 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf2..9f575d2 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2..d8bd567 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a6..3f0a2a9 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692..10b2b39 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	.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,
@@ -608,6 +613,42 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (5 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations Gagandeep Singh
                       ` (7 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b39..2d8c4e6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +----
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c..56454dc 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b39..2d8c4e6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev,
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (6 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
                       ` (6 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e6..d0f9e2b 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++++++---------------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e6..d0f9e2b 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (7 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
                       ` (5 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b..a7dddc5 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d2..ab13211 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd567..6b7bbfb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9..90a383a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b..a7dddc5 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (8 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
                       ` (4 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5..66cbf74 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211..eeb0752 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb..0eed2cb 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a..2eb1df3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc..e494eb8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5..66cbf74 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -11,13 +11,6 @@
 int enetc_logtype_pmd;
 
 static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
-static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
@@ -168,7 +161,8 @@
 	};
 	dev_info->max_rx_queues = MAX_RX_RINGS;
 	dev_info->max_tx_queues = MAX_TX_RINGS;
-	dev_info->max_rx_pktlen = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (9 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
                       ` (3 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74..ff9301e 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb0752..26d61f6 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb..bd901fa 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74..ff9301e 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@
 	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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ int enetc_stats_get(struct rte_eth_dev *dev,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (10 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
                       ` (2 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e..ffae8ae 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16ca..4a758d2 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f6..2620460 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901fa..101dc0a 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df3..261ad15 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8..8c830a5 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e..ffae8ae 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16ca..4a758d2 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (11 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae..362e074 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d2..0ce7dbe 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a..39a5201 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad15..ff2bda5 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae..362e074 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d2..0ce7dbe 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (12 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12 11:01     ` Gagandeep Singh
  2019-04-12 11:01       ` Gagandeep Singh
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbe..81b0ef3 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12 11:01       ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 11:01 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbe..81b0ef3 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                       ` (13 preceding siblings ...)
  2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12 12:28     ` Gagandeep Singh
  2019-04-12 12:28       ` Gagandeep Singh
                         ` (14 more replies)
  14 siblings, 15 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode Gagandeep Singh
                         ` (13 subsequent siblings)
  14 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: 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(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12 12:28       ` Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28         ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
                         ` (12 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe7517..7a9a97deb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e2430d..a31a38725 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12 12:28         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 22 ++++++++++++----------
 drivers/net/enetc/enetc_rxtx.c   |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 023fe7517..7a9a97deb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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,
 };
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 631e2430d..a31a38725 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
  2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28         ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
                         ` (11 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97deb..f1807b901 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12 12:28         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

First configure ring with BDs properly then enable
the ring.

Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 7a9a97deb..f1807b901 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (2 preceding siblings ...)
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28         ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
                         ` (10 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a38725..42f16cab1 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
@ 2019-04-12 12:28         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index a31a38725..42f16cab1 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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;
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (3 preceding siblings ...)
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28         ` Gagandeep Singh
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics Gagandeep Singh
                         ` (9 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11e0..e3738a695 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b901..91e9692d6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12 12:28         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/base/enetc_hw.h | 13 ++++++++++++-
 drivers/net/enetc/enetc_ethdev.c  | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index f36fa11e0..e3738a695 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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))
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index f1807b901..91e9692d6 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (4 preceding siblings ...)
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
@ 2019-04-12 12:28       ` Gagandeep Singh
  2019-04-12 12:28         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
                         ` (8 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf205..9f575d27f 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2a1..d8bd5679d 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a695..3f0a2a9a3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692d6..10b2b396d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static const struct eth_dev_ops enetc_ops = {
 	.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,
@@ -608,6 +613,42 @@ enetc_rx_queue_release(void *rxq)
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12 12:28         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:28 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable basic statistics APIs enetc_stats_get
and enetc_stats_reset.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 8038bf205..9f575d27f 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -46,6 +46,7 @@ ENETC Features
 
 - Link Status
 - Packet type information
+- Basic stats
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 69476a2a1..d8bd5679d 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -6,6 +6,7 @@
 [Features]
 Packet type parsing  = Y
 Link status          = Y
+Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index e3738a695..3f0a2a9a3 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
 
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 91e9692d6..10b2b396d 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_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
@@ -46,6 +49,8 @@ static const struct eth_dev_ops enetc_ops = {
 	.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,
@@ -608,6 +613,42 @@ enetc_rx_queue_release(void *rxq)
 	rte_free(rx_ring);
 }
 
+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;
+
+	/* Total received packets, bad + good, if we want to get counters of
+	 * only good received packets then use ENETC_PM0_RFRM,
+	 * ENETC_PM0_TFRM registers.
+	 */
+	stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT);
+	stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT);
+	stats->ibytes =  enetc_port_rd(enetc_hw, ENETC_PM0_REOCT);
+	stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT);
+	/* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without
+	 * truncated packets
+	 */
+	stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP);
+	stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR);
+	stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR);
+
+	return 0;
+}
+
+static void
+enetc_stats_reset(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+
+	enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS);
+}
+
 static int
 enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			   struct rte_pci_device *pci_dev)
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (5 preceding siblings ...)
  2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations Gagandeep Singh
                         ` (7 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +---
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++----------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c5b..56454dc9d 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b396d..2d8c4e604 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ enetc_dev_stop(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc.h        |  7 +---
 drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++----------------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 0e80d1c5b..56454dc9d 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
  */
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 10b2b396d..2d8c4e604 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -131,28 +131,31 @@ enetc_dev_start(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
 
 	/* Enable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val | ENETC_PMR_EN);
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, 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_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) {
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_RGAUTO);
 	}
-	if (enetc_global_rd(&hw->hw,
+	if (enetc_global_rd(enetc_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);
+		enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
+		enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE,
+			      ENETC_PM0_IFM_XGMII);
 	}
 
 	return 0;
@@ -163,18 +166,17 @@ enetc_dev_stop(struct rte_eth_dev *dev)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	uint32_t val;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Disable port */
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR),
-			val & (~ENETC_PMR_EN));
-
-	val = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-			     ENETC_PM0_CMD_CFG));
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG),
-			val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
+	val = enetc_port_rd(enetc_hw, ENETC_PMR);
+	enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN));
+
+	val = enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG);
+	enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG,
+		      val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN)));
 }
 
 static void
@@ -221,6 +223,7 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 {
 	struct enetc_eth_hw *hw =
 		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
 	struct rte_eth_link link;
 	uint32_t status;
 
@@ -228,8 +231,7 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 
 	memset(&link, 0, sizeof(link));
 
-	status = ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port,
-				ENETC_PM0_STATUS));
+	status = enetc_port_rd(enetc_hw, ENETC_PM0_STATUS);
 
 	if (status & ENETC_LINK_MODE)
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
@@ -262,6 +264,7 @@ static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
 	uint32_t psipmr = 0;
+	struct enetc_hw *enetc_hw = &hw->hw;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -269,8 +272,7 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
 	/* Enabling Station Interface */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR),
-					  ENETC_SIMR_EN);
+	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
 	/* Setting to accept broadcast packets for each inetrface */
 	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
@@ -280,14 +282,11 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
 		  ENETC_PSIPMR_SET_VLAN_MP(2);
 
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR),
-			psipmr);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 
 	/* Enabling broadcast address */
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)),
-			0xFFFFFFFF);
-	ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)),
-			0xFFFF << 16);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
+	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
 
 	return 0;
 }
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (6 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
                         ` (6 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++-----------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e604..d0f9e2b35 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Remove unneeded forward declarations and re-order the code.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++-----------------
 1 file changed, 107 insertions(+), 130 deletions(-)

diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 2d8c4e604..d0f9e2b35 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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)
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (7 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
                         ` (5 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d27f..ab13211a5 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd5679d..6b7bbfb3d 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9a3..90a383a8b 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b35..a7dddc5cb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ enetc_dev_close(struct rte_eth_dev *dev)
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ static const struct eth_dev_ops enetc_ops = {
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Promiscuous and allmulticast enable/disable APIs added.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 9f575d27f..ab13211a5 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -47,6 +47,8 @@ ENETC Features
 - Link Status
 - Packet type information
 - Basic stats
+- Promiscuous
+- Multicast
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index d8bd5679d..6b7bbfb3d 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 3f0a2a9a3..90a383a8b 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index d0f9e2b35..a7dddc5cb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -133,8 +133,8 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 static int
 enetc_hardware_init(struct enetc_eth_hw *hw)
 {
-	uint32_t psipmr = 0;
 	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t *mac = (uint32_t *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 	/* Calculating and storing the base HW addresses */
@@ -144,19 +144,9 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
 	/* Enabling Station Interface */
 	enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
-	/* Setting to accept broadcast packets for each inetrface */
-	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) |
-		  ENETC_PSIPMR_SET_VLAN_MP(0);
-	psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) |
-		  ENETC_PSIPMR_SET_VLAN_MP(1);
-	psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) |
-		  ENETC_PSIPMR_SET_VLAN_MP(2);
-
-	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
-
-	/* Enabling broadcast address */
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF);
-	enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16);
+	*mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0));
+	mac++;
+	*mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0));
 
 	return 0;
 }
@@ -539,6 +529,74 @@ enetc_dev_close(struct rte_eth_dev *dev)
 	dev->data->nb_tx_queues = 0;
 }
 
+static void
+enetc_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable promiscuous mode*/
+	psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	/* Setting to disable promiscuous mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+	psipmr &= (~ENETC_PSIPMR_SET_UP(0));
+
+	if (dev->data->all_multicast == 0)
+		psipmr &= (~ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR);
+
+	/* Setting to enable allmulticast mode for SI0*/
+	psipmr |= ENETC_PSIPMR_SET_MP(0);
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
+static void
+enetc_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t psipmr = 0;
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	/* Setting to disable all multicast mode for SI0*/
+	psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) &
+			       ~(ENETC_PSIPMR_SET_MP(0));
+
+	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -557,6 +615,10 @@ static const struct eth_dev_ops enetc_ops = {
 	.link_update          = enetc_link_update,
 	.stats_get            = enetc_stats_get,
 	.stats_reset          = enetc_stats_reset,
+	.promiscuous_enable   = enetc_promiscuous_enable,
+	.promiscuous_disable  = enetc_promiscuous_disable,
+	.allmulticast_enable  = enetc_allmulticast_enable,
+	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (8 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
                         ` (4 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211a5..eeb07523d 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb3d..0eed2cb9b 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a8b..2eb1df30e 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc9d..e494eb8b8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5cb..66cbf74d0 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,13 +10,6 @@
 
 int enetc_logtype_pmd;
 
-static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -168,7 +161,8 @@ 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 = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ enetc_allmulticast_disable(struct rte_eth_dev *dev)
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ static const struct eth_dev_ops enetc_ops = {
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ enetc_dev_init(struct rte_eth_dev *eth_dev)
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Enable the jumbo frames and mtu update feature.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index ab13211a5..eeb07523d 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -49,6 +49,7 @@ ENETC Features
 - Basic stats
 - Promiscuous
 - Multicast
+- Jumbo packets
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 6b7bbfb3d..0eed2cb9b 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 90a383a8b..2eb1df30e 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 56454dc9d..e494eb8b8 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index a7dddc5cb..66cbf74d0 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,13 +10,6 @@
 
 int enetc_logtype_pmd;
 
-static int
-enetc_dev_configure(struct rte_eth_dev *dev __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return 0;
-}
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -168,7 +161,8 @@ 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 = 1500;
+	dev_info->max_rx_pktlen = ENETC_MAC_MAXFRM_SIZE;
+	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
 }
 
 static int
@@ -597,6 +591,76 @@ enetc_allmulticast_disable(struct rte_eth_dev *dev)
 	enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr);
 }
 
+static int
+enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct enetc_eth_hw *hw =
+		ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct enetc_hw *enetc_hw = &hw->hw;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	/* check that mtu is within the allowed range */
+	if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE)
+		return -EINVAL;
+
+	/*
+	 * Refuse mtu that requires the support of scattered packets
+	 * when this feature has not been enabled before.
+	 */
+	if (dev->data->min_rx_buf_size &&
+		!dev->data->scattered_rx && frame_size >
+		dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
+		ENETC_PMD_ERR("SG not enabled, will not fit in one buffer");
+		return -EINVAL;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.offloads &=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev->data->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE);
+	enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE);
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	/*setting the MTU*/
+	enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) |
+		      ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE));
+
+	return 0;
+}
+
+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;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		uint32_t max_len;
+
+		max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+
+		enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM,
+			      ENETC_SET_MAXFRM(max_len));
+		enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0),
+			      ENETC_MAC_MAXFRM_SIZE);
+		enetc_port_wr(enetc_hw, ENETC_PTXMBAR,
+			      2 * ENETC_MAC_MAXFRM_SIZE);
+		dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -620,6 +684,7 @@ static const struct eth_dev_ops enetc_ops = {
 	.allmulticast_enable  = enetc_allmulticast_enable,
 	.allmulticast_disable = enetc_allmulticast_disable,
 	.dev_infos_get        = enetc_dev_infos_get,
+	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
@@ -674,6 +739,11 @@ enetc_dev_init(struct rte_eth_dev *eth_dev)
 	ether_addr_copy((struct ether_addr *)hw->mac.addr,
 			&eth_dev->data->mac_addrs[0]);
 
+	/* Set MTU */
+	enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM,
+		      ENETC_SET_MAXFRM(ETHER_MAX_LEN));
+	eth_dev->data->mtu = ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	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);
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (9 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
                         ` (3 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb07523d..26d61f67d 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb9b..bd901faf4 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74d0..ff9301e01 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@ static void
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@ enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@ enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@ enetc_alloc_tx_resources(struct rte_eth_dev *dev,
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@ enetc_alloc_tx_resources(struct rte_eth_dev *dev,
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@ enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@ enetc_alloc_rx_resources(struct rte_eth_dev *dev,
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@ enetc_alloc_rx_resources(struct rte_eth_dev *dev,
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ enetc_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ static const struct eth_dev_ops enetc_ops = {
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

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

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index eeb07523d..26d61f67d 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -50,6 +50,8 @@ ENETC Features
 - Promiscuous
 - Multicast
 - Jumbo packets
+- Queue Start/Stop
+- Deferred Queue Start
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 0eed2cb9b..bd901faf4 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 66cbf74d0..ff9301e01 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -203,7 +203,6 @@ static void
 enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 {
 	int idx = tx_ring->index;
-	uint32_t tbmr;
 	phys_addr_t bd_address;
 
 	bd_address = (phys_addr_t)
@@ -215,9 +214,6 @@ enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 	enetc_txbdr_wr(hw, idx, ENETC_TBLENR,
 		       ENETC_RTBLENR_LEN(tx_ring->bd_count));
 
-	tbmr = ENETC_TBMR_EN;
-	/* enable ring */
-	enetc_txbdr_wr(hw, idx, ENETC_TBMR, tbmr);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0);
 	enetc_txbdr_wr(hw, idx, ENETC_TBCISR, 0);
 	tx_ring->tcir = (void *)((size_t)hw->reg +
@@ -227,16 +223,22 @@ enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
 }
 
 static int
-enetc_alloc_tx_resources(struct rte_eth_dev *dev,
-			 uint16_t queue_idx,
-			 uint16_t nb_desc)
+enetc_tx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t queue_idx,
+		     uint16_t nb_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_txconf *tx_conf)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *tx_ring;
 	struct rte_eth_dev_data *data = dev->data;
 	struct enetc_eth_adapter *priv =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_desc > MAX_BD_COUNT)
+		return -1;
+
 	tx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (tx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate TX ring memory");
@@ -253,6 +255,17 @@ enetc_alloc_tx_resources(struct rte_eth_dev *dev,
 	enetc_setup_txbdr(&priv->hw.hw, tx_ring);
 	data->tx_queues[queue_idx] = tx_ring;
 
+	if (!tx_conf->tx_deferred_start) {
+		/* enable ring */
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index,
+			       ENETC_TBMR, ENETC_TBMR_EN);
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->tx_queue_state[tx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(tx_ring);
@@ -260,24 +273,6 @@ enetc_alloc_tx_resources(struct rte_eth_dev *dev,
 	return err;
 }
 
-static int
-enetc_tx_queue_setup(struct rte_eth_dev *dev,
-		     uint16_t queue_idx,
-		     uint16_t nb_desc,
-		     unsigned int socket_id __rte_unused,
-		     const struct rte_eth_txconf *tx_conf __rte_unused)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_tx_resources(dev, queue_idx, nb_desc);
-
-	return err;
-}
-
 static void
 enetc_tx_queue_release(void *txq)
 {
@@ -367,23 +362,27 @@ enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *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
-enetc_alloc_rx_resources(struct rte_eth_dev *dev,
-			 uint16_t rx_queue_id,
-			 uint16_t nb_rx_desc,
-			 struct rte_mempool *mb_pool)
+enetc_rx_queue_setup(struct rte_eth_dev *dev,
+		     uint16_t rx_queue_id,
+		     uint16_t nb_rx_desc,
+		     unsigned int socket_id __rte_unused,
+		     const struct rte_eth_rxconf *rx_conf,
+		     struct rte_mempool *mb_pool)
 {
-	int err;
+	int err = 0;
 	struct enetc_bdr *rx_ring;
 	struct rte_eth_dev_data *data =  dev->data;
 	struct enetc_eth_adapter *adapter =
 			ENETC_DEV_PRIVATE(data->dev_private);
 
+	PMD_INIT_FUNC_TRACE();
+	if (nb_rx_desc > MAX_BD_COUNT)
+		return -1;
+
 	rx_ring = rte_zmalloc(NULL, sizeof(struct enetc_bdr), 0);
 	if (rx_ring == NULL) {
 		ENETC_PMD_ERR("Failed to allocate RX ring memory");
@@ -400,6 +399,17 @@ enetc_alloc_rx_resources(struct rte_eth_dev *dev,
 	enetc_setup_rxbdr(&adapter->hw.hw, rx_ring, mb_pool);
 	data->rx_queues[rx_queue_id] = rx_ring;
 
+	if (!rx_conf->rx_deferred_start) {
+		/* enable ring */
+		enetc_rxbdr_wr(&adapter->hw.hw, rx_ring->index, ENETC_RBMR,
+			       ENETC_RBMR_EN);
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STARTED;
+	} else {
+		dev->data->rx_queue_state[rx_ring->index] =
+			       RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 fail:
 	rte_free(rx_ring);
@@ -407,27 +417,6 @@ enetc_alloc_rx_resources(struct rte_eth_dev *dev,
 	return err;
 }
 
-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 __rte_unused,
-		     const struct rte_eth_rxconf *rx_conf __rte_unused,
-		     struct rte_mempool *mb_pool)
-{
-	int err = 0;
-
-	PMD_INIT_FUNC_TRACE();
-	if (nb_rx_desc > MAX_BD_COUNT)
-		return -1;
-
-	err = enetc_alloc_rx_resources(dev, rx_queue_id,
-				       nb_rx_desc,
-				       mb_pool);
-
-	return err;
-}
-
 static void
 enetc_rx_queue_release(void *rxq)
 {
@@ -661,6 +650,90 @@ enetc_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+enetc_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data | ENETC_RBMR_EN;
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *rx_ring;
+	uint32_t rx_data;
+
+	rx_ring = dev->data->rx_queues[qidx];
+	if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		rx_data = enetc_rxbdr_rd(&priv->hw.hw, rx_ring->index,
+					 ENETC_RBMR);
+		rx_data = rx_data & (~ENETC_RBMR_EN);
+		enetc_rxbdr_wr(&priv->hw.hw, rx_ring->index, ENETC_RBMR,
+			       rx_data);
+		dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data | ENETC_TBMR_EN;
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
+	return 0;
+}
+
+static int
+enetc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+	struct enetc_eth_adapter *priv =
+			ENETC_DEV_PRIVATE(dev->data->dev_private);
+	struct enetc_bdr *tx_ring;
+	uint32_t tx_data;
+
+	tx_ring = dev->data->tx_queues[qidx];
+	if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) {
+		tx_data = enetc_txbdr_rd(&priv->hw.hw, tx_ring->index,
+					 ENETC_TBMR);
+		tx_data = tx_data & (~ENETC_TBMR_EN);
+		enetc_txbdr_wr(&priv->hw.hw, tx_ring->index, ENETC_TBMR,
+			       tx_data);
+		dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return 0;
+}
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -686,8 +759,12 @@ static const struct eth_dev_ops enetc_ops = {
 	.dev_infos_get        = enetc_dev_infos_get,
 	.mtu_set              = enetc_mtu_set,
 	.rx_queue_setup       = enetc_rx_queue_setup,
+	.rx_queue_start       = enetc_rx_queue_start,
+	.rx_queue_stop        = enetc_rx_queue_stop,
 	.rx_queue_release     = enetc_rx_queue_release,
 	.tx_queue_setup       = enetc_tx_queue_setup,
+	.tx_queue_start       = enetc_tx_queue_start,
+	.tx_queue_stop        = enetc_tx_queue_stop,
 	.tx_queue_release     = enetc_tx_queue_release,
 	.dev_supported_ptypes_get = enetc_supported_ptypes_get,
 };
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (10 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
                         ` (2 subsequent siblings)
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f67d..26204601a 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901faf4..101dc0a69 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df30e..261ad157a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8b8..8c830a5c0 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e01..ffae8ae25 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16cab1..4a758d25a 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

CRC offload keep feature supported

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst
index 26d61f67d..26204601a 100644
--- a/doc/guides/nics/enetc.rst
+++ b/doc/guides/nics/enetc.rst
@@ -52,6 +52,7 @@ ENETC Features
 - Jumbo packets
 - Queue Start/Stop
 - Deferred Queue Start
+- CRC offload
 
 NIC Driver (PMD)
 ~~~~~~~~~~~~~~~~
diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index bd901faf4..101dc0a69 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 2eb1df30e..261ad157a 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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)
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index e494eb8b8..8c830a5c0 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -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 */
 };
 
 /*
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ff9301e01..ffae8ae25 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 42f16cab1..4a758d25a 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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,
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (11 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
  2019-04-16  7:41       ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Ferruh Yigit
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a69..39a520172 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad157a..ff2bda592 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae25..362e0740c 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d25a..0ce7dbee7 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh

Checksum Validation on Rx is supported.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 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(-)

diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini
index 101dc0a69..39a520172 100644
--- a/doc/guides/nics/features/enetc.ini
+++ b/doc/guides/nics/features/enetc.ini
@@ -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
diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h
index 261ad157a..ff2bda592 100644
--- a/drivers/net/enetc/base/enetc_hw.h
+++ b/drivers/net/enetc/base/enetc_hw.h
@@ -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
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index ffae8ae25..362e0740c 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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;
 }
 
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 4a758d25a..0ce7dbee7 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -115,69 +115,150 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 	return j;
 }
 
+static inline void enetc_slow_parsing(struct rte_mbuf *m,
+				     uint64_t parse_results)
+{
+	m->ol_flags &= ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD);
+
+	switch (parse_results) {
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6;
+		m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_TCP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_UDP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_SCTP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV4 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+				 RTE_PTYPE_L3_IPV6 |
+				 RTE_PTYPE_L4_ICMP;
+		m->ol_flags |= PKT_RX_IP_CKSUM_GOOD |
+			       PKT_RX_L4_CKSUM_BAD;
+		return;
+	/* More switch cases can be added */
+	default:
+		m->packet_type = RTE_PTYPE_UNKNOWN;
+		m->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN |
+			       PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 
 static inline void __attribute__((hot))
 enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results)
 {
 	ENETC_PMD_DP_DEBUG("parse summary = 0x%x   ", parse_results);
+	m->ol_flags |= PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD;
 
-	m->packet_type = RTE_PTYPE_UNKNOWN;
 	switch (parse_results) {
 	case ENETC_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_TCP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_TCP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_UDP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_SCTP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_SCTP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV4_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV4 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	case ENETC_PKT_TYPE_IPV6_ICMP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 				 RTE_PTYPE_L3_IPV6 |
 				 RTE_PTYPE_L4_ICMP;
-		break;
+		return;
 	/* More switch cases can be added */
 	default:
-		m->packet_type = RTE_PTYPE_UNKNOWN;
+		enetc_slow_parsing(m, parse_results);
 	}
+
 }
 
 static int
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (12 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
@ 2019-04-12 12:29       ` Gagandeep Singh
  2019-04-12 12:29         ` Gagandeep Singh
  2019-04-16  7:41       ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Ferruh Yigit
  14 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbee7..81b0ef3b1 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-12 12:29         ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-12 12:29 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: Gagandeep Singh, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbee7..81b0ef3b1 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -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);
-- 
2.19.1


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
                         ` (13 preceding siblings ...)
  2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
@ 2019-04-16  7:41       ` Ferruh Yigit
  2019-04-16  7:41         ` Ferruh Yigit
  2019-04-16  8:28         ` Ferruh Yigit
  14 siblings, 2 replies; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-16  7:41 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
> *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

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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-16  7:41       ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Ferruh Yigit
@ 2019-04-16  7:41         ` Ferruh Yigit
  2019-04-16  8:28         ` Ferruh Yigit
  1 sibling, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-16  7:41 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
> *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

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


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-16  7:41       ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Ferruh Yigit
  2019-04-16  7:41         ` Ferruh Yigit
@ 2019-04-16  8:28         ` Ferruh Yigit
  2019-04-16  8:28           ` Ferruh Yigit
  1 sibling, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-16  8:28 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/16/2019 8:41 AM, Ferruh Yigit wrote:
> On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
>> *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
> 
> 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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-16  8:28         ` Ferruh Yigit
@ 2019-04-16  8:28           ` Ferruh Yigit
  0 siblings, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2019-04-16  8:28 UTC (permalink / raw)
  To: Gagandeep Singh, dev

On 4/16/2019 8:41 AM, Ferruh Yigit wrote:
> On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
>> *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
> 
> 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

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
@ 2019-04-16 10:17 Gagandeep Singh
  2019-04-16 10:17 ` Gagandeep Singh
  0 siblings, 1 reply; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-16 10:17 UTC (permalink / raw)
  To: Ferruh Yigit, dev



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Tuesday, April 16, 2019 1:59 PM
> To: Gagandeep Singh <G.Singh@nxp.com>; dev@dpdk.org
> Subject: [EXT] Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and
> bug fixes
> 
> 
> On 4/16/2019 8:41 AM, Ferruh Yigit wrote:
> > On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
> >> *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
> >
> > 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

Hi Ferruh,

I have submitted an another patch for release notes. 
http://patchwork.dpdk.org/patch/52823/

Thank you.
Gagandeep Singh

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes
  2019-04-16 10:17 Gagandeep Singh
@ 2019-04-16 10:17 ` Gagandeep Singh
  0 siblings, 0 replies; 128+ messages in thread
From: Gagandeep Singh @ 2019-04-16 10:17 UTC (permalink / raw)
  To: Ferruh Yigit, dev



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Tuesday, April 16, 2019 1:59 PM
> To: Gagandeep Singh <G.Singh@nxp.com>; dev@dpdk.org
> Subject: [EXT] Re: [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and
> bug fixes
> 
> 
> On 4/16/2019 8:41 AM, Ferruh Yigit wrote:
> > On 4/12/2019 1:28 PM, Gagandeep Singh wrote:
> >> *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
> >
> > 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

Hi Ferruh,

I have submitted an another patch for release notes. 
http://patchwork.dpdk.org/patch/52823/

Thank you.
Gagandeep Singh

^ permalink raw reply	[flat|nested] 128+ messages in thread

end of thread, other threads:[~2019-04-16 10:18 UTC | newest]

Thread overview: 128+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 11:22 [dpdk-dev] [PATCH 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
2019-04-08 11:22 ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 01/13] net/enetc: support physical addressing mode Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 13:16   ` Ferruh Yigit
2019-04-08 13:16     ` Ferruh Yigit
2019-04-08 11:22 ` [dpdk-dev] [PATCH 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:35   ` David Marchand
2019-04-08 11:35     ` David Marchand
2019-04-10 11:18     ` [dpdk-dev] [EXT] " Gagandeep Singh
2019-04-10 11:18       ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 07/13] net/enetc: remove forward declarations Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-08 11:22 ` [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
2019-04-08 11:22   ` Gagandeep Singh
2019-04-12  7:04 ` [dpdk-dev] [PATCH v2 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
2019-04-12  7:04   ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 01/13] net/enetc: support physical addressing mode Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 03/13] net/enetc: use correct buffer allocation API Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  8:37     ` Thomas Monjalon
2019-04-12  8:37       ` Thomas Monjalon
2019-04-12  8:50       ` [dpdk-dev] [EXT] " Gagandeep Singh
2019-04-12  8:50         ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 05/13] net/enetc: add basic statistics Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 07/13] net/enetc: remove forward declarations Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12  7:04   ` [dpdk-dev] [PATCH v2 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
2019-04-12  7:04     ` Gagandeep Singh
2019-04-12 11:01   ` [dpdk-dev] [PATCH v3 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
2019-04-12 11:01     ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 01/13] net/enetc: support physical addressing mode Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 07/13] net/enetc: remove forward declarations Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 11:01     ` [dpdk-dev] [PATCH v3 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
2019-04-12 11:01       ` Gagandeep Singh
2019-04-12 12:28     ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Gagandeep Singh
2019-04-12 12:28       ` Gagandeep Singh
2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 01/13] net/enetc: support physical addressing mode Gagandeep Singh
2019-04-12 12:28         ` Gagandeep Singh
2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 02/13] net/enetc: fix SMMU unhandled context fault Gagandeep Singh
2019-04-12 12:28         ` Gagandeep Singh
2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 03/13] net/enetc: fix big endian build and correct buffer allocation Gagandeep Singh
2019-04-12 12:28         ` Gagandeep Singh
2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 04/13] net/enetc: set interface mode for SXGMII Gagandeep Singh
2019-04-12 12:28         ` Gagandeep Singh
2019-04-12 12:28       ` [dpdk-dev] [PATCH v4 05/13] net/enetc: add basic statistics Gagandeep Singh
2019-04-12 12:28         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 06/13] net/enetc: replace register read/write macros with functions Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 09/13] net/enetc: add MTU update and jumbo frames support Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 10/13] net/enetc: enable Rx-Tx queue start/stop feature Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 11/13] net/enetc: enable CRC offload feature Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 12/13] net/enetc: enable Rx checksum offload validation Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-12 12:29       ` [dpdk-dev] [PATCH v4 13/13] net/enetc: fix crash at high speed traffic Gagandeep Singh
2019-04-12 12:29         ` Gagandeep Singh
2019-04-16  7:41       ` [dpdk-dev] [PATCH v4 00/13] ENETC PMD basic features and bug fixes Ferruh Yigit
2019-04-16  7:41         ` Ferruh Yigit
2019-04-16  8:28         ` Ferruh Yigit
2019-04-16  8:28           ` Ferruh Yigit
2019-04-16 10:17 Gagandeep Singh
2019-04-16 10:17 ` Gagandeep Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).