Defining an SR-IOV network

You can create a network attachment for a Single Root I/O Virtualization (SR-IOV) device for virtual machines.

After the network is defined, you can attach virtual machines to the SR-IOV network.

Prerequisites

Configuring SR-IOV additional network

You can configure an additional network that uses SR-IOV hardware by creating a SriovNetwork object. When you create a SriovNetwork object, the SR-IOV Operator automatically creates a NetworkAttachmentDefinition object.

Users can then attach virtual machines to the SR-IOV network by specifying the network in the virtual machine configurations.

Do not modify or delete a SriovNetwork object if it is attached to any pods or virtual machines in the running state.

Prerequisites

  • Install the OpenShift CLI (oc).

  • Log in as a user with cluster-admin privileges.

Procedure

  1. Create the following SriovNetwork object, and then save the YAML in the <name>-sriov-network.yaml file. Replace <name> with a name for this additional network.
  1. apiVersion: sriovnetwork.openshift.io/v1
  2. kind: SriovNetwork
  3. metadata:
  4. name: <name> (1)
  5. namespace: openshift-sriov-network-operator (2)
  6. spec:
  7. resourceName: <sriov_resource_name> (3)
  8. networkNamespace: <target_namespace> (4)
  9. vlan: <vlan> (5)
  10. spoofChk: "<spoof_check>" (6)
  11. linkState: <link_state> (7)
  12. maxTxRate: <max_tx_rate> (8)
  13. minTxRate: <min_rx_rate> (9)
  14. vlanQoS: <vlan_qos> (10)
  15. trust: "<trust_vf>" (11)
  16. capabilities: <capabilities> (12)
1Replace <name> with a name for the object. The SR-IOV Network Operator creates a NetworkAttachmentDefinition object with same name.
2Specify the namespace where the SR-IOV Network Operator is installed.
3Replace <sriov_resource_name> with the value for the .spec.resourceName parameter from the SriovNetworkNodePolicy object that defines the SR-IOV hardware for this additional network.
4Replace <target_namespace> with the target namespace for the SriovNetwork. Only pods or virtual machines in the target namespace can attach to the SriovNetwork.
5Optional: Replace <vlan> with a Virtual LAN (VLAN) ID for the additional network. The integer value must be from 0 to 4095. The default value is 0.
6Optional: Replace <spoof_check> with the spoof check mode of the VF. The allowed values are the strings “on” and “off”.

You must enclose the value you specify in quotes or the CR is rejected by the SR-IOV Network Operator.

7Optional: Replace <link_state> with the link state of virtual function (VF). Allowed value are enable, disable and auto.
8Optional: Replace <max_tx_rate> with a maximum transmission rate, in Mbps, for the VF.
9Optional: Replace <min_tx_rate> with a minimum transmission rate, in Mbps, for the VF. This value should always be less than or equal to Maximum transmission rate.

Intel NICs do not support the minTxRate parameter. For more information, see BZ#1772847.

10Optional: Replace <vlan_qos> with an IEEE 802.1p priority level for the VF. The default value is 0.
11Optional: Replace <trust_vf> with the trust mode of the VF. The allowed values are the strings “on” and “off”.

You must enclose the value you specify in quotes or the CR is rejected by the SR-IOV Network Operator.

12Optional: Replace <capabilities> with the capabilities to configure for this network.
  1. To create the object, enter the following command. Replace <name> with a name for this additional network.

    1. $ oc create -f <name>-sriov-network.yaml
  2. Optional: To confirm that the NetworkAttachmentDefinition object associated with the SriovNetwork object that you created in the previous step exists, enter the following command. Replace <namespace> with the namespace you specified in the SriovNetwork object.

    1. $ oc get net-attach-def -n <namespace>

Next steps