18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  linux/drivers/net/ethernet/ibm/ehea/ehea.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  eHEA ethernet device driver for IBM eServer System p
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  (C) Copyright IBM Corp. 2006
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci *  Authors:
108c2ecf20Sopenharmony_ci *       Christoph Raisch <raisch@de.ibm.com>
118c2ecf20Sopenharmony_ci *       Jan-Bernd Themann <themann@de.ibm.com>
128c2ecf20Sopenharmony_ci *       Thomas Klein <tklein@de.ibm.com>
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifndef __EHEA_H__
168c2ecf20Sopenharmony_ci#define __EHEA_H__
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <linux/module.h>
198c2ecf20Sopenharmony_ci#include <linux/ethtool.h>
208c2ecf20Sopenharmony_ci#include <linux/vmalloc.h>
218c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <asm/ibmebus.h>
248c2ecf20Sopenharmony_ci#include <asm/io.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define DRV_NAME	"ehea"
278c2ecf20Sopenharmony_ci#define DRV_VERSION	"EHEA_0107"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* eHEA capability flags */
308c2ecf20Sopenharmony_ci#define DLPAR_PORT_ADD_REM 1
318c2ecf20Sopenharmony_ci#define DLPAR_MEM_ADD      2
328c2ecf20Sopenharmony_ci#define DLPAR_MEM_REM      4
338c2ecf20Sopenharmony_ci#define EHEA_CAPABILITIES  (DLPAR_PORT_ADD_REM | DLPAR_MEM_ADD | DLPAR_MEM_REM)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
368c2ecf20Sopenharmony_ci	| NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define EHEA_MAX_ENTRIES_RQ1 32767
398c2ecf20Sopenharmony_ci#define EHEA_MAX_ENTRIES_RQ2 16383
408c2ecf20Sopenharmony_ci#define EHEA_MAX_ENTRIES_RQ3 16383
418c2ecf20Sopenharmony_ci#define EHEA_MAX_ENTRIES_SQ  32767
428c2ecf20Sopenharmony_ci#define EHEA_MIN_ENTRIES_QP  127
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define EHEA_SMALL_QUEUES
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifdef EHEA_SMALL_QUEUES
478c2ecf20Sopenharmony_ci#define EHEA_MAX_CQE_COUNT      1023
488c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_SQ     1023
498c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ1    1023
508c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ2    1023
518c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ3    511
528c2ecf20Sopenharmony_ci#else
538c2ecf20Sopenharmony_ci#define EHEA_MAX_CQE_COUNT      4080
548c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_SQ     4080
558c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ1    8160
568c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ2    2040
578c2ecf20Sopenharmony_ci#define EHEA_DEF_ENTRIES_RQ3    2040
588c2ecf20Sopenharmony_ci#endif
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define EHEA_MAX_ENTRIES_EQ 20
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define EHEA_SG_SQ  2
638c2ecf20Sopenharmony_ci#define EHEA_SG_RQ1 1
648c2ecf20Sopenharmony_ci#define EHEA_SG_RQ2 0
658c2ecf20Sopenharmony_ci#define EHEA_SG_RQ3 0
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define EHEA_MAX_PACKET_SIZE    9022	/* for jumbo frames */
688c2ecf20Sopenharmony_ci#define EHEA_RQ2_PKT_SIZE       2048
698c2ecf20Sopenharmony_ci#define EHEA_L_PKT_SIZE         256	/* low latency */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* Send completion signaling */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* Protection Domain Identifier */
748c2ecf20Sopenharmony_ci#define EHEA_PD_ID        0xaabcdeff
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define EHEA_RQ2_THRESHOLD 	   1
778c2ecf20Sopenharmony_ci#define EHEA_RQ3_THRESHOLD	   4	/* use RQ3 threshold of 2048 bytes */
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define EHEA_SPEED_10G         10000
808c2ecf20Sopenharmony_ci#define EHEA_SPEED_1G           1000
818c2ecf20Sopenharmony_ci#define EHEA_SPEED_100M          100
828c2ecf20Sopenharmony_ci#define EHEA_SPEED_10M            10
838c2ecf20Sopenharmony_ci#define EHEA_SPEED_AUTONEG         0
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/* Broadcast/Multicast registration types */
868c2ecf20Sopenharmony_ci#define EHEA_BCMC_SCOPE_ALL	0x08
878c2ecf20Sopenharmony_ci#define EHEA_BCMC_SCOPE_SINGLE	0x00
888c2ecf20Sopenharmony_ci#define EHEA_BCMC_MULTICAST	0x04
898c2ecf20Sopenharmony_ci#define EHEA_BCMC_BROADCAST	0x00
908c2ecf20Sopenharmony_ci#define EHEA_BCMC_UNTAGGED	0x02
918c2ecf20Sopenharmony_ci#define EHEA_BCMC_TAGGED	0x00
928c2ecf20Sopenharmony_ci#define EHEA_BCMC_VLANID_ALL	0x01
938c2ecf20Sopenharmony_ci#define EHEA_BCMC_VLANID_SINGLE	0x00
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define EHEA_CACHE_LINE          128
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/* Memory Regions */
988c2ecf20Sopenharmony_ci#define EHEA_MR_ACC_CTRL       0x00800000
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define EHEA_BUSMAP_START      0x8000000000000000ULL
1018c2ecf20Sopenharmony_ci#define EHEA_INVAL_ADDR        0xFFFFFFFFFFFFFFFFULL
1028c2ecf20Sopenharmony_ci#define EHEA_DIR_INDEX_SHIFT 13                   /* 8k Entries in 64k block */
1038c2ecf20Sopenharmony_ci#define EHEA_TOP_INDEX_SHIFT (EHEA_DIR_INDEX_SHIFT * 2)
1048c2ecf20Sopenharmony_ci#define EHEA_MAP_ENTRIES (1 << EHEA_DIR_INDEX_SHIFT)
1058c2ecf20Sopenharmony_ci#define EHEA_MAP_SIZE (0x10000)                   /* currently fixed map size */
1068c2ecf20Sopenharmony_ci#define EHEA_INDEX_MASK (EHEA_MAP_ENTRIES - 1)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define EHEA_WATCH_DOG_TIMEOUT 10*HZ
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* utility functions */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_civoid ehea_dump(void *adr, int len, char *msg);
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define EHEA_BMASK(pos, length) (((pos) << 16) + (length))
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define EHEA_BMASK_IBM(from, to) (((63 - to) << 16) + ((to) - (from) + 1))
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define EHEA_BMASK_SHIFTPOS(mask) (((mask) >> 16) & 0xffff)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define EHEA_BMASK_MASK(mask) \
1228c2ecf20Sopenharmony_ci	(0xffffffffffffffffULL >> ((64 - (mask)) & 0xffff))
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define EHEA_BMASK_SET(mask, value) \
1258c2ecf20Sopenharmony_ci	((EHEA_BMASK_MASK(mask) & ((u64)(value))) << EHEA_BMASK_SHIFTPOS(mask))
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define EHEA_BMASK_GET(mask, value) \
1288c2ecf20Sopenharmony_ci	(EHEA_BMASK_MASK(mask) & (((u64)(value)) >> EHEA_BMASK_SHIFTPOS(mask)))
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/*
1318c2ecf20Sopenharmony_ci * Generic ehea page
1328c2ecf20Sopenharmony_ci */
1338c2ecf20Sopenharmony_cistruct ehea_page {
1348c2ecf20Sopenharmony_ci	u8 entries[PAGE_SIZE];
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/*
1388c2ecf20Sopenharmony_ci * Generic queue in linux kernel virtual memory
1398c2ecf20Sopenharmony_ci */
1408c2ecf20Sopenharmony_cistruct hw_queue {
1418c2ecf20Sopenharmony_ci	u64 current_q_offset;		/* current queue entry */
1428c2ecf20Sopenharmony_ci	struct ehea_page **queue_pages;	/* array of pages belonging to queue */
1438c2ecf20Sopenharmony_ci	u32 qe_size;			/* queue entry size */
1448c2ecf20Sopenharmony_ci	u32 queue_length;      		/* queue length allocated in bytes */
1458c2ecf20Sopenharmony_ci	u32 pagesize;
1468c2ecf20Sopenharmony_ci	u32 toggle_state;		/* toggle flag - per page */
1478c2ecf20Sopenharmony_ci	u32 reserved;			/* 64 bit alignment */
1488c2ecf20Sopenharmony_ci};
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/*
1518c2ecf20Sopenharmony_ci * For pSeries this is a 64bit memory address where
1528c2ecf20Sopenharmony_ci * I/O memory is mapped into CPU address space
1538c2ecf20Sopenharmony_ci */
1548c2ecf20Sopenharmony_cistruct h_epa {
1558c2ecf20Sopenharmony_ci	void __iomem *addr;
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistruct h_epa_user {
1598c2ecf20Sopenharmony_ci	u64 addr;
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistruct h_epas {
1638c2ecf20Sopenharmony_ci	struct h_epa kernel;	/* kernel space accessible resource,
1648c2ecf20Sopenharmony_ci				   set to 0 if unused */
1658c2ecf20Sopenharmony_ci	struct h_epa_user user;	/* user space accessible resource
1668c2ecf20Sopenharmony_ci				   set to 0 if unused */
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/*
1708c2ecf20Sopenharmony_ci * Memory map data structures
1718c2ecf20Sopenharmony_ci */
1728c2ecf20Sopenharmony_cistruct ehea_dir_bmap
1738c2ecf20Sopenharmony_ci{
1748c2ecf20Sopenharmony_ci	u64 ent[EHEA_MAP_ENTRIES];
1758c2ecf20Sopenharmony_ci};
1768c2ecf20Sopenharmony_cistruct ehea_top_bmap
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	struct ehea_dir_bmap *dir[EHEA_MAP_ENTRIES];
1798c2ecf20Sopenharmony_ci};
1808c2ecf20Sopenharmony_cistruct ehea_bmap
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	struct ehea_top_bmap *top[EHEA_MAP_ENTRIES];
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistruct ehea_qp;
1868c2ecf20Sopenharmony_cistruct ehea_cq;
1878c2ecf20Sopenharmony_cistruct ehea_eq;
1888c2ecf20Sopenharmony_cistruct ehea_port;
1898c2ecf20Sopenharmony_cistruct ehea_av;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/*
1928c2ecf20Sopenharmony_ci * Queue attributes passed to ehea_create_qp()
1938c2ecf20Sopenharmony_ci */
1948c2ecf20Sopenharmony_cistruct ehea_qp_init_attr {
1958c2ecf20Sopenharmony_ci	/* input parameter */
1968c2ecf20Sopenharmony_ci	u32 qp_token;           /* queue token */
1978c2ecf20Sopenharmony_ci	u8 low_lat_rq1;
1988c2ecf20Sopenharmony_ci	u8 signalingtype;       /* cqe generation flag */
1998c2ecf20Sopenharmony_ci	u8 rq_count;            /* num of receive queues */
2008c2ecf20Sopenharmony_ci	u8 eqe_gen;             /* eqe generation flag */
2018c2ecf20Sopenharmony_ci	u16 max_nr_send_wqes;   /* max number of send wqes */
2028c2ecf20Sopenharmony_ci	u16 max_nr_rwqes_rq1;   /* max number of receive wqes */
2038c2ecf20Sopenharmony_ci	u16 max_nr_rwqes_rq2;
2048c2ecf20Sopenharmony_ci	u16 max_nr_rwqes_rq3;
2058c2ecf20Sopenharmony_ci	u8 wqe_size_enc_sq;
2068c2ecf20Sopenharmony_ci	u8 wqe_size_enc_rq1;
2078c2ecf20Sopenharmony_ci	u8 wqe_size_enc_rq2;
2088c2ecf20Sopenharmony_ci	u8 wqe_size_enc_rq3;
2098c2ecf20Sopenharmony_ci	u8 swqe_imm_data_len;   /* immediate data length for swqes */
2108c2ecf20Sopenharmony_ci	u16 port_nr;
2118c2ecf20Sopenharmony_ci	u16 rq2_threshold;
2128c2ecf20Sopenharmony_ci	u16 rq3_threshold;
2138c2ecf20Sopenharmony_ci	u64 send_cq_handle;
2148c2ecf20Sopenharmony_ci	u64 recv_cq_handle;
2158c2ecf20Sopenharmony_ci	u64 aff_eq_handle;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	/* output parameter */
2188c2ecf20Sopenharmony_ci	u32 qp_nr;
2198c2ecf20Sopenharmony_ci	u16 act_nr_send_wqes;
2208c2ecf20Sopenharmony_ci	u16 act_nr_rwqes_rq1;
2218c2ecf20Sopenharmony_ci	u16 act_nr_rwqes_rq2;
2228c2ecf20Sopenharmony_ci	u16 act_nr_rwqes_rq3;
2238c2ecf20Sopenharmony_ci	u8 act_wqe_size_enc_sq;
2248c2ecf20Sopenharmony_ci	u8 act_wqe_size_enc_rq1;
2258c2ecf20Sopenharmony_ci	u8 act_wqe_size_enc_rq2;
2268c2ecf20Sopenharmony_ci	u8 act_wqe_size_enc_rq3;
2278c2ecf20Sopenharmony_ci	u32 nr_sq_pages;
2288c2ecf20Sopenharmony_ci	u32 nr_rq1_pages;
2298c2ecf20Sopenharmony_ci	u32 nr_rq2_pages;
2308c2ecf20Sopenharmony_ci	u32 nr_rq3_pages;
2318c2ecf20Sopenharmony_ci	u32 liobn_sq;
2328c2ecf20Sopenharmony_ci	u32 liobn_rq1;
2338c2ecf20Sopenharmony_ci	u32 liobn_rq2;
2348c2ecf20Sopenharmony_ci	u32 liobn_rq3;
2358c2ecf20Sopenharmony_ci};
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci/*
2388c2ecf20Sopenharmony_ci * Event Queue attributes, passed as parameter
2398c2ecf20Sopenharmony_ci */
2408c2ecf20Sopenharmony_cistruct ehea_eq_attr {
2418c2ecf20Sopenharmony_ci	u32 type;
2428c2ecf20Sopenharmony_ci	u32 max_nr_of_eqes;
2438c2ecf20Sopenharmony_ci	u8 eqe_gen;        /* generate eqe flag */
2448c2ecf20Sopenharmony_ci	u64 eq_handle;
2458c2ecf20Sopenharmony_ci	u32 act_nr_of_eqes;
2468c2ecf20Sopenharmony_ci	u32 nr_pages;
2478c2ecf20Sopenharmony_ci	u32 ist1;          /* Interrupt service token */
2488c2ecf20Sopenharmony_ci	u32 ist2;
2498c2ecf20Sopenharmony_ci	u32 ist3;
2508c2ecf20Sopenharmony_ci	u32 ist4;
2518c2ecf20Sopenharmony_ci};
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/*
2558c2ecf20Sopenharmony_ci * Event Queue
2568c2ecf20Sopenharmony_ci */
2578c2ecf20Sopenharmony_cistruct ehea_eq {
2588c2ecf20Sopenharmony_ci	struct ehea_adapter *adapter;
2598c2ecf20Sopenharmony_ci	struct hw_queue hw_queue;
2608c2ecf20Sopenharmony_ci	u64 fw_handle;
2618c2ecf20Sopenharmony_ci	struct h_epas epas;
2628c2ecf20Sopenharmony_ci	spinlock_t spinlock;
2638c2ecf20Sopenharmony_ci	struct ehea_eq_attr attr;
2648c2ecf20Sopenharmony_ci};
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci/*
2678c2ecf20Sopenharmony_ci * HEA Queues
2688c2ecf20Sopenharmony_ci */
2698c2ecf20Sopenharmony_cistruct ehea_qp {
2708c2ecf20Sopenharmony_ci	struct ehea_adapter *adapter;
2718c2ecf20Sopenharmony_ci	u64 fw_handle;			/* QP handle for firmware calls */
2728c2ecf20Sopenharmony_ci	struct hw_queue hw_squeue;
2738c2ecf20Sopenharmony_ci	struct hw_queue hw_rqueue1;
2748c2ecf20Sopenharmony_ci	struct hw_queue hw_rqueue2;
2758c2ecf20Sopenharmony_ci	struct hw_queue hw_rqueue3;
2768c2ecf20Sopenharmony_ci	struct h_epas epas;
2778c2ecf20Sopenharmony_ci	struct ehea_qp_init_attr init_attr;
2788c2ecf20Sopenharmony_ci};
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci/*
2818c2ecf20Sopenharmony_ci * Completion Queue attributes
2828c2ecf20Sopenharmony_ci */
2838c2ecf20Sopenharmony_cistruct ehea_cq_attr {
2848c2ecf20Sopenharmony_ci	/* input parameter */
2858c2ecf20Sopenharmony_ci	u32 max_nr_of_cqes;
2868c2ecf20Sopenharmony_ci	u32 cq_token;
2878c2ecf20Sopenharmony_ci	u64 eq_handle;
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	/* output parameter */
2908c2ecf20Sopenharmony_ci	u32 act_nr_of_cqes;
2918c2ecf20Sopenharmony_ci	u32 nr_pages;
2928c2ecf20Sopenharmony_ci};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci/*
2958c2ecf20Sopenharmony_ci * Completion Queue
2968c2ecf20Sopenharmony_ci */
2978c2ecf20Sopenharmony_cistruct ehea_cq {
2988c2ecf20Sopenharmony_ci	struct ehea_adapter *adapter;
2998c2ecf20Sopenharmony_ci	u64 fw_handle;
3008c2ecf20Sopenharmony_ci	struct hw_queue hw_queue;
3018c2ecf20Sopenharmony_ci	struct h_epas epas;
3028c2ecf20Sopenharmony_ci	struct ehea_cq_attr attr;
3038c2ecf20Sopenharmony_ci};
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci/*
3068c2ecf20Sopenharmony_ci * Memory Region
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_cistruct ehea_mr {
3098c2ecf20Sopenharmony_ci	struct ehea_adapter *adapter;
3108c2ecf20Sopenharmony_ci	u64 handle;
3118c2ecf20Sopenharmony_ci	u64 vaddr;
3128c2ecf20Sopenharmony_ci	u32 lkey;
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci/*
3168c2ecf20Sopenharmony_ci * Port state information
3178c2ecf20Sopenharmony_ci */
3188c2ecf20Sopenharmony_cistruct port_stats {
3198c2ecf20Sopenharmony_ci	int poll_receive_errors;
3208c2ecf20Sopenharmony_ci	int queue_stopped;
3218c2ecf20Sopenharmony_ci	int err_tcp_cksum;
3228c2ecf20Sopenharmony_ci	int err_ip_cksum;
3238c2ecf20Sopenharmony_ci	int err_frame_crc;
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci#define EHEA_IRQ_NAME_SIZE 20
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/*
3298c2ecf20Sopenharmony_ci * Queue SKB Array
3308c2ecf20Sopenharmony_ci */
3318c2ecf20Sopenharmony_cistruct ehea_q_skb_arr {
3328c2ecf20Sopenharmony_ci	struct sk_buff **arr;		/* skb array for queue */
3338c2ecf20Sopenharmony_ci	int len;                	/* array length */
3348c2ecf20Sopenharmony_ci	int index;			/* array index */
3358c2ecf20Sopenharmony_ci	int os_skbs;			/* rq2/rq3 only: outstanding skbs */
3368c2ecf20Sopenharmony_ci};
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci/*
3398c2ecf20Sopenharmony_ci * Port resources
3408c2ecf20Sopenharmony_ci */
3418c2ecf20Sopenharmony_cistruct ehea_port_res {
3428c2ecf20Sopenharmony_ci	struct napi_struct napi;
3438c2ecf20Sopenharmony_ci	struct port_stats p_stats;
3448c2ecf20Sopenharmony_ci	struct ehea_mr send_mr;       	/* send memory region */
3458c2ecf20Sopenharmony_ci	struct ehea_mr recv_mr;       	/* receive memory region */
3468c2ecf20Sopenharmony_ci	struct ehea_port *port;
3478c2ecf20Sopenharmony_ci	char int_recv_name[EHEA_IRQ_NAME_SIZE];
3488c2ecf20Sopenharmony_ci	char int_send_name[EHEA_IRQ_NAME_SIZE];
3498c2ecf20Sopenharmony_ci	struct ehea_qp *qp;
3508c2ecf20Sopenharmony_ci	struct ehea_cq *send_cq;
3518c2ecf20Sopenharmony_ci	struct ehea_cq *recv_cq;
3528c2ecf20Sopenharmony_ci	struct ehea_eq *eq;
3538c2ecf20Sopenharmony_ci	struct ehea_q_skb_arr rq1_skba;
3548c2ecf20Sopenharmony_ci	struct ehea_q_skb_arr rq2_skba;
3558c2ecf20Sopenharmony_ci	struct ehea_q_skb_arr rq3_skba;
3568c2ecf20Sopenharmony_ci	struct ehea_q_skb_arr sq_skba;
3578c2ecf20Sopenharmony_ci	int sq_skba_size;
3588c2ecf20Sopenharmony_ci	int swqe_refill_th;
3598c2ecf20Sopenharmony_ci	atomic_t swqe_avail;
3608c2ecf20Sopenharmony_ci	int swqe_ll_count;
3618c2ecf20Sopenharmony_ci	u32 swqe_id_counter;
3628c2ecf20Sopenharmony_ci	u64 tx_packets;
3638c2ecf20Sopenharmony_ci	u64 tx_bytes;
3648c2ecf20Sopenharmony_ci	u64 rx_packets;
3658c2ecf20Sopenharmony_ci	u64 rx_bytes;
3668c2ecf20Sopenharmony_ci	int sq_restart_flag;
3678c2ecf20Sopenharmony_ci};
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci#define EHEA_MAX_PORTS 16
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci#define EHEA_NUM_PORTRES_FW_HANDLES    6  /* QP handle, SendCQ handle,
3738c2ecf20Sopenharmony_ci					     RecvCQ handle, EQ handle,
3748c2ecf20Sopenharmony_ci					     SendMR handle, RecvMR handle */
3758c2ecf20Sopenharmony_ci#define EHEA_NUM_PORT_FW_HANDLES       1  /* EQ handle */
3768c2ecf20Sopenharmony_ci#define EHEA_NUM_ADAPTER_FW_HANDLES    2  /* MR handle, NEQ handle */
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistruct ehea_adapter {
3798c2ecf20Sopenharmony_ci	u64 handle;
3808c2ecf20Sopenharmony_ci	struct platform_device *ofdev;
3818c2ecf20Sopenharmony_ci	struct ehea_port *port[EHEA_MAX_PORTS];
3828c2ecf20Sopenharmony_ci	struct ehea_eq *neq;       /* notification event queue */
3838c2ecf20Sopenharmony_ci	struct tasklet_struct neq_tasklet;
3848c2ecf20Sopenharmony_ci	struct ehea_mr mr;
3858c2ecf20Sopenharmony_ci	u32 pd;                    /* protection domain */
3868c2ecf20Sopenharmony_ci	u64 max_mc_mac;            /* max number of multicast mac addresses */
3878c2ecf20Sopenharmony_ci	int active_ports;
3888c2ecf20Sopenharmony_ci	struct list_head list;
3898c2ecf20Sopenharmony_ci};
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistruct ehea_mc_list {
3938c2ecf20Sopenharmony_ci	struct list_head list;
3948c2ecf20Sopenharmony_ci	u64 macaddr;
3958c2ecf20Sopenharmony_ci};
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/* kdump support */
3988c2ecf20Sopenharmony_cistruct ehea_fw_handle_entry {
3998c2ecf20Sopenharmony_ci	u64 adh;               /* Adapter Handle */
4008c2ecf20Sopenharmony_ci	u64 fwh;               /* Firmware Handle */
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistruct ehea_fw_handle_array {
4048c2ecf20Sopenharmony_ci	struct ehea_fw_handle_entry *arr;
4058c2ecf20Sopenharmony_ci	int num_entries;
4068c2ecf20Sopenharmony_ci	struct mutex lock;
4078c2ecf20Sopenharmony_ci};
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_cistruct ehea_bcmc_reg_entry {
4108c2ecf20Sopenharmony_ci	u64 adh;               /* Adapter Handle */
4118c2ecf20Sopenharmony_ci	u32 port_id;           /* Logical Port Id */
4128c2ecf20Sopenharmony_ci	u8 reg_type;           /* Registration Type */
4138c2ecf20Sopenharmony_ci	u64 macaddr;
4148c2ecf20Sopenharmony_ci};
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_cistruct ehea_bcmc_reg_array {
4178c2ecf20Sopenharmony_ci	struct ehea_bcmc_reg_entry *arr;
4188c2ecf20Sopenharmony_ci	int num_entries;
4198c2ecf20Sopenharmony_ci	spinlock_t lock;
4208c2ecf20Sopenharmony_ci};
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci#define EHEA_PORT_UP 1
4238c2ecf20Sopenharmony_ci#define EHEA_PORT_DOWN 0
4248c2ecf20Sopenharmony_ci#define EHEA_PHY_LINK_UP 1
4258c2ecf20Sopenharmony_ci#define EHEA_PHY_LINK_DOWN 0
4268c2ecf20Sopenharmony_ci#define EHEA_MAX_PORT_RES 16
4278c2ecf20Sopenharmony_cistruct ehea_port {
4288c2ecf20Sopenharmony_ci	struct ehea_adapter *adapter;	 /* adapter that owns this port */
4298c2ecf20Sopenharmony_ci	struct net_device *netdev;
4308c2ecf20Sopenharmony_ci	struct rtnl_link_stats64 stats;
4318c2ecf20Sopenharmony_ci	struct ehea_port_res port_res[EHEA_MAX_PORT_RES];
4328c2ecf20Sopenharmony_ci	struct platform_device  ofdev; /* Open Firmware Device */
4338c2ecf20Sopenharmony_ci	struct ehea_mc_list *mc_list;	 /* Multicast MAC addresses */
4348c2ecf20Sopenharmony_ci	struct ehea_eq *qp_eq;
4358c2ecf20Sopenharmony_ci	struct work_struct reset_task;
4368c2ecf20Sopenharmony_ci	struct delayed_work stats_work;
4378c2ecf20Sopenharmony_ci	struct mutex port_lock;
4388c2ecf20Sopenharmony_ci	char int_aff_name[EHEA_IRQ_NAME_SIZE];
4398c2ecf20Sopenharmony_ci	int allmulti;			 /* Indicates IFF_ALLMULTI state */
4408c2ecf20Sopenharmony_ci	int promisc;		 	 /* Indicates IFF_PROMISC state */
4418c2ecf20Sopenharmony_ci	int num_mcs;
4428c2ecf20Sopenharmony_ci	int resets;
4438c2ecf20Sopenharmony_ci	unsigned long flags;
4448c2ecf20Sopenharmony_ci	u64 mac_addr;
4458c2ecf20Sopenharmony_ci	u32 logical_port_id;
4468c2ecf20Sopenharmony_ci	u32 port_speed;
4478c2ecf20Sopenharmony_ci	u32 msg_enable;
4488c2ecf20Sopenharmony_ci	u32 sig_comp_iv;
4498c2ecf20Sopenharmony_ci	u32 state;
4508c2ecf20Sopenharmony_ci	u8 phy_link;
4518c2ecf20Sopenharmony_ci	u8 full_duplex;
4528c2ecf20Sopenharmony_ci	u8 autoneg;
4538c2ecf20Sopenharmony_ci	u8 num_def_qps;
4548c2ecf20Sopenharmony_ci	wait_queue_head_t swqe_avail_wq;
4558c2ecf20Sopenharmony_ci	wait_queue_head_t restart_wq;
4568c2ecf20Sopenharmony_ci};
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_cistruct port_res_cfg {
4598c2ecf20Sopenharmony_ci	int max_entries_rcq;
4608c2ecf20Sopenharmony_ci	int max_entries_scq;
4618c2ecf20Sopenharmony_ci	int max_entries_sq;
4628c2ecf20Sopenharmony_ci	int max_entries_rq1;
4638c2ecf20Sopenharmony_ci	int max_entries_rq2;
4648c2ecf20Sopenharmony_ci	int max_entries_rq3;
4658c2ecf20Sopenharmony_ci};
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_cienum ehea_flag_bits {
4688c2ecf20Sopenharmony_ci	__EHEA_STOP_XFER,
4698c2ecf20Sopenharmony_ci	__EHEA_DISABLE_PORT_RESET
4708c2ecf20Sopenharmony_ci};
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_civoid ehea_set_ethtool_ops(struct net_device *netdev);
4738c2ecf20Sopenharmony_ciint ehea_sense_port_attr(struct ehea_port *port);
4748c2ecf20Sopenharmony_ciint ehea_set_portspeed(struct ehea_port *port, u32 port_speed);
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci#endif	/* __EHEA_H__ */
477