meta-google: phosphor-ipmi-config: Refactor NIC mapping logic
We want to be able to enable any slot for potentially multiple NICs.
Follow on changes will reuse this logic.
We can now enable arbitrary ethernet channels by calling
and the relevant ipmi json mappings will be established. The resulting
file looks something like
```
{
"0": {
"name": "IPMB",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "ipmb",
"protocol_type": "ipmb-1.0",
"session_supported": "session-less",
"is_ipmi": true
}
},
"1": {
"name": "ncsi",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "lan-802.3",
"protocol_type": "ipmb-1.0",
"session_supported": "multi-session",
"is_ipmi": true
}
},
"2": {
"name": "front",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "lan-802.3",
"protocol_type": "ipmb-1.0",
"session_supported": "multi-session",
"is_ipmi": true
}
},
"3": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"4": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"5": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"6": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"7": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"8": {
"name": "INTRABMC",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "oem",
"protocol_type": "oem",
"session_supported": "session-less",
"is_ipmi": true
}
},
"9": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"10": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"11": {
"name": "gbmcbr",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "lan-802.3",
"protocol_type": "ipmb-1.0",
"session_supported": "multi-session",
"is_ipmi": true
}
},
"12": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"13": {
"name": "RESERVED",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "reserved",
"protocol_type": "na",
"session_supported": "session-less",
"is_ipmi": true
}
},
"14": {
"name": "SELF",
"is_valid": false,
"active_sessions": 0,
"channel_info": {
"medium_type": "ipmb",
"protocol_type": "ipmb-1.0",
"session_supported": "session-less",
"is_ipmi": true
}
},
"15": {
"name": "ipmi_kcs3",
"is_valid": true,
"active_sessions": 0,
"channel_info": {
"medium_type": "system-interface",
"protocol_type": "kcs",
"session_supported": "session-less",
"is_ipmi": true
}
}
}
```
Change-Id: I361edd658491ea85b79b60d3107fab6dd5e192e2
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
index 5c27e02..0250bda 100644
--- a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
+++ b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
@@ -1,8 +1,8 @@
FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:"
SRC_URI:append:gbmc = " \
- file://gbmc_bridge_config.json \
- file://gbmc_bridge_access.json \
+ file://gbmc_eth_config.json \
+ file://gbmc_eth_access.json \
"
DEPENDS:append:gbmc = " jq-native"
@@ -11,29 +11,37 @@
ENTITY_MAPPING ?= "default"
+gbmc_add_channel() {
+ local chan="$1"
+ local intf="$2"
+
+ jq --slurpfile ecfg ${WORKDIR}/gbmc_eth_config.json --arg CHAN "$chan" --arg INTF "$intf" \
+ '. + {$CHAN: ($ecfg[0] + {"name": $INTF})}' $config_json >${WORKDIR}/tmp-config.json
+ mv ${WORKDIR}/tmp-config.json $config_json
+
+ jq --slurpfile ecfg ${WORKDIR}/gbmc_eth_access.json --arg CHAN "$chan" \
+ '. + {$CHAN: $ecfg[0]}' $access_json >${WORKDIR}/tmp-access.json
+ mv ${WORKDIR}/tmp-access.json $access_json
+}
+
# Replace a channel in config.json to add gbmcbr reporting
do_install:append:gbmc() {
config_json=${D}${datadir}/ipmi-providers/channel_config.json
+ access_json=${D}${datadir}/ipmi-providers/channel_access.json
+
overlapping="$(jq '."${GBMCBR_IPMI_CHANNEL}" | .is_valid and .name != "gbmcbr"' $config_json)"
if [ "$overlapping" != "false" ]; then
echo "gBMC channel config overlaps on ${GBMCBR_IPMI_CHANNEL}" >&2
cat $config_json
exit 1
fi
- jq --slurpfile brcfg ${WORKDIR}/gbmc_bridge_config.json \
- '. + {"${GBMCBR_IPMI_CHANNEL}": $brcfg[0]}' $config_json >${WORKDIR}/tmp
- mv ${WORKDIR}/tmp $config_json
-
- access_json=${D}${datadir}/ipmi-providers/channel_access.json
overlapping="$(jq '."${GBMCBR_IPMI_CHANNEL}" | .access_mode and .access_mode != "always_available"' $access_json)"
if [ "$overlapping" != "false" ]; then
echo "gBMC channel access overlaps on ${GBMCBR_IPMI_CHANNEL}" >&2
cat $access_json
exit 1
fi
- jq --slurpfile brcfg ${WORKDIR}/gbmc_bridge_access.json \
- '. + {"${GBMCBR_IPMI_CHANNEL}": $brcfg[0]}' $access_json >${WORKDIR}/tmp
- mv ${WORKDIR}/tmp $access_json
+ gbmc_add_channel ${GBMCBR_IPMI_CHANNEL} gbmcbr
# Set entity-map.json to empty json for gBMC by default.
# Each system will override it if needed.
diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_bridge_access.json b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_eth_access.json
similarity index 100%
rename from meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_bridge_access.json
rename to meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_eth_access.json
diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_bridge_config.json b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_eth_config.json
similarity index 90%
rename from meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_bridge_config.json
rename to meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_eth_config.json
index f877283..8eb844b 100644
--- a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_bridge_config.json
+++ b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config/gbmc_eth_config.json
@@ -1,5 +1,5 @@
{
- "name" : "gbmcbr",
+ "name" : "invalid",
"is_valid" : true,
"active_sessions" : 0,
"channel_info" : {