Skip to content

Commit

Permalink
The SFPI layer should not implement transmitter disable for QSFP modu…
Browse files Browse the repository at this point in the history
…les as part of the TX_DISABLE control.

The transmitter disable bytes are standardized by the MSA and managed by the upper layer using the dev_writeb() routines when
appropriate based on module type.

Writing the transmitter enable bytes are not appropriate for CR cables and will generate write errors so attempting to
emulate this behavior without knowing the type of module is also troublesome.
  • Loading branch information
jnealtowns committed Aug 17, 2018
1 parent 398084e commit f29aa90
Showing 1 changed file with 27 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int sfp_map_bus[] ={21, 22, 23, 24, 26, 25, 28, 27,
* SFPI Entry Points
*
***********************************************************/

int
onlp_sfpi_init(void)
{
Expand Down Expand Up @@ -92,18 +92,18 @@ onlp_sfpi_is_present(int port)
*/
int present;
int bus, addr;

if(port <0 || port > 34)
return ONLP_STATUS_E_INTERNAL;

addr = 60;
bus = 11;

if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}

return present;
}

Expand All @@ -116,8 +116,8 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
int bus=11;
char file[64] = {0};
int count;
ptr = bytes;

ptr = bytes;
sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr);
fp = fopen(file, "r");
if(fp == NULL) {
Expand All @@ -132,7 +132,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3.");
return ONLP_STATUS_E_INTERNAL;
}

/* Convert to 64 bit integer in port order */
uint64_t presence_all = 0 ;
int i = 0;
Expand All @@ -158,7 +158,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
FILE* fp;

int addr=60, i = 0;

fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr);
Expand All @@ -181,7 +181,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
}

/* Populate bitmap */
for(i = 0; rx_los_all; i++) {
for(i = 0; rx_los_all; i++) {
AIM_BITMAP_MOD(dst, i, (rx_los_all & 1));
rx_los_all >>= 1;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ onlp_sfpi_dom_read(int port, uint8_t data[256])
{
FILE* fp;
char file[64] = {0};

sprintf(file, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port));
fp = fopen(file, "r");
if(fp == NULL) {
Expand Down Expand Up @@ -279,39 +279,23 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
int rv;
int addr = 60;
int bus = 11;

if(port <0 || port > 34)
return ONLP_STATUS_E_INTERNAL;

switch(control)
{
case ONLP_SFP_CONTROL_TX_DISABLE:
{
if(port==32 || port==33)
{
if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) {
if(port==32 || port==33) {
if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
}
else if(port >=0)
{
if(!onlp_sfpi_is_present(port))
return ONLP_STATUS_OK;
rv=onlp_sfpi_dev_writeb(port, 0x50, 86, 1);
if(rv < 0)
{
AIM_LOG_ERROR("Fail to read onlp_sfpi_dev_writeb, port=%d\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else
{
rv = ONLP_STATUS_OK;
}
}
else {
rv = ONLP_STATUS_E_UNSUPPORTED;
}
break;
}

Expand All @@ -329,16 +313,12 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
int rv;
int addr = 60;
int bus = 11;

if(port <0 || port > 34)
return ONLP_STATUS_E_INTERNAL;

switch(control)
{
case ONLP_SFP_CONTROL_RX_LOS:
{
if(port==32 || port==33)
{
if(port==32 || port==33) {
if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
Expand All @@ -347,16 +327,15 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rv = ONLP_STATUS_OK;
}
}
else
return ONLP_STATUS_E_UNSUPPORTED;
else {
rv = ONLP_STATUS_E_UNSUPPORTED;
}
break;
}

case ONLP_SFP_CONTROL_TX_FAULT:
{
if(port==32 || port==33)
{
if(port==32 || port==33) {
if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
Expand All @@ -365,15 +344,15 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rv = ONLP_STATUS_OK;
}
}
else
return ONLP_STATUS_E_UNSUPPORTED;
else {
rv = ONLP_STATUS_E_UNSUPPORTED;
}
break;
}

case ONLP_SFP_CONTROL_TX_DISABLE:
{
if(port==32 || port==33)
{
if(port==32 || port==33) {
if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
Expand All @@ -382,27 +361,8 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rv = ONLP_STATUS_OK;
}
}
else
{
if(port >= 0)
{
if(!onlp_sfpi_is_present(port))
{
*value=0;
return ONLP_STATUS_OK;
}
rv=onlp_sfpi_dev_readb(port, 0x50, 86);
if(rv < 0)
{
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else
{
*value= (rv & 0x1);
rv = ONLP_STATUS_OK;
}
}
else {
rv = ONLP_STATUS_E_UNSUPPORTED;
}
break;
}
Expand All @@ -419,4 +379,3 @@ onlp_sfpi_denit(void)
{
return ONLP_STATUS_OK;
}

0 comments on commit f29aa90

Please sign in to comment.