mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Mellanox MSN2700, MSN2100 and MSN2410 platforms ONL support.
Signed-off-by: Michael Shych <michaelsh@mellanox.com>
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
- smartmontools
|
||||
- grub2
|
||||
- onl-upgrade
|
||||
|
||||
|
||||
|
||||
- hw-management
|
||||
- sx-kernel
|
||||
|
||||
|
||||
|
||||
@@ -1877,7 +1877,7 @@ CONFIG_I2C_ALGOPCA=y
|
||||
# CONFIG_I2C_AMD8111 is not set
|
||||
CONFIG_I2C_I801=y
|
||||
CONFIG_I2C_ISCH=y
|
||||
CONFIG_I2C_ISMT=y
|
||||
# CONFIG_I2C_ISMT is not set
|
||||
# CONFIG_I2C_PIIX4 is not set
|
||||
# CONFIG_I2C_NFORCE2 is not set
|
||||
# CONFIG_I2C_SIS5595 is not set
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,175 +1,145 @@
|
||||
+ 0x75diff -urpN a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c 2016-09-15 19:55:02.680725611 +0000
|
||||
@@ -179,8 +179,11 @@ static s32 igb_init_phy_params_82575(str
|
||||
ctrl_ext = rd32(E1000_CTRL_EXT);
|
||||
|
||||
if (igb_sgmii_active_82575(hw)) {
|
||||
- phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
|
||||
- ctrl_ext |= E1000_CTRL_I2C_ENA;
|
||||
+ if(phy->type == e1000_phy_bcm5461s)
|
||||
+ phy->ops.reset = igb_phy_hw_reset;
|
||||
+ else
|
||||
+ phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
|
||||
+ ctrl_ext |= E1000_CTRL_I2C_ENA;
|
||||
} else {
|
||||
phy->ops.reset = igb_phy_hw_reset;
|
||||
ctrl_ext &= ~E1000_CTRL_I2C_ENA;
|
||||
@@ -286,6 +289,19 @@ static s32 igb_init_phy_params_82575(str
|
||||
phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state_82580;
|
||||
phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c 2016-11-14 15:48:41.379628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c 2016-11-15 09:36:04.608478513 +0000
|
||||
@@ -302,6 +302,16 @@
|
||||
phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580;
|
||||
phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
|
||||
break;
|
||||
+
|
||||
+ case BCM5461S_PHY_ID:
|
||||
+ phy->type = e1000_phy_bcm5461s;
|
||||
+ phy->ops.check_polarity = NULL;
|
||||
+ phy->ops.get_phy_info = igb_get_phy_info_5461s;
|
||||
+ phy->ops.get_cable_length = NULL;
|
||||
+ phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580;
|
||||
+ break;
|
||||
+
|
||||
+ case BCM5461S_PHY_ID:
|
||||
+ phy->type = e1000_phy_bcm5461s;
|
||||
+ phy->ops.check_polarity = NULL;
|
||||
+ phy->ops.get_info = igb_get_phy_info_5461s;
|
||||
+ phy->ops.get_cable_length = NULL;
|
||||
+ phy->ops.force_speed_duplex = igb_e1000_phy_force_speed_duplex_82577;
|
||||
+ break;
|
||||
+ case BCM54616_E_PHY_ID:
|
||||
+ phy->type = e1000_phy_bcm54616;
|
||||
+ break;
|
||||
+
|
||||
+ phy->type = e1000_phy_bcm54616;
|
||||
+ break;
|
||||
default:
|
||||
ret_val = -E1000_ERR_PHY;
|
||||
goto out;
|
||||
@@ -827,9 +843,9 @@ static s32 igb_get_phy_id_82575(struct e
|
||||
break;
|
||||
case e1000_82580:
|
||||
case e1000_i350:
|
||||
- case e1000_i354:
|
||||
case e1000_i210:
|
||||
case e1000_i211:
|
||||
+ case e1000_i354:
|
||||
mdic = rd32(E1000_MDICNFG);
|
||||
mdic &= E1000_MDICNFG_PHY_MASK;
|
||||
phy->addr = mdic >> E1000_MDICNFG_PHY_SHIFT;
|
||||
@@ -840,6 +856,17 @@ static s32 igb_get_phy_id_82575(struct e
|
||||
@@ -701,6 +711,17 @@
|
||||
break;
|
||||
}
|
||||
ret_val = igb_get_phy_id(hw);
|
||||
ret_val = e1000_get_phy_id(hw);
|
||||
+
|
||||
+ if (ret_val && hw->mac.type == e1000_i354) {
|
||||
+ /* we do a special check for bcm5461s phy by setting
|
||||
+ * the phy->addr to 5 and doing the phy check again. This
|
||||
+ * call will succeed and retrieve a valid phy id if we have
|
||||
+ * the bcm5461s phy
|
||||
+ */
|
||||
+ phy->addr = 5;
|
||||
+ phy->type = e1000_phy_bcm5461s;
|
||||
+ ret_val = igb_get_phy_id(hw);
|
||||
+ /* we do a special check for bcm5461s phy by setting
|
||||
+ * the phy->addr to 5 and doing the phy check again. This
|
||||
+ * call will succeed and retrieve a valid phy id if we have
|
||||
+ * the bcm5461s phy
|
||||
+ */
|
||||
+ phy->addr = 5;
|
||||
+ phy->type = e1000_phy_bcm5461s;
|
||||
+ ret_val = e1000_get_phy_id(hw);
|
||||
+ }
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1220,6 +1247,9 @@ static s32 igb_get_cfg_done_82575(struct
|
||||
|
||||
@@ -1148,6 +1169,9 @@
|
||||
(hw->phy.type == e1000_phy_igp_3))
|
||||
igb_phy_init_script_igp3(hw);
|
||||
|
||||
e1000_phy_init_script_igp3(hw);
|
||||
|
||||
+ if (hw->phy.type == e1000_phy_bcm5461s)
|
||||
+ igb_phy_init_script_5461s(hw);
|
||||
+ igb_phy_init_script_5461s(hw);
|
||||
+
|
||||
return 0;
|
||||
return E1000_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1552,6 +1582,7 @@ static s32 igb_setup_copper_link_82575(s
|
||||
|
||||
@@ -1557,6 +1581,7 @@
|
||||
case e1000_i350:
|
||||
case e1000_i210:
|
||||
case e1000_i211:
|
||||
+ case e1000_i354:
|
||||
phpm_reg = rd32(E1000_82580_PHY_POWER_MGMT);
|
||||
phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
|
||||
phpm_reg &= ~E1000_82580_PM_GO_LINKD;
|
||||
wr32(E1000_82580_PHY_POWER_MGMT, phpm_reg);
|
||||
@@ -1595,6 +1626,10 @@ static s32 igb_setup_copper_link_82575(s
|
||||
E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
|
||||
@@ -1602,6 +1627,10 @@
|
||||
case e1000_phy_82580:
|
||||
ret_val = igb_copper_link_setup_82580(hw);
|
||||
ret_val = igb_e1000_copper_link_setup_82577(hw);
|
||||
break;
|
||||
+ case e1000_phy_bcm54616:
|
||||
+ break;
|
||||
+ case e1000_phy_bcm5461s:
|
||||
+ break;
|
||||
+ break;
|
||||
default:
|
||||
ret_val = -E1000_ERR_PHY;
|
||||
break;
|
||||
diff -urpN a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h 2016-09-15 19:55:27.068726140 +0000
|
||||
@@ -860,6 +860,8 @@
|
||||
#define M88_VENDOR 0x0141
|
||||
#define I210_I_PHY_ID 0x01410C00
|
||||
#define M88E1543_E_PHY_ID 0x01410EA0
|
||||
+#define BCM54616_E_PHY_ID 0x3625D10
|
||||
+#define BCM5461S_PHY_ID 0x002060C0
|
||||
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h 2016-11-14 15:48:41.383628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h 2016-11-14 17:13:16.567695539 +0000
|
||||
@@ -1184,6 +1184,8 @@
|
||||
#define I350_I_PHY_ID 0x015403B0
|
||||
#define I210_I_PHY_ID 0x01410C00
|
||||
#define IGP04E1000_E_PHY_ID 0x02A80391
|
||||
+#define BCM54616_E_PHY_ID 0x3625D10
|
||||
+#define BCM5461S_PHY_ID 0x002060C0
|
||||
#define M88_VENDOR 0x0141
|
||||
|
||||
/* M88E1000 Specific Registers */
|
||||
#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
|
||||
diff -urpN a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h 2016-09-15 19:55:44.584726520 +0000
|
||||
@@ -128,6 +128,8 @@ enum e1000_phy_type {
|
||||
e1000_phy_ife,
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h 2016-11-14 15:48:41.387628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h 2016-11-14 17:11:55.735694465 +0000
|
||||
@@ -133,6 +133,8 @@
|
||||
e1000_phy_82580,
|
||||
e1000_phy_vf,
|
||||
e1000_phy_i210,
|
||||
+ e1000_phy_bcm54616,
|
||||
+ e1000_phy_bcm5461s,
|
||||
};
|
||||
|
||||
|
||||
enum e1000_bus_type {
|
||||
diff -urpN a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c 2016-09-15 20:07:34.964741935 +0000
|
||||
@@ -148,6 +148,14 @@ s32 igb_read_phy_reg_mdic(struct e1000_h
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c 2016-11-14 15:48:41.403628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c 2016-11-15 09:48:09.668488140 +0000
|
||||
@@ -272,6 +272,13 @@
|
||||
* Control register. The MAC will take care of interfacing with the
|
||||
* PHY to retrieve the desired data.
|
||||
*/
|
||||
+
|
||||
+ if (phy->type == e1000_phy_bcm5461s) {
|
||||
+ mdic = rd32(E1000_MDICNFG);
|
||||
+ mdic &= ~E1000_MDICNFG_PHY_MASK;
|
||||
+ mdic |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
|
||||
+ wr32(E1000_MDICNFG, mdic);
|
||||
+ mdic = E1000_READ_REG(hw, E1000_MDICNFG);
|
||||
+ mdic &= ~E1000_MDICNFG_PHY_MASK;
|
||||
+ mdic |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
|
||||
+ E1000_WRITE_REG(hw, E1000_MDICNFG, mdic);
|
||||
+ }
|
||||
+
|
||||
mdic = ((offset << E1000_MDIC_REG_SHIFT) |
|
||||
(phy->addr << E1000_MDIC_PHY_SHIFT) |
|
||||
(E1000_MDIC_OP_READ));
|
||||
@@ -204,6 +212,14 @@ s32 igb_write_phy_reg_mdic(struct e1000_
|
||||
@@ -331,6 +338,13 @@
|
||||
* Control register. The MAC will take care of interfacing with the
|
||||
* PHY to retrieve the desired data.
|
||||
*/
|
||||
+
|
||||
+ if (phy->type == e1000_phy_bcm5461s) {
|
||||
+ mdic = rd32(E1000_MDICNFG);
|
||||
+ mdic &= ~E1000_MDICNFG_PHY_MASK;
|
||||
+ mdic |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
|
||||
+ wr32(E1000_MDICNFG, mdic);
|
||||
+ mdic = E1000_READ_REG(hw, E1000_MDICNFG);
|
||||
+ mdic &= ~E1000_MDICNFG_PHY_MASK;
|
||||
+ mdic |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
|
||||
+ E1000_WRITE_REG(hw, E1000_MDICNFG, mdic);
|
||||
+ }
|
||||
+
|
||||
mdic = (((u32)data) |
|
||||
(offset << E1000_MDIC_REG_SHIFT) |
|
||||
(phy->addr << E1000_MDIC_PHY_SHIFT) |
|
||||
@@ -1115,11 +1131,13 @@ s32 igb_setup_copper_link(struct e1000_h
|
||||
@@ -1614,10 +1628,12 @@
|
||||
* depending on user settings.
|
||||
*/
|
||||
hw_dbg("Forcing Speed and Duplex\n");
|
||||
DEBUGOUT("Forcing Speed and Duplex\n");
|
||||
- ret_val = hw->phy.ops.force_speed_duplex(hw);
|
||||
- if (ret_val) {
|
||||
+ if(hw->phy.ops.force_speed_duplex) {
|
||||
+ ret_val = hw->phy.ops.force_speed_duplex(hw);
|
||||
+ if (ret_val) {
|
||||
hw_dbg("Error Forcing Speed and Duplex\n");
|
||||
goto out;
|
||||
- }
|
||||
+ }
|
||||
+ }
|
||||
- DEBUGOUT("Error Forcing Speed and Duplex\n");
|
||||
- return ret_val;
|
||||
+ if (hw->phy.ops.force_speed_duplex) {
|
||||
+ ret_val = hw->phy.ops.force_speed_duplex(hw);
|
||||
+ if (ret_val) {
|
||||
+ DEBUGOUT("Error Forcing Speed and Duplex\n");
|
||||
+ return ret_val;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
/* Check link status. Wait up to 100 microseconds for link to become
|
||||
@@ -2509,3 +2527,67 @@ static s32 igb_set_master_slave_mode(str
|
||||
|
||||
return hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data);
|
||||
|
||||
@@ -3407,3 +3423,67 @@
|
||||
|
||||
return ready;
|
||||
}
|
||||
+
|
||||
+/**
|
||||
@@ -216,7 +186,7 @@ diff -urpN a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/i
|
||||
+ s32 ret_val;
|
||||
+ bool link;
|
||||
+
|
||||
+ ret_val = igb_phy_has_link(hw, 1, 0, &link);
|
||||
+ ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
|
||||
+ if (ret_val)
|
||||
+ goto out;
|
||||
+
|
||||
@@ -235,46 +205,38 @@ diff -urpN a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/i
|
||||
+out:
|
||||
+ return ret_val;
|
||||
+}
|
||||
diff -urpN a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_phy.h 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.h 2016-09-15 19:41:43.584708271 +0000
|
||||
@@ -61,6 +61,8 @@ s32 igb_phy_has_link(struct e1000_hw *h
|
||||
void igb_power_up_phy_copper(struct e1000_hw *hw);
|
||||
void igb_power_down_phy_copper(struct e1000_hw *hw);
|
||||
s32 igb_phy_init_script_igp3(struct e1000_hw *hw);
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h
|
||||
--- a/drivers/net/ethernet/intel/igb/e1000_phy.h 2016-11-14 15:48:41.403628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.h 2016-11-14 17:21:08.243701801 +0000
|
||||
@@ -74,6 +74,8 @@
|
||||
s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
|
||||
u32 usec_interval, bool *success);
|
||||
s32 e1000_phy_init_script_igp3(struct e1000_hw *hw);
|
||||
+s32 igb_phy_init_script_5461s(struct e1000_hw *hw);
|
||||
+s32 igb_get_phy_info_5461s(struct e1000_hw *hw);
|
||||
s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data);
|
||||
s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
|
||||
s32 igb_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data);
|
||||
diff -urpN a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
|
||||
--- a/drivers/net/ethernet/intel/igb/igb_main.c 2016-03-02 10:31:21.000000000 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/igb_main.c 2016-09-15 19:56:53.276728011 +0000
|
||||
@@ -108,6 +108,7 @@ static const struct pci_device_id igb_pc
|
||||
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 },
|
||||
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 },
|
||||
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82575GB_QUAD_COPPER), board_82575 },
|
||||
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_SGMII), board_82575 },
|
||||
/* required last entry */
|
||||
{0, }
|
||||
};
|
||||
@@ -7198,11 +7199,19 @@ static int igb_mii_ioctl(struct net_devi
|
||||
data->phy_id = adapter->hw.phy.addr;
|
||||
break;
|
||||
enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id);
|
||||
s32 e1000_determine_phy_address(struct e1000_hw *hw);
|
||||
s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg);
|
||||
diff -Nu a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
|
||||
--- a/drivers/net/ethernet/intel/igb/igb_main.c 2016-11-14 15:48:41.411628151 +0000
|
||||
+++ b/drivers/net/ethernet/intel/igb/igb_main.c 2016-11-14 19:07:51.867786828 +0000
|
||||
@@ -8607,11 +8607,19 @@
|
||||
case SIOCGMIIREG:
|
||||
+ adapter->hw.phy.addr = data->phy_id;
|
||||
if (igb_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
|
||||
&data->val_out))
|
||||
if (!capable(CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
+ adapter->hw.phy.addr = data->phy_id;
|
||||
if (igb_e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
|
||||
&data->val_out))
|
||||
return -EIO;
|
||||
break;
|
||||
case SIOCSMIIREG:
|
||||
+ if (!capable(CAP_NET_ADMIN))
|
||||
+ return -EPERM;
|
||||
+ adapter->hw.phy.addr = data->phy_id;
|
||||
+ if (igb_write_phy_reg(&adapter->hw, data->reg_num & 0x1F,
|
||||
+ data->val_in))
|
||||
+ return -EIO;
|
||||
+ break;
|
||||
+ if (!capable(CAP_NET_ADMIN))
|
||||
+ return -EPERM;
|
||||
+ adapter->hw.phy.addr = data->phy_id;
|
||||
+ if (igb_e1000_write_phy_reg(&adapter->hw, data->reg_num & 0x1F,
|
||||
+ data->val_in))
|
||||
+ return -EIO;
|
||||
+ break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,5 @@ driver-hwmon-pmbus-add-dps460-support.patch
|
||||
driver-hwmon-pmbus-ucd9200-mlnx.patch
|
||||
driver-arista-piix4-mux-patch.patch
|
||||
3.16-fs-overlayfs.patch
|
||||
driver-igb-version-5.3.54.patch
|
||||
driver-support-intel-igb-bcm5461X-phy.patch
|
||||
|
||||
|
||||
|
||||
1
packages/platforms/mellanox/vendor-config/Makefile
Normal file
1
packages/platforms/mellanox/vendor-config/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
packages/platforms/mellanox/vendor-config/PKG.yml
Normal file
1
packages/platforms/mellanox/vendor-config/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=mellanox Vendor=Mellanox
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from onl.platform.base import *
|
||||
|
||||
class OnlPlatformMellanox(OnlPlatformBase):
|
||||
MANUFACTURER='Mellanox'
|
||||
PRIVATE_ENTERPRISE_NUMBER=33049
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mlnx-msn2100 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-mlnx-msn2100
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_mlnx_msn2100 onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-mlnx-msn2100.so
|
||||
$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
|
||||
include $(BUILDER)/so.mk
|
||||
.DEFAULT_GOAL := $(SHAREDLIB)
|
||||
|
||||
GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2100-r0 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:22.249911
|
||||
#
|
||||
###############################################################################
|
||||
libonlp-x86-64-mlnx-msn2100-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2100 module.
|
||||
#
|
||||
# Autogenerated 2016-10-13 22:58:39.095824
|
||||
#
|
||||
###############################################################################
|
||||
libonlp-x86-64-mlnx-msn2100_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the x86_64_mlnx_msn2100 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:22.262891
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2100_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
.DEFAULT_GOAL := onlpdump
|
||||
|
||||
MODULE := onlpdump
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF onlp x86_64_mlnx_msn2100 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
BINARY := onlpdump
|
||||
$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS)
|
||||
include $(BUILDER)/bin.mk
|
||||
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1
|
||||
GLOBAL_LINK_LIBS += -lpthread -lm
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the onlpdump module.
|
||||
#
|
||||
# Autogenerated 2016-10-13 22:58:37.393320
|
||||
#
|
||||
###############################################################################
|
||||
onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
name: x86_64_mlnx_msn2100
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
include ../../init.mk
|
||||
MODULE := x86_64_mlnx_msn2100
|
||||
AUTOMODULE := x86_64_mlnx_msn2100
|
||||
include $(BUILDER)/definemodule.mk
|
||||
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2100 README
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2100 Autogeneration
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2100_AUTO_DEFS := module/auto/x86_64_mlnx_msn2100.yml
|
||||
x86_64_mlnx_msn2100_AUTO_DIRS := module/inc/x86_64_mlnx_msn2100 module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2100 Autogeneration Definitions.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB
|
||||
- X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
- X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION:
|
||||
doc: "Assume chassis fan direction is the same as the PSU fan direction."
|
||||
default: 0
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
X86_64_MLNX_MSN2100_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: x86_64_mlnx_msn2100_config
|
||||
|
||||
portingmacro:
|
||||
x86_64_mlnx_msn2100:
|
||||
macros:
|
||||
- malloc
|
||||
- free
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- vsnprintf
|
||||
- snprintf
|
||||
- strlen
|
||||
@@ -0,0 +1,14 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
/* <--auto.start.xmacro(ALL).define> */
|
||||
/* <auto.end.xmacro(ALL).define> */
|
||||
|
||||
/* <--auto.start.xenum(ALL).define> */
|
||||
/* <auto.end.xenum(ALL).define> */
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_mlnx_msn2100 Configuration Header
|
||||
*
|
||||
* @addtogroup x86_64_mlnx_msn2100-config
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2100_CONFIG_H__
|
||||
#define __x86_64_mlnx_msn2100_CONFIG_H__
|
||||
|
||||
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
|
||||
#include <global_custom_config.h>
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_INCLUDE_CUSTOM_CONFIG
|
||||
#include <x86_64_mlnx_msn2100_custom_config.h>
|
||||
#endif
|
||||
|
||||
/* <auto.start.cdefs(x86_64_mlnx_msn2100_CONFIG_HEADER).header> */
|
||||
#include <AIM/aim.h>
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING
|
||||
*
|
||||
* Include or exclude logging. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING
|
||||
#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
*
|
||||
* Default enabled log options. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
#define x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT
|
||||
#define x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled custom log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
#define x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB
|
||||
*
|
||||
* Default all porting macros to use the C standard libraries. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB
|
||||
#define x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
*
|
||||
* Include standard library headers for stdlib porting macros. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
#define x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI
|
||||
*
|
||||
* Include generic uCli support. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI
|
||||
#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
*
|
||||
* Assume chassis fan direction is the same as the PSU fan direction. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* All compile time options can be queried or displayed
|
||||
*/
|
||||
|
||||
/** Configuration settings structure. */
|
||||
typedef struct x86_64_mlnx_msn2100_config_settings_s {
|
||||
/** name */
|
||||
const char* name;
|
||||
/** value */
|
||||
const char* value;
|
||||
} x86_64_mlnx_msn2100_config_settings_t;
|
||||
|
||||
/** Configuration settings table. */
|
||||
/** x86_64_mlnx_msn2100_config_settings table. */
|
||||
extern x86_64_mlnx_msn2100_config_settings_t x86_64_mlnx_msn2100_config_settings[];
|
||||
|
||||
/**
|
||||
* @brief Lookup a configuration setting.
|
||||
* @param setting The name of the configuration option to lookup.
|
||||
*/
|
||||
const char* x86_64_mlnx_msn2100_config_lookup(const char* setting);
|
||||
|
||||
/**
|
||||
* @brief Show the compile-time configuration.
|
||||
* @param pvs The output stream.
|
||||
*/
|
||||
int x86_64_mlnx_msn2100_config_show(struct aim_pvs_s* pvs);
|
||||
|
||||
/* <auto.end.cdefs(x86_64_mlnx_msn2100_CONFIG_HEADER).header> */
|
||||
|
||||
#include "x86_64_mlnx_msn2100_porting.h"
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2100_CONFIG_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,26 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_mlnx_msn2100 Doxygen Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2100_DOX_H__
|
||||
#define __x86_64_mlnx_msn2100_DOX_H__
|
||||
|
||||
/**
|
||||
* @defgroup x86_64_mlnx_msn2100 x86_64_mlnx_msn2100 - x86_64_mlnx_msn2100 Description
|
||||
*
|
||||
|
||||
The documentation overview for this module should go here.
|
||||
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup x86_64_mlnx_msn2100-x86_64_mlnx_msn2100 Public Interface
|
||||
* @defgroup x86_64_mlnx_msn2100-config Compile Time Configuration
|
||||
* @defgroup x86_64_mlnx_msn2100-porting Porting Macros
|
||||
*
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2100_DOX_H__ */
|
||||
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_mlnx_msn2100 Porting Macros.
|
||||
*
|
||||
* @addtogroup x86_64_mlnx_msn2100-porting
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2100_PORTING_H__
|
||||
#define __x86_64_mlnx_msn2100_PORTING_H__
|
||||
|
||||
|
||||
/* <auto.start.portingmacro(ALL).define> */
|
||||
#if x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_MALLOC
|
||||
#if defined(GLOBAL_MALLOC)
|
||||
#define x86_64_mlnx_msn2100_MALLOC GLOBAL_MALLOC
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_MALLOC malloc
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_MALLOC is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_FREE
|
||||
#if defined(GLOBAL_FREE)
|
||||
#define x86_64_mlnx_msn2100_FREE GLOBAL_FREE
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_FREE free
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_FREE is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_MEMSET
|
||||
#if defined(GLOBAL_MEMSET)
|
||||
#define x86_64_mlnx_msn2100_MEMSET GLOBAL_MEMSET
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_MEMSET memset
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_MEMSET is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_MEMCPY
|
||||
#if defined(GLOBAL_MEMCPY)
|
||||
#define x86_64_mlnx_msn2100_MEMCPY GLOBAL_MEMCPY
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_MEMCPY memcpy
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_MEMCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_STRNCPY
|
||||
#if defined(GLOBAL_STRNCPY)
|
||||
#define x86_64_mlnx_msn2100_STRNCPY GLOBAL_STRNCPY
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_STRNCPY strncpy
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_STRNCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_VSNPRINTF
|
||||
#if defined(GLOBAL_VSNPRINTF)
|
||||
#define x86_64_mlnx_msn2100_VSNPRINTF GLOBAL_VSNPRINTF
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_VSNPRINTF vsnprintf
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_VSNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_SNPRINTF
|
||||
#if defined(GLOBAL_SNPRINTF)
|
||||
#define x86_64_mlnx_msn2100_SNPRINTF GLOBAL_SNPRINTF
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_SNPRINTF snprintf
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_SNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2100_STRLEN
|
||||
#if defined(GLOBAL_STRLEN)
|
||||
#define x86_64_mlnx_msn2100_STRLEN GLOBAL_STRLEN
|
||||
#elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2100_STRLEN strlen
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2100_STRLEN is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* <auto.end.portingmacro(ALL).define> */
|
||||
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2100_PORTING_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,10 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
x86_64_mlnx_msn2100_INCLUDES := -I $(THIS_DIR)inc
|
||||
x86_64_mlnx_msn2100_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
x86_64_mlnx_msn2100_DEPENDMODULE_ENTRIES := init:x86_64_mlnx_msn2100 ucli:x86_64_mlnx_msn2100
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Local source generation targets.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ucli:
|
||||
@../../../../tools/uclihandlers.py x86_64_mlnx_msn2100_ucli.c
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Fan Platform Implementation Defaults.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PREFIX_PATH "/bsp/fan/"
|
||||
|
||||
#define FAN_STATUS_OK 1
|
||||
|
||||
#define PERCENTAGE_MIN 60.0
|
||||
#define PERCENTAGE_MAX 100.0
|
||||
#define RPM_MAGIC_MIN 153.0
|
||||
#define RPM_MAGIC_MAX 255.0
|
||||
|
||||
#define PROJECT_NAME
|
||||
#define LEN_FILE_NAME 80
|
||||
|
||||
#define FAN_RESERVED 0
|
||||
#define FAN_1_ON_MAIN_BOARD 1
|
||||
#define FAN_2_ON_MAIN_BOARD 2
|
||||
#define FAN_3_ON_MAIN_BOARD 3
|
||||
#define FAN_4_ON_MAIN_BOARD 4
|
||||
#define FAN_MODEL "MEC012579"
|
||||
|
||||
static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0};
|
||||
static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0};
|
||||
|
||||
typedef struct fan_path_S
|
||||
{
|
||||
char status[LEN_FILE_NAME];
|
||||
char r_speed_get[LEN_FILE_NAME];
|
||||
char r_speed_set[LEN_FILE_NAME];
|
||||
char min[LEN_FILE_NAME];
|
||||
char max[LEN_FILE_NAME];
|
||||
}fan_path_T;
|
||||
|
||||
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \
|
||||
{ #prj"fan"#id"_status", \
|
||||
#prj"fan"#id"_speed_get", \
|
||||
#prj"fan"#id"_speed_set", \
|
||||
#prj"fan"#id"_min", \
|
||||
#prj"fan"#id"_max" }
|
||||
|
||||
#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id)
|
||||
|
||||
static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
{
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD)
|
||||
};
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \
|
||||
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
}
|
||||
|
||||
/* Static fan information */
|
||||
onlp_fan_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4)
|
||||
};
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define OPEN_READ_FILE(fullpath, data, nbytes, len) \
|
||||
if (onlp_file_read((uint8_t*)data, nbytes, &len, fullpath) < 0) \
|
||||
return ONLP_STATUS_E_INTERNAL; \
|
||||
else \
|
||||
AIM_LOG_VERBOSE("read data: %s\n", r_data); \
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int len = 0, nbytes = 10;
|
||||
float range = 0;
|
||||
float temp = 0;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[65] = {0};
|
||||
const char fan_model[]=FAN_MODEL;
|
||||
|
||||
/* Fixed system FAN is always present */
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
strncpy(info->model, fan_model, sizeof(info->model));
|
||||
|
||||
/* get fan speed */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* check failure */
|
||||
if (info->rpm <= 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) {
|
||||
/* get fan min speed */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].min);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
min_fan_speed[local_id] = atoi(r_data);
|
||||
|
||||
/* get fan max speed */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].max);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
max_fan_speed[local_id] = atoi(r_data);
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
range = max_fan_speed[local_id] - min_fan_speed[local_id];
|
||||
if (range > 0) {
|
||||
temp = ((float)info->rpm - (float)min_fan_speed[local_id]) / range * 40.0 + 60.0;
|
||||
if (temp < PERCENTAGE_MIN) {
|
||||
temp = PERCENTAGE_MIN;
|
||||
}
|
||||
info->percentage = (int)temp;
|
||||
} else {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rc = 0;
|
||||
int local_id = 0;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
*info = linfo[local_id];
|
||||
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
case FAN_3_ON_MAIN_BOARD:
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
break;
|
||||
default:
|
||||
rc = ONLP_STATUS_E_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the speed of the given fan in RPM.
|
||||
*
|
||||
* This function will only be called if the fan supprots the RPM_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_rpm_set(onlp_oid_t id, int rpm)
|
||||
{
|
||||
float temp = 0.0;
|
||||
int rv = 0, local_id = 0, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[LEN_FILE_NAME] = {0};
|
||||
onlp_fan_info_t* info = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
info = &linfo[local_id];
|
||||
|
||||
if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) {
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* reject rpm=0% (rpm=0%, stop fan) */
|
||||
if (0 == rpm) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH,
|
||||
fan_path[local_id].r_speed_set);
|
||||
|
||||
/* Set fan speed
|
||||
Converting percent to driver value.
|
||||
Driver accept value in range between 153 and 255.
|
||||
Value 153 is minimum rpm.
|
||||
Value 255 is maximum rpm.
|
||||
*/
|
||||
if (local_id > sizeof(min_fan_speed)/sizeof(min_fan_speed[0])) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
if (max_fan_speed[local_id] - min_fan_speed[local_id] < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
if (rpm < min_fan_speed[local_id] || rpm > max_fan_speed[local_id]) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
temp = (rpm - min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) /
|
||||
(max_fan_speed[local_id] - min_fan_speed[local_id]) + RPM_MAGIC_MIN;
|
||||
|
||||
snprintf(r_data, sizeof(r_data), "%d", (int)temp);
|
||||
nbytes = strnlen(r_data, sizeof(r_data));
|
||||
rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
float temp = 0.0;
|
||||
int rv = 0, local_id = 0, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[LEN_FILE_NAME] = {0};
|
||||
onlp_fan_info_t* info = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
info = &linfo[local_id];
|
||||
|
||||
if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) {
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* reject p=0% (p=0%, stop fan) */
|
||||
if (0 == p) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH,
|
||||
fan_path[local_id].r_speed_set);
|
||||
|
||||
/* Set fan speed
|
||||
Converting percent to driver value.
|
||||
Driver accept value in range between 153 and 255.
|
||||
Value 153 is 60%.
|
||||
Value 255 is 100%.
|
||||
*/
|
||||
temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) /
|
||||
(PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN;
|
||||
|
||||
snprintf(r_data, sizeof(r_data), "%d", (int)temp);
|
||||
nbytes = strnlen(r_data, sizeof(r_data));
|
||||
rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as per
|
||||
* the predefined ONLP fan speed modes: off, slow, normal, fast, max.
|
||||
*
|
||||
* Interpretation of these modes is up to the platform.
|
||||
*
|
||||
*/
|
||||
int
|
||||
onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan direction of the given OID.
|
||||
*
|
||||
* This function is only relevant if the fan OID supports both direction
|
||||
* capabilities.
|
||||
*
|
||||
* This function is optional unless the functionality is available.
|
||||
*/
|
||||
int
|
||||
onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic fan ioctl. Optional.
|
||||
*/
|
||||
int
|
||||
onlp_fani_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define prefix_path "/bsp/led/led_"
|
||||
#define driver_value_len 50
|
||||
|
||||
#define LED_MODE_OFF "none"
|
||||
#define LED_MODE_GREEN "green"
|
||||
#define LED_MODE_RED "red"
|
||||
#define LED_MODE_BLUE "blue"
|
||||
#define LED_MODE_GREEN_BLINK "green_blink"
|
||||
#define LED_MODE_RED_BLINK "red_blink"
|
||||
#define LED_MODE_BLUE_BLINK "blue_blink"
|
||||
#define LED_MODE_AUTO "cpld_control"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
enum onlp_led_id
|
||||
{
|
||||
LED_RESERVED = 0,
|
||||
LED_SYSTEM,
|
||||
LED_FAN,
|
||||
LED_PSU1,
|
||||
LED_PSU2,
|
||||
LED_UID
|
||||
};
|
||||
|
||||
typedef struct led_light_mode_map {
|
||||
enum onlp_led_id id;
|
||||
char* driver_led_mode;
|
||||
enum onlp_led_mode_e onlp_led_mode;
|
||||
} led_light_mode_map_t;
|
||||
|
||||
led_light_mode_map_t led_map[] = {
|
||||
{LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_FAN, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_FAN, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_FAN, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_PSU1, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_PSU1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_PSU1, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_PSU1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_PSU1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_PSU2, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_PSU2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_PSU2, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_PSU2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_PSU2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_UID, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_UID, LED_MODE_BLUE, ONLP_LED_MODE_BLUE},
|
||||
{LED_UID, LED_MODE_BLUE_BLINK, ONLP_LED_MODE_BLUE_BLINKING},
|
||||
{LED_UID, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
};
|
||||
|
||||
static char file_names[][10] = /* must map with onlp_led_id */
|
||||
{
|
||||
"reserved",
|
||||
"status",
|
||||
"fan",
|
||||
"psu1",
|
||||
"psu2",
|
||||
"uid"
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the information for the given LED OID.
|
||||
*/
|
||||
static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_SYSTEM), "Chassis LED 1 (SYSTEM LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 2 (FAN LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 3 (PSU1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_UID), "Chassis LED 5 (UID LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING |
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
}
|
||||
};
|
||||
|
||||
static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id &&
|
||||
!strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len))
|
||||
{
|
||||
return led_map[i].onlp_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
|
||||
{
|
||||
return led_map[i].driver_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return LED_MODE_OFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* TODO setting UI LED to off when it will be supported
|
||||
*/
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int len, local_id = 0;
|
||||
uint8_t data[driver_value_len] = {0};
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* get fullpath */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[ONLP_OID_ID_GET(id)];
|
||||
|
||||
/* Get LED mode */
|
||||
if (onlp_file_read(data, sizeof(data), &len, fullpath) != 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mode = driver_to_onlp_led_mode(local_id, (char*)data);
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
|
||||
if (!on_or_off) {
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function puts the LED into the given mode. It is a more functional
|
||||
* interface for multimode LEDs.
|
||||
*
|
||||
* Only modes reported in the LED's capabilities will be attempted.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int local_id;
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]);
|
||||
|
||||
if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, fullpath) != 0)
|
||||
{
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
LIBRARY := x86_64_mlnx_msn2100
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/lib.mk
|
||||
@@ -0,0 +1,35 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <AIM/aim.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <sys/mman.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
/* Nothing on this platform */
|
||||
@@ -0,0 +1,52 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#ifndef __PLATFORM_LIB_H__
|
||||
#define __PLATFORM_LIB_H__
|
||||
|
||||
#include <onlp/fan.h>
|
||||
#include <onlp/psu.h>
|
||||
#include "x86_64_mlnx_msn2100_log.h"
|
||||
|
||||
#define CHASSIS_LED_COUNT 5
|
||||
#define CHASSIS_PSU_COUNT 2
|
||||
#define CHASSIS_FAN_COUNT 4
|
||||
#define CHASSIS_THERMAL_COUNT 7
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s"
|
||||
#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s"
|
||||
#define IDPROM_PATH "/bsp/eeprom/%s%d_info"
|
||||
|
||||
typedef enum psu_type {
|
||||
PSU_TYPE_UNKNOWN,
|
||||
PSU_TYPE_AC_F2B,
|
||||
PSU_TYPE_AC_B2F
|
||||
} psu_type_t;
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
@@ -0,0 +1,176 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_STATUS_PRESENT 1
|
||||
#define PSU_CABLE_PRESENT 1
|
||||
|
||||
#define PSU_NODE_MAX_INT_LEN 8
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
#define PSU_MODEL "POW000167"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
psu_module_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int len, ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
sprintf(node_path, PSU_MODULE_PREFIX, id, node);
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path);
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_power_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int len, ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
sprintf(node_path, PSU_POWER_PREFIX, id, node);
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path);
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
_psu_info_get(onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int index = ONLP_OID_ID_GET(info->hdr.id);
|
||||
|
||||
/* Set capability */
|
||||
info->caps = ONLP_PSU_CAPS_AC;
|
||||
|
||||
if (info->status & ONLP_PSU_STATUS_FAILED) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Read voltage, current and power */
|
||||
if (psu_power_info_get(index, "volt", &val) == 0) {
|
||||
info->mvout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VOUT;
|
||||
}
|
||||
|
||||
if (psu_power_info_get(index, "curr", &val) == 0) {
|
||||
info->miout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IOUT;
|
||||
}
|
||||
|
||||
info->mpout = info->mvout * info->miout;
|
||||
info->caps |= ONLP_PSU_CAPS_POUT;
|
||||
|
||||
info->mpin = ((int)(info->mpout / 91)) * 100;
|
||||
info->caps |= ONLP_PSU_CAPS_PIN;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get all information about the given PSU oid.
|
||||
*/
|
||||
static onlp_psu_info_t pinfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 },
|
||||
},
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
const char psu_model[]=PSU_MODEL;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
memset(info, 0, sizeof(onlp_psu_info_t));
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Fixed system, PSU is always present */
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
strncpy(info->model, psu_model, sizeof(info->model));
|
||||
|
||||
/* Get the cable preset state */
|
||||
if (psu_module_info_get(index, "pwr_status", &val) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_CABLE_PRESENT) {
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
ret = _psu_info_get(info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/sfpi.h>
|
||||
|
||||
#include <fcntl.h> /* For O_RDWR && open */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlplib/sfp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
#define SFP_SYSFS_VALUE_LEN 20
|
||||
static char sfp_node_path[MAX_SFP_PATH] = {0};
|
||||
#define NUM_OF_SFP_PORT 16
|
||||
#define SFP_PRESENT_STATUS "good"
|
||||
#define SFP_NOT_PRESENT_STATUS "not_connected"
|
||||
|
||||
static int
|
||||
msn2100_sfp_node_read_int(char *node_path, int *value)
|
||||
{
|
||||
int data_len = 0, ret = 0;
|
||||
char buf[SFP_SYSFS_VALUE_LEN] = {0};
|
||||
*value = -1;
|
||||
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path);
|
||||
|
||||
if (ret == 0) {
|
||||
if (!strncmp(buf, SFP_PRESENT_STATUS, strlen(SFP_PRESENT_STATUS))) {
|
||||
*value = 1;
|
||||
} else if (!strncmp(buf, SFP_NOT_PRESENT_STATUS, strlen(SFP_NOT_PRESENT_STATUS))) {
|
||||
*value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char*
|
||||
msn2100_sfp_get_port_path(int port, char *node_name)
|
||||
{
|
||||
sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name);
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
*
|
||||
***********************************************************/
|
||||
int
|
||||
onlp_sfpi_init(void)
|
||||
{
|
||||
/* Called at initialization time */
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
|
||||
{
|
||||
int p = 1;
|
||||
AIM_BITMAP_CLR_ALL(bmap);
|
||||
|
||||
for (; p <= NUM_OF_SFP_PORT; p++) {
|
||||
AIM_BITMAP_SET(bmap, p);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_is_present(int port)
|
||||
{
|
||||
/*
|
||||
* Return 1 if present.
|
||||
* Return 0 if not present.
|
||||
* Return < 0 if error.
|
||||
*/
|
||||
int present = -1;
|
||||
char* path = msn2100_sfp_get_port_path(port, "_status");
|
||||
|
||||
if (msn2100_sfp_node_read_int(path, &present) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return present;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
int ii = 1;
|
||||
int rc = 0;
|
||||
|
||||
for (;ii <= NUM_OF_SFP_PORT; ii++) {
|
||||
rc = onlp_sfpi_is_present(ii);
|
||||
AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = msn2100_sfp_get_port_path(port, "");
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
*
|
||||
* Return MISSING if SFP is missing.
|
||||
* Return OK if eeprom is read
|
||||
*/
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (onlplib_sfp_eeprom_read_file(path, data) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlp/platformi/sysi.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
#include "x86_64_mlnx_msn2100_int.h"
|
||||
#include "x86_64_mlnx_msn2100_log.h"
|
||||
|
||||
|
||||
|
||||
#define COMMAND_OUTPUT_BUFFER 256
|
||||
|
||||
#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld"
|
||||
#define NUM_OF_CPLD 2
|
||||
static char arr_cplddev_name[NUM_OF_CPLD][30] =
|
||||
{
|
||||
"cpld_brd_version",
|
||||
"cpld_mgmt_version"
|
||||
};
|
||||
|
||||
static void
|
||||
_onlp_sysi_execute_command(char *command, char buffer[COMMAND_OUTPUT_BUFFER])
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
/* Open the command for reading. */
|
||||
fp = popen(command, "r");
|
||||
if (NULL == fp) {
|
||||
AIM_LOG_WARN("Failed to run command '%s'\n", command);
|
||||
}
|
||||
|
||||
/* Read the output */
|
||||
if (fgets(buffer, COMMAND_OUTPUT_BUFFER-1, fp) == NULL) {
|
||||
AIM_LOG_WARN("Failed to read output of command '%s'\n", command);
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
/* The last symbol is '\n', so remote it */
|
||||
buffer[strnlen(buffer, COMMAND_OUTPUT_BUFFER) - 1] = '\0';
|
||||
|
||||
/* close */
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
return "x86-64-mlnx-msn2100-r0";
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD]={0};
|
||||
|
||||
for (i=0; i < NUM_OF_CPLD; i++) {
|
||||
v[i] = 0;
|
||||
if(onlp_file_read_int(v+i, "%s/%s", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d", v[0], v[1]);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_sysi_oids_get(onlp_oid_t* table, int max)
|
||||
{
|
||||
int i;
|
||||
onlp_oid_t* e = table;
|
||||
memset(table, 0, max*sizeof(onlp_oid_t));
|
||||
|
||||
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++)
|
||||
{
|
||||
*e++ = ONLP_THERMAL_ID_CREATE(i);
|
||||
}
|
||||
|
||||
for (i = 1; i <= CHASSIS_LED_COUNT; i++)
|
||||
{
|
||||
*e++ = ONLP_LED_ID_CREATE(i);
|
||||
}
|
||||
|
||||
for (i = 1; i <= CHASSIS_PSU_COUNT; i++)
|
||||
{
|
||||
*e++ = ONLP_PSU_ID_CREATE(i);
|
||||
}
|
||||
|
||||
for (i = 1; i <= CHASSIS_FAN_COUNT; i++)
|
||||
{
|
||||
*e++ = ONLP_FAN_ID_CREATE(i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_sysi_grep_output(char value[256], const char *attr, const char *tmp_file)
|
||||
{
|
||||
int value_offset = 30; /* value offset in onie-syseeprom */
|
||||
char command[256] = {0};
|
||||
char buffer[COMMAND_OUTPUT_BUFFER] = {0};
|
||||
int v = 0;
|
||||
|
||||
snprintf(command, sizeof(command), "cat '%s' | grep '%s'", tmp_file, attr);
|
||||
_onlp_sysi_execute_command(command, buffer);
|
||||
|
||||
/* Reading value from buffer with command output */
|
||||
while (buffer[value_offset] != '\n' &&
|
||||
buffer[value_offset] != '\r' &&
|
||||
buffer[value_offset] != '\0') {
|
||||
value[v] = buffer[value_offset];
|
||||
v++;
|
||||
value_offset++;
|
||||
}
|
||||
value[v] = '\0';
|
||||
|
||||
AIM_LOG_VERBOSE("Value for sytem attribute '%s' is '%s' \n", attr, value);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_onie_info_get(onlp_onie_info_t* onie)
|
||||
{
|
||||
|
||||
const char onie_version_file[] = "/bsp/onie-version";
|
||||
const char onie_version_command[] = "onie-shell -c 'onie-sysinfo -v' > /bsp/onie-version";
|
||||
const char onie_syseeprom_file[] = "/bsp/onie-syseeprom";
|
||||
const char onie_syseeprom_command[] = "onie-shell -c onie-syseeprom > /bsp/onie-syseeprom";
|
||||
struct stat stat_buf;
|
||||
char value[256] = {0};
|
||||
char command[256] = {0};
|
||||
int rc = 0;
|
||||
int exit_status;
|
||||
|
||||
/* We must initialize this otherwise crash occurs while free memory */
|
||||
list_init(&onie->vx_list);
|
||||
|
||||
/* Check if cache file exist */
|
||||
rc = stat(onie_syseeprom_file, &stat_buf);
|
||||
if (-1 == rc) {
|
||||
rc = system(onie_syseeprom_command);
|
||||
if (-1 == rc) {
|
||||
return rc;
|
||||
}
|
||||
exit_status = WEXITSTATUS(rc);
|
||||
if (EXIT_SUCCESS != exit_status) {
|
||||
return ONLP_STATUS_E_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
rc = _onlp_sysi_grep_output(value, "Product Name", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->product_name = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Part Number", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->part_number = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Serial Number", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->serial_number = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Base MAC Address", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
strncpy((char*)onie->mac, value, sizeof(onie->mac));
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacture Date", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacture_date = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Device Version", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->device_version = atoi(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacturer", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacturer = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacturer", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacturer = aim_strdup(value);
|
||||
onie->vendor = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "MAC Addresses", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->mac_range = atoi(value);
|
||||
/* Check if onie version first run and cache file exist */
|
||||
rc = stat(onie_version_file, &stat_buf);
|
||||
if (-1 == rc)
|
||||
{
|
||||
rc = system(onie_version_command);
|
||||
if (-1 == rc) {
|
||||
return rc;
|
||||
}
|
||||
exit_status = WEXITSTATUS(rc);
|
||||
if (EXIT_SUCCESS != exit_status) {
|
||||
return ONLP_STATUS_E_GENERIC;
|
||||
}}
|
||||
snprintf(command, sizeof(command), "cat '%s'", onie_version_file);
|
||||
_onlp_sysi_execute_command(command, value);
|
||||
/* ONIE version */
|
||||
onie->onie_version = aim_strdup(value);
|
||||
|
||||
/* Platform name */
|
||||
onie->platform_name = aim_strdup("x86_64-mlnx_msn2100-r0");
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Thermal Sensor Platform Implementation.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <AIM/aim_log.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define prefix_path "/bsp/thermal"
|
||||
|
||||
/* CPU thermal_threshold */
|
||||
typedef enum cpu_thermal_threshold_e {
|
||||
CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000,
|
||||
CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000,
|
||||
CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000,
|
||||
} cpu_thermal_threshold_t;
|
||||
|
||||
/* Shortcut for CPU thermal threshold value. */
|
||||
#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \
|
||||
{ CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \
|
||||
CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \
|
||||
CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT }
|
||||
|
||||
/* Asic thermal_threshold */
|
||||
typedef enum asic_thermal_threshold_e {
|
||||
ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000,
|
||||
ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000,
|
||||
ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000,
|
||||
} asic_thermal_threshold_t;
|
||||
|
||||
/* Shortcut for CPU thermal threshold value. */
|
||||
#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \
|
||||
{ ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \
|
||||
ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \
|
||||
ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT }
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_THERMAL(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_CPU_CORE_0,
|
||||
THERMAL_CPU_CORE_1,
|
||||
THERMAL_CPU_CORE_2,
|
||||
THERMAL_CPU_CORE_3,
|
||||
THERMAL_ASIC,
|
||||
THERMAL_BOARD_AMB,
|
||||
THERMAL_PORT
|
||||
};
|
||||
|
||||
static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
"cpu_core0",
|
||||
"cpu_core1",
|
||||
"cpu_core2",
|
||||
"cpu_core3",
|
||||
"asic",
|
||||
"board_amb",
|
||||
"port_amb"
|
||||
};
|
||||
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 2", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 3", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_ASIC), "Asic Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_BOARD_AMB), "Board AMB Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_PORT), "Port AMB Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* This will be called to intiialize the thermali subsystem.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the information structure for the given thermal OID.
|
||||
*
|
||||
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
|
||||
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
|
||||
* Otherwise, return ONLP_STATUS_OK with the OID's information.
|
||||
*
|
||||
* Note -- it is expected that you fill out the information
|
||||
* structure even if the sensor described by the OID is not present.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
{
|
||||
int rv, len = 10, temp_base=1, local_id = 0;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[50] = {0};
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[local_id];
|
||||
|
||||
/* get fullpath */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", prefix_path, last_path[local_id]);
|
||||
|
||||
rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mcelsius = atoi(r_data) / temp_base;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
/* <auto.start.cdefs(x86_64_mlnx_msn2100_CONFIG_HEADER).source> */
|
||||
#define __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(_x) #_x
|
||||
#define __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(_x) __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(_x)
|
||||
x86_64_mlnx_msn2100_config_settings_t x86_64_mlnx_msn2100_config_settings[] =
|
||||
{
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
{ __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#undef __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE
|
||||
#undef __x86_64_mlnx_msn2100_config_STRINGIFY_NAME
|
||||
|
||||
const char*
|
||||
x86_64_mlnx_msn2100_config_lookup(const char* setting)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_mlnx_msn2100_config_settings[i].name; i++) {
|
||||
if(strcmp(x86_64_mlnx_msn2100_config_settings[i].name, setting)) {
|
||||
return x86_64_mlnx_msn2100_config_settings[i].value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
x86_64_mlnx_msn2100_config_show(struct aim_pvs_s* pvs)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_mlnx_msn2100_config_settings[i].name; i++) {
|
||||
aim_printf(pvs, "%s = %s\n", x86_64_mlnx_msn2100_config_settings[i].name, x86_64_mlnx_msn2100_config_settings[i].value);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* <auto.end.cdefs(x86_64_mlnx_msn2100_CONFIG_HEADER).source> */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
/* <--auto.start.enum(ALL).source> */
|
||||
/* <auto.end.enum(ALL).source> */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_mlnx_msn2100 Internal Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2100_INT_H__
|
||||
#define __x86_64_mlnx_msn2100_INT_H__
|
||||
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2100_INT_H__ */
|
||||
@@ -0,0 +1,18 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
#include "x86_64_mlnx_msn2100_log.h"
|
||||
/*
|
||||
* x86_64_mlnx_msn2100 log struct.
|
||||
*/
|
||||
AIM_LOG_STRUCT_DEFINE(
|
||||
x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT,
|
||||
x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT,
|
||||
NULL, /* Custom log map */
|
||||
x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2100_LOG_H__
|
||||
#define __x86_64_mlnx_msn2100_LOG_H__
|
||||
|
||||
#define AIM_LOG_MODULE_NAME x86_64_mlnx_msn2100
|
||||
#include <AIM/aim_log.h>
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2100_LOG_H__ */
|
||||
@@ -0,0 +1,24 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
#include "x86_64_mlnx_msn2100_log.h"
|
||||
|
||||
static int
|
||||
datatypes_init__(void)
|
||||
{
|
||||
#define x86_64_mlnx_msn2100_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100.x>
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __x86_64_mlnx_msn2100_module_init__(void)
|
||||
{
|
||||
AIM_LOG_STRUCT_REGISTER();
|
||||
datatypes_init__();
|
||||
}
|
||||
|
||||
int __onlp_platform_version__ = 1;
|
||||
@@ -0,0 +1,50 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h>
|
||||
|
||||
#if x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI == 1
|
||||
|
||||
#include <uCli/ucli.h>
|
||||
#include <uCli/ucli_argparse.h>
|
||||
#include <uCli/ucli_handler_macros.h>
|
||||
|
||||
static ucli_status_t
|
||||
x86_64_mlnx_msn2100_ucli_ucli__config__(ucli_context_t* uc)
|
||||
{
|
||||
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_mlnx_msn2100)
|
||||
}
|
||||
|
||||
/* <auto.ucli.handlers.start> */
|
||||
/* <auto.ucli.handlers.end> */
|
||||
|
||||
static ucli_module_t
|
||||
x86_64_mlnx_msn2100_ucli_module__ =
|
||||
{
|
||||
"x86_64_mlnx_msn2100_ucli",
|
||||
NULL,
|
||||
x86_64_mlnx_msn2100_ucli_ucli_handlers__,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
ucli_node_t*
|
||||
x86_64_mlnx_msn2100_ucli_node_create(void)
|
||||
{
|
||||
ucli_node_t* n;
|
||||
ucli_module_init(&x86_64_mlnx_msn2100_ucli_module__);
|
||||
n = ucli_node_create("x86_64_mlnx_msn2100", NULL, &x86_64_mlnx_msn2100_ucli_module__);
|
||||
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_mlnx_msn2100"));
|
||||
return n;
|
||||
}
|
||||
|
||||
#else
|
||||
void*
|
||||
x86_64_mlnx_msn2100_ucli_node_create(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the x86_64_mlnx_msn2100 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:56.754200
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2100_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
include $(x86_64_mlnx_msn2100_BASEDIR)/module/make.mk
|
||||
include $(x86_64_mlnx_msn2100_BASEDIR)/module/auto/make.mk
|
||||
include $(x86_64_mlnx_msn2100_BASEDIR)/module/src/make.mk
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=mellanox PLATFORM=x86-64-mlnx-msn2100-r0
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# platform-config for Mellanox msn2100
|
||||
#
|
||||
######################################################################
|
||||
|
||||
x86-64-mlnx-msn2100-r0:
|
||||
|
||||
grub:
|
||||
|
||||
serial: >-
|
||||
--unit=0
|
||||
--speed=115200
|
||||
--word=8
|
||||
--parity=0
|
||||
--stop=1
|
||||
|
||||
kernel:
|
||||
<<: *kernel-3-16
|
||||
|
||||
args: >-
|
||||
nopat
|
||||
console=ttyS0,115200n8
|
||||
rd_NO_MD
|
||||
rd_NO_LUKS
|
||||
acpi_enforce_resources=lax
|
||||
acpi=noirq
|
||||
|
||||
##network
|
||||
## interfaces:
|
||||
## ma1:
|
||||
## name: ~
|
||||
## syspath: pci0000:00/0000:00:14.0
|
||||
@@ -0,0 +1,17 @@
|
||||
from onl.platform.base import *
|
||||
from onl.platform.mellanox import *
|
||||
|
||||
class OnlPlatform_x86_64_mlnx_msn2100_r0(OnlPlatformMellanox,
|
||||
OnlPlatformPortConfig_32x100):
|
||||
PLATFORM='x86-64-mlnx-msn2100-r0'
|
||||
MODEL="SN2100"
|
||||
SYS_OBJECT_ID=".2100.1"
|
||||
|
||||
def baseconfig(self):
|
||||
# load modules
|
||||
import os
|
||||
# necessary if there are issues with the install
|
||||
# os.system("/usr/bin/apt-get install")
|
||||
os.system("/etc/mlnx/mlnx-hw-management start")
|
||||
|
||||
return True
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mlnx-msn2410 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-mlnx-msn2410
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_mlnx_msn2410 onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-mlnx-msn2410.so
|
||||
$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
|
||||
include $(BUILDER)/so.mk
|
||||
.DEFAULT_GOAL := $(SHAREDLIB)
|
||||
|
||||
GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2410-r0 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:22.249911
|
||||
#
|
||||
###############################################################################
|
||||
libonlp-x86-64-mlnx-msn2410-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2410 module.
|
||||
#
|
||||
# Autogenerated 2016-10-13 22:58:39.095824
|
||||
#
|
||||
###############################################################################
|
||||
libonlp-x86-64-mlnx-msn2410_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the x86_64_mlnx_msn2410 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:22.262891
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2410_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
.DEFAULT_GOAL := onlpdump
|
||||
|
||||
MODULE := onlpdump
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF onlp x86_64_mlnx_msn2410 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
BINARY := onlpdump
|
||||
$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS)
|
||||
include $(BUILDER)/bin.mk
|
||||
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1
|
||||
GLOBAL_LINK_LIBS += -lpthread -lm
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the onlpdump module.
|
||||
#
|
||||
# Autogenerated 2016-10-13 22:58:37.393320
|
||||
#
|
||||
###############################################################################
|
||||
onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
name: x86_64_mlnx_msn2410
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
include ../../init.mk
|
||||
MODULE := x86_64_mlnx_msn2410
|
||||
AUTOMODULE := x86_64_mlnx_msn2410
|
||||
include $(BUILDER)/definemodule.mk
|
||||
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2410 README
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2410 Autogeneration
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2410_AUTO_DEFS := module/auto/x86_64_mlnx_msn2410.yml
|
||||
x86_64_mlnx_msn2410_AUTO_DIRS := module/inc/x86_64_mlnx_msn2410 module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_mlnx_msn2410 Autogeneration Definitions.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB
|
||||
- X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
- X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION:
|
||||
doc: "Assume chassis fan direction is the same as the PSU fan direction."
|
||||
default: 0
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
X86_64_MLNX_MSN2410_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: x86_64_mlnx_msn2410_config
|
||||
|
||||
portingmacro:
|
||||
x86_64_mlnx_msn2410:
|
||||
macros:
|
||||
- malloc
|
||||
- free
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- vsnprintf
|
||||
- snprintf
|
||||
- strlen
|
||||
@@ -0,0 +1,14 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
/* <--auto.start.xmacro(ALL).define> */
|
||||
/* <auto.end.xmacro(ALL).define> */
|
||||
|
||||
/* <--auto.start.xenum(ALL).define> */
|
||||
/* <auto.end.xenum(ALL).define> */
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_mlnx_msn2410 Configuration Header
|
||||
*
|
||||
* @addtogroup x86_64_mlnx_msn2410-config
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2410_CONFIG_H__
|
||||
#define __x86_64_mlnx_msn2410_CONFIG_H__
|
||||
|
||||
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
|
||||
#include <global_custom_config.h>
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_INCLUDE_CUSTOM_CONFIG
|
||||
#include <x86_64_mlnx_msn2410_custom_config.h>
|
||||
#endif
|
||||
|
||||
/* <auto.start.cdefs(x86_64_mlnx_msn2410_CONFIG_HEADER).header> */
|
||||
#include <AIM/aim.h>
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING
|
||||
*
|
||||
* Include or exclude logging. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING
|
||||
#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
*
|
||||
* Default enabled log options. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
#define x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT
|
||||
#define x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled custom log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
#define x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB
|
||||
*
|
||||
* Default all porting macros to use the C standard libraries. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB
|
||||
#define x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
*
|
||||
* Include standard library headers for stdlib porting macros. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
#define x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI
|
||||
*
|
||||
* Include generic uCli support. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI
|
||||
#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
*
|
||||
* Assume chassis fan direction is the same as the PSU fan direction. */
|
||||
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* All compile time options can be queried or displayed
|
||||
*/
|
||||
|
||||
/** Configuration settings structure. */
|
||||
typedef struct x86_64_mlnx_msn2410_config_settings_s {
|
||||
/** name */
|
||||
const char* name;
|
||||
/** value */
|
||||
const char* value;
|
||||
} x86_64_mlnx_msn2410_config_settings_t;
|
||||
|
||||
/** Configuration settings table. */
|
||||
/** x86_64_mlnx_msn2410_config_settings table. */
|
||||
extern x86_64_mlnx_msn2410_config_settings_t x86_64_mlnx_msn2410_config_settings[];
|
||||
|
||||
/**
|
||||
* @brief Lookup a configuration setting.
|
||||
* @param setting The name of the configuration option to lookup.
|
||||
*/
|
||||
const char* x86_64_mlnx_msn2410_config_lookup(const char* setting);
|
||||
|
||||
/**
|
||||
* @brief Show the compile-time configuration.
|
||||
* @param pvs The output stream.
|
||||
*/
|
||||
int x86_64_mlnx_msn2410_config_show(struct aim_pvs_s* pvs);
|
||||
|
||||
/* <auto.end.cdefs(x86_64_mlnx_msn2410_CONFIG_HEADER).header> */
|
||||
|
||||
#include "x86_64_mlnx_msn2410_porting.h"
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2410_CONFIG_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,26 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_mlnx_msn2410 Doxygen Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2410_DOX_H__
|
||||
#define __x86_64_mlnx_msn2410_DOX_H__
|
||||
|
||||
/**
|
||||
* @defgroup x86_64_mlnx_msn2410 x86_64_mlnx_msn2410 - x86_64_mlnx_msn2410 Description
|
||||
*
|
||||
|
||||
The documentation overview for this module should go here.
|
||||
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup x86_64_mlnx_msn2410-x86_64_mlnx_msn2410 Public Interface
|
||||
* @defgroup x86_64_mlnx_msn2410-config Compile Time Configuration
|
||||
* @defgroup x86_64_mlnx_msn2410-porting Porting Macros
|
||||
*
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2410_DOX_H__ */
|
||||
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_mlnx_msn2410 Porting Macros.
|
||||
*
|
||||
* @addtogroup x86_64_mlnx_msn2410-porting
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2410_PORTING_H__
|
||||
#define __x86_64_mlnx_msn2410_PORTING_H__
|
||||
|
||||
|
||||
/* <auto.start.portingmacro(ALL).define> */
|
||||
#if x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_MALLOC
|
||||
#if defined(GLOBAL_MALLOC)
|
||||
#define x86_64_mlnx_msn2410_MALLOC GLOBAL_MALLOC
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_MALLOC malloc
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_MALLOC is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_FREE
|
||||
#if defined(GLOBAL_FREE)
|
||||
#define x86_64_mlnx_msn2410_FREE GLOBAL_FREE
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_FREE free
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_FREE is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_MEMSET
|
||||
#if defined(GLOBAL_MEMSET)
|
||||
#define x86_64_mlnx_msn2410_MEMSET GLOBAL_MEMSET
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_MEMSET memset
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_MEMSET is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_MEMCPY
|
||||
#if defined(GLOBAL_MEMCPY)
|
||||
#define x86_64_mlnx_msn2410_MEMCPY GLOBAL_MEMCPY
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_MEMCPY memcpy
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_MEMCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_STRNCPY
|
||||
#if defined(GLOBAL_STRNCPY)
|
||||
#define x86_64_mlnx_msn2410_STRNCPY GLOBAL_STRNCPY
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_STRNCPY strncpy
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_STRNCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_VSNPRINTF
|
||||
#if defined(GLOBAL_VSNPRINTF)
|
||||
#define x86_64_mlnx_msn2410_VSNPRINTF GLOBAL_VSNPRINTF
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_VSNPRINTF vsnprintf
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_VSNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_SNPRINTF
|
||||
#if defined(GLOBAL_SNPRINTF)
|
||||
#define x86_64_mlnx_msn2410_SNPRINTF GLOBAL_SNPRINTF
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_SNPRINTF snprintf
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_SNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_mlnx_msn2410_STRLEN
|
||||
#if defined(GLOBAL_STRLEN)
|
||||
#define x86_64_mlnx_msn2410_STRLEN GLOBAL_STRLEN
|
||||
#elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_mlnx_msn2410_STRLEN strlen
|
||||
#else
|
||||
#error The macro x86_64_mlnx_msn2410_STRLEN is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* <auto.end.portingmacro(ALL).define> */
|
||||
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2410_PORTING_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,10 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
x86_64_mlnx_msn2410_INCLUDES := -I $(THIS_DIR)inc
|
||||
x86_64_mlnx_msn2410_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
x86_64_mlnx_msn2410_DEPENDMODULE_ENTRIES := init:x86_64_mlnx_msn2410 ucli:x86_64_mlnx_msn2410
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Local source generation targets.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ucli:
|
||||
@../../../../tools/uclihandlers.py x86_64_mlnx_msn2410_ucli.c
|
||||
|
||||
@@ -0,0 +1,544 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Fan Platform Implementation Defaults.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PREFIX_PATH "/bsp/fan/"
|
||||
#define PREFIX_MODULE_PATH "/bsp/module/"
|
||||
|
||||
#define FAN_STATUS_OK 1
|
||||
|
||||
#define PERCENTAGE_MIN 60.0
|
||||
#define PERCENTAGE_MAX 100.0
|
||||
#define RPM_MAGIC_MIN 153.0
|
||||
#define RPM_MAGIC_MAX 255.0
|
||||
|
||||
#define PSU_FAN_RPM_MIN 11700.0
|
||||
#define PSU_FAN_RPM_MAX 19500.0
|
||||
|
||||
#define PROJECT_NAME
|
||||
#define LEN_FILE_NAME 80
|
||||
|
||||
#define FAN_RESERVED 0
|
||||
#define FAN_1_ON_MAIN_BOARD 1
|
||||
#define FAN_2_ON_MAIN_BOARD 2
|
||||
#define FAN_3_ON_MAIN_BOARD 3
|
||||
#define FAN_4_ON_MAIN_BOARD 4
|
||||
#define FAN_5_ON_MAIN_BOARD 5
|
||||
#define FAN_6_ON_MAIN_BOARD 6
|
||||
#define FAN_7_ON_MAIN_BOARD 7
|
||||
#define FAN_8_ON_MAIN_BOARD 8
|
||||
#define FAN_1_ON_PSU1 9
|
||||
#define FAN_1_ON_PSU2 10
|
||||
|
||||
static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0};
|
||||
static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0};
|
||||
|
||||
typedef struct fan_path_S
|
||||
{
|
||||
char status[LEN_FILE_NAME];
|
||||
char r_speed_get[LEN_FILE_NAME];
|
||||
char r_speed_set[LEN_FILE_NAME];
|
||||
char min[LEN_FILE_NAME];
|
||||
char max[LEN_FILE_NAME];
|
||||
}fan_path_T;
|
||||
|
||||
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \
|
||||
{ #prj"fan"#id"_status", \
|
||||
#prj"fan"#id"_speed_get", \
|
||||
#prj"fan"#id"_speed_set", \
|
||||
#prj"fan"#id"_min", \
|
||||
#prj"fan"#id"_max" }
|
||||
|
||||
#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id)
|
||||
|
||||
#define MAKE_FAN_PATH_ON_PSU(psu_id, fan_id) \
|
||||
{"psu"#psu_id"_status", \
|
||||
"psu"#psu_id"_fan"#fan_id"_speed_get", "", "", "",}
|
||||
|
||||
static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
{
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_5_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_6_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_7_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_8_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_PSU(1 ,1),
|
||||
MAKE_FAN_PATH_ON_PSU(2, 1)
|
||||
};
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \
|
||||
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
}
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id" Fan "#fan_id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
}
|
||||
|
||||
/* Static fan information */
|
||||
onlp_fan_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(7),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8),
|
||||
MAKE_FAN_INFO_NODE_ON_PSU(1,1),
|
||||
MAKE_FAN_INFO_NODE_ON_PSU(2,1)
|
||||
};
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define OPEN_READ_FILE(fullpath, data, nbytes, len) \
|
||||
if (onlp_file_read((uint8_t*)data, nbytes, &len, fullpath) < 0) \
|
||||
return ONLP_STATUS_E_INTERNAL; \
|
||||
else \
|
||||
AIM_LOG_VERBOSE("read data: %s\n", r_data); \
|
||||
|
||||
|
||||
static int
|
||||
_onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
const char sanity_checker[] = "MLNX";
|
||||
const uint8_t sanity_offset = 8;
|
||||
const uint8_t sanity_len = 4;
|
||||
const uint8_t block1_start = 12;
|
||||
const uint8_t block1_type = 1;
|
||||
const uint8_t block2_start = 14;
|
||||
const uint8_t block2_type = 5;
|
||||
const uint8_t serial_offset = 8;
|
||||
const uint8_t serial_len = 24;
|
||||
const uint8_t part_len = 20;
|
||||
const uint8_t fan_offset = 14;
|
||||
const uint8_t multiplier = 16;
|
||||
uint8_t data[256] = {0};
|
||||
uint8_t offset = 0;
|
||||
uint8_t temp = 0;
|
||||
int rv = 0;
|
||||
int len = 0;
|
||||
char path[LEN_FILE_NAME] = {0};
|
||||
|
||||
/* We have 4 FRU with 2 fans(total 8 fans).
|
||||
Eeprom is per FRU but not per fan.
|
||||
So, need to convert fan ID to FRU ID.*/
|
||||
if (local_id % 2) {
|
||||
local_id = local_id / 2 + 1;
|
||||
} else {
|
||||
local_id /= 2;
|
||||
}
|
||||
|
||||
/* Reading FRU eeprom. */
|
||||
snprintf(path, sizeof(path), IDPROM_PATH, "fan", local_id);
|
||||
rv = onlp_file_read(data, sizeof(data), &len, path);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* Sanity checker */
|
||||
if (strncmp(sanity_checker, (char*)&data[sanity_offset], sanity_len)) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
/* Checking eeprom block type with S/N and P/N */
|
||||
if (data[block1_start + 1] != block1_type) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
/* Reading serial number */
|
||||
offset = data[block1_start] * multiplier + serial_offset;
|
||||
strncpy(info->serial, (char *)&data[offset], serial_len);
|
||||
|
||||
/* Reading part number */
|
||||
offset += serial_len;
|
||||
strncpy(info->model, (char *)&data[offset], part_len);
|
||||
|
||||
/* Reading fan direction */
|
||||
if (data[block2_start + 1] != block2_type) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
offset = data[block2_start] * multiplier + fan_offset;
|
||||
temp = data[offset];
|
||||
switch (temp) {
|
||||
case 1:
|
||||
info->caps |= ONLP_FAN_CAPS_F2B;
|
||||
break;
|
||||
case 2:
|
||||
info->caps |= ONLP_FAN_CAPS_B2F;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int len = 0, nbytes = 10;
|
||||
float range = 0;
|
||||
float temp = 0;
|
||||
float fru_index = 0;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[65] = {0};
|
||||
|
||||
/* We have 4 FRU with 2 fans(total 8 fans).
|
||||
Eeprom is per FRU but not per fan.
|
||||
So, need to convert fan ID to FRU ID.*/
|
||||
if (local_id % 2) {
|
||||
fru_index = local_id / 2 + 1;
|
||||
} else {
|
||||
fru_index = local_id / 2;
|
||||
}
|
||||
|
||||
/* get fan status
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[(int)fru_index].status);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
if (atoi(r_data) != FAN_STATUS_OK) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* check failure */
|
||||
if (info->rpm <= 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) {
|
||||
/* get fan min speed
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].min);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
min_fan_speed[local_id] = atoi(r_data);
|
||||
|
||||
/* get fan max speed
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].max);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
max_fan_speed[local_id] = atoi(r_data);
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
range = max_fan_speed[local_id] - min_fan_speed[local_id];
|
||||
if (range > 0) {
|
||||
temp = ((float)info->rpm - (float)min_fan_speed[local_id]) / range * 40.0 + 60.0;
|
||||
if (temp < PERCENTAGE_MIN) {
|
||||
temp = PERCENTAGE_MIN;
|
||||
}
|
||||
info->percentage = (int)temp;
|
||||
} else {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
return _onlp_fani_read_fan_eeprom(local_id, info);
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int len = 0, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[80] = {0};
|
||||
float rpms_per_perc = 0.0;
|
||||
float temp = 0.0;
|
||||
|
||||
/* get fan status
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
if (atoi(r_data) != FAN_STATUS_OK) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get);
|
||||
OPEN_READ_FILE(fullpath, r_data, nbytes, len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* check failure */
|
||||
if (info->rpm <= 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
rpms_per_perc = PSU_FAN_RPM_MIN / PERCENTAGE_MIN;
|
||||
temp = (float)info->rpm / rpms_per_perc;
|
||||
if (temp < PERCENTAGE_MIN) {
|
||||
temp = PERCENTAGE_MIN;
|
||||
}
|
||||
info->percentage = (int)temp;
|
||||
|
||||
/* Serial number and model for PSU fan is the same as for appropriate PSU */
|
||||
if (FAN_1_ON_PSU1 == local_id) {
|
||||
if (0 != psu_read_eeprom(PSU1_ID, NULL, info))
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
} else if (FAN_1_ON_PSU2 == local_id) {
|
||||
if (0 != psu_read_eeprom(PSU2_ID, NULL, info))
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rc = 0;
|
||||
int local_id = 0;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
*info = linfo[local_id];
|
||||
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU1_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_PSU2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU2_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
case FAN_3_ON_MAIN_BOARD:
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
case FAN_5_ON_MAIN_BOARD:
|
||||
case FAN_6_ON_MAIN_BOARD:
|
||||
case FAN_7_ON_MAIN_BOARD:
|
||||
case FAN_8_ON_MAIN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
break;
|
||||
default:
|
||||
rc = ONLP_STATUS_E_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the speed of the given fan in RPM.
|
||||
*
|
||||
* This function will only be called if the fan supprots the RPM_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_rpm_set(onlp_oid_t id, int rpm)
|
||||
{
|
||||
float temp = 0.0;
|
||||
int rv = 0, local_id = 0, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[LEN_FILE_NAME] = {0};
|
||||
onlp_fan_info_t* info = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
info = &linfo[local_id];
|
||||
|
||||
if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) {
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* reject rpm=0% (rpm=0%, stop fan) */
|
||||
if (0 == rpm) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH,
|
||||
fan_path[local_id].r_speed_set);
|
||||
|
||||
/* Set fan speed
|
||||
Converting percent to driver value.
|
||||
Driver accept value in range between 153 and 255.
|
||||
Value 153 is minimum rpm.
|
||||
Value 255 is maximum rpm.
|
||||
*/
|
||||
if (local_id > sizeof(min_fan_speed)/sizeof(min_fan_speed[0])) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
if (max_fan_speed[local_id] - min_fan_speed[local_id] < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
if (rpm < min_fan_speed[local_id] || rpm > max_fan_speed[local_id]) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
temp = (rpm - min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) /
|
||||
(max_fan_speed[local_id] - min_fan_speed[local_id]) + RPM_MAGIC_MIN;
|
||||
|
||||
snprintf(r_data, sizeof(r_data), "%d", (int)temp);
|
||||
nbytes = strnlen(r_data, sizeof(r_data));
|
||||
rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
float temp = 0.0;
|
||||
int rv = 0, local_id = 0, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[LEN_FILE_NAME] = {0};
|
||||
onlp_fan_info_t* info = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
info = &linfo[local_id];
|
||||
|
||||
if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) {
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* reject p=0% (p=0%, stop fan) */
|
||||
if (0 == p) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH,
|
||||
fan_path[local_id].r_speed_set);
|
||||
|
||||
/* Set fan speed
|
||||
Converting percent to driver value.
|
||||
Driver accept value in range between 153 and 255.
|
||||
Value 153 is 60%.
|
||||
Value 255 is 100%.
|
||||
*/
|
||||
temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) /
|
||||
(PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN;
|
||||
|
||||
snprintf(r_data, sizeof(r_data), "%d", (int)temp);
|
||||
nbytes = strnlen(r_data, sizeof(r_data));
|
||||
rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as per
|
||||
* the predefined ONLP fan speed modes: off, slow, normal, fast, max.
|
||||
*
|
||||
* Interpretation of these modes is up to the platform.
|
||||
*
|
||||
*/
|
||||
int
|
||||
onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan direction of the given OID.
|
||||
*
|
||||
* This function is only relevant if the fan OID supports both direction
|
||||
* capabilities.
|
||||
*
|
||||
* This function is optional unless the functionality is available.
|
||||
*/
|
||||
int
|
||||
onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic fan ioctl. Optional.
|
||||
*/
|
||||
int
|
||||
onlp_fani_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define prefix_path "/bsp/led/led_"
|
||||
#define driver_value_len 50
|
||||
|
||||
#define LED_MODE_OFF "none"
|
||||
#define LED_MODE_GREEN "green"
|
||||
#define LED_MODE_RED "red"
|
||||
#define LED_MODE_BLUE "blue"
|
||||
#define LED_MODE_GREEN_BLINK "green_blink"
|
||||
#define LED_MODE_RED_BLINK "red_blink"
|
||||
#define LED_MODE_BLUE_BLINK "blue_blink"
|
||||
#define LED_MODE_AUTO "cpld_control"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
enum onlp_led_id
|
||||
{
|
||||
LED_RESERVED = 0,
|
||||
LED_SYSTEM,
|
||||
LED_FAN1,
|
||||
LED_FAN2,
|
||||
LED_FAN3,
|
||||
LED_FAN4,
|
||||
LED_PSU,
|
||||
};
|
||||
|
||||
typedef struct led_light_mode_map {
|
||||
enum onlp_led_id id;
|
||||
char* driver_led_mode;
|
||||
enum onlp_led_mode_e onlp_led_mode;
|
||||
} led_light_mode_map_t;
|
||||
|
||||
led_light_mode_map_t led_map[] = {
|
||||
{LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_FAN1, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_FAN1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_FAN1, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_FAN1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_FAN1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_FAN1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_FAN2, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_FAN2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_FAN2, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_FAN2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_FAN2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_FAN2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_FAN3, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_FAN3, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_FAN3, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_FAN3, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_FAN3, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_FAN3, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_FAN4, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_FAN4, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_FAN4, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_FAN4, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_FAN4, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_FAN4, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
|
||||
{LED_PSU, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_PSU, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_PSU, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_PSU, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING},
|
||||
{LED_PSU, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
|
||||
{LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}
|
||||
};
|
||||
|
||||
static char file_names[][10] = /* must map with onlp_led_id */
|
||||
{
|
||||
"reserved",
|
||||
"status",
|
||||
"fan1",
|
||||
"fan2",
|
||||
"fan3",
|
||||
"fan4",
|
||||
"psu"
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the information for the given LED OID.
|
||||
*/
|
||||
static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_SYSTEM), "Chassis LED 1 (SYSTEM LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN1), "Chassis LED 2 (FAN1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN2), "Chassis LED 3 (FAN2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN3), "Chassis LED 4 (FAN3 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN4), "Chassis LED 5 (FAN4 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU), "Chassis LED 6 (PSU LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
|
||||
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
}
|
||||
};
|
||||
|
||||
static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id &&
|
||||
!strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len))
|
||||
{
|
||||
return led_map[i].onlp_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
|
||||
{
|
||||
return led_map[i].driver_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return LED_MODE_OFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* TODO setting UI LED to off when it will be supported on MSN2410
|
||||
*/
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int len, local_id = 0;
|
||||
uint8_t data[driver_value_len] = {0};
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* get fullpath */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[ONLP_OID_ID_GET(id)];
|
||||
|
||||
/* Get LED mode */
|
||||
if (onlp_file_read(data, sizeof(data), &len, fullpath) != 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mode = driver_to_onlp_led_mode(local_id, (char*)data);
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
|
||||
if (!on_or_off) {
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function puts the LED into the given mode. It is a more functional
|
||||
* interface for multimode LEDs.
|
||||
*
|
||||
* Only modes reported in the LED's capabilities will be attempted.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int local_id;
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]);
|
||||
|
||||
if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, fullpath) != 0)
|
||||
{
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
LIBRARY := x86_64_mlnx_msn2410
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/lib.mk
|
||||
@@ -0,0 +1,80 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <AIM/aim.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <sys/mman.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
int
|
||||
psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info)
|
||||
{
|
||||
char path[64] = {0};
|
||||
const char sanity_check[] = "MLNX";
|
||||
const uint8_t serial_len = 24;
|
||||
char data[256] = {0};
|
||||
bool sanity_found = false;
|
||||
int index = 0, rv = 0, len = 0;
|
||||
|
||||
snprintf(path, sizeof(path), IDPROM_PATH, "psu", psu_index);
|
||||
rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, path);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* Looking for sanity checker */
|
||||
while (index < sizeof(data) - sizeof(sanity_check) - 1) {
|
||||
if (!strncmp(&data[index], sanity_check, sizeof(sanity_check) - 1)) {
|
||||
sanity_found = true;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (false == sanity_found) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
/* Serial number */
|
||||
index += strlen(sanity_check);
|
||||
if (psu_info) {
|
||||
strncpy(psu_info->serial, &data[index], sizeof(psu_info->serial));
|
||||
} else if (fan_info) {
|
||||
strncpy(fan_info->serial, &data[index], sizeof(fan_info->serial));
|
||||
}
|
||||
|
||||
/* Part number */
|
||||
index += serial_len;
|
||||
if (psu_info) {
|
||||
strncpy(psu_info->model, &data[index], sizeof(psu_info->model));
|
||||
} else if (fan_info) {
|
||||
strncpy(fan_info->model, &data[index], sizeof(fan_info->model));
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#ifndef __PLATFORM_LIB_H__
|
||||
#define __PLATFORM_LIB_H__
|
||||
|
||||
#include <onlp/fan.h>
|
||||
#include <onlp/psu.h>
|
||||
#include "x86_64_mlnx_msn2410_log.h"
|
||||
|
||||
#define CHASSIS_PSU_COUNT 2
|
||||
#define CHASSIS_TOTAL_FAN_COUNT 10
|
||||
#define CHASSIS_TOTAL_THERMAL_COUNT 8
|
||||
#define CHASSIS_FAN_COUNT (CHASSIS_TOTAL_FAN_COUNT - CHASSIS_PSU_COUNT)
|
||||
#define CHASSIS_THERMAL_COUNT (CHASSIS_TOTAL_THERMAL_COUNT - CHASSIS_PSU_COUNT)
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s"
|
||||
#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s"
|
||||
#define IDPROM_PATH "/bsp/eeprom/%s%d_info"
|
||||
|
||||
typedef enum psu_type {
|
||||
PSU_TYPE_UNKNOWN,
|
||||
PSU_TYPE_AC_F2B,
|
||||
PSU_TYPE_AC_B2F
|
||||
} psu_type_t;
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
|
||||
int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info,
|
||||
onlp_fan_info_t* fan_info);
|
||||
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
@@ -0,0 +1,202 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_STATUS_PRESENT 1
|
||||
#define PSU_CABLE_PRESENT 1
|
||||
|
||||
#define PSU_NODE_MAX_INT_LEN 8
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
psu_module_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int len, ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
sprintf(node_path, PSU_MODULE_PREFIX, id, node);
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path);
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_power_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int len, ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
sprintf(node_path, PSU_POWER_PREFIX, id, node);
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path);
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
_psu_info_get(onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int index = ONLP_OID_ID_GET(info->hdr.id);
|
||||
|
||||
/* Set capability
|
||||
*/
|
||||
info->caps = ONLP_PSU_CAPS_AC;
|
||||
|
||||
if (info->status & ONLP_PSU_STATUS_FAILED) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Set the associated oid_table */
|
||||
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
|
||||
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);
|
||||
|
||||
/* Read voltage, current and power */
|
||||
if (psu_power_info_get(index, "volt_in", &val) == 0 &&
|
||||
0 != val) {
|
||||
info->mvin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VIN;
|
||||
|
||||
if (psu_power_info_get(index, "volt", &val) == 0) {
|
||||
info->mvout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VOUT;
|
||||
}
|
||||
|
||||
if (psu_power_info_get(index, "curr_in", &val) == 0) {
|
||||
info->miin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IIN;
|
||||
}
|
||||
|
||||
if (psu_power_info_get(index, "curr", &val) == 0) {
|
||||
info->miout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IOUT;
|
||||
}
|
||||
|
||||
if (psu_power_info_get(index, "power_in", &val) == 0) {
|
||||
info->mpin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_PIN;
|
||||
}
|
||||
|
||||
if (psu_power_info_get(index, "power", &val) == 0) {
|
||||
info->mpout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_POUT;
|
||||
}
|
||||
} else {
|
||||
info->status |= ONLP_PSU_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
return psu_read_eeprom(index, info, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get all information about the given PSU oid.
|
||||
*/
|
||||
static onlp_psu_info_t pinfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 },
|
||||
},
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
memset(info, 0, sizeof(onlp_psu_info_t));
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Get the present state */
|
||||
if (psu_module_info_get(index, "status", &val) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
info->status &= ~ONLP_PSU_STATUS_PRESENT;
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Get the cable preset state */
|
||||
if (psu_module_info_get(index, "pwr_status", &val) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_CABLE_PRESENT) {
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
ret = _psu_info_get(info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/sfpi.h>
|
||||
|
||||
#include <fcntl.h> /* For O_RDWR && open */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlplib/sfp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
#define SFP_SYSFS_VALUE_LEN 20
|
||||
static char sfp_node_path[MAX_SFP_PATH] = {0};
|
||||
#define NUM_OF_SFP_PORT 56
|
||||
#define SFP_PRESENT_STATUS "good"
|
||||
#define SFP_NOT_PRESENT_STATUS "not_connected"
|
||||
|
||||
static int
|
||||
msn2410_sfp_node_read_int(char *node_path, int *value)
|
||||
{
|
||||
int data_len = 0, ret = 0;
|
||||
char buf[SFP_SYSFS_VALUE_LEN] = {0};
|
||||
*value = -1;
|
||||
|
||||
ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path);
|
||||
|
||||
if (ret == 0) {
|
||||
if (!strncmp(buf, SFP_PRESENT_STATUS, strlen(SFP_PRESENT_STATUS))) {
|
||||
*value = 1;
|
||||
} else if (!strncmp(buf, SFP_NOT_PRESENT_STATUS, strlen(SFP_NOT_PRESENT_STATUS))) {
|
||||
*value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char*
|
||||
msn2410_sfp_get_port_path(int port, char *node_name)
|
||||
{
|
||||
sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name);
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
*
|
||||
***********************************************************/
|
||||
int
|
||||
onlp_sfpi_init(void)
|
||||
{
|
||||
/* Called at initialization time */
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
|
||||
{
|
||||
/*
|
||||
* Ports {1, 32}
|
||||
*/
|
||||
int p = 1;
|
||||
AIM_BITMAP_CLR_ALL(bmap);
|
||||
|
||||
for (; p <= NUM_OF_SFP_PORT; p++) {
|
||||
AIM_BITMAP_SET(bmap, p);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_is_present(int port)
|
||||
{
|
||||
/*
|
||||
* Return 1 if present.
|
||||
* Return 0 if not present.
|
||||
* Return < 0 if error.
|
||||
*/
|
||||
int present = -1;
|
||||
char* path = msn2410_sfp_get_port_path(port, "_status");
|
||||
|
||||
if (msn2410_sfp_node_read_int(path, &present) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return present;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
int ii = 1;
|
||||
int rc = 0;
|
||||
|
||||
for (;ii <= NUM_OF_SFP_PORT; ii++) {
|
||||
rc = onlp_sfpi_is_present(ii);
|
||||
AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = msn2410_sfp_get_port_path(port, "");
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
*
|
||||
* Return MISSING if SFP is missing.
|
||||
* Return OK if eeprom is read
|
||||
*/
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (onlplib_sfp_eeprom_read_file(path, data) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlp/platformi/sysi.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
#include "x86_64_mlnx_msn2410_int.h"
|
||||
#include "x86_64_mlnx_msn2410_log.h"
|
||||
|
||||
#define NUM_OF_THERMAL_ON_MAIN_BROAD CHASSIS_THERMAL_COUNT
|
||||
#define NUM_OF_FAN_ON_MAIN_BROAD CHASSIS_FAN_COUNT
|
||||
#define NUM_OF_PSU_ON_MAIN_BROAD 2
|
||||
#define NUM_OF_LED_ON_MAIN_BROAD 6
|
||||
|
||||
#define COMMAND_OUTPUT_BUFFER 256
|
||||
|
||||
#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld"
|
||||
#define NUM_OF_CPLD 3
|
||||
static char arr_cplddev_name[NUM_OF_CPLD][30] =
|
||||
{
|
||||
"cpld_brd_version",
|
||||
"cpld_mgmt_version",
|
||||
"cpld_port_version"
|
||||
};
|
||||
|
||||
static void
|
||||
_onlp_sysi_execute_command(char *command, char buffer[COMMAND_OUTPUT_BUFFER])
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
/* Open the command for reading. */
|
||||
fp = popen(command, "r");
|
||||
if (NULL == fp) {
|
||||
AIM_LOG_WARN("Failed to run command '%s'\n", command);
|
||||
}
|
||||
|
||||
/* Read the output */
|
||||
if (fgets(buffer, COMMAND_OUTPUT_BUFFER-1, fp) == NULL) {
|
||||
AIM_LOG_WARN("Failed to read output of command '%s'\n", command);
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
/* The last symbol is '\n', so remote it */
|
||||
buffer[strnlen(buffer, COMMAND_OUTPUT_BUFFER) - 1] = '\0';
|
||||
|
||||
/* close */
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
return "x86-64-mlnx-msn2410-r0";
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD]={0};
|
||||
|
||||
for (i=0; i < NUM_OF_CPLD; i++) {
|
||||
v[i] = 0;
|
||||
if(onlp_file_read_int(v+i, "%s/%s", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d, port=%d", v[0], v[1], v[2]);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_sysi_oids_get(onlp_oid_t* table, int max)
|
||||
{
|
||||
int i;
|
||||
onlp_oid_t* e = table;
|
||||
memset(table, 0, max*sizeof(onlp_oid_t));
|
||||
|
||||
/* 8 Thermal sensors on the chassis */
|
||||
for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++)
|
||||
{
|
||||
*e++ = ONLP_THERMAL_ID_CREATE(i);
|
||||
}
|
||||
|
||||
/* 6 LEDs on the chassis */
|
||||
for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++)
|
||||
{
|
||||
*e++ = ONLP_LED_ID_CREATE(i);
|
||||
}
|
||||
|
||||
/* 2 PSUs on the chassis */
|
||||
for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++)
|
||||
{
|
||||
*e++ = ONLP_PSU_ID_CREATE(i);
|
||||
}
|
||||
|
||||
/* 8 Fans and 2 PSU fans on the chassis */
|
||||
for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++)
|
||||
{
|
||||
*e++ = ONLP_FAN_ID_CREATE(i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_sysi_grep_output(char value[256], const char *attr, const char *tmp_file)
|
||||
{
|
||||
int value_offset = 30; /* value offset in onie-syseeprom */
|
||||
char command[256] = {0};
|
||||
char buffer[COMMAND_OUTPUT_BUFFER] = {0};
|
||||
int v = 0;
|
||||
|
||||
snprintf(command, sizeof(command), "cat '%s' | grep '%s'", tmp_file, attr);
|
||||
_onlp_sysi_execute_command(command, buffer);
|
||||
|
||||
/* Reading value from buffer with command output */
|
||||
while (buffer[value_offset] != '\n' &&
|
||||
buffer[value_offset] != '\r' &&
|
||||
buffer[value_offset] != '\0') {
|
||||
value[v] = buffer[value_offset];
|
||||
v++;
|
||||
value_offset++;
|
||||
}
|
||||
value[v] = '\0';
|
||||
|
||||
AIM_LOG_VERBOSE("Value for sytem attribute '%s' is '%s' \n", attr, value);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_onie_info_get(onlp_onie_info_t* onie)
|
||||
{
|
||||
|
||||
const char onie_version_file[] = "/bsp/onie-version";
|
||||
const char onie_version_command[] = "onie-shell -c 'onie-sysinfo -v' > /bsp/onie-version";
|
||||
const char onie_syseeprom_file[] = "/bsp/onie-syseeprom";
|
||||
const char onie_syseeprom_command[] = "onie-shell -c onie-syseeprom > /bsp/onie-syseeprom";
|
||||
struct stat stat_buf;
|
||||
char value[256] = {0};
|
||||
char command[256] = {0};
|
||||
int rc = 0;
|
||||
int exit_status;
|
||||
|
||||
/* We must initialize this otherwise crash occurs while free memory */
|
||||
list_init(&onie->vx_list);
|
||||
|
||||
/* Check if cache file exist */
|
||||
rc = stat(onie_syseeprom_file, &stat_buf);
|
||||
if (-1 == rc) {
|
||||
rc = system(onie_syseeprom_command);
|
||||
if (-1 == rc) {
|
||||
return rc;
|
||||
}
|
||||
exit_status = WEXITSTATUS(rc);
|
||||
if (EXIT_SUCCESS != exit_status) {
|
||||
return ONLP_STATUS_E_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
rc = _onlp_sysi_grep_output(value, "Product Name", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->product_name = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Part Number", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->part_number = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Serial Number", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->serial_number = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Base MAC Address", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
strncpy((char*)onie->mac, value, sizeof(onie->mac));
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacture Date", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacture_date = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Device Version", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->device_version = atoi(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacturer", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacturer = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "Manufacturer", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->manufacturer = aim_strdup(value);
|
||||
onie->vendor = aim_strdup(value);
|
||||
rc = _onlp_sysi_grep_output(value, "MAC Addresses", onie_syseeprom_file);
|
||||
if (ONLP_STATUS_OK != rc) {
|
||||
return rc;
|
||||
}
|
||||
onie->mac_range = atoi(value);
|
||||
/* Check if onie version first run and cache file exist */
|
||||
rc = stat(onie_version_file, &stat_buf);
|
||||
if (-1 == rc)
|
||||
{
|
||||
rc = system(onie_version_command);
|
||||
if (-1 == rc) {
|
||||
return rc;
|
||||
}
|
||||
exit_status = WEXITSTATUS(rc);
|
||||
if (EXIT_SUCCESS != exit_status) {
|
||||
return ONLP_STATUS_E_GENERIC;
|
||||
}}
|
||||
snprintf(command, sizeof(command), "cat '%s'", onie_version_file);
|
||||
_onlp_sysi_execute_command(command, value);
|
||||
/* ONIE version */
|
||||
onie->onie_version = aim_strdup(value);
|
||||
|
||||
/* Platform name */
|
||||
onie->platform_name = aim_strdup("x86_64-mlnx_msn2410-r0");
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Thermal Sensor Platform Implementation.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <AIM/aim_log.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define prefix_path "/bsp/thermal"
|
||||
|
||||
/** CPU thermal_threshold */
|
||||
typedef enum cpu_thermal_threshold_e {
|
||||
CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000,
|
||||
CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000,
|
||||
CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000,
|
||||
} cpu_thermal_threshold_t;
|
||||
|
||||
/**
|
||||
* Shortcut for CPU thermal threshold value.
|
||||
*/
|
||||
#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \
|
||||
{ CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \
|
||||
CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \
|
||||
CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT }
|
||||
|
||||
/** Asic thermal_threshold */
|
||||
typedef enum asic_thermal_threshold_e {
|
||||
ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000,
|
||||
ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000,
|
||||
ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000,
|
||||
} asic_thermal_threshold_t;
|
||||
|
||||
/**
|
||||
* Shortcut for CPU thermal threshold value.
|
||||
*/
|
||||
#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \
|
||||
{ ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \
|
||||
ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \
|
||||
ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT }
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_THERMAL(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_CPU_CORE_0,
|
||||
THERMAL_CPU_CORE_1,
|
||||
THERMAL_CPU_PACK,
|
||||
THERMAL_ASIC,
|
||||
THERMAL_BOAR_AMB,
|
||||
THERMAL_PORT,
|
||||
THERMAL_ON_PSU1,
|
||||
THERMAL_ON_PSU2,
|
||||
};
|
||||
|
||||
static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
"cpu_core0",
|
||||
"cpu_core1",
|
||||
"cpu_pack",
|
||||
"asic",
|
||||
"board_amb",
|
||||
"port_amb",
|
||||
"psu1",
|
||||
"psu2"
|
||||
};
|
||||
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_PACK), "CPU Pack", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_ASIC), "Asic Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_BOAR_AMB), "Board AMB Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_PORT), "Port AMB Thermal Sensor", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* This will be called to intiialize the thermali subsystem.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the information structure for the given thermal OID.
|
||||
*
|
||||
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
|
||||
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
|
||||
* Otherwise, return ONLP_STATUS_OK with the OID's information.
|
||||
*
|
||||
* Note -- it is expected that you fill out the information
|
||||
* structure even if the sensor described by the OID is not present.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
{
|
||||
int rv, len = 10, temp_base=1, local_id = 0;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[50] = {0};
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[local_id];
|
||||
|
||||
/* get fullpath */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", prefix_path, last_path[local_id]);
|
||||
|
||||
rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, fullpath);
|
||||
if (rv < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mcelsius = atoi(r_data) / temp_base;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
/* <auto.start.cdefs(x86_64_mlnx_msn2410_CONFIG_HEADER).source> */
|
||||
#define __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(_x) #_x
|
||||
#define __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(_x) __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(_x)
|
||||
x86_64_mlnx_msn2410_config_settings_t x86_64_mlnx_msn2410_config_settings[] =
|
||||
{
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
{ __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) },
|
||||
#else
|
||||
{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#undef __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE
|
||||
#undef __x86_64_mlnx_msn2410_config_STRINGIFY_NAME
|
||||
|
||||
const char*
|
||||
x86_64_mlnx_msn2410_config_lookup(const char* setting)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_mlnx_msn2410_config_settings[i].name; i++) {
|
||||
if(strcmp(x86_64_mlnx_msn2410_config_settings[i].name, setting)) {
|
||||
return x86_64_mlnx_msn2410_config_settings[i].value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
x86_64_mlnx_msn2410_config_show(struct aim_pvs_s* pvs)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_mlnx_msn2410_config_settings[i].name; i++) {
|
||||
aim_printf(pvs, "%s = %s\n", x86_64_mlnx_msn2410_config_settings[i].name, x86_64_mlnx_msn2410_config_settings[i].value);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* <auto.end.cdefs(x86_64_mlnx_msn2410_CONFIG_HEADER).source> */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
/* <--auto.start.enum(ALL).source> */
|
||||
/* <auto.end.enum(ALL).source> */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_mlnx_msn2410 Internal Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2410_INT_H__
|
||||
#define __x86_64_mlnx_msn2410_INT_H__
|
||||
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2410_INT_H__ */
|
||||
@@ -0,0 +1,18 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
#include "x86_64_mlnx_msn2410_log.h"
|
||||
/*
|
||||
* x86_64_mlnx_msn2410 log struct.
|
||||
*/
|
||||
AIM_LOG_STRUCT_DEFINE(
|
||||
x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT,
|
||||
x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT,
|
||||
NULL, /* Custom log map */
|
||||
x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_mlnx_msn2410_LOG_H__
|
||||
#define __x86_64_mlnx_msn2410_LOG_H__
|
||||
|
||||
#define AIM_LOG_MODULE_NAME x86_64_mlnx_msn2410
|
||||
#include <AIM/aim_log.h>
|
||||
|
||||
#endif /* __x86_64_mlnx_msn2410_LOG_H__ */
|
||||
@@ -0,0 +1,24 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
#include "x86_64_mlnx_msn2410_log.h"
|
||||
|
||||
static int
|
||||
datatypes_init__(void)
|
||||
{
|
||||
#define x86_64_mlnx_msn2410_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410.x>
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __x86_64_mlnx_msn2410_module_init__(void)
|
||||
{
|
||||
AIM_LOG_STRUCT_REGISTER();
|
||||
datatypes_init__();
|
||||
}
|
||||
|
||||
int __onlp_platform_version__ = 1;
|
||||
@@ -0,0 +1,50 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h>
|
||||
|
||||
#if x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI == 1
|
||||
|
||||
#include <uCli/ucli.h>
|
||||
#include <uCli/ucli_argparse.h>
|
||||
#include <uCli/ucli_handler_macros.h>
|
||||
|
||||
static ucli_status_t
|
||||
x86_64_mlnx_msn2410_ucli_ucli__config__(ucli_context_t* uc)
|
||||
{
|
||||
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_mlnx_msn2410)
|
||||
}
|
||||
|
||||
/* <auto.ucli.handlers.start> */
|
||||
/* <auto.ucli.handlers.end> */
|
||||
|
||||
static ucli_module_t
|
||||
x86_64_mlnx_msn2410_ucli_module__ =
|
||||
{
|
||||
"x86_64_mlnx_msn2410_ucli",
|
||||
NULL,
|
||||
x86_64_mlnx_msn2410_ucli_ucli_handlers__,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
ucli_node_t*
|
||||
x86_64_mlnx_msn2410_ucli_node_create(void)
|
||||
{
|
||||
ucli_node_t* n;
|
||||
ucli_module_init(&x86_64_mlnx_msn2410_ucli_module__);
|
||||
n = ucli_node_create("x86_64_mlnx_msn2410", NULL, &x86_64_mlnx_msn2410_ucli_module__);
|
||||
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_mlnx_msn2410"));
|
||||
return n;
|
||||
}
|
||||
|
||||
#else
|
||||
void*
|
||||
x86_64_mlnx_msn2410_ucli_node_create(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the x86_64_mlnx_msn2410 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:56.754200
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_mlnx_msn2410_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
include $(x86_64_mlnx_msn2410_BASEDIR)/module/make.mk
|
||||
include $(x86_64_mlnx_msn2410_BASEDIR)/module/auto/make.mk
|
||||
include $(x86_64_mlnx_msn2410_BASEDIR)/module/src/make.mk
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=mellanox PLATFORM=x86-64-mlnx-msn2410-r0
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# platform-config for Mellanox 2410
|
||||
#
|
||||
######################################################################
|
||||
|
||||
x86-64-mlnx-msn2410-r0:
|
||||
|
||||
grub:
|
||||
|
||||
serial: >-
|
||||
--unit=0
|
||||
--speed=115200
|
||||
--word=8
|
||||
--parity=0
|
||||
--stop=1
|
||||
|
||||
kernel:
|
||||
<<: *kernel-3-16
|
||||
|
||||
args: >-
|
||||
nopat
|
||||
console=ttyS0,115200n8
|
||||
rd_NO_MD
|
||||
rd_NO_LUKS
|
||||
acpi_enforce_resources=lax
|
||||
acpi=noirq
|
||||
|
||||
##network
|
||||
## interfaces:
|
||||
## ma1:
|
||||
## name: ~
|
||||
## syspath: pci0000:00/0000:00:14.0
|
||||
@@ -0,0 +1,17 @@
|
||||
from onl.platform.base import *
|
||||
from onl.platform.mellanox import *
|
||||
|
||||
class OnlPlatform_x86_64_mlnx_msn2410_r0(OnlPlatformMellanox,
|
||||
OnlPlatformPortConfig_32x100):
|
||||
PLATFORM='x86-64-mlnx-msn2410-r0'
|
||||
MODEL="SN2410"
|
||||
SYS_OBJECT_ID=".2410.1"
|
||||
|
||||
def baseconfig(self):
|
||||
# load modules
|
||||
import os
|
||||
# necessary if there are issues with the install
|
||||
# os.system("/usr/bin/apt-get install")
|
||||
os.system("/etc/mlnx/mlnx-hw-management start")
|
||||
|
||||
return True
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mlnx-msn2700 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-mlnx-msn2700
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_mlnx_msn2700 onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-mlnx-msn2700.so
|
||||
$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
|
||||
include $(BUILDER)/so.mk
|
||||
.DEFAULT_GOAL := $(SHAREDLIB)
|
||||
|
||||
GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2700-r0 module.
|
||||
#
|
||||
# Autogenerated 2015-12-23 23:45:22.249911
|
||||
#
|
||||
###############################################################################
|
||||
libonlp-x86-64-mlnx-msn2700-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user