drivers/net/ethernet/intel/ixgbe/devlink/region.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ixgbe/devlink/region.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/ixgbe/devlink/region.c
Extension
.c
Size
8169 bytes
Lines
291
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Failed to acquire NVM semaphore");
			kvfree(nvm_data);
			return -EBUSY;
		}

		err = ixgbe_read_flat_nvm(hw, i * IXGBE_DEVLINK_READ_BLK_SIZE,
					  &read_sz, buf, read_shadow_ram);
		if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Failed to read RAM content");
			ixgbe_release_nvm(hw);
			kvfree(nvm_data);
			return -EIO;
		}

		ixgbe_release_nvm(hw);

		buf += read_sz;
		left -= read_sz;
	}

	*data = nvm_data;
	return 0;
}

/**
 * ixgbe_devlink_devcaps_snapshot - Capture a snapshot of device capabilities
 * @devlink: the devlink instance
 * @ops: the devlink region being snapshotted
 * @extack: extended ACK response structure
 * @data: on exit points to snapshot data buffer
 *
 * This function is called in response to the DEVLINK_CMD_REGION_NEW for
 * the device-caps devlink region.
 *
 * Capture a snapshot of the device capabilities reported by firmware.
 *
 * No need to worry with freeing @data, devlink core takes care if it.
 *
 * Return: 0 on success, -ENOMEM when cannot alloc mem, or return code of
 * the reading operation.
 */
static int ixgbe_devlink_devcaps_snapshot(struct devlink *devlink,
					  const struct devlink_region_ops *ops,
					  struct netlink_ext_ack *extack,
					  u8 **data)
{
	struct ixgbe_adapter *adapter = devlink_priv(devlink);
	struct ixgbe_aci_cmd_list_caps_elem *caps;
	struct ixgbe_hw *hw = &adapter->hw;
	int err;

	caps = kvzalloc(IXGBE_ACI_MAX_BUFFER_SIZE, GFP_KERNEL);
	if (!caps)
		return -ENOMEM;

	err = ixgbe_aci_list_caps(hw, caps, IXGBE_ACI_MAX_BUFFER_SIZE, NULL,
				  ixgbe_aci_opc_list_dev_caps);
	if (err) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Failed to read device capabilities");
		kvfree(caps);
		return err;
	}

	*data = (u8 *)caps;
	return 0;
}

/**
 * ixgbe_devlink_nvm_read - Read a portion of NVM flash content
 * @devlink: the devlink instance
 * @ops: the devlink region to snapshot
 * @extack: extended ACK response structure
 * @offset: the offset to start at
 * @size: the amount to read
 * @data: the data buffer to read into
 *
 * This function is called in response to DEVLINK_CMD_REGION_READ to directly
 * read a section of the NVM contents.
 *
 * Read from either the nvm-flash region either shadow-ram region.
 *
 * Return: 0 on success, -EOPNOTSUPP for unsupported regions, -EBUSY when
 * cannot lock NVM, -ERANGE when buffer limit exceeded and -EIO when error
 * occurs during reading.
 */
static int ixgbe_devlink_nvm_read(struct devlink *devlink,

Annotation

Implementation Notes