/** * ixgbe_devlink_nvm_snapshot - Capture a snapshot of the NVM content * @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 cmd. * * Capture a snapshot of the whole requested NVM region. * * No need to worry with freeing @data, devlink core takes care if it. * * Return: 0 on success, -EOPNOTSUPP for unsupported regions, -EBUSY when * cannot lock NVM, -ENOMEM when cannot alloc mem and -EIO when error * occurs during reading.
*/ staticint ixgbe_devlink_nvm_snapshot(struct devlink *devlink, conststruct devlink_region_ops *ops, struct netlink_ext_ack *extack, u8 **data)
{ struct ixgbe_adapter *adapter = devlink_priv(devlink); struct ixgbe_hw *hw = &adapter->hw; bool read_shadow_ram;
u8 *nvm_data, *buf;
u32 nvm_size, left;
u8 num_blks; int err;
err = ixgbe_devlink_parse_region(hw, ops, &read_shadow_ram, &nvm_size); if (err) return err;
nvm_data = kvzalloc(nvm_size, GFP_KERNEL); if (!nvm_data) return -ENOMEM;
num_blks = DIV_ROUND_UP(nvm_size, IXGBE_DEVLINK_READ_BLK_SIZE);
buf = nvm_data;
left = nvm_size;
for (int i = 0; i < num_blks; i++) {
u32 read_sz = min_t(u32, IXGBE_DEVLINK_READ_BLK_SIZE, left);
/* Need to acquire NVM lock during each loop run because the * total period of reading whole NVM is longer than the maximum * period the lock can be taken defined by the IXGBE_NVM_TIMEOUT.
*/
err = ixgbe_acquire_nvm(hw, LIBIE_AQC_RES_ACCESS_READ); 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.
*/ staticint ixgbe_devlink_devcaps_snapshot(struct devlink *devlink, conststruct 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.
*/ staticint ixgbe_devlink_nvm_read(struct devlink *devlink, conststruct devlink_region_ops *ops, struct netlink_ext_ack *extack,
u64 offset, u32 size, u8 *data)
{ struct ixgbe_adapter *adapter = devlink_priv(devlink); struct ixgbe_hw *hw = &adapter->hw; bool read_shadow_ram;
u32 nvm_size; int err;
err = ixgbe_devlink_parse_region(hw, ops, &read_shadow_ram, &nvm_size); if (err) return err;
if (offset + size > nvm_size) {
NL_SET_ERR_MSG_MOD(extack, "Cannot read beyond the region size"); return -ERANGE;
}
err = ixgbe_acquire_nvm(hw, LIBIE_AQC_RES_ACCESS_READ); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Failed to acquire NVM semaphore"); return -EBUSY;
}
err = ixgbe_read_flat_nvm(hw, (u32)offset, &size, data, read_shadow_ram); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Failed to read NVM contents");
ixgbe_release_nvm(hw); return -EIO;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.