Writing Device Drivers for Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

pci_param_get() Interface

SR-IOV drivers must use the pci_param_get(9F) interface to obtain the list of currently configured parameters. This interface is called during driver attachment or at any other appropriate time. The returned data, which is a pointer to the parameter list, contains the name-value information of both the PF and its corresponding VF devices.

int pci_param_get(dev_info_t *dip, pci_param_t *php)

where:

dip

A pointer to the dev_info structure

php

A pointer to param handle, pci_param_t

The device driver should perform the following steps to obtain the list of parameters of PF and VF after calling the pci_param_get interface:

  1. Call the pci_plist_get(9F) interface to obtain the list of parameters of the PF device and the pci_plist_getvf(9F) interface to obtain the list of parameters of the configured VFs.

  2. Call the pci_plist_lookup(9F) interface to obtain the device parameters.

  3. Validate all the PF and VF parameters

  4. If the parameters do not match the current configuration, the driver should fail the device attachment.

  5. Call the pci_param_free(9F) interface to free the pointer to the parameter handle obtaining the parameters for PF and the configured VF devices. See Example 21–2


Note - Validation of the parameters should be completed before the VFs are configured.

The name-value pairs are defined on a per–device basis. There is one set of name-value pairs for the PF and one set each for the configured VFs. The name-value pairs are optional and may be absent for any or all of the devices.

Example 21-2  SR-IOV pci_param_get(9F) Routine
	pci_param_t my_params;
pci_plist_t pf_plist;
pci_plist_t  vf_plist[8];
labelp = NULL;
rval = pci_param_get(dip,&my_params);
if (rval || (my_params == NULL)) {
   cmn_err(CE_NOTE, "No params available\n");
goto continue_with_attach;
}
rval = pci_plist_get(my_params, &pf_list);
if (rval || (pf_plist == NULL)) {
		cmn_err(CE_NOTE, "No params for PF \n");
goto continue_with_attach;
}
for (i = 0; i < 8; i++) {
    rval = pci_plist_getvf(my_params, i, &vf_plist[i]);
    if (rval || (vf_plist[i] == NULL)) {
     cmn_err(CE_WARN, "No params for VF %d\n", i);
     continue;
 }
}
pci_param_free(my_params);
/*
* Validate the PF and VF params lists.
* Fail the attach if the params are incompatible or exceed the
* resources available.
*/
continue_with_attach: