dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ipn3ke: setup MTU when HW init
@ 2019-08-08  9:12 Andy Pei
  2019-08-08 16:01 ` [dpdk-dev] [PATCH v2] " Andy Pei
  0 siblings, 1 reply; 18+ messages in thread
From: Andy Pei @ 2019-08-08  9:12 UTC (permalink / raw)
  To: dev; +Cc: rosen.xu

set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/net/ipn3ke/ipn3ke_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ipn3ke/ipn3ke_ethdev.h | 19 ++++++++
 2 files changed, 112 insertions(+)

diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index c226d63..8c56152 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -209,6 +209,96 @@
 	return 0;
 }
 
+static void ipn3ke_10G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	tmp = (tx > rx) ? rx : tx;
+	tmp = (tmp > IPN3KE_MAC_FRAME_SIZE_MAX) ?
+		IPN3KE_MAC_FRAME_SIZE_MAX : tmp;
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+}
+
+static void ipn3ke_25G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	tmp = (tx > rx) ? rx : tx;
+	tmp = (tmp > IPN3KE_MAC_FRAME_SIZE_MAX) ?
+		IPN3KE_MAC_FRAME_SIZE_MAX : tmp;
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
+{
+	int i;
+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_10G_mtu_setup(hw, i, 0);
+			ipn3ke_10G_mtu_setup(hw, i, 1);
+		}
+	} else if (hw->retimer.mac_type ==
+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_25G_mtu_setup(hw, i, 0);
+			ipn3ke_25G_mtu_setup(hw, i, 1);
+		}
+	}
+}
+
 static int
 ipn3ke_hw_init(struct rte_afu_device *afu_dev,
 	struct ipn3ke_hw *hw)
@@ -303,6 +393,9 @@
 		}
 	}
 
+	/* init mtu */
+	ipn3ke_mtu_setup(hw);
+
 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
 	if (ret)
 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..6419da3 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
@@ -654,6 +654,25 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
 #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
 
+/* Additional Feature Register */
+#define ADD_PHY_CTRL		0x0
+#define PHY_RESET		BIT(0)
+/* registers for 25G/40G mac */
+#define MAC_CONFIG	0x310
+#define MAC_RESET_MASK	GENMASK(2, 0)
+
+#define IPN3KE_MAX_MTU                                               0xffff
+
+#define IPN3KE_25G_PHY_PMA_SLOOP                                     0x313
+#define IPN3KE_25G_TX_FLOW_CTRL                                      0x640
+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
+
+#define IPN3KE_10G_TX_PAUSE_FRAME_QUANTA                             0x0042
+#define IPN3KE_10G_TX_PAUSE_FRAME_HOLDOFF                            0x0043
+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
+
 #define IPN3KE_REGISTER_WIDTH                                        32
 
 /*Bits[2:0]: Configuration of TX statistics counters:
-- 
1.8.3.1


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

* [dpdk-dev] [PATCH v2] net/ipn3ke: setup MTU when HW init
  2019-08-08  9:12 [dpdk-dev] [PATCH] net/ipn3ke: setup MTU when HW init Andy Pei
@ 2019-08-08 16:01 ` Andy Pei
  2019-08-21  6:15   ` Ye Xiaolong
  2019-09-02  2:54   ` [dpdk-dev] [PATCH v3] " Andy Pei
  0 siblings, 2 replies; 18+ messages in thread
From: Andy Pei @ 2019-08-08 16:01 UTC (permalink / raw)
  To: dev; +Cc: rosen.xu, tianfei.zhang

set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
v2:
* modify low bound and upper bound.

 drivers/net/ipn3ke/ipn3ke_ethdev.c | 97 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ipn3ke/ipn3ke_ethdev.h | 19 ++++++++
 2 files changed, 116 insertions(+)

diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index c226d63..1a6c217 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -209,6 +209,100 @@
 	return 0;
 }
 
+static void ipn3ke_10G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	tmp = (tx > rx) ? rx : tx;
+	if (tmp < RTE_ETHER_MIN_MTU)
+		tmp = RTE_ETHER_MIN_MTU;
+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+}
+
+static void ipn3ke_25G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	tmp = (tx > rx) ? rx : tx;
+	if (tmp < RTE_ETHER_MIN_MTU)
+		tmp = RTE_ETHER_MIN_MTU;
+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
+{
+	int i;
+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_10G_mtu_setup(hw, i, 0);
+			ipn3ke_10G_mtu_setup(hw, i, 1);
+		}
+	} else if (hw->retimer.mac_type ==
+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_25G_mtu_setup(hw, i, 0);
+			ipn3ke_25G_mtu_setup(hw, i, 1);
+		}
+	}
+}
+
 static int
 ipn3ke_hw_init(struct rte_afu_device *afu_dev,
 	struct ipn3ke_hw *hw)
@@ -303,6 +397,9 @@
 		}
 	}
 
+	/* init mtu */
+	ipn3ke_mtu_setup(hw);
+
 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
 	if (ret)
 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..6419da3 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
@@ -654,6 +654,25 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
 #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
 
+/* Additional Feature Register */
+#define ADD_PHY_CTRL		0x0
+#define PHY_RESET		BIT(0)
+/* registers for 25G/40G mac */
+#define MAC_CONFIG	0x310
+#define MAC_RESET_MASK	GENMASK(2, 0)
+
+#define IPN3KE_MAX_MTU                                               0xffff
+
+#define IPN3KE_25G_PHY_PMA_SLOOP                                     0x313
+#define IPN3KE_25G_TX_FLOW_CTRL                                      0x640
+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
+
+#define IPN3KE_10G_TX_PAUSE_FRAME_QUANTA                             0x0042
+#define IPN3KE_10G_TX_PAUSE_FRAME_HOLDOFF                            0x0043
+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
+
 #define IPN3KE_REGISTER_WIDTH                                        32
 
 /*Bits[2:0]: Configuration of TX statistics counters:
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] net/ipn3ke: setup MTU when HW init
  2019-08-08 16:01 ` [dpdk-dev] [PATCH v2] " Andy Pei
@ 2019-08-21  6:15   ` Ye Xiaolong
  2019-09-02  3:01     ` Pei, Andy
  2019-09-02  2:54   ` [dpdk-dev] [PATCH v3] " Andy Pei
  1 sibling, 1 reply; 18+ messages in thread
From: Ye Xiaolong @ 2019-08-21  6:15 UTC (permalink / raw)
  To: Andy Pei; +Cc: dev, rosen.xu, tianfei.zhang

On 08/09, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>v2:
>* modify low bound and upper bound.
>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 97 ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h | 19 ++++++++
> 2 files changed, 116 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..1a6c217 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,100 @@
> 	return 0;
> }
> 
>+static void ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)

The dpdk convention is:

static void
ipn3ke_10G_mtu_setup(xxx)

>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);

Need to verify whether hw->f_mac_read is NULL or not.

>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = (tx > rx) ? rx : tx;

Can use RTE_MIN

>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;
>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);

Need to check f_mac_write is not NULL before calling it.

>+}
>+
>+static void ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = (tx > rx) ? rx : tx;
>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;
>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+}
>+

ipn3ke_10G_mtu_setup and ipn3ke_25G_mtu_setup share most of the code, please try
to refactor to avoid duplicate code.

>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
>+{
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +397,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..6419da3 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,25 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
> #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+/* Additional Feature Register */
>+#define ADD_PHY_CTRL		0x0
>+#define PHY_RESET		BIT(0)
>+/* registers for 25G/40G mac */
>+#define MAC_CONFIG	0x310
>+#define MAC_RESET_MASK	GENMASK(2, 0)
>+
>+#define IPN3KE_MAX_MTU                                               0xffff
>+
>+#define IPN3KE_25G_PHY_PMA_SLOOP                                     0x313
>+#define IPN3KE_25G_TX_FLOW_CTRL                                      0x640
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_PAUSE_FRAME_QUANTA                             0x0042
>+#define IPN3KE_10G_TX_PAUSE_FRAME_HOLDOFF                            0x0043
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+
> #define IPN3KE_REGISTER_WIDTH                                        32

I saw some MACRO definitions are not used in this patch.


And by the way, why there is no mtu_set ops for ipn3ke ethdev?

Thanks,
Xiaolong

> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>-- 
>1.8.3.1
>

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

