--- zzzz-none-000/linux-3.10.107/drivers/net/ethernet/cisco/enic/vnic_rq.h 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/net/ethernet/cisco/enic/vnic_rq.h 2021-02-04 17:41:59.000000000 +0000 @@ -21,6 +21,7 @@ #define _VNIC_RQ_H_ #include +#include #include "vnic_dev.h" #include "vnic_cq.h" @@ -72,6 +73,13 @@ unsigned int len; unsigned int index; void *desc; + uint64_t wr_id; +}; + +enum enic_poll_state { + ENIC_POLL_STATE_IDLE, + ENIC_POLL_STATE_NAPI, + ENIC_POLL_STATE_POLL }; struct vnic_rq { @@ -84,6 +92,9 @@ struct vnic_rq_buf *to_clean; void *os_buf_head; unsigned int pkts_outstanding; +#ifdef CONFIG_NET_RX_BUSY_POLL + atomic_t bpoll_state; +#endif /* CONFIG_NET_RX_BUSY_POLL */ }; static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq) @@ -110,7 +121,8 @@ static inline void vnic_rq_post(struct vnic_rq *rq, void *os_buf, unsigned int os_buf_index, - dma_addr_t dma_addr, unsigned int len) + dma_addr_t dma_addr, unsigned int len, + uint64_t wrid) { struct vnic_rq_buf *buf = rq->to_use; @@ -118,6 +130,7 @@ buf->os_buf_index = os_buf_index; buf->dma_addr = dma_addr; buf->len = len; + buf->wr_id = wrid; buf = buf->next; rq->to_use = buf; @@ -194,6 +207,81 @@ return 0; } +#ifdef CONFIG_NET_RX_BUSY_POLL +static inline void enic_busy_poll_init_lock(struct vnic_rq *rq) +{ + atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE); +} + +static inline bool enic_poll_lock_napi(struct vnic_rq *rq) +{ + int rc = atomic_cmpxchg(&rq->bpoll_state, ENIC_POLL_STATE_IDLE, + ENIC_POLL_STATE_NAPI); + + return (rc == ENIC_POLL_STATE_IDLE); +} + +static inline void enic_poll_unlock_napi(struct vnic_rq *rq, + struct napi_struct *napi) +{ + WARN_ON(atomic_read(&rq->bpoll_state) != ENIC_POLL_STATE_NAPI); + napi_gro_flush(napi, false); + atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE); +} + +static inline bool enic_poll_lock_poll(struct vnic_rq *rq) +{ + int rc = atomic_cmpxchg(&rq->bpoll_state, ENIC_POLL_STATE_IDLE, + ENIC_POLL_STATE_POLL); + + return (rc == ENIC_POLL_STATE_IDLE); +} + + +static inline void enic_poll_unlock_poll(struct vnic_rq *rq) +{ + WARN_ON(atomic_read(&rq->bpoll_state) != ENIC_POLL_STATE_POLL); + atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE); +} + +static inline bool enic_poll_busy_polling(struct vnic_rq *rq) +{ + return atomic_read(&rq->bpoll_state) & ENIC_POLL_STATE_POLL; +} + +#else + +static inline void enic_busy_poll_init_lock(struct vnic_rq *rq) +{ +} + +static inline bool enic_poll_lock_napi(struct vnic_rq *rq) +{ + return true; +} + +static inline bool enic_poll_unlock_napi(struct vnic_rq *rq, + struct napi_struct *napi) +{ + return false; +} + +static inline bool enic_poll_lock_poll(struct vnic_rq *rq) +{ + return false; +} + +static inline bool enic_poll_unlock_poll(struct vnic_rq *rq) +{ + return false; +} + +static inline bool enic_poll_ll_polling(struct vnic_rq *rq) +{ + return false; +} +#endif /* CONFIG_NET_RX_BUSY_POLL */ + void vnic_rq_free(struct vnic_rq *rq); int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index, unsigned int desc_count, unsigned int desc_size);