drivers/octeontx2: allow experimental symbols
Subsystems (2)
PATCH 1/5 drivers/octeontx2: allow experimental symbols
Multiple experimental symbols are used. They must be allowed to avoid compilation error.
--- drivers/common/octeontx2/Makefile | 2 ++ drivers/net/octeontx2/Makefile | 2 ++ drivers/raw/octeontx2_dma/Makefile | 2 ++ 3 files changed, 6 insertions(+)
drivers/common/octeontx2/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_common_octeontx2_version.map #
drivers/net/octeontx2/Makefile +2 -0
@@ -26,6 +26,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_pmd_octeontx2_version.map #
drivers/raw/octeontx2_dma/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_rawdev_octeontx2_dma_version.map #
Signature · 1 line
2.17.1
PATCH v3 2/5 eal: add API to check if its interrupt context
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
V3:
* Rebased patch on latest commit
V2:
* Removed unnecessary if statement
* Reworded subject line
* Updated return values of API
lib/librte_eal/common/include/rte_interrupts.h | 15 +++++++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 26 insertions(+)
lib/librte_eal/common/include/rte_interrupts.h +15 -0
@@ -138,6 +138,21 @@ int rte_intr_disable(const struct rte_intr_handle *intr_handle);__rte_experimental int rte_intr_ack(const struct rte_intr_handle *intr_handle); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Check if currently executing in interrupt context +* +* @return +* - positive in case of interrupt context +* - zero in case of process context +* - negative if unsuccessful +*/ +__rte_experimental +int +rte_thread_is_intr (void ); + #ifdef __cplusplus }#endif
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1487,3 +1487,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/rte_eal_version.map +1 -0
@@ -332,4 +332,5 @@ EXPERIMENTAL { # added in 19.11 rte_log_get_stream; rte_mcfg_get_single_file_segments; + rte_thread_is_intr; };
Signature · 1 line
2.17.1
PATCH 3/5 common/octeontx2: add interrupt offset to mbox structure
In reply to Sunil Kumar Korimbox response are triggered at bar2 + RVU_PF_INT or bar2 + RVU_VF_INT, depending upon the device. To process these interrupts different irq handlers are installed. To unify it, added offset field into mbox structure which is initialized with RVU_PF_INT or RVU_VF_INT at the time of otx2_mbox_init.
--- drivers/common/octeontx2/otx2_dev.c | 14 ++++++++++---- drivers/common/octeontx2/otx2_mbox.c | 5 +++-- drivers/common/octeontx2/otx2_mbox.h | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-)
drivers/common/octeontx2/otx2_dev.c +10 -4
@@ -900,6 +900,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +925,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +971,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +3 -2
@@ -59,12 +59,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int -otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs) +otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevs,uint64_t intr_offset) {struct otx2_mbox_dev *mdev;int devid; + mbox->intr_offset = intr_offset; mbox->reg_base = reg_base; mbox->hwbase = hwbase;
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
PATCH 4/5 common/octeontx2: add polling based response mbox message
In reply to Sunil Kumar KoriCurrently otx2_mbox_get_rsp get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
--- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++ drivers/common/octeontx2/otx2_mbox.h | 7 +++ .../rte_common_octeontx2_version.map | 7 +++ 3 files changed, 72 insertions(+)
drivers/common/octeontx2/otx2_mbox.c +58 -0
@@ -11,6 +11,7 @@#include <rte_cycles.h> #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000)#define RVU_AF_AFPF_MBOX1 (0x02008)
@@ -245,6 +246,63 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)return msghdr->rc; } +/** +* @internal +* Polling for given wait time to get mailbox response +*/ +int +otx2_mbox_get_rsp_poll_tmo (struct otx2_mbox *mbox,int devid,void **msg, +uint32_t wait) +{ +struct otx2_mbox_dev *mdev = &mbox->dev[devid]; +uint32_t timeout =0 , sleep =1 ; +struct mbox_msghdr *msghdr; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; +uint64_t offset; + +rte_rmb (); + + offset = mbox->rx_start + +RTE_ALIGN (sizeof (struct mbox_hdr ),MBOX_MSG_ALIGN ); + msghdr = (struct mbox_msghdr *)((uintptr_t )mdev->mbase + offset); + + reg_addr = mbox->reg_base + mbox->intr_offset; +while (!rsp_reg) { +rte_rmb (); + rsp_reg =otx2_read64 (reg_addr); + +if (timeout >= wait) +return -ETIMEDOUT ; + +rte_delay_ms (sleep); + timeout += sleep; + } + +if (msg !=NULL ) + *msg = msghdr; + +/* Clear interrupt */ +otx2_write64 (rsp_reg, reg_addr); + +/* Reset mbox */ +otx2_mbox_reset (mbox,0 ); + +return msghdr->rc; +} + +/** +* @internal +* Polling for 5 seconds to get mailbox response +*/ +int +otx2_mbox_get_rsp_poll (struct otx2_mbox *mbox,int devid,void **msg) +{ +uint32_t wait =5 *MS_PER_S ;/* 5 Seconds */ + +return otx2_mbox_get_rsp_poll_tmo (mbox, devid, msg, wait); +} +/** * @internal * Wait and get mailbox response with timeout
drivers/common/octeontx2/otx2_mbox.h +7 -0
@@ -1570,6 +1570,13 @@ void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp_tmo (struct otx2_mbox *mbox,int devid,uint32_t tmo);int otx2_mbox_get_rsp (struct otx2_mbox *mbox,int devid,void **msg); + +__rte_experimental +int otx2_mbox_get_rsp_poll(struct otx2_mbox *mbox, int devid, void **msg); +__rte_experimental +int otx2_mbox_get_rsp_poll_tmo(struct otx2_mbox *mbox, int devid, void **msg, +uint32_t tmo); +int otx2_mbox_get_rsp_tmo (struct otx2_mbox *mbox,int devid,void **msg,uint32_t tmo);int otx2_mbox_get_availmem (struct otx2_mbox *mbox,int devid);
drivers/common/octeontx2/rte_common_octeontx2_version.map +7 -0
@@ -33,3 +33,10 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + otx2_mbox_get_rsp_poll; + otx2_mbox_get_rsp_poll_tmo; +};
Signature · 1 line
2.17.1
PATCH 5/5 common/octeontx2: enhancing mbox APIs to get response
In reply to Sunil Kumar KoriBased on thread context, mbox API will get response for submitted request. If thread runs in interrupt context then it uses polling based get response API otherwise interrupt based.
--- drivers/common/octeontx2/otx2_dev.c | 27 ++++++++++++--------------- drivers/common/octeontx2/otx2_mbox.h | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 19 deletions(-)
drivers/common/octeontx2/otx2_dev.c +12 -15
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
drivers/common/octeontx2/otx2_mbox.h +17 -4
@@ -9,6 +9,7 @@#include <stdbool.h> #include <rte_ether.h> +#include <rte_interrupts.h> #include <rte_spinlock.h> #include <otx2_common.h>
@@ -1627,28 +1628,40 @@ static inline int otx2_mbox_process(struct otx2_mbox *mbox) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp (mbox,0 ,NULL ); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll (mbox,0 ,NULL ); +else +return otx2_mbox_get_rsp (mbox,0 ,NULL ); }static inline int otx2_mbox_process_msg (struct otx2_mbox *mbox,void **msg) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp (mbox,0 , msg); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll (mbox,0 , msg); +else +return otx2_mbox_get_rsp (mbox,0 , msg); }static inline int otx2_mbox_process_tmo (struct otx2_mbox *mbox,uint32_t tmo) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp_tmo (mbox,0 ,NULL , tmo); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll_tmo (mbox,0 ,NULL , tmo); +else +return otx2_mbox_get_rsp_tmo (mbox,0 ,NULL , tmo); }static inline int otx2_mbox_process_msg_tmo (struct otx2_mbox *mbox,void **msg,uint32_t tmo) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp_tmo (mbox,0 , msg, tmo); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll_tmo (mbox,0 , msg, tmo); +else +return otx2_mbox_get_rsp_tmo (mbox,0 , msg, tmo); }int otx2_send_ready_msg (struct otx2_mbox *mbox,uint16_t *pf_func/* out */ );
Signature · 1 line
2.17.1
PATCH v2 1/5 drivers/octeontx2: allow experimental symbols
In reply to Sunil Kumar KoriMultiple experimental symbols are used. They must be allowed to avoid compilation error.
--- drivers/common/octeontx2/Makefile | 2 ++ drivers/common/octeontx2/meson.build | 2 ++ drivers/net/octeontx2/Makefile | 2 ++ drivers/net/octeontx2/meson.build | 2 ++ drivers/raw/octeontx2_dma/Makefile | 2 ++ drivers/raw/octeontx2_dma/meson.build | 2 ++ 6 files changed, 12 insertions(+)
drivers/common/octeontx2/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_common_octeontx2_version.map #
drivers/common/octeontx2/meson.build +2 -0
@@ -8,6 +8,8 @@ sources= files('otx2_dev.c', 'otx2_common.c', ) +allow_experimental_apis = true + extra_flags = [] # This integrated controller runs only on a arm64 machine, remove 32bit warnings if not dpdk_conf.get('RTE_ARCH_64')
drivers/net/octeontx2/Makefile +2 -0
@@ -26,6 +26,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_pmd_octeontx2_version.map #
drivers/net/octeontx2/meson.build +2 -0
@@ -24,6 +24,8 @@ sources = files('otx2_rx.c', 'otx2_ethdev_devargs.c' ) +allow_experimental_apis = true + deps += ['bus_pci', 'common_octeontx2', 'mempool_octeontx2'] cflags += ['-flax-vector-conversions']
drivers/raw/octeontx2_dma/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_rawdev_octeontx2_dma_version.map #
drivers/raw/octeontx2_dma/meson.build +2 -0
@@ -5,6 +5,8 @@ deps += ['bus_pci', 'common_octeontx2', 'rawdev'] sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c', 'otx2_dpi_test.c') +allow_experimental_apis = true + extra_flags = [] # This integrated controller runs only on a arm64 machine, remove 32bit warnings if not dpdk_conf.get('RTE_ARCH_64')
Signature · 1 line
2.17.1
26/11/2019 07:15, Sunil Kumar Kori:
Quoted 2 lines
Multiple experimental symbols are used. They must be allowed to avoid compilation error.
If there was an error,
1/ I would see it in my compilation test
2/ There would be some "Fixes:" tag to point the root cause
I guess this patch is not critical. Where are patches 2, 3, 4, 5?
Quoted 10 lines
Signed-off-by Sunil Kumar Kori <[email protected]>--- drivers/common/octeontx2/Makefile | 2 ++ drivers/common/octeontx2/meson.build | 2 ++ drivers/net/octeontx2/Makefile | 2 ++ drivers/net/octeontx2/meson.build | 2 ++ drivers/raw/octeontx2_dma/Makefile | 2 ++ drivers/raw/octeontx2_dma/meson.build | 2 ++ 6 files changed, 12 insertions(+)
Regards
Sunil Kumar Kori
Quoted 15 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, November 26, 2019 9:51 PM
To: [email protected]
Cc: Sunil Kumar Kori <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH v2 1/5]drivers/octeontx2: allow experimental symbolsExternal Email
Quoted 8 lines
----------------------------------------------------------------------
26/11/2019 07:15, Sunil Kumar Kori:Quoted 2 lines
Multiple experimental symbols are used. They must be allowed to avoid compilation error.
If there was an error,
1/ I would see it in my compilation test 2/ There would be some "Fixes:" tag to point the root cause
Actually change is part of below series which is started using experimental symbols in mentioned driver. Apart of these drivers, FLAGs are already present in other drivers so that there is no error found. Error occurs when applying below series.
So I had two options to get it done. Either I can do Makefile changes along with the corresponding changes or make them as a separate patch. I have chosen second option.
And because of this is new change, it does not contain any "Fixes" tag.
Quoted 3 lines
I guess this patch is not critical.
Where are patches 2, 3, 4, 5?
Following are the series of patches:
http://patches.dpdk.org/patch/63299/
http://patches.dpdk.org/patch/63271/
http://patches.dpdk.org/patch/63272/
http://patches.dpdk.org/patch/63273/
http://patches.dpdk.org/patch/63274/
Not all the patches are reworked for next versions that's why same is not reflected in subject line.
Quoted 13 lines
Quoted 11 lines
Signed-off-by Sunil Kumar Kori <[email protected]>--- drivers/common/octeontx2/Makefile | 2 ++ drivers/common/octeontx2/meson.build | 2 ++ drivers/net/octeontx2/Makefile | 2 ++ drivers/net/octeontx2/meson.build | 2 ++ drivers/raw/octeontx2_dma/Makefile | 2 ++ drivers/raw/octeontx2_dma/meson.build | 2 ++ 6 files changed, 12 insertions(+)
27/11/2019 09:34, Sunil Kumar Kori:
Quoted 9 lines
From: Thomas Monjalon <[email protected]>
Quoted 7 lines
26/11/2019 07:15, Sunil Kumar Kori:
Quoted 2 lines
Multiple experimental symbols are used. They must be allowed to avoid compilation error.
If there was an error,
1/ I would see it in my compilation test 2/ There would be some "Fixes:" tag to point the root cause
Quoted 6 lines
Actually change is part of below series which is started using experimental symbols in mentioned driver. Apart of these drivers, FLAGs are already present in other drivers so that there is no error found. Error occurs when applying below series.
So I had two options to get it done. Either I can do
Makefilechanges along with the corresponding changes or make them as a separate patch. I have chosen second option.
This is the wrong choice :)
When you do a change, it should be atomic, i.e. includes changes which are dependent.
Quoted 11 lines
And because of this is new change, it does not contain any "Fixes" tag.
Quoted 3 lines
I guess this patch is not critical.
Where are patches 2, 3, 4, 5?Following are the series of patches:
http://patches.dpdk.org/patch/63299/
http://patches.dpdk.org/patch/63271/
http://patches.dpdk.org/patch/63272/
http://patches.dpdk.org/patch/63273/
http://patches.dpdk.org/patch/63274/
Not all the patches are reworked for next versions that's why same is not reflected in subject line.
When you send a new version, you should send the whole series again. And please don't forget changelogs and --in-reply-to.
Thanks
PATCH v2 1/4 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriAdded an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_interrupts.h | 15 +++++++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 26 insertions(+)
lib/librte_eal/common/include/rte_interrupts.h +15 -0
@@ -138,6 +138,21 @@ int rte_intr_disable(const struct rte_intr_handle *intr_handle);__rte_experimental int rte_intr_ack(const struct rte_intr_handle *intr_handle); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Check if currently executing in interrupt context +* +* @return +* - positive in case of interrupt context +* - zero in case of process context +* - negative if unsuccessful +*/ +__rte_experimental +int +rte_thread_is_intr (void ); + #ifdef __cplusplus }#endif
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1487,3 +1487,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/rte_eal_version.map +1 -0
@@ -332,4 +332,5 @@ EXPERIMENTAL { # added in 19.11 rte_log_get_stream; rte_mcfg_get_single_file_segments; + rte_thread_is_intr; };
Signature · 1 line
2.17.1
PATCH v2 2/4 common/octeontx2: add interrupt offset to mbox structure
mbox response are triggered at bar2 + RVU_PF_INT or bar2 + RVU_VF_INT, depending upon the device. To process these interrupts different irq handlers are installed. To unify it, added offset field into mbox structure which is initialized with RVU_PF_INT or RVU_VF_INT at the time of otx2_mbox_init.
---
v2:
* Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 14 ++++++++++---- drivers/common/octeontx2/otx2_mbox.c | 5 +++-- drivers/common/octeontx2/otx2_mbox.h | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-)
drivers/common/octeontx2/otx2_dev.c +10 -4
@@ -900,6 +900,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +925,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +971,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +3 -2
@@ -59,12 +59,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int -otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs) +otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevs,uint64_t intr_offset) {struct otx2_mbox_dev *mdev;int devid; + mbox->intr_offset = intr_offset; mbox->reg_base = reg_base; mbox->hwbase = hwbase;
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
PATCH v2 3/4 common/octeontx2: add polling based response mbox message
In reply to Sunil Kumar KoriCurrently otx2_mbox_get_rsp get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/Makefile | 2 + drivers/common/octeontx2/meson.build | 2 + drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++ drivers/common/octeontx2/otx2_mbox.h | 7 +++ .../rte_common_octeontx2_version.map | 7 +++ 5 files changed, 76 insertions(+)
drivers/common/octeontx2/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_common_octeontx2_version.map #
drivers/common/octeontx2/meson.build +2 -0
@@ -8,6 +8,8 @@ sources= files('otx2_dev.c', 'otx2_common.c', ) +allow_experimental_apis = true + extra_flags = [] # This integrated controller runs only on a arm64 machine, remove 32bit warnings if not dpdk_conf.get('RTE_ARCH_64')
drivers/common/octeontx2/otx2_mbox.c +58 -0
70 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +7 -0
@@ -1570,6 +1570,13 @@ void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp_tmo (struct otx2_mbox *mbox,int devid,uint32_t tmo);int otx2_mbox_get_rsp (struct otx2_mbox *mbox,int devid,void **msg); + +__rte_experimental +int otx2_mbox_get_rsp_poll(struct otx2_mbox *mbox, int devid, void **msg); +__rte_experimental +int otx2_mbox_get_rsp_poll_tmo(struct otx2_mbox *mbox, int devid, void **msg, +uint32_t tmo); +int otx2_mbox_get_rsp_tmo (struct otx2_mbox *mbox,int devid,void **msg,uint32_t tmo);int otx2_mbox_get_availmem (struct otx2_mbox *mbox,int devid);
drivers/common/octeontx2/rte_common_octeontx2_version.map +7 -0
@@ -33,3 +33,10 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + otx2_mbox_get_rsp_poll; + otx2_mbox_get_rsp_poll_tmo; +};
Signature · 1 line
2.17.1
PATCH v2 4/4 drivers/octeontx2: enhancing mbox APIs to get response
In reply to Sunil Kumar KoriBased on thread context, mbox API will get response for submitted request. If thread runs in interrupt context then it uses polling based get response API otherwise interrupt based.
---
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 27 ++++++++++++--------------- drivers/common/octeontx2/otx2_mbox.h | 21 +++++++++++++++++---- drivers/net/octeontx2/Makefile | 2 ++ drivers/net/octeontx2/meson.build | 2 ++ drivers/raw/octeontx2_dma/Makefile | 2 ++ drivers/raw/octeontx2_dma/meson.build | 2 ++ 6 files changed, 37 insertions(+), 19 deletions(-)
drivers/common/octeontx2/otx2_dev.c +12 -15
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
drivers/common/octeontx2/otx2_mbox.h +17 -4
@@ -9,6 +9,7 @@#include <stdbool.h> #include <rte_ether.h> +#include <rte_interrupts.h> #include <rte_spinlock.h> #include <otx2_common.h>
@@ -1627,28 +1628,40 @@ static inline int otx2_mbox_process(struct otx2_mbox *mbox) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp (mbox,0 ,NULL ); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll (mbox,0 ,NULL ); +else +return otx2_mbox_get_rsp (mbox,0 ,NULL ); }static inline int otx2_mbox_process_msg (struct otx2_mbox *mbox,void **msg) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp (mbox,0 , msg); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll (mbox,0 , msg); +else +return otx2_mbox_get_rsp (mbox,0 , msg); }static inline int otx2_mbox_process_tmo (struct otx2_mbox *mbox,uint32_t tmo) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp_tmo (mbox,0 ,NULL , tmo); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll_tmo (mbox,0 ,NULL , tmo); +else +return otx2_mbox_get_rsp_tmo (mbox,0 ,NULL , tmo); }static inline int otx2_mbox_process_msg_tmo (struct otx2_mbox *mbox,void **msg,uint32_t tmo) {otx2_mbox_msg_send (mbox,0 ); -return otx2_mbox_get_rsp_tmo (mbox,0 , msg, tmo); +if (rte_thread_is_intr ()) +return otx2_mbox_get_rsp_poll_tmo (mbox,0 , msg, tmo); +else +return otx2_mbox_get_rsp_tmo (mbox,0 , msg, tmo); }int otx2_send_ready_msg (struct otx2_mbox *mbox,uint16_t *pf_func/* out */ );
drivers/net/octeontx2/Makefile +2 -0
@@ -26,6 +26,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_pmd_octeontx2_version.map #
drivers/net/octeontx2/meson.build +2 -0
@@ -24,6 +24,8 @@ sources = files('otx2_rx.c', 'otx2_ethdev_devargs.c' ) +allow_experimental_apis = true + deps += ['bus_pci', 'common_octeontx2', 'mempool_octeontx2'] cflags += ['-flax-vector-conversions']
drivers/raw/octeontx2_dma/Makefile +2 -0
@@ -22,6 +22,8 @@ CFLAGS += -diag-disable 2259 endif endif +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_rawdev_octeontx2_dma_version.map #
drivers/raw/octeontx2_dma/meson.build +2 -0
@@ -5,6 +5,8 @@ deps += ['bus_pci', 'common_octeontx2', 'rawdev'] sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c', 'otx2_dpi_test.c') +allow_experimental_apis = true + extra_flags = [] # This integrated controller runs only on a arm64 machine, remove 32bit warnings if not dpdk_conf.get('RTE_ARCH_64')
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 1/4] eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriQuoted 5 lines · On Wed, 27 Nov 2019 15:52:19 +0530 Sunil Kumar Kori <[email protected]> wrote:
lib/librte_eal/common/include/rte_interrupts.h +4
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +*
lib/librte_eal/common/include/rte_interrupts.h int rte_intr_disable(const struct rte_intr_handle *intr_handle); · line 154
Quoted 10 lines
lib/librte_eal/common/include/rte_interrupts.h +10
-0+* Check if currently executing in interrupt context +* +* @return +* - positive in case of interrupt context +* - zero in case of process context +* - negative if unsuccessful +*/ +__rte_experimental +int +rte_thread_is_intr (void );
If you only need this in drivers, it should be internal not exposed as part of API
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/4] eal: add API to check if its interrupt context
Quoted 16 lines · Stephen Hemminger
External Email
----------------------------------------------------------------------
Quoted 10 lines · On Wed, 27 Nov 2019 15:52:19 +0530 Sunil Kumar Kori <[email protected]> wrote:
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ * - positive in case of interrupt context
+ * - zero in case of process context
Quoted 8 lines
lib/librte_eal/common/include/rte_interrupts.h int rte_intr_disable(const struct rte_intr_handle *intr_handle); · line 154
Quoted 5 lines
+ * - negative if unsuccessful
+ */lib/librte_eal/common/include/rte_interrupts.h +3
-0+__rte_experimental +int +rte_thread_is_intr (void );If you only need this in drivers, it should be internal not exposed as part of API
Sorry, but can you please help me understand the query. Do you mean:
* Since "rte_thread_is_intr" would be used only used by libraries/drivers and not by any external application, rather having it in "rte_interrupt.h", we should have it in some internal header file like "eal_private.h" ??
ANS - Yes we can do that but since all other related APIs like "rte_intr_ack", "rte_intr_enable/disable" which are also used by drivers/lib and not application, are prototyped in "rte_interupt.h".
OR do u mean
* Since only octeontx2 driver is using this, why it is exposed as an API rather it should be defined as some driver internal function ??
ANS - "rte_thread_is_intr" is an counter part of "in_interrupt()" in DPDK, which will return whether the current execution is in interrupt context. This helps in dealing with nested interrupts case. We faced a similar case while handling hotplug probing initiated via secondary process.
We believe this API could be very useful for many drivers which might end up in handling nested interrupts case.
Thanks
Harman
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/4] eal: add API to check if its interrupt context
Quoted 48 lines · On Thu, 28 Nov 2019 08:10:23 +0000 Harman Kalra <[email protected]> wrote:
Quoted 16 lines · Stephen Hemminger
External Email
----------------------------------------------------------------------
Quoted 10 lines · On Wed, 27 Nov 2019 15:52:19 +0530 Sunil Kumar Kori <[email protected]> wrote:
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ * - positive in case of interrupt context
+ * - zero in case of process contextQuoted 8 lines
lib/librte_eal/common/include/rte_interrupts.h int rte_intr_disable(const struct rte_intr_handle *intr_handle); · line 154
Quoted 5 lines
+ * - negative if unsuccessful
+ */lib/librte_eal/common/include/rte_interrupts.h +3
-0+__rte_experimental +int +rte_thread_is_intr (void );If you only need this in drivers, it should be internal not exposed as part of API
Sorry, but can you please help me understand the query. Do you mean:
* Since "rte_thread_is_intr" would be used only used by libraries/drivers and not by any external application, rather having it in "rte_interrupt.h", we should have it in some internal header file like "eal_private.h" ??ANS - Yes we can do that but since all other related APIs like "
rte_intr_ack", "rte_intr_enable/disable" which are also used bydrivers/liband not application, are prototyped in "rte_interupt.h".OR do u mean
* Since only octeontx2 driver is using this, why it is exposed as an API rather it should be defined as some driver internal function ??ANS - "
rte_thread_is_intr" is an counter part of "in_interrupt()" in DPDK, which will return whether the current execution is in interrupt context. This helps in dealing with nested interrupts case. We faced a similar case while handling hotplug probing initiated via secondary process.
We believe this API could be very useful for many drivers which might end up in handling nested interrupts case.
Quoted 2 lines
Thanks
Harman
What I meant was that some functions in EAL are documented as being internal (flagged with @internal) and don't show up in the documented API.
My concern is that if we make this part of the public API, it makes it harder to change structural things like the interrupt thread later. The interrupt thread is already problematic for several other usages.
Re: [dpdk-dev] [EXT] Re: [PATCH v2 1/4] eal: add API to check if its interrupt context
Quoted 54 lines · Stephen Hemminger
Quoted 48 lines · On Thu, 28 Nov 2019 08:10:23 +0000 Harman Kalra <[email protected]> wrote:
Quoted 16 lines · Stephen Hemminger
External Email
----------------------------------------------------------------------
Quoted 10 lines · On Wed, 27 Nov 2019 15:52:19 +0530 Sunil Kumar Kori <[email protected]> wrote:
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ * - positive in case of interrupt context
+ * - zero in case of process contextQuoted 8 lines
lib/librte_eal/common/include/rte_interrupts.h int rte_intr_disable(const struct rte_intr_handle *intr_handle); · line 154
Quoted 5 lines
+ * - negative if unsuccessful
+ */lib/librte_eal/common/include/rte_interrupts.h +3
-0+__rte_experimental +int +rte_thread_is_intr (void );If you only need this in drivers, it should be internal not exposed as part of API
Sorry, but can you please help me understand the query. Do you mean:
* Since "rte_thread_is_intr" would be used only used by libraries/drivers and not by any external application, rather having it in "rte_interrupt.h", we should have it in some internal header file like "eal_private.h" ??ANS - Yes we can do that but since all other related APIs like "
rte_intr_ack", "rte_intr_enable/disable" which are also used bydrivers/liband not application, are prototyped in "rte_interupt.h".OR do u mean
* Since only octeontx2 driver is using this, why it is exposed as an API rather it should be defined as some driver internal function ??ANS - "
rte_thread_is_intr" is an counter part of "in_interrupt()" in DPDK, which will return whether the current execution is in interrupt context. This helps in dealing with nested interrupts case. We faced a similar case while handling hotplug probing initiated via secondary process.
We believe this API could be very useful for many drivers which might end up in handling nested interrupts case.Quoted 2 lines
Thanks
Harman
Quoted 9 lines
What I meant was that some functions in EAL are documented as being internal (flagged with @internal) and don't show up in the documented API.
My concern is that if we make this part of the public API, it makes it harder to change structural things like the interrupt thread later. The interrupt thread is already problematic for several other usages.
I think now I understood your point, I will move prototype of this API to "common/include/rte_eal_interrupts.h", flag it as @internal and resend next version. I think this file was created for such APIs only as its description says.
/**
* @file rte_eal_interrupts.h
* @internal
*
* Contains function prototypes exposed by the EAL for interrupt handling by
* drivers and other DPDK internal consumers.
*/
Thanks
Harman
PATCH v3 1/2 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriFrom: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ 3 files changed, 21 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
Signature · 1 line
2.17.1
PATCH v3 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 ++++++++++---------- drivers/common/octeontx2/otx2_mbox.c | 57 +++++++++++++++++++++++----- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 72 insertions(+), 31 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +47 -10
98 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 2/2] common/octeontx2: add polling based response mbox message
Hi Sunil,
Quoted 196 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Sunil Kumar Kori
Sent: Monday, December 16, 2019 6:40 PM
To: [email protected]; Nithin Dabilpuram <[email protected]>; Vamsi Attunuru <[email protected]>
Cc: [email protected]; Sunil Kumar Kori <[email protected]>; Harman Kalra <[email protected]>
Subject: [dpdk-dev] [PATCH v3 2/2] common/octeontx2: add polling based response mbox messageCurrently
otx2_mbox_get_rsp_xxxget response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
Signed-off-by Sunil Kumar Kori <[email protected]>Signed-off-by Harman Kalra <[email protected]>---
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- IncludedMakefileand meson build changes.
- Rebased patch on 19.11-rc4drivers/common/octeontx2/otx2_dev.c | 41 ++++++++++---------- drivers/common/octeontx2/otx2_mbox.c | 57 +++++++++++++++++++++++--- -- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 72 insertions(+), 31 deletions(-)drivers/common/octeontx2/otx2_dev.c +6
-7@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static void
drivers/common/octeontx2/otx2_dev.c +6
-8@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static int
drivers/common/octeontx2/otx2_dev.c +1
-0@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;drivers/common/octeontx2/otx2_dev.c +8
-4uint64_t bar4_addr;@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) if (otx2_dev_is_vf(dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev- >max_vfs); + bar2, MBOX_DIR_PFVF_UP, pci_dev-Quoted 1 line
max_vfs,drivers/common/octeontx2/otx2_dev.c +1
-0+ intr_offset);if (rc) goto mbox_fini; }drivers/common/octeontx2/otx2_mbox.c +8
-4@@ -11,6 +11,7 @@#include <rte_cycles.h> #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000)#define RVU_AF_AFPF_MBOX1 (0x02008)@@ -59,12 +60,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int -otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs) +otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevs,uint64_t intr_offset) {struct otx2_mbox_dev *mdev;int devid; + mbox->intr_offset = intr_offset; mbox->reg_base = reg_base; mbox->hwbase = hwbase;@@ -230,8 +232,8 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)int rc; rc =otx2_mbox_wait_for_rsp (mbox, devid); -if (rc !=1 ) -return -EIO ; +if (rc <0 ) +return rc;rte_rmb ();@@ -244,6 +246,37 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)return msghdr->rc; } +/** +* Polling for given wait time to get mailbox response
drivers/common/octeontx2/otx2_mbox.c otx2_mbox_get_rsp(struct otx2_mbox *mbox, int · line 261
Quoted 10 lines
drivers/common/octeontx2/otx2_mbox.c +10
-0+*/ +static int +mbox_poll (struct otx2_mbox *mbox,uint32_t wait) +{ +uint32_t timeout =0 , sleep =1 ; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; +while (!rsp_reg) {
The first iteration of (!rsp_reg) always evaluate to 'true'. Why not use do .. while to save one iteration?
drivers/common/octeontx2/otx2_mbox.c otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg) · line 261
Quoted 1 line
drivers/common/octeontx2/otx2_mbox.c +1
-0+rte_rmb ();
Rte_rmb is overkill, how is reg_addr mapped(what is the memory attribute? WC? cacheable? )
If it is a PCI mmaped region, then rte_io_barrier is okay, I am proposing to relax the io barrier for aarch64 as a compiler barrier.
http://patches.dpdk.org/patch/61662/
Quoted 81 lines
drivers/common/octeontx2/otx2_mbox.c +18
-0+ rsp_reg =otx2_read64 (reg_addr); + +if (timeout >= wait) +return -ETIMEDOUT ; + +rte_delay_us (sleep); + timeout += sleep; + } + +/* Clear interrupt */ +otx2_write64 (rsp_reg, reg_addr); + +/* Reset mbox */ +otx2_mbox_reset (mbox,0 ); + +return 0 ; +} +/** * @internal * Wait and get mailbox response with timeout
drivers/common/octeontx2/otx2_mbox.c +10
-6@@ -258,8 +291,8 @@ otx2_mbox_get_rsp_tmo(struct otx2_mbox *mbox, int devid, void **msg, int rc; rc =otx2_mbox_wait_for_rsp_tmo (mbox, devid, tmo); -if (rc !=1 ) -return -EIO ; +if (rc <0 ) +return rc;rte_rmb ();@@ -321,11 +354,15 @@ otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo) }/* Wait message */ - rc =mbox_wait (mbox, devid, tmo); -if (rc) -return rc; +if (rte_thread_is_intr ()) { + rc =mbox_poll (mbox, tmo); + }else { + rc =mbox_wait (mbox, devid, tmo); +if (!rc) + rc = mdev->msgs_acked; + } -return mdev->msgs_acked; +return rc; }/**
drivers/common/octeontx2/otx2_mbox.h +3
-2@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */ @@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int
otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
--
2.17.1
Re: [dpdk-dev] [PATCH v3 2/2] common/octeontx2: add polling based response mbox message
Quoted 10 lines
drivers/common/octeontx2/otx2_mbox.c otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg) · line 260
Quoted 8 lines
drivers/common/octeontx2/otx2_mbox.c +8
-0+mbox_poll(struct otx2_mbox *mbox, uint32_t wait) +{ + uint32_t timeout = 0, sleep = 1; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; +while (!rsp_reg) {The first iteration of (!rsp_reg) always evaluate to 'true'. Why not use do .. while to save one iteration?
Quoted 4 lines
Quoted 1 line
+
rte_rmb();
Rte_rmbis overkill, how isreg_addrmapped(what is the memory attribute? WC? cacheable? )
If it is a PCI mmaped region, thenrte_io_barrieris okay, I am proposing to relax the io barrier for aarch64 as a compiler barrier.
http://patches.dpdk.org/patch/61662/
It is the device memory and Linux kernel(_CPU_ not IO) is updating the memory on the other side. I think,
we would need rte_smp_rmb() here. Since it was slow-path code, added the full barrier here.
I think it is OK to change rte_smp_rmb() not to rte_io_* version. Correct?
Re: [dpdk-dev] [PATCH v3 2/2] common/octeontx2: add polling based response mbox message
Hi Jerin,
Quoted 26 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Tuesday, December 17, 2019 7:14 PM
To: Gavin Hu <[email protected]>
Cc: Sunil Kumar Kori <[email protected]>; [email protected]; Nithin Dabilpuram <[email protected]>; Vamsi Attunuru <[email protected]>; [email protected]; Harman Kalra <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 2/2] common/octeontx2: add polling based response mbox messageQuoted 10 lines
drivers/common/octeontx2/otx2_mbox.c otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg) · line 260
Quoted 8 lines
drivers/common/octeontx2/otx2_mbox.c +8
-0+mbox_poll(struct otx2_mbox *mbox, uint32_t wait) +{ + uint32_t timeout = 0, sleep = 1; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; +while (!rsp_reg) {The first iteration of (!rsp_reg) always evaluate to 'true'. Why not use do .. while to save one iteration?
Quoted 2 lines
Quoted 1 line
+
rte_rmb();
Rte_rmbis overkill, how isreg_addrmapped(what is the memory attribute?WC? cacheable? )
Quoted 1 line
If it is a PCI mmaped region, then
rte_io_barrieris okay, I am proposing to
Quoted 8 lines
relax the io barrier for aarch64 as a compiler barrier.
Quoted 1 line
It is the device memory and Linux
kernel(_CPU_ not IO)is updating the memory on the other side. I think,
we would needrte_smp_rmb()here. Since it was slow-path code, added the full barrier here.
I think it is OK to changerte_smp_rmb()not to rte_io_* version. Correct?
I want to summarize as follows:
rte_io_* should be used in this case as it is the device memory.
rte_smp_* is for normal memory, including DMA buffer resides in the normal memory and updated by devices.
Rte_cio_* should be used for ordering between normal memory and device memory, for example, updates to descriptors in the normal memory and a doorbell write.
PATCH v4 1/2 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriFrom: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ 3 files changed, 21 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
Signature · 1 line
2.17.1
PATCH v4 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v4:
- used rte_io_rmb instead of rte_rmb in mbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++--------- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++++++----- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 73 insertions(+), 31 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +48 -10
99 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
PATCH v4 1/2 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriFrom: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ 3 files changed, 21 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
Signature · 1 line
2.17.1
PATCH v4 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v4:
- used rte_io_rmb instead of rte_rmb in mbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++--------- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++++++----- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 73 insertions(+), 31 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +48 -10
99 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v4 2/2] common/octeontx2: add polling based response mbox message
Hi Sunil,
Quoted 200 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Sunil Kumar Kori
Sent: Wednesday, December 18, 2019 12:53 AM
To: [email protected]; Nithin Dabilpuram <[email protected]>; Vamsi Attunuru <[email protected]>
Cc: [email protected]; Sunil Kumar Kori <[email protected]>; Harman Kalra <[email protected]>
Subject: [dpdk-dev] [PATCH v4 2/2] common/octeontx2: add polling based response mbox messageCurrently
otx2_mbox_get_rsp_xxxget response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
Signed-off-by Sunil Kumar Kori <[email protected]>Signed-off-by Harman Kalra <[email protected]>---
v4:
- usedrte_io_rmbinstead ofrte_rmbinmbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- IncludedMakefileand meson build changes.
- Rebased patch on 19.11-rc4drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++--------- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++++++--- -- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 73 insertions(+), 31 deletions(-)drivers/common/octeontx2/otx2_dev.c +6
-7@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static void
drivers/common/octeontx2/otx2_dev.c +6
-8@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static int
drivers/common/octeontx2/otx2_dev.c +1
-0@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;drivers/common/octeontx2/otx2_dev.c +8
-4uint64_t bar4_addr;@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) if (otx2_dev_is_vf(dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev- >max_vfs); + bar2, MBOX_DIR_PFVF_UP, pci_dev-Quoted 1 line
max_vfs,drivers/common/octeontx2/otx2_dev.c +1
-0+ intr_offset);if (rc) goto mbox_fini; }drivers/common/octeontx2/otx2_mbox.c +10
-4@@ -11,6 +11,7 @@#include <rte_cycles.h> #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000)#define RVU_AF_AFPF_MBOX1 (0x02008)@@ -59,12 +60,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int -otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs) +otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevs,uint64_t intr_offset) {struct otx2_mbox_dev *mdev;int devid; + mbox->intr_offset = intr_offset; mbox->reg_base = reg_base; mbox->hwbase = hwbase;@@ -230,8 +232,8 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)int rc; rc =otx2_mbox_wait_for_rsp (mbox, devid); -if (rc !=1 ) -return -EIO ; +if (rc <0 ) +return rc;rte_rmb ();@@ -244,6 +246,38 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)return msghdr->rc; } +/** +* Polling for given wait time to get mailbox response +*/ +static int
drivers/common/octeontx2/otx2_mbox.c otx2_mbox_get_rsp(struct otx2_mbox *mbox, int · line 263
Quoted 10 lines
drivers/common/octeontx2/otx2_mbox.c +10
-0+mbox_poll(struct otx2_mbox *mbox, uint32_t wait) +{ + uint32_t timeout = 0, sleep = 1; +uint32_t wait_us = wait *1000 ; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; + do { + rte_smp_rmb();
Device memory is not within the inner sharable domain, here rte_io_rmb should be used. More details are explained in the v3 thread.
Quoted 81 lines
drivers/common/octeontx2/otx2_mbox.c +18
-0+ rsp_reg =otx2_read64 (reg_addr); + +if (timeout >= wait_us) +return -ETIMEDOUT ; + +rte_delay_us (sleep); + timeout += sleep; + }while (!rsp_reg); + +/* Clear interrupt */ +otx2_write64 (rsp_reg, reg_addr); + +/* Reset mbox */ +otx2_mbox_reset (mbox,0 ); + +return 0 ; +} +/** * @internal * Wait and get mailbox response with timeout
drivers/common/octeontx2/otx2_mbox.c +10
-6@@ -258,8 +292,8 @@ otx2_mbox_get_rsp_tmo(struct otx2_mbox *mbox, int devid, void **msg, int rc; rc =otx2_mbox_wait_for_rsp_tmo (mbox, devid, tmo); -if (rc !=1 ) -return -EIO ; +if (rc <0 ) +return rc;rte_rmb ();@@ -321,11 +355,15 @@ otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo) }/* Wait message */ - rc =mbox_wait (mbox, devid, tmo); -if (rc) -return rc; +if (rte_thread_is_intr ()) + rc =mbox_poll (mbox, tmo); +else + rc =mbox_wait (mbox, devid, tmo); -return mdev->msgs_acked; +if (!rc) + rc = mdev->num_msgs; + +return rc; }/**
drivers/common/octeontx2/otx2_mbox.h +3
-2@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */ @@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int
otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
--
2.17.1
PATCH v5 1/2 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriFrom: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/rte_eal_version.map +1 -0
@@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive;
Signature · 1 line
2.17.1
PATCH v5 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v5:
- Fix shared library compilation error
v4:
- used rte_io_rmb instead of rte_rmb in mbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++--------- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++++++----- drivers/common/octeontx2/otx2_mbox.h | 5 ++- 3 files changed, 73 insertions(+), 31 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +48 -10
99 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
PATCH v6 1/2 eal: add API to check if its interrupt context
From: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v6:
- No changes.
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/rte_eal_version.map +1 -0
@@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive;
Signature · 1 line
2.17.1
PATCH v6 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v6:
- Removed unnecessary code.
v5:
- Fix shared library compilation error
v4:
- used rte_io_rmb instead of rte_rmb in mbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++----------- drivers/common/octeontx2/otx2_mbox.c | 51 ++++++++++++++++++++++++---- drivers/common/octeontx2/otx2_mbox.h | 5 +-- 3 files changed, 70 insertions(+), 27 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +45 -6
80 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v6 2/2] common/octeontx2: add polling based response mbox message
Quoted 3 lines · Sunil Kumar Kori
Currently
otx2_mbox_get_rsp_xxxget response once AF driver interrupts after completion. But this funciton will get into
s/funciton/function
Quoted 10 lines
deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
Signed-off-by Sunil Kumar Kori <[email protected]>Signed-off-by Harman Kalra <[email protected]>
With the above change:
@Thomas Monjalon Since this patch has a dependency on an eal patch(1/2 eal: add API to check if its interrupt context), I am delegating this patch to EAL maintainer.
Quoted 233 lines
---
v6:
- Removed unnecessary code.
v5:
- Fix shared library compilation error
v4:
- usedrte_io_rmbinstead ofrte_rmbinmbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- IncludedMakefileand meson build changes.
- Rebased patch on 19.11-rc4drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++----------- drivers/common/octeontx2/otx2_mbox.c | 51 ++++++++++++++++++++++++---- drivers/common/octeontx2/otx2_mbox.h | 5 +-- 3 files changed, 70 insertions(+), 27 deletions(-)drivers/common/octeontx2/otx2_dev.c +22
-19@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }drivers/common/octeontx2/otx2_mbox.c +45
-6@@ -11,6 +11,7 @@#include <rte_cycles.h> #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000)#define RVU_AF_AFPF_MBOX1 (0x02008)@@ -59,12 +60,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int -otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs) +otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevs,uint64_t intr_offset) {struct otx2_mbox_dev *mdev;int devid; + mbox->intr_offset = intr_offset; mbox->reg_base = reg_base; mbox->hwbase = hwbase;@@ -244,6 +246,39 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)return msghdr->rc; } +/** +* Polling for given wait time to get mailbox response +*/ +static int +mbox_poll (struct otx2_mbox *mbox,uint32_t wait) +{ +uint32_t timeout =0 , sleep =1 ; +uint32_t wait_us = wait *1000 ; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; +do { + rsp_reg =otx2_read64 (reg_addr); + +if (timeout >= wait_us) +return -ETIMEDOUT ; + +rte_delay_us (sleep); + timeout += sleep; + }while (!rsp_reg); + +rte_smp_rmb (); + +/* Clear interrupt */ +otx2_write64 (rsp_reg, reg_addr); + +/* Reset mbox */ +otx2_mbox_reset (mbox,0 ); + +return 0 ; +} +/** * @internal * Wait and get mailbox response with timeout @@ -321,11 +356,15 @@ otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo) }/* Wait message */ - rc =mbox_wait (mbox, devid, tmo); -if (rc) -return rc; +if (rte_thread_is_intr ()) + rc =mbox_poll (mbox, tmo); +else + rc =mbox_wait (mbox, devid, tmo); -return mdev->msgs_acked; +if (!rc) + rc = mdev->num_msgs; + +return rc; }/** drivers/common/octeontx2/otx2_mbox.h +3
-3@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */ @@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid); --2.17.1
Re: [dpdk-dev] [PATCH v6 2/2] common/octeontx2: add polling based response mbox message
14/01/2020 09:41, Jerin Jacob:
Quoted 18 lines · Sunil Kumar Kori
Quoted 3 lines
Currently
otx2_mbox_get_rsp_xxxget response once AF driver interrupts after completion. But this funciton will get intos/funciton/function
Quoted 10 lines
deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
Signed-off-by Sunil Kumar Kori <[email protected]>Signed-off-by Harman Kalra <[email protected]>
Quoted 6 lines
With the above change:
Acked-by Jerin Jacob <[email protected]>@Thomas Monjalon Since this patch has a dependency on an eal patch(1/2 eal: add API to check if its interrupt context), I am delegating this patch to EAL maintainer.
Yes, we don't split series.
So if there is an EAL change in a series, the whole series must be merged in master.
PATCH v7 1/2 eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriFrom: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
---
v7:
- No changes.
v6:
- No changes.
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +11 -0
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */
lib/librte_eal/freebsd/eal/eal_interrupts.c +5 -0
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/linux/eal/eal_interrupts.c +5 -0
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}
lib/librte_eal/rte_eal_version.map +1 -0
@@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive;
Signature · 1 line
2.17.1
PATCH v7 2/2 common/octeontx2: add polling based response mbox message
Currently otx2_mbox_get_rsp_xxx get response once AF driver interrupts after completion. But this function will get into deadlock if called in another interrupt context.
To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
---
v7:
- Corrected spelling in commit message
v6:
- Removed unnecessary code.
v5:
- Fix shared library compilation error
v4:
- used rte_io_rmb instead of rte_rmb in mbox_poll.
v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- Included Makefile and meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c | 41 +++++++++++----------- drivers/common/octeontx2/otx2_mbox.c | 51 ++++++++++++++++++++++++---- drivers/common/octeontx2/otx2_mbox.h | 5 +-- 3 files changed, 70 insertions(+), 27 deletions(-)
drivers/common/octeontx2/otx2_dev.c +22 -19
@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static void
@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any" );otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev->vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); } static int
@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;
@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev)if (otx2_dev_is_vf (dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;
@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev->max_vfs, + intr_offset);if (rc) goto mbox_fini; }
drivers/common/octeontx2/otx2_mbox.c +45 -6
80 lines not on this page · raw message
drivers/common/octeontx2/otx2_mbox.h +3 -2
@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ };/* Header which precedes all mbox messages */
@@ -1562,8 +1563,8 @@ struct tim_enable_rsp {const char *otx2_mbox_id2name (uint16_t id);int otx2_mbox_id2size (uint16_t id);void otx2_mbox_reset (struct otx2_mbox *mbox,int devid); -int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase, -uintptr_t reg_base,int direction,int ndevs); +int otx2_mbox_init (struct otx2_mbox *mbox,uintptr_t hwbase,uintptr_t reg_base, +int direction,int ndevsi,uint64_t intr_offset);void otx2_mbox_fini (struct otx2_mbox *mbox);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 2/2] common/octeontx2: add polling based response mbox message
Hello Thomas,
I have uploaded next version after handling Jerin's comments.
Can you please look into the series so that It can be applied if there is no more comments ? Thanks.
Regards
Sunil Kumar Kori
Quoted 269 lines
-----Original Message-----
From: Sunil Kumar Kori <[email protected]>
Sent: Tuesday, January 14, 2020 2:35 PM
To: Jerin Jacob Kollanukkaran <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Vamsi Krishna Attunuru <[email protected]>
Cc: [email protected]; Sunil Kumar Kori <[email protected]>; Harman Kalra <[email protected]>
Subject: [PATCH v7 2/2] common/octeontx2: add polling based response mbox messageCurrently
otx2_mbox_get_rsp_xxxget response once AF driver interrupts after completion. But this function will get into deadlock if called in another interrupt context.To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout.
Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages.
Signed-off-by Sunil Kumar Kori <[email protected]>Signed-off-by Harman Kalra <[email protected]>Acked-by Jerin Jacob <[email protected]>---
v7:
- Corrected spelling in commit message
v6:
- Removed unnecessary code.
v5:
- Fix shared library compilation error
v4:
- usedrte_io_rmbinstead ofrte_rmbinmbox_poll. v3:
- Remove experimental tag as API is defined static.
- Merge all changes to single patch.
v2:
- IncludedMakefileand meson build changes.
- Rebased patch on 19.11-rc4
drivers/common/octeontx2/otx2_dev.c| 41 +++++++++++-----------drivers/common/octeontx2/otx2_mbox.c| 51 ++++++++++++++++++++++++---
-drivers/common/octeontx2/otx2_mbox.h| 5 +--3 files changed, 70 insertions(+), 27 deletions(-)drivers/common/octeontx2/otx2_dev.c +6
-7@@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_VF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_VF_INT );otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static void
drivers/common/octeontx2/otx2_dev.c +6
-8@@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr =otx2_read64 (dev->bar2 +RVU_PF_INT );if (intr ==0 ) -return ; +otx2_base_dbg ("Proceeding to check mbox UP messages if any");otx2_write64 (intr, dev->bar2 +RVU_PF_INT ); -otx2_base_dbg ("Irq 0x%" PRIx64"(pf:%d,vf:%d)" , intr, dev->pf, dev- >vf); -if (intr) { -/* First process all configuration messages */ -otx2_process_msgs (dev, dev->mbox); -/* Process Uplink messages */ -otx2_process_msgs_up (dev, &dev->mbox_up); - } +/* First process all configuration messages */ +otx2_process_msgs (dev, dev->mbox); + +/* Process Uplink messages */ +otx2_process_msgs_up (dev, &dev->mbox_up); }static int
drivers/common/octeontx2/otx2_dev.c +10
-4@@ -900,6 +897,7 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) {int up_direction =MBOX_DIR_PFAF_UP ;int rc, direction =MBOX_DIR_PFAF ; +uint64_t intr_offset =RVU_PF_INT ;struct otx2_dev *dev = otx2_dev;uintptr_t bar2, bar4;uint64_t bar4_addr;@@ -924,15 +922,18 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) if (otx2_dev_is_vf(dev)) { direction =MBOX_DIR_VFPF ; up_direction =MBOX_DIR_VFPF_UP ; + intr_offset =RVU_VF_INT ; }/* Initialize the local mbox */ - rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 ); + rc =otx2_mbox_init (&dev->mbox_local, bar4, bar2, direction,1 , + intr_offset);if (rc) goto error; dev->mbox = &dev->mbox_local; - rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 ); + rc =otx2_mbox_init (&dev->mbox_up, bar4, bar2, up_direction,1 , + intr_offset);if (rc) goto error;@@ -967,13 +968,15 @@ otx2_dev_priv_init(struct rte_pci_device *pci_dev, void *otx2_dev) }/* Init mbox object */ rc =otx2_mbox_init (&dev->mbox_vfpf, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF , pci_dev->max_vfs); + bar2,MBOX_DIR_PFVF , pci_dev->max_vfs, + intr_offset);if (rc) goto iounmap;/* PF -> VF UP messages */ rc =otx2_mbox_init (&dev->mbox_vfpf_up, (uintptr_t )hwbase, - bar2,MBOX_DIR_PFVF_UP , pci_dev- >max_vfs); + bar2,MBOX_DIR_PFVF_UP , pci_dev- >max_vfs, + intr_offset);if (rc) goto mbox_fini; }drivers/common/octeontx2/otx2_mbox.c +1
-0@@ -11,6 +11,7 @@#include <rte_cycles.h> #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000)#define RVU_AF_AFPF_MBOX1 (0x02008)@@ -59,12 +60,13 @@ otx2_mbox_reset(struct otx2_mbox *mbox, int devid) }int
drivers/common/octeontx2/otx2_mbox.c +1
-2-otx2_mbox_init(struct otx2_mbox *mbox, uintptr_t hwbase, - uintptr_t reg_base, int direction, int ndevs) +otx2_mbox_init(struct otx2_mbox *mbox, uintptr_t hwbase, uintptr_t
reg_base,drivers/common/octeontx2/otx2_mbox.c +1
-0+ int direction, int ndevs, uint64_t intr_offset){ struct otx2_mbox_dev *mdev; int devid;drivers/common/octeontx2/otx2_mbox.c +1
-0+ mbox->intr_offset = intr_offset;mbox->reg_base = reg_base; mbox->hwbase = hwbase;drivers/common/octeontx2/otx2_mbox.c +30
-0@@ -244,6 +246,39 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg)return msghdr->rc; } +/** +* Polling for given wait time to get mailbox response */ static int +mbox_poll (struct otx2_mbox *mbox,uint32_t wait) { +uint32_t timeout =0 , sleep =1 ; +uint32_t wait_us = wait *1000 ; +uint64_t rsp_reg =0 ; +uintptr_t reg_addr; + + reg_addr = mbox->reg_base + mbox->intr_offset; +do { + rsp_reg =otx2_read64 (reg_addr); + +if (timeout >= wait_us) +return -ETIMEDOUT ; + +rte_delay_us (sleep); + timeout += sleep; + }while (!rsp_reg); + +rte_smp_rmb (); + +/* Clear interrupt */ +otx2_write64 (rsp_reg, reg_addr); + +/* Reset mbox */ +otx2_mbox_reset (mbox,0 ); + +return 0 ; +} +/** * @internal * Wait and get mailbox response with timeout @@ -321,11 +356,15 @@
otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo)} /* Wait message */drivers/common/octeontx2/otx2_mbox.c +8
-4- rc =mbox_wait (mbox, devid, tmo); -if (rc) -return rc; +if (rte_thread_is_intr ()) + rc =mbox_poll (mbox, tmo); +else + rc =mbox_wait (mbox, devid, tmo); -return mdev->msgs_acked; +if (!rc) + rc = mdev->num_msgs; + +return rc;}
/**
drivers/common/octeontx2/otx2_mbox.h +1
-0@@ -73,6 +73,7 @@ struct otx2_mbox {uint16_t tx_size;/* Size of Tx region */ uint16_t ndevs;/* The number of peers */ struct otx2_mbox_dev *dev; +uint64_t intr_offset;/* Offset to interrupt register */ }; /* Header which precedes all mbox messages */ @@ -1562,8 +1563,8 @@struct
tim_enable_rsp{ const char *otx2_mbox_id2name(uint16_t id); intotx2_mbox_id2size(uint16_t id); voidotx2_mbox_reset(struct otx2_mbox *mbox, int devid); -int otx2_mbox_init(structotx2_mbox*mbox,uintptr_thwbase,drivers/common/octeontx2/otx2_mbox.h +1
-1- uintptr_t reg_base, int direction, int ndevs); +int otx2_mbox_init(struct otx2_mbox *mbox, uintptr_t hwbase, uintptr_t
reg_base,drivers/common/octeontx2/otx2_mbox.h +1
-0+ int direction, int ndevsi, uint64_t intr_offset);void
otx2_mbox_fini(struct otx2_mbox *mbox); voidotx2_mbox_msg_send(struct otx2_mbox *mbox, int devid); intotx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid); --
2.17.1
Re: [dpdk-dev] [PATCH v7 1/2] eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriQuoted 90 lines · Sunil Kumar Kori
From: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
Signed-off-by Harman Kalra <[email protected]>Signed-off-by Sunil Kumar Kori <[email protected]>Reviewed-by Jerin Jacob <[email protected]>---
v7:
- No changes.
v6:
- No changes.
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+)lib/librte_eal/common/include/rte_eal_interrupts.h +11
-0@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */ lib/librte_eal/freebsd/eal/eal_interrupts.c +5
-0@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}lib/librte_eal/linux/eal/eal_interrupts.c +5
-0@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}lib/librte_eal/rte_eal_version.map +1
-1@@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive; --
Quoted 1 line
2.17.1
We can't put this symbol in the stable ABI and just flag it as internal in the function description.
Users won't notice this warning.
I moved this as an experimental API and enabled the use of experimental api in octeontx2 common driver.
We can revisit once we have the rte_internal tag Neil had proposed.
Series applied, thanks.
--
David Marchand
Re: [dpdk-dev] [PATCH v6 1/2] eal: add API to check if its interrupt context
In reply to Sunil Kumar KoriQuoted 8 lines · Sunil Kumar Kori
From: Harman Kalra <[email protected]>
Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases.
Signed-off-by Harman Kalra <[email protected]>Signed-off-by Sunil Kumar Kori <[email protected]>
Quoted 81 lines
---
v6:
- No changes.
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+)lib/librte_eal/common/include/rte_eal_interrupts.h +11
-0@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); +/** +* @internal +* Check if currently executing in interrupt context +* +* @return +* - non zero in case of interrupt context +* - zero in case of process context +*/ +int +rte_thread_is_intr (void ); +#endif /* _RTE_EAL_INTERRUPTS_H_ */ lib/librte_eal/freebsd/eal/eal_interrupts.c +5
-0@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) {RTE_SET_USED (intr_handle); } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}lib/librte_eal/linux/eal/eal_interrupts.c +5
-0@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)return 0 ; } + +int rte_thread_is_intr (void ) +{ +return pthread_equal (intr_thread,pthread_self ()); +}lib/librte_eal/rte_eal_version.map +1
-1@@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive; --2.17.1