162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  PS3 Platfom gelic network driver.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2007 Sony Computer Entertainment Inc.
662306a36Sopenharmony_ci * Copyright 2006, 2007 Sony Corporation.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This file is based on: spider_net.h
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * (C) Copyright IBM Corp. 2005
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * Authors : Utz Bacher <utz.bacher@de.ibm.com>
1362306a36Sopenharmony_ci *           Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci#ifndef _GELIC_NET_H
1662306a36Sopenharmony_ci#define _GELIC_NET_H
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* descriptors */
1962306a36Sopenharmony_ci#define GELIC_NET_RX_DESCRIPTORS        128 /* num of descriptors */
2062306a36Sopenharmony_ci#define GELIC_NET_TX_DESCRIPTORS        128 /* num of descriptors */
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define GELIC_NET_MAX_FRAME             2312
2362306a36Sopenharmony_ci#define GELIC_NET_MAX_MTU               2294
2462306a36Sopenharmony_ci#define GELIC_NET_MIN_MTU               64
2562306a36Sopenharmony_ci#define GELIC_NET_RXBUF_ALIGN           128
2662306a36Sopenharmony_ci#define GELIC_CARD_RX_CSUM_DEFAULT      1 /* hw chksum */
2762306a36Sopenharmony_ci#define GELIC_NET_WATCHDOG_TIMEOUT      5*HZ
2862306a36Sopenharmony_ci#define GELIC_NET_BROADCAST_ADDR        0xffffffffffffL
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define GELIC_NET_MC_COUNT_MAX          32 /* multicast address list */
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* virtual interrupt status register bits */
3362306a36Sopenharmony_ci	/* INT1 */
3462306a36Sopenharmony_ci#define GELIC_CARD_TX_RAM_FULL_ERR           0x0000000000000001L
3562306a36Sopenharmony_ci#define GELIC_CARD_RX_RAM_FULL_ERR           0x0000000000000002L
3662306a36Sopenharmony_ci#define GELIC_CARD_TX_SHORT_FRAME_ERR        0x0000000000000004L
3762306a36Sopenharmony_ci#define GELIC_CARD_TX_INVALID_DESCR_ERR      0x0000000000000008L
3862306a36Sopenharmony_ci#define GELIC_CARD_RX_FIFO_FULL_ERR          0x0000000000002000L
3962306a36Sopenharmony_ci#define GELIC_CARD_RX_DESCR_CHAIN_END        0x0000000000004000L
4062306a36Sopenharmony_ci#define GELIC_CARD_RX_INVALID_DESCR_ERR      0x0000000000008000L
4162306a36Sopenharmony_ci#define GELIC_CARD_TX_RESPONCE_ERR           0x0000000000010000L
4262306a36Sopenharmony_ci#define GELIC_CARD_RX_RESPONCE_ERR           0x0000000000100000L
4362306a36Sopenharmony_ci#define GELIC_CARD_TX_PROTECTION_ERR         0x0000000000400000L
4462306a36Sopenharmony_ci#define GELIC_CARD_RX_PROTECTION_ERR         0x0000000004000000L
4562306a36Sopenharmony_ci#define GELIC_CARD_TX_TCP_UDP_CHECKSUM_ERR   0x0000000008000000L
4662306a36Sopenharmony_ci#define GELIC_CARD_PORT_STATUS_CHANGED       0x0000000020000000L
4762306a36Sopenharmony_ci#define GELIC_CARD_WLAN_EVENT_RECEIVED       0x0000000040000000L
4862306a36Sopenharmony_ci#define GELIC_CARD_WLAN_COMMAND_COMPLETED    0x0000000080000000L
4962306a36Sopenharmony_ci	/* INT 0 */
5062306a36Sopenharmony_ci#define GELIC_CARD_TX_FLAGGED_DESCR          0x0004000000000000L
5162306a36Sopenharmony_ci#define GELIC_CARD_RX_FLAGGED_DESCR          0x0040000000000000L
5262306a36Sopenharmony_ci#define GELIC_CARD_TX_TRANSFER_END           0x0080000000000000L
5362306a36Sopenharmony_ci#define GELIC_CARD_TX_DESCR_CHAIN_END        0x0100000000000000L
5462306a36Sopenharmony_ci#define GELIC_CARD_NUMBER_OF_RX_FRAME        0x1000000000000000L
5562306a36Sopenharmony_ci#define GELIC_CARD_ONE_TIME_COUNT_TIMER      0x4000000000000000L
5662306a36Sopenharmony_ci#define GELIC_CARD_FREE_RUN_COUNT_TIMER      0x8000000000000000L
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* initial interrupt mask */
5962306a36Sopenharmony_ci#define GELIC_CARD_TXINT	GELIC_CARD_TX_DESCR_CHAIN_END
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define GELIC_CARD_RXINT	(GELIC_CARD_RX_DESCR_CHAIN_END | \
6262306a36Sopenharmony_ci				 GELIC_CARD_NUMBER_OF_RX_FRAME)
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci /* RX descriptor data_status bits */
6562306a36Sopenharmony_cienum gelic_descr_rx_status {
6662306a36Sopenharmony_ci	GELIC_DESCR_RXDMADU	= 0x80000000, /* destination MAC addr unknown */
6762306a36Sopenharmony_ci	GELIC_DESCR_RXLSTFBF	= 0x40000000, /* last frame buffer            */
6862306a36Sopenharmony_ci	GELIC_DESCR_RXIPCHK	= 0x20000000, /* IP checksum performed        */
6962306a36Sopenharmony_ci	GELIC_DESCR_RXTCPCHK	= 0x10000000, /* TCP/UDP checksup performed   */
7062306a36Sopenharmony_ci	GELIC_DESCR_RXWTPKT	= 0x00C00000, /*
7162306a36Sopenharmony_ci					       * wakeup trigger packet
7262306a36Sopenharmony_ci					       * 01: Magic Packet (TM)
7362306a36Sopenharmony_ci					       * 10: ARP packet
7462306a36Sopenharmony_ci					       * 11: Multicast MAC addr
7562306a36Sopenharmony_ci					       */
7662306a36Sopenharmony_ci	GELIC_DESCR_RXVLNPKT	= 0x00200000, /* VLAN packet */
7762306a36Sopenharmony_ci	/* bit 20..16 reserved */
7862306a36Sopenharmony_ci	GELIC_DESCR_RXRRECNUM	= 0x0000ff00, /* reception receipt number */
7962306a36Sopenharmony_ci	/* bit 7..0 reserved */
8062306a36Sopenharmony_ci};
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#define GELIC_DESCR_DATA_STATUS_CHK_MASK	\
8362306a36Sopenharmony_ci	(GELIC_DESCR_RXIPCHK | GELIC_DESCR_RXTCPCHK)
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci /* TX descriptor data_status bits */
8662306a36Sopenharmony_cienum gelic_descr_tx_status {
8762306a36Sopenharmony_ci	GELIC_DESCR_TX_TAIL	= 0x00000001, /* gelic treated this
8862306a36Sopenharmony_ci					       * descriptor was end of
8962306a36Sopenharmony_ci					       * a tx frame
9062306a36Sopenharmony_ci					       */
9162306a36Sopenharmony_ci};
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* RX descriptor data error bits */
9462306a36Sopenharmony_cienum gelic_descr_rx_error {
9562306a36Sopenharmony_ci	/* bit 31 reserved */
9662306a36Sopenharmony_ci	GELIC_DESCR_RXALNERR	= 0x40000000, /* alignement error 10/100M */
9762306a36Sopenharmony_ci	GELIC_DESCR_RXOVERERR	= 0x20000000, /* oversize error */
9862306a36Sopenharmony_ci	GELIC_DESCR_RXRNTERR	= 0x10000000, /* Runt error */
9962306a36Sopenharmony_ci	GELIC_DESCR_RXIPCHKERR	= 0x08000000, /* IP checksum  error */
10062306a36Sopenharmony_ci	GELIC_DESCR_RXTCPCHKERR	= 0x04000000, /* TCP/UDP checksum  error */
10162306a36Sopenharmony_ci	GELIC_DESCR_RXDRPPKT	= 0x00100000, /* drop packet */
10262306a36Sopenharmony_ci	GELIC_DESCR_RXIPFMTERR	= 0x00080000, /* IP packet format error */
10362306a36Sopenharmony_ci	/* bit 18 reserved */
10462306a36Sopenharmony_ci	GELIC_DESCR_RXDATAERR	= 0x00020000, /* IP packet format error */
10562306a36Sopenharmony_ci	GELIC_DESCR_RXCALERR	= 0x00010000, /* cariier extension length
10662306a36Sopenharmony_ci					      * error */
10762306a36Sopenharmony_ci	GELIC_DESCR_RXCREXERR	= 0x00008000, /* carrier extension error */
10862306a36Sopenharmony_ci	GELIC_DESCR_RXMLTCST	= 0x00004000, /* multicast address frame */
10962306a36Sopenharmony_ci	/* bit 13..0 reserved */
11062306a36Sopenharmony_ci};
11162306a36Sopenharmony_ci#define GELIC_DESCR_DATA_ERROR_CHK_MASK		\
11262306a36Sopenharmony_ci	(GELIC_DESCR_RXIPCHKERR | GELIC_DESCR_RXTCPCHKERR)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* DMA command and status (RX and TX)*/
11562306a36Sopenharmony_cienum gelic_descr_dma_status {
11662306a36Sopenharmony_ci	GELIC_DESCR_DMA_COMPLETE            = 0x00000000, /* used in tx */
11762306a36Sopenharmony_ci	GELIC_DESCR_DMA_BUFFER_FULL         = 0x00000000, /* used in rx */
11862306a36Sopenharmony_ci	GELIC_DESCR_DMA_RESPONSE_ERROR      = 0x10000000, /* used in rx, tx */
11962306a36Sopenharmony_ci	GELIC_DESCR_DMA_PROTECTION_ERROR    = 0x20000000, /* used in rx, tx */
12062306a36Sopenharmony_ci	GELIC_DESCR_DMA_FRAME_END           = 0x40000000, /* used in rx */
12162306a36Sopenharmony_ci	GELIC_DESCR_DMA_FORCE_END           = 0x50000000, /* used in rx, tx */
12262306a36Sopenharmony_ci	GELIC_DESCR_DMA_CARDOWNED           = 0xa0000000, /* used in rx, tx */
12362306a36Sopenharmony_ci	GELIC_DESCR_DMA_NOT_IN_USE          = 0xb0000000, /* any other value */
12462306a36Sopenharmony_ci};
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define GELIC_DESCR_DMA_STAT_MASK	(0xf0000000)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/* tx descriptor command and status */
12962306a36Sopenharmony_cienum gelic_descr_tx_dma_status {
13062306a36Sopenharmony_ci	/* [19] */
13162306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_IKE		= 0x00080000, /* IPSEC off */
13262306a36Sopenharmony_ci	/* [18] */
13362306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_FRAME_TAIL	= 0x00040000, /* last descriptor of
13462306a36Sopenharmony_ci						       * the packet
13562306a36Sopenharmony_ci						       */
13662306a36Sopenharmony_ci	/* [17..16] */
13762306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_TCP_CHKSUM	= 0x00020000, /* TCP packet */
13862306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_UDP_CHKSUM	= 0x00030000, /* UDP packet */
13962306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_NO_CHKSUM	= 0x00000000, /* no checksum */
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci	/* [1] */
14262306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_CHAIN_END	= 0x00000002, /* DMA terminated
14362306a36Sopenharmony_ci						       * due to chain end
14462306a36Sopenharmony_ci						       */
14562306a36Sopenharmony_ci};
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci#define GELIC_DESCR_DMA_CMD_NO_CHKSUM	\
14862306a36Sopenharmony_ci	(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
14962306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_NO_CHKSUM)
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define GELIC_DESCR_DMA_CMD_TCP_CHKSUM	\
15262306a36Sopenharmony_ci	(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
15362306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_TCP_CHKSUM)
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci#define GELIC_DESCR_DMA_CMD_UDP_CHKSUM	\
15662306a36Sopenharmony_ci	(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
15762306a36Sopenharmony_ci	GELIC_DESCR_TX_DMA_UDP_CHKSUM)
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cienum gelic_descr_rx_dma_status {
16062306a36Sopenharmony_ci	/* [ 1 ] */
16162306a36Sopenharmony_ci	GELIC_DESCR_RX_DMA_CHAIN_END	= 0x00000002, /* DMA terminated
16262306a36Sopenharmony_ci						       * due to chain end
16362306a36Sopenharmony_ci						       */
16462306a36Sopenharmony_ci};
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci/* for lv1_net_control */
16762306a36Sopenharmony_cienum gelic_lv1_net_control_code {
16862306a36Sopenharmony_ci	GELIC_LV1_GET_MAC_ADDRESS	= 1,
16962306a36Sopenharmony_ci	GELIC_LV1_GET_ETH_PORT_STATUS	= 2,
17062306a36Sopenharmony_ci	GELIC_LV1_SET_NEGOTIATION_MODE	= 3,
17162306a36Sopenharmony_ci	GELIC_LV1_GET_VLAN_ID		= 4,
17262306a36Sopenharmony_ci	GELIC_LV1_SET_WOL		= 5,
17362306a36Sopenharmony_ci	GELIC_LV1_GET_CHANNEL           = 6,
17462306a36Sopenharmony_ci	GELIC_LV1_POST_WLAN_CMD		= 9,
17562306a36Sopenharmony_ci	GELIC_LV1_GET_WLAN_CMD_RESULT	= 10,
17662306a36Sopenharmony_ci	GELIC_LV1_GET_WLAN_EVENT	= 11,
17762306a36Sopenharmony_ci};
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci/* for GELIC_LV1_SET_WOL */
18062306a36Sopenharmony_cienum gelic_lv1_wol_command {
18162306a36Sopenharmony_ci	GELIC_LV1_WOL_MAGIC_PACKET	= 1,
18262306a36Sopenharmony_ci	GELIC_LV1_WOL_ADD_MATCH_ADDR	= 6,
18362306a36Sopenharmony_ci	GELIC_LV1_WOL_DELETE_MATCH_ADDR	= 7,
18462306a36Sopenharmony_ci};
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci/* for GELIC_LV1_WOL_MAGIC_PACKET */
18762306a36Sopenharmony_cienum gelic_lv1_wol_mp_arg {
18862306a36Sopenharmony_ci	GELIC_LV1_WOL_MP_DISABLE	= 0,
18962306a36Sopenharmony_ci	GELIC_LV1_WOL_MP_ENABLE		= 1,
19062306a36Sopenharmony_ci};
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci/* for GELIC_LV1_WOL_{ADD,DELETE}_MATCH_ADDR */
19362306a36Sopenharmony_cienum gelic_lv1_wol_match_arg {
19462306a36Sopenharmony_ci	GELIC_LV1_WOL_MATCH_INDIVIDUAL	= 0,
19562306a36Sopenharmony_ci	GELIC_LV1_WOL_MATCH_ALL		= 1,
19662306a36Sopenharmony_ci};
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/* status returened from GET_ETH_PORT_STATUS */
19962306a36Sopenharmony_cienum gelic_lv1_ether_port_status {
20062306a36Sopenharmony_ci	GELIC_LV1_ETHER_LINK_UP		= 0x0000000000000001L,
20162306a36Sopenharmony_ci	GELIC_LV1_ETHER_FULL_DUPLEX	= 0x0000000000000002L,
20262306a36Sopenharmony_ci	GELIC_LV1_ETHER_AUTO_NEG	= 0x0000000000000004L,
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci	GELIC_LV1_ETHER_SPEED_10	= 0x0000000000000010L,
20562306a36Sopenharmony_ci	GELIC_LV1_ETHER_SPEED_100	= 0x0000000000000020L,
20662306a36Sopenharmony_ci	GELIC_LV1_ETHER_SPEED_1000	= 0x0000000000000040L,
20762306a36Sopenharmony_ci	GELIC_LV1_ETHER_SPEED_MASK	= 0x0000000000000070L,
20862306a36Sopenharmony_ci};
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_cienum gelic_lv1_vlan_index {
21162306a36Sopenharmony_ci	/* for outgoing packets */
21262306a36Sopenharmony_ci	GELIC_LV1_VLAN_TX_ETHERNET_0	= 0x0000000000000002L,
21362306a36Sopenharmony_ci	GELIC_LV1_VLAN_TX_WIRELESS	= 0x0000000000000003L,
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci	/* for incoming packets */
21662306a36Sopenharmony_ci	GELIC_LV1_VLAN_RX_ETHERNET_0	= 0x0000000000000012L,
21762306a36Sopenharmony_ci	GELIC_LV1_VLAN_RX_WIRELESS	= 0x0000000000000013L,
21862306a36Sopenharmony_ci};
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cienum gelic_lv1_phy {
22162306a36Sopenharmony_ci	GELIC_LV1_PHY_ETHERNET_0	= 0x0000000000000002L,
22262306a36Sopenharmony_ci};
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci/* size of hardware part of gelic descriptor */
22562306a36Sopenharmony_ci#define GELIC_DESCR_SIZE	(32)
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_cienum gelic_port_type {
22862306a36Sopenharmony_ci	GELIC_PORT_ETHERNET_0	= 0,
22962306a36Sopenharmony_ci	GELIC_PORT_WIRELESS	= 1,
23062306a36Sopenharmony_ci	GELIC_PORT_MAX
23162306a36Sopenharmony_ci};
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_cistruct gelic_descr {
23462306a36Sopenharmony_ci	/* as defined by the hardware */
23562306a36Sopenharmony_ci	__be32 buf_addr;
23662306a36Sopenharmony_ci	__be32 buf_size;
23762306a36Sopenharmony_ci	__be32 next_descr_addr;
23862306a36Sopenharmony_ci	__be32 dmac_cmd_status;
23962306a36Sopenharmony_ci	__be32 result_size;
24062306a36Sopenharmony_ci	__be32 valid_size;	/* all zeroes for tx */
24162306a36Sopenharmony_ci	__be32 data_status;
24262306a36Sopenharmony_ci	__be32 data_error;	/* all zeroes for tx */
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci	/* used in the driver */
24562306a36Sopenharmony_ci	struct sk_buff *skb;
24662306a36Sopenharmony_ci	dma_addr_t bus_addr;
24762306a36Sopenharmony_ci	struct gelic_descr *next;
24862306a36Sopenharmony_ci	struct gelic_descr *prev;
24962306a36Sopenharmony_ci} __attribute__((aligned(32)));
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_cistruct gelic_descr_chain {
25262306a36Sopenharmony_ci	/* we walk from tail to head */
25362306a36Sopenharmony_ci	struct gelic_descr *head;
25462306a36Sopenharmony_ci	struct gelic_descr *tail;
25562306a36Sopenharmony_ci};
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_cistruct gelic_vlan_id {
25862306a36Sopenharmony_ci	u16 tx;
25962306a36Sopenharmony_ci	u16 rx;
26062306a36Sopenharmony_ci};
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_cistruct gelic_card {
26362306a36Sopenharmony_ci	struct napi_struct napi;
26462306a36Sopenharmony_ci	struct net_device *netdev[GELIC_PORT_MAX];
26562306a36Sopenharmony_ci	/*
26662306a36Sopenharmony_ci	 * hypervisor requires irq_status should be
26762306a36Sopenharmony_ci	 * 8 bytes aligned, but u64 member is
26862306a36Sopenharmony_ci	 * always disposed in that manner
26962306a36Sopenharmony_ci	 */
27062306a36Sopenharmony_ci	u64 irq_status;
27162306a36Sopenharmony_ci	u64 irq_mask;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	struct ps3_system_bus_device *dev;
27462306a36Sopenharmony_ci	struct gelic_vlan_id vlan[GELIC_PORT_MAX];
27562306a36Sopenharmony_ci	int vlan_required;
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci	struct gelic_descr_chain tx_chain;
27862306a36Sopenharmony_ci	struct gelic_descr_chain rx_chain;
27962306a36Sopenharmony_ci	/*
28062306a36Sopenharmony_ci	 * tx_lock guards tx descriptor list and
28162306a36Sopenharmony_ci	 * tx_dma_progress.
28262306a36Sopenharmony_ci	 */
28362306a36Sopenharmony_ci	spinlock_t tx_lock;
28462306a36Sopenharmony_ci	int tx_dma_progress;
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci	struct work_struct tx_timeout_task;
28762306a36Sopenharmony_ci	atomic_t tx_timeout_task_counter;
28862306a36Sopenharmony_ci	wait_queue_head_t waitq;
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci	/* only first user should up the card */
29162306a36Sopenharmony_ci	struct mutex updown_lock;
29262306a36Sopenharmony_ci	atomic_t users;
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci	u64 ether_port_status;
29562306a36Sopenharmony_ci	int link_mode;
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci	/* original address returned by kzalloc */
29862306a36Sopenharmony_ci	void *unalign;
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci	/*
30162306a36Sopenharmony_ci	 * each netdevice has copy of irq
30262306a36Sopenharmony_ci	 */
30362306a36Sopenharmony_ci	unsigned int irq;
30462306a36Sopenharmony_ci	struct gelic_descr *tx_top, *rx_top;
30562306a36Sopenharmony_ci	struct gelic_descr descr[]; /* must be the last */
30662306a36Sopenharmony_ci};
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_cistruct gelic_port {
30962306a36Sopenharmony_ci	struct gelic_card *card;
31062306a36Sopenharmony_ci	struct net_device *netdev;
31162306a36Sopenharmony_ci	enum gelic_port_type type;
31262306a36Sopenharmony_ci	long priv[]; /* long for alignment */
31362306a36Sopenharmony_ci};
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_cistatic inline struct gelic_card *port_to_card(struct gelic_port *p)
31662306a36Sopenharmony_ci{
31762306a36Sopenharmony_ci	return p->card;
31862306a36Sopenharmony_ci}
31962306a36Sopenharmony_cistatic inline struct net_device *port_to_netdev(struct gelic_port *p)
32062306a36Sopenharmony_ci{
32162306a36Sopenharmony_ci	return p->netdev;
32262306a36Sopenharmony_ci}
32362306a36Sopenharmony_cistatic inline struct gelic_card *netdev_card(struct net_device *d)
32462306a36Sopenharmony_ci{
32562306a36Sopenharmony_ci	return ((struct gelic_port *)netdev_priv(d))->card;
32662306a36Sopenharmony_ci}
32762306a36Sopenharmony_cistatic inline struct gelic_port *netdev_port(struct net_device *d)
32862306a36Sopenharmony_ci{
32962306a36Sopenharmony_ci	return (struct gelic_port *)netdev_priv(d);
33062306a36Sopenharmony_ci}
33162306a36Sopenharmony_cistatic inline struct device *ctodev(struct gelic_card *card)
33262306a36Sopenharmony_ci{
33362306a36Sopenharmony_ci	return &card->dev->core;
33462306a36Sopenharmony_ci}
33562306a36Sopenharmony_cistatic inline u64 bus_id(struct gelic_card *card)
33662306a36Sopenharmony_ci{
33762306a36Sopenharmony_ci	return card->dev->bus_id;
33862306a36Sopenharmony_ci}
33962306a36Sopenharmony_cistatic inline u64 dev_id(struct gelic_card *card)
34062306a36Sopenharmony_ci{
34162306a36Sopenharmony_ci	return card->dev->dev_id;
34262306a36Sopenharmony_ci}
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_cistatic inline void *port_priv(struct gelic_port *port)
34562306a36Sopenharmony_ci{
34662306a36Sopenharmony_ci	return port->priv;
34762306a36Sopenharmony_ci}
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC
35062306a36Sopenharmony_civoid udbg_shutdown_ps3gelic(void);
35162306a36Sopenharmony_ci#else
35262306a36Sopenharmony_cistatic inline void udbg_shutdown_ps3gelic(void) {}
35362306a36Sopenharmony_ci#endif
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ciint gelic_card_set_irq_mask(struct gelic_card *card, u64 mask);
35662306a36Sopenharmony_ci/* shared netdev ops */
35762306a36Sopenharmony_civoid gelic_card_up(struct gelic_card *card);
35862306a36Sopenharmony_civoid gelic_card_down(struct gelic_card *card);
35962306a36Sopenharmony_ciint gelic_net_open(struct net_device *netdev);
36062306a36Sopenharmony_ciint gelic_net_stop(struct net_device *netdev);
36162306a36Sopenharmony_cinetdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
36262306a36Sopenharmony_civoid gelic_net_set_multi(struct net_device *netdev);
36362306a36Sopenharmony_civoid gelic_net_tx_timeout(struct net_device *netdev, unsigned int txqueue);
36462306a36Sopenharmony_ciint gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card);
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci/* shared ethtool ops */
36762306a36Sopenharmony_civoid gelic_net_get_drvinfo(struct net_device *netdev,
36862306a36Sopenharmony_ci			   struct ethtool_drvinfo *info);
36962306a36Sopenharmony_civoid gelic_net_poll_controller(struct net_device *netdev);
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci#endif /* _GELIC_NET_H */
372