1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Applied Micro X-Gene SoC Ethernet v2 Driver
5 * Copyright (c) 2017, Applied Micro Circuits Corporation
6 * Author(s): Iyappan Subramanian <isubramanian@apm.com>
7 * Keyur Chudgar <kchudgar@apm.com>
10 #ifndef __XGENE_ENET_V2_RING_H__
11 #define __XGENE_ENET_V2_RING_H__
13 #define XGENE_ENET_DESC_SIZE 64
14 #define XGENE_ENET_NUM_DESC 256
16 #define SLOT_EMPTY 0xfff
18 #define DMATXCTRL 0xa180
19 #define DMATXDESCL 0xa184
20 #define DMATXDESCH 0xa1a0
21 #define DMATXSTATUS 0xa188
22 #define DMARXCTRL 0xa18c
23 #define DMARXDESCL 0xa190
24 #define DMARXDESCH 0xa1a4
25 #define DMARXSTATUS 0xa194
26 #define DMAINTRMASK 0xa198
27 #define DMAINTERRUPT 0xa19c
33 #define PKT_ADDRL_POS 0
34 #define PKT_ADDRL_LEN 32
35 #define PKT_ADDRH_POS 32
36 #define PKT_ADDRH_LEN 10
37 #define PKT_SIZE_POS 32
38 #define PKT_SIZE_LEN 12
39 #define NEXT_DESC_ADDRL_POS 0
40 #define NEXT_DESC_ADDRL_LEN 32
41 #define NEXT_DESC_ADDRH_POS 48
42 #define NEXT_DESC_ADDRH_LEN 10
44 #define TXPKTCOUNT_POS 16
45 #define TXPKTCOUNT_LEN 8
46 #define RXPKTCOUNT_POS 16
47 #define RXPKTCOUNT_LEN 8
49 #define TX_PKT_SENT BIT(0)
50 #define TX_BUS_ERROR BIT(3)
51 #define RX_PKT_RCVD BIT(4)
52 #define RX_BUS_ERROR BIT(7)
53 #define RXSTATUS_RXPKTRCVD BIT(0)
72 /* software context of a descriptor ring */
73 struct xge_desc_ring
{
74 struct net_device
*ndev
;
80 struct xge_raw_desc
*raw_desc
;
82 struct pkt_info (*pkt_info
);
85 static inline u64
xge_set_desc_bits(int pos
, int len
, u64 val
)
87 return (val
& ((1ULL << len
) - 1)) << pos
;
90 static inline u64
xge_get_desc_bits(int pos
, int len
, u64 src
)
92 return (src
>> pos
) & ((1ULL << len
) - 1);
95 #define SET_BITS(field, val) \
96 xge_set_desc_bits(field ## _POS, field ## _LEN, val)
98 #define GET_BITS(field, src) \
99 xge_get_desc_bits(field ## _POS, field ## _LEN, src)
101 void xge_setup_desc(struct xge_desc_ring
*ring
);
102 void xge_update_tx_desc_addr(struct xge_pdata
*pdata
);
103 void xge_update_rx_desc_addr(struct xge_pdata
*pdata
);
104 void xge_intr_enable(struct xge_pdata
*pdata
);
105 void xge_intr_disable(struct xge_pdata
*pdata
);
107 #endif /* __XGENE_ENET_V2_RING_H__ */