Writing Device Drivers for Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

pciv_vf_config() Interface

The pciv_vf_config(9F) interface is used by the SR-IOV drivers to obtain configuration info about the VFs and is also used to configure the VFs during the attachment of the driver.

#include <sys/sunddi.h>
int pciv_vf_config(dev_info_t *dip, pciv_config_vf_t *vfcfg_p)

where:

dip

A pointer to the dev_info structure.

vfcfg_p

A pointer to the pciv_config_vf structure.

typedef enum { 
                 PCIV_VFCFG_PARAM,
                 PCIV_VF_ENABLE,
						  PCIV_VF_DISABLE
                 PCIV_EVT_VFENABLE_PRE,
                 PCIV_EVT_VFENABLE_POST,
                 PCIV_EVT_VFDISABLE_PRE,
                 PCIV_EVT_VFDISABLE_POST
             } pciv_vf_config_cmd_t;

The pciv_config_vf structure contains the following fields:

typedef struct pciv_config_vf {
       		int version;
        		pciv_vf_config_cmd_t cmd;
        		uint16_t num_vf;
        		uint16_t first_vf_offset;
        		uint16_t vf_stride;
        		boolean_t ari_cap;
        		uint32_t page_size;
 	} pciv_config_vf_t;

where:

version

Version number.

cmd

Used to indicate whether this interface is called to obtain configuration information or to attach the VFs.

  • PCIV_VFCFG_PARAM – Obtain configuration information

  • PCIV_VF_ENABLE – Enable the VFs

    • PCIV_EVT_VFENABLE_PRE

    • PCIV_EVT_VFDISABLE_PRE

    • PCIV_EVT_VFENABLE_POST

    • PCIV_EVT_VFDISABLE_POST

num_vf

Number of VFs defined in the backend.

vf_stride

Distance between the VFs.

first_vf_offset

Offset between the first VF and PF.

ari_cap

ARI-capable hierarchy.

page_size

Specifies system page size.

The driver should first call the pciv_vfconfig() interface with the cmd field set to PCIV_VFCFG_PARAM to obtain the configuration information. The driver should then call this interface again with the cmd field set to PCIV_VF_ENABLE to configure the VFs.

The driver can return one of the following error codes:

DDI_SUCCESS

DDI_FAILURE

PCIV_REQRESET

PCIV_REQREATTACH

The driver does not have to register the callbacks with the DDI_CB_FLAG_SRIOV bit set before calling the pciv_vf_config() interface to enable the VFs. However in order to receive notifications when the VFs are unconfigured by the SR-IOV framework, the drivers must register callbacks with DDI_CB_FLAG_SRIOV bit set after the VFs are enabled. See Driver Callbacks for additional information.

All PF drivers that can support VFs should inform the PCIe framework of their capability by calling the ddi_cb_register(9F) with DDI_CB_FLAG_SRIOV flag set in the flags argument. The ddi_cb_register() function must be called in the driver's attach routine. If the PF device driver calls the pciv_vf_config() function to enable VFs in its attach routine, then the PF driver should call the ddi_cb_register() function after enabling the VFs.

The DDI_CB_FLAG_SRIOV flag is required by the framework to perform the following actions:

  • Indicate to the Sparc OVM agent that there is a device driver capable of supporting VFs. The Sparc OVM agent then will allow creation of VF devices. In the absence of this capability, the user will not be able to create VFs on Sparc platforms.

  • The framework will callback the PF driver before and after it disables the VFs. This will facilitate the PF driver to do its internal book keeping for VF support.