* [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-08-08 16:01 ` [dpdk-dev] [PATCH v2] " Andy Pei
  2019-08-21  6:15   ` Ye Xiaolong
@ 2019-09-02  2:54   ` Andy Pei
  2019-09-02  9:23     ` Ye Xiaolong
  2019-09-03  8:46     ` [dpdk-dev] [PATCH v4] " Andy Pei
  1 sibling, 2 replies; 18+ messages in thread
From: Andy Pei @ 2019-09-02  2:54 UTC (permalink / raw)
  To: dev; +Cc: andy.pei, qi.z.zhang, ferruh.yigit, rosen.xu, xiaolong.ye

set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
Cc: qi.z.zhang@intel.com
Cc: ferruh.yigit@intel.com
Cc: rosen.xu@intel.com
Cc: xiaolong.ye@intel.com

v2:
modify low bound and upper bound.

v3:
modify according to community comments.

 drivers/net/ipn3ke/ipn3ke_ethdev.c | 109 +++++++++++++++++++++++++++++++++++++
 drivers/net/ipn3ke/ipn3ke_ethdev.h |  15 +++++
 2 files changed, 124 insertions(+)

diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index c226d63..711d48e 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -209,6 +209,112 @@
 	return 0;
 }
 
+static uint32_t
+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
+{
+	uint32_t tmp;
+	tmp = RTE_MIN(tx, rx);
+	if (tmp < RTE_ETHER_MIN_MTU)
+		tmp = RTE_ETHER_MIN_MTU;
+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
+	return tmp;
+}
+
+static void
+ipn3ke_10G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
+		return;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	tmp = ipn3ke_mtu_cal(tx, rx);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_25G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
+		return;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	tmp = ipn3ke_mtu_cal(tx, rx);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
+{
+	int i;
+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_10G_mtu_setup(hw, i, 0);
+			ipn3ke_10G_mtu_setup(hw, i, 1);
+		}
+	} else if (hw->retimer.mac_type ==
+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_25G_mtu_setup(hw, i, 0);
+			ipn3ke_25G_mtu_setup(hw, i, 1);
+		}
+	}
+}
+
 static int
 ipn3ke_hw_init(struct rte_afu_device *afu_dev,
 	struct ipn3ke_hw *hw)
@@ -303,6 +409,9 @@
 		}
 	}
 
+	/* init mtu */
+	ipn3ke_mtu_setup(hw);
+
 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
 	if (ret)
 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..596df08 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
@@ -654,6 +654,21 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
 #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
 
+/* Additional Feature Register */
+#define ADD_PHY_CTRL		0x0
+#define PHY_RESET		BIT(0)
+/* registers for 25G/40G mac */
+#define MAC_CONFIG	0x310
+#define MAC_RESET_MASK	GENMASK(2, 0)
+
+#define IPN3KE_MAX_MTU                                               0xffff
+
+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
+
+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
+
 #define IPN3KE_REGISTER_WIDTH                                        32
 
 /*Bits[2:0]: Configuration of TX statistics counters:
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] net/ipn3ke: setup MTU when HW init
  2019-08-21  6:15   ` Ye Xiaolong
@ 2019-09-02  3:01     ` Pei, Andy
  0 siblings, 0 replies; 18+ messages in thread
From: Pei, Andy @ 2019-09-02  3:01 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Xu, Rosen, Zhang, Tianfei

HI xiaolong,

Reply inline.

-----Original Message-----
From: Ye, Xiaolong 
Sent: Wednesday, August 21, 2019 2:16 PM
To: Pei, Andy <andy.pei@intel.com>
Cc: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei <tianfei.zhang@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2] net/ipn3ke: setup MTU when HW init

On 08/09, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>v2:
>* modify low bound and upper bound.
>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 97 
> ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h | 19 ++++++++
> 2 files changed, 116 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..1a6c217 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,100 @@
> 	return 0;
> }
> 
>+static void ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)

The dpdk convention is:

static void
ipn3ke_10G_mtu_setup(xxx)

OK

>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);

Need to verify whether hw->f_mac_read is NULL or not.
ok
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = (tx > rx) ? rx : tx;

Can use RTE_MIN

OK

>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;
>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);

Need to check f_mac_write is not NULL before calling it.
ok
>+}
>+
>+static void ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) {
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = (tx > rx) ? rx : tx;
>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;
>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+}
>+

ipn3ke_10G_mtu_setup and ipn3ke_25G_mtu_setup share most of the code, please try to refactor to avoid duplicate code.
ok
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw) {
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +397,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device 
>%d", diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..6419da3 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,25 @@ static inline void _ipn3ke_indrct_write(struct 
>ipn3ke_hw *hw,  #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+/* Additional Feature Register */
>+#define ADD_PHY_CTRL		0x0
>+#define PHY_RESET		BIT(0)
>+/* registers for 25G/40G mac */
>+#define MAC_CONFIG	0x310
>+#define MAC_RESET_MASK	GENMASK(2, 0)
>+
>+#define IPN3KE_MAX_MTU                                               0xffff
>+
>+#define IPN3KE_25G_PHY_PMA_SLOOP                                     0x313
>+#define IPN3KE_25G_TX_FLOW_CTRL                                      0x640
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_PAUSE_FRAME_QUANTA                             0x0042
>+#define IPN3KE_10G_TX_PAUSE_FRAME_HOLDOFF                            0x0043
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+
> #define IPN3KE_REGISTER_WIDTH                                        32

I saw some MACRO definitions are not used in this patch.
I copy these MACRO from ipn3ke kernel driver in case we will use later.
If not use currently, I can delete these MACRO.

And by the way, why there is no mtu_set ops for ipn3ke ethdev?
Mtu_set ops is in ipn3ke_representor.c

Thanks,
Xiaolong

> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>--
>1.8.3.1
>

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-02  2:54   ` [dpdk-dev] [PATCH v3] " Andy Pei
@ 2019-09-02  9:23     ` Ye Xiaolong
  2019-09-03  2:34       ` Pei, Andy
  2019-09-03  8:46     ` [dpdk-dev] [PATCH v4] " Andy Pei
  1 sibling, 1 reply; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-02  9:23 UTC (permalink / raw)
  To: Andy Pei; +Cc: dev, qi.z.zhang, ferruh.yigit, rosen.xu

Hi, Andy

On 09/02, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>modify according to community comments.

Better to put more details about your changes other than the vague description.

>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 109 +++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  15 +++++
> 2 files changed, 124 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..711d48e 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,112 @@
> 	return 0;
> }
> 
>+static uint32_t
>+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
>+{
>+	uint32_t tmp;
>+	tmp = RTE_MIN(tx, rx);
>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;

	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);

>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;

	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
	
>+	return tmp;
>+}
>+
>+static void
>+ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+}
>+
>+static void
>+ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+}


Above 2 functions still share lots of duplicated code, can you extract the
duplicated code to a common function?

>+
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
>+{
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +409,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..596df08 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,21 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
> #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+/* Additional Feature Register */
>+#define ADD_PHY_CTRL		0x0
>+#define PHY_RESET		BIT(0)
>+/* registers for 25G/40G mac */
>+#define MAC_CONFIG	0x310
>+#define MAC_RESET_MASK	GENMASK(2, 0)
>+
>+#define IPN3KE_MAX_MTU                                               0xffff
>+
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+

It's better to remove unused MACROs here to make the patch clean.

Thanks,
Xiaolong

> #define IPN3KE_REGISTER_WIDTH                                        32
> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>-- 
>1.8.3.1
>

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-02  9:23     ` Ye Xiaolong
@ 2019-09-03  2:34       ` Pei, Andy
  2019-09-03  6:23         ` Ye Xiaolong
  0 siblings, 1 reply; 18+ messages in thread
From: Pei, Andy @ 2019-09-03  2:34 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

HI Xiaolong,

Reply inline.

-----Original Message-----
From: Ye, Xiaolong 
Sent: Monday, September 2, 2019 5:24 PM
To: Pei, Andy <andy.pei@intel.com>
Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init

Hi, Andy

On 09/02, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>modify according to community comments.

Better to put more details about your changes other than the vague description.

OK

>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 109 
> +++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  15 +++++
> 2 files changed, 124 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..711d48e 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,112 @@
> 	return 0;
> }
> 
>+static uint32_t
>+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx) {
>+	uint32_t tmp;
>+	tmp = RTE_MIN(tx, rx);
>+	if (tmp < RTE_ETHER_MIN_MTU)
>+		tmp = RTE_ETHER_MIN_MTU;

	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);

>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;

	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
	
in the definition of TRE_MIN and TRE_MAX, typeof() is used.
RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue.

>+	return tmp;
>+}
>+
>+static void
>+ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) {
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_TX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_10G_RX_FRAME_MAXLENGTH,
>+			mac_num,
>+			eth_group_sel);
>+}
>+
>+static void
>+ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) {
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_TX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			IPN3KE_25G_MAX_RX_SIZE_CONFIG,
>+			mac_num,
>+			eth_group_sel);
>+}


Above 2 functions still share lots of duplicated code, can you extract the duplicated code to a common function?
OK
>+
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw) {
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +409,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device 
>%d", diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..596df08 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,21 @@ static inline void _ipn3ke_indrct_write(struct 
>ipn3ke_hw *hw,  #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+/* Additional Feature Register */
>+#define ADD_PHY_CTRL		0x0
>+#define PHY_RESET		BIT(0)
>+/* registers for 25G/40G mac */
>+#define MAC_CONFIG	0x310
>+#define MAC_RESET_MASK	GENMASK(2, 0)
>+
>+#define IPN3KE_MAX_MTU                                               0xffff
>+
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+

It's better to remove unused MACROs here to make the patch clean.

OK

Thanks,
Xiaolong

> #define IPN3KE_REGISTER_WIDTH                                        32
> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>--
>1.8.3.1
>

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-03  2:34       ` Pei, Andy
@ 2019-09-03  6:23         ` Ye Xiaolong
  2019-09-03  6:29           ` Pei, Andy
  0 siblings, 1 reply; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-03  6:23 UTC (permalink / raw)
  To: Pei, Andy; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

On 09/03, Pei, Andy wrote:
[snip]
>	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);
>
>>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>
>	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
>	
>in the definition of TRE_MIN and TRE_MAX, typeof() is used.
>RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue.
>

How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)

Thanks,
Xiaolong

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-03  6:23         ` Ye Xiaolong
@ 2019-09-03  6:29           ` Pei, Andy
  2019-09-03  8:35             ` Ye Xiaolong
  0 siblings, 1 reply; 18+ messages in thread
From: Pei, Andy @ 2019-09-03  6:29 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

Hi Xiaolong,

I tried, but compile issue exist.

-----Original Message-----
From: Ye, Xiaolong 
Sent: Tuesday, September 3, 2019 2:23 PM
To: Pei, Andy <andy.pei@intel.com>
Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init

On 09/03, Pei, Andy wrote:
[snip]
>	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);
>
>>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>
>	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
>	
>in the definition of TRE_MIN and TRE_MAX, typeof() is used.
>RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue.
>

How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)

Thanks,
Xiaolong

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-03  6:29           ` Pei, Andy
@ 2019-09-03  8:35             ` Ye Xiaolong
  2019-09-03  8:46               ` Pei, Andy
  0 siblings, 1 reply; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-03  8:35 UTC (permalink / raw)
  To: Pei, Andy; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

On 09/03, Pei, Andy wrote:
>Hi Xiaolong,
>
>I tried, but compile issue exist.

Er, what's the exact compiling issue after the type cast? We can see the similar
usage in function like replay_num_bucket @lib/librte_ipsec/sa.c.

Thanks,
Xiaolong
>
>-----Original Message-----
>From: Ye, Xiaolong 
>Sent: Tuesday, September 3, 2019 2:23 PM
>To: Pei, Andy <andy.pei@intel.com>
>Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
>Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init
>
>On 09/03, Pei, Andy wrote:
>[snip]
>>	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);
>>
>>>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>>>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>>
>>	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
>>	
>>in the definition of TRE_MIN and TRE_MAX, typeof() is used.
>>RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue.
>>
>
>How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)
>
>Thanks,
>Xiaolong

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

* Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init
  2019-09-03  8:35             ` Ye Xiaolong
