1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Driver for Alibaba Elastic Ethernet Adapter.
*
* Copyright (C) 2025 Alibaba Inc.
*/
#ifndef __EEA_RING_H__
#define __EEA_RING_H__
#include <linux/dma-mapping.h>
#include "eea_desc.h"
#define EEA_RING_DESC_F_MORE BIT(0)
#define EEA_RING_DESC_F_CQ_PHASE BIT(7)
/* These two values define the bounds for the queue depth returned by the
* hardware.
*/
#define EEA_NET_IO_HW_RING_DEPTH_MAX (32 * 1024)
#define EEA_NET_IO_HW_RING_DEPTH_MIN 128
/* This value constrains the minimum queue depth that the driver configures for
* the hardware, which typically applies to user-provided settings. Naturally,
* the configured depth must also not exceed the maximum capacity supported by
* the hardware.
*/
#define EEA_NET_IO_RING_DEPTH_MIN 64
struct eea_common_desc {
__le16 flags;
__le16 id;
};
struct eea_device;
struct eea_ring_sq {
void *desc;
u16 head;
u16 hw_idx;
u16 shadow_idx;
__le16 shadow_id;
u16 shadow_num;
u8 desc_size;
u8 desc_size_shift;
dma_addr_t dma_addr;
u32 dma_size;
};
struct eea_ring_cq {
void *desc;
u16 head;
u16 hw_idx;
u8 phase;
u8 desc_size_shift;
u8 desc_size;
dma_addr_t dma_addr;
u32 dma_size;
};
struct eea_ring {
const char *name;
struct eea_device *edev;
u32 index;
void __iomem *db;
u16 msix_vec;
u32 num;
u32 num_free;
struct eea_ring_sq sq;
struct eea_ring_cq cq;
};
struct eea_ring *eea_ering_alloc(u32 index, u32 num, struct eea_device *edev,
u8 sq_desc_size, u8 cq_desc_size,
const char *name);
void eea_ering_free(struct eea_ring *ering);
void eea_ering_kick(struct eea_ring *ering);
void *eea_ering_sq_alloc_desc(struct eea_ring *ering, u16 id,
bool is_last, u16 flags);
void *eea_ering_aq_alloc_desc(struct eea_ring *ering);
void eea_ering_sq_commit_desc(struct eea_ring *ering);
void eea_ering_sq_cancel(struct eea_ring *ering);
void eea_ering_cq_ack_desc(struct eea_ring *ering, u32 num);
void eea_ering_irq_active(struct eea_ring *ering, struct eea_ring *tx_ering);
void *eea_ering_cq_get_desc(const struct eea_ring *ering);
#endif
|