Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openstack/nfv: find PCI address using sriovnetworknodestates #43986

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -Eeuo pipefail

export OS_CLIENT_CONFIG_FILE="${SHARED_DIR}/clouds.yaml"

function wait_for_network() {
# Wait up to 2 minutes for the network to be ready
for _ in $(seq 1 12); do
Expand Down Expand Up @@ -75,6 +77,9 @@ then
source "${SHARED_DIR}/proxy-conf.sh"
fi

OPENSTACK_DPDK_NETWORK_ID=$(openstack network show "${OPENSTACK_DPDK_NETWORK}" -f value -c id)
DPDK_PCI_DEVICE=$(oc get sriovnetworknodestates -n openshift-sriov-network-operator -o jsonpath='{.items[0].status.interfaces[?(@.netFilter=="'"openstack/NetworkID:${OPENSTACK_DPDK_NETWORK_ID}"'")].pciAddress}')

CNF_NAMESPACE=$(
oc create -f - -o jsonpath='{.metadata.name}' <<EOF
apiVersion: v1
Expand Down Expand Up @@ -104,7 +109,7 @@ spec:
additionalNetworks:
- name: ${OPENSTACK_DPDK_NETWORK}
namespace: ${CNF_NAMESPACE}
rawCNIConfig: '{ "cniVersion": "0.3.1", "name": "${OPENSTACK_DPDK_NETWORK}", "type": "host-device","pciBusId": "0000:00:04.0", "ipam": {}}'
rawCNIConfig: '{ "cniVersion": "0.3.1", "name": "${OPENSTACK_DPDK_NETWORK}", "type": "host-device","pciBusId": "${DPDK_PCI_DEVICE}", "ipam": {}}'
type: Raw
EOF
oc patch network.operator cluster --patch "$(cat "${SHARED_DIR}/additionalnetwork-dpdk.yaml")" --type=merge
Expand Down Expand Up @@ -168,7 +173,7 @@ else
exit 1
fi

TESTPMD_OUTPUT=$(oc -n "${CNF_NAMESPACE}" rsh "${CNF_POD}" bash -c "yes | testpmd -l 2-3 --in-memory --allow 00:04.0 --socket-mem 1024 -n 4 --proc-type auto --file-prefix pg -- --disable-rss --nb-cores=1 --rxq=1 --txq=1 --auto-start --forward-mode=mac")
TESTPMD_OUTPUT=$(oc -n "${CNF_NAMESPACE}" rsh "${CNF_POD}" bash -c "yes | testpmd -l 2-3 --in-memory --allow ${DPDK_PCI_DEVICE} --socket-mem 1024 -n 4 --proc-type auto --file-prefix pg -- --disable-rss --nb-cores=1 --rxq=1 --txq=1 --auto-start --forward-mode=mac")
EmilienM marked this conversation as resolved.
Show resolved Hide resolved
echo "${TESTPMD_OUTPUT}"
if [[ "${TESTPMD_OUTPUT}" == *"forwards packets on 1 streams"* ]]; then
echo "Testpmd could run successfully"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -Eeuo pipefail

export OS_CLIENT_CONFIG_FILE="${SHARED_DIR}/clouds.yaml"

function wait_for_network() {
# Wait up to 2 minutes for the network to be ready
for _ in $(seq 1 12); do
Expand Down Expand Up @@ -57,7 +59,6 @@ function check_pod_status() {
}

CNF_NAMESPACE="example-cnf-sriov"
PCI_DEVICE="06"

# For disconnected or otherwise unreachable environments, we want to
# have steps use an HTTP(S) proxy to reach the API server. This proxy
Expand All @@ -70,6 +71,9 @@ then
source "${SHARED_DIR}/proxy-conf.sh"
fi

OPENSTACK_SRIOV_NETWORK_ID=$(openstack network show "${OPENSTACK_SRIOV_NETWORK}" -f value -c id)
SRIOV_PCI_DEVICE=$(oc get sriovnetworknodestates -n openshift-sriov-network-operator -o jsonpath='{.items[0].status.interfaces[?(@.netFilter=="'"openstack/NetworkID:${OPENSTACK_SRIOV_NETWORK_ID}"'")].pciAddress}')

CNF_NAMESPACE=$(
oc create -f - -o jsonpath='{.metadata.name}' <<EOF
apiVersion: v1
Expand All @@ -87,15 +91,12 @@ echo "Created \"$CNF_NAMESPACE\" Namespace"

# Mellanox use Bifurcation driver so we need the host-device CNI to move the NIC into the namespace
if [[ "${OPENSTACK_SRIOV_NETWORK}" == *"mellanox"* ]]; then
if [[ "${OPENSTACK_SRIOV_NETWORK}" == *"hwoffload"* ]]; then
PCI_DEVICE="05"
fi
cat <<EOF > "${SHARED_DIR}/additionalnetwork-sriov.yaml"
spec:
additionalNetworks:
- name: ${OPENSTACK_SRIOV_NETWORK}
namespace: ${CNF_NAMESPACE}
rawCNIConfig: '{ "cniVersion": "0.3.1", "name": "${OPENSTACK_SRIOV_NETWORK}", "type": "host-device","pciBusId": "0000:00:${PCI_DEVICE}.0", "ipam": {}}'
rawCNIConfig: '{ "cniVersion": "0.3.1", "name": "${OPENSTACK_SRIOV_NETWORK}", "type": "host-device","pciBusId": "${SRIOV_PCI_DEVICE}", "ipam": {}}'
type: Raw
EOF
oc patch network.operator cluster --patch "$(cat "${SHARED_DIR}/additionalnetwork-sriov.yaml")" --type=merge
Expand Down Expand Up @@ -161,7 +162,7 @@ else
exit 1
fi

TESTPMD_OUTPUT=$(oc -n "${CNF_NAMESPACE}" rsh "${CNF_POD}" bash -c "yes | testpmd -l 2-3 --in-memory --allow 00:${PCI_DEVICE}.0 --socket-mem 1024 -n 4 --proc-type auto --file-prefix pg -- --disable-rss --nb-cores=1 --rxq=1 --txq=1 --auto-start --forward-mode=mac")
TESTPMD_OUTPUT=$(oc -n "${CNF_NAMESPACE}" rsh "${CNF_POD}" bash -c "yes | testpmd -l 2-3 --in-memory --allow ${SRIOV_PCI_DEVICE} --socket-mem 1024 -n 4 --proc-type auto --file-prefix pg -- --disable-rss --nb-cores=1 --rxq=1 --txq=1 --auto-start --forward-mode=mac")
echo "${TESTPMD_OUTPUT}"
if [[ "${TESTPMD_OUTPUT}" == *"forwards packets on 1 streams"* ]]; then
echo "Testpmd could run successfully"
Expand Down