xref: /openbmc/linux/drivers/net/ethernet/intel/igc/igc_base.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
113b5b7fdSSasha Neftin /* SPDX-License-Identifier: GPL-2.0 */
213b5b7fdSSasha Neftin /* Copyright (c)  2018 Intel Corporation */
313b5b7fdSSasha Neftin 
4ecad77fdSSasha Neftin #ifndef _IGC_BASE_H_
5ecad77fdSSasha Neftin #define _IGC_BASE_H_
613b5b7fdSSasha Neftin 
713b5b7fdSSasha Neftin /* forward declaration */
813b5b7fdSSasha Neftin void igc_rx_fifo_flush_base(struct igc_hw *hw);
95586838fSSasha Neftin void igc_power_down_phy_copper_base(struct igc_hw *hw);
10b8897dc5SMuhammad Husaini Zulkifli bool igc_is_device_id_i225(struct igc_hw *hw);
11b8897dc5SMuhammad Husaini Zulkifli bool igc_is_device_id_i226(struct igc_hw *hw);
1213b5b7fdSSasha Neftin 
1313b5b7fdSSasha Neftin /* Transmit Descriptor - Advanced */
1413b5b7fdSSasha Neftin union igc_adv_tx_desc {
1513b5b7fdSSasha Neftin 	struct {
1613b5b7fdSSasha Neftin 		__le64 buffer_addr;    /* Address of descriptor's data buf */
1713b5b7fdSSasha Neftin 		__le32 cmd_type_len;
1813b5b7fdSSasha Neftin 		__le32 olinfo_status;
1913b5b7fdSSasha Neftin 	} read;
2013b5b7fdSSasha Neftin 	struct {
2113b5b7fdSSasha Neftin 		__le64 rsvd;       /* Reserved */
2213b5b7fdSSasha Neftin 		__le32 nxtseq_seed;
2313b5b7fdSSasha Neftin 		__le32 status;
2413b5b7fdSSasha Neftin 	} wb;
2513b5b7fdSSasha Neftin };
2613b5b7fdSSasha Neftin 
27d3ae3cfbSSasha Neftin /* Context descriptors */
28d3ae3cfbSSasha Neftin struct igc_adv_tx_context_desc {
29d3ae3cfbSSasha Neftin 	__le32 vlan_macip_lens;
30d3ae3cfbSSasha Neftin 	__le32 launch_time;
31d3ae3cfbSSasha Neftin 	__le32 type_tucmd_mlhl;
32d3ae3cfbSSasha Neftin 	__le32 mss_l4len_idx;
33d3ae3cfbSSasha Neftin };
34d3ae3cfbSSasha Neftin 
350507ef8aSSasha Neftin /* Adv Transmit Descriptor Config Masks */
360507ef8aSSasha Neftin #define IGC_ADVTXD_MAC_TSTAMP	0x00080000 /* IEEE1588 Timestamp packet */
37*3ed247e7SVinicius Costa Gomes #define IGC_ADVTXD_TSTAMP_REG_1	0x00010000 /* Select register 1 for timestamp */
38*3ed247e7SVinicius Costa Gomes #define IGC_ADVTXD_TSTAMP_REG_2	0x00020000 /* Select register 2 for timestamp */
39*3ed247e7SVinicius Costa Gomes #define IGC_ADVTXD_TSTAMP_REG_3	0x00030000 /* Select register 3 for timestamp */
400507ef8aSSasha Neftin #define IGC_ADVTXD_DTYP_CTXT	0x00200000 /* Advanced Context Descriptor */
410507ef8aSSasha Neftin #define IGC_ADVTXD_DTYP_DATA	0x00300000 /* Advanced Data Descriptor */
420507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_EOP	0x01000000 /* End of Packet */
430507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_IFCS	0x02000000 /* Insert FCS (Ethernet CRC) */
440507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_RS	0x08000000 /* Report Status */
450507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_DEXT	0x20000000 /* Descriptor extension (1=Adv) */
460507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_VLE	0x40000000 /* VLAN pkt enable */
470507ef8aSSasha Neftin #define IGC_ADVTXD_DCMD_TSE	0x80000000 /* TCP Seg enable */
480507ef8aSSasha Neftin #define IGC_ADVTXD_PAYLEN_SHIFT	14 /* Adv desc PAYLEN shift */
490507ef8aSSasha Neftin 
50c0071c7aSSasha Neftin #define IGC_RAR_ENTRIES		16
51c0071c7aSSasha Neftin 
5213b5b7fdSSasha Neftin /* Receive Descriptor - Advanced */
5313b5b7fdSSasha Neftin union igc_adv_rx_desc {
5413b5b7fdSSasha Neftin 	struct {
5513b5b7fdSSasha Neftin 		__le64 pkt_addr; /* Packet buffer address */
5613b5b7fdSSasha Neftin 		__le64 hdr_addr; /* Header buffer address */
5713b5b7fdSSasha Neftin 	} read;
5813b5b7fdSSasha Neftin 	struct {
5913b5b7fdSSasha Neftin 		struct {
6013b5b7fdSSasha Neftin 			union {
6113b5b7fdSSasha Neftin 				__le32 data;
6213b5b7fdSSasha Neftin 				struct {
6313b5b7fdSSasha Neftin 					__le16 pkt_info; /*RSS type, Pkt type*/
6413b5b7fdSSasha Neftin 					/* Split Header, header buffer len */
6513b5b7fdSSasha Neftin 					__le16 hdr_info;
6613b5b7fdSSasha Neftin 				} hs_rss;
6713b5b7fdSSasha Neftin 			} lo_dword;
6813b5b7fdSSasha Neftin 			union {
6913b5b7fdSSasha Neftin 				__le32 rss; /* RSS Hash */
7013b5b7fdSSasha Neftin 				struct {
7113b5b7fdSSasha Neftin 					__le16 ip_id; /* IP id */
7213b5b7fdSSasha Neftin 					__le16 csum; /* Packet Checksum */
7313b5b7fdSSasha Neftin 				} csum_ip;
7413b5b7fdSSasha Neftin 			} hi_dword;
7513b5b7fdSSasha Neftin 		} lower;
7613b5b7fdSSasha Neftin 		struct {
7713b5b7fdSSasha Neftin 			__le32 status_error; /* ext status/error */
7813b5b7fdSSasha Neftin 			__le16 length; /* Packet length */
7913b5b7fdSSasha Neftin 			__le16 vlan; /* VLAN tag */
8013b5b7fdSSasha Neftin 		} upper;
8113b5b7fdSSasha Neftin 	} wb;  /* writeback */
8213b5b7fdSSasha Neftin };
8313b5b7fdSSasha Neftin 
8413b5b7fdSSasha Neftin /* Additional Transmit Descriptor Control definitions */
8513b5b7fdSSasha Neftin #define IGC_TXDCTL_QUEUE_ENABLE	0x02000000 /* Ena specific Tx Queue */
869acf59a7SAndre Guedes #define IGC_TXDCTL_SWFLUSH	0x04000000 /* Transmit Software Flush */
8713b5b7fdSSasha Neftin 
8813b5b7fdSSasha Neftin /* Additional Receive Descriptor Control definitions */
8913b5b7fdSSasha Neftin #define IGC_RXDCTL_QUEUE_ENABLE	0x02000000 /* Ena specific Rx Queue */
90fc9df2a0SAndre Guedes #define IGC_RXDCTL_SWFLUSH		0x04000000 /* Receive Software Flush */
9113b5b7fdSSasha Neftin 
9213b5b7fdSSasha Neftin /* SRRCTL bit definitions */
933ce29c17SSong Yoong Siang #define IGC_SRRCTL_BSIZEPKT_MASK	GENMASK(6, 0)
943ce29c17SSong Yoong Siang #define IGC_SRRCTL_BSIZEPKT(x)		FIELD_PREP(IGC_SRRCTL_BSIZEPKT_MASK, \
953ce29c17SSong Yoong Siang 					(x) / 1024) /* in 1 KB resolution */
963ce29c17SSong Yoong Siang #define IGC_SRRCTL_BSIZEHDR_MASK	GENMASK(13, 8)
973ce29c17SSong Yoong Siang #define IGC_SRRCTL_BSIZEHDR(x)		FIELD_PREP(IGC_SRRCTL_BSIZEHDR_MASK, \
983ce29c17SSong Yoong Siang 					(x) / 64) /* in 64 bytes resolution */
993ce29c17SSong Yoong Siang #define IGC_SRRCTL_DESCTYPE_MASK	GENMASK(27, 25)
1003ce29c17SSong Yoong Siang #define IGC_SRRCTL_DESCTYPE_ADV_ONEBUF	FIELD_PREP(IGC_SRRCTL_DESCTYPE_MASK, 1)
10113b5b7fdSSasha Neftin 
10213b5b7fdSSasha Neftin #endif /* _IGC_BASE_H */
103