18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic iSCSI Offload Driver
48c2ecf20Sopenharmony_ci * Copyright (c) 2016 Cavium Inc.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef NVM_ISCSI_CFG_H
88c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define NUM_OF_ISCSI_TARGET_PER_PF    4   /* Defined as per the
118c2ecf20Sopenharmony_ci					   * ISCSI IBFT constraint
128c2ecf20Sopenharmony_ci					   */
138c2ecf20Sopenharmony_ci#define NUM_OF_ISCSI_PF_SUPPORTED     4   /* One PF per Port -
148c2ecf20Sopenharmony_ci					   * assuming 4 port card
158c2ecf20Sopenharmony_ci					   */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN  256
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciunion nvm_iscsi_dhcp_vendor_id {
208c2ecf20Sopenharmony_ci	u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN / 4];
218c2ecf20Sopenharmony_ci	u8  byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN];
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4
258c2ecf20Sopenharmony_ciunion nvm_iscsi_ipv4_addr {
268c2ecf20Sopenharmony_ci	u32 addr;
278c2ecf20Sopenharmony_ci	u8  byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN];
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16
318c2ecf20Sopenharmony_ciunion nvm_iscsi_ipv6_addr {
328c2ecf20Sopenharmony_ci	u32 addr[4];
338c2ecf20Sopenharmony_ci	u8  byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN];
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistruct nvm_iscsi_initiator_ipv4 {
378c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr addr;				/* 0x0 */
388c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr subnet_mask;			/* 0x4 */
398c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr gateway;			/* 0x8 */
408c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr primary_dns;			/* 0xC */
418c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr secondary_dns;		/* 0x10 */
428c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr dhcp_addr;			/* 0x14 */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr isns_server;			/* 0x18 */
458c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr slp_server;			/* 0x1C */
468c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr primay_radius_server;		/* 0x20 */
478c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr secondary_radius_server;	/* 0x24 */
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr rsvd[4];			/* 0x28 */
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct nvm_iscsi_initiator_ipv6 {
538c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr addr;				/* 0x0 */
548c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr subnet_mask;			/* 0x10 */
558c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr gateway;			/* 0x20 */
568c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr primary_dns;			/* 0x30 */
578c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr secondary_dns;		/* 0x40 */
588c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr dhcp_addr;			/* 0x50 */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr isns_server;			/* 0x60 */
618c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr slp_server;			/* 0x70 */
628c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr primay_radius_server;		/* 0x80 */
638c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr secondary_radius_server;	/* 0x90 */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr rsvd[3];			/* 0xA0 */
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	u32   config;						/* 0xD0 */
688c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK      0x000000FF
698c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET    0
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	u32   rsvd_1[3];
728c2ecf20Sopenharmony_ci};
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN  256
758c2ecf20Sopenharmony_ciunion nvm_iscsi_name {
768c2ecf20Sopenharmony_ci	u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN / 4];
778c2ecf20Sopenharmony_ci	u8  byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN];
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN  256
818c2ecf20Sopenharmony_ciunion nvm_iscsi_chap_name {
828c2ecf20Sopenharmony_ci	u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN / 4];
838c2ecf20Sopenharmony_ci	u8  byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN];
848c2ecf20Sopenharmony_ci};
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN  16 /* md5 need per RFC1996
878c2ecf20Sopenharmony_ci					    * is 16 octets
888c2ecf20Sopenharmony_ci					    */
898c2ecf20Sopenharmony_ciunion nvm_iscsi_chap_password {
908c2ecf20Sopenharmony_ci	u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN / 4];
918c2ecf20Sopenharmony_ci	u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN];
928c2ecf20Sopenharmony_ci};
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciunion nvm_iscsi_lun {
958c2ecf20Sopenharmony_ci	u8  byte[8];
968c2ecf20Sopenharmony_ci	u32 value[2];
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct nvm_iscsi_generic {
1008c2ecf20Sopenharmony_ci	u32 ctrl_flags;						/* 0x0 */
1018c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_CHAP_ENABLED                 BIT(0)
1028c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED    BIT(1)
1038c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED    BIT(2)
1048c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_IPV6_ENABLED                 BIT(3)
1058c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED        BIT(4)
1068c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN             BIT(5)
1078c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN         BIT(6)
1088c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED	       BIT(7)
1098c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED          BIT(8)
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	u32 timeout;						/* 0x4 */
1128c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK       0x0000FFFF
1138c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET     0
1148c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK         0xFFFF0000
1158c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET       16
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	union nvm_iscsi_dhcp_vendor_id  dhcp_vendor_id;		/* 0x8  */
1188c2ecf20Sopenharmony_ci	u32 rsvd[62];						/* 0x108 */
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistruct nvm_iscsi_initiator {
1228c2ecf20Sopenharmony_ci	struct nvm_iscsi_initiator_ipv4 ipv4;			/* 0x0 */
1238c2ecf20Sopenharmony_ci	struct nvm_iscsi_initiator_ipv6 ipv6;			/* 0x38 */
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci	union nvm_iscsi_name           initiator_name;		/* 0x118 */
1268c2ecf20Sopenharmony_ci	union nvm_iscsi_chap_name      chap_name;		/* 0x218 */
1278c2ecf20Sopenharmony_ci	union nvm_iscsi_chap_password  chap_password;		/* 0x318 */
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	u32 generic_cont0;					/* 0x398 */
1308c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK		0x0000FFFF
1318c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET		0
1328c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_MASK		0x00030000
1338c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_OFFSET	16
1348c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4		1
1358c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_6		2
1368c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4_AND_6	3
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	u32 ctrl_flags;
1398c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6     BIT(0)
1408c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED               BIT(1)
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	u32 rsvd[116];						/* 0x32C */
1438c2ecf20Sopenharmony_ci};
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistruct nvm_iscsi_target {
1468c2ecf20Sopenharmony_ci	u32 ctrl_flags;						/* 0x0 */
1478c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_TARGET_ENABLED            BIT(0)
1488c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS    BIT(1)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	u32 generic_cont0;					/* 0x4 */
1518c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK      0x0000FFFF
1528c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET    0
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	u32 ip_ver;
1558c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_IPv4       4
1568c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_IPv6       6
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	u32 rsvd_1[7];						/* 0x24 */
1598c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv4_addr ipv4_addr;			/* 0x28 */
1608c2ecf20Sopenharmony_ci	union nvm_iscsi_ipv6_addr ipv6_addr;			/* 0x2C */
1618c2ecf20Sopenharmony_ci	union nvm_iscsi_lun lun;				/* 0x3C */
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	union nvm_iscsi_name           target_name;		/* 0x44 */
1648c2ecf20Sopenharmony_ci	union nvm_iscsi_chap_name      chap_name;		/* 0x144 */
1658c2ecf20Sopenharmony_ci	union nvm_iscsi_chap_password  chap_password;		/* 0x244 */
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	u32 rsvd_2[107];					/* 0x2C4 */
1688c2ecf20Sopenharmony_ci};
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_cistruct nvm_iscsi_block {
1718c2ecf20Sopenharmony_ci	u32 id;							/* 0x0 */
1728c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK         0x0000000F
1738c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET       0
1748c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK            0x00000FF0
1758c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET          4
1768c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY    BIT(0)
1778c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED       BIT(1)
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	u32 rsvd_1[5];						/* 0x4 */
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	struct nvm_iscsi_generic     generic;			/* 0x18 */
1828c2ecf20Sopenharmony_ci	struct nvm_iscsi_initiator   initiator;			/* 0x218 */
1838c2ecf20Sopenharmony_ci	struct nvm_iscsi_target      target[NUM_OF_ISCSI_TARGET_PER_PF];
1848c2ecf20Sopenharmony_ci								/* 0x718 */
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	u32 rsvd_2[58];						/* 0x1718 */
1878c2ecf20Sopenharmony_ci	/* total size - 0x1800 - 6K block */
1888c2ecf20Sopenharmony_ci};
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistruct nvm_iscsi_cfg {
1918c2ecf20Sopenharmony_ci	u32 id;							/* 0x0 */
1928c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK     0x000000FF
1938c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK     0x0000FF00
1948c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK         0xFFFF0000
1958c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_SIGNATURE              0x49430000 /* IC - Iscsi
1968c2ecf20Sopenharmony_ci							     * Config
1978c2ecf20Sopenharmony_ci							     */
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_VERSION_MAJOR          0
2008c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_VERSION_MINOR          10
2018c2ecf20Sopenharmony_ci#define NVM_ISCSI_CFG_BLK_VERSION ((NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | \
2028c2ecf20Sopenharmony_ci				   NVM_ISCSI_CFG_BLK_VERSION_MINOR)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	struct nvm_iscsi_block	block[NUM_OF_ISCSI_PF_SUPPORTED]; /* 0x4 */
2058c2ecf20Sopenharmony_ci};
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci#endif
208