1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved. 3 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 4 */ 5 6 #ifndef _VNIC_CQ_H_ 7 #define _VNIC_CQ_H_ 8 9 #include <rte_mbuf.h> 10 11 #include "cq_desc.h" 12 #include "vnic_dev.h" 13 14 /* Completion queue control */ 15 struct vnic_cq_ctrl { 16 uint64_t ring_base; /* 0x00 */ 17 uint32_t ring_size; /* 0x08 */ 18 uint32_t pad0; 19 uint32_t flow_control_enable; /* 0x10 */ 20 uint32_t pad1; 21 uint32_t color_enable; /* 0x18 */ 22 uint32_t pad2; 23 uint32_t cq_head; /* 0x20 */ 24 uint32_t pad3; 25 uint32_t cq_tail; /* 0x28 */ 26 uint32_t pad4; 27 uint32_t cq_tail_color; /* 0x30 */ 28 uint32_t pad5; 29 uint32_t interrupt_enable; /* 0x38 */ 30 uint32_t pad6; 31 uint32_t cq_entry_enable; /* 0x40 */ 32 uint32_t pad7; 33 uint32_t cq_message_enable; /* 0x48 */ 34 uint32_t pad8; 35 uint32_t interrupt_offset; /* 0x50 */ 36 uint32_t pad9; 37 uint64_t cq_message_addr; /* 0x58 */ 38 uint32_t pad10; 39 }; 40 41 #ifdef ENIC_AIC 42 struct vnic_rx_bytes_counter { 43 unsigned int small_pkt_bytes_cnt; 44 unsigned int large_pkt_bytes_cnt; 45 }; 46 #endif 47 48 struct vnic_cq { 49 unsigned int index; 50 struct vnic_dev *vdev; 51 struct vnic_cq_ctrl __iomem *ctrl; /* memory-mapped */ 52 struct vnic_dev_ring ring; 53 unsigned int to_clean; 54 unsigned int last_color; 55 unsigned int interrupt_offset; 56 #ifdef ENIC_AIC 57 struct vnic_rx_bytes_counter pkt_size_counter; 58 unsigned int cur_rx_coal_timeval; 59 unsigned int tobe_rx_coal_timeval; 60 ktime_t prev_ts; 61 #endif 62 bool admin_chan; 63 }; 64 65 void vnic_cq_free(struct vnic_cq *cq); 66 int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index, 67 unsigned int socket_id, 68 unsigned int desc_count, unsigned int desc_size); 69 int vnic_admin_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index, 70 unsigned int socket_id, unsigned int desc_count, unsigned int desc_size); 71 void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable, 72 unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail, 73 unsigned int cq_tail_color, unsigned int interrupt_enable, 74 unsigned int cq_entry_enable, unsigned int message_enable, 75 unsigned int interrupt_offset, uint64_t message_addr); 76 void vnic_cq_clean(struct vnic_cq *cq); 77 int vnic_cq_mem_size(struct vnic_cq *cq, unsigned int desc_count, 78 unsigned int desc_size); 79 80 #endif /* _VNIC_CQ_H_ */ 81