Commit d517ee7c authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: spectrum: Move QSFP EEPROM definitions to common location

Move QSFP EEPROM definitions to common location from the spectrum driver
in order to make them available for other mlxsw modules. They are common
for all kind of chips and have relation to SFF specifications 8024,
8436, 8472, 8636, rather than to chip type.
Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 03b96742
...@@ -8055,13 +8055,41 @@ MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16); ...@@ -8055,13 +8055,41 @@ MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
*/ */
MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16); MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
#define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48 #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
#define MLXSW_REG_MCIA_EEPROM_SIZE 48
#define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
#define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
#define MLXSW_REG_MCIA_PAGE0_LO 0
#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
};
enum mlxsw_reg_mcia_eeprom_module_info_id {
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
};
enum mlxsw_reg_mcia_eeprom_module_info {
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
};
/* reg_mcia_eeprom /* reg_mcia_eeprom
* Bytes to read/write. * Bytes to read/write.
* Access: RW * Access: RW
*/ */
MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE); MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock, static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
u8 page_number, u16 device_addr, u8 page_number, u16 device_addr,
......
...@@ -2723,23 +2723,23 @@ static int mlxsw_sp_query_module_eeprom(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -2723,23 +2723,23 @@ static int mlxsw_sp_query_module_eeprom(struct mlxsw_sp_port *mlxsw_sp_port,
unsigned int *p_read_size) unsigned int *p_read_size)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char eeprom_tmp[MLXSW_SP_REG_MCIA_EEPROM_SIZE]; char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
char mcia_pl[MLXSW_REG_MCIA_LEN]; char mcia_pl[MLXSW_REG_MCIA_LEN];
u16 i2c_addr; u16 i2c_addr;
int status; int status;
int err; int err;
size = min_t(u16, size, MLXSW_SP_REG_MCIA_EEPROM_SIZE); size = min_t(u16, size, MLXSW_REG_MCIA_EEPROM_SIZE);
if (offset < MLXSW_SP_EEPROM_PAGE_LENGTH && if (offset < MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH &&
offset + size > MLXSW_SP_EEPROM_PAGE_LENGTH) offset + size > MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH)
/* Cross pages read, read until offset 256 in low page */ /* Cross pages read, read until offset 256 in low page */
size = MLXSW_SP_EEPROM_PAGE_LENGTH - offset; size = MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH - offset;
i2c_addr = MLXSW_SP_I2C_ADDR_LOW; i2c_addr = MLXSW_REG_MCIA_I2C_ADDR_LOW;
if (offset >= MLXSW_SP_EEPROM_PAGE_LENGTH) { if (offset >= MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) {
i2c_addr = MLXSW_SP_I2C_ADDR_HIGH; i2c_addr = MLXSW_REG_MCIA_I2C_ADDR_HIGH;
offset -= MLXSW_SP_EEPROM_PAGE_LENGTH; offset -= MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH;
} }
mlxsw_reg_mcia_pack(mcia_pl, mlxsw_sp_port->mapping.module, mlxsw_reg_mcia_pack(mcia_pl, mlxsw_sp_port->mapping.module,
...@@ -2760,55 +2760,37 @@ static int mlxsw_sp_query_module_eeprom(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -2760,55 +2760,37 @@ static int mlxsw_sp_query_module_eeprom(struct mlxsw_sp_port *mlxsw_sp_port,
return 0; return 0;
} }
enum mlxsw_sp_eeprom_module_info_rev_id {
MLXSW_SP_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
MLXSW_SP_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
MLXSW_SP_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
};
enum mlxsw_sp_eeprom_module_info_id {
MLXSW_SP_EEPROM_MODULE_INFO_ID_SFP = 0x03,
MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
};
enum mlxsw_sp_eeprom_module_info {
MLXSW_SP_EEPROM_MODULE_INFO_ID,
MLXSW_SP_EEPROM_MODULE_INFO_REV_ID,
MLXSW_SP_EEPROM_MODULE_INFO_SIZE,
};
static int mlxsw_sp_get_module_info(struct net_device *netdev, static int mlxsw_sp_get_module_info(struct net_device *netdev,
struct ethtool_modinfo *modinfo) struct ethtool_modinfo *modinfo)
{ {
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev);
u8 module_info[MLXSW_SP_EEPROM_MODULE_INFO_SIZE]; u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE;
u8 module_rev_id, module_id; u8 module_rev_id, module_id;
unsigned int read_size; unsigned int read_size;
int err; int err;
err = mlxsw_sp_query_module_eeprom(mlxsw_sp_port, 0, err = mlxsw_sp_query_module_eeprom(mlxsw_sp_port, 0, offset,
MLXSW_SP_EEPROM_MODULE_INFO_SIZE,
module_info, &read_size); module_info, &read_size);
if (err) if (err)
return err; return err;
if (read_size < MLXSW_SP_EEPROM_MODULE_INFO_SIZE) if (read_size < offset)
return -EIO; return -EIO;
module_rev_id = module_info[MLXSW_SP_EEPROM_MODULE_INFO_REV_ID]; module_rev_id = module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID];
module_id = module_info[MLXSW_SP_EEPROM_MODULE_INFO_ID]; module_id = module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID];
switch (module_id) { switch (module_id) {
case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP:
modinfo->type = ETH_MODULE_SFF_8436; modinfo->type = ETH_MODULE_SFF_8436;
modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
break; break;
case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP_PLUS: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP28: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
if (module_id == MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP28 || if (module_id == MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 ||
module_rev_id >= MLXSW_SP_EEPROM_MODULE_INFO_REV_ID_8636) { module_rev_id >=
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636) {
modinfo->type = ETH_MODULE_SFF_8636; modinfo->type = ETH_MODULE_SFF_8636;
modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN; modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
} else { } else {
...@@ -2816,7 +2798,7 @@ static int mlxsw_sp_get_module_info(struct net_device *netdev, ...@@ -2816,7 +2798,7 @@ static int mlxsw_sp_get_module_info(struct net_device *netdev,
modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
} }
break; break;
case MLXSW_SP_EEPROM_MODULE_INFO_ID_SFP: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
modinfo->type = ETH_MODULE_SFF_8472; modinfo->type = ETH_MODULE_SFF_8472;
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment