diff options
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r-- | usr/src/uts/common/sys/ethernet.h | 5 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fcoe/fcoe_common.h | 349 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fcoe/fcoeio.h | 144 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fct.h | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/stmf.h | 3 |
5 files changed, 499 insertions, 5 deletions
diff --git a/usr/src/uts/common/sys/ethernet.h b/usr/src/uts/common/sys/ethernet.h index 97531e917c..eb1b686540 100644 --- a/usr/src/uts/common/sys/ethernet.h +++ b/usr/src/uts/common/sys/ethernet.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -30,8 +30,6 @@ #ifndef _SYS_ETHERNET_H #define _SYS_ETHERNET_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -94,6 +92,7 @@ struct ether_vlan_extinfo { #define ETHERTYPE_PPPOES (0x8864) /* PPPoE Session Stage */ #define ETHERTYPE_EAPOL (0x888e) /* EAPOL protocol */ #define ETHERTYPE_RSN_PREAUTH (0x88c7) /* RSN PRE-Authentication */ +#define ETHERTYPE_FCOE (0x8906) /* FCoE */ #define ETHERTYPE_MAX (0xffff) /* Max valid ethernet type */ /* diff --git a/usr/src/uts/common/sys/fcoe/fcoe_common.h b/usr/src/uts/common/sys/fcoe/fcoe_common.h new file mode 100644 index 0000000000..bad3c5a133 --- /dev/null +++ b/usr/src/uts/common/sys/fcoe/fcoe_common.h @@ -0,0 +1,349 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#ifndef _FCOE_COMMON_H_ +#define _FCOE_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Interface return value + */ +#define FCOE_SUCCESS 0 +#define FCOE_FAILURE -1 +#define FCOE_BUSY -2 +#define FCOE_NOT_SUPPORTED -3 +#define FCOE_BAD_FRAME -4 + +/* + * FCOE port speed + */ +#define FCOE_PORT_SPEED_1G 1000000000 +#define FCOE_PORT_SPEED_10G 10000000000 + +/* + * FC Frame header size: 24 bytes + */ +#define FCFH_SIZE (sizeof (fcoe_fc_frame_header_t)) + +/* + * FLOGI + */ +#define FLOGI_REQ_PAYLOAD_SIZE 116 +#define FLOGI_ACC_PAYLOAD_SIZE 116 + +/* + * Minimum MTU size + */ +#define FCOE_MIN_MTU_SIZE 2500 + +/* + * 24 byte FC frame header + * For all data structures that have endian problems, we will use only + * one type: uint8_t. We need associate the data structure pointer with + * one buffer directly. + */ +typedef struct fcoe_fc_frame_header { + uint8_t hdr_r_ctl[1]; + uint8_t hdr_d_id[3]; + + uint8_t hdr_cs_ctl[1]; + uint8_t hdr_s_id[3]; + + uint8_t hdr_type[1]; + uint8_t hdr_f_ctl[3]; + + uint8_t hdr_seq_id[1]; + uint8_t hdr_df_ctl[1]; + uint8_t hdr_seq_cnt[2]; + + uint8_t hdr_oxid[2]; + uint8_t hdr_rxid[2]; + + uint8_t hdr_param[4]; +} fcoe_fc_frame_header_t; + +/* + * Solicited frame: allocted by FCOET/FOCEI, free-ed by FCOE + * Unsolicited frame: allocated by FCOE, free-ed by FCOET/FCOEI + */ +struct fcoe_port; +typedef struct fcoe_frame { + uint32_t frm_flags; + void *frm_netb; + fcoe_fc_frame_header_t *frm_hdr; + uint8_t *frm_ofh1; + uint8_t *frm_ofh2; + uint8_t *frm_fc_frame; + uint8_t *frm_payload; + uint32_t frm_fc_frame_size; + uint32_t frm_payload_size; + uint32_t frm_alloc_size; + struct fcoe_port *frm_eport; + void *frm_fcoe_private; + void *frm_client_private; +} fcoe_frame_t; + +/* + * FCOE HBA + */ +typedef struct fcoe_port { + uint32_t eport_flags; + void *eport_fcoe_private; + void *eport_client_private; + uint8_t eport_portwwn[8]; + uint8_t eport_nodewwn[8]; + uint32_t eport_max_fc_frame_size; + uint32_t eport_mtu; + uint64_t eport_link_speed; + uint8_t eport_efh_dst[ETHERADDRL]; + void (*eport_tx_frame)(fcoe_frame_t *frame); + fcoe_frame_t *(*eport_alloc_frame)(struct fcoe_port *eport, + uint32_t this_fc_frame_size, void *netb); + void (*eport_release_frame)(fcoe_frame_t *frame); + void *(*eport_alloc_netb)(struct fcoe_port *eport, + uint32_t this_fc_frame_size, uint8_t **ppfc); + void (*eport_free_netb)(void *netb); + void (*eport_deregister_client)(struct fcoe_port *eport); + int (*eport_ctl)(struct fcoe_port *eport, + int cmd, void *arg); + int (*eport_set_mac_address)(struct fcoe_port *eport, + uint8_t *addr, boolean_t fc_assigned); +} fcoe_port_t; + +/* + * FCOE only supports two kinds of topology: direct P2P, fabric P2P. + */ +#define EPORT_FLAG_IS_DIRECT_P2P 0x01 +#define EPORT_FLAG_TGT_MODE 0x02 +#define EPORT_FLAG_INI_MODE 0x04 +#define EPORT_FLAG_MAC_IN_USE 0x08 + +#define FCOE_NOTIFY_EPORT_LINK_UP 0x01 +#define FCOE_NOTIFY_EPORT_LINK_DOWN 0x02 +#define FCOE_NOTIFY_EPORT_ADDR_CHG 0x03 + +#define FCOE_PORT_CTL_CMDS 0x3000 +#define FCOE_CMD_PORT_ONLINE (FCOE_PORT_CTL_CMDS | 0x01) +#define FCOE_CMD_PORT_OFFLINE (FCOE_PORT_CTL_CMDS | 0x02) + +typedef struct fcoe_client { + uint32_t ect_eport_flags; + uint32_t ect_max_fc_frame_size; + uint32_t ect_private_frame_struct_size; + char ect_channel_name[32]; + void *ect_client_port_struct; + void (*ect_rx_frame)(fcoe_frame_t *frame); + void (*ect_port_event)(fcoe_port_t *eport, uint32_t event); + void (*ect_release_sol_frame)(fcoe_frame_t *frame); +} fcoe_client_t; + +/* + * Define common-used conversion or calculation macros + */ +#define FCOE_V2B_1(x_v, x_b) \ + { \ + ((uint8_t *)(x_b))[0] = 0xFF & (x_v); \ + } + +#define FCOE_V2B_2(x_v, x_b) \ + { \ + ((uint8_t *)(x_b))[1] = 0xFF & (x_v); \ + ((uint8_t *)(x_b))[0] = 0xFF & ((x_v) >> 8); \ + } + +#define FCOE_V2B_3(x_v, x_b) \ + { \ + ((uint8_t *)(x_b))[2] = 0xFF & (x_v); \ + ((uint8_t *)(x_b))[1] = 0xFF & ((x_v) >> 8); \ + ((uint8_t *)(x_b))[0] = 0xFF & ((x_v) >> 16); \ + } + +#define FCOE_V2B_4(x_v, x_b) \ + { \ + ((uint8_t *)(x_b))[3] = 0xFF & (x_v); \ + ((uint8_t *)(x_b))[2] = 0xFF & ((x_v) >> 8); \ + ((uint8_t *)(x_b))[1] = 0xFF & ((x_v) >> 16); \ + ((uint8_t *)(x_b))[0] = 0xFF & ((x_v) >> 24); \ + } + +#define FCOE_V2B_8(x_v, x_b) \ + { \ + ((uint8_t *)(x_b))[7] = 0xFF & (x_v); \ + ((uint8_t *)(x_b))[6] = 0xFF & ((x_v) >> 8); \ + ((uint8_t *)(x_b))[5] = 0xFF & ((x_v) >> 16); \ + ((uint8_t *)(x_b))[4] = 0xFF & ((x_v) >> 24); \ + ((uint8_t *)(x_b))[3] = 0xFF & ((x_v) >> 32); \ + ((uint8_t *)(x_b))[2] = 0xFF & ((x_v) >> 40); \ + ((uint8_t *)(x_b))[1] = 0xFF & ((x_v) >> 48); \ + ((uint8_t *)(x_b))[0] = 0xFF & ((x_v) >> 56); \ + } + +#define FCOE_B2V_1(x_b) \ + ((((uint8_t *)(x_b))[0]) & 0xFF) + +#define FCOE_B2V_2(x_b) \ + ((((uint8_t *)(x_b))[1] | ((uint8_t *)(x_b))[0] << 8) & 0xFFFF) + +#define FCOE_B2V_3(x_b) \ + ((((uint8_t *)(x_b))[2] | ((uint8_t *)(x_b))[1] << 8 | \ + ((uint8_t *)(x_b))[0] << 16) & 0xFFFFFF) + +#define FCOE_B2V_4(x_b) \ + ((((uint8_t *)(x_b))[3] | ((uint8_t *)(x_b))[2] << 8 | \ + ((uint8_t *)(x_b))[1] << 16 | \ + ((uint8_t *)(x_b))[0] << 24) & 0xFFFFFFFF) + +#define FCOE_B2V_8(x_b) \ + ((((uint8_t *)(x_b))[7] | ((uint8_t *)(x_b))[6] << 8 | \ + ((uint8_t *)(x_b))[5] << 16 | \ + ((uint8_t *)(x_b))[4] << 24 | \ + ((uint8_t *)(x_b))[3] << 32 | \ + ((uint8_t *)(x_b))[2] << 40 | \ + ((uint8_t *)(x_b))[1] << 48 | \ + ((uint8_t *)(x_b))[0] << 56) & 0xFFFFFFFFFFFFFFFF) + +/* + * Get FC frame header's element + */ +#define FRM_R_CTL(x_frm) (FCOE_B2V_1((x_frm)->frm_hdr->hdr_r_ctl)) +#define FRM_D_ID(x_frm) (FCOE_B2V_3((x_frm)->frm_hdr->hdr_d_id)) +#define FRM_S_ID(x_frm) (FCOE_B2V_3((x_frm)->frm_hdr->hdr_s_id)) +#define FRM_TYPE(x_frm) (FCOE_B2V_1((x_frm)->frm_hdr->hdr_type)) +#define FRM_F_CTL(x_frm) (FCOE_B2V_3((x_frm)->frm_hdr->hdr_f_ctl)) +#define FRM_SEQ_ID(x_frm) (FCOE_B2V_1((x_frm)->frm_hdr->hdr_seq_id)) +#define FRM_DF_CTL(x_frm) (FCOE_B2V_1((x_frm)->frm_hdr->hdr_df_ctl)) +#define FRM_SEQ_CNT(x_frm) (FCOE_B2V_2((x_frm)->frm_hdr->hdr_seq_cnt)) +#define FRM_OXID(x_frm) (FCOE_B2V_2((x_frm)->frm_hdr->hdr_oxid)) +#define FRM_RXID(x_frm) (FCOE_B2V_2((x_frm)->frm_hdr->hdr_rxid)) +#define FRM_PARAM(x_frm) (FCOE_B2V_4((x_frm)->frm_hdr->hdr_param)) + +/* + * Set FC frame header's element + */ +#define FFM_R_CTL(x_v, x_frm) FCOE_V2B_1((x_v), (x_frm)->frm_hdr->hdr_r_ctl) +#define FFM_D_ID(x_v, x_frm) FCOE_V2B_3((x_v), (x_frm)->frm_hdr->hdr_d_id) +#define FFM_S_ID(x_v, x_frm) FCOE_V2B_3((x_v), (x_frm)->frm_hdr->hdr_s_id) +#define FFM_TYPE(x_v, x_frm) FCOE_V2B_1((x_v), (x_frm)->frm_hdr->hdr_type) +#define FFM_F_CTL(x_v, x_frm) FCOE_V2B_3((x_v), (x_frm)->frm_hdr->hdr_f_ctl) +#define FFM_SEQ_ID(x_v, x_frm) FCOE_V2B_1((x_v), (x_frm)->frm_hdr->hdr_seq_id) +#define FFM_DF_CTL(x_v, x_frm) FCOE_V2B_1((x_v), (x_frm)->frm_hdr->hdr_df_ctl) +#define FFM_SEQ_CNT(x_v, x_frm) FCOE_V2B_2((x_v), (x_frm)->frm_hdr->hdr_seq_cnt) +#define FFM_OXID(x_v, x_frm) FCOE_V2B_2((x_v), (x_frm)->frm_hdr->hdr_oxid) +#define FFM_RXID(x_v, x_frm) FCOE_V2B_2((x_v), (x_frm)->frm_hdr->hdr_rxid) +#define FFM_PARAM(x_v, x_frm) FCOE_V2B_4((x_v), (x_frm)->frm_hdr->hdr_param) + +/* + * frame header checking + */ +#define FRM_IS_LAST_FRAME(x_frm) (FRM_F_CTL(x_frm) & (1 << 19)) + +/* + * FCOET/FCOEI will only call this fcoe function explicitly, all others + * should be called through vectors in struct fcoe_port. + * FCOE client call this to register one port to FCOE, FCOE need initialize + * and return the corresponding fcoe_port. + */ +extern fcoe_port_t *fcoe_register_client(fcoe_client_t *client); + +#define EPORT_CLT_TYPE(eport) \ + (((eport)->eport_flags & EPORT_FLAG_INI_MODE) ? \ + FCOE_CLIENT_INITIATOR : FCOE_CLIENT_TARGET) + +#define FCOE_SET_DEFAULT_OUI(x_oui) \ + (x_oui)[0] = 0x0e; (x_oui)[1] = 0xfc; (x_oui)[2] = 0x00; +#define FCOE_SET_DEFAULT_FPORT_ADDR(x_addr) \ + FCOE_SET_DEFAULT_OUI(x_addr) \ + (x_addr)[3] = 0xff; (x_addr)[4] = 0xff; (x_addr)[5] = 0xfe; + +/* + * FC payload size + */ +#define FCOE_DEFAULT_FCP_DATA_PAYLOAD_SIZE 2048 +#define FCOE_MIN_FCP_DATA_PAYLOAD_SIZE 1024 + +typedef struct fcoe_fcp_cmnd { + uint8_t ffc_lun[8]; + uint8_t ffc_ref_num[1]; + + /* + * least 3 bits + */ + uint8_t ffc_attribute[1]; + + /* + * Magnagement flags + */ + uint8_t ffc_management_flags[1]; + + /* + * additional cdb len and read/write flag + */ + uint8_t ffc_addlen_rdwr[1]; + + uint8_t ffc_cdb[16]; + uint8_t ffc_fcp_dl[4]; +} fcoe_fcp_cmnd_t; + +typedef struct fcoe_fcp_rsp { + uint8_t ffr_rsvd[8]; + + /* + * see SAM-4 + */ + uint8_t ffr_retry_delay_timer[2]; + uint8_t ffr_flags[1]; + uint8_t ffr_scsi_status[1]; + uint8_t ffr_resid[4]; + uint8_t ffr_sns_len[4]; + uint8_t ffr_rsp_len[4]; + /* + * Followed by sense data when available + */ +} fcoe_fcp_rsp_t; + +typedef struct fcoe_fcp_xfer_rdy { + uint8_t fxr_data_ro[4]; + uint8_t fxr_burst_len[4]; + uint8_t fxr_rsvd[4]; +} fcoe_fcp_xfer_rdy_t; + +/* + * FCOE project global functions + */ +#define FCOE_SEC2TICK(x_sec) (drv_usectohz((x_sec) * 1000000)) +typedef void (*TQ_FUNC_P)(void *); +extern void fcoe_trace(caddr_t ident, const char *fmt, ...); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FCOE_COMMON_H_ */ diff --git a/usr/src/uts/common/sys/fcoe/fcoeio.h b/usr/src/uts/common/sys/fcoe/fcoeio.h new file mode 100644 index 0000000000..6d24a2673f --- /dev/null +++ b/usr/src/uts/common/sys/fcoe/fcoeio.h @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#ifndef _FCOEIO_H_ +#define _FCOEIO_H_ + +#include <sys/ethernet.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ioctl cmd definitions + */ +#define FCOEIO_CMD ('G'<< 8 | 2009) +#define FCOEIO_SUB_CMD ('X' << 8) + +/* + * fcoe ioctl sub-command + */ +#define FCOEIO_CREATE_FCOE_PORT (FCOEIO_SUB_CMD + 0x01) +#define FCOEIO_DELETE_FCOE_PORT (FCOEIO_SUB_CMD + 0x02) +#define FCOEIO_GET_FCOE_PORT_LIST (FCOEIO_SUB_CMD + 0x03) + +/* + * define common-used constants + */ +#define FCOE_MAX_MAC_NAME_LEN 32 + +/* + * fcoeio_xfer definitions + */ +#define FCOEIO_XFER_NONE 0x00 +#define FCOEIO_XFER_READ 0x01 +#define FCOEIO_XFER_WRITE 0x02 +#define FCOEIO_XFER_RW (FCOEIO_XFER_READ | FCOEIO_XFER_WRITE) + +/* + * fcoeio_errno definitions + */ +typedef enum { + FCOEIOE_INVAL_ARG = 5, + FCOEIOE_BUSY, + FCOEIOE_ALREADY, + FCOEIOE_PWWN_CONFLICTED, + FCOEIOE_NWWN_CONFLICTED, + FCOEIOE_CREATE_MAC, + FCOEIOE_OPEN_MAC, + FCOEIOE_CREATE_PORT, + FCOEIOE_NEED_JUMBO_FRAME, + FCOEIOE_MAC_NOT_FOUND, + FCOEIOE_OFFLINE_FAILURE, + FCOEIOE_MORE_DATA, + FCOEIOE_VNIC_UNSUPPORT +} fcoeio_stat_t; + +/* Biggest buffer length, can hold up to 1024 port instances */ +#define FCOEIO_MAX_BUF_LEN 0x10000 + +typedef struct fcoeio { + uint16_t fcoeio_xfer; /* direction */ + uint16_t fcoeio_cmd; /* sub command */ + uint16_t fcoeio_flags; /* flags */ + uint16_t fcoeio_cmd_flags; /* command specific flags */ + uint32_t fcoeio_ilen; /* Input buffer length */ + uint32_t fcoeio_olen; /* Output buffer length */ + uint32_t fcoeio_alen; /* Auxillary buffer length */ + fcoeio_stat_t fcoeio_status; /* FC internal error status */ + uint64_t fcoeio_ibuf; /* Input buffer */ + uint64_t fcoeio_obuf; /* Output buffer */ + uint64_t fcoeio_abuf; /* Auxillary buffer */ +} fcoeio_t; + +/* + * Client port type + */ +typedef enum { + FCOE_CLIENT_INITIATOR = 0, + FCOE_CLIENT_TARGET +} fcoe_cli_type_t; + +/* + * Command for FCOEIO_CREATE_FCOET_PORT + */ +#define FCOE_WWN_SIZE 8 +typedef struct fcoeio_create_port_param { + uchar_t fcp_pwwn[FCOE_WWN_SIZE]; + uchar_t fcp_nwwn[FCOE_WWN_SIZE]; + uint32_t fcp_nwwn_provided; + uint32_t fcp_pwwn_provided; + uint32_t fcp_force_promisc; + fcoe_cli_type_t fcp_port_type; + uchar_t fcp_mac_name[MAXLINKNAMELEN]; +} fcoeio_create_port_param_t; + +/* + * FCOE port instance + */ +typedef struct fcoe_port_instance { + uchar_t fpi_pwwn[FCOE_WWN_SIZE]; + uchar_t fpi_mac_link_name[MAXLINKNAMELEN]; + uint8_t fpi_mac_factory_addr[ETHERADDRL]; + uint16_t fpi_mac_promisc; + uint8_t fpi_mac_current_addr[ETHERADDRL]; + uint16_t fpi_rsvd1; + fcoe_cli_type_t fpi_port_type; + uint32_t fpi_mtu_size; +} fcoe_port_instance_t; + +/* + * FCOE port instance list + */ +typedef struct fcoe_port_list { + uint64_t numPorts; + fcoe_port_instance_t ports[1]; +} fcoe_port_list_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _FCOEIO_H_ */ diff --git a/usr/src/uts/common/sys/fct.h b/usr/src/uts/common/sys/fct.h index 1808038963..514535afba 100644 --- a/usr/src/uts/common/sys/fct.h +++ b/usr/src/uts/common/sys/fct.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _FCT_H @@ -294,6 +294,7 @@ typedef struct fct_link_info { #define PORT_SPEED_2G 2 #define PORT_SPEED_4G 4 #define PORT_SPEED_8G 8 +#define PORT_SPEED_10G 16 /* * Abort commands diff --git a/usr/src/uts/common/sys/stmf.h b/usr/src/uts/common/sys/stmf.h index 940545b255..1159cc13b1 100644 --- a/usr/src/uts/common/sys/stmf.h +++ b/usr/src/uts/common/sys/stmf.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _STMF_H @@ -87,6 +87,7 @@ typedef struct stmf_data_buf { #define DB_SEND_STATUS_GOOD 0x0004 #define DB_STATUS_GOOD_SENT 0x0008 #define DB_DONT_CACHE 0x0010 +#define DB_DONT_REUSE 0x0020 typedef struct scsi_task { void *task_stmf_private; |