liquidio: allocate RX buffers in OOM conditions in PF and VF
Subsystems (3)
PATCH 1/1 liquidio: allocate RX buffers in OOM conditions in PF and VF
From: Satanand Burla <[email protected]>
Add workqueue that is periodically run to try to allocate RX buffers in OOM conditions in PF and VF.
--- .../ethernet/cavium/liquidio/cn23xx_pf_device.h | 2 + drivers/net/ethernet/cavium/liquidio/lio_core.c | 56 ++++++++++++++++++++++ drivers/net/ethernet/cavium/liquidio/lio_main.c | 5 ++ drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 5 ++ drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 26 ++++++++++ drivers/net/ethernet/cavium/liquidio/octeon_droq.h | 2 + .../net/ethernet/cavium/liquidio/octeon_network.h | 7 +++ 7 files changed, 103 insertions(+)
drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.h +2 -0
@@ -43,6 +43,8 @@ struct octeon_cn23xx_pf {struct octeon_config *conf; }; +#define CN23XX_SLI_DEF_BP 0x40 +int setup_cn23xx_octeon_pf_device (struct octeon_device *oct); int validate_cn23xx_pf_config_info(struct octeon_device *oct,
drivers/net/ethernet/cavium/liquidio/lio_core.c +56 -0
65 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/lio_main.c +5 -0
@@ -1672,6 +1672,8 @@ static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx)cleanup_link_status_change_wq (netdev); +cleanup_rx_oom_poll_fn (netdev); +delete_glists (lio);free_netdev (netdev);
@@ -4146,6 +4148,9 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)if (setup_link_status_change_wq (netdev)) goto setup_nic_dev_fail; +if (setup_rx_oom_poll_fn (netdev)) + goto setup_nic_dev_fail; +/* Register the network device with the OS */ if (register_netdev (netdev)) {dev_err (&octeon_dev->pci_dev->dev,"Device registration failed\n" );
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +5 -0
@@ -1154,6 +1154,8 @@ static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx)if (atomic_read (&lio->ifstate) &LIO_IFSTATE_REGISTERED )unregister_netdev (netdev); +cleanup_rx_oom_poll_fn (netdev); +cleanup_link_status_change_wq (netdev);delete_glists (lio);
@@ -2994,6 +2996,9 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)if (setup_link_status_change_wq (netdev)) goto setup_nic_dev_fail; +if (setup_rx_oom_poll_fn (netdev)) + goto setup_nic_dev_fail; +/* Register the network device with the OS */ if (register_netdev (netdev)) {dev_err (&octeon_dev->pci_dev->dev,"Device registration failed\n" );
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +26 -0
@@ -513,6 +513,32 @@ octeon_droq_refill(struct octeon_device *octeon_dev, struct octeon_droq *droq)return desc_refilled; } +/** check if we can allocate packets to get out of oom. +* @param droq - Droq being checked. +* @return does not return anything +*/ +void octeon_droq_check_oom (struct octeon_droq *droq) +{ +int desc_refilled; +struct octeon_device *oct = droq->oct_dev; + +if (readl (droq->pkts_credit_reg) <=CN23XX_SLI_DEF_BP ) { +spin_lock_bh (&droq->lock); + desc_refilled =octeon_droq_refill (oct, droq); +if (desc_refilled) { +/* Flush the droq descriptor data to memory to be sure +* that when we update the credits the data in memory +* is accurate. +*/ +wmb (); +writel (desc_refilled, droq->pkts_credit_reg); +/* make sure mmio write completes */ +mmiowb (); + } +spin_unlock_bh (&droq->lock); + } +} +static inline u32 octeon_droq_get_bufcount (u32 buf_size,u32 total_len) {
drivers/net/ethernet/cavium/liquidio/octeon_droq.h +2 -0
@@ -426,4 +426,6 @@ int octeon_droq_process_packets(struct octeon_device *oct,int octeon_process_droq_poll_cmd (struct octeon_device *oct,u32 q_no,int cmd,u32 arg); +void octeon_droq_check_oom (struct octeon_droq *droq); +#endif /*__OCTEON_DROQ_H__ */
drivers/net/ethernet/cavium/liquidio/octeon_network.h +7 -0
@@ -129,6 +129,9 @@ struct lio {/* work queue for txq status */ struct cavium_wq txq_status_wq; +/* work queue for rxq oom status */ +struct cavium_wq rxq_status_wq; +/* work queue for link status */ struct cavium_wq link_status_wq;
@@ -152,6 +155,10 @@ struct lio {*/ int liquidio_set_feature (struct net_device *netdev,int cmd,u16 param1); +int setup_rx_oom_poll_fn (struct net_device *netdev); + +void cleanup_rx_oom_poll_fn (struct net_device *netdev); +/** * \brief Link control command completion callback * @param nctrl_ptr pointer to control packet structure
From: Felix Manlunas <[email protected]>
Date: Wed, 22 Mar 2017 11:31:13 -0700
Quoted 7 lines
From: Satanand Burla <[email protected]>
Add workqueue that is periodically run to try to allocate RX buffers in OOM conditions in PF and VF.
Signed-off-by Satanand Burla <[email protected]>Signed-off-by Felix Manlunas <[email protected]>
Applied, but I'm really not so sure you want to poll these queue states 4 times a second all the time.
Why don't you trigger the workqueue when you actually get an allocation failure?
Quoted 8 lines · David Miller
From: Felix Manlunas <[email protected]>
Date: Wed, 22 Mar 2017 11:31:13 -0700Quoted 5 lines
From: Satanand Burla <[email protected]>
Add workqueue that is periodically run to try to allocate RX buffers in OOM conditions in PF and VF.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Satanand Burla <[email protected]>Signed-off-by Felix Manlunas <[email protected]>Applied, but I'm really not so sure you want to poll these queue states 4 times a second all the time.
Why don't you trigger the workqueue when you actually get an allocation failure?
That is certainly a better option. We will incorporate that in the coming series.
Signature · 2 lines
Thanks Satanand