Path: blob/master/drivers/infiniband/hw/qib/qib_qsfp.h
15112 views
/*1* Copyright (c) 2006, 2007, 2008, 2009 QLogic Corporation. All rights reserved.2* Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/32/* QSFP support common definitions, for ib_qib driver */3334#define QSFP_DEV 0xA035#define QSFP_PWR_LAG_MSEC 20003637/*38* Below are masks for various QSFP signals, for Port 1.39* Port2 equivalents are shifted by QSFP_GPIO_PORT2_SHIFT.40* _N means asserted low41*/42#define QSFP_GPIO_MOD_SEL_N (4)43#define QSFP_GPIO_MOD_PRS_N (8)44#define QSFP_GPIO_INT_N (0x10)45#define QSFP_GPIO_MOD_RST_N (0x20)46#define QSFP_GPIO_LP_MODE (0x40)47#define QSFP_GPIO_PORT2_SHIFT 54849#define QSFP_PAGESIZE 12850/* Defined fields that QLogic requires of qualified cables */51/* Byte 0 is Identifier, not checked */52/* Byte 1 is reserved "status MSB" */53/* Byte 2 is "status LSB" We only care that D2 "Flat Mem" is set. */54/*55* Rest of first 128 not used, although 127 is reserved for page select56* if module is not "Flat memory".57*/58/* Byte 128 is Identifier: must be 0x0c for QSFP, or 0x0d for QSFP+ */59#define QSFP_MOD_ID_OFFS 12860/*61* Byte 129 is "Extended Identifier". We only care about D7,D6: Power class62* 0:1.5W, 1:2.0W, 2:2.5W, 3:3.5W63*/64#define QSFP_MOD_PWR_OFFS 12965/* Byte 130 is Connector type. Not QLogic req'd */66/* Bytes 131..138 are Transceiver types, bit maps for various tech, none IB */67/* Byte 139 is encoding. code 0x01 is 8b10b. Not QLogic req'd */68/* byte 140 is nominal bit-rate, in units of 100Mbits/sec Not QLogic req'd */69/* Byte 141 is Extended Rate Select. Not QLogic req'd */70/* Bytes 142..145 are lengths for various fiber types. Not QLogic req'd */71/* Byte 146 is length for Copper. Units of 1 meter */72#define QSFP_MOD_LEN_OFFS 14673/*74* Byte 147 is Device technology. D0..3 not Qlogc req'd75* D4..7 select from 15 choices, translated by table:76*/77#define QSFP_MOD_TECH_OFFS 14778extern const char *const qib_qsfp_devtech[16];79/* Active Equalization includes fiber, copper full EQ, and copper near Eq */80#define QSFP_IS_ACTIVE(tech) ((0xA2FF >> ((tech) >> 4)) & 1)81/* Active Equalization includes fiber, copper full EQ, and copper far Eq */82#define QSFP_IS_ACTIVE_FAR(tech) ((0x32FF >> ((tech) >> 4)) & 1)83/* Attenuation should be valid for copper other than full/near Eq */84#define QSFP_HAS_ATTEN(tech) ((0x4D00 >> ((tech) >> 4)) & 1)85/* Length is only valid if technology is "copper" */86#define QSFP_IS_CU(tech) ((0xED00 >> ((tech) >> 4)) & 1)87#define QSFP_TECH_1490 98889#define QSFP_OUI(oui) (((unsigned)oui[0] << 16) | ((unsigned)oui[1] << 8) | \90oui[2])91#define QSFP_OUI_AMPHENOL 0x41504892#define QSFP_OUI_FINISAR 0x00906593#define QSFP_OUI_GORE 0x0021779495/* Bytes 148..163 are Vendor Name, Left-justified Blank-filled */96#define QSFP_VEND_OFFS 14897#define QSFP_VEND_LEN 1698/* Byte 164 is IB Extended tranceiver codes Bits D0..3 are SDR,DDR,QDR,EDR */99#define QSFP_IBXCV_OFFS 164100/* Bytes 165..167 are Vendor OUI number */101#define QSFP_VOUI_OFFS 165102#define QSFP_VOUI_LEN 3103/* Bytes 168..183 are Vendor Part Number, string */104#define QSFP_PN_OFFS 168105#define QSFP_PN_LEN 16106/* Bytes 184,185 are Vendor Rev. Left Justified, Blank-filled */107#define QSFP_REV_OFFS 184108#define QSFP_REV_LEN 2109/*110* Bytes 186,187 are Wavelength, if Optical. Not Qlogic req'd111* If copper, they are attenuation in dB:112* Byte 186 is at 2.5Gb/sec (SDR), Byte 187 at 5.0Gb/sec (DDR)113*/114#define QSFP_ATTEN_OFFS 186115#define QSFP_ATTEN_LEN 2116/* Bytes 188,189 are Wavelength tolerance, not QLogic req'd */117/* Byte 190 is Max Case Temp. Not QLogic req'd */118/* Byte 191 is LSB of sum of bytes 128..190. Not QLogic req'd */119#define QSFP_CC_OFFS 191120/* Bytes 192..195 are Options implemented in qsfp. Not Qlogic req'd */121/* Bytes 196..211 are Serial Number, String */122#define QSFP_SN_OFFS 196123#define QSFP_SN_LEN 16124/* Bytes 212..219 are date-code YYMMDD (MM==1 for Jan) */125#define QSFP_DATE_OFFS 212126#define QSFP_DATE_LEN 6127/* Bytes 218,219 are optional lot-code, string */128#define QSFP_LOT_OFFS 218129#define QSFP_LOT_LEN 2130/* Bytes 220, 221 indicate monitoring options, Not QLogic req'd */131/* Byte 223 is LSB of sum of bytes 192..222 */132#define QSFP_CC_EXT_OFFS 223133134/*135* struct qib_qsfp_data encapsulates state of QSFP device for one port.136* it will be part of port-chip-specific data if a board supports QSFP.137*138* Since multiple board-types use QSFP, and their pport_data structs139* differ (in the chip-specific section), we need a pointer to its head.140*141* Avoiding premature optimization, we will have one work_struct per port,142* and let the (increasingly inaccurately named) eep_lock arbitrate143* access to common resources.144*145*/146147/*148* Hold the parts of the onboard EEPROM that we care about, so we aren't149* coonstantly bit-boffing150*/151struct qib_qsfp_cache {152u8 id; /* must be 0x0C or 0x0D; 0 indicates invalid EEPROM read */153u8 pwr; /* in D6,7 */154u8 len; /* in meters, Cu only */155u8 tech;156char vendor[QSFP_VEND_LEN];157u8 xt_xcv; /* Ext. tranceiver codes, 4 lsbs are IB speed supported */158u8 oui[QSFP_VOUI_LEN];159u8 partnum[QSFP_PN_LEN];160u8 rev[QSFP_REV_LEN];161u8 atten[QSFP_ATTEN_LEN];162u8 cks1; /* Checksum of bytes 128..190 */163u8 serial[QSFP_SN_LEN];164u8 date[QSFP_DATE_LEN];165u8 lot[QSFP_LOT_LEN];166u8 cks2; /* Checsum of bytes 192..222 */167};168169#define QSFP_PWR(pbyte) (((pbyte) >> 6) & 3)170#define QSFP_ATTEN_SDR(attenarray) (attenarray[0])171#define QSFP_ATTEN_DDR(attenarray) (attenarray[1])172173struct qib_qsfp_data {174/* Helps to find our way */175struct qib_pportdata *ppd;176struct work_struct work;177struct qib_qsfp_cache cache;178u64 t_insert;179};180181extern int qib_refresh_qsfp_cache(struct qib_pportdata *ppd,182struct qib_qsfp_cache *cp);183extern void qib_qsfp_init(struct qib_qsfp_data *qd,184void (*fevent)(struct work_struct *));185extern void qib_qsfp_deinit(struct qib_qsfp_data *qd);186187188