From: Pawel Sobczyk <[email protected]> Adds a new API ice_ctrlq_pending() to check if there are pending messages in the admin control queue. The function is intended to be called after clearing the ADMINQ_EVENT_PENDING flag to ensure all pending messages are processed before re-enabling interrupts.
Signed-off-by: Pawel Sobczyk <[email protected]> Signed-off-by: Soumyadeep Hore <[email protected]> --- drivers/net/intel/ice/base/ice_common.h | 1 + drivers/net/intel/ice/base/ice_controlq.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/net/intel/ice/base/ice_common.h b/drivers/net/intel/ice/base/ice_common.h index 884b8f7834..3e9d3c2f80 100644 --- a/drivers/net/intel/ice/base/ice_common.h +++ b/drivers/net/intel/ice/base/ice_common.h @@ -148,6 +148,7 @@ ice_aq_ena_dis_txtimeq(struct ice_hw *hw, u16 txtimeq, u16 q_count, bool q_ena, extern const struct ice_ctx_ele ice_txtime_ctx_info[]; bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq); +bool ice_ctrlq_pending(struct ice_hw *hw, struct ice_ctl_q_info *cq); int ice_aq_q_shutdown(struct ice_hw *hw, bool unloading); void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode); extern const struct ice_ctx_ele ice_tlan_ctx_info[]; diff --git a/drivers/net/intel/ice/base/ice_controlq.c b/drivers/net/intel/ice/base/ice_controlq.c index b210495827..d68e603a8c 100644 --- a/drivers/net/intel/ice/base/ice_controlq.c +++ b/drivers/net/intel/ice/base/ice_controlq.c @@ -965,6 +965,22 @@ static bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq) return rd32(hw, cq->sq.head) == cq->sq.next_to_use; } +/** + * ice_ctrlq_pending - check if there are pending messages on the control queue + * @hw: pointer to the HW struct + * @cq: pointer to the specific Control queue + * + * Returns: true if there are pending messages in a queue (i.e. next_to_clean + * does not match the hardware head register), false otherwise + */ +bool ice_ctrlq_pending(struct ice_hw *hw, struct ice_ctl_q_info *cq) +{ + u16 ntu; + + ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask); + return cq->rq.next_to_clean != ntu; +} + /** * ice_sq_send_cmd_nolock - send command to a control queue * @hw: pointer to the HW struct -- 2.47.1

