net: stmmac: support FPE link partner hand-shaking procedure
Subsystems (4)
RFC 1/1 net: stmmac: support FPE link partner hand-shaking procedure
From: Ong Boon Leong <[email protected]>
In order to discover whether remote station supports frame preemption, local station sends verify mPacket and expects response mPacket in return from the remote station.
So, we add the functions to send and handle event when verify mPacket and response mPacket are exchanged between the networked stations.
The mechanism to handle different FPE states between local and remote station (link partner) is implemented using workqueue which starts a task each time there is some sign of verify & response mPacket exchange as check in FPE IRQ event. The task retries couple of times to try to spot the states that both stations are ready to enter FPE ON. This allows different end points to enable FPE at different time and verify-response mPacket can happen asynchronously. Ultimately, the task will only turn FPE ON when local station have both exchange response in both directions.
Thanks to Voon Weifeng for implementing the core functions for detecting FPE events and send mPacket and phylink related change.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 7 + .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 + drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 49 +++++ drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 11 ++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 7 + drivers/net/ethernet/stmicro/stmmac/stmmac.h | 7 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 179 ++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 28 ++- include/linux/stmmac.h | 27 +++ 9 files changed, 316 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +7 -0
@@ -309,6 +309,13 @@ enum dma_irq_status {#define CORE_IRQ_RX_PATH_IN_LPI_MODE (1 << 2)#define CORE_IRQ_RX_PATH_EXIT_LPI_MODE (1 << 3) +/* FPE defines */ +#define FPE_EVENT_UNKNOWN 0 +#define FPE_EVENT_TRSP BIT(0) +#define FPE_EVENT_TVER BIT(1) +#define FPE_EVENT_RRSP BIT(2) +#define FPE_EVENT_RVER BIT(3) +#define CORE_IRQ_MTL_RX_OVERFLOW BIT(8)/* Physical Coding Sublayer */
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +8 -0
@@ -53,6 +53,10 @@ static void dwmac4_core_init(struct mac_device_info *hw,if (hw->pcs) value |=GMAC_PCS_IRQ_DEFAULT ; +/* Enable FPE interrupt */ +if ((GMAC_HW_FEAT_FPESEL &readl (ioaddr +GMAC_HW_FEATURE3 )) >>26 ) + value |=GMAC_INT_FPE_EN ; +writel (value, ioaddr +GMAC_INT_EN ); }
@@ -1245,6 +1249,8 @@ const struct stmmac_ops dwmac410_ops = { .config_l4_filter = dwmac4_config_l4_filter, .est_configure = dwmac5_est_configure, .fpe_configure = dwmac5_fpe_configure, + .fpe_send_mpacket = dwmac5_fpe_send_mpacket, + .fpe_irq_status = dwmac5_fpe_irq_status, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr,
@@ -1294,6 +1300,8 @@ const struct stmmac_ops dwmac510_ops = { .config_l4_filter = dwmac4_config_l4_filter, .est_configure = dwmac5_est_configure, .fpe_configure = dwmac5_fpe_configure, + .fpe_send_mpacket = dwmac5_fpe_send_mpacket, + .fpe_irq_status = dwmac5_fpe_irq_status, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr,
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +49 -0
52 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwmac5.h +11 -0
@@ -12,6 +12,12 @@#define TMOUTEN BIT(0)#define MAC_FPE_CTRL_STS 0x00000234 +#define TRSP BIT(19) +#define TVER BIT(18) +#define RRSP BIT(17) +#define RVER BIT(16) +#define SRSP BIT(2) +#define SVER BIT(1)#define EFPE BIT(0)#define MAC_PPS_CONTROL 0x00000b70
@@ -98,6 +104,8 @@#define GMAC_RXQCTRL_VFFQ_SHIFT 17#define GMAC_RXQCTRL_VFFQE BIT(16) +#define GMAC_INT_FPE_EN BIT(17) +int dwmac5_safety_feat_config (void __iomem *ioaddr,unsigned int asp); int dwmac5_safety_feat_irq_status(struct net_device *ndev, void __iomem *ioaddr, unsigned int asp,
@@ -113,5 +121,8 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, unsigned int ptp_rate);void dwmac5_fpe_configure (void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable); +void dwmac5_fpe_send_mpacket (void __iomem *ioaddr, +enum stmmac_mpacket_type type); +int dwmac5_fpe_irq_status (void __iomem *ioaddr,struct net_device *dev);#endif /* __DWMAC5_H__ */
drivers/net/ethernet/stmicro/stmmac/hwif.h +7 -0
@@ -395,6 +395,9 @@ struct stmmac_ops { unsigned int ptp_rate);void (*fpe_configure)(void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable); +void (*fpe_send_mpacket)(void __iomem *ioaddr, +enum stmmac_mpacket_type type); +int (*fpe_irq_status)(void __iomem *ioaddr,struct net_device *dev); }; #define stmmac_core_init(__priv, __args...) \
@@ -493,6 +496,10 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, est_configure, __args) #define stmmac_fpe_configure(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, fpe_configure, __args) +#define stmmac_fpe_send_mpacket(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args) +#define stmmac_fpe_irq_status(__priv, __args...) \ + stmmac_do_callback(__priv, mac, fpe_irq_status, __args)/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {
drivers/net/ethernet/stmicro/stmmac/stmmac.h +7 -0
@@ -234,6 +234,12 @@ struct stmmac_priv {struct workqueue_struct *wq;struct work_struct service_task; +/* Workqueue for handling FPE hand-shaking */ +unsigned long fpe_task_state; +struct workqueue_struct *fpe_wq; +struct work_struct fpe_task; +char wq_name[IFNAMSIZ +4 ]; +/* TC Handling */ unsigned int tc_entries_max;unsigned int tc_off_max;
@@ -272,6 +278,7 @@ void stmmac_disable_eee_mode(struct stmmac_priv *priv);bool stmmac_eee_init (struct stmmac_priv *priv);int stmmac_reinit_queues (struct net_device *dev,u32 rx_cnt,u32 tx_cnt);int stmmac_reinit_ringparam (struct net_device *dev,u32 rx_size,u32 tx_size); +void stmmac_fpe_handshake (struct stmmac_priv *priv,bool enable);#if IS_ENABLED (CONFIG_STMMAC_SELFTESTS ) void stmmac_selftest_run(struct net_device *dev,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +179 -0
253 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +21 -7
@@ -748,13 +748,10 @@ static int tc_setup_taprio(struct stmmac_priv *priv,if (fpe && !priv->dma_cap.fpesel)return -EOPNOTSUPP ; - ret =stmmac_fpe_configure (priv, priv->ioaddr, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, fpe); -if (ret && fpe) { -netdev_err (priv->dev,"failed to enable Frame Preemption\n" ); -return ret; - } +/* Actual FPE register configuration will be done after FPE handshake +* is success. +*/ + priv->plat->fpe_cfg.enable = fpe; ret =stmmac_est_configure (priv, priv->ioaddr, priv->plat->est, priv->plat->clk_ptp_rate);
@@ -764,12 +761,29 @@ static int tc_setup_taprio(struct stmmac_priv *priv, }netdev_info (priv->dev,"configured EST\n" ); + +if (fpe) { +stmmac_fpe_handshake (priv, true); +netdev_info (priv->dev,"start FPE handshake\n" ); + } +return 0 ; disable: priv->plat->est->enable = false;stmmac_est_configure (priv, priv->ioaddr, priv->plat->est, priv->plat->clk_ptp_rate); + + priv->plat->fpe_cfg.enable = false; +stmmac_fpe_configure (priv, priv->ioaddr, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false); +netdev_info (priv->dev,"disabled FPE\n" ); + +stmmac_fpe_handshake (priv, false); +netdev_info (priv->dev,"stop FPE handshake\n" ); +return ret; }
include/linux/stmmac.h +27 -0
@@ -143,6 +143,32 @@ struct stmmac_txq_cfg {int tbs_en; }; +/* FPE link state */ +enum stmmac_fpe_state { +FPE_STATE_OFF =0 , +FPE_STATE_CAPABLE =1 , +FPE_STATE_ENTERING_ON =2 , +FPE_STATE_ON =3 , +}; + +/* FPE link-partner hand-shaking mPacket type */ +enum stmmac_mpacket_type { +MPACKET_VERIFY =0 , +MPACKET_RESPONSE =1 , +}; + +enum stmmac_fpe_task_state_t { + __FPE_REMOVING, + __FPE_TASK_SCHED, +}; + +struct stmmac_fpe_cfg { +bool enable;/* FPE enable */ +bool hs_enable;/* FPE handshake enable */ +enum stmmac_fpe_state lp_fpe_state;/* Link Partner FPE state */ +enum stmmac_fpe_state lo_fpe_state;/* Local station FPE state */ +}; +struct plat_stmmacenet_data {int bus_id;int phy_addr;
@@ -154,6 +180,7 @@ struct plat_stmmacenet_data {struct device_node *mdio_node;struct stmmac_dma_cfg *dma_cfg;struct stmmac_est *est; +struct stmmac_fpe_cfg fpe_cfg;int clk_csr;int has_gmac;int enh_desc;
Signature · 1 line
2.17.1
kernel test robot
build botreproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross #…
Hi,
[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/mohammad-athari-ismail-intel-com/net-stmmac-support-FPE-link-partner-hand-shaking-procedure/20210310-120756 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git d310ec03a34e92a77302edb804f7d68ee4f01ba0 config: m68k-allmodconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/e50ee25914bd48b315d2d16e236ac23e63d2842b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review mohammad-athari-ismail-intel-com/net-stmmac-support-FPE-link-partner-hand-shaking-procedure/20210310-120756 git checkout e50ee25914bd48b315d2d16e236ac23e63d2842b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/err.h:5,
from include/linux/clk.h:12,
from drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:17:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: At top level:
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:925:6: warning: no previous prototype for 'stmmac_fpe_link_state_handle' [-Wmissing-prototypes]
925 | void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4167:6: warning: no previous prototype for 'stmmac_fpe_event_status' [-Wmissing-prototypes] 4167 | void stmmac_fpe_event_status(struct stmmac_priv *priv, int status)
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +/stmmac_fpe_link_state_handle +925 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
924
> 925 void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up)
926 {
927 struct stmmac_fpe_cfg *fpe_cfg = &priv->plat->fpe_cfg;
928 enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
929 enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
930 bool *hs_enable = &fpe_cfg->hs_enable;
931
932 if (is_up && *hs_enable) {
933 stmmac_fpe_send_mpacket(priv, priv->ioaddr, MPACKET_VERIFY);
934 } else {
935 *lo_state = FPE_EVENT_UNKNOWN;
936 *lp_state = FPE_EVENT_UNKNOWN;
937 }
938 }
939
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org