Skip to content

Commit 6a91b84

Browse files
Radhey Shyam Pandeykuba-moo
authored andcommitted
net: axienet: Introduce dmaengine support
Add dmaengine framework to communicate with the xilinx DMAengine driver(AXIDMA). Axi ethernet driver uses separate channels for transmit and receive. Add support for these channels to handle TX and RX with skb and appropriate callbacks. Also add axi ethernet core interrupt for dmaengine framework support. The dmaengine framework was extended for metadata API support. However it still needs further enhancements to make it well suited for ethernet usecases. The ethernet features i.e ethtool set/get of DMA IP properties, ndo_poll_controller,(mentioned in TODO) are not supported and it requires follow-up discussions. dmaengine support has a dependency on xilinx_dma as it uses xilinx_vdma_channel_set_config() API to reset the DMA IP which internally reset MAC prior to accessing MDIO. Benchmark with netperf: xilinx-zcu102-20232:~$ netperf -H 192.168.10.20 -t TCP_STREAM MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.10.20 () port 0 AF_INET Recv Send Send Socket Socket Message Elapsed Size Size Size Time Throughput bytes bytes bytes secs. 10^6bits/sec 131072 16384 16384 10.02 886.69 xilinx-zcu102-20232:~$ netperf -H 192.168.10.20 -t UDP_STREAM MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.10.20 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 65507 10.00 15851 0 830.66 212992 10.00 15851 830.66 Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> Link: https://lore.kernel.org/r/1700074613-1977070-4-git-send-email-radhey.shyam.pandey@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6b1b40f commit 6a91b84

File tree

3 files changed

+425
-2
lines changed

3 files changed

+425
-2
lines changed

drivers/net/ethernet/xilinx/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ config XILINX_EMACLITE
2626
config XILINX_AXI_EMAC
2727
tristate "Xilinx 10/100/1000 AXI Ethernet support"
2828
depends on HAS_IOMEM
29+
depends on XILINX_DMA
2930
select PHYLINK
3031
help
3132
This driver supports the 10/100/1000 Ethernet from Xilinx for the

drivers/net/ethernet/xilinx/xilinx_axienet.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/interrupt.h>
1515
#include <linux/if_vlan.h>
1616
#include <linux/phylink.h>
17+
#include <linux/skbuff.h>
1718

1819
/* Packet size info */
1920
#define XAE_HDR_SIZE 14 /* Size of Ethernet header */
@@ -378,6 +379,22 @@ struct axidma_bd {
378379

379380
#define XAE_NUM_MISC_CLOCKS 3
380381

382+
/**
383+
* struct skbuf_dma_descriptor - skb for each dma descriptor
384+
* @sgl: Pointer for sglist.
385+
* @desc: Pointer to dma descriptor.
386+
* @dma_address: dma address of sglist.
387+
* @skb: Pointer to SKB transferred using DMA
388+
* @sg_len: number of entries in the sglist.
389+
*/
390+
struct skbuf_dma_descriptor {
391+
struct scatterlist sgl[MAX_SKB_FRAGS + 1];
392+
struct dma_async_tx_descriptor *desc;
393+
dma_addr_t dma_address;
394+
struct sk_buff *skb;
395+
int sg_len;
396+
};
397+
381398
/**
382399
* struct axienet_local - axienet private per device data
383400
* @ndev: Pointer for net_device to which it will be attached.
@@ -436,6 +453,14 @@ struct axidma_bd {
436453
* @coalesce_count_tx: Store the irq coalesce on TX side.
437454
* @coalesce_usec_tx: IRQ coalesce delay for TX
438455
* @use_dmaengine: flag to check dmaengine framework usage.
456+
* @tx_chan: TX DMA channel.
457+
* @rx_chan: RX DMA channel.
458+
* @tx_skb_ring: Pointer to TX skb ring buffer array.
459+
* @rx_skb_ring: Pointer to RX skb ring buffer array.
460+
* @tx_ring_head: TX skb ring buffer head index.
461+
* @tx_ring_tail: TX skb ring buffer tail index.
462+
* @rx_ring_head: RX skb ring buffer head index.
463+
* @rx_ring_tail: RX skb ring buffer tail index.
439464
*/
440465
struct axienet_local {
441466
struct net_device *ndev;
@@ -501,6 +526,14 @@ struct axienet_local {
501526
u32 coalesce_count_tx;
502527
u32 coalesce_usec_tx;
503528
u8 use_dmaengine;
529+
struct dma_chan *tx_chan;
530+
struct dma_chan *rx_chan;
531+
struct skbuf_dma_descriptor **tx_skb_ring;
532+
struct skbuf_dma_descriptor **rx_skb_ring;
533+
int tx_ring_head;
534+
int tx_ring_tail;
535+
int rx_ring_head;
536+
int rx_ring_tail;
504537
};
505538

506539
/**

0 commit comments

Comments
 (0)