diff options
author | Marcin Wojtas <mw@FreeBSD.org> | 2017-10-31 12:20:48 +0000 |
---|---|---|
committer | Marcin Wojtas <mw@FreeBSD.org> | 2017-10-31 12:20:48 +0000 |
commit | 6371f456375e6a1dcaf0b4046e2ad661378f9520 (patch) | |
tree | f37a181e68a6e4e044daade99d58617b4c49ed99 /ena_eth_com.h | |
parent | df00fb68b9f65b3540fa22663ac954755b4e6755 (diff) | |
download | src-test2-6371f456375e6a1dcaf0b4046e2ad661378f9520.tar.gz src-test2-6371f456375e6a1dcaf0b4046e2ad661378f9520.zip |
Notes
Diffstat (limited to 'ena_eth_com.h')
-rw-r--r-- | ena_eth_com.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ena_eth_com.h b/ena_eth_com.h index ec32d77ef9d2..d0c8b9080589 100644 --- a/ena_eth_com.h +++ b/ena_eth_com.h @@ -98,7 +98,7 @@ static inline void ena_com_unmask_intr(struct ena_com_io_cq *io_cq, ENA_REG_WRITE32(io_cq->bus, intr_reg->intr_control, io_cq->unmask_reg); } -static inline int ena_com_sq_empty_space(struct ena_com_io_sq *io_sq) +static inline int ena_com_free_desc(struct ena_com_io_sq *io_sq) { u16 tail, next_to_comp, cnt; @@ -109,6 +109,25 @@ static inline int ena_com_sq_empty_space(struct ena_com_io_sq *io_sq) return io_sq->q_depth - 1 - cnt; } +/* Check if the submission queue has enough space to hold required_buffers */ +static inline bool ena_com_sq_have_enough_space(struct ena_com_io_sq *io_sq, + u16 required_buffers) +{ + int temp; + + if (io_sq->mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_HOST) + return ena_com_free_desc(io_sq) >= required_buffers; + + /* This calculation doesn't need to be 100% accurate. So to reduce + * the calculation overhead just Subtract 2 lines from the free descs + * (one for the header line and one to compensate the devision + * down calculation. + */ + temp = required_buffers / io_sq->llq_info.descs_per_entry + 2; + + return ena_com_free_desc(io_sq) > temp; +} + static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) { u16 tail; |