New upstream version 18.02
[deb_dpdk.git] / drivers / net / enic / base / vnic_cq.h
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         u64 ring_base;                  /* 0x00 */
17         u32 ring_size;                  /* 0x08 */
18         u32 pad0;
19         u32 flow_control_enable;        /* 0x10 */
20         u32 pad1;
21         u32 color_enable;               /* 0x18 */
22         u32 pad2;
23         u32 cq_head;                    /* 0x20 */
24         u32 pad3;
25         u32 cq_tail;                    /* 0x28 */
26         u32 pad4;
27         u32 cq_tail_color;              /* 0x30 */
28         u32 pad5;
29         u32 interrupt_enable;           /* 0x38 */
30         u32 pad6;
31         u32 cq_entry_enable;            /* 0x40 */
32         u32 pad7;
33         u32 cq_message_enable;          /* 0x48 */
34         u32 pad8;
35         u32 interrupt_offset;           /* 0x50 */
36         u32 pad9;
37         u64 cq_message_addr;            /* 0x58 */
38         u32 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 };
63
64 void vnic_cq_free(struct vnic_cq *cq);
65 int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index,
66         unsigned int socket_id,
67         unsigned int desc_count, unsigned int desc_size);
68 void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
69         unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail,
70         unsigned int cq_tail_color, unsigned int interrupt_enable,
71         unsigned int cq_entry_enable, unsigned int message_enable,
72         unsigned int interrupt_offset, u64 message_addr);
73 void vnic_cq_clean(struct vnic_cq *cq);
74 int vnic_cq_mem_size(struct vnic_cq *cq, unsigned int desc_count,
75         unsigned int desc_size);
76
77 #endif /* _VNIC_CQ_H_ */