Skip to content

Commit 225480f

Browse files
committed
Merge branch 'dpaa2-eth-AF_XDP-zc'
Ioana Ciornei says: ==================== net: dpaa2-eth: AF_XDP zero-copy support This patch set adds support for AF_XDP zero-copy in the dpaa2-eth driver. The support is available on the LX2160A SoC and its variants and only on interfaces (DPNIs) with a maximum of 8 queues (HW limitations are the root cause). We are first implementing the .get_channels() callback since this a dependency for further work. Patches 2-3 are working on making the necessary changes for multiple buffer pools on a single interface. By default, without an AF_XDP socket attached, only a single buffer pool will be used and shared between all the queues. The changes in the functions are made in this patch, but the actual allocation and setup of a new BP is done in patch#10. Patches 4-5 are improving the information exposed in debugfs. We are exposing a new file to show which buffer pool is used by what channels and how many buffers it currently has. The 6th patch updates the dpni_set_pools() firmware API so that we are capable of setting up a different buffer per queue in later patches. In the 7th patch the generic dev_open/close APIs are used instead of the dpaa2-eth internal ones. Patches 8-9 are rearranging the existing code in dpaa2-eth.c in order to create new functions which will be used in the XSK implementation in dpaa2-xsk.c Finally, the last 3 patches are adding the actual support for both the Rx and Tx path of AF_XDP zero-copy and some associated tracepoints. Details on the implementation can be found in the actual patch. Changes in v2: - 3/12: Export dpaa2_eth_allocate_dpbp/dpaa2_eth_free_dpbp in this patch to avoid a build warning. The functions will be used in next patches. - 6/12: Use __le16 instead of u16 for the dpbp_id field. - 12/12: Use xdp_buff->data_hard_start when tracing the BP seeding. Changes in v3: - 3/12: fix leaking of bp on error path ==================== Acked-by: Björn Töpel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 3bd5549 + 3817b2a commit 225480f

File tree

11 files changed

+1094
-242
lines changed

11 files changed

+1094
-242
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6326,6 +6326,7 @@ F: drivers/net/ethernet/freescale/dpaa2/Kconfig
63266326
F: drivers/net/ethernet/freescale/dpaa2/Makefile
63276327
F: drivers/net/ethernet/freescale/dpaa2/dpaa2-eth*
63286328
F: drivers/net/ethernet/freescale/dpaa2/dpaa2-mac*
6329+
F: drivers/net/ethernet/freescale/dpaa2/dpaa2-xsk*
63296330
F: drivers/net/ethernet/freescale/dpaa2/dpkg.h
63306331
F: drivers/net/ethernet/freescale/dpaa2/dpmac*
63316332
F: drivers/net/ethernet/freescale/dpaa2/dpni*

drivers/net/ethernet/freescale/dpaa2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o
77
obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += fsl-dpaa2-ptp.o
88
obj-$(CONFIG_FSL_DPAA2_SWITCH) += fsl-dpaa2-switch.o
99

10-
fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-mac.o dpmac.o dpaa2-eth-devlink.o
10+
fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-mac.o dpmac.o dpaa2-eth-devlink.o dpaa2-xsk.o
1111
fsl-dpaa2-eth-${CONFIG_FSL_DPAA2_ETH_DCB} += dpaa2-eth-dcb.o
1212
fsl-dpaa2-eth-${CONFIG_DEBUG_FS} += dpaa2-eth-debugfs.o
1313
fsl-dpaa2-ptp-objs := dpaa2-ptp.o dprtc.o

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ static int dpaa2_dbg_ch_show(struct seq_file *file, void *offset)
9898
int i;
9999

100100
seq_printf(file, "Channel stats for %s:\n", priv->net_dev->name);
101-
seq_printf(file, "%s%16s%16s%16s%16s%16s%16s\n",
102-
"CHID", "CPU", "Deq busy", "Frames", "CDANs",
101+
seq_printf(file, "%s %5s%16s%16s%16s%16s%16s%16s\n",
102+
"IDX", "CHID", "CPU", "Deq busy", "Frames", "CDANs",
103103
"Avg Frm/CDAN", "Buf count");
104104

105105
for (i = 0; i < priv->num_channels; i++) {
106106
ch = priv->channel[i];
107-
seq_printf(file, "%4d%16d%16llu%16llu%16llu%16llu%16d\n",
108-
ch->ch_id,
107+
seq_printf(file, "%3s%d%6d%16d%16llu%16llu%16llu%16llu%16d\n",
108+
"CH#", i, ch->ch_id,
109109
ch->nctx.desired_cpu,
110110
ch->stats.dequeue_portal_busy,
111111
ch->stats.frames,
@@ -119,6 +119,51 @@ static int dpaa2_dbg_ch_show(struct seq_file *file, void *offset)
119119

120120
DEFINE_SHOW_ATTRIBUTE(dpaa2_dbg_ch);
121121

122+
static int dpaa2_dbg_bp_show(struct seq_file *file, void *offset)
123+
{
124+
struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)file->private;
125+
int i, j, num_queues, buf_cnt;
126+
struct dpaa2_eth_bp *bp;
127+
char ch_name[10];
128+
int err;
129+
130+
/* Print out the header */
131+
seq_printf(file, "Buffer pool info for %s:\n", priv->net_dev->name);
132+
seq_printf(file, "%s %10s%15s", "IDX", "BPID", "Buf count");
133+
num_queues = dpaa2_eth_queue_count(priv);
134+
for (i = 0; i < num_queues; i++) {
135+
snprintf(ch_name, sizeof(ch_name), "CH#%d", i);
136+
seq_printf(file, "%10s", ch_name);
137+
}
138+
seq_printf(file, "\n");
139+
140+
/* For each buffer pool, print out its BPID, the number of buffers in
141+
* that buffer pool and the channels which are using it.
142+
*/
143+
for (i = 0; i < priv->num_bps; i++) {
144+
bp = priv->bp[i];
145+
146+
err = dpaa2_io_query_bp_count(NULL, bp->bpid, &buf_cnt);
147+
if (err) {
148+
netdev_warn(priv->net_dev, "Buffer count query error %d\n", err);
149+
return err;
150+
}
151+
152+
seq_printf(file, "%3s%d%10d%15d", "BP#", i, bp->bpid, buf_cnt);
153+
for (j = 0; j < num_queues; j++) {
154+
if (priv->channel[j]->bp == bp)
155+
seq_printf(file, "%10s", "x");
156+
else
157+
seq_printf(file, "%10s", "");
158+
}
159+
seq_printf(file, "\n");
160+
}
161+
162+
return 0;
163+
}
164+
165+
DEFINE_SHOW_ATTRIBUTE(dpaa2_dbg_bp);
166+
122167
void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
123168
{
124169
struct fsl_mc_device *dpni_dev;
@@ -139,6 +184,10 @@ void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
139184

140185
/* per-fq stats file */
141186
debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_fops);
187+
188+
/* per buffer pool stats file */
189+
debugfs_create_file("bp_stats", 0444, dir, priv, &dpaa2_dbg_bp_fops);
190+
142191
}
143192

144193
void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-trace.h

Lines changed: 91 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_fd,
7373
TP_ARGS(netdev, fd)
7474
);
7575

76+
/* Tx (egress) XSK fd */
77+
DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_xsk_fd,
78+
TP_PROTO(struct net_device *netdev,
79+
const struct dpaa2_fd *fd),
80+
81+
TP_ARGS(netdev, fd)
82+
);
83+
7684
/* Rx fd */
7785
DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_fd,
7886
TP_PROTO(struct net_device *netdev,
@@ -81,6 +89,14 @@ DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_fd,
8189
TP_ARGS(netdev, fd)
8290
);
8391

92+
/* Rx XSK fd */
93+
DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_xsk_fd,
94+
TP_PROTO(struct net_device *netdev,
95+
const struct dpaa2_fd *fd),
96+
97+
TP_ARGS(netdev, fd)
98+
);
99+
84100
/* Tx confirmation fd */
85101
DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_conf_fd,
86102
TP_PROTO(struct net_device *netdev,
@@ -90,57 +106,81 @@ DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_conf_fd,
90106
);
91107

92108
/* Log data about raw buffers. Useful for tracing DPBP content. */
93-
TRACE_EVENT(dpaa2_eth_buf_seed,
94-
/* Trace function prototype */
95-
TP_PROTO(struct net_device *netdev,
96-
/* virtual address and size */
97-
void *vaddr,
98-
size_t size,
99-
/* dma map address and size */
100-
dma_addr_t dma_addr,
101-
size_t map_size,
102-
/* buffer pool id, if relevant */
103-
u16 bpid),
104-
105-
/* Repeat argument list here */
106-
TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid),
107-
108-
/* A structure containing the relevant information we want
109-
* to record. Declare name and type for each normal element,
110-
* name, type and size for arrays. Use __string for variable
111-
* length strings.
112-
*/
113-
TP_STRUCT__entry(
114-
__field(void *, vaddr)
115-
__field(size_t, size)
116-
__field(dma_addr_t, dma_addr)
117-
__field(size_t, map_size)
118-
__field(u16, bpid)
119-
__string(name, netdev->name)
120-
),
121-
122-
/* The function that assigns values to the above declared
123-
* fields
124-
*/
125-
TP_fast_assign(
126-
__entry->vaddr = vaddr;
127-
__entry->size = size;
128-
__entry->dma_addr = dma_addr;
129-
__entry->map_size = map_size;
130-
__entry->bpid = bpid;
131-
__assign_str(name, netdev->name);
132-
),
133-
134-
/* This is what gets printed when the trace event is
135-
* triggered.
136-
*/
137-
TP_printk(TR_BUF_FMT,
138-
__get_str(name),
139-
__entry->vaddr,
140-
__entry->size,
141-
&__entry->dma_addr,
142-
__entry->map_size,
143-
__entry->bpid)
109+
DECLARE_EVENT_CLASS(dpaa2_eth_buf,
110+
/* Trace function prototype */
111+
TP_PROTO(struct net_device *netdev,
112+
/* virtual address and size */
113+
void *vaddr,
114+
size_t size,
115+
/* dma map address and size */
116+
dma_addr_t dma_addr,
117+
size_t map_size,
118+
/* buffer pool id, if relevant */
119+
u16 bpid),
120+
121+
/* Repeat argument list here */
122+
TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid),
123+
124+
/* A structure containing the relevant information we want
125+
* to record. Declare name and type for each normal element,
126+
* name, type and size for arrays. Use __string for variable
127+
* length strings.
128+
*/
129+
TP_STRUCT__entry(
130+
__field(void *, vaddr)
131+
__field(size_t, size)
132+
__field(dma_addr_t, dma_addr)
133+
__field(size_t, map_size)
134+
__field(u16, bpid)
135+
__string(name, netdev->name)
136+
),
137+
138+
/* The function that assigns values to the above declared
139+
* fields
140+
*/
141+
TP_fast_assign(
142+
__entry->vaddr = vaddr;
143+
__entry->size = size;
144+
__entry->dma_addr = dma_addr;
145+
__entry->map_size = map_size;
146+
__entry->bpid = bpid;
147+
__assign_str(name, netdev->name);
148+
),
149+
150+
/* This is what gets printed when the trace event is
151+
* triggered.
152+
*/
153+
TP_printk(TR_BUF_FMT,
154+
__get_str(name),
155+
__entry->vaddr,
156+
__entry->size,
157+
&__entry->dma_addr,
158+
__entry->map_size,
159+
__entry->bpid)
160+
);
161+
162+
/* Main memory buff seeding */
163+
DEFINE_EVENT(dpaa2_eth_buf, dpaa2_eth_buf_seed,
164+
TP_PROTO(struct net_device *netdev,
165+
void *vaddr,
166+
size_t size,
167+
dma_addr_t dma_addr,
168+
size_t map_size,
169+
u16 bpid),
170+
171+
TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid)
172+
);
173+
174+
/* UMEM buff seeding on AF_XDP fast path */
175+
DEFINE_EVENT(dpaa2_eth_buf, dpaa2_xsk_buf_seed,
176+
TP_PROTO(struct net_device *netdev,
177+
void *vaddr,
178+
size_t size,
179+
dma_addr_t dma_addr,
180+
size_t map_size,
181+
u16 bpid),
182+
183+
TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid)
144184
);
145185

146186
/* If only one event of a certain type needs to be declared, use TRACE_EVENT().

0 commit comments

Comments
 (0)