net/ipn3ke: setup MTU when HW init
PATCH 1/1 net/ipn3ke: setup MTU when HW init
set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
--- drivers/net/ipn3ke/ipn3ke_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++++ drivers/net/ipn3ke/ipn3ke_ethdev.h | 19 ++++++++ 2 files changed, 112 insertions(+)
drivers/net/ipn3ke/ipn3ke_ethdev.c +93 -0
@@ -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",
drivers/net/ipn3ke/ipn3ke_ethdev.h +19 -0
@@ -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:
Signature · 1 line
1.8.3.1
PATCH v2 1/1 net/ipn3ke: setup MTU when HW init
set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
---
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(+)
drivers/net/ipn3ke/ipn3ke_ethdev.c +97 -0
@@ -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",
drivers/net/ipn3ke/ipn3ke_ethdev.h +19 -0
@@ -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:
Signature · 1 line
1.8.3.1
Quoted 16 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +0
-0
drivers/net/ipn3ke/ipn3ke_ethdev.c line 213
Quoted 5 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0@@ -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 voidipn3ke_10G_mtu_setup(xxx)
drivers/net/ipn3ke/ipn3ke_ethdev.c line 223
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+{ +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.
drivers/net/ipn3ke/ipn3ke_ethdev.c line 231
Quoted 8 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +8
-0+ + (*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
Quoted 6 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +6
-0+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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 247
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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.
Quoted 30 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +30
-0+} + +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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 287
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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.
Quoted 49 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +18
-0+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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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",drivers/net/ipn3ke/ipn3ke_ethdev.h +10
-0@@ -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
drivers/net/ipn3ke/ipn3ke_ethdev.h static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw, · line 676
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +9
-0+#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
Quoted 5 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +0
-0/*Bits[2:0]: Configuration of TX statistics counters: Signature · 1 line
1.8.3.1
HI xiaolong,
Reply inline.
-----Original Message-----
From: Ye, Xiaolong
Sent: Wednesday, August 21, 2019 2:16 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] net/ipn3ke: setup MTU when HW init
Quoted 18 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +0
-0
drivers/net/ipn3ke/ipn3ke_ethdev.c line 213
Quoted 5 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0@@ -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 voidipn3ke_10G_mtu_setup(xxx)
OK
drivers/net/ipn3ke/ipn3ke_ethdev.c line 223
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+{ +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
drivers/net/ipn3ke/ipn3ke_ethdev.c line 231
Quoted 8 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +8
-0+ + (*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
Quoted 6 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +6
-0+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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 247
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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
Quoted 29 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +29
-0+} + +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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 287
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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
Quoted 49 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +17
-0+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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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.hb/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..6419da3 100644drivers/net/ipn3ke/ipn3ke_ethdev.h +10
-0@@ -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
drivers/net/ipn3ke/ipn3ke_ethdev.h static inline void _ipn3ke_indrct_write(struct · line 676
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +9
-0+#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
Quoted 5 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +0
-1/*Bits[2:0]: Configuration of TX statistics counters: -- 1.8.3.1
PATCH v3 1/1 net/ipn3ke: setup MTU when HW init
In reply to Andy Peiset up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
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(+)
drivers/net/ipn3ke/ipn3ke_ethdev.c +109 -0
@@ -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",
drivers/net/ipn3ke/ipn3ke_ethdev.h +15 -0
@@ -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:
Signature · 1 line
1.8.3.1
Hi, Andy
Quoted 9 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Quoted 5 lines
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.
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c| 109 +++++++++++++++++++++++++++++++++++++drivers/net/ipn3ke/ipn3ke_ethdev.h| 15 +++++2 files changed, 124 insertions(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +0
-0
drivers/net/ipn3ke/ipn3ke_ethdev.c line 218
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +7
-0@@ -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);
drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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);
Quoted 68 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +68
-0+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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 298
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+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?
Quoted 45 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +19
-0+ +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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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",drivers/net/ipn3ke/ipn3ke_ethdev.h +5
-0@@ -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
drivers/net/ipn3ke/ipn3ke_ethdev.h static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw, · line 671
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +10
-0+#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
Quoted 6 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +0
-0#define IPN3KE_REGISTER_WIDTH 32/*Bits[2:0]: Configuration of TX statistics counters: Signature · 1 line
1.8.3.1
HI Xiaolong,
Reply inline.
-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, September 2, 2019 5:24 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init
Hi, Andy
Quoted 9 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Quoted 5 lines
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
Quoted 12 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c| 109
+++++++++++++++++++++++++++++++++++++drivers/net/ipn3ke/ipn3ke_ethdev.h| 15 +++++2 files changed, 124 insertions(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +0
-0
drivers/net/ipn3ke/ipn3ke_ethdev.c line 217
Quoted 9 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +6
-0@@ -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);
drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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.
Quoted 66 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +66
-0+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,
drivers/net/ipn3ke/ipn3ke_ethdev.c line 298
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+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
Quoted 45 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +18
-0+ +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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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.hb/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..596df08 100644drivers/net/ipn3ke/ipn3ke_ethdev.h +5
-0@@ -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
drivers/net/ipn3ke/ipn3ke_ethdev.h static inline void _ipn3ke_indrct_write(struct · line 671
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +10
-0+#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
Quoted 6 lines
drivers/net/ipn3ke/ipn3ke_ethdev.h +0
-1#define IPN3KE_REGISTER_WIDTH 32/*Bits[2:0]: Configuration of TX statistics counters: -- 1.8.3.1
On 09/03, Pei, Andy wrote:
[snip]
Quoted 10 lines
tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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_MINandTRE_MAX,typeof()is used.RTE_ETHER_MIN_MTUis MACRO, your expression cause complie issue.
How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)
Thanks,
Xiaolong
Hi Xiaolong,
I tried, but compile issue exist.
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 3, 2019 2:23 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init
On 09/03, Pei, Andy wrote:
[snip]
Quoted 10 lines
tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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_MINandTRE_MAX,typeof()is used.RTE_ETHER_MIN_MTUis MACRO, your expression cause complie issue.
How about RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)
Thanks,
Xiaolong
Quoted 3 lines · Andy
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
Quoted 25 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 3, 2019 2:23 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW initOn 09/03, Pei, Andy wrote:
[snip]Quoted 10 lines
tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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_MINandTRE_MAX,typeof()is used.RTE_ETHER_MIN_MTUis MACRO, your expression cause complie issue.How about
RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)Thanks,
Xiaolong
Oh, I misuse () when casting.
Now it works.
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 3, 2019 4:35 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init
Quoted 3 lines · Andy
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
Quoted 26 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 3, 2019 2:23 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW initOn 09/03, Pei, Andy wrote:
[snip]Quoted 10 lines
tmp = RTE_MAX(tmp, RTE_ETHER_MIN_MTU);drivers/net/ipn3ke/ipn3ke_ethdev.c line 220
Quoted 2 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +2
-0+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_MINandTRE_MAX,typeof()is used.RTE_ETHER_MIN_MTUis MACRO, your expression cause complie issue.How about
RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU)Thanks,
Xiaolong
PATCH v4 1/1 net/ipn3ke: setup MTU when HW init
In reply to Andy Peiset up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
---
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(+)
drivers/net/ipn3ke/ipn3ke_ethdev.c +87 -0
@@ -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",
drivers/net/ipn3ke/ipn3ke_ethdev.h +6 -0
@@ -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:
Signature · 1 line
1.8.3.1
Quoted 38 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +5
-0@@ -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);
drivers/net/ipn3ke/ipn3ke_ethdev.c line 226
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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
Quoted 102 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +69
-0+{ +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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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",drivers/net/ipn3ke/ipn3ke_ethdev.h +6
-0@@ -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: Signature · 1 line
1.8.3.1
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 <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v4] net/ipn3ke: setup MTU when HW init
Quoted 39 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +4
-0@@ -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);
drivers/net/ipn3ke/ipn3ke_ethdev.c line 225
Quoted 10 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+ 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
Quoted 98 lines
drivers/net/ipn3ke/ipn3ke_ethdev.c +64
-0+{ +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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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.hb/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..fc45826 100644drivers/net/ipn3ke/ipn3ke_ethdev.h +6
-1@@ -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
PATCH v5 1/1 net/ipn3ke: setup MTU when HW init
In reply to Andy Peiset up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX.
---
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(+)
drivers/net/ipn3ke/ipn3ke_ethdev.c +86 -0
@@ -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",
drivers/net/ipn3ke/ipn3ke_ethdev.h +6 -0
@@ -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:
Signature · 1 line
1.8.3.1
Quoted 152 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +83
-0@@ -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(structrte_afu_device*afu_dev,
structipn3ke_hw*hw)drivers/net/ipn3ke/ipn3ke_ethdev.c +3
-0@@ -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",drivers/net/ipn3ke/ipn3ke_ethdev.h +6
-0@@ -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: Signature · 1 line
1.8.3.1
Hi,
Quoted 162 lines
-----Original Message-----
From: Pei, Andy
Sent: Wednesday, September 04, 2019 2:53
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v5] net/ipn3ke: setup MTU when HW initset up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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(+)drivers/net/ipn3ke/ipn3ke_ethdev.c +72
-0@@ -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) {drivers/net/ipn3ke/ipn3ke_ethdev.c +10
-0+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 domainfor device %d", diff --git
a/drivers/net/ipn3ke/ipn3ke_ethdev.hb/drivers/net/ipn3ke/ipn3ke_ethdev.h
index c7b336b..fc45826 100644drivers/net/ipn3ke/ipn3ke_ethdev.h +6
-0@@ -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
Quoted 3 lines
/*Bits[2:0]: Configuration of TX statistics counters:
--
1.8.3.1
Ye Xiaolong
AppliedQuoted 21 lines · Andy Pei
set up mtu to the minimun in tx mtu, rx mtu and
IPN3KE_MAC_FRAME_SIZE_MAX.Signed-off-by Andy Pei <[email protected]>---
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.
Quoted 7 lines
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.