@ 2019-09-03  8:46               ` Pei, Andy
  0 siblings, 0 replies; 18+ messages in thread
From: Pei, Andy @ 2019-09-03  8:46 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

Oh, I misuse () when casting.
Now it works.


-----Original Message-----
From: Ye, Xiaolong 
Sent: Tuesday, September 3, 2019 4:35 PM
To: Pei, Andy <andy.pei@intel.com>
Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init

On 09/03, Pei, Andy wrote:
>Hi Xiaolong,
>
>I tried, but compile issue exist.

Er, what's the exact compiling issue after the type cast? We can see the similar usage in function like replay_num_bucket @lib/librte_ipsec/sa.c.

Thanks,
Xiaolong
>
>-----Original Message-----
>From: Ye, Xiaolong
>Sent: Tuesday, September 3, 2019 2:23 PM
>To: Pei, Andy <andy.pei@intel.com>
>Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh 
><ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
>Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init
>
>On 09/03, Pei, Andy wrote:
>[snip]
>>	tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);
>>
>>>+	if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD)
>>>+		tmp = IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD;
>>
>>	tmp = RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD);
>>	
>>in the definition of TRE_MIN and TRE_MAX, typeof() is used.
>>RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue.
>>
>
>How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)
>
>Thanks,
>Xiaolong

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

* [dpdk-dev] [PATCH v4] net/ipn3ke: setup MTU when HW init
  2019-09-02  2:54   ` [dpdk-dev] [PATCH v3] " Andy Pei
  2019-09-02  9:23     ` Ye Xiaolong
@ 2019-09-03  8:46     ` Andy Pei
  2019-09-03 13:31       ` Ye Xiaolong
  2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
  1 sibling, 2 replies; 18+ messages in thread
From: Andy Pei @ 2019-09-03  8:46 UTC (permalink / raw)
  To: dev; +Cc: andy.pei, qi.z.zhang, ferruh.yigit, rosen.xu, xiaolong.ye

set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---

Cc: qi.z.zhang@intel.com
Cc: ferruh.yigit@intel.com
Cc: rosen.xu@intel.com
Cc: xiaolong.ye@intel.com

v2:
modify low bound and upper bound.

v3:
delete unnecessary MACROs.
extract the duplicated code to a common function.

v4:
delete unnecessary MACROs.
extract the duplicated code to a common function.

 drivers/net/ipn3ke/ipn3ke_ethdev.c | 87 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
 2 files changed, 93 insertions(+)

diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index c226d63..e619ba3 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -209,6 +209,90 @@
 	return 0;
 }
 
+static uint32_t
+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
+{
+	uint32_t tmp;
+	tmp = RTE_MIN(tx, rx);
+	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
+	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
+		IPN3KE_ETH_OVERHEAD));
+	return tmp;
+}
+
+static void
+ipn3ke_mtu_set
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel,
+uint32_t txaddr, uint32_t rxaddr)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
+		return;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			txaddr,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			rxaddr,
+			mac_num,
+			eth_group_sel);
+
+	tmp = ipn3ke_mtu_cal(tx, rx);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			txaddr,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			rxaddr,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_10G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
+		IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH);
+}
+
+static void
+ipn3ke_25G_mtu_setup
+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
+{
+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
+		IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG);
+}
+
+static void
+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
+{
+	int i;
+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_10G_mtu_setup(hw, i, 0);
+			ipn3ke_10G_mtu_setup(hw, i, 1);
+		}
+	} else if (hw->retimer.mac_type ==
+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_25G_mtu_setup(hw, i, 0);
+			ipn3ke_25G_mtu_setup(hw, i, 1);
+		}
+	}
+}
+
 static int
 ipn3ke_hw_init(struct rte_afu_device *afu_dev,
 	struct ipn3ke_hw *hw)
@@ -303,6 +387,9 @@
 		}
 	}
 
+	/* init mtu */
+	ipn3ke_mtu_setup(hw);
+
 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
 	if (ret)
 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..fc45826 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
 #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
 
+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
+
+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
+
 #define IPN3KE_REGISTER_WIDTH                                        32
 
 /*Bits[2:0]: Configuration of TX statistics counters:
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v4] net/ipn3ke: setup MTU when HW init
  2019-09-03  8:46     ` [dpdk-dev] [PATCH v4] " Andy Pei
@ 2019-09-03 13:31       ` Ye Xiaolong
  2019-09-04  2:05         ` Pei, Andy
  2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
  1 sibling, 1 reply; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-03 13:31 UTC (permalink / raw)
  To: Andy Pei; +Cc: dev, qi.z.zhang, ferruh.yigit, rosen.xu

On 09/03, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v4:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 87 ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
> 2 files changed, 93 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..e619ba3 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,90 @@
> 	return 0;
> }
> 
>+static uint32_t
>+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
>+{
>+	uint32_t tmp;
>+	tmp = RTE_MIN(tx, rx);
>+	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
>+	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
>+		IPN3KE_ETH_OVERHEAD));
>+	return tmp;
>+}
>+
>+static void
>+ipn3ke_mtu_set
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel,
>+uint32_t txaddr, uint32_t rxaddr)

It's quite rare to start the arguments in a separate line, better to follow
the common convention like

static void
rte_eth_dev_config_restore(struct rte_eth_dev *dev,
                           struct rte_eth_dev_info *dev_info, uint16_t port_id)


Thanks,
Xiaolong


>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+}
>+
>+static void
>+ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
>+{
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH);
>+}
>+
>+static void
>+ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel)
>+{
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG);
>+}
>+
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
>+{
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +387,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..fc45826 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
> #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+
> #define IPN3KE_REGISTER_WIDTH                                        32
> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>-- 
>1.8.3.1
>

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

* [dpdk-dev] [PATCH v5] net/ipn3ke: setup MTU when HW init
  2019-09-03  8:46     ` [dpdk-dev] [PATCH v4] " Andy Pei
  2019-09-03 13:31       ` Ye Xiaolong
@ 2019-09-04  1:52       ` Andy Pei
  2019-09-18  9:00         ` Ye Xiaolong
                           ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Andy Pei @ 2019-09-04  1:52 UTC (permalink / raw)
  To: dev; +Cc: andy.pei, qi.z.zhang, ferruh.yigit, rosen.xu, xiaolong.ye

set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---

Cc: qi.z.zhang@intel.com
Cc: ferruh.yigit@intel.com
Cc: rosen.xu@intel.com
Cc: xiaolong.ye@intel.com

v2:
modify low bound and upper bound.

v3:
delete unnecessary MACROs.
extract the duplicated code to a common function.

v4:
delete unnecessary MACROs.
extract the duplicated code to a common function.

v5:
Not to start the arguments in a separate line.

drivers/net/ipn3ke/ipn3ke_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
 2 files changed, 92 insertions(+)

diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index c226d63..28d8aaf 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -209,6 +209,89 @@
 	return 0;
 }
 
+static uint32_t
+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
+{
+	uint32_t tmp;
+	tmp = RTE_MIN(tx, rx);
+	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
+	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
+		IPN3KE_ETH_OVERHEAD));
+	return tmp;
+}
+
+static void
+ipn3ke_mtu_set(struct ipn3ke_hw *hw, uint32_t mac_num,
+	uint32_t eth_group_sel, uint32_t txaddr, uint32_t rxaddr)
+{
+	uint32_t tx;
+	uint32_t rx;
+	uint32_t tmp;
+
+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
+		return;
+
+	(*hw->f_mac_read)(hw,
+			&tx,
+			txaddr,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_read)(hw,
+			&rx,
+			rxaddr,
+			mac_num,
+			eth_group_sel);
+
+	tmp = ipn3ke_mtu_cal(tx, rx);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			txaddr,
+			mac_num,
+			eth_group_sel);
+
+	(*hw->f_mac_write)(hw,
+			tmp,
+			rxaddr,
+			mac_num,
+			eth_group_sel);
+}
+
+static void
+ipn3ke_10G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
+	uint32_t eth_group_sel)
+{
+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
+		IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH);
+}
+
+static void
+ipn3ke_25G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
+	uint32_t eth_group_sel)
+{
+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
+		IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG);
+}
+
+static void
+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
+{
+	int i;
+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_10G_mtu_setup(hw, i, 0);
+			ipn3ke_10G_mtu_setup(hw, i, 1);
+		}
+	} else if (hw->retimer.mac_type ==
+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
+		for (i = 0; i < hw->port_num; i++) {
+			ipn3ke_25G_mtu_setup(hw, i, 0);
+			ipn3ke_25G_mtu_setup(hw, i, 1);
+		}
+	}
+}
+
 static int
 ipn3ke_hw_init(struct rte_afu_device *afu_dev,
 	struct ipn3ke_hw *hw)
@@ -303,6 +386,9 @@
 		}
 	}
 
+	/* init mtu */
+	ipn3ke_mtu_setup(hw);
+
 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
 	if (ret)
 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..fc45826 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
 #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
 
+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
+
+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
+
 #define IPN3KE_REGISTER_WIDTH                                        32
 
 /*Bits[2:0]: Configuration of TX statistics counters:
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v4] net/ipn3ke: setup MTU when HW init
  2019-09-03 13:31       ` Ye Xiaolong
@ 2019-09-04  2:05         ` Pei, Andy
  0 siblings, 0 replies; 18+ messages in thread
From: Pei, Andy @ 2019-09-04  2:05 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Zhang, Qi Z, Yigit, Ferruh, Xu, Rosen

Hi Xiaolong

OK. I will do that in v5.

-----Original Message-----
From: Ye, Xiaolong 
Sent: Tuesday, September 3, 2019 9:32 PM
To: Pei, Andy <andy.pei@intel.com>
Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>
Subject: Re: [PATCH v4] net/ipn3ke: setup MTU when HW init

On 09/03, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v4:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 87 
> ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
> 2 files changed, 93 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..e619ba3 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,90 @@
> 	return 0;
> }
> 
>+static uint32_t
>+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx) {
>+	uint32_t tmp;
>+	tmp = RTE_MIN(tx, rx);
>+	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
>+	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
>+		IPN3KE_ETH_OVERHEAD));
>+	return tmp;
>+}
>+
>+static void
>+ipn3ke_mtu_set
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel, 
>+uint32_t txaddr, uint32_t rxaddr)

It's quite rare to start the arguments in a separate line, better to follow the common convention like

static void
rte_eth_dev_config_restore(struct rte_eth_dev *dev,
                           struct rte_eth_dev_info *dev_info, uint16_t port_id)


Thanks,
Xiaolong


>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+}
>+
>+static void
>+ipn3ke_10G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) {
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH); }
>+
>+static void
>+ipn3ke_25G_mtu_setup
>+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) {
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG); }
>+
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw) {
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +387,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device 
>%d", diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h 
>b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..fc45826 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct 
>ipn3ke_hw *hw,  #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+
> #define IPN3KE_REGISTER_WIDTH                                        32
> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>--
>1.8.3.1
>

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

* Re: [dpdk-dev] [PATCH v5] net/ipn3ke: setup MTU when HW init
  2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
@ 2019-09-18  9:00         ` Ye Xiaolong
  2019-09-24  8:59         ` Xu, Rosen
  2019-09-24  9:38         ` Ye Xiaolong
  2 siblings, 0 replies; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-18  9:00 UTC (permalink / raw)
  To: Andy Pei; +Cc: dev, qi.z.zhang, ferruh.yigit, rosen.xu

On 09/04, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v4:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v5:
>Not to start the arguments in a separate line.
>
>drivers/net/ipn3ke/ipn3ke_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
> 2 files changed, 92 insertions(+)
>
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>index c226d63..28d8aaf 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
>@@ -209,6 +209,89 @@
> 	return 0;
> }
> 
>+static uint32_t
>+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx)
>+{
>+	uint32_t tmp;
>+	tmp = RTE_MIN(tx, rx);
>+	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
>+	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
>+		IPN3KE_ETH_OVERHEAD));
>+	return tmp;
>+}
>+
>+static void
>+ipn3ke_mtu_set(struct ipn3ke_hw *hw, uint32_t mac_num,
>+	uint32_t eth_group_sel, uint32_t txaddr, uint32_t rxaddr)
>+{
>+	uint32_t tx;
>+	uint32_t rx;
>+	uint32_t tmp;
>+
>+	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
>+		return;
>+
>+	(*hw->f_mac_read)(hw,
>+			&tx,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_read)(hw,
>+			&rx,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	tmp = ipn3ke_mtu_cal(tx, rx);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			txaddr,
>+			mac_num,
>+			eth_group_sel);
>+
>+	(*hw->f_mac_write)(hw,
>+			tmp,
>+			rxaddr,
>+			mac_num,
>+			eth_group_sel);
>+}
>+
>+static void
>+ipn3ke_10G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
>+	uint32_t eth_group_sel)
>+{
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH);
>+}
>+
>+static void
>+ipn3ke_25G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
>+	uint32_t eth_group_sel)
>+{
>+	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
>+		IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG);
>+}
>+
>+static void
>+ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
>+{
>+	int i;
>+	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_10G_mtu_setup(hw, i, 0);
>+			ipn3ke_10G_mtu_setup(hw, i, 1);
>+		}
>+	} else if (hw->retimer.mac_type ==
>+			IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
>+		for (i = 0; i < hw->port_num; i++) {
>+			ipn3ke_25G_mtu_setup(hw, i, 0);
>+			ipn3ke_25G_mtu_setup(hw, i, 1);
>+		}
>+	}
>+}
>+
> static int
> ipn3ke_hw_init(struct rte_afu_device *afu_dev,
> 	struct ipn3ke_hw *hw)
>@@ -303,6 +386,9 @@
> 		}
> 	}
> 
>+	/* init mtu */
>+	ipn3ke_mtu_setup(hw);
>+
> 	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
> 	if (ret)
> 		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d",
>diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>index c7b336b..fc45826 100644
>--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
>+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
>@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw,
> #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
> 	IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
>+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
>+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
>+
>+#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
>+#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
>+
> #define IPN3KE_REGISTER_WIDTH                                        32
> 
> /*Bits[2:0]: Configuration of TX statistics counters:
>-- 
>1.8.3.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

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

* Re: [dpdk-dev] [PATCH v5] net/ipn3ke: setup MTU when HW init
  2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
  2019-09-18  9:00         ` Ye Xiaolong
@ 2019-09-24  8:59         ` Xu, Rosen
  2019-09-24  9:38         ` Ye Xiaolong
  2 siblings, 0 replies; 18+ messages in thread
From: Xu, Rosen @ 2019-09-24  8:59 UTC (permalink / raw)
  To: Pei, Andy, dev; +Cc: Zhang, Qi Z, Yigit, Ferruh, Ye, Xiaolong

Hi,

> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, September 04, 2019 2:53
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>; Ye,
> Xiaolong <xiaolong.ye@intel.com>
> Subject: [PATCH v5] net/ipn3ke: setup MTU when HW init
> 
> set up mtu to the minimun in tx mtu, rx mtu and
> IPN3KE_MAC_FRAME_SIZE_MAX.
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
> 
> Cc: qi.z.zhang@intel.com
> Cc: ferruh.yigit@intel.com
> Cc: rosen.xu@intel.com
> Cc: xiaolong.ye@intel.com
> 
> v2:
> modify low bound and upper bound.
> 
> v3:
> delete unnecessary MACROs.
> extract the duplicated code to a common function.
> 
> v4:
> delete unnecessary MACROs.
> extract the duplicated code to a common function.
> 
> v5:
> Not to start the arguments in a separate line.
> 
> drivers/net/ipn3ke/ipn3ke_ethdev.c | 86
> ++++++++++++++++++++++++++++++++++++++
>  drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
>  2 files changed, 92 insertions(+)
> 
> diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c
> b/drivers/net/ipn3ke/ipn3ke_ethdev.c
> index c226d63..28d8aaf 100644
> --- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
> +++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
> @@ -209,6 +209,89 @@
>  	return 0;
>  }
> 
> +static uint32_t
> +ipn3ke_mtu_cal(uint32_t tx, uint32_t rx) {
> +	uint32_t tmp;
> +	tmp = RTE_MIN(tx, rx);
> +	tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU);
> +	tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX -
> +		IPN3KE_ETH_OVERHEAD));
> +	return tmp;
> +}
> +
> +static void
> +ipn3ke_mtu_set(struct ipn3ke_hw *hw, uint32_t mac_num,
> +	uint32_t eth_group_sel, uint32_t txaddr, uint32_t rxaddr) {
> +	uint32_t tx;
> +	uint32_t rx;
> +	uint32_t tmp;
> +
> +	if (!(*hw->f_mac_read) || !(*hw->f_mac_write))
> +		return;
> +
> +	(*hw->f_mac_read)(hw,
> +			&tx,
> +			txaddr,
> +			mac_num,
> +			eth_group_sel);
> +
> +	(*hw->f_mac_read)(hw,
> +			&rx,
> +			rxaddr,
> +			mac_num,
> +			eth_group_sel);
> +
> +	tmp = ipn3ke_mtu_cal(tx, rx);
> +
> +	(*hw->f_mac_write)(hw,
> +			tmp,
> +			txaddr,
> +			mac_num,
> +			eth_group_sel);
> +
> +	(*hw->f_mac_write)(hw,
> +			tmp,
> +			rxaddr,
> +			mac_num,
> +			eth_group_sel);
> +}
> +
> +static void
> +ipn3ke_10G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
> +	uint32_t eth_group_sel)
> +{
> +	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
> +		IPN3KE_10G_TX_FRAME_MAXLENGTH,
> IPN3KE_10G_RX_FRAME_MAXLENGTH); }
> +
> +static void
> +ipn3ke_25G_mtu_setup(struct ipn3ke_hw *hw, uint32_t mac_num,
> +	uint32_t eth_group_sel)
> +{
> +	ipn3ke_mtu_set(hw, mac_num, eth_group_sel,
> +		IPN3KE_25G_MAX_TX_SIZE_CONFIG,
> IPN3KE_25G_MAX_RX_SIZE_CONFIG); }
> +
> +static void
> +ipn3ke_mtu_setup(struct ipn3ke_hw *hw)
> +{
> +	int i;
> +	if (hw->retimer.mac_type ==
> IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
> +		for (i = 0; i < hw->port_num; i++) {
> +			ipn3ke_10G_mtu_setup(hw, i, 0);
> +			ipn3ke_10G_mtu_setup(hw, i, 1);
> +		}
> +	} else if (hw->retimer.mac_type ==
> +
> 	IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
> +		for (i = 0; i < hw->port_num; i++) {
> +			ipn3ke_25G_mtu_setup(hw, i, 0);
> +			ipn3ke_25G_mtu_setup(hw, i, 1);
> +		}
> +	}
> +}
> +
>  static int
>  ipn3ke_hw_init(struct rte_afu_device *afu_dev,
>  	struct ipn3ke_hw *hw)
> @@ -303,6 +386,9 @@
>  		}
>  	}
> 
> +	/* init mtu */
> +	ipn3ke_mtu_setup(hw);
> +
>  	ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id);
>  	if (ret)
>  		IPN3KE_AFU_PMD_WARN("failed to allocate switch domain
> for device %d", diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h
> b/drivers/net/ipn3ke/ipn3ke_ethdev.h
> index c7b336b..fc45826 100644
> --- a/drivers/net/ipn3ke/ipn3ke_ethdev.h
> +++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h
> @@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct
> ipn3ke_hw *hw,  #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \
>  	IPN3KE_MASK(0xFFFF,
> IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT)
> 
> +#define IPN3KE_25G_MAX_TX_SIZE_CONFIG                                0x407
> +#define IPN3KE_25G_MAX_RX_SIZE_CONFIG                                0x506
> +
> +#define IPN3KE_10G_TX_FRAME_MAXLENGTH                                0x002C
> +#define IPN3KE_10G_RX_FRAME_MAXLENGTH                                0x00AE
> +
>  #define IPN3KE_REGISTER_WIDTH                                        32
> 
>  /*Bits[2:0]: Configuration of TX statistics counters:
> --
> 1.8.3.1

Acked-by: Rosen Xu <rosen.xu@intel.com>

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

* Re: [dpdk-dev] [PATCH v5] net/ipn3ke: setup MTU when HW init
  2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
  2019-09-18  9:00         ` Ye Xiaolong
  2019-09-24  8:59         ` Xu, Rosen
@ 2019-09-24  9:38         ` Ye Xiaolong
  2 siblings, 0 replies; 18+ messages in thread
From: Ye Xiaolong @ 2019-09-24  9:38 UTC (permalink / raw)
  To: Andy Pei; +Cc: dev, qi.z.zhang, ferruh.yigit, rosen.xu

On 09/04, Andy Pei wrote:
>set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
>
>Signed-off-by: Andy Pei <andy.pei@intel.com>
>---
>
>Cc: qi.z.zhang@intel.com
>Cc: ferruh.yigit@intel.com
>Cc: rosen.xu@intel.com
>Cc: xiaolong.ye@intel.com
>
>v2:
>modify low bound and upper bound.
>
>v3:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v4:
>delete unnecessary MACROs.
>extract the duplicated code to a common function.
>
>v5:
>Not to start the arguments in a separate line.
>
>drivers/net/ipn3ke/ipn3ke_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++
> drivers/net/ipn3ke/ipn3ke_ethdev.h |  6 +++
> 2 files changed, 92 insertions(+)
>

Applied to dpdk-next-net-intel.

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

end of thread, other threads:[~2019-09-24  9:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08  9:12 [dpdk-dev] [PATCH] net/ipn3ke: setup MTU when HW init Andy Pei
2019-08-08 16:01 ` [dpdk-dev] [PATCH v2] " Andy Pei
2019-08-21  6:15   ` Ye Xiaolong
2019-09-02  3:01     ` Pei, Andy
2019-09-02  2:54   ` [dpdk-dev] [PATCH v3] " Andy Pei
2019-09-02  9:23     ` Ye Xiaolong
2019-09-03  2:34       ` Pei, Andy
2019-09-03  6:23         ` Ye Xiaolong
2019-09-03  6:29           ` Pei, Andy
2019-09-03  8:35             ` Ye Xiaolong
2019-09-03  8:46               ` Pei, Andy
2019-09-03  8:46     ` [dpdk-dev] [PATCH v4] " Andy Pei
2019-09-03 13:31       ` Ye Xiaolong
2019-09-04  2:05         ` Pei, Andy
2019-09-04  1:52       ` [dpdk-dev] [PATCH v5] " Andy Pei
2019-09-18  9:00         ` Ye Xiaolong
2019-09-24  8:59         ` Xu, Rosen
2019-09-24  9:38         ` Ye Xiaolong

